| 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 '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
| 8 import '../dart2jslib.dart'; | 8 import '../dart2jslib.dart'; |
| 9 import '../dart_types.dart'; | 9 import '../dart_types.dart'; |
| 10 import '../types/types.dart'; | 10 import '../types/types.dart'; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 } | 588 } |
| 589 | 589 |
| 590 String toString() { | 590 String toString() { |
| 591 String named = ''; | 591 String named = ''; |
| 592 String type = ''; | 592 String type = ''; |
| 593 if (namedArgumentCount > 0) named = ', named=${namedArgumentsToString()}'; | 593 if (namedArgumentCount > 0) named = ', named=${namedArgumentsToString()}'; |
| 594 if (mask != null) type = ', mask=$mask'; | 594 if (mask != null) type = ', mask=$mask'; |
| 595 return 'Selector($kind, $name, ' | 595 return 'Selector($kind, $name, ' |
| 596 'arity=$argumentCount$named$type)'; | 596 'arity=$argumentCount$named$type)'; |
| 597 } | 597 } |
| 598 |
| 599 Selector extendIfReachesAll(Compiler compiler) { |
| 600 return new TypedSelector(compiler.typesTask.dynamicType, this); |
| 601 } |
| 598 } | 602 } |
| 599 | 603 |
| 600 class TypedSelector extends Selector { | 604 class TypedSelector extends Selector { |
| 601 final Selector asUntyped; | 605 final Selector asUntyped; |
| 602 final TypeMask mask; | 606 final TypeMask mask; |
| 603 | 607 |
| 604 TypedSelector.internal(this.mask, Selector selector, int hashCode) | 608 TypedSelector.internal(this.mask, Selector selector, int hashCode) |
| 605 : asUntyped = selector, | 609 : asUntyped = selector, |
| 606 super.internal(selector.kind, | 610 super.internal(selector.kind, |
| 607 selector.name, | 611 selector.name, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 // get foo => () => 42; | 653 // get foo => () => 42; |
| 650 // bar() => foo(); // The call to 'foo' is a typed selector. | 654 // bar() => foo(); // The call to 'foo' is a typed selector. |
| 651 // } | 655 // } |
| 652 if (element.getEnclosingClass().isClosure()) { | 656 if (element.getEnclosingClass().isClosure()) { |
| 653 return appliesUntyped(element, compiler); | 657 return appliesUntyped(element, compiler); |
| 654 } | 658 } |
| 655 | 659 |
| 656 if (!mask.canHit(element, this, compiler)) return false; | 660 if (!mask.canHit(element, this, compiler)) return false; |
| 657 return appliesUntyped(element, compiler); | 661 return appliesUntyped(element, compiler); |
| 658 } | 662 } |
| 663 |
| 664 Selector extendIfReachesAll(Compiler compiler) { |
| 665 bool canReachAll = compiler.enabledInvokeOn |
| 666 && mask.needsNoSuchMethodHandling(this, compiler); |
| 667 return canReachAll |
| 668 ? new TypedSelector(compiler.typesTask.dynamicType, this) |
| 669 : this; |
| 670 } |
| 659 } | 671 } |
| OLD | NEW |