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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 ClosureClassMap closureClassMap = _closureMappingCache[element]; | 44 ClosureClassMap closureClassMap = _closureMappingCache[element]; |
45 assert(invariant(resolvedAst.element, closureClassMap != null, | 45 assert(invariant(resolvedAst.element, closureClassMap != null, |
46 message: "No ClosureClassMap computed for ${element}.")); | 46 message: "No ClosureClassMap computed for ${element}.")); |
47 return closureClassMap; | 47 return closureClassMap; |
48 }); | 48 }); |
49 } | 49 } |
50 | 50 |
51 /// Create [ClosureClassMap]s for all live members. | 51 /// Create [ClosureClassMap]s for all live members. |
52 void createClosureClasses() { | 52 void createClosureClasses() { |
53 compiler.enqueuer.resolution.processedElements | 53 compiler.enqueuer.resolution.processedEntities |
54 .forEach((AstElement element) { | 54 .forEach((AstElement element) { |
55 ResolvedAst resolvedAst = element.resolvedAst; | 55 ResolvedAst resolvedAst = element.resolvedAst; |
56 if (element.isAbstract) return; | 56 if (element.isAbstract) return; |
57 if (element.isField && | 57 if (element.isField && |
58 !element.isInstanceMember && | 58 !element.isInstanceMember && |
59 resolvedAst.body == null) { | 59 resolvedAst.body == null) { |
60 // Skip top-level/static fields without an initializer. | 60 // Skip top-level/static fields without an initializer. |
61 return; | 61 return; |
62 } | 62 } |
63 computeClosureToClassMapping(resolvedAst); | 63 computeClosureToClassMapping(resolvedAst); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 void forgetElement(var closure) { | 114 void forgetElement(var closure) { |
115 ClosureClassElement cls; | 115 ClosureClassElement cls; |
116 if (closure is ClosureFieldElement) { | 116 if (closure is ClosureFieldElement) { |
117 cls = closure.closureClass; | 117 cls = closure.closureClass; |
118 } else if (closure is SynthesizedCallMethodElementX) { | 118 } else if (closure is SynthesizedCallMethodElementX) { |
119 cls = closure.closureClass; | 119 cls = closure.closureClass; |
120 } else { | 120 } else { |
121 throw new SpannableAssertionFailure( | 121 throw new SpannableAssertionFailure( |
122 closure, 'Not a closure: $closure (${closure.runtimeType}).'); | 122 closure, 'Not a closure: $closure (${closure.runtimeType}).'); |
123 } | 123 } |
124 compiler.enqueuer.codegen.forgetElement(cls, compiler); | 124 compiler.enqueuer.codegen.forgetEntity(cls, compiler); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 /// Common interface for [BoxFieldElement] and [ClosureFieldElement] as | 128 /// Common interface for [BoxFieldElement] and [ClosureFieldElement] as |
129 /// non-elements. | 129 /// non-elements. |
130 // TODO(johnniwinther): Remove `implements Element`. | 130 // TODO(johnniwinther): Remove `implements Element`. |
131 abstract class CapturedVariable implements Element {} | 131 abstract class CapturedVariable implements Element {} |
132 | 132 |
133 // TODO(ahe): These classes continuously cause problems. We need to | 133 // TODO(ahe): These classes continuously cause problems. We need to |
134 // find a more general solution. | 134 // find a more general solution. |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 /// | 1208 /// |
1209 /// Move the below classes to a JS model eventually. | 1209 /// Move the below classes to a JS model eventually. |
1210 /// | 1210 /// |
1211 abstract class JSEntity implements Entity { | 1211 abstract class JSEntity implements Entity { |
1212 Entity get declaredEntity; | 1212 Entity get declaredEntity; |
1213 } | 1213 } |
1214 | 1214 |
1215 abstract class PrivatelyNamedJSEntity implements JSEntity { | 1215 abstract class PrivatelyNamedJSEntity implements JSEntity { |
1216 Entity get rootOfScope; | 1216 Entity get rootOfScope; |
1217 } | 1217 } |
OLD | NEW |