| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 library dart2js.kernel.element_map; | 5 library dart2js.kernel.element_map; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import '../closure.dart' show BoxLocal; | 9 import '../closure.dart' show BoxLocal, ThisLocal; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| 11 import '../common/names.dart' show Identifiers; | 11 import '../common/names.dart' show Identifiers; |
| 12 import '../common/resolution.dart'; | 12 import '../common/resolution.dart'; |
| 13 import '../compile_time_constants.dart'; | 13 import '../compile_time_constants.dart'; |
| 14 import '../constants/constant_system.dart'; | 14 import '../constants/constant_system.dart'; |
| 15 import '../constants/constructors.dart'; | 15 import '../constants/constructors.dart'; |
| 16 import '../constants/evaluation.dart'; | 16 import '../constants/evaluation.dart'; |
| 17 import '../constants/expressions.dart'; | 17 import '../constants/expressions.dart'; |
| 18 import '../constants/values.dart'; | 18 import '../constants/values.dart'; |
| 19 import '../common_elements.dart'; | 19 import '../common_elements.dart'; |
| 20 import '../elements/elements.dart'; | 20 import '../elements/elements.dart'; |
| 21 import '../elements/entities.dart'; | 21 import '../elements/entities.dart'; |
| 22 import '../elements/entity_utils.dart' as utils; | 22 import '../elements/entity_utils.dart' as utils; |
| 23 import '../elements/names.dart'; | 23 import '../elements/names.dart'; |
| 24 import '../elements/types.dart'; | 24 import '../elements/types.dart'; |
| 25 import '../environment.dart'; | 25 import '../environment.dart'; |
| 26 import '../frontend_strategy.dart'; | 26 import '../frontend_strategy.dart'; |
| 27 import '../js_backend/backend_usage.dart'; | 27 import '../js_backend/backend_usage.dart'; |
| 28 import '../js_backend/constant_system_javascript.dart'; | 28 import '../js_backend/constant_system_javascript.dart'; |
| 29 import '../js_backend/interceptor_data.dart'; | 29 import '../js_backend/interceptor_data.dart'; |
| 30 import '../js_backend/native_data.dart'; | 30 import '../js_backend/native_data.dart'; |
| 31 import '../js_backend/no_such_method_registry.dart'; | 31 import '../js_backend/no_such_method_registry.dart'; |
| 32 import '../js_backend/runtime_types.dart'; | 32 import '../js_backend/runtime_types.dart'; |
| 33 import '../js_model/closure.dart'; | 33 import '../js_model/closure.dart'; |
| 34 import '../js_model/elements.dart'; | 34 import '../js_model/elements.dart'; |
| 35 import '../js_model/locals.dart'; |
| 35 import '../native/enqueue.dart'; | 36 import '../native/enqueue.dart'; |
| 36 import '../native/native.dart' as native; | 37 import '../native/native.dart' as native; |
| 37 import '../native/resolver.dart'; | 38 import '../native/resolver.dart'; |
| 38 import '../ordered_typeset.dart'; | 39 import '../ordered_typeset.dart'; |
| 39 import '../options.dart'; | 40 import '../options.dart'; |
| 40 import '../ssa/kernel_impact.dart'; | 41 import '../ssa/kernel_impact.dart'; |
| 41 import '../universe/class_set.dart'; | 42 import '../universe/class_set.dart'; |
| 42 import '../universe/selector.dart'; | 43 import '../universe/selector.dart'; |
| 43 import '../universe/world_builder.dart'; | 44 import '../universe/world_builder.dart'; |
| 44 import '../world.dart'; | 45 import '../world.dart'; |
| (...skipping 2147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2192 ..isMixinApplication = false | 2193 ..isMixinApplication = false |
| 2193 ..thisType = closureData.rawType = | 2194 ..thisType = closureData.rawType = |
| 2194 new InterfaceType(classEntity, const <DartType>[]) | 2195 new InterfaceType(classEntity, const <DartType>[]) |
| 2195 ..supertype = supertype | 2196 ..supertype = supertype |
| 2196 ..interfaces = const <InterfaceType>[]; | 2197 ..interfaces = const <InterfaceType>[]; |
| 2197 var setBuilder = new _KernelOrderedTypeSetBuilder(this, classEntity); | 2198 var setBuilder = new _KernelOrderedTypeSetBuilder(this, classEntity); |
| 2198 _classData.add(closureData); | 2199 _classData.add(closureData); |
| 2199 closureData.orderedTypeSet = setBuilder.createOrderedTypeSet( | 2200 closureData.orderedTypeSet = setBuilder.createOrderedTypeSet( |
| 2200 closureData.supertype, const Link<InterfaceType>()); | 2201 closureData.supertype, const Link<InterfaceType>()); |
| 2201 | 2202 |
| 2203 Local closureEntity; |
| 2204 if (node.parent is ir.FunctionDeclaration) { |
| 2205 ir.FunctionDeclaration parent = node.parent; |
| 2206 closureEntity = localsMap.getLocalVariable(parent.variable); |
| 2207 } else if (node.parent is ir.FunctionExpression) { |
| 2208 closureEntity = new JLocal('', localsMap.currentMember); |
| 2209 } |
| 2210 Local thisLocal = |
| 2211 info.hasThisLocal ? new ThisLocal(localsMap.currentMember) : null; |
| 2212 |
| 2202 KernelClosureClass cls = new KernelClosureClass.fromScopeInfo( | 2213 KernelClosureClass cls = new KernelClosureClass.fromScopeInfo( |
| 2203 classEntity, node, info, localsMap); | 2214 classEntity, node, info, localsMap, closureEntity, thisLocal); |
| 2204 int i = 0; | 2215 int i = 0; |
| 2205 for (ir.VariableDeclaration variable in info.freeVariables) { | 2216 for (ir.VariableDeclaration variable in info.freeVariables) { |
| 2206 // Make a corresponding field entity in this closure class for every | 2217 // Make a corresponding field entity in this closure class for every |
| 2207 // single freeVariable in the KernelScopeInfo.freeVariable. | 2218 // single freeVariable in the KernelScopeInfo.freeVariable. |
| 2208 _constructClosureFields(member, cls, memberMap, variable, i, | 2219 _constructClosureFields(member, cls, memberMap, variable, i, |
| 2209 info.capturedVariablesAccessor, localsMap); | 2220 info.capturedVariablesAccessor, localsMap); |
| 2210 i++; | 2221 i++; |
| 2211 } | 2222 } |
| 2212 | 2223 |
| 2213 FunctionEntity callMethod = cls.callMethod = new JClosureCallMethod( | 2224 FunctionEntity callMethod = cls.callMethod = new JClosureCallMethod( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 /// | 2332 /// |
| 2322 /// These names are not used in generated code, just as element name. | 2333 /// These names are not used in generated code, just as element name. |
| 2323 String _getClosureVariableName(String name, int id) { | 2334 String _getClosureVariableName(String name, int id) { |
| 2324 return "_captured_${name}_$id"; | 2335 return "_captured_${name}_$id"; |
| 2325 } | 2336 } |
| 2326 | 2337 |
| 2327 String getDeferredUri(ir.LibraryDependency node) { | 2338 String getDeferredUri(ir.LibraryDependency node) { |
| 2328 throw new UnimplementedError('JsKernelToElementMap.getDeferredUri'); | 2339 throw new UnimplementedError('JsKernelToElementMap.getDeferredUri'); |
| 2329 } | 2340 } |
| 2330 } | 2341 } |
| OLD | NEW |