| 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 | |
| 206 /** | 203 /** |
| 207 * The member name for invocation mirrors created from this selector. | 204 * The member name for invocation mirrors created from this selector. |
| 208 */ | 205 */ |
| 209 String get invocationMirrorMemberName => | 206 String get invocationMirrorMemberName => |
| 210 isSetter ? '$name=' : name; | 207 isSetter ? '$name=' : name; |
| 211 | 208 |
| 212 int get invocationMirrorKind { | 209 int get invocationMirrorKind { |
| 213 const int METHOD = 0; | 210 const int METHOD = 0; |
| 214 const int GETTER = 1; | 211 const int GETTER = 1; |
| 215 const int SETTER = 2; | 212 const int SETTER = 2; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return signatureApplies(element); | 245 return signatureApplies(element); |
| 249 } | 246 } |
| 250 | 247 |
| 251 bool signatureApplies(FunctionElement function) { | 248 bool signatureApplies(FunctionElement function) { |
| 252 if (Elements.isUnresolved(function)) return false; | 249 if (Elements.isUnresolved(function)) return false; |
| 253 return callStructure.signatureApplies(function.functionSignature); | 250 return callStructure.signatureApplies(function.functionSignature); |
| 254 } | 251 } |
| 255 | 252 |
| 256 bool sameNameHack(Element element, World world) { | 253 bool sameNameHack(Element element, World world) { |
| 257 // TODO(ngeoffray): Remove workaround checks. | 254 // TODO(ngeoffray): Remove workaround checks. |
| 258 return element.isConstructor || | 255 return element.isConstructor || name == element.name; |
| 259 name == element.name || | |
| 260 name == 'assert' && world.isAssertMethod(element); | |
| 261 } | 256 } |
| 262 | 257 |
| 263 bool applies(Element element, World world) { | 258 bool applies(Element element, World world) { |
| 264 if (!sameNameHack(element, world)) return false; | 259 if (!sameNameHack(element, world)) return false; |
| 265 return appliesUnnamed(element, world); | 260 return appliesUnnamed(element, world); |
| 266 } | 261 } |
| 267 | 262 |
| 268 bool match(SelectorKind kind, | 263 bool match(SelectorKind kind, |
| 269 Name memberName, | 264 Name memberName, |
| 270 CallStructure callStructure) { | 265 CallStructure callStructure) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 281 // Add bits from the call structure. | 276 // Add bits from the call structure. |
| 282 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); | 277 return Hashing.mixHashCodeBits(hash, callStructure.hashCode); |
| 283 } | 278 } |
| 284 | 279 |
| 285 String toString() { | 280 String toString() { |
| 286 return 'Selector($kind, $name, ${callStructure.structureToString()})'; | 281 return 'Selector($kind, $name, ${callStructure.structureToString()})'; |
| 287 } | 282 } |
| 288 | 283 |
| 289 Selector toCallSelector() => new Selector.callClosureFrom(this); | 284 Selector toCallSelector() => new Selector.callClosureFrom(this); |
| 290 } | 285 } |
| OLD | NEW |