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; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2019 FunctionEntity callMethod = cls.callMethod = new JClosureCallMethod( | 2019 FunctionEntity callMethod = cls.callMethod = new JClosureCallMethod( |
2020 _memberData.length, | 2020 _memberData.length, |
2021 cls, | 2021 cls, |
2022 _getParameterStructure(node), | 2022 _getParameterStructure(node), |
2023 _getAsyncMarker(node)); | 2023 _getAsyncMarker(node)); |
2024 _memberList.add(cls.callMethod); | 2024 _memberList.add(cls.callMethod); |
2025 | 2025 |
2026 _memberData.add(new ClosureFunctionData( | 2026 _memberData.add(new ClosureFunctionData( |
2027 new ClosureMemberDefinition(callMethod, closureData.definition.location, | 2027 new ClosureMemberDefinition(callMethod, closureData.definition.location, |
2028 MemberKind.closureCall, node.parent), | 2028 MemberKind.closureCall, node.parent), |
2029 getFunctionType(node))); | 2029 getFunctionType(node), |
| 2030 node)); |
2030 memberMap[cls.callMethod.name] = cls.callMethod; | 2031 memberMap[cls.callMethod.name] = cls.callMethod; |
2031 return cls; | 2032 return cls; |
2032 } | 2033 } |
2033 | 2034 |
2034 _constructClosureFields( | 2035 _constructClosureFields( |
2035 MemberEntity member, | 2036 MemberEntity member, |
2036 KernelClosureClass cls, | 2037 KernelClosureClass cls, |
2037 Map<String, MemberEntity> memberMap, | 2038 Map<String, MemberEntity> memberMap, |
2038 ir.VariableDeclaration variable, | 2039 ir.VariableDeclaration variable, |
2039 int fieldNumber, | 2040 int fieldNumber, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 parts.add('closure'); | 2088 parts.add('closure'); |
2088 } | 2089 } |
2089 ir.TreeNode node = treeNode.parent; | 2090 ir.TreeNode node = treeNode.parent; |
2090 while (node != null) { | 2091 while (node != null) { |
2091 // TODO(johnniwinther): Simplify computed names. | 2092 // TODO(johnniwinther): Simplify computed names. |
2092 if (node is ir.Constructor || | 2093 if (node is ir.Constructor || |
2093 node.parent is ir.Constructor || | 2094 node.parent is ir.Constructor || |
2094 (node is ir.Procedure && node.kind == ir.ProcedureKind.Factory)) { | 2095 (node is ir.Procedure && node.kind == ir.ProcedureKind.Factory)) { |
2095 FunctionEntity entity; | 2096 FunctionEntity entity; |
2096 if (node.parent is ir.Constructor) { | 2097 if (node.parent is ir.Constructor) { |
2097 entity = getConstructorBody(node); | 2098 entity = getConstructorBody(node.parent); |
2098 } else { | 2099 } else { |
2099 entity = getMember(node); | 2100 entity = getMember(node); |
2100 } | 2101 } |
2101 parts.add(utils.reconstructConstructorName(entity)); | 2102 parts.add(utils.reconstructConstructorName(entity)); |
2102 } else { | 2103 } else { |
2103 if (node is ir.Class) { | 2104 if (node is ir.Class) { |
2104 parts.add(Elements.operatorNameToIdentifier(node.name)); | 2105 parts.add(Elements.operatorNameToIdentifier(node.name)); |
2105 } else if (node is ir.Procedure) { | 2106 } else if (node is ir.Procedure) { |
2106 parts.add(Elements.operatorNameToIdentifier(node.name.name)); | 2107 parts.add(Elements.operatorNameToIdentifier(node.name.name)); |
2107 } | 2108 } |
(...skipping 18 matching lines...) Expand all Loading... |
2126 /// | 2127 /// |
2127 /// These names are not used in generated code, just as element name. | 2128 /// These names are not used in generated code, just as element name. |
2128 String _getClosureVariableName(String name, int id) { | 2129 String _getClosureVariableName(String name, int id) { |
2129 return "_captured_${name}_$id"; | 2130 return "_captured_${name}_$id"; |
2130 } | 2131 } |
2131 | 2132 |
2132 String getDeferredUri(ir.LibraryDependency node) { | 2133 String getDeferredUri(ir.LibraryDependency node) { |
2133 throw new UnimplementedError('JsKernelToElementMap.getDeferredUri'); | 2134 throw new UnimplementedError('JsKernelToElementMap.getDeferredUri'); |
2134 } | 2135 } |
2135 } | 2136 } |
OLD | NEW |