OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of types; | 5 part of types; |
6 | 6 |
7 /** | 7 /** |
8 * A type mask represents a set of contained classes, but the | 8 * A type mask represents a set of contained classes, but the |
9 * operations on it are not guaranteed to be precise and they may | 9 * operations on it are not guaranteed to be precise and they may |
10 * yield conservative answers that contain too many classes. | 10 * yield conservative answers that contain too many classes. |
11 */ | 11 */ |
12 abstract class TypeMask { | 12 abstract class TypeMask { |
13 factory TypeMask(ClassElement base, | 13 factory TypeMask(ClassElement base, |
14 int kind, | 14 int kind, |
15 bool isNullable, | 15 bool isNullable, |
16 ClassWorld classWorld) { | 16 ClassWorld classWorld) { |
17 return new FlatTypeMask.normalized( | 17 return new FlatTypeMask.normalized( |
18 base, (kind << 1) | (isNullable ? 1 : 0), classWorld); | 18 base, (kind << 1) | (isNullable ? 1 : 0), classWorld); |
19 } | 19 } |
20 | 20 |
21 const factory TypeMask.empty() = FlatTypeMask.empty; | 21 const factory TypeMask.empty() = FlatTypeMask.empty; |
22 | 22 |
23 factory TypeMask.exact(ClassElement base, ClassWorld classWorld) { | 23 factory TypeMask.exact(ClassElement base, ClassWorld classWorld) { |
24 assert(invariant(base, classWorld.isInstantiated(base), | 24 assert(invariant(base, classWorld.isInstantiated(base), |
25 message: "Cannot create extact type mask for uninstantiated class " | 25 message: "Cannot create extact type mask for " |
26 "${base.name}")); | 26 "uninstantiated class $base")); |
27 return new FlatTypeMask.exact(base); | 27 return new FlatTypeMask.exact(base); |
28 } | 28 } |
29 | 29 |
30 factory TypeMask.exactOrEmpty(ClassElement base, ClassWorld classWorld) { | 30 factory TypeMask.exactOrEmpty(ClassElement base, ClassWorld classWorld) { |
31 if (classWorld.isInstantiated(base)) return new FlatTypeMask.exact(base); | 31 if (classWorld.isInstantiated(base)) return new FlatTypeMask.exact(base); |
32 return const TypeMask.empty(); | 32 return const TypeMask.empty(); |
33 } | 33 } |
34 | 34 |
35 factory TypeMask.subclass(ClassElement base, ClassWorld classWorld) { | 35 factory TypeMask.subclass(ClassElement base, ClassWorld classWorld) { |
36 if (classWorld.hasAnySubclass(base)) { | 36 if (classWorld.hasAnySubclass(base)) { |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 /** | 264 /** |
265 * Returns the [element] that is known to always be hit at runtime | 265 * Returns the [element] that is known to always be hit at runtime |
266 * on this mask. Returns null if there is none. | 266 * on this mask. Returns null if there is none. |
267 */ | 267 */ |
268 // TODO(johnniwinther): Move this method to [World]. | 268 // TODO(johnniwinther): Move this method to [World]. |
269 Element locateSingleElement( | 269 Element locateSingleElement( |
270 Selector selector, | 270 Selector selector, |
271 TypeMask mask, | 271 TypeMask mask, |
272 Compiler compiler); | 272 Compiler compiler); |
273 } | 273 } |
OLD | NEW |