| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 closureToClassMapper; | 5 library closureToClassMapper; |
| 6 | 6 |
| 7 import 'common/names.dart' show Identifiers; | 7 import 'common/names.dart' show Identifiers; |
| 8 import 'common/resolution.dart' show ParsingContext, Resolution; | 8 import 'common/resolution.dart' show ParsingContext, Resolution; |
| 9 import 'common/tasks.dart' show CompilerTask; | 9 import 'common/tasks.dart' show CompilerTask; |
| 10 import 'common.dart'; | 10 import 'common.dart'; |
| 11 import 'compiler.dart' show Compiler; | 11 import 'compiler.dart' show Compiler; |
| 12 import 'constants/expressions.dart'; | 12 import 'constants/expressions.dart'; |
| 13 import 'elements/resolution_types.dart'; | |
| 14 import 'elements/elements.dart'; | 13 import 'elements/elements.dart'; |
| 15 import 'elements/entities.dart'; | 14 import 'elements/entities.dart'; |
| 16 import 'elements/entity_utils.dart' as utils; | 15 import 'elements/entity_utils.dart' as utils; |
| 17 import 'elements/modelx.dart' | 16 import 'elements/modelx.dart' |
| 18 show BaseFunctionElementX, ClassElementX, ElementX; | 17 show BaseFunctionElementX, ClassElementX, ElementX; |
| 18 import 'elements/resolution_types.dart'; |
| 19 import 'elements/types.dart'; |
| 19 import 'elements/visitor.dart' show ElementVisitor; | 20 import 'elements/visitor.dart' show ElementVisitor; |
| 20 import 'js_backend/js_backend.dart' show JavaScriptBackend; | 21 import 'js_backend/js_backend.dart' show JavaScriptBackend; |
| 21 import 'resolution/tree_elements.dart' show TreeElements; | 22 import 'resolution/tree_elements.dart' show TreeElements; |
| 22 import 'package:front_end/src/fasta/scanner.dart' show Token; | 23 import 'package:front_end/src/fasta/scanner.dart' show Token; |
| 23 import 'tree/tree.dart'; | 24 import 'tree/tree.dart'; |
| 24 import 'util/util.dart'; | 25 import 'util/util.dart'; |
| 25 import 'world.dart' show ClosedWorldRefiner; | 26 import 'world.dart' show ClosedWorldRefiner; |
| 26 | 27 |
| 27 abstract class ClosureClassMaps { | 28 abstract class ClosureClassMaps { |
| 28 ClosureClassMap getMemberMap(MemberEntity member); | 29 ClosureClassMap getMemberMap(MemberEntity member); |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 } | 761 } |
| 761 } else if (variable is LocalParameterElement && | 762 } else if (variable is LocalParameterElement && |
| 762 variable.functionDeclaration.asyncMarker == AsyncMarker.SYNC_STAR) { | 763 variable.functionDeclaration.asyncMarker == AsyncMarker.SYNC_STAR) { |
| 763 // Parameters in a sync* function are shared between each Iterator created | 764 // Parameters in a sync* function are shared between each Iterator created |
| 764 // by the Iterable returned by the function, therefore they must be boxed. | 765 // by the Iterable returned by the function, therefore they must be boxed. |
| 765 closureData.variablesUsedInTryOrGenerator.add(variable); | 766 closureData.variablesUsedInTryOrGenerator.add(variable); |
| 766 } | 767 } |
| 767 } | 768 } |
| 768 | 769 |
| 769 void useTypeVariableAsLocal(ResolutionTypeVariableType typeVariable) { | 770 void useTypeVariableAsLocal(ResolutionTypeVariableType typeVariable) { |
| 770 useLocal(new TypeVariableLocal(typeVariable, outermostElement)); | 771 useLocal(new TypeVariableLocal( |
| 772 typeVariable, outermostElement, outermostElement.memberContext)); |
| 771 } | 773 } |
| 772 | 774 |
| 773 void declareLocal(LocalVariableElement element) { | 775 void declareLocal(LocalVariableElement element) { |
| 774 scopeVariables.add(element); | 776 scopeVariables.add(element); |
| 775 } | 777 } |
| 776 | 778 |
| 777 void registerNeedsThis() { | 779 void registerNeedsThis() { |
| 778 if (closureData.thisLocal != null) { | 780 if (closureData.thisLocal != null) { |
| 779 useLocal(closureData.thisLocal); | 781 useLocal(closureData.thisLocal); |
| 780 } | 782 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 // An `await for` loop is enclosed in an implicit try-finally. | 1212 // An `await for` loop is enclosed in an implicit try-finally. |
| 1211 bool oldInTryStatement = inTryStatement; | 1213 bool oldInTryStatement = inTryStatement; |
| 1212 inTryStatement = true; | 1214 inTryStatement = true; |
| 1213 visitLoop(node); | 1215 visitLoop(node); |
| 1214 inTryStatement = oldInTryStatement; | 1216 inTryStatement = oldInTryStatement; |
| 1215 } | 1217 } |
| 1216 } | 1218 } |
| 1217 | 1219 |
| 1218 /// A type variable as a local variable. | 1220 /// A type variable as a local variable. |
| 1219 class TypeVariableLocal implements Local { | 1221 class TypeVariableLocal implements Local { |
| 1220 final ResolutionTypeVariableType typeVariable; | 1222 final TypeVariableType typeVariable; |
| 1221 final ExecutableElement executableContext; | 1223 final Entity executableContext; |
| 1224 final MemberEntity memberContext; |
| 1222 | 1225 |
| 1223 TypeVariableLocal(this.typeVariable, this.executableContext); | 1226 TypeVariableLocal( |
| 1227 this.typeVariable, this.executableContext, this.memberContext); |
| 1224 | 1228 |
| 1225 @override | 1229 String get name => typeVariable.element.name; |
| 1226 MemberElement get memberContext => executableContext.memberContext; | |
| 1227 | |
| 1228 String get name => typeVariable.name; | |
| 1229 | 1230 |
| 1230 int get hashCode => typeVariable.hashCode; | 1231 int get hashCode => typeVariable.hashCode; |
| 1231 | 1232 |
| 1232 bool operator ==(other) { | 1233 bool operator ==(other) { |
| 1233 if (other is! TypeVariableLocal) return false; | 1234 if (other is! TypeVariableLocal) return false; |
| 1234 return typeVariable == other.typeVariable; | 1235 return typeVariable == other.typeVariable; |
| 1235 } | 1236 } |
| 1236 } | 1237 } |
| 1237 | 1238 |
| 1238 /// | 1239 /// |
| 1239 /// Move the below classes to a JS model eventually. | 1240 /// Move the below classes to a JS model eventually. |
| 1240 /// | 1241 /// |
| 1241 abstract class JSEntity implements Entity { | 1242 abstract class JSEntity implements Entity { |
| 1242 Entity get declaredEntity; | 1243 Entity get declaredEntity; |
| 1243 } | 1244 } |
| 1244 | 1245 |
| 1245 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1246 abstract class PrivatelyNamedJSEntity implements JSEntity { |
| 1246 Entity get rootOfScope; | 1247 Entity get rootOfScope; |
| 1247 } | 1248 } |
| OLD | NEW |