| Index: pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| diff --git a/pkg/compiler/lib/src/cps_ir/type_propagation.dart b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| index 1d1a7f2eb8a25b4b8b6b6f0a08c01f810d4b1982..f0e3eb070edf6ff0c5fafe497e779fde359bea2d 100644
|
| --- a/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| +++ b/pkg/compiler/lib/src/cps_ir/type_propagation.dart
|
| @@ -164,7 +164,7 @@ class _TransformingVisitor extends RecursiveVisitor {
|
| // Set up the replacement structure.
|
| PrimitiveConstantValue primitiveConstant = value.constant;
|
| ConstantExpression constExp =
|
| - new PrimitiveConstantExpression(primitiveConstant);
|
| + const ConstantExpressionCreator().convert(primitiveConstant);
|
| Constant constant = new Constant(constExp);
|
| LetPrim letPrim = new LetPrim(constant);
|
| InvokeContinuation invoke =
|
| @@ -918,3 +918,77 @@ class _AbstractValue<T> {
|
| }
|
| }
|
| }
|
| +
|
| +class ConstantExpressionCreator
|
| + implements ConstantValueVisitor<ConstantExpression, dynamic> {
|
| +
|
| + const ConstantExpressionCreator();
|
| +
|
| + ConstantExpression convert(ConstantValue value) => value.accept(this, null);
|
| +
|
| + @override
|
| + ConstantExpression visitBool(BoolConstantValue constant, _) {
|
| + return new BoolConstantExpression(constant.primitiveValue, constant);
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitConstructed(ConstructedConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitConstructed");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitDeferred(DeferredConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitDeferred");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitDouble(DoubleConstantValue constant, arg) {
|
| + return new DoubleConstantExpression(constant.primitiveValue, constant);
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitDummy(DummyConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitDummy");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitFunction(FunctionConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitFunction");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitInt(IntConstantValue constant, arg) {
|
| + return new IntConstantExpression(constant.primitiveValue, constant);
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitInterceptor(InterceptorConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitInterceptor");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitList(ListConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitList");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitMap(MapConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitMap");
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitNull(NullConstantValue constant, arg) {
|
| + return new NullConstantExpression(constant);
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitString(StringConstantValue constant, arg) {
|
| + return new StringConstantExpression(
|
| + constant.primitiveValue.slowToString(), constant);
|
| + }
|
| +
|
| + @override
|
| + ConstantExpression visitType(TypeConstantValue constant, arg) {
|
| + throw new UnsupportedError("ConstantExpressionCreator.visitType");
|
| + }
|
| +}
|
|
|