Chromium Code Reviews| Index: pkg/compiler/lib/src/cps_ir/type_mask_system.dart |
| diff --git a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart |
| index a5fa5a8dc9618e51ca53f4b51496735ff404cdbf..a57775db39d660f5fdac94e1fd9c6cc1f143634e 100644 |
| --- a/pkg/compiler/lib/src/cps_ir/type_mask_system.dart |
| +++ b/pkg/compiler/lib/src/cps_ir/type_mask_system.dart |
| @@ -295,4 +295,31 @@ class TypeMaskSystem { |
| TypeMask receiverTypeFor(Selector selector, TypeMask mask) { |
| return classWorld.allFunctions.receiverType(selector, mask); |
| } |
| + |
| + /// The result of an index operation on something of [type], or the dynamic |
| + /// type if unknown. |
| + TypeMask getIndexType(TypeMask type) { |
|
sra1
2015/09/15 15:59:32
Is there a nice way to write this kind of function
sra1
2015/09/15 15:59:32
'getIndexType' suggests to me the argument type of
asgerf
2015/09/15 16:34:07
I don't entirely understand the use of forwarding
|
| + if (type is ContainerTypeMask) { |
|
karlklose
2015/09/15 08:17:07
We should maybe use a predicate instead of the is
asgerf
2015/09/15 10:46:14
The idea is that TypeMaskSystem should be that int
|
| + return type.elementType; |
| + } |
| + if (isDefinitelyString(type)) { |
| + return stringType; |
| + } |
| + if (type.satisfies(backend.typedArrayClass, classWorld)) { |
| + if (type.satisfies(backend.typedArrayOfIntClass, classWorld)) { |
| + return intType; |
| + } |
| + return numType; |
| + } |
| + return dynamicType; |
| + } |
| + |
| + /// The length of something of [type], or `null` if unknown. |
| + int getContainerLength(TypeMask type) { |
| + if (type is ContainerTypeMask) { |
| + return type.length; |
| + } else { |
| + return null; |
| + } |
| + } |
| } |