| OLD | NEW |
| 1 // TODO(sigmund): rename universe => world | 1 // TODO(sigmund): rename universe => world |
| 2 /// Describes individual features that may be seen in a program. Most features | 2 /// Describes individual features that may be seen in a program. Most features |
| 3 /// can be described only by name using the [Feature] enum, some features are | 3 /// can be described only by name using the [Feature] enum, some features are |
| 4 /// expressed including details on how they are used. For example, whether a | 4 /// expressed including details on how they are used. For example, whether a |
| 5 /// list literal was constant or empty. | 5 /// list literal was constant or empty. |
| 6 /// | 6 /// |
| 7 /// The use of these features is typically discovered in an early phase of the | 7 /// The use of these features is typically discovered in an early phase of the |
| 8 /// compilation pipeline, for example during resolution. | 8 /// compilation pipeline, for example during resolution. |
| 9 library compiler.universe.feature; | 9 library compiler.universe.feature; |
| 10 | 10 |
| 11 import '../elements/resolution_types.dart' show ResolutionInterfaceType; | 11 import '../elements/types.dart' show InterfaceType; |
| 12 | 12 |
| 13 /// A language feature that may be seen in the program. | 13 /// A language feature that may be seen in the program. |
| 14 // TODO(johnniwinther): Should mirror usage be part of this? | 14 // TODO(johnniwinther): Should mirror usage be part of this? |
| 15 enum Feature { | 15 enum Feature { |
| 16 /// Invocation of a generative construction on an abstract class. | 16 /// Invocation of a generative construction on an abstract class. |
| 17 ABSTRACT_CLASS_INSTANTIATION, | 17 ABSTRACT_CLASS_INSTANTIATION, |
| 18 | 18 |
| 19 /// An assert statement with no message. | 19 /// An assert statement with no message. |
| 20 ASSERT, | 20 ASSERT, |
| 21 | 21 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 /// An implicit throw of a runtime error, like | 81 /// An implicit throw of a runtime error, like |
| 82 THROW_RUNTIME_ERROR, | 82 THROW_RUNTIME_ERROR, |
| 83 | 83 |
| 84 /// The need for a type variable bound check, like instantiation of a generic | 84 /// The need for a type variable bound check, like instantiation of a generic |
| 85 /// type whose type variable have non-trivial bounds. | 85 /// type whose type variable have non-trivial bounds. |
| 86 TYPE_VARIABLE_BOUNDS_CHECK, | 86 TYPE_VARIABLE_BOUNDS_CHECK, |
| 87 } | 87 } |
| 88 | 88 |
| 89 /// Describes a use of a map literal in the program. | 89 /// Describes a use of a map literal in the program. |
| 90 class MapLiteralUse { | 90 class MapLiteralUse { |
| 91 final ResolutionInterfaceType type; | 91 final InterfaceType type; |
| 92 final bool isConstant; | 92 final bool isConstant; |
| 93 final bool isEmpty; | 93 final bool isEmpty; |
| 94 | 94 |
| 95 MapLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false}); | 95 MapLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false}); |
| 96 | 96 |
| 97 int get hashCode { | 97 int get hashCode { |
| 98 return type.hashCode * 13 + | 98 return type.hashCode * 13 + |
| 99 isConstant.hashCode * 17 + | 99 isConstant.hashCode * 17 + |
| 100 isEmpty.hashCode * 19; | 100 isEmpty.hashCode * 19; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool operator ==(other) { | 103 bool operator ==(other) { |
| 104 if (identical(this, other)) return true; | 104 if (identical(this, other)) return true; |
| 105 if (other is! MapLiteralUse) return false; | 105 if (other is! MapLiteralUse) return false; |
| 106 return type == other.type && | 106 return type == other.type && |
| 107 isConstant == other.isConstant && | 107 isConstant == other.isConstant && |
| 108 isEmpty == other.isEmpty; | 108 isEmpty == other.isEmpty; |
| 109 } | 109 } |
| 110 | 110 |
| 111 String toString() { | 111 String toString() { |
| 112 return 'MapLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)'; | 112 return 'MapLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)'; |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 /// Describes the use of a list literal in the program. | 116 /// Describes the use of a list literal in the program. |
| 117 class ListLiteralUse { | 117 class ListLiteralUse { |
| 118 final ResolutionInterfaceType type; | 118 final InterfaceType type; |
| 119 final bool isConstant; | 119 final bool isConstant; |
| 120 final bool isEmpty; | 120 final bool isEmpty; |
| 121 | 121 |
| 122 ListLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false}); | 122 ListLiteralUse(this.type, {this.isConstant: false, this.isEmpty: false}); |
| 123 | 123 |
| 124 int get hashCode { | 124 int get hashCode { |
| 125 return type.hashCode * 13 + | 125 return type.hashCode * 13 + |
| 126 isConstant.hashCode * 17 + | 126 isConstant.hashCode * 17 + |
| 127 isEmpty.hashCode * 19; | 127 isEmpty.hashCode * 19; |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool operator ==(other) { | 130 bool operator ==(other) { |
| 131 if (identical(this, other)) return true; | 131 if (identical(this, other)) return true; |
| 132 if (other is! ListLiteralUse) return false; | 132 if (other is! ListLiteralUse) return false; |
| 133 return type == other.type && | 133 return type == other.type && |
| 134 isConstant == other.isConstant && | 134 isConstant == other.isConstant && |
| 135 isEmpty == other.isEmpty; | 135 isEmpty == other.isEmpty; |
| 136 } | 136 } |
| 137 | 137 |
| 138 String toString() { | 138 String toString() { |
| 139 return 'ListLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)'; | 139 return 'ListLiteralUse($type,isConstant:$isConstant,isEmpty:$isEmpty)'; |
| 140 } | 140 } |
| 141 } | 141 } |
| OLD | NEW |