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 universe; | 5 library universe; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import '../cache_strategy.dart'; | 9 import '../cache_strategy.dart'; |
10 import '../common.dart'; | 10 import '../common.dart'; |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 case StaticUseKind.CLOSURE: | 714 case StaticUseKind.CLOSURE: |
715 allClosures.add(element); | 715 allClosures.add(element); |
716 break; | 716 break; |
717 case StaticUseKind.DIRECT_INVOKE: | 717 case StaticUseKind.DIRECT_INVOKE: |
718 invariant( | 718 invariant( |
719 element, 'Direct static use is not supported for resolution.'); | 719 element, 'Direct static use is not supported for resolution.'); |
720 break; | 720 break; |
721 } | 721 } |
722 } | 722 } |
723 | 723 |
724 void forgetElement(Element element, Compiler compiler) { | 724 void forgetEntity(Entity entity, Compiler compiler) { |
725 allClosures.remove(element); | 725 allClosures.remove(entity); |
726 slowDirectlyNestedClosures(element).forEach(compiler.forgetElement); | 726 slowDirectlyNestedClosures(entity).forEach(compiler.forgetElement); |
727 closurizedMembers.remove(element); | 727 closurizedMembers.remove(entity); |
728 fieldSetters.remove(element); | 728 fieldSetters.remove(entity); |
729 _instantiationInfo.remove(element); | 729 _instantiationInfo.remove(entity); |
730 | 730 |
731 void removeUsage(Set<_MemberUsage> set, Element element) { | 731 void removeUsage(Set<_MemberUsage> set, Entity entity) { |
732 if (set == null) return; | 732 if (set == null) return; |
733 set.removeAll( | 733 set.removeAll( |
734 set.where((_MemberUsage usage) => usage.entity == element).toList()); | 734 set.where((_MemberUsage usage) => usage.entity == entity).toList()); |
735 } | 735 } |
736 | 736 |
737 _processedClasses.remove(element); | 737 _processedClasses.remove(entity); |
738 removeUsage(_instanceMembersByName[element.name], element); | 738 removeUsage(_instanceMembersByName[entity.name], entity); |
739 removeUsage(_instanceFunctionsByName[element.name], element); | 739 removeUsage(_instanceFunctionsByName[entity.name], entity); |
740 } | 740 } |
741 | 741 |
742 // TODO(ahe): Replace this method with something that is O(1), for example, | 742 // TODO(ahe): Replace this method with something that is O(1), for example, |
743 // by using a map. | 743 // by using a map. |
744 List<LocalFunctionElement> slowDirectlyNestedClosures(Element element) { | 744 List<LocalFunctionElement> slowDirectlyNestedClosures(Element element) { |
745 // Return new list to guard against concurrent modifications. | 745 // Return new list to guard against concurrent modifications. |
746 return new List<LocalFunctionElement>.from( | 746 return new List<LocalFunctionElement>.from( |
747 allClosures.where((LocalFunctionElement closure) { | 747 allClosures.where((LocalFunctionElement closure) { |
748 return closure.executableContext == element; | 748 return closure.executableContext == element; |
749 })); | 749 })); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 for (_MemberUsage usage in members) { | 801 for (_MemberUsage usage in members) { |
802 if (!updateUsage(usage)) remaining.add(usage); | 802 if (!updateUsage(usage)) remaining.add(usage); |
803 } | 803 } |
804 map[memberName].addAll(remaining); | 804 map[memberName].addAll(remaining); |
805 } | 805 } |
806 | 806 |
807 void _processInstanceMembers(String name, bool updateUsage(_MemberUsage e)) { | 807 void _processInstanceMembers(String name, bool updateUsage(_MemberUsage e)) { |
808 _processSet(_instanceMembersByName, name, updateUsage); | 808 _processSet(_instanceMembersByName, name, updateUsage); |
809 } | 809 } |
810 | 810 |
811 void _processInstanceFunctions(String name, bool updateUsage(_MemberUsage e))
{ | 811 void _processInstanceFunctions( |
| 812 String name, bool updateUsage(_MemberUsage e)) { |
812 _processSet(_instanceFunctionsByName, name, updateUsage); | 813 _processSet(_instanceFunctionsByName, name, updateUsage); |
813 } | 814 } |
814 | 815 |
815 void _processInstantiatedClassMember( | 816 void _processInstantiatedClassMember( |
816 ClassElement cls, MemberElement member, MemberUsed memberUsed) { | 817 ClassElement cls, MemberElement member, MemberUsed memberUsed) { |
817 assert(invariant(member, member.isDeclaration)); | 818 assert(invariant(member, member.isDeclaration)); |
818 if (!member.isInstanceMember) return; | 819 if (!member.isInstanceMember) return; |
819 String memberName = member.name; | 820 String memberName = member.name; |
820 member.computeType(_resolution); | 821 member.computeType(_resolution); |
821 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>(); | 822 EnumSet<MemberUse> useSet = new EnumSet<MemberUse>(); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 class ClassUses { | 1442 class ClassUses { |
1442 static const EnumSet<ClassUse> NONE = const EnumSet<ClassUse>.fixed(0); | 1443 static const EnumSet<ClassUse> NONE = const EnumSet<ClassUse>.fixed(0); |
1443 static const EnumSet<ClassUse> INSTANTIATED_ONLY = | 1444 static const EnumSet<ClassUse> INSTANTIATED_ONLY = |
1444 const EnumSet<ClassUse>.fixed(1); | 1445 const EnumSet<ClassUse>.fixed(1); |
1445 static const EnumSet<ClassUse> IMPLEMENTED_ONLY = | 1446 static const EnumSet<ClassUse> IMPLEMENTED_ONLY = |
1446 const EnumSet<ClassUse>.fixed(2); | 1447 const EnumSet<ClassUse>.fixed(2); |
1447 static const EnumSet<ClassUse> ALL = const EnumSet<ClassUse>.fixed(3); | 1448 static const EnumSet<ClassUse> ALL = const EnumSet<ClassUse>.fixed(3); |
1448 } | 1449 } |
1449 | 1450 |
1450 typedef void ClassUsed(ClassEntity cls, EnumSet<ClassUse> useSet); | 1451 typedef void ClassUsed(ClassEntity cls, EnumSet<ClassUse> useSet); |
OLD | NEW |