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

Unified Diff: runtime/vm/ast.cc

Issue 25505008: Support compile time constant conditional expressions (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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.h ('k') | tests/language/compile_time_constant11_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.cc
===================================================================
--- runtime/vm/ast.cc (revision 28102)
+++ runtime/vm/ast.cc (working copy)
@@ -376,6 +376,24 @@
}
+bool ConditionalExprNode::IsPotentiallyConst() const {
+ return this->condition()->IsPotentiallyConst() &&
+ this->true_expr()->IsPotentiallyConst() &&
+ this->false_expr()->IsPotentiallyConst();
+}
+
+
+const Instance* ConditionalExprNode::EvalConstExpr() const {
+ const Instance* cond = this->condition()->EvalConstExpr();
+ if ((cond != NULL) &&
+ (this->true_expr()->EvalConstExpr() != NULL) &&
+ (this->false_expr()->EvalConstExpr() != NULL)) {
+ return cond;
+ }
+ return NULL;
+}
+
+
bool ClosureNode::IsPotentiallyConst() const {
if (function().IsImplicitStaticClosureFunction()) {
return true;
« no previous file with comments | « runtime/vm/ast.h ('k') | tests/language/compile_time_constant11_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698