| Index: runtime/vm/parser.cc
|
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
|
| index 22df857e4b0737fca24cbb1c979534bed913ac3c..0328af02b25bf45c50d57897390d35751c251794 100644
|
| --- a/runtime/vm/parser.cc
|
| +++ b/runtime/vm/parser.cc
|
| @@ -2591,9 +2591,12 @@ AstNode* Parser::ParseExternalInitializedField(const Field& field) {
|
| } else {
|
| init_expr = ParseExpr(kAllowConst, kConsumeCascades);
|
| if (init_expr->EvalConstExpr() != NULL) {
|
| - init_expr =
|
| - new LiteralNode(field.token_pos(),
|
| - EvaluateConstExpr(expr_pos, init_expr));
|
| + Instance& expr_value = Instance::ZoneHandle(Z);
|
| + if (!GetCachedConstant(expr_pos, &expr_value)) {
|
| + expr_value = EvaluateConstExpr(expr_pos, init_expr).raw();
|
| + CacheConstantValue(expr_pos, expr_value);
|
| + }
|
| + init_expr = new(Z) LiteralNode(field.token_pos(), expr_value);
|
| }
|
| }
|
| set_current_class(saved_class);
|
| @@ -2637,8 +2640,12 @@ void Parser::ParseInitializedInstanceFields(const Class& cls,
|
| intptr_t expr_pos = TokenPos();
|
| init_expr = ParseExpr(kAllowConst, kConsumeCascades);
|
| if (init_expr->EvalConstExpr() != NULL) {
|
| - init_expr = new LiteralNode(field.token_pos(),
|
| - EvaluateConstExpr(expr_pos, init_expr));
|
| + Instance& expr_value = Instance::ZoneHandle(Z);
|
| + if (!GetCachedConstant(expr_pos, &expr_value)) {
|
| + expr_value = EvaluateConstExpr(expr_pos, init_expr).raw();
|
| + CacheConstantValue(expr_pos, expr_value);
|
| + }
|
| + init_expr = new(Z) LiteralNode(field.token_pos(), expr_value);
|
| }
|
| }
|
| }
|
| @@ -13040,6 +13047,11 @@ AstNode* Parser::ParseSymbolLiteral() {
|
| ReportError("illegal symbol literal");
|
| }
|
|
|
| + Instance& symbol_instance = Instance::ZoneHandle(Z);
|
| + if (GetCachedConstant(symbol_pos, &symbol_instance)) {
|
| + return new(Z) LiteralNode(symbol_pos, symbol_instance);
|
| + }
|
| +
|
| // Call Symbol class constructor to create a symbol instance.
|
| const Class& symbol_class = Class::Handle(I->object_store()->symbol_class());
|
| ASSERT(!symbol_class.IsNull());
|
| @@ -13059,9 +13071,9 @@ AstNode* Parser::ParseSymbolLiteral() {
|
| script_, symbol_pos,
|
| "error executing const Symbol constructor");
|
| }
|
| - const Instance& instance = Instance::Cast(result);
|
| - return new(Z) LiteralNode(symbol_pos,
|
| - Instance::ZoneHandle(Z, instance.raw()));
|
| + symbol_instance ^= result.raw();
|
| + CacheConstantValue(symbol_pos, symbol_instance);
|
| + return new(Z) LiteralNode(symbol_pos, symbol_instance);
|
| }
|
|
|
|
|
|
|