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

Unified Diff: runtime/vm/ast.cc

Issue 1493693002: Make ?? a compile-time constant operator. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix test, runs in dart2js and analyzer. Created 5 years 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
Index: runtime/vm/ast.cc
diff --git a/runtime/vm/ast.cc b/runtime/vm/ast.cc
index 48bd0534e0b425094f3e700caaeeb38ae81486c7..6ce0703e7141d3324c69b5b5dd24acc24e350578 100644
--- a/runtime/vm/ast.cc
+++ b/runtime/vm/ast.cc
@@ -312,6 +312,7 @@ bool BinaryOpNode::IsPotentiallyConst() const {
case Token::kBIT_AND:
case Token::kSHL:
case Token::kSHR:
+ case Token::kIFNULL:
return this->left()->IsPotentiallyConst() &&
this->right()->IsPotentiallyConst();
default:
@@ -326,7 +327,8 @@ const Instance* BinaryOpNode::EvalConstExpr() const {
if (left_val == NULL) {
return NULL;
}
- if (!left_val->IsNumber() && !left_val->IsBool() && !left_val->IsString()) {
+ if (!left_val->IsNumber() && !left_val->IsBool() && !left_val->IsString() &&
+ kind_ != Token::kIFNULL) {
return NULL;
}
const Instance* right_val = this->right()->EvalConstExpr();
@@ -371,6 +373,9 @@ const Instance* BinaryOpNode::EvalConstExpr() const {
return left_val;
}
return NULL;
+ case Token::kIFNULL:
+ if (left_val->IsNull()) return right_val;
Ivan Posva 2015/12/03 21:29:04 {} as is the style elsewhere in this file.
Lasse Reichstein Nielsen 2015/12/04 12:11:46 Done.
+ return left_val;
default:
UNREACHABLE();
return NULL;

Powered by Google App Engine
This is Rietveld 408576698