Chromium Code Reviews| 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 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 selector._orderedNamedArguments, | 740 selector._orderedNamedArguments, |
| 741 hashCode) { | 741 hashCode) { |
| 742 assert(mask != null); | 742 assert(mask != null); |
| 743 assert(asUntyped.mask == null); | 743 assert(asUntyped.mask == null); |
| 744 } | 744 } |
| 745 | 745 |
| 746 static Map<Selector, Map<TypeMask, TypedSelector>> canonicalizedValues = | 746 static Map<Selector, Map<TypeMask, TypedSelector>> canonicalizedValues = |
| 747 new Map<Selector, Map<TypeMask, TypedSelector>>(); | 747 new Map<Selector, Map<TypeMask, TypedSelector>>(); |
| 748 | 748 |
| 749 factory TypedSelector(TypeMask mask, Selector selector, World world) { | 749 factory TypedSelector(TypeMask mask, Selector selector, World world) { |
| 750 if (!world.hasClosedWorldAssumption) { | |
|
Johnni Winther
2014/11/17 09:56:32
Add a TODO (for me) to improve the use of TypedSel
| |
| 751 bool isNullable = mask.isNullable; | |
| 752 mask = world.compiler.typesTask.dynamicType; | |
| 753 if (isNullable) { | |
| 754 mask = mask.nullable(); | |
| 755 } | |
| 756 } | |
| 750 // TODO(johnniwinther): Allow more TypeSelector kinds during resoluton. | 757 // TODO(johnniwinther): Allow more TypeSelector kinds during resoluton. |
| 751 assert(world.isClosed || mask.isExact); | 758 assert(world.isClosed || mask.isExact); |
| 752 if (selector.mask == mask) return selector; | 759 if (selector.mask == mask) return selector; |
| 753 Selector untyped = selector.asUntyped; | 760 Selector untyped = selector.asUntyped; |
| 754 Map<TypeMask, TypedSelector> map = canonicalizedValues.putIfAbsent(untyped, | 761 Map<TypeMask, TypedSelector> map = canonicalizedValues.putIfAbsent(untyped, |
| 755 () => new Map<TypeMask, TypedSelector>()); | 762 () => new Map<TypeMask, TypedSelector>()); |
| 756 TypedSelector result = map[mask]; | 763 TypedSelector result = map[mask]; |
| 757 if (result == null) { | 764 if (result == null) { |
| 758 int hashCode = Selector.mixHashCodeBits(untyped.hashCode, mask.hashCode); | 765 int hashCode = Selector.mixHashCodeBits(untyped.hashCode, mask.hashCode); |
| 759 result = map[mask] = new TypedSelector.internal(mask, untyped, hashCode); | 766 result = map[mask] = new TypedSelector.internal(mask, untyped, hashCode); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 | 803 |
| 797 Selector extendIfReachesAll(Compiler compiler) { | 804 Selector extendIfReachesAll(Compiler compiler) { |
| 798 bool canReachAll = compiler.enabledInvokeOn | 805 bool canReachAll = compiler.enabledInvokeOn |
| 799 && mask.needsNoSuchMethodHandling(this, compiler.world); | 806 && mask.needsNoSuchMethodHandling(this, compiler.world); |
| 800 return canReachAll | 807 return canReachAll |
| 801 ? new TypedSelector( | 808 ? new TypedSelector( |
| 802 compiler.typesTask.dynamicType, this, compiler.world) | 809 compiler.typesTask.dynamicType, this, compiler.world) |
| 803 : this; | 810 : this; |
| 804 } | 811 } |
| 805 } | 812 } |
| OLD | NEW |