OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 part of world_builder; | 5 part of world_builder; |
6 | 6 |
7 abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld { | 7 abstract class ResolutionWorldBuilder implements WorldBuilder, OpenWorld { |
8 /// Set of all local functions in the program. Used by the mirror tracking | 8 /// Set of all local functions in the program. Used by the mirror tracking |
9 /// system to find all live closure instances. | 9 /// system to find all live closure instances. |
10 Iterable<Local> get localFunctions; | 10 Iterable<Local> get localFunctions; |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 | 558 |
559 void registerIsCheck(DartType type) { | 559 void registerIsCheck(DartType type) { |
560 isChecks.add(type); | 560 isChecks.add(type); |
561 } | 561 } |
562 | 562 |
563 bool registerConstantUse(ConstantUse use) { | 563 bool registerConstantUse(ConstantUse use) { |
564 return _constantValues.add(use.value); | 564 return _constantValues.add(use.value); |
565 } | 565 } |
566 | 566 |
567 void registerStaticUse(StaticUse staticUse, MemberUsedCallback memberUsed) { | 567 void registerStaticUse(StaticUse staticUse, MemberUsedCallback memberUsed) { |
| 568 if (staticUse.kind == StaticUseKind.CLOSURE) { |
| 569 Local localFunction = staticUse.element; |
| 570 FunctionType type = |
| 571 _elementEnvironment.getLocalFunctionType(localFunction); |
| 572 if (type.containsTypeVariables) { |
| 573 localFunctionsWithFreeTypeVariables.add(localFunction); |
| 574 } |
| 575 localFunctions.add(staticUse.element); |
| 576 return; |
| 577 } |
| 578 |
568 MemberEntity element = staticUse.element; | 579 MemberEntity element = staticUse.element; |
569 _StaticMemberUsage usage = _staticMemberUsage.putIfAbsent(element, () { | 580 _StaticMemberUsage usage = _staticMemberUsage.putIfAbsent(element, () { |
570 if ((element.isStatic || element.isTopLevel) && element.isFunction) { | 581 if ((element.isStatic || element.isTopLevel) && element.isFunction) { |
571 return new _StaticFunctionUsage(element); | 582 return new _StaticFunctionUsage(element); |
572 } else { | 583 } else { |
573 return new _GeneralStaticMemberUsage(element); | 584 return new _GeneralStaticMemberUsage(element); |
574 } | 585 } |
575 }); | 586 }); |
576 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>(); | 587 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>(); |
577 | 588 |
578 if ((element.isStatic || element.isTopLevel) && element.isField) { | 589 if ((element.isStatic || element.isTopLevel) && element.isField) { |
579 allReferencedStaticFields.add(staticUse.element); | 590 allReferencedStaticFields.add(staticUse.element); |
580 } | 591 } |
581 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and | 592 // TODO(johnniwinther): Avoid this. Currently [FIELD_GET] and |
582 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. | 593 // [FIELD_SET] contains [BoxFieldElement]s which we cannot enqueue. |
583 // Also [CLOSURE] contains [LocalFunctionElement] which we cannot | 594 // Also [CLOSURE] contains [LocalFunctionElement] which we cannot |
584 // enqueue. | 595 // enqueue. |
585 switch (staticUse.kind) { | 596 switch (staticUse.kind) { |
586 case StaticUseKind.FIELD_GET: | 597 case StaticUseKind.FIELD_GET: |
587 break; | 598 break; |
588 case StaticUseKind.FIELD_SET: | 599 case StaticUseKind.FIELD_SET: |
589 fieldSetters.add(staticUse.element); | 600 fieldSetters.add(staticUse.element); |
590 break; | 601 break; |
591 case StaticUseKind.CLOSURE: | 602 case StaticUseKind.CLOSURE: |
592 throw new UnimplementedError( | 603 // Already handled above. |
593 "registerStaticUse not implemented for StaticUseKind.CLOSURE."); | 604 break; |
594 case StaticUseKind.SUPER_TEAR_OFF: | 605 case StaticUseKind.SUPER_TEAR_OFF: |
595 useSet.addAll(usage.tearOff()); | 606 useSet.addAll(usage.tearOff()); |
596 methodsNeedingSuperGetter.add(staticUse.element); | 607 methodsNeedingSuperGetter.add(staticUse.element); |
597 break; | 608 break; |
598 case StaticUseKind.SUPER_FIELD_SET: | 609 case StaticUseKind.SUPER_FIELD_SET: |
599 fieldSetters.add(staticUse.element); | 610 fieldSetters.add(staticUse.element); |
600 useSet.addAll(usage.normalUse()); | 611 useSet.addAll(usage.normalUse()); |
601 break; | 612 break; |
602 case StaticUseKind.STATIC_TEAR_OFF: | 613 case StaticUseKind.STATIC_TEAR_OFF: |
603 useSet.addAll(usage.tearOff()); | 614 useSet.addAll(usage.tearOff()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 @override | 772 @override |
762 bool isMemberUsed(MemberEntity member) { | 773 bool isMemberUsed(MemberEntity member) { |
763 if (member.isInstanceMember) { | 774 if (member.isInstanceMember) { |
764 _MemberUsage usage = _instanceMemberUsage[member]; | 775 _MemberUsage usage = _instanceMemberUsage[member]; |
765 if (usage != null && usage.hasUse) return true; | 776 if (usage != null && usage.hasUse) return true; |
766 } | 777 } |
767 _StaticMemberUsage usage = _staticMemberUsage[member]; | 778 _StaticMemberUsage usage = _staticMemberUsage[member]; |
768 return usage != null && usage.hasUse; | 779 return usage != null && usage.hasUse; |
769 } | 780 } |
770 } | 781 } |
OLD | NEW |