Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 8 #ifndef DART_PRECOMPILED |
| 9 | 9 |
| 10 #include "lib/invocation_mirror.h" | 10 #include "lib/invocation_mirror.h" |
| (...skipping 10534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10545 BinaryOpNode* old = lhs->AsBinaryOpNode(); | 10545 BinaryOpNode* old = lhs->AsBinaryOpNode(); |
| 10546 BinaryOpWithMask32Node* binop = new(Z) BinaryOpWithMask32Node( | 10546 BinaryOpWithMask32Node* binop = new(Z) BinaryOpWithMask32Node( |
| 10547 old->token_pos(), old->kind(), old->left(), old->right(), val); | 10547 old->token_pos(), old->kind(), old->left(), old->right(), val); |
| 10548 return binop; | 10548 return binop; |
| 10549 } | 10549 } |
| 10550 } | 10550 } |
| 10551 } | 10551 } |
| 10552 } | 10552 } |
| 10553 if (binary_op == Token::kIFNULL) { | 10553 if (binary_op == Token::kIFNULL) { |
| 10554 // Handle a ?? b. | 10554 // Handle a ?? b. |
| 10555 if (lhs->IsPotentiallyConst() && lhs->EvalConstExpr() != NULL) { | |
|
Ivan Posva
2015/12/03 21:29:04
() ditto: Please keep the style of the file.
Lasse Reichstein Nielsen
2015/12/04 12:11:46
Done.
| |
| 10556 // If we know at compile time whether the lhs is null | |
| 10557 // and side-effect free, just reduce it to either the lhs or rhs. | |
| 10558 // This enables ?? to be compile-time constant. | |
| 10559 Instance& expr_value = Instance::ZoneHandle(Z); | |
| 10560 intptr_t lhs_pos = lhs->token_pos(); | |
| 10561 if (!GetCachedConstant(lhs_pos, &expr_value)) { | |
| 10562 expr_value = EvaluateConstExpr(lhs_pos, lhs).raw(); | |
| 10563 CacheConstantValue(lhs_pos, expr_value); | |
| 10564 } | |
| 10565 if (expr_value.IsNull()) return rhs; | |
|
Ivan Posva
2015/12/03 21:29:04
ditto
Lasse Reichstein Nielsen
2015/12/04 12:11:46
Done.
| |
| 10566 return new(Z) LiteralNode(lhs_pos, expr_value); | |
| 10567 } | |
| 10568 // Otherwise create a temporary variable for the lhs so we can both | |
| 10569 // check it against null and return it if necessary. | |
| 10555 LetNode* result = new(Z) LetNode(op_pos); | 10570 LetNode* result = new(Z) LetNode(op_pos); |
| 10556 LocalVariable* left_temp = result->AddInitializer(lhs); | 10571 LocalVariable* left_temp = result->AddInitializer(lhs); |
| 10557 const intptr_t no_pos = Scanner::kNoSourcePos; | 10572 const intptr_t no_pos = Scanner::kNoSourcePos; |
| 10558 LiteralNode* null_operand = | 10573 LiteralNode* null_operand = |
| 10559 new(Z) LiteralNode(no_pos, Instance::ZoneHandle(Z)); | 10574 new(Z) LiteralNode(no_pos, Instance::ZoneHandle(Z)); |
| 10560 LoadLocalNode* load_left_temp = new(Z) LoadLocalNode(no_pos, left_temp); | 10575 LoadLocalNode* load_left_temp = new(Z) LoadLocalNode(no_pos, left_temp); |
| 10561 ComparisonNode* null_compare = | 10576 ComparisonNode* null_compare = |
| 10562 new(Z) ComparisonNode(no_pos, | 10577 new(Z) ComparisonNode(no_pos, |
| 10563 Token::kNE_STRICT, | 10578 Token::kNE_STRICT, |
| 10564 load_left_temp, | 10579 load_left_temp, |
| (...skipping 3856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14421 const ArgumentListNode& function_args, | 14436 const ArgumentListNode& function_args, |
| 14422 const LocalVariable* temp_for_last_arg, | 14437 const LocalVariable* temp_for_last_arg, |
| 14423 bool is_super_invocation) { | 14438 bool is_super_invocation) { |
| 14424 UNREACHABLE(); | 14439 UNREACHABLE(); |
| 14425 return NULL; | 14440 return NULL; |
| 14426 } | 14441 } |
| 14427 | 14442 |
| 14428 } // namespace dart | 14443 } // namespace dart |
| 14429 | 14444 |
| 14430 #endif // DART_PRECOMPILED | 14445 #endif // DART_PRECOMPILED |
| OLD | NEW |