| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.constants.expressions; | 5 library dart2js.constants.expressions; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../constants/constant_system.dart'; | 8 import '../constants/constant_system.dart'; |
| 9 import '../core_types.dart'; | 9 import '../core_types.dart'; |
| 10 import '../dart_types.dart'; | 10 import '../dart_types.dart'; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 /// Implicit constants are simple literals, like bool, int and string | 126 /// Implicit constants are simple literals, like bool, int and string |
| 127 /// literals, constant references and compositions of implicit constants. | 127 /// literals, constant references and compositions of implicit constants. |
| 128 /// Explicit constants are constructor constants, and constant map and list | 128 /// Explicit constants are constructor constants, and constant map and list |
| 129 /// literals. | 129 /// literals. |
| 130 bool get isImplicit => true; | 130 bool get isImplicit => true; |
| 131 | 131 |
| 132 /// Returns `true` if this expression is only potentially constant, that is, | 132 /// Returns `true` if this expression is only potentially constant, that is, |
| 133 /// if it contains positional or named references, used to define constant | 133 /// if it contains positional or named references, used to define constant |
| 134 /// constructors. | 134 /// constructors. |
| 135 // TODO(johnniwinther): Maybe make this final if we use it outside assertions. | 135 // TODO(johnniwinther): Maybe make this final if we use it outside assertions. |
| 136 bool get isPotential => true; | 136 bool get isPotential => false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 /// A synthetic constant used to recover from errors. | 139 /// A synthetic constant used to recover from errors. |
| 140 class ErroneousConstantExpression extends ConstantExpression { | 140 class ErroneousConstantExpression extends ConstantExpression { |
| 141 ConstantExpressionKind get kind => ConstantExpressionKind.ERRONEOUS; | 141 ConstantExpressionKind get kind => ConstantExpressionKind.ERRONEOUS; |
| 142 | 142 |
| 143 accept(ConstantExpressionVisitor visitor, [context]) { | 143 accept(ConstantExpressionVisitor visitor, [context]) { |
| 144 // Do nothing. This is an error. | 144 // Do nothing. This is an error. |
| 145 } | 145 } |
| 146 | 146 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 188 } |
| 189 | 189 |
| 190 @override | 190 @override |
| 191 bool _equals(SyntheticConstantExpression other) { | 191 bool _equals(SyntheticConstantExpression other) { |
| 192 return value == other.value; | 192 return value == other.value; |
| 193 } | 193 } |
| 194 | 194 |
| 195 ConstantExpressionKind get kind => ConstantExpressionKind.SYNTHETIC; | 195 ConstantExpressionKind get kind => ConstantExpressionKind.SYNTHETIC; |
| 196 | 196 |
| 197 @override | 197 @override |
| 198 bool get isPotential => false; | |
| 199 | |
| 200 @override | |
| 201 bool get isImplicit => false; | 198 bool get isImplicit => false; |
| 202 } | 199 } |
| 203 | 200 |
| 204 /// A boolean, int, double, string, or null constant. | 201 /// A boolean, int, double, string, or null constant. |
| 205 abstract class PrimitiveConstantExpression extends ConstantExpression { | 202 abstract class PrimitiveConstantExpression extends ConstantExpression { |
| 206 /// The primitive value of this contant expression. | 203 /// The primitive value of this contant expression. |
| 207 get primitiveValue; | 204 get primitiveValue; |
| 208 } | 205 } |
| 209 | 206 |
| 210 /// Boolean literal constant. | 207 /// Boolean literal constant. |
| (...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 @override | 1260 @override |
| 1264 bool _equals(PositionalArgumentReference other) => index == other.index; | 1261 bool _equals(PositionalArgumentReference other) => index == other.index; |
| 1265 | 1262 |
| 1266 @override | 1263 @override |
| 1267 ConstantValue evaluate( | 1264 ConstantValue evaluate( |
| 1268 Environment environment, ConstantSystem constantSystem) { | 1265 Environment environment, ConstantSystem constantSystem) { |
| 1269 throw new UnsupportedError('PositionalArgumentReference.evaluate'); | 1266 throw new UnsupportedError('PositionalArgumentReference.evaluate'); |
| 1270 } | 1267 } |
| 1271 | 1268 |
| 1272 @override | 1269 @override |
| 1273 bool get isPotential { | 1270 bool get isPotential => true; |
| 1274 return true; | |
| 1275 } | |
| 1276 } | 1271 } |
| 1277 | 1272 |
| 1278 /// A reference to a named parameter. | 1273 /// A reference to a named parameter. |
| 1279 class NamedArgumentReference extends ConstantExpression { | 1274 class NamedArgumentReference extends ConstantExpression { |
| 1280 final String name; | 1275 final String name; |
| 1281 | 1276 |
| 1282 NamedArgumentReference(this.name); | 1277 NamedArgumentReference(this.name); |
| 1283 | 1278 |
| 1284 ConstantExpressionKind get kind { | 1279 ConstantExpressionKind get kind { |
| 1285 return ConstantExpressionKind.NAMED_REFERENCE; | 1280 return ConstantExpressionKind.NAMED_REFERENCE; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1304 @override | 1299 @override |
| 1305 bool _equals(NamedArgumentReference other) => name == other.name; | 1300 bool _equals(NamedArgumentReference other) => name == other.name; |
| 1306 | 1301 |
| 1307 @override | 1302 @override |
| 1308 ConstantValue evaluate( | 1303 ConstantValue evaluate( |
| 1309 Environment environment, ConstantSystem constantSystem) { | 1304 Environment environment, ConstantSystem constantSystem) { |
| 1310 throw new UnsupportedError('NamedArgumentReference.evaluate'); | 1305 throw new UnsupportedError('NamedArgumentReference.evaluate'); |
| 1311 } | 1306 } |
| 1312 | 1307 |
| 1313 @override | 1308 @override |
| 1314 bool get isPotential { | 1309 bool get isPotential => true; |
| 1315 return true; | |
| 1316 } | |
| 1317 } | 1310 } |
| 1318 | 1311 |
| 1319 abstract class FromEnvironmentConstantExpression extends ConstantExpression { | 1312 abstract class FromEnvironmentConstantExpression extends ConstantExpression { |
| 1320 final ConstantExpression name; | 1313 final ConstantExpression name; |
| 1321 final ConstantExpression defaultValue; | 1314 final ConstantExpression defaultValue; |
| 1322 | 1315 |
| 1323 FromEnvironmentConstantExpression(this.name, this.defaultValue); | 1316 FromEnvironmentConstantExpression(this.name, this.defaultValue); |
| 1324 | 1317 |
| 1325 @override | 1318 @override |
| 1326 int _computeHashCode() { | 1319 int _computeHashCode() { |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1881 visit(exp.name); | 1874 visit(exp.name); |
| 1882 if (exp.defaultValue != null) { | 1875 if (exp.defaultValue != null) { |
| 1883 sb.write(', defaultValue: '); | 1876 sb.write(', defaultValue: '); |
| 1884 visit(exp.defaultValue); | 1877 visit(exp.defaultValue); |
| 1885 } | 1878 } |
| 1886 sb.write(')'); | 1879 sb.write(')'); |
| 1887 } | 1880 } |
| 1888 | 1881 |
| 1889 String toString() => sb.toString(); | 1882 String toString() => sb.toString(); |
| 1890 } | 1883 } |
| OLD | NEW |