| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.resolution.registry; | 5 library dart2js.resolution.registry; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' show | 8 import '../common/backend_api.dart' show |
| 9 Backend, | 9 Backend, |
| 10 ForeignResolver; | 10 ForeignResolver; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 import '../world.dart' show World; | 34 import '../world.dart' show World; |
| 35 | 35 |
| 36 import 'send_structure.dart'; | 36 import 'send_structure.dart'; |
| 37 | 37 |
| 38 import 'members.dart' show | 38 import 'members.dart' show |
| 39 ResolverVisitor; | 39 ResolverVisitor; |
| 40 import 'tree_elements.dart' show | 40 import 'tree_elements.dart' show |
| 41 TreeElementMapping; | 41 TreeElementMapping; |
| 42 | 42 |
| 43 // TODO(johnniwinther): Remove this. | 43 // TODO(johnniwinther): Remove this. |
| 44 class EagerRegistry implements Registry { | 44 class EagerRegistry extends Registry { |
| 45 final Compiler compiler; | 45 final Compiler compiler; |
| 46 final TreeElementMapping mapping; | 46 final TreeElementMapping mapping; |
| 47 | 47 |
| 48 EagerRegistry(this.compiler, this.mapping); | 48 EagerRegistry(this.compiler, this.mapping); |
| 49 | 49 |
| 50 ResolutionEnqueuer get world => compiler.enqueuer.resolution; | 50 ResolutionEnqueuer get world => compiler.enqueuer.resolution; |
| 51 | 51 |
| 52 @override | 52 @override |
| 53 bool get isForResolution => true; | 53 bool get isForResolution => true; |
| 54 | 54 |
| 55 @override | 55 @override |
| 56 Iterable<Element> get otherDependencies => mapping.otherDependencies; | |
| 57 | |
| 58 @override | |
| 59 void registerAssert(bool hasMessage) { | |
| 60 // TODO(johnniwinther): Do something here? | |
| 61 } | |
| 62 | |
| 63 @override | |
| 64 void registerDependency(Element element) { | |
| 65 mapping.registerDependency(element); | |
| 66 } | |
| 67 | |
| 68 @override | |
| 69 void registerDynamicGetter(UniverseSelector selector) { | 56 void registerDynamicGetter(UniverseSelector selector) { |
| 70 world.registerDynamicGetter(selector); | 57 world.registerDynamicGetter(selector); |
| 71 } | 58 } |
| 72 | 59 |
| 73 @override | 60 @override |
| 74 void registerDynamicInvocation(UniverseSelector selector) { | 61 void registerDynamicInvocation(UniverseSelector selector) { |
| 75 world.registerDynamicInvocation(selector); | 62 world.registerDynamicInvocation(selector); |
| 76 } | 63 } |
| 77 | 64 |
| 78 @override | 65 @override |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 return _features != null ? _features : const <Feature>[]; | 332 return _features != null ? _features : const <Feature>[]; |
| 346 } | 333 } |
| 347 | 334 |
| 348 String toString() => '$registry'; | 335 String toString() => '$registry'; |
| 349 } | 336 } |
| 350 | 337 |
| 351 /// [ResolutionRegistry] collects all resolution information. It stores node | 338 /// [ResolutionRegistry] collects all resolution information. It stores node |
| 352 /// related information in a [TreeElements] mapping and registers calls with | 339 /// related information in a [TreeElements] mapping and registers calls with |
| 353 /// [Backend], [World] and [Enqueuer]. | 340 /// [Backend], [World] and [Enqueuer]. |
| 354 // TODO(johnniwinther): Split this into an interface and implementation class. | 341 // TODO(johnniwinther): Split this into an interface and implementation class. |
| 355 class ResolutionRegistry implements Registry { | 342 class ResolutionRegistry extends Registry { |
| 356 final Compiler compiler; | 343 final Compiler compiler; |
| 357 final TreeElementMapping mapping; | 344 final TreeElementMapping mapping; |
| 358 final _ResolutionWorldImpact worldImpact; | 345 final _ResolutionWorldImpact worldImpact; |
| 359 | 346 |
| 360 ResolutionRegistry(Compiler compiler, TreeElementMapping mapping) | 347 ResolutionRegistry(Compiler compiler, TreeElementMapping mapping) |
| 361 : this.compiler = compiler, | 348 : this.compiler = compiler, |
| 362 this.mapping = mapping, | 349 this.mapping = mapping, |
| 363 this.worldImpact = new _ResolutionWorldImpact(compiler, mapping); | 350 this.worldImpact = new _ResolutionWorldImpact(compiler, mapping); |
| 364 | 351 |
| 365 bool get isForResolution => true; | 352 bool get isForResolution => true; |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 695 |
| 709 void registerMixinUse(MixinApplicationElement mixinApplication, | 696 void registerMixinUse(MixinApplicationElement mixinApplication, |
| 710 ClassElement mixin) { | 697 ClassElement mixin) { |
| 711 universe.registerMixinUse(mixinApplication, mixin); | 698 universe.registerMixinUse(mixinApplication, mixin); |
| 712 } | 699 } |
| 713 | 700 |
| 714 void registerThrowExpression() { | 701 void registerThrowExpression() { |
| 715 worldImpact.registerFeature(Feature.THROW_EXPRESSION); | 702 worldImpact.registerFeature(Feature.THROW_EXPRESSION); |
| 716 } | 703 } |
| 717 | 704 |
| 718 void registerDependency(Element element) { | |
| 719 mapping.registerDependency(element); | |
| 720 } | |
| 721 | |
| 722 Setlet<Element> get otherDependencies => mapping.otherDependencies; | |
| 723 | |
| 724 void registerStaticInvocation(Element element) { | 705 void registerStaticInvocation(Element element) { |
| 725 // TODO(johnniwinther): Increase precision of [registerStaticUse] and | 706 // TODO(johnniwinther): Increase precision of [registerStaticUse] and |
| 726 // [registerDependency]. | 707 // [registerDependency]. |
| 727 if (element == null) return; | 708 if (element == null) return; |
| 728 registerStaticUse(element); | 709 registerStaticUse(element); |
| 729 registerDependency(element); | |
| 730 } | 710 } |
| 731 | 711 |
| 732 void registerInstantiation(InterfaceType type) { | 712 void registerInstantiation(InterfaceType type) { |
| 733 registerInstantiatedType(type); | 713 registerInstantiatedType(type); |
| 734 } | 714 } |
| 735 | 715 |
| 736 void registerAssert(bool hasMessage) { | 716 void registerAssert(bool hasMessage) { |
| 737 worldImpact.registerFeature( | 717 worldImpact.registerFeature( |
| 738 hasMessage ? Feature.ASSERT_WITH_MESSAGE : Feature.ASSERT); | 718 hasMessage ? Feature.ASSERT_WITH_MESSAGE : Feature.ASSERT); |
| 739 } | 719 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 @override | 771 @override |
| 792 void registerInstantiatedType(InterfaceType type) { | 772 void registerInstantiatedType(InterfaceType type) { |
| 793 registry.registerInstantiatedType(type); | 773 registry.registerInstantiatedType(type); |
| 794 } | 774 } |
| 795 | 775 |
| 796 @override | 776 @override |
| 797 DartType resolveTypeFromString(Node node, String typeName) { | 777 DartType resolveTypeFromString(Node node, String typeName) { |
| 798 return visitor.resolveTypeFromString(node, typeName); | 778 return visitor.resolveTypeFromString(node, typeName); |
| 799 } | 779 } |
| 800 } | 780 } |
| OLD | NEW |