OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 universe; | 5 part of universe; |
6 | 6 |
7 class SelectorKind { | 7 class SelectorKind { |
8 final String name; | 8 final String name; |
9 final int hashCode; | 9 final int hashCode; |
10 const SelectorKind(this.name, this.hashCode); | 10 const SelectorKind(this.name, this.hashCode); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 bool get isSetter => kind == SelectorKind.SETTER; | 174 bool get isSetter => kind == SelectorKind.SETTER; |
175 bool get isCall => kind == SelectorKind.CALL; | 175 bool get isCall => kind == SelectorKind.CALL; |
176 bool get isClosureCall => isCall && memberName == CALL_NAME; | 176 bool get isClosureCall => isCall && memberName == CALL_NAME; |
177 | 177 |
178 bool get isIndex => kind == SelectorKind.INDEX && argumentCount == 1; | 178 bool get isIndex => kind == SelectorKind.INDEX && argumentCount == 1; |
179 bool get isIndexSet => kind == SelectorKind.INDEX && argumentCount == 2; | 179 bool get isIndexSet => kind == SelectorKind.INDEX && argumentCount == 2; |
180 | 180 |
181 bool get isOperator => kind == SelectorKind.OPERATOR; | 181 bool get isOperator => kind == SelectorKind.OPERATOR; |
182 bool get isUnaryOperator => isOperator && argumentCount == 0; | 182 bool get isUnaryOperator => isOperator && argumentCount == 0; |
183 | 183 |
184 /** Check whether this is a call to 'assert'. */ | |
185 bool get isAssert => isCall && identical(name, "assert"); | |
186 | |
187 /** | 184 /** |
188 * The member name for invocation mirrors created from this selector. | 185 * The member name for invocation mirrors created from this selector. |
189 */ | 186 */ |
190 String get invocationMirrorMemberName => | 187 String get invocationMirrorMemberName => |
191 isSetter ? '$name=' : name; | 188 isSetter ? '$name=' : name; |
192 | 189 |
193 int get invocationMirrorKind { | 190 int get invocationMirrorKind { |
194 const int METHOD = 0; | 191 const int METHOD = 0; |
195 const int GETTER = 1; | 192 const int GETTER = 1; |
196 const int SETTER = 2; | 193 const int SETTER = 2; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 return signatureApplies(element); | 226 return signatureApplies(element); |
230 } | 227 } |
231 | 228 |
232 bool signatureApplies(FunctionElement function) { | 229 bool signatureApplies(FunctionElement function) { |
233 if (Elements.isUnresolved(function)) return false; | 230 if (Elements.isUnresolved(function)) return false; |
234 return callStructure.signatureApplies(function.functionSignature); | 231 return callStructure.signatureApplies(function.functionSignature); |
235 } | 232 } |
236 | 233 |
237 bool sameNameHack(Element element, World world) { | 234 bool sameNameHack(Element element, World world) { |
238 // TODO(ngeoffray): Remove workaround checks. | 235 // TODO(ngeoffray): Remove workaround checks. |
239 return element.isConstructor || | 236 return element.isConstructor || name == element.name; |
240 name == element.name || | |
241 name == 'assert' && world.isAssertMethod(element); | |
242 } | 237 } |
243 | 238 |
244 bool applies(Element element, World world) { | 239 bool applies(Element element, World world) { |
245 if (!sameNameHack(element, world)) return false; | 240 if (!sameNameHack(element, world)) return false; |
246 return appliesUnnamed(element, world); | 241 return appliesUnnamed(element, world); |
247 } | 242 } |
248 | 243 |
249 bool match(SelectorKind kind, | 244 bool match(SelectorKind kind, |
250 Name memberName, | 245 Name memberName, |
251 CallStructure callStructure) { | 246 CallStructure callStructure) { |
(...skipping 10 matching lines...) Expand all Loading... |
262 // Add bits from the call structure. | 257 // Add bits from the call structure. |
263 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); | 258 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); |
264 } | 259 } |
265 | 260 |
266 String toString() { | 261 String toString() { |
267 return 'Selector($kind, $name, ${callStructure.structureToString()})'; | 262 return 'Selector($kind, $name, ${callStructure.structureToString()})'; |
268 } | 263 } |
269 | 264 |
270 Selector toCallSelector() => new Selector.callClosureFrom(this); | 265 Selector toCallSelector() => new Selector.callClosureFrom(this); |
271 } | 266 } |
OLD | NEW |