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.enqueue; | 5 library dart2js.enqueue; |
6 | 6 |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 | 8 |
9 import 'cache_strategy.dart'; | 9 import 'cache_strategy.dart'; |
10 import 'common/backend_api.dart' show Backend; | 10 import 'common/backend_api.dart' show Backend; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 CompilerTask get task; | 78 CompilerTask get task; |
79 WorldBuilder get universe; | 79 WorldBuilder get universe; |
80 native.NativeEnqueuer get nativeEnqueuer; | 80 native.NativeEnqueuer get nativeEnqueuer; |
81 void forgetElement(Element element, Compiler compiler); | 81 void forgetElement(Element element, Compiler compiler); |
82 void processInstantiatedClassMembers(ClassElement cls); | 82 void processInstantiatedClassMembers(ClassElement cls); |
83 void processInstantiatedClassMember(ClassElement cls, Element member); | 83 void processInstantiatedClassMember(ClassElement cls, Element member); |
84 void handleUnseenSelectorInternal(DynamicUse dynamicUse); | 84 void handleUnseenSelectorInternal(DynamicUse dynamicUse); |
85 void registerStaticUse(StaticUse staticUse); | 85 void registerStaticUse(StaticUse staticUse); |
86 void registerStaticUseInternal(StaticUse staticUse); | 86 void registerStaticUseInternal(StaticUse staticUse); |
87 void registerDynamicUse(DynamicUse dynamicUse); | 87 void registerDynamicUse(DynamicUse dynamicUse); |
88 void registerTypeUse(TypeUse typeUse); | |
89 | 88 |
90 /// Returns [:true:] if this enqueuer is the resolution enqueuer. | 89 /// Returns [:true:] if this enqueuer is the resolution enqueuer. |
91 bool get isResolutionQueue; | 90 bool get isResolutionQueue; |
92 | 91 |
93 bool queueIsClosed; | 92 bool queueIsClosed; |
94 | 93 |
95 bool get queueIsEmpty; | 94 bool get queueIsEmpty; |
96 | 95 |
97 ImpactUseCase get impactUse; | 96 ImpactUseCase get impactUse; |
98 | 97 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 universe.closuresWithFreeTypeVariables.add(closure); | 447 universe.closuresWithFreeTypeVariables.add(closure); |
449 } | 448 } |
450 addElement = false; | 449 addElement = false; |
451 break; | 450 break; |
452 case StaticUseKind.SUPER_FIELD_SET: | 451 case StaticUseKind.SUPER_FIELD_SET: |
453 case StaticUseKind.SUPER_TEAR_OFF: | 452 case StaticUseKind.SUPER_TEAR_OFF: |
454 case StaticUseKind.GENERAL: | 453 case StaticUseKind.GENERAL: |
455 break; | 454 break; |
456 case StaticUseKind.CONSTRUCTOR_INVOKE: | 455 case StaticUseKind.CONSTRUCTOR_INVOKE: |
457 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: | 456 case StaticUseKind.CONST_CONSTRUCTOR_INVOKE: |
458 registerTypeUse(new TypeUse.instantiation(staticUse.type)); | 457 _registerTypeUse(new TypeUse.instantiation(staticUse.type)); |
459 break; | 458 break; |
460 case StaticUseKind.DIRECT_INVOKE: | 459 case StaticUseKind.DIRECT_INVOKE: |
461 invariant( | 460 invariant( |
462 element, 'Direct static use is not supported for resolution.'); | 461 element, 'Direct static use is not supported for resolution.'); |
463 break; | 462 break; |
464 } | 463 } |
465 if (addElement) { | 464 if (addElement) { |
466 addToWorkList(element); | 465 addToWorkList(element); |
467 } | 466 } |
468 } | 467 } |
469 | 468 |
470 void registerTypeUse(TypeUse typeUse) { | 469 void _registerTypeUse(TypeUse typeUse) { |
471 DartType type = typeUse.type; | 470 DartType type = typeUse.type; |
472 switch (typeUse.kind) { | 471 switch (typeUse.kind) { |
473 case TypeUseKind.INSTANTIATION: | 472 case TypeUseKind.INSTANTIATION: |
474 _registerInstantiatedType(type, globalDependency: false); | 473 _registerInstantiatedType(type, globalDependency: false); |
475 break; | 474 break; |
476 case TypeUseKind.MIRROR_INSTANTIATION: | 475 case TypeUseKind.MIRROR_INSTANTIATION: |
477 _registerInstantiatedType(type, | 476 _registerInstantiatedType(type, |
478 mirrorUsage: true, globalDependency: false); | 477 mirrorUsage: true, globalDependency: false); |
479 break; | 478 break; |
480 case TypeUseKind.NATIVE_INSTANTIATION: | 479 case TypeUseKind.NATIVE_INSTANTIATION: |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 enqueuer.registerStaticUseInternal(staticUse); | 735 enqueuer.registerStaticUseInternal(staticUse); |
737 } | 736 } |
738 | 737 |
739 @override | 738 @override |
740 void processDynamicUse(Enqueuer enqueuer, DynamicUse dynamicUse) { | 739 void processDynamicUse(Enqueuer enqueuer, DynamicUse dynamicUse) { |
741 enqueuer.handleUnseenSelectorInternal(dynamicUse); | 740 enqueuer.handleUnseenSelectorInternal(dynamicUse); |
742 } | 741 } |
743 } | 742 } |
744 | 743 |
745 class _EnqueuerImpactVisitor implements WorldImpactVisitor { | 744 class _EnqueuerImpactVisitor implements WorldImpactVisitor { |
746 final Enqueuer enqueuer; | 745 final ResolutionEnqueuer enqueuer; |
747 | 746 |
748 _EnqueuerImpactVisitor(this.enqueuer); | 747 _EnqueuerImpactVisitor(this.enqueuer); |
749 | 748 |
750 @override | 749 @override |
751 void visitDynamicUse(DynamicUse dynamicUse) { | 750 void visitDynamicUse(DynamicUse dynamicUse) { |
752 enqueuer.registerDynamicUse(dynamicUse); | 751 enqueuer.registerDynamicUse(dynamicUse); |
753 } | 752 } |
754 | 753 |
755 @override | 754 @override |
756 void visitStaticUse(StaticUse staticUse) { | 755 void visitStaticUse(StaticUse staticUse) { |
757 enqueuer.registerStaticUse(staticUse); | 756 enqueuer.registerStaticUse(staticUse); |
758 } | 757 } |
759 | 758 |
760 @override | 759 @override |
761 void visitTypeUse(TypeUse typeUse) { | 760 void visitTypeUse(TypeUse typeUse) { |
762 enqueuer.registerTypeUse(typeUse); | 761 enqueuer._registerTypeUse(typeUse); |
763 } | 762 } |
764 } | 763 } |
765 | 764 |
766 typedef void _DeferredActionFunction(); | 765 typedef void _DeferredActionFunction(); |
767 | 766 |
768 class _DeferredAction { | 767 class _DeferredAction { |
769 final Element element; | 768 final Element element; |
770 final _DeferredActionFunction action; | 769 final _DeferredActionFunction action; |
771 | 770 |
772 _DeferredAction(this.element, this.action); | 771 _DeferredAction(this.element, this.action); |
773 } | 772 } |
OLD | NEW |