| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Analysis to determine how to generate code for typed JavaScript interop. | 5 /// Analysis to determine how to generate code for typed JavaScript interop. |
| 6 library compiler.src.js_backend.js_interop_analysis; | 6 library compiler.src.js_backend.js_interop_analysis; |
| 7 | 7 |
| 8 import '../elements/resolution_types.dart' | 8 import '../elements/resolution_types.dart' |
| 9 show ResolutionDartType, ResolutionDynamicType, ResolutionFunctionType; | 9 show ResolutionDartType, ResolutionDynamicType, ResolutionFunctionType; |
| 10 import '../js/js.dart' as jsAst; | 10 import '../js/js.dart' as jsAst; |
| 11 import '../js/js.dart' show js; | 11 import '../js/js.dart' show js; |
| 12 import '../universe/selector.dart' show Selector; | 12 import '../universe/selector.dart' show Selector; |
| 13 import '../universe/world_builder.dart' show SelectorConstraints; | 13 import '../universe/world_builder.dart' show SelectorConstraints; |
| 14 import 'js_backend.dart' show JavaScriptBackend; | 14 import 'js_backend.dart' show JavaScriptBackend; |
| 15 | 15 |
| 16 class JsInteropAnalysis { | 16 class JsInteropAnalysis { |
| 17 final JavaScriptBackend backend; | 17 final JavaScriptBackend backend; |
| 18 | 18 |
| 19 JsInteropAnalysis(this.backend); | 19 JsInteropAnalysis(this.backend); |
| 20 | 20 |
| 21 jsAst.Statement buildJsInteropBootstrap() { | 21 jsAst.Statement buildJsInteropBootstrap() { |
| 22 if (!backend.nativeBasicData.isJsInteropUsed) return null; | 22 if (!backend.compiler.frontendStrategy.nativeBasicData.isJsInteropUsed) |
| 23 return null; |
| 23 List<jsAst.Statement> statements = <jsAst.Statement>[]; | 24 List<jsAst.Statement> statements = <jsAst.Statement>[]; |
| 24 backend.compiler.codegenWorldBuilder.forEachInvokedName( | 25 backend.compiler.codegenWorldBuilder.forEachInvokedName( |
| 25 (String name, Map<Selector, SelectorConstraints> selectors) { | 26 (String name, Map<Selector, SelectorConstraints> selectors) { |
| 26 selectors.forEach((Selector selector, SelectorConstraints constraints) { | 27 selectors.forEach((Selector selector, SelectorConstraints constraints) { |
| 27 if (selector.isClosureCall) { | 28 if (selector.isClosureCall) { |
| 28 // TODO(jacobr): support named arguments. | 29 // TODO(jacobr): support named arguments. |
| 29 if (selector.namedArgumentCount > 0) return; | 30 if (selector.namedArgumentCount > 0) return; |
| 30 int argumentCount = selector.argumentCount; | 31 int argumentCount = selector.argumentCount; |
| 31 var candidateParameterNames = | 32 var candidateParameterNames = |
| 32 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | 33 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 ResolutionFunctionType buildJsFunctionType() { | 47 ResolutionFunctionType buildJsFunctionType() { |
| 47 // TODO(jacobr): consider using codegenWorldBuilder.isChecks to determine th
e | 48 // TODO(jacobr): consider using codegenWorldBuilder.isChecks to determine th
e |
| 48 // range of positional arguments that need to be supported by JavaScript | 49 // range of positional arguments that need to be supported by JavaScript |
| 49 // function types. | 50 // function types. |
| 50 return new ResolutionFunctionType.synthesized( | 51 return new ResolutionFunctionType.synthesized( |
| 51 const ResolutionDynamicType(), | 52 const ResolutionDynamicType(), |
| 52 [], | 53 [], |
| 53 new List<ResolutionDartType>.filled(16, const ResolutionDynamicType())); | 54 new List<ResolutionDartType>.filled(16, const ResolutionDynamicType())); |
| 54 } | 55 } |
| 55 } | 56 } |
| OLD | NEW |