| 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 'closure.dart' show | 7 import 'closure.dart' show |
| 8 SynthesizedCallMethodElementX; | 8 SynthesizedCallMethodElementX; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'common/backend_api.dart' show | 10 import 'common/backend_api.dart' show |
| 11 Backend; | 11 Backend; |
| 12 import 'compiler.dart' show | 12 import 'compiler.dart' show |
| 13 Compiler; | 13 Compiler; |
| 14 import 'core_types.dart' show |
| 15 CoreClasses; |
| 14 import 'dart_types.dart'; | 16 import 'dart_types.dart'; |
| 15 import 'elements/elements.dart' show | 17 import 'elements/elements.dart' show |
| 16 ClassElement, | 18 ClassElement, |
| 17 Element, | 19 Element, |
| 18 FunctionElement, | 20 FunctionElement, |
| 19 MixinApplicationElement, | 21 MixinApplicationElement, |
| 20 TypedefElement, | 22 TypedefElement, |
| 21 VariableElement; | 23 VariableElement; |
| 22 import 'ordered_typeset.dart'; | 24 import 'ordered_typeset.dart'; |
| 23 import 'types/types.dart' as ti; | 25 import 'types/types.dart' as ti; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 /// incremental compilation isn't enabled. | 130 /// incremental compilation isn't enabled. |
| 129 bool get hasClosedWorldAssumption; | 131 bool get hasClosedWorldAssumption; |
| 130 | 132 |
| 131 /// Returns a string representation of the closed world. | 133 /// Returns a string representation of the closed world. |
| 132 /// | 134 /// |
| 133 /// If [cls] is provided, the dump will contain only classes related to [cls]. | 135 /// If [cls] is provided, the dump will contain only classes related to [cls]. |
| 134 String dump([ClassElement cls]); | 136 String dump([ClassElement cls]); |
| 135 } | 137 } |
| 136 | 138 |
| 137 class World implements ClassWorld { | 139 class World implements ClassWorld { |
| 138 ClassElement get objectClass => compiler.objectClass; | 140 ClassElement get objectClass => coreClasses.objectClass; |
| 139 ClassElement get functionClass => compiler.functionClass; | 141 ClassElement get functionClass => coreClasses.functionClass; |
| 140 ClassElement get boolClass => compiler.boolClass; | 142 ClassElement get boolClass => coreClasses.boolClass; |
| 141 ClassElement get numClass => compiler.numClass; | 143 ClassElement get numClass => coreClasses.numClass; |
| 142 ClassElement get intClass => compiler.intClass; | 144 ClassElement get intClass => coreClasses.intClass; |
| 143 ClassElement get doubleClass => compiler.doubleClass; | 145 ClassElement get doubleClass => coreClasses.doubleClass; |
| 144 ClassElement get stringClass => compiler.stringClass; | 146 ClassElement get stringClass => coreClasses.stringClass; |
| 145 ClassElement get nullClass => compiler.nullClass; | 147 ClassElement get nullClass => coreClasses.nullClass; |
| 146 | 148 |
| 147 /// Cache of [ti.FlatTypeMask]s grouped by the 8 possible values of the | 149 /// Cache of [ti.FlatTypeMask]s grouped by the 8 possible values of the |
| 148 /// [ti.FlatTypeMask.flags] property. | 150 /// [ti.FlatTypeMask.flags] property. |
| 149 List<Map<ClassElement, ti.TypeMask>> canonicalizedTypeMasks = | 151 List<Map<ClassElement, ti.TypeMask>> canonicalizedTypeMasks = |
| 150 new List<Map<ClassElement, ti.TypeMask>>.filled(8, null); | 152 new List<Map<ClassElement, ti.TypeMask>>.filled(8, null); |
| 151 | 153 |
| 152 bool checkInvariants(ClassElement cls, {bool mustBeInstantiated: true}) { | 154 bool checkInvariants(ClassElement cls, {bool mustBeInstantiated: true}) { |
| 153 return | 155 return |
| 154 invariant(cls, cls.isDeclaration, | 156 invariant(cls, cls.isDeclaration, |
| 155 message: '$cls must be the declaration.') && | 157 message: '$cls must be the declaration.') && |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 428 |
| 427 Set<ClassElement> typesImplementedBySubclassesOf(ClassElement cls) { | 429 Set<ClassElement> typesImplementedBySubclassesOf(ClassElement cls) { |
| 428 return _typesImplementedBySubclasses[cls.declaration]; | 430 return _typesImplementedBySubclasses[cls.declaration]; |
| 429 } | 431 } |
| 430 | 432 |
| 431 World(Compiler compiler) | 433 World(Compiler compiler) |
| 432 : allFunctions = new FunctionSet(compiler), | 434 : allFunctions = new FunctionSet(compiler), |
| 433 this.compiler = compiler, | 435 this.compiler = compiler, |
| 434 alreadyPopulated = compiler.cacheStrategy.newSet(); | 436 alreadyPopulated = compiler.cacheStrategy.newSet(); |
| 435 | 437 |
| 438 CoreClasses get coreClasses => compiler.coreClasses; |
| 439 |
| 436 DiagnosticReporter get reporter => compiler.reporter; | 440 DiagnosticReporter get reporter => compiler.reporter; |
| 437 | 441 |
| 438 /// Called to add [cls] to the set of known classes. | 442 /// Called to add [cls] to the set of known classes. |
| 439 /// | 443 /// |
| 440 /// This ensures that class hierarchy queries can be performed on [cls] and | 444 /// This ensures that class hierarchy queries can be performed on [cls] and |
| 441 /// classes that extend or implement it. | 445 /// classes that extend or implement it. |
| 442 void registerClass(ClassElement cls) { | 446 void registerClass(ClassElement cls) { |
| 443 _ensureClassSet(cls); | 447 _ensureClassSet(cls); |
| 444 } | 448 } |
| 445 | 449 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 549 } |
| 546 | 550 |
| 547 @override | 551 @override |
| 548 String dump([ClassElement cls]) { | 552 String dump([ClassElement cls]) { |
| 549 StringBuffer sb = new StringBuffer(); | 553 StringBuffer sb = new StringBuffer(); |
| 550 if (cls != null) { | 554 if (cls != null) { |
| 551 sb.write("Classes in the closed world related to $cls:\n"); | 555 sb.write("Classes in the closed world related to $cls:\n"); |
| 552 } else { | 556 } else { |
| 553 sb.write("Instantiated classes in the closed world:\n"); | 557 sb.write("Instantiated classes in the closed world:\n"); |
| 554 } | 558 } |
| 555 getClassHierarchyNode(compiler.objectClass) | 559 getClassHierarchyNode(coreClasses.objectClass) |
| 556 .printOn(sb, ' ', instantiatedOnly: cls == null, withRespectTo: cls); | 560 .printOn(sb, ' ', instantiatedOnly: cls == null, withRespectTo: cls); |
| 557 return sb.toString(); | 561 return sb.toString(); |
| 558 } | 562 } |
| 559 | 563 |
| 560 void registerMixinUse(MixinApplicationElement mixinApplication, | 564 void registerMixinUse(MixinApplicationElement mixinApplication, |
| 561 ClassElement mixin) { | 565 ClassElement mixin) { |
| 562 // TODO(johnniwinther): Add map restricted to live classes. | 566 // TODO(johnniwinther): Add map restricted to live classes. |
| 563 // We don't support patch classes as mixin. | 567 // We don't support patch classes as mixin. |
| 564 assert(mixin.isDeclaration); | 568 assert(mixin.isDeclaration); |
| 565 List<MixinApplicationElement> users = | 569 List<MixinApplicationElement> users = |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 // function expressions's element. | 696 // function expressions's element. |
| 693 // TODO(herhut): Generate classes for function expressions earlier. | 697 // TODO(herhut): Generate classes for function expressions earlier. |
| 694 if (element is SynthesizedCallMethodElementX) { | 698 if (element is SynthesizedCallMethodElementX) { |
| 695 return getMightBePassedToApply(element.expression); | 699 return getMightBePassedToApply(element.expression); |
| 696 } | 700 } |
| 697 return functionsThatMightBePassedToApply.contains(element); | 701 return functionsThatMightBePassedToApply.contains(element); |
| 698 } | 702 } |
| 699 | 703 |
| 700 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 704 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
| 701 } | 705 } |
| OLD | NEW |