Chromium Code Reviews| Index: pkg/compiler/lib/src/kernel/ir_element_map.dart |
| diff --git a/pkg/compiler/lib/src/kernel/ir_element_map.dart b/pkg/compiler/lib/src/kernel/ir_element_map.dart |
| index 5344f727f89237343cbaac1f26c5d15360077816..7ea0356155eec995cc129a027fea7e3c857f53f6 100644 |
| --- a/pkg/compiler/lib/src/kernel/ir_element_map.dart |
| +++ b/pkg/compiler/lib/src/kernel/ir_element_map.dart |
| @@ -719,6 +719,34 @@ class Constantifier extends ir.ExpressionVisitor<ConstantExpression> { |
| 'Unexpected constant expression $node (${node.runtimeType})'); |
| } |
| + @override |
| + ConstantExpression visitLet(ir.Let node) { |
| + if (node.body is ir.ConditionalExpression) { |
| + ir.ConditionalExpression conditional = node.body; |
|
sra1
2017/05/08 15:58:52
The conversion here (implicit as-check in strong m
Johnni Winther
2017/05/09 10:20:25
OK, I'll rewrite it.
|
| + if (conditional.condition is ir.MethodInvocation) { |
| + ir.MethodInvocation methodInvocation = conditional.condition; |
| + if (methodInvocation.name.name == BinaryOperator.EQ.name && |
| + methodInvocation.receiver is ir.VariableGet && |
| + methodInvocation.arguments.positional.single is ir.NullLiteral && |
| + conditional.otherwise is ir.VariableGet) { |
| + ir.VariableGet variableGet1 = methodInvocation.receiver; |
| + ir.VariableGet variableGet2 = conditional.otherwise; |
| + if (variableGet1.variable == node.variable && |
| + variableGet2.variable == node.variable) { |
| + // We have <left> ?? <right> encoded as: |
| + // let #1 = <left> in #1 == null ? <right> : #1 |
| + ConstantExpression left = visit(node.variable.initializer); |
| + ConstantExpression right = visit(conditional.then); |
| + return new BinaryConstantExpression( |
| + left, BinaryOperator.IF_NULL, right); |
|
Siggi Cherem (dart-lang)
2017/05/05 18:13:37
nothing to change here, but I just wonder if it is
Johnni Winther
2017/05/08 09:01:06
I'd like the expressions to be structurally equiva
sra1
2017/05/08 15:58:52
It would be nice to have a TODO that explains this
Johnni Winther
2017/05/09 10:20:25
Will add a TODO
|
| + } |
| + } |
| + } |
| + } |
| + throw new UnimplementedError( |
| + 'Unexpected constant expression $node (${node.runtimeType})'); |
| + } |
| + |
| /// Compute the [ConstantConstructor] corresponding to the const constructor |
| /// [node]. |
| ConstantConstructor computeConstantConstructor(ir.Constructor node) { |