Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: runtime/vm/parser.cc

Issue 1575383002: Implement ?? as compile-time constant in VM. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/ast.cc ('k') | tests/language/language.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « runtime/vm/ast.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698