| 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 library dart2js.selector; | 5 library dart2js.selector; |
| 6 | 6 |
| 7 import '../common/names.dart' show | 7 import '../common/names.dart' show |
| 8 Names; | 8 Names; |
| 9 import '../diagnostics/spannable.dart' show | 9 import '../diagnostics/spannable.dart' show |
| 10 SpannableAssertionFailure; | 10 SpannableAssertionFailure; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 bool get isSetter => kind == SelectorKind.SETTER; | 193 bool get isSetter => kind == SelectorKind.SETTER; |
| 194 bool get isCall => kind == SelectorKind.CALL; | 194 bool get isCall => kind == SelectorKind.CALL; |
| 195 bool get isClosureCall => isCall && memberName == Names.CALL_NAME; | 195 bool get isClosureCall => isCall && memberName == Names.CALL_NAME; |
| 196 | 196 |
| 197 bool get isIndex => kind == SelectorKind.INDEX && argumentCount == 1; | 197 bool get isIndex => kind == SelectorKind.INDEX && argumentCount == 1; |
| 198 bool get isIndexSet => kind == SelectorKind.INDEX && argumentCount == 2; | 198 bool get isIndexSet => kind == SelectorKind.INDEX && argumentCount == 2; |
| 199 | 199 |
| 200 bool get isOperator => kind == SelectorKind.OPERATOR; | 200 bool get isOperator => kind == SelectorKind.OPERATOR; |
| 201 bool get isUnaryOperator => isOperator && argumentCount == 0; | 201 bool get isUnaryOperator => isOperator && argumentCount == 0; |
| 202 | 202 |
| 203 /** Check whether this is a call to 'assert'. */ |
| 204 bool get isAssert => isCall && identical(name, "assert"); |
| 205 |
| 203 /** | 206 /** |
| 204 * The member name for invocation mirrors created from this selector. | 207 * The member name for invocation mirrors created from this selector. |
| 205 */ | 208 */ |
| 206 String get invocationMirrorMemberName => | 209 String get invocationMirrorMemberName => |
| 207 isSetter ? '$name=' : name; | 210 isSetter ? '$name=' : name; |
| 208 | 211 |
| 209 int get invocationMirrorKind { | 212 int get invocationMirrorKind { |
| 210 const int METHOD = 0; | 213 const int METHOD = 0; |
| 211 const int GETTER = 1; | 214 const int GETTER = 1; |
| 212 const int SETTER = 2; | 215 const int SETTER = 2; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 return signatureApplies(element); | 248 return signatureApplies(element); |
| 246 } | 249 } |
| 247 | 250 |
| 248 bool signatureApplies(FunctionElement function) { | 251 bool signatureApplies(FunctionElement function) { |
| 249 if (Elements.isUnresolved(function)) return false; | 252 if (Elements.isUnresolved(function)) return false; |
| 250 return callStructure.signatureApplies(function.functionSignature); | 253 return callStructure.signatureApplies(function.functionSignature); |
| 251 } | 254 } |
| 252 | 255 |
| 253 bool sameNameHack(Element element, World world) { | 256 bool sameNameHack(Element element, World world) { |
| 254 // TODO(ngeoffray): Remove workaround checks. | 257 // TODO(ngeoffray): Remove workaround checks. |
| 255 return element.isConstructor || name == element.name; | 258 return element.isConstructor || |
| 259 name == element.name || |
| 260 name == 'assert' && world.isAssertMethod(element); |
| 256 } | 261 } |
| 257 | 262 |
| 258 bool applies(Element element, World world) { | 263 bool applies(Element element, World world) { |
| 259 if (!sameNameHack(element, world)) return false; | 264 if (!sameNameHack(element, world)) return false; |
| 260 return appliesUnnamed(element, world); | 265 return appliesUnnamed(element, world); |
| 261 } | 266 } |
| 262 | 267 |
| 263 bool match(SelectorKind kind, | 268 bool match(SelectorKind kind, |
| 264 Name memberName, | 269 Name memberName, |
| 265 CallStructure callStructure) { | 270 CallStructure callStructure) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 276 // Add bits from the call structure. | 281 // Add bits from the call structure. |
| 277 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); | 282 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); |
| 278 } | 283 } |
| 279 | 284 |
| 280 String toString() { | 285 String toString() { |
| 281 return 'Selector($kind, $name, ${callStructure.structureToString()})'; | 286 return 'Selector($kind, $name, ${callStructure.structureToString()})'; |
| 282 } | 287 } |
| 283 | 288 |
| 284 Selector toCallSelector() => new Selector.callClosureFrom(this); | 289 Selector toCallSelector() => new Selector.callClosureFrom(this); |
| 285 } | 290 } |
| OLD | NEW |