Index: pkg/compiler/lib/src/constants/values.dart |
diff --git a/pkg/compiler/lib/src/constants/values.dart b/pkg/compiler/lib/src/constants/values.dart |
index 45f47eaa97786b523a70e2d9256d1ace360e1627..e40a6b838ac1dea110fc78cdacc932f3dbfa99e5 100644 |
--- a/pkg/compiler/lib/src/constants/values.dart |
+++ b/pkg/compiler/lib/src/constants/values.dart |
@@ -39,6 +39,9 @@ abstract class ConstantValueVisitor<R, A> { |
abstract class ConstantValue { |
const ConstantValue(); |
+ /// `true` if this is a valid constant value. |
+ bool get isConstant => true; |
+ |
bool get isNull => false; |
bool get isBool => false; |
bool get isTrue => false; |
@@ -482,9 +485,11 @@ class ListConstantValue extends ObjectConstantValue { |
String toStructuredString() { |
StringBuffer sb = new StringBuffer(); |
- sb.write('ListConstant(['); |
+ sb.write('ListConstant('); |
+ _unparseTypeArguments(sb); |
+ sb.write('['); |
for (int i = 0 ; i < length ; i++) { |
- if (i > 0) sb.write(','); |
+ if (i > 0) sb.write(', '); |
sb.write(entries[i].toStructuredString()); |
} |
sb.write('])'); |
@@ -551,11 +556,13 @@ class MapConstantValue extends ObjectConstantValue { |
String toStructuredString() { |
StringBuffer sb = new StringBuffer(); |
- sb.write('MapConstant({'); |
+ sb.write('MapConstant('); |
+ _unparseTypeArguments(sb); |
+ sb.write('{'); |
for (int i = 0; i < length; i++) { |
- if (i > 0) sb.write(','); |
+ if (i > 0) sb.write(', '); |
sb.write(keys[i].toStructuredString()); |
- sb.write(':'); |
+ sb.write(': '); |
sb.write(values[i].toStructuredString()); |
} |
sb.write('})'); |
@@ -717,3 +724,27 @@ class DeferredConstantValue extends ConstantValue { |
String toStructuredString() => 'DeferredConstant($referenced)'; |
} |
+ |
+/// A constant value resulting from a non constant or erroneous constant |
+/// expression. |
+// TODO(johnniwinther): Expand this to contain the error kind. |
+class NonConstantValue extends ConstantValue { |
+ bool get isConstant => false; |
+ |
+ @override |
+ accept(ConstantValueVisitor visitor, arg) { |
+ // TODO(johnniwinther): Should this be part of the visiting? |
+ } |
+ |
+ @override |
+ List<ConstantValue> getDependencies() => const <ConstantValue>[]; |
+ |
+ @override |
+ DartType getType(CoreTypes types) => const DynamicType(); |
+ |
+ @override |
+ String toStructuredString() => 'NonConstant'; |
+ |
+ @override |
+ String unparse() => '>>non-constant<<'; |
+} |