| 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 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool hasAnySubclassThatMixes(ClassElement superclass, ClassElement mixin); | 122 bool hasAnySubclassThatMixes(ClassElement superclass, ClassElement mixin); |
| 123 | 123 |
| 124 /// Returns `true` if any subclass of [superclass] implements [type]. | 124 /// Returns `true` if any subclass of [superclass] implements [type]. |
| 125 bool hasAnySubclassThatImplements(ClassElement superclass, ClassElement type); | 125 bool hasAnySubclassThatImplements(ClassElement superclass, ClassElement type); |
| 126 | 126 |
| 127 /// Returns `true` if closed-world assumptions can be made, that is, | 127 /// Returns `true` if closed-world assumptions can be made, that is, |
| 128 /// incremental compilation isn't enabled. | 128 /// incremental compilation isn't enabled. |
| 129 bool get hasClosedWorldAssumption; | 129 bool get hasClosedWorldAssumption; |
| 130 | 130 |
| 131 /// Returns a string representation of the closed world. | 131 /// Returns a string representation of the closed world. |
| 132 String dump(); | 132 /// |
| 133 /// If [cls] is provided, the dump will contain only classes related to [cls]. |
| 134 String dump([ClassElement cls]); |
| 133 } | 135 } |
| 134 | 136 |
| 135 class World implements ClassWorld { | 137 class World implements ClassWorld { |
| 136 ClassElement get objectClass => compiler.objectClass; | 138 ClassElement get objectClass => compiler.objectClass; |
| 137 ClassElement get functionClass => compiler.functionClass; | 139 ClassElement get functionClass => compiler.functionClass; |
| 138 ClassElement get boolClass => compiler.boolClass; | 140 ClassElement get boolClass => compiler.boolClass; |
| 139 ClassElement get numClass => compiler.numClass; | 141 ClassElement get numClass => compiler.numClass; |
| 140 ClassElement get intClass => compiler.intClass; | 142 ClassElement get intClass => compiler.intClass; |
| 141 ClassElement get doubleClass => compiler.doubleClass; | 143 ClassElement get doubleClass => compiler.doubleClass; |
| 142 ClassElement get stringClass => compiler.stringClass; | 144 ClassElement get stringClass => compiler.stringClass; |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 538 } |
| 537 | 539 |
| 538 // Use the [:seenClasses:] set to include non-instantiated | 540 // Use the [:seenClasses:] set to include non-instantiated |
| 539 // classes: if the superclass of these classes require RTI, then | 541 // classes: if the superclass of these classes require RTI, then |
| 540 // they also need RTI, so that a constructor passes the type | 542 // they also need RTI, so that a constructor passes the type |
| 541 // variables to the super constructor. | 543 // variables to the super constructor. |
| 542 compiler.resolverWorld.directlyInstantiatedClasses.forEach(addSubtypes); | 544 compiler.resolverWorld.directlyInstantiatedClasses.forEach(addSubtypes); |
| 543 } | 545 } |
| 544 | 546 |
| 545 @override | 547 @override |
| 546 String dump() { | 548 String dump([ClassElement cls]) { |
| 547 StringBuffer sb = new StringBuffer(); | 549 StringBuffer sb = new StringBuffer(); |
| 548 sb.write("Instantiated classes in the closed world:\n"); | 550 if (cls != null) { |
| 551 sb.write("Classes in the closed world related to $cls:\n"); |
| 552 } else { |
| 553 sb.write("Instantiated classes in the closed world:\n"); |
| 554 } |
| 549 getClassHierarchyNode(compiler.objectClass) | 555 getClassHierarchyNode(compiler.objectClass) |
| 550 .printOn(sb, ' ', instantiatedOnly: true); | 556 .printOn(sb, ' ', instantiatedOnly: cls == null, withRespectTo: cls); |
| 551 return sb.toString(); | 557 return sb.toString(); |
| 552 } | 558 } |
| 553 | 559 |
| 554 void registerMixinUse(MixinApplicationElement mixinApplication, | 560 void registerMixinUse(MixinApplicationElement mixinApplication, |
| 555 ClassElement mixin) { | 561 ClassElement mixin) { |
| 556 // TODO(johnniwinther): Add map restricted to live classes. | 562 // TODO(johnniwinther): Add map restricted to live classes. |
| 557 // We don't support patch classes as mixin. | 563 // We don't support patch classes as mixin. |
| 558 assert(mixin.isDeclaration); | 564 assert(mixin.isDeclaration); |
| 559 List<MixinApplicationElement> users = | 565 List<MixinApplicationElement> users = |
| 560 _mixinUses.putIfAbsent(mixin, () => | 566 _mixinUses.putIfAbsent(mixin, () => |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 // function expressions's element. | 692 // function expressions's element. |
| 687 // TODO(herhut): Generate classes for function expressions earlier. | 693 // TODO(herhut): Generate classes for function expressions earlier. |
| 688 if (element is SynthesizedCallMethodElementX) { | 694 if (element is SynthesizedCallMethodElementX) { |
| 689 return getMightBePassedToApply(element.expression); | 695 return getMightBePassedToApply(element.expression); |
| 690 } | 696 } |
| 691 return functionsThatMightBePassedToApply.contains(element); | 697 return functionsThatMightBePassedToApply.contains(element); |
| 692 } | 698 } |
| 693 | 699 |
| 694 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 700 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
| 695 } | 701 } |
| OLD | NEW |