Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index 28777b271e0e835818d86f2bf029a6b8c9c47c75..dad1bc226edce0ae74673560adfac76184cd88f0 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -10502,6 +10502,16 @@ AstNode* Parser::OptimizeBinaryOpNode(intptr_t op_pos, |
| // Handle a ?? b. |
| LetNode* result = new(Z) LetNode(op_pos); |
| LocalVariable* left_temp = result->AddInitializer(lhs); |
| + left_temp->set_is_final(); |
| + if ((lhs->IsPotentiallyConst()) && (lhs->EvalConstExpr() != NULL)) { |
|
hausner
2016/01/12 20:46:47
The first test, IsPotentiallyConst(), is not neede
hausner
2016/01/12 21:48:35
On second thought: you also need to check that rhs
Lasse Reichstein Nielsen
2016/01/13 13:40:35
Done.
I still set left_temp to final below becaus
|
| + Instance& expr_value = Instance::ZoneHandle(Z); |
| + intptr_t lhs_pos = lhs->token_pos(); |
| + if (!GetCachedConstant(lhs_pos, &expr_value)) { |
| + expr_value = EvaluateConstExpr(lhs_pos, lhs).raw(); |
| + CacheConstantValue(lhs_pos, expr_value); |
| + } |
| + left_temp->SetConstValue(expr_value); |
| + } |
| const intptr_t no_pos = Scanner::kNoSourcePos; |
| LiteralNode* null_operand = |
| new(Z) LiteralNode(no_pos, Object::null_instance()); |