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 '../elements/elements.dart' | 10 import '../elements/elements.dart' |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 /// [classMembers]. | 98 /// [classMembers]. |
99 /// | 99 /// |
100 /// If [name] and [names] are not null, the computation is restricted to | 100 /// If [name] and [names] are not null, the computation is restricted to |
101 /// members with these names. | 101 /// members with these names. |
102 void computeSuperClassMembers(String name, Setlet<Name> names) { | 102 void computeSuperClassMembers(String name, Setlet<Name> names) { |
103 ResolutionInterfaceType supertype = cls.supertype; | 103 ResolutionInterfaceType supertype = cls.supertype; |
104 if (supertype == null) return; | 104 if (supertype == null) return; |
105 ClassElement superclass = supertype.element; | 105 ClassElement superclass = supertype.element; |
106 | 106 |
107 // Inherit class and interface members from superclass. | 107 // Inherit class and interface members from superclass. |
108 void inheritClassMember(DeclaredMember member) { | 108 void inheritClassMember(Member _member) { |
| 109 DeclaredMember member = _member; |
109 if (shouldSkipMember(member)) return; | 110 if (shouldSkipMember(member)) return; |
110 if (!member.isStatic) { | 111 if (!member.isStatic) { |
111 DeclaredMember inherited = member.inheritFrom(supertype); | 112 DeclaredMember inherited = member.inheritFrom(supertype); |
112 classMembers[member.name] = inherited; | 113 classMembers[member.name] = inherited; |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 if (names != null) { | 117 if (names != null) { |
117 _computeClassMember(resolution, superclass, name, names); | 118 _computeClassMember(resolution, superclass, name, names); |
118 for (Name memberName in names) { | 119 for (Name memberName in names) { |
(...skipping 10 matching lines...) Expand all Loading... |
129 /// If [name] and [names] are not null, the computation is restricted to | 130 /// If [name] and [names] are not null, the computation is restricted to |
130 /// members with these names. | 131 /// members with these names. |
131 Map<Name, Member> computeClassMembers(String nameText, Setlet<Name> names) { | 132 Map<Name, Member> computeClassMembers(String nameText, Setlet<Name> names) { |
132 Map<Name, Member> declaredMembers = new Map<Name, Member>(); | 133 Map<Name, Member> declaredMembers = new Map<Name, Member>(); |
133 | 134 |
134 if (cls.isMixinApplication) { | 135 if (cls.isMixinApplication) { |
135 MixinApplicationElement mixinApplication = cls; | 136 MixinApplicationElement mixinApplication = cls; |
136 if (mixinApplication.mixin != null) { | 137 if (mixinApplication.mixin != null) { |
137 // Only mix in class members when the mixin type is not malformed. | 138 // Only mix in class members when the mixin type is not malformed. |
138 | 139 |
139 void inheritMixinMember(DeclaredMember member) { | 140 void inheritMixinMember(Member _member) { |
| 141 DeclaredMember member = _member; |
140 if (shouldSkipMember(member)) return; | 142 if (shouldSkipMember(member)) return; |
141 Name name = member.name; | 143 Name name = member.name; |
142 if (!member.isAbstract && !member.isStatic) { | 144 if (!member.isAbstract && !member.isStatic) { |
143 // Abstract and static members are not mixed in. | 145 // Abstract and static members are not mixed in. |
144 DeclaredMember mixedInMember = | 146 DeclaredMember mixedInMember = |
145 member.inheritFrom(mixinApplication.mixinType); | 147 member.inheritFrom(mixinApplication.mixinType); |
146 DeclaredMember inherited = classMembers[name]; | 148 DeclaredMember inherited = classMembers[name]; |
147 classMembers[name] = mixedInMember; | 149 classMembers[name] = mixedInMember; |
148 checkValidOverride(mixedInMember, inherited); | 150 checkValidOverride(mixedInMember, inherited); |
149 } | 151 } |
150 } | 152 } |
151 | 153 |
152 if (names != null) { | 154 if (names != null) { |
153 _computeClassMember( | 155 _computeClassMember( |
154 resolution, mixinApplication.mixin, nameText, names); | 156 resolution, mixinApplication.mixin, nameText, names); |
155 for (Name memberName in names) { | 157 for (Name memberName in names) { |
156 inheritMixinMember( | 158 inheritMixinMember( |
157 mixinApplication.mixin.lookupClassMember(memberName)); | 159 mixinApplication.mixin.lookupClassMember(memberName)); |
158 } | 160 } |
159 } else { | 161 } else { |
160 computeAllClassMembers(resolution, mixinApplication.mixin); | 162 computeAllClassMembers(resolution, mixinApplication.mixin); |
161 mixinApplication.mixin.forEachClassMember(inheritMixinMember); | 163 mixinApplication.mixin.forEachClassMember(inheritMixinMember); |
162 } | 164 } |
163 } | 165 } |
164 } else { | 166 } else { |
165 LibraryElement library = cls.library; | 167 LibraryElement library = cls.library; |
166 ResolutionInterfaceType thisType = cls.thisType; | 168 ResolutionInterfaceType thisType = cls.thisType; |
167 | 169 |
168 void createMember(MemberElement element) { | 170 void createMember(Element _element) { |
| 171 MemberElement element = _element; |
169 if (element.isConstructor) return; | 172 if (element.isConstructor) return; |
170 String elementName = element.name; | 173 String elementName = element.name; |
171 if (shouldSkipName(elementName)) return; | 174 if (shouldSkipName(elementName)) return; |
172 if (nameText != null && elementName != nameText) return; | 175 if (nameText != null && elementName != nameText) return; |
173 | 176 |
174 void addDeclaredMember(Name name, ResolutionDartType type, | 177 void addDeclaredMember(Name name, ResolutionDartType type, |
175 ResolutionFunctionType functionType) { | 178 ResolutionFunctionType functionType) { |
176 DeclaredMember inherited = classMembers[name]; | 179 DeclaredMember inherited = classMembers[name]; |
177 DeclaredMember declared; | 180 DeclaredMember declared; |
178 if (element.isAbstract) { | 181 if (element.isAbstract) { |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 failedAt(this, "Members have not been fully computed for $this.")); | 965 failedAt(this, "Members have not been fully computed for $this.")); |
963 if (interfaceMembersAreClassMembers) { | 966 if (interfaceMembersAreClassMembers) { |
964 classMembers.forEach((_, member) { | 967 classMembers.forEach((_, member) { |
965 if (!member.isStatic) f(member); | 968 if (!member.isStatic) f(member); |
966 }); | 969 }); |
967 } else { | 970 } else { |
968 interfaceMembers.forEach((_, member) => f(member)); | 971 interfaceMembers.forEach((_, member) => f(member)); |
969 } | 972 } |
970 } | 973 } |
971 } | 974 } |
OLD | NEW |