| 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, ThisLocal; | 9 import '../closure.dart' show BoxLocal, ThisLocal; |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 2232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2243 Map<String, MemberEntity> memberMap, | 2243 Map<String, MemberEntity> memberMap, |
| 2244 ir.VariableDeclaration variable, | 2244 ir.VariableDeclaration variable, |
| 2245 int fieldNumber, | 2245 int fieldNumber, |
| 2246 NodeBox box, | 2246 NodeBox box, |
| 2247 KernelToLocalsMap localsMap) { | 2247 KernelToLocalsMap localsMap) { |
| 2248 // NOTE: This construction order may be slightly different than the | 2248 // NOTE: This construction order may be slightly different than the |
| 2249 // old Element version. The old version did all the boxed items and then | 2249 // old Element version. The old version did all the boxed items and then |
| 2250 // all the others. | 2250 // all the others. |
| 2251 Local capturedLocal = localsMap.getLocalVariable(variable); | 2251 Local capturedLocal = localsMap.getLocalVariable(variable); |
| 2252 if (cls.isBoxed(capturedLocal)) { | 2252 if (cls.isBoxed(capturedLocal)) { |
| 2253 FieldEntity boxedField = new JBoxedField( | 2253 FieldEntity boxedField = new JRecord( |
| 2254 _getClosureVariableName(capturedLocal.name, fieldNumber), | 2254 _getClosureVariableName(capturedLocal.name, fieldNumber), |
| 2255 _memberData.length, | 2255 _memberData.length, |
| 2256 new BoxLocal(box.name, | 2256 new BoxLocal(box.name, |
| 2257 localsMap.getLocalVariable(box.executableContext), member), | 2257 localsMap.getLocalVariable(box.executableContext), member), |
| 2258 cls.closureClassEntity, | 2258 cls.closureClassEntity, |
| 2259 variable.isConst, | 2259 variable.isConst); |
| 2260 variable.isFinal || variable.isConst); | |
| 2261 cls.localToFieldMap[capturedLocal] = boxedField; | 2260 cls.localToFieldMap[capturedLocal] = boxedField; |
| 2262 _memberList.add(boxedField); | 2261 _memberList.add(boxedField); |
| 2263 _memberData.add(new ClosureFieldData(new ClosureMemberDefinition( | 2262 _memberData.add(new ClosureFieldData(new ClosureMemberDefinition( |
| 2264 boxedField, | 2263 boxedField, |
| 2265 computeSourceSpanFromTreeNode(variable), | 2264 computeSourceSpanFromTreeNode(variable), |
| 2266 MemberKind.closureField, | 2265 MemberKind.closureField, |
| 2267 variable))); | 2266 variable))); |
| 2268 memberMap[boxedField.name] = boxedField; | 2267 memberMap[boxedField.name] = boxedField; |
| 2269 } else { | 2268 } else { |
| 2270 FieldEntity closureField = new JClosureField( | 2269 FieldEntity closureField = new JClosureField( |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 /// | 2331 /// |
| 2333 /// These names are not used in generated code, just as element name. | 2332 /// These names are not used in generated code, just as element name. |
| 2334 String _getClosureVariableName(String name, int id) { | 2333 String _getClosureVariableName(String name, int id) { |
| 2335 return "_captured_${name}_$id"; | 2334 return "_captured_${name}_$id"; |
| 2336 } | 2335 } |
| 2337 | 2336 |
| 2338 String getDeferredUri(ir.LibraryDependency node) { | 2337 String getDeferredUri(ir.LibraryDependency node) { |
| 2339 throw new UnimplementedError('JsKernelToElementMap.getDeferredUri'); | 2338 throw new UnimplementedError('JsKernelToElementMap.getDeferredUri'); |
| 2340 } | 2339 } |
| 2341 } | 2340 } |
| OLD | NEW |