| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.abstract_value_domain; | 5 library dart2js.abstract_value_domain; |
| 6 | 6 |
| 7 import '../constants/values.dart'; | 7 import '../constants/values.dart'; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../universe/selector.dart' show Selector; | 10 import '../universe/selector.dart' show Selector; |
| 11 | 11 |
| 12 enum AbstractBool { | 12 enum AbstractBool { True, False, Maybe, Nothing } |
| 13 True, False, Maybe, Nothing | |
| 14 } | |
| 15 | 13 |
| 16 /// A value in an abstraction of runtime values. | 14 /// A value in an abstraction of runtime values. |
| 17 abstract class AbstractValue {} | 15 abstract class AbstractValue {} |
| 18 | 16 |
| 19 /// A system that implements an abstraction over runtime values and provides | 17 /// A system that implements an abstraction over runtime values and provides |
| 20 /// access to interprocedural analysis results. | 18 /// access to interprocedural analysis results. |
| 21 // TODO(johnniwinther): Consider extracting the inference result access from | 19 // TODO(johnniwinther): Consider extracting the inference result access from |
| 22 // this interface. | 20 // this interface. |
| 23 abstract class AbstractValueDomain { | 21 abstract class AbstractValueDomain { |
| 24 AbstractValue get dynamicType; | 22 AbstractValue get dynamicType; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 118 |
| 121 bool isDefinitelyFixedArray(AbstractValue t, {bool allowNull: false}); | 119 bool isDefinitelyFixedArray(AbstractValue t, {bool allowNull: false}); |
| 122 | 120 |
| 123 bool isDefinitelyExtendableArray(AbstractValue t, {bool allowNull: false}); | 121 bool isDefinitelyExtendableArray(AbstractValue t, {bool allowNull: false}); |
| 124 | 122 |
| 125 bool isDefinitelyIndexable(AbstractValue t, {bool allowNull: false}); | 123 bool isDefinitelyIndexable(AbstractValue t, {bool allowNull: false}); |
| 126 | 124 |
| 127 bool isDefinitelyMutableIndexable(AbstractValue t, {bool allowNull: false}); | 125 bool isDefinitelyMutableIndexable(AbstractValue t, {bool allowNull: false}); |
| 128 | 126 |
| 129 bool isDefinitelyFixedLengthIndexable(AbstractValue t, | 127 bool isDefinitelyFixedLengthIndexable(AbstractValue t, |
| 130 {bool allowNull: false}); | 128 {bool allowNull: false}); |
| 131 | 129 |
| 132 bool isDefinitelyIntercepted(AbstractValue t, {bool allowNull}); | 130 bool isDefinitelyIntercepted(AbstractValue t, {bool allowNull}); |
| 133 | 131 |
| 134 bool isDefinitelySelfInterceptor(AbstractValue t, {bool allowNull: false}); | 132 bool isDefinitelySelfInterceptor(AbstractValue t, {bool allowNull: false}); |
| 135 | 133 |
| 136 /// Given a class from the interceptor hierarchy, returns an [AbstractValue] | 134 /// Given a class from the interceptor hierarchy, returns an [AbstractValue] |
| 137 /// matching all values with that interceptor (or a subtype thereof). | 135 /// matching all values with that interceptor (or a subtype thereof). |
| 138 AbstractValue getInterceptorSubtypes(ClassElement class_); | 136 AbstractValue getInterceptorSubtypes(ClassElement class_); |
| 139 | 137 |
| 140 bool areDisjoint(AbstractValue leftType, AbstractValue rightType); | 138 bool areDisjoint(AbstractValue leftType, AbstractValue rightType); |
| 141 | 139 |
| 142 bool isMorePreciseOrEqual(AbstractValue t1, AbstractValue t2); | 140 bool isMorePreciseOrEqual(AbstractValue t1, AbstractValue t2); |
| 143 | 141 |
| 144 AbstractBool isSubtypeOf(AbstractValue value, | 142 AbstractBool isSubtypeOf(AbstractValue value, DartType type, |
| 145 DartType type, | 143 {bool allowNull}); |
| 146 {bool allowNull}); | |
| 147 | 144 |
| 148 /// Returns whether [value] is one of the falsy values: false, 0, -0, NaN, | 145 /// Returns whether [value] is one of the falsy values: false, 0, -0, NaN, |
| 149 /// the empty string, or null. | 146 /// the empty string, or null. |
| 150 AbstractBool boolify(AbstractValue value); | 147 AbstractBool boolify(AbstractValue value); |
| 151 | 148 |
| 152 AbstractBool strictBoolify(AbstractValue type); | 149 AbstractBool strictBoolify(AbstractValue type); |
| 153 | 150 |
| 154 /// Create a type mask containing at least all subtypes of [type]. | 151 /// Create a type mask containing at least all subtypes of [type]. |
| 155 AbstractValue subtypesOf(DartType type); | 152 AbstractValue subtypesOf(DartType type); |
| 156 | 153 |
| 157 /// Returns a subset of [receiver] containing at least the types | 154 /// Returns a subset of [receiver] containing at least the types |
| 158 /// that can respond to [selector] without throwing. | 155 /// that can respond to [selector] without throwing. |
| 159 AbstractValue receiverTypeFor(Selector selector, AbstractValue receiver); | 156 AbstractValue receiverTypeFor(Selector selector, AbstractValue receiver); |
| 160 | 157 |
| 161 /// The result of an index operation on [value], or the dynamic type if | 158 /// The result of an index operation on [value], or the dynamic type if |
| 162 /// unknown. | 159 /// unknown. |
| 163 AbstractValue elementTypeOfIndexable(AbstractValue value); | 160 AbstractValue elementTypeOfIndexable(AbstractValue value); |
| 164 | 161 |
| 165 /// The length property of [value], or `null` if unknown. | 162 /// The length property of [value], or `null` if unknown. |
| 166 int getContainerLength(AbstractValue value); | 163 int getContainerLength(AbstractValue value); |
| 167 | 164 |
| 168 /// Returns the type of the entry of [container] at a given index. | 165 /// Returns the type of the entry of [container] at a given index. |
| 169 /// Returns `null` if unknown. | 166 /// Returns `null` if unknown. |
| 170 AbstractValue indexWithConstant(AbstractValue container, | 167 AbstractValue indexWithConstant( |
| 171 ConstantValue indexValue); | 168 AbstractValue container, ConstantValue indexValue); |
| 172 } | 169 } |
| OLD | NEW |