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

Unified Diff: runtime/vm/parser.cc

Issue 10446102: Insert closure calls in conditional expression of assert (issue 1584). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 8157)
+++ runtime/vm/parser.cc (working copy)
@@ -4987,6 +4987,23 @@
}
+AstNode* Parser::InsertClosureCallNodes(AstNode* condition) {
+ if (condition->IsClosureNode() ||
+ (condition->IsStoreLocalNode() &&
+ condition->AsStoreLocalNode()->value()->IsClosureNode())) {
+ EnsureExpressionTemp();
+ // Function literal in assert implies a call.
+ const intptr_t pos = condition->token_index();
+ condition = new ClosureCallNode(pos, condition, new ArgumentListNode(pos));
+ } else if (condition->IsConditionalExprNode()) {
+ ConditionalExprNode* cond_expr = condition->AsConditionalExprNode();
+ cond_expr->set_true_expr(InsertClosureCallNodes(cond_expr->true_expr()));
+ cond_expr->set_false_expr(InsertClosureCallNodes(cond_expr->false_expr()));
+ }
+ return condition;
+}
+
+
AstNode* Parser::ParseAssertStatement() {
TRACE_PARSER("ParseAssertStatement");
ConsumeToken(); // Consume assert keyword.
@@ -5000,14 +5017,7 @@
AstNode* condition = ParseExpr(kAllowConst);
const intptr_t condition_end = token_index_;
ExpectToken(Token::kRPAREN);
- if (condition->IsClosureNode()) {
- EnsureExpressionTemp();
- // Function literal in assert implies a call.
- condition =
- new ClosureCallNode(condition_pos,
- condition,
- new ArgumentListNode(condition_pos));
- }
+ condition = InsertClosureCallNodes(condition);
condition = new UnaryOpNode(condition_pos, Token::kNOT, condition);
AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end);
return new IfNode(condition_pos,
« runtime/vm/ast.h ('K') | « runtime/vm/parser.h ('k') | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698