| 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 class Universe { | 5 class Universe { |
| 6 Map<Element, CodeBuffer> generatedCode; | 6 Map<Element, CodeBuffer> generatedCode; |
| 7 Map<Element, CodeBuffer> generatedBailoutCode; | 7 Map<Element, CodeBuffer> generatedBailoutCode; |
| 8 final Set<ClassElement> instantiatedClasses; | 8 final Set<ClassElement> instantiatedClasses; |
| 9 final Set<SourceString> instantiatedClassInstanceFields; | 9 final Set<SourceString> instantiatedClassInstanceFields; |
| 10 final Set<FunctionElement> staticFunctionsNeedingGetter; | 10 final Set<FunctionElement> staticFunctionsNeedingGetter; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 => Elements.constructOperatorName( | 161 => Elements.constructOperatorName( |
| 162 const SourceString('operator'), name, isUnary); | 162 const SourceString('operator'), name, isUnary); |
| 163 | 163 |
| 164 static SourceString indexName() | 164 static SourceString indexName() |
| 165 => operatorName(const SourceString('[]'), false); | 165 => operatorName(const SourceString('[]'), false); |
| 166 | 166 |
| 167 static SourceString indexSetName() | 167 static SourceString indexSetName() |
| 168 => operatorName(const SourceString('[]='), false); | 168 => operatorName(const SourceString('[]='), false); |
| 169 | 169 |
| 170 int hashCode() => argumentCount + 1000 * namedArguments.length; | 170 int hashCode() => argumentCount + 1000 * namedArguments.length; |
| 171 int get namedArgumentCount() => namedArguments.length; | 171 int get namedArgumentCount => namedArguments.length; |
| 172 int get positionalArgumentCount() => argumentCount - namedArgumentCount; | 172 int get positionalArgumentCount => argumentCount - namedArgumentCount; |
| 173 Type get receiverType() => null; | 173 Type get receiverType => null; |
| 174 | 174 |
| 175 bool applies(Element element, Compiler compiler) { | 175 bool applies(Element element, Compiler compiler) { |
| 176 if (element.isSetter()) return isSetter(); | 176 if (element.isSetter()) return isSetter(); |
| 177 if (element.isGetter()) return isGetter() || isCall(); | 177 if (element.isGetter()) return isGetter() || isCall(); |
| 178 if (element.isField()) return isGetter() || isSetter() || isCall(); | 178 if (element.isField()) return isGetter() || isSetter() || isCall(); |
| 179 if (isGetter()) return true; | 179 if (isGetter()) return true; |
| 180 | 180 |
| 181 FunctionElement function = element; | 181 FunctionElement function = element; |
| 182 FunctionSignature parameters = function.computeSignature(compiler); | 182 FunctionSignature parameters = function.computeSignature(compiler); |
| 183 if (argumentCount > parameters.parameterCount) return false; | 183 if (argumentCount > parameters.parameterCount) return false; |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 } | 355 } |
| 356 return false; | 356 return false; |
| 357 } | 357 } |
| 358 | 358 |
| 359 bool applies(Element element, Compiler compiler) { | 359 bool applies(Element element, Compiler compiler) { |
| 360 if (!element.isMember()) return false; | 360 if (!element.isMember()) return false; |
| 361 | 361 |
| 362 // A closure can be called through any typed selector: | 362 // A closure can be called through any typed selector: |
| 363 // class A { | 363 // class A { |
| 364 // get foo() => () => 42; | 364 // get foo => () => 42; |
| 365 // bar() => foo(); // The call to 'foo' is a typed selector. | 365 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 366 // } | 366 // } |
| 367 ClassElement other = element.getEnclosingClass(); | 367 ClassElement other = element.getEnclosingClass(); |
| 368 if (other.superclass === compiler.closureClass) { | 368 if (other.superclass === compiler.closureClass) { |
| 369 return super.applies(element, compiler); | 369 return super.applies(element, compiler); |
| 370 } | 370 } |
| 371 | 371 |
| 372 ClassElement self = receiverType.element; | 372 ClassElement self = receiverType.element; |
| 373 // TODO(ngeoffray): tree-shake on interfaces. | 373 // TODO(ngeoffray): tree-shake on interfaces. |
| 374 if (self.isInterface() || other.isSubclassOf(self)) { | 374 if (self.isInterface() || other.isSubclassOf(self)) { |
| 375 return super.applies(element, compiler); | 375 return super.applies(element, compiler); |
| 376 } | 376 } |
| 377 | 377 |
| 378 if (!self.isInterface() && self.isSubclassOf(other)) { | 378 if (!self.isInterface() && self.isSubclassOf(other)) { |
| 379 // Resolve an invocation of [element.name] on [self]. If it | 379 // Resolve an invocation of [element.name] on [self]. If it |
| 380 // is found, this selector is a candidate. | 380 // is found, this selector is a candidate. |
| 381 return hasElementIn(self, element) && super.applies(element, compiler); | 381 return hasElementIn(self, element) && super.applies(element, compiler); |
| 382 } | 382 } |
| 383 | 383 |
| 384 return false; | 384 return false; |
| 385 } | 385 } |
| 386 | 386 |
| 387 toString() => 'Selector($kind, $name, $argumentCount, type=$receiverType)'; | 387 toString() => 'Selector($kind, $name, $argumentCount, type=$receiverType)'; |
| 388 } | 388 } |
| OLD | NEW |