| 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 universe; | 5 library universe; |
| 6 | 6 |
| 7 import '../closure.dart'; | 7 import '../closure.dart'; |
| 8 import '../elements/elements.dart'; | 8 import '../elements/elements.dart'; |
| 9 import '../dart2jslib.dart'; | 9 import '../dart2jslib.dart'; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 bool isIndex() => identical(kind, SelectorKind.INDEX) && argumentCount == 1; | 219 bool isIndex() => identical(kind, SelectorKind.INDEX) && argumentCount == 1; |
| 220 bool isIndexSet() => identical(kind, SelectorKind.INDEX) && argumentCount == 2
; | 220 bool isIndexSet() => identical(kind, SelectorKind.INDEX) && argumentCount == 2
; |
| 221 | 221 |
| 222 bool isOperator() => identical(kind, SelectorKind.OPERATOR); | 222 bool isOperator() => identical(kind, SelectorKind.OPERATOR); |
| 223 bool isUnaryOperator() => isOperator() && argumentCount == 0; | 223 bool isUnaryOperator() => isOperator() && argumentCount == 0; |
| 224 bool isBinaryOperator() => isOperator() && argumentCount == 1; | 224 bool isBinaryOperator() => isOperator() && argumentCount == 1; |
| 225 | 225 |
| 226 /** Check whether this is a call to 'assert'. */ | 226 /** Check whether this is a call to 'assert'. */ |
| 227 bool isAssert() => isCall() && identical(name.stringValue, "assert"); | 227 bool isAssert() => isCall() && identical(name.stringValue, "assert"); |
| 228 | 228 |
| 229 /** Check whether this is a closure invocation call. */ |
| 230 bool isClosureCall() => |
| 231 isCall() && identical(name.stringValue, Compiler.CALL_OPERATOR_NAME); |
| 232 |
| 229 int get hashCode => argumentCount + 1000 * namedArguments.length; | 233 int get hashCode => argumentCount + 1000 * namedArguments.length; |
| 230 int get namedArgumentCount => namedArguments.length; | 234 int get namedArgumentCount => namedArguments.length; |
| 231 int get positionalArgumentCount => argumentCount - namedArgumentCount; | 235 int get positionalArgumentCount => argumentCount - namedArgumentCount; |
| 232 DartType get receiverType => null; | 236 DartType get receiverType => null; |
| 233 | 237 |
| 234 /** | 238 /** |
| 235 * The member name for invocation mirrors created from this selector. | 239 * The member name for invocation mirrors created from this selector. |
| 236 */ | 240 */ |
| 237 String get invocationMirrorMemberName => | 241 String get invocationMirrorMemberName => |
| 238 isSetter() ? '${name.slowToString()}=' : name.slowToString(); | 242 isSetter() ? '${name.slowToString()}=' : name.slowToString(); |
| 239 | 243 |
| 240 int get invocationMirrorKind { | 244 int get invocationMirrorKind { |
| 241 const int METHOD = 0; | 245 const int METHOD = 0; |
| 242 const int GETTER = 1; | 246 const int GETTER = 1; |
| 243 const int SETTER = 2; | 247 const int SETTER = 2; |
| 244 int kind = METHOD; | 248 int kind = METHOD; |
| 245 if (isGetter()) { | 249 if (isGetter()) { |
| 246 kind = GETTER; | 250 kind = GETTER; |
| 247 } else if (isSetter()) { | 251 } else if (isSetter()) { |
| 248 kind = SETTER; | 252 kind = SETTER; |
| 249 } | 253 } |
| 250 return kind; | 254 return kind; |
| 251 } | 255 } |
| 252 | 256 |
| 253 bool applies(Element element, Compiler compiler) | 257 bool applies(Element element, Compiler compiler) |
| 254 => appliesUntyped(element, compiler); | 258 => appliesUntyped(element, compiler); |
| 255 | 259 |
| 256 bool appliesUntyped(Element element, Compiler compiler) { | 260 bool appliesUntyped(Element element, Compiler compiler) { |
| 257 if (Elements.isUnresolved(element)) return false; | 261 if (Elements.isUnresolved(element)) return false; |
| 262 if (name.isPrivate() && library != element.getLibrary()) return false; |
| 258 if (element.isForeign(compiler)) return true; | 263 if (element.isForeign(compiler)) return true; |
| 259 | |
| 260 if (element.isSetter()) return isSetter(); | 264 if (element.isSetter()) return isSetter(); |
| 261 if (element.isGetter()) return isGetter() || isCall(); | 265 if (element.isGetter()) return isGetter() || isCall(); |
| 262 if (element.isField()) return isGetter() || isSetter() || isCall(); | 266 if (element.isField()) return isGetter() || isSetter() || isCall(); |
| 263 if (isGetter()) return true; | 267 if (isGetter()) return true; |
| 264 if (isSetter()) return false; | 268 if (isSetter()) return false; |
| 265 | 269 |
| 266 FunctionElement function = element; | 270 FunctionElement function = element; |
| 267 FunctionSignature parameters = function.computeSignature(compiler); | 271 FunctionSignature parameters = function.computeSignature(compiler); |
| 268 if (argumentCount > parameters.parameterCount) return false; | 272 if (argumentCount > parameters.parameterCount) return false; |
| 269 int requiredParameterCount = parameters.requiredParameterCount; | 273 int requiredParameterCount = parameters.requiredParameterCount; |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 ClassElement cls = self; | 479 ClassElement cls = self; |
| 476 if (cls.isSubclassOf(other)) { | 480 if (cls.isSubclassOf(other)) { |
| 477 // Resolve an invocation of [element.name] on [self]. If it | 481 // Resolve an invocation of [element.name] on [self]. If it |
| 478 // is found, this selector is a candidate. | 482 // is found, this selector is a candidate. |
| 479 return hasElementIn(self, element) && appliesUntyped(element, compiler); | 483 return hasElementIn(self, element) && appliesUntyped(element, compiler); |
| 480 } | 484 } |
| 481 | 485 |
| 482 return false; | 486 return false; |
| 483 } | 487 } |
| 484 } | 488 } |
| OLD | NEW |