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.resolution.compute_members; | 5 library dart2js.resolution.compute_members; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/names.dart' show Identifiers, Names; | 8 import '../common/names.dart' show Identifiers, Names; |
9 import '../common/resolution.dart' show Resolution; | 9 import '../common/resolution.dart' show Resolution; |
10 import '../compiler.dart' show Compiler; | 10 import '../compiler.dart' show Compiler; |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 /// When [classMembers] and [interfaceMembers] have not been fully computed | 817 /// When [classMembers] and [interfaceMembers] have not been fully computed |
818 /// [computedMembersNames] holds the names for which members have already been | 818 /// [computedMembersNames] holds the names for which members have already been |
819 /// computed. | 819 /// computed. |
820 /// | 820 /// |
821 /// If [computedMemberNames], [classMembers] and [interfaceMembers] are `null` | 821 /// If [computedMemberNames], [classMembers] and [interfaceMembers] are `null` |
822 /// no members have been computed, if only [computedMemberNames] is `null` all | 822 /// no members have been computed, if only [computedMemberNames] is `null` all |
823 /// members have been computed. A non-null [computedMemberNames] implicitly | 823 /// members have been computed. A non-null [computedMemberNames] implicitly |
824 /// includes `call`. | 824 /// includes `call`. |
825 Iterable<String> computedMemberNames; | 825 Iterable<String> computedMemberNames; |
826 | 826 |
827 bool _interfaceMembersAreClassMembers; | |
828 | |
829 /// Compute value of the [_interfaceMembersAreClassMembers] for this class | |
830 /// and its superclasses. | |
831 void _ensureInterfaceMembersAreClassMembers(Resolution resolution) { | |
Siggi Cherem (dart-lang)
2016/05/31 16:28:31
rename: change `ensure` to `compute`?
the current
Johnni Winther
2016/06/02 09:02:51
Done.
| |
832 if (_interfaceMembersAreClassMembers == null) { | |
833 ensureResolved(resolution); | |
834 ClassMemberMixin superclass = this.superclass; | |
835 if (superclass != null) { | |
836 superclass._ensureInterfaceMembersAreClassMembers(resolution); | |
837 } | |
838 if ((superclass != null && | |
839 (!superclass.interfaceMembersAreClassMembers || | |
840 superclass.isMixinApplication)) || | |
841 !interfaces.isEmpty) { | |
842 _interfaceMembersAreClassMembers = false; | |
843 } else { | |
844 _interfaceMembersAreClassMembers = true; | |
845 } | |
846 } | |
847 } | |
848 | |
827 /// If `true` interface members are the non-static class member. | 849 /// If `true` interface members are the non-static class member. |
828 bool interfaceMembersAreClassMembers = true; | 850 bool get interfaceMembersAreClassMembers => _interfaceMembersAreClassMembers; |
829 | 851 |
830 Map<Name, Member> classMembers; | 852 Map<Name, Member> classMembers; |
831 Map<Name, MemberSignature> interfaceMembers; | 853 Map<Name, MemberSignature> interfaceMembers; |
832 | 854 |
833 /// Creates the necessary maps and [MembersCreator] for compute members of | 855 /// Creates the necessary maps and [MembersCreator] for compute members of |
834 /// this class. | 856 /// this class. |
835 MembersCreator _prepareCreator(Resolution resolution) { | 857 MembersCreator _prepareCreator(Resolution resolution) { |
836 if (classMembers == null) { | 858 if (classMembers == null) { |
837 ensureResolved(resolution); | 859 _ensureInterfaceMembersAreClassMembers(resolution); |
838 classMembers = new Map<Name, Member>(); | 860 classMembers = new Map<Name, Member>(); |
839 | |
840 if (interfaceMembersAreClassMembers) { | |
841 ClassMemberMixin superclass = this.superclass; | |
842 if ((superclass != null && | |
843 (!superclass.interfaceMembersAreClassMembers || | |
844 superclass.isMixinApplication)) || | |
845 !interfaces.isEmpty) { | |
846 interfaceMembersAreClassMembers = false; | |
847 } | |
848 } | |
849 if (!interfaceMembersAreClassMembers) { | 861 if (!interfaceMembersAreClassMembers) { |
850 interfaceMembers = new Map<Name, MemberSignature>(); | 862 interfaceMembers = new Map<Name, MemberSignature>(); |
851 } | 863 } |
852 } | 864 } |
853 return interfaceMembersAreClassMembers | 865 return interfaceMembersAreClassMembers |
854 ? new ClassMembersCreator( | 866 ? new ClassMembersCreator( |
855 resolution, this, computedMemberNames, classMembers) | 867 resolution, this, computedMemberNames, classMembers) |
856 : new InterfaceMembersCreator(resolution, this, computedMemberNames, | 868 : new InterfaceMembersCreator(resolution, this, computedMemberNames, |
857 classMembers, interfaceMembers); | 869 classMembers, interfaceMembers); |
858 } | 870 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
934 message: "Members have not been fully computed for $this.")); | 946 message: "Members have not been fully computed for $this.")); |
935 if (interfaceMembersAreClassMembers) { | 947 if (interfaceMembersAreClassMembers) { |
936 classMembers.forEach((_, member) { | 948 classMembers.forEach((_, member) { |
937 if (!member.isStatic) f(member); | 949 if (!member.isStatic) f(member); |
938 }); | 950 }); |
939 } else { | 951 } else { |
940 interfaceMembers.forEach((_, member) => f(member)); | 952 interfaceMembers.forEach((_, member) => f(member)); |
941 } | 953 } |
942 } | 954 } |
943 } | 955 } |
OLD | NEW |