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

Side by Side 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: Merge to head 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/ast.cc ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 10405 matching lines...) Expand 10 before | Expand all | Expand 10 after
10416 BinaryOpNode* old = lhs->AsBinaryOpNode(); 10416 BinaryOpNode* old = lhs->AsBinaryOpNode();
10417 BinaryOpWithMask32Node* binop = new(Z) BinaryOpWithMask32Node( 10417 BinaryOpWithMask32Node* binop = new(Z) BinaryOpWithMask32Node(
10418 old->token_pos(), old->kind(), old->left(), old->right(), val); 10418 old->token_pos(), old->kind(), old->left(), old->right(), val);
10419 return binop; 10419 return binop;
10420 } 10420 }
10421 } 10421 }
10422 } 10422 }
10423 } 10423 }
10424 if (binary_op == Token::kIFNULL) { 10424 if (binary_op == Token::kIFNULL) {
10425 // Handle a ?? b. 10425 // Handle a ?? b.
10426 if ((lhs->EvalConstExpr() != NULL) && (rhs->EvalConstExpr() != NULL)) {
10427 Instance& expr_value = Instance::ZoneHandle(Z);
10428 if (!GetCachedConstant(op_pos, &expr_value)) {
10429 expr_value = EvaluateConstExpr(lhs->token_pos(), lhs).raw();
10430 if (expr_value.IsNull()) {
10431 expr_value = EvaluateConstExpr(rhs->token_pos(), rhs).raw();
10432 }
10433 CacheConstantValue(op_pos, expr_value);
10434 }
10435 return new(Z) LiteralNode(op_pos, expr_value);
10436 }
10437
10426 LetNode* result = new(Z) LetNode(op_pos); 10438 LetNode* result = new(Z) LetNode(op_pos);
10427 LocalVariable* left_temp = result->AddInitializer(lhs); 10439 LocalVariable* left_temp = result->AddInitializer(lhs);
10440 left_temp->set_is_final();
10428 const intptr_t no_pos = Token::kNoSourcePos; 10441 const intptr_t no_pos = Token::kNoSourcePos;
10429 LiteralNode* null_operand = 10442 LiteralNode* null_operand =
10430 new(Z) LiteralNode(no_pos, Object::null_instance()); 10443 new(Z) LiteralNode(no_pos, Object::null_instance());
10431 LoadLocalNode* load_left_temp = new(Z) LoadLocalNode(no_pos, left_temp); 10444 LoadLocalNode* load_left_temp = new(Z) LoadLocalNode(no_pos, left_temp);
10432 ComparisonNode* null_compare = 10445 ComparisonNode* null_compare =
10433 new(Z) ComparisonNode(no_pos, 10446 new(Z) ComparisonNode(no_pos,
10434 Token::kNE_STRICT, 10447 Token::kNE_STRICT,
10435 load_left_temp, 10448 load_left_temp,
10436 null_operand); 10449 null_operand);
10437 result->AddNode(new(Z) ConditionalExprNode(op_pos, 10450 result->AddNode(new(Z) ConditionalExprNode(op_pos,
(...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after
14301 const ArgumentListNode& function_args, 14314 const ArgumentListNode& function_args,
14302 const LocalVariable* temp_for_last_arg, 14315 const LocalVariable* temp_for_last_arg,
14303 bool is_super_invocation) { 14316 bool is_super_invocation) {
14304 UNREACHABLE(); 14317 UNREACHABLE();
14305 return NULL; 14318 return NULL;
14306 } 14319 }
14307 14320
14308 } // namespace dart 14321 } // namespace dart
14309 14322
14310 #endif // DART_PRECOMPILED_RUNTIME 14323 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« 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