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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 abstract class ClassWorld { | 7 abstract class ClassWorld { |
8 // TODO(johnniwinther): Refine this into a `BackendClasses` interface. | 8 // TODO(johnniwinther): Refine this into a `BackendClasses` interface. |
9 Backend get backend; | 9 Backend get backend; |
10 | 10 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if (x == objectClass) return false; | 141 if (x == objectClass) return false; |
142 while (x != null && x.hierarchyDepth >= y.hierarchyDepth) { | 142 while (x != null && x.hierarchyDepth >= y.hierarchyDepth) { |
143 if (x == y) return true; | 143 if (x == y) return true; |
144 x = x.superclass; | 144 x = x.superclass; |
145 } | 145 } |
146 return false; | 146 return false; |
147 } | 147 } |
148 | 148 |
149 /// Returns `true` if [cls] is instantiated. | 149 /// Returns `true` if [cls] is instantiated. |
150 bool isInstantiated(ClassElement cls) { | 150 bool isInstantiated(ClassElement cls) { |
151 return compiler.enqueuer.resolution.isLive(cls); | 151 return compiler.resolverWorld.isInstantiated(cls); |
152 } | 152 } |
153 | 153 |
154 /// Returns an iterable over the live classes that extend [cls] including | 154 /// Returns an iterable over the live classes that extend [cls] including |
155 /// [cls] itself. | 155 /// [cls] itself. |
156 Iterable<ClassElement> subclassesOf(ClassElement cls) { | 156 Iterable<ClassElement> subclassesOf(ClassElement cls) { |
157 Set<ClassElement> subclasses = _subclasses[cls.declaration]; | 157 Set<ClassElement> subclasses = _subclasses[cls.declaration]; |
158 if (subclasses == null) return const <ClassElement>[]; | 158 if (subclasses == null) return const <ClassElement>[]; |
159 assert(invariant(cls, isInstantiated(cls.declaration), | 159 assert(invariant(cls, isInstantiated(cls.declaration), |
160 message: 'Class $cls has not been instantiated.')); | 160 message: 'Class $cls has not been instantiated.')); |
161 return subclasses; | 161 return subclasses; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 typesImplementedBySubclassesOfCls.add(current.element); | 378 typesImplementedBySubclassesOfCls.add(current.element); |
379 } | 379 } |
380 superclass = superclass.superclass; | 380 superclass = superclass.superclass; |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 // Use the [:seenClasses:] set to include non-instantiated | 384 // Use the [:seenClasses:] set to include non-instantiated |
385 // classes: if the superclass of these classes require RTI, then | 385 // classes: if the superclass of these classes require RTI, then |
386 // they also need RTI, so that a constructor passes the type | 386 // they also need RTI, so that a constructor passes the type |
387 // variables to the super constructor. | 387 // variables to the super constructor. |
388 compiler.resolverWorld.allInstantiatedClasses.forEach(addSubtypes); | 388 compiler.resolverWorld.directlyInstantiatedClasses.forEach(addSubtypes); |
389 } | 389 } |
390 | 390 |
391 void registerMixinUse(MixinApplicationElement mixinApplication, | 391 void registerMixinUse(MixinApplicationElement mixinApplication, |
392 ClassElement mixin) { | 392 ClassElement mixin) { |
393 // TODO(johnniwinther): Add map restricted to live classes. | 393 // TODO(johnniwinther): Add map restricted to live classes. |
394 // We don't support patch classes as mixin. | 394 // We don't support patch classes as mixin. |
395 assert(mixin.isDeclaration); | 395 assert(mixin.isDeclaration); |
396 List<MixinApplicationElement> users = | 396 List<MixinApplicationElement> users = |
397 _mixinUses.putIfAbsent(mixin, () => | 397 _mixinUses.putIfAbsent(mixin, () => |
398 new List<MixinApplicationElement>()); | 398 new List<MixinApplicationElement>()); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // method of function classes that were generated for function | 516 // method of function classes that were generated for function |
517 // expressions. In such a case, we have to look at the original | 517 // expressions. In such a case, we have to look at the original |
518 // function expressions's element. | 518 // function expressions's element. |
519 // TODO(herhut): Generate classes for function expressions earlier. | 519 // TODO(herhut): Generate classes for function expressions earlier. |
520 if (element is closureMapping.SynthesizedCallMethodElementX) { | 520 if (element is closureMapping.SynthesizedCallMethodElementX) { |
521 return getMightBePassedToApply(element.expression); | 521 return getMightBePassedToApply(element.expression); |
522 } | 522 } |
523 return functionsThatMightBePassedToApply.contains(element); | 523 return functionsThatMightBePassedToApply.contains(element); |
524 } | 524 } |
525 } | 525 } |
OLD | NEW |