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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (hashCode != other.hashCode) return false; | 117 if (hashCode != other.hashCode) return false; |
118 return _equals(other); | 118 return _equals(other); |
119 } | 119 } |
120 | 120 |
121 String toString() { | 121 String toString() { |
122 assertDebugMode('Use ConstantExpression.toDartText() or ' | 122 assertDebugMode('Use ConstantExpression.toDartText() or ' |
123 'ConstantExpression.toStructuredText() instead of ' | 123 'ConstantExpression.toStructuredText() instead of ' |
124 'ConstantExpression.toString()'); | 124 'ConstantExpression.toString()'); |
125 return toDartText(); | 125 return toDartText(); |
126 } | 126 } |
| 127 |
| 128 /// Returns `true` if this expression is implicitly constant, that is, that |
| 129 /// it doesn't declare its constness with the 'const' keyword. |
| 130 /// |
| 131 /// Implicit constants are simple literals, like bool, int and string |
| 132 /// literals, constant references and compositions of implicit constants. |
| 133 /// Explicit constants are constructor constants, and constant map and list |
| 134 /// literals. |
| 135 bool get isImplicit => true; |
| 136 |
| 137 /// Returns `true` if this expression is only potentially constant, that is, |
| 138 /// if it contains positional or named references, used to define constant |
| 139 /// constructors. |
| 140 // TODO(johnniwinther): Maybe make this final if we use it outside assertions. |
| 141 bool get isPotential => true; |
127 } | 142 } |
128 | 143 |
129 /// A synthetic constant used to recover from errors. | 144 /// A synthetic constant used to recover from errors. |
130 class ErroneousConstantExpression extends ConstantExpression { | 145 class ErroneousConstantExpression extends ConstantExpression { |
131 ConstantExpressionKind get kind => ConstantExpressionKind.ERRONEOUS; | 146 ConstantExpressionKind get kind => ConstantExpressionKind.ERRONEOUS; |
132 | 147 |
133 accept(ConstantExpressionVisitor visitor, [context]) { | 148 accept(ConstantExpressionVisitor visitor, [context]) { |
134 // Do nothing. This is an error. | 149 // Do nothing. This is an error. |
135 } | 150 } |
136 | 151 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 accept(ConstantExpressionVisitor visitor, [context]) { | 191 accept(ConstantExpressionVisitor visitor, [context]) { |
177 throw "unsupported"; | 192 throw "unsupported"; |
178 } | 193 } |
179 | 194 |
180 @override | 195 @override |
181 bool _equals(SyntheticConstantExpression other) { | 196 bool _equals(SyntheticConstantExpression other) { |
182 return value == other.value; | 197 return value == other.value; |
183 } | 198 } |
184 | 199 |
185 ConstantExpressionKind get kind => ConstantExpressionKind.SYNTHETIC; | 200 ConstantExpressionKind get kind => ConstantExpressionKind.SYNTHETIC; |
| 201 |
| 202 @override |
| 203 bool get isPotential => false; |
| 204 |
| 205 @override |
| 206 bool get isImplicit => false; |
186 } | 207 } |
187 | 208 |
188 /// A boolean, int, double, string, or null constant. | 209 /// A boolean, int, double, string, or null constant. |
189 abstract class PrimitiveConstantExpression extends ConstantExpression { | 210 abstract class PrimitiveConstantExpression extends ConstantExpression { |
190 /// The primitive value of this contant expression. | 211 /// The primitive value of this contant expression. |
191 get primitiveValue; | 212 get primitiveValue; |
192 } | 213 } |
193 | 214 |
194 /// Boolean literal constant. | 215 /// Boolean literal constant. |
195 class BoolConstantExpression extends PrimitiveConstantExpression { | 216 class BoolConstantExpression extends PrimitiveConstantExpression { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (type != other.type) return false; | 436 if (type != other.type) return false; |
416 if (values.length != other.values.length) return false; | 437 if (values.length != other.values.length) return false; |
417 for (int i = 0; i < values.length; i++) { | 438 for (int i = 0; i < values.length; i++) { |
418 if (values[i] != other.values[i]) return false; | 439 if (values[i] != other.values[i]) return false; |
419 } | 440 } |
420 return true; | 441 return true; |
421 } | 442 } |
422 | 443 |
423 @override | 444 @override |
424 DartType getKnownType(CoreTypes coreTypes) => type; | 445 DartType getKnownType(CoreTypes coreTypes) => type; |
| 446 |
| 447 @override |
| 448 bool get isImplicit => false; |
| 449 |
| 450 @override |
| 451 bool get isPotential => values.any((e) => e.isPotential); |
425 } | 452 } |
426 | 453 |
427 /// Literal map constant. | 454 /// Literal map constant. |
428 class MapConstantExpression extends ConstantExpression { | 455 class MapConstantExpression extends ConstantExpression { |
429 final InterfaceType type; | 456 final InterfaceType type; |
430 final List<ConstantExpression> keys; | 457 final List<ConstantExpression> keys; |
431 final List<ConstantExpression> values; | 458 final List<ConstantExpression> values; |
432 | 459 |
433 MapConstantExpression(this.type, this.keys, this.values); | 460 MapConstantExpression(this.type, this.keys, this.values); |
434 | 461 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 if (values.length != other.values.length) return false; | 511 if (values.length != other.values.length) return false; |
485 for (int i = 0; i < values.length; i++) { | 512 for (int i = 0; i < values.length; i++) { |
486 if (keys[i] != other.keys[i]) return false; | 513 if (keys[i] != other.keys[i]) return false; |
487 if (values[i] != other.values[i]) return false; | 514 if (values[i] != other.values[i]) return false; |
488 } | 515 } |
489 return true; | 516 return true; |
490 } | 517 } |
491 | 518 |
492 @override | 519 @override |
493 DartType getKnownType(CoreTypes coreTypes) => type; | 520 DartType getKnownType(CoreTypes coreTypes) => type; |
| 521 |
| 522 @override |
| 523 bool get isImplicit => false; |
| 524 |
| 525 @override |
| 526 bool get isPotential { |
| 527 return keys.any((e) => e.isPotential) || values.any((e) => e.isPotential); |
| 528 } |
494 } | 529 } |
495 | 530 |
496 /// Invocation of a const constructor. | 531 /// Invocation of a const constructor. |
497 class ConstructedConstantExpression extends ConstantExpression { | 532 class ConstructedConstantExpression extends ConstantExpression { |
498 final InterfaceType type; | 533 final InterfaceType type; |
499 final ConstructorElement target; | 534 final ConstructorElement target; |
500 final CallStructure callStructure; | 535 final CallStructure callStructure; |
501 final List<ConstantExpression> arguments; | 536 final List<ConstantExpression> arguments; |
502 | 537 |
503 ConstructedConstantExpression( | 538 ConstructedConstantExpression( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 @override | 599 @override |
565 bool _equals(ConstructedConstantExpression other) { | 600 bool _equals(ConstructedConstantExpression other) { |
566 if (type != other.type) return false; | 601 if (type != other.type) return false; |
567 if (target != other.target) return false; | 602 if (target != other.target) return false; |
568 if (callStructure != other.callStructure) return false; | 603 if (callStructure != other.callStructure) return false; |
569 for (int i = 0; i < arguments.length; i++) { | 604 for (int i = 0; i < arguments.length; i++) { |
570 if (arguments[i] != other.arguments[i]) return false; | 605 if (arguments[i] != other.arguments[i]) return false; |
571 } | 606 } |
572 return true; | 607 return true; |
573 } | 608 } |
| 609 |
| 610 @override |
| 611 bool get isImplicit => false; |
| 612 |
| 613 @override |
| 614 bool get isPotential { |
| 615 return arguments.any((e) => e.isPotential); |
| 616 } |
574 } | 617 } |
575 | 618 |
576 /// String literal with juxtaposition and/or interpolations. | 619 /// String literal with juxtaposition and/or interpolations. |
577 class ConcatenateConstantExpression extends ConstantExpression { | 620 class ConcatenateConstantExpression extends ConstantExpression { |
578 final List<ConstantExpression> expressions; | 621 final List<ConstantExpression> expressions; |
579 | 622 |
580 ConcatenateConstantExpression(this.expressions); | 623 ConcatenateConstantExpression(this.expressions); |
581 | 624 |
582 ConstantExpressionKind get kind => ConstantExpressionKind.CONCATENATE; | 625 ConstantExpressionKind get kind => ConstantExpressionKind.CONCATENATE; |
583 | 626 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 bool _equals(ConcatenateConstantExpression other) { | 686 bool _equals(ConcatenateConstantExpression other) { |
644 if (expressions.length != other.expressions.length) return false; | 687 if (expressions.length != other.expressions.length) return false; |
645 for (int i = 0; i < expressions.length; i++) { | 688 for (int i = 0; i < expressions.length; i++) { |
646 if (expressions[i] != other.expressions[i]) return false; | 689 if (expressions[i] != other.expressions[i]) return false; |
647 } | 690 } |
648 return true; | 691 return true; |
649 } | 692 } |
650 | 693 |
651 @override | 694 @override |
652 DartType getKnownType(CoreTypes coreTypes) => coreTypes.stringType; | 695 DartType getKnownType(CoreTypes coreTypes) => coreTypes.stringType; |
| 696 |
| 697 @override |
| 698 bool get isPotential { |
| 699 return expressions.any((e) => e.isPotential); |
| 700 } |
653 } | 701 } |
654 | 702 |
655 /// Symbol literal. | 703 /// Symbol literal. |
656 class SymbolConstantExpression extends ConstantExpression { | 704 class SymbolConstantExpression extends ConstantExpression { |
657 final String name; | 705 final String name; |
658 | 706 |
659 SymbolConstantExpression(this.name); | 707 SymbolConstantExpression(this.name); |
660 | 708 |
661 ConstantExpressionKind get kind => ConstantExpressionKind.SYMBOL; | 709 ConstantExpressionKind get kind => ConstantExpressionKind.SYMBOL; |
662 | 710 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 return 13 * operator.hashCode + 17 * left.hashCode + 19 * right.hashCode; | 936 return 13 * operator.hashCode + 17 * left.hashCode + 19 * right.hashCode; |
889 } | 937 } |
890 | 938 |
891 @override | 939 @override |
892 bool _equals(BinaryConstantExpression other) { | 940 bool _equals(BinaryConstantExpression other) { |
893 return operator == other.operator && | 941 return operator == other.operator && |
894 left == other.left && | 942 left == other.left && |
895 right == other.right; | 943 right == other.right; |
896 } | 944 } |
897 | 945 |
| 946 @override |
| 947 bool get isPotential { |
| 948 return left.isPotential || right.isPotential; |
| 949 } |
| 950 |
898 static const Map<BinaryOperatorKind, int> PRECEDENCE_MAP = const { | 951 static const Map<BinaryOperatorKind, int> PRECEDENCE_MAP = const { |
899 BinaryOperatorKind.EQ: 6, | 952 BinaryOperatorKind.EQ: 6, |
900 BinaryOperatorKind.NOT_EQ: 6, | 953 BinaryOperatorKind.NOT_EQ: 6, |
901 BinaryOperatorKind.LOGICAL_AND: 5, | 954 BinaryOperatorKind.LOGICAL_AND: 5, |
902 BinaryOperatorKind.LOGICAL_OR: 4, | 955 BinaryOperatorKind.LOGICAL_OR: 4, |
903 BinaryOperatorKind.XOR: 9, | 956 BinaryOperatorKind.XOR: 9, |
904 BinaryOperatorKind.AND: 10, | 957 BinaryOperatorKind.AND: 10, |
905 BinaryOperatorKind.OR: 8, | 958 BinaryOperatorKind.OR: 8, |
906 BinaryOperatorKind.SHR: 11, | 959 BinaryOperatorKind.SHR: 11, |
907 BinaryOperatorKind.SHL: 11, | 960 BinaryOperatorKind.SHL: 11, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 return 17 * left.hashCode + 19 * right.hashCode; | 1014 return 17 * left.hashCode + 19 * right.hashCode; |
962 } | 1015 } |
963 | 1016 |
964 @override | 1017 @override |
965 bool _equals(IdenticalConstantExpression other) { | 1018 bool _equals(IdenticalConstantExpression other) { |
966 return left == other.left && right == other.right; | 1019 return left == other.left && right == other.right; |
967 } | 1020 } |
968 | 1021 |
969 @override | 1022 @override |
970 DartType getKnownType(CoreTypes coreTypes) => coreTypes.boolType; | 1023 DartType getKnownType(CoreTypes coreTypes) => coreTypes.boolType; |
| 1024 |
| 1025 @override |
| 1026 bool get isPotential { |
| 1027 return left.isPotential || right.isPotential; |
| 1028 } |
971 } | 1029 } |
972 | 1030 |
973 /// A unary constant expression like `-a`. | 1031 /// A unary constant expression like `-a`. |
974 class UnaryConstantExpression extends ConstantExpression { | 1032 class UnaryConstantExpression extends ConstantExpression { |
975 final UnaryOperator operator; | 1033 final UnaryOperator operator; |
976 final ConstantExpression expression; | 1034 final ConstantExpression expression; |
977 | 1035 |
978 UnaryConstantExpression(this.operator, this.expression) { | 1036 UnaryConstantExpression(this.operator, this.expression) { |
979 assert(PRECEDENCE_MAP[operator.kind] != null); | 1037 assert(PRECEDENCE_MAP[operator.kind] != null); |
980 } | 1038 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 @override | 1072 @override |
1015 bool _equals(UnaryConstantExpression other) { | 1073 bool _equals(UnaryConstantExpression other) { |
1016 return operator == other.operator && expression == other.expression; | 1074 return operator == other.operator && expression == other.expression; |
1017 } | 1075 } |
1018 | 1076 |
1019 @override | 1077 @override |
1020 DartType getKnownType(CoreTypes coreTypes) { | 1078 DartType getKnownType(CoreTypes coreTypes) { |
1021 return expression.getKnownType(coreTypes); | 1079 return expression.getKnownType(coreTypes); |
1022 } | 1080 } |
1023 | 1081 |
| 1082 @override |
| 1083 bool get isPotential { |
| 1084 return expression.isPotential; |
| 1085 } |
| 1086 |
1024 static const Map<UnaryOperatorKind, int> PRECEDENCE_MAP = const { | 1087 static const Map<UnaryOperatorKind, int> PRECEDENCE_MAP = const { |
1025 UnaryOperatorKind.NOT: 14, | 1088 UnaryOperatorKind.NOT: 14, |
1026 UnaryOperatorKind.COMPLEMENT: 14, | 1089 UnaryOperatorKind.COMPLEMENT: 14, |
1027 UnaryOperatorKind.NEGATE: 14, | 1090 UnaryOperatorKind.NEGATE: 14, |
1028 }; | 1091 }; |
1029 } | 1092 } |
1030 | 1093 |
1031 /// A string length constant expression like `a.length`. | 1094 /// A string length constant expression like `a.length`. |
1032 class StringLengthConstantExpression extends ConstantExpression { | 1095 class StringLengthConstantExpression extends ConstantExpression { |
1033 final ConstantExpression expression; | 1096 final ConstantExpression expression; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 return 23 * expression.hashCode; | 1132 return 23 * expression.hashCode; |
1070 } | 1133 } |
1071 | 1134 |
1072 @override | 1135 @override |
1073 bool _equals(StringLengthConstantExpression other) { | 1136 bool _equals(StringLengthConstantExpression other) { |
1074 return expression == other.expression; | 1137 return expression == other.expression; |
1075 } | 1138 } |
1076 | 1139 |
1077 @override | 1140 @override |
1078 DartType getKnownType(CoreTypes coreTypes) => coreTypes.intType; | 1141 DartType getKnownType(CoreTypes coreTypes) => coreTypes.intType; |
| 1142 |
| 1143 @override |
| 1144 bool get isPotential { |
| 1145 return expression.isPotential; |
| 1146 } |
1079 } | 1147 } |
1080 | 1148 |
1081 /// A constant conditional expression like `a ? b : c`. | 1149 /// A constant conditional expression like `a ? b : c`. |
1082 class ConditionalConstantExpression extends ConstantExpression { | 1150 class ConditionalConstantExpression extends ConstantExpression { |
1083 final ConstantExpression condition; | 1151 final ConstantExpression condition; |
1084 final ConstantExpression trueExp; | 1152 final ConstantExpression trueExp; |
1085 final ConstantExpression falseExp; | 1153 final ConstantExpression falseExp; |
1086 | 1154 |
1087 ConditionalConstantExpression(this.condition, this.trueExp, this.falseExp); | 1155 ConditionalConstantExpression(this.condition, this.trueExp, this.falseExp); |
1088 | 1156 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 | 1210 |
1143 @override | 1211 @override |
1144 DartType getKnownType(CoreTypes coreTypes) { | 1212 DartType getKnownType(CoreTypes coreTypes) { |
1145 DartType trueType = trueExp.getKnownType(coreTypes); | 1213 DartType trueType = trueExp.getKnownType(coreTypes); |
1146 DartType falseType = falseExp.getKnownType(coreTypes); | 1214 DartType falseType = falseExp.getKnownType(coreTypes); |
1147 if (trueType == falseType) { | 1215 if (trueType == falseType) { |
1148 return trueType; | 1216 return trueType; |
1149 } | 1217 } |
1150 return null; | 1218 return null; |
1151 } | 1219 } |
| 1220 |
| 1221 @override |
| 1222 bool get isPotential { |
| 1223 return condition.isPotential || trueExp.isPotential || falseExp.isPotential; |
| 1224 } |
1152 } | 1225 } |
1153 | 1226 |
1154 /// A reference to a position parameter. | 1227 /// A reference to a position parameter. |
1155 class PositionalArgumentReference extends ConstantExpression { | 1228 class PositionalArgumentReference extends ConstantExpression { |
1156 final int index; | 1229 final int index; |
1157 | 1230 |
1158 PositionalArgumentReference(this.index); | 1231 PositionalArgumentReference(this.index); |
1159 | 1232 |
1160 ConstantExpressionKind get kind { | 1233 ConstantExpressionKind get kind { |
1161 return ConstantExpressionKind.POSITIONAL_REFERENCE; | 1234 return ConstantExpressionKind.POSITIONAL_REFERENCE; |
(...skipping 16 matching lines...) Expand all Loading... |
1178 int _computeHashCode() => 13 * index.hashCode; | 1251 int _computeHashCode() => 13 * index.hashCode; |
1179 | 1252 |
1180 @override | 1253 @override |
1181 bool _equals(PositionalArgumentReference other) => index == other.index; | 1254 bool _equals(PositionalArgumentReference other) => index == other.index; |
1182 | 1255 |
1183 @override | 1256 @override |
1184 ConstantValue evaluate( | 1257 ConstantValue evaluate( |
1185 Environment environment, ConstantSystem constantSystem) { | 1258 Environment environment, ConstantSystem constantSystem) { |
1186 throw new UnsupportedError('PositionalArgumentReference.evaluate'); | 1259 throw new UnsupportedError('PositionalArgumentReference.evaluate'); |
1187 } | 1260 } |
| 1261 |
| 1262 @override |
| 1263 bool get isPotential { |
| 1264 return true; |
| 1265 } |
1188 } | 1266 } |
1189 | 1267 |
1190 /// A reference to a named parameter. | 1268 /// A reference to a named parameter. |
1191 class NamedArgumentReference extends ConstantExpression { | 1269 class NamedArgumentReference extends ConstantExpression { |
1192 final String name; | 1270 final String name; |
1193 | 1271 |
1194 NamedArgumentReference(this.name); | 1272 NamedArgumentReference(this.name); |
1195 | 1273 |
1196 ConstantExpressionKind get kind { | 1274 ConstantExpressionKind get kind { |
1197 return ConstantExpressionKind.NAMED_REFERENCE; | 1275 return ConstantExpressionKind.NAMED_REFERENCE; |
(...skipping 16 matching lines...) Expand all Loading... |
1214 int _computeHashCode() => 13 * name.hashCode; | 1292 int _computeHashCode() => 13 * name.hashCode; |
1215 | 1293 |
1216 @override | 1294 @override |
1217 bool _equals(NamedArgumentReference other) => name == other.name; | 1295 bool _equals(NamedArgumentReference other) => name == other.name; |
1218 | 1296 |
1219 @override | 1297 @override |
1220 ConstantValue evaluate( | 1298 ConstantValue evaluate( |
1221 Environment environment, ConstantSystem constantSystem) { | 1299 Environment environment, ConstantSystem constantSystem) { |
1222 throw new UnsupportedError('NamedArgumentReference.evaluate'); | 1300 throw new UnsupportedError('NamedArgumentReference.evaluate'); |
1223 } | 1301 } |
| 1302 |
| 1303 @override |
| 1304 bool get isPotential { |
| 1305 return true; |
| 1306 } |
1224 } | 1307 } |
1225 | 1308 |
1226 abstract class FromEnvironmentConstantExpression extends ConstantExpression { | 1309 abstract class FromEnvironmentConstantExpression extends ConstantExpression { |
1227 final ConstantExpression name; | 1310 final ConstantExpression name; |
1228 final ConstantExpression defaultValue; | 1311 final ConstantExpression defaultValue; |
1229 | 1312 |
1230 FromEnvironmentConstantExpression(this.name, this.defaultValue); | 1313 FromEnvironmentConstantExpression(this.name, this.defaultValue); |
1231 | 1314 |
1232 @override | 1315 @override |
1233 int _computeHashCode() { | 1316 int _computeHashCode() { |
1234 return 13 * name.hashCode + 17 * defaultValue.hashCode; | 1317 return 13 * name.hashCode + 17 * defaultValue.hashCode; |
1235 } | 1318 } |
1236 | 1319 |
1237 @override | 1320 @override |
1238 bool _equals(FromEnvironmentConstantExpression other) { | 1321 bool _equals(FromEnvironmentConstantExpression other) { |
1239 return name == other.name && defaultValue == other.defaultValue; | 1322 return name == other.name && defaultValue == other.defaultValue; |
1240 } | 1323 } |
| 1324 |
| 1325 @override |
| 1326 bool get isImplicit { |
| 1327 return false; |
| 1328 } |
| 1329 |
| 1330 @override |
| 1331 bool get isPotential { |
| 1332 return name.isPotential || |
| 1333 (defaultValue != null && defaultValue.isPotential); |
| 1334 } |
1241 } | 1335 } |
1242 | 1336 |
1243 /// A `const bool.fromEnvironment` constant. | 1337 /// A `const bool.fromEnvironment` constant. |
1244 class BoolFromEnvironmentConstantExpression | 1338 class BoolFromEnvironmentConstantExpression |
1245 extends FromEnvironmentConstantExpression { | 1339 extends FromEnvironmentConstantExpression { |
1246 BoolFromEnvironmentConstantExpression( | 1340 BoolFromEnvironmentConstantExpression( |
1247 ConstantExpression name, ConstantExpression defaultValue) | 1341 ConstantExpression name, ConstantExpression defaultValue) |
1248 : super(name, defaultValue); | 1342 : super(name, defaultValue); |
1249 | 1343 |
1250 ConstantExpressionKind get kind { | 1344 ConstantExpressionKind get kind { |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 | 1558 |
1465 @override | 1559 @override |
1466 bool _equals(DeferredConstantExpression other) { | 1560 bool _equals(DeferredConstantExpression other) { |
1467 return expression == other.expression; | 1561 return expression == other.expression; |
1468 } | 1562 } |
1469 | 1563 |
1470 @override | 1564 @override |
1471 accept(ConstantExpressionVisitor visitor, [context]) { | 1565 accept(ConstantExpressionVisitor visitor, [context]) { |
1472 return visitor.visitDeferred(this, context); | 1566 return visitor.visitDeferred(this, context); |
1473 } | 1567 } |
| 1568 |
| 1569 @override |
| 1570 bool get isPotential { |
| 1571 return expression.isPotential; |
| 1572 } |
1474 } | 1573 } |
1475 | 1574 |
1476 abstract class ConstantExpressionVisitor<R, A> { | 1575 abstract class ConstantExpressionVisitor<R, A> { |
1477 const ConstantExpressionVisitor(); | 1576 const ConstantExpressionVisitor(); |
1478 | 1577 |
1479 R visit(ConstantExpression constant, A context) { | 1578 R visit(ConstantExpression constant, A context) { |
1480 return constant.accept(this, context); | 1579 return constant.accept(this, context); |
1481 } | 1580 } |
1482 | 1581 |
1483 R visitBool(BoolConstantExpression exp, A context); | 1582 R visitBool(BoolConstantExpression exp, A context); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 visit(exp.name); | 1871 visit(exp.name); |
1773 if (exp.defaultValue != null) { | 1872 if (exp.defaultValue != null) { |
1774 sb.write(', defaultValue: '); | 1873 sb.write(', defaultValue: '); |
1775 visit(exp.defaultValue); | 1874 visit(exp.defaultValue); |
1776 } | 1875 } |
1777 sb.write(')'); | 1876 sb.write(')'); |
1778 } | 1877 } |
1779 | 1878 |
1780 String toString() => sb.toString(); | 1879 String toString() => sb.toString(); |
1781 } | 1880 } |
OLD | NEW |