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'; |
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 } | 1047 } |
1048 | 1048 |
1049 JavaScriptBackend get backend => compiler.backend; | 1049 JavaScriptBackend get backend => compiler.backend; |
1050 | 1050 |
1051 ClosureClassMap globalizeClosure( | 1051 ClosureClassMap globalizeClosure( |
1052 FunctionExpression node, LocalFunctionElement element) { | 1052 FunctionExpression node, LocalFunctionElement element) { |
1053 String closureName = computeClosureName(element); | 1053 String closureName = computeClosureName(element); |
1054 ClosureClassElement globalizedElement = | 1054 ClosureClassElement globalizedElement = |
1055 new ClosureClassElement(node, closureName, compiler, element); | 1055 new ClosureClassElement(node, closureName, compiler, element); |
1056 // Extend [globalizedElement] as an instantiated class in the closed world. | 1056 // Extend [globalizedElement] as an instantiated class in the closed world. |
1057 compiler.world | 1057 compiler.inferenceWorld.registerClosureClass(globalizedElement); |
1058 .registerClass(globalizedElement, isDirectlyInstantiated: true); | |
1059 FunctionElement callElement = new SynthesizedCallMethodElementX( | 1058 FunctionElement callElement = new SynthesizedCallMethodElementX( |
1060 Identifiers.call, element, globalizedElement, node, elements); | 1059 Identifiers.call, element, globalizedElement, node, elements); |
1061 backend.maybeMarkClosureAsNeededForReflection( | 1060 backend.maybeMarkClosureAsNeededForReflection( |
1062 globalizedElement, callElement, element); | 1061 globalizedElement, callElement, element); |
1063 MemberElement enclosing = element.memberContext; | 1062 MemberElement enclosing = element.memberContext; |
1064 enclosing.nestedClosures.add(callElement); | 1063 enclosing.nestedClosures.add(callElement); |
1065 globalizedElement.addMember(callElement, reporter); | 1064 globalizedElement.addMember(callElement, reporter); |
1066 globalizedElement.computeAllClassMembers(compiler.resolution); | 1065 globalizedElement.computeAllClassMembers(compiler.resolution); |
1067 // The nested function's 'this' is the same as the one for the outer | 1066 // The nested function's 'this' is the same as the one for the outer |
1068 // function. It could be [null] if we are inside a static method. | 1067 // function. It could be [null] if we are inside a static method. |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 /// | 1191 /// |
1193 /// Move the below classes to a JS model eventually. | 1192 /// Move the below classes to a JS model eventually. |
1194 /// | 1193 /// |
1195 abstract class JSEntity implements Entity { | 1194 abstract class JSEntity implements Entity { |
1196 Entity get declaredEntity; | 1195 Entity get declaredEntity; |
1197 } | 1196 } |
1198 | 1197 |
1199 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1198 abstract class PrivatelyNamedJSEntity implements JSEntity { |
1200 Entity get rootOfScope; | 1199 Entity get rootOfScope; |
1201 } | 1200 } |
OLD | NEW |