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 dart2js.world; | 5 library dart2js.world; |
6 | 6 |
7 import 'cache_strategy.dart'; | 7 import 'cache_strategy.dart'; |
8 import 'closure.dart' show SynthesizedCallMethodElementX; | 8 import 'closure.dart' show SynthesizedCallMethodElementX; |
9 import 'common/backend_api.dart' show BackendClasses; | 9 import 'common/backend_api.dart' show BackendClasses; |
10 import 'common.dart'; | 10 import 'common.dart'; |
11 import 'core_types.dart' show CoreClasses; | 11 import 'core_types.dart' show CoreClasses; |
12 import 'dart_types.dart'; | 12 import 'dart_types.dart'; |
13 import 'elements/elements.dart' | 13 import 'elements/elements.dart' |
14 show | 14 show |
15 ClassElement, | 15 ClassElement, |
16 Element, | 16 Element, |
17 FunctionElement, | 17 FunctionElement, |
18 MixinApplicationElement, | 18 MixinApplicationElement, |
19 TypedefElement, | 19 TypedefElement, |
20 FieldElement; | 20 FieldElement; |
21 import 'js_backend/backend.dart' show JavaScriptBackend; | 21 import 'js_backend/backend.dart' show JavaScriptBackend; |
22 import 'ordered_typeset.dart'; | 22 import 'ordered_typeset.dart'; |
23 import 'types/masks.dart' show CommonMasks, FlatTypeMask, TypeMask; | 23 import 'types/masks.dart' show CommonMasks, FlatTypeMask, TypeMask; |
24 import 'universe/class_set.dart'; | 24 import 'universe/class_set.dart'; |
25 import 'universe/function_set.dart' show FunctionSet; | 25 import 'universe/function_set.dart' show FunctionSet; |
26 import 'universe/selector.dart' show Selector; | 26 import 'universe/selector.dart' show Selector; |
27 import 'universe/side_effects.dart' show SideEffects; | 27 import 'universe/side_effects.dart' show SideEffects; |
28 import 'universe/world_builder.dart' show ResolutionWorldBuilder; | 28 import 'universe/world_builder.dart' |
29 import 'util/enumset.dart'; | 29 show InstantiationInfo, ResolutionWorldBuilder; |
30 import 'util/util.dart' show Link; | 30 import 'util/util.dart' show Link; |
31 | 31 |
32 /// Common superinterface for [OpenWorld] and [ClosedWorld]. | 32 /// Common superinterface for [OpenWorld] and [ClosedWorld]. |
33 abstract class World {} | 33 abstract class World {} |
34 | 34 |
35 /// The [ClosedWorld] represents the information known about a program when | 35 /// The [ClosedWorld] represents the information known about a program when |
36 /// compiling with closed-world semantics. | 36 /// compiling with closed-world semantics. |
37 /// | 37 /// |
38 /// Given the entrypoint of an application, we can track what's reachable from | 38 /// Given the entrypoint of an application, we can track what's reachable from |
39 /// it, what functions are called, what classes are allocated, which native | 39 /// it, what functions are called, what classes are allocated, which native |
(...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 } | 1000 } |
1001 if (abstractlyInstantiated) { | 1001 if (abstractlyInstantiated) { |
1002 node.isAbstractlyInstantiated = true; | 1002 node.isAbstractlyInstantiated = true; |
1003 } | 1003 } |
1004 } | 1004 } |
1005 | 1005 |
1006 ClosedWorld closeWorld(DiagnosticReporter reporter) { | 1006 ClosedWorld closeWorld(DiagnosticReporter reporter) { |
1007 /// Updates the `isDirectlyInstantiated` and `isIndirectlyInstantiated` | 1007 /// Updates the `isDirectlyInstantiated` and `isIndirectlyInstantiated` |
1008 /// properties of the [ClassHierarchyNode] for [cls]. | 1008 /// properties of the [ClassHierarchyNode] for [cls]. |
1009 | 1009 |
1010 void addSubtypes(ClassElement cls, EnumSet<Instantiation> instantiations) { | 1010 void addSubtypes(ClassElement cls, InstantiationInfo info) { |
| 1011 if (!info.hasInstantiation) { |
| 1012 return; |
| 1013 } |
1011 if (cacheStrategy.hasIncrementalSupport && !alreadyPopulated.add(cls)) { | 1014 if (cacheStrategy.hasIncrementalSupport && !alreadyPopulated.add(cls)) { |
1012 return; | 1015 return; |
1013 } | 1016 } |
1014 assert(cls.isDeclaration); | 1017 assert(cls.isDeclaration); |
1015 if (!cls.isResolved) { | 1018 if (!cls.isResolved) { |
1016 reporter.internalError(cls, 'Class "${cls.name}" is not resolved.'); | 1019 reporter.internalError(cls, 'Class "${cls.name}" is not resolved.'); |
1017 } | 1020 } |
1018 | 1021 |
1019 _updateClassHierarchyNodeForClass(cls, | 1022 _updateClassHierarchyNodeForClass(cls, |
1020 directlyInstantiated: | 1023 directlyInstantiated: info.isDirectlyInstantiated, |
1021 instantiations.contains(Instantiation.DIRECTLY_INSTANTIATED), | 1024 abstractlyInstantiated: info.isAbstractlyInstantiated); |
1022 abstractlyInstantiated: | |
1023 instantiations.contains(Instantiation.ABSTRACTLY_INSTANTIATED)); | |
1024 | 1025 |
1025 // Walk through the superclasses, and record the types | 1026 // Walk through the superclasses, and record the types |
1026 // implemented by that type on the superclasses. | 1027 // implemented by that type on the superclasses. |
1027 ClassElement superclass = cls.superclass; | 1028 ClassElement superclass = cls.superclass; |
1028 while (superclass != null) { | 1029 while (superclass != null) { |
1029 Set<Element> typesImplementedBySubclassesOfCls = | 1030 Set<Element> typesImplementedBySubclassesOfCls = |
1030 _typesImplementedBySubclasses.putIfAbsent( | 1031 _typesImplementedBySubclasses.putIfAbsent( |
1031 superclass, () => new Set<ClassElement>()); | 1032 superclass, () => new Set<ClassElement>()); |
1032 for (DartType current in cls.allSupertypes) { | 1033 for (DartType current in cls.allSupertypes) { |
1033 typesImplementedBySubclassesOfCls.add(current.element); | 1034 typesImplementedBySubclassesOfCls.add(current.element); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 /// Only the class itself is included. | 1219 /// Only the class itself is included. |
1219 EXACT, | 1220 EXACT, |
1220 | 1221 |
1221 /// The class and all subclasses (transitively) are included. | 1222 /// The class and all subclasses (transitively) are included. |
1222 SUBCLASS, | 1223 SUBCLASS, |
1223 | 1224 |
1224 /// The class and all classes that implement or subclass it (transitively) | 1225 /// The class and all classes that implement or subclass it (transitively) |
1225 /// are included. | 1226 /// are included. |
1226 SUBTYPE, | 1227 SUBTYPE, |
1227 } | 1228 } |
OLD | NEW |