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

Unified Diff: runtime/vm/parser.cc

Issue 2064663002: Make VM accept function values in assert statements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 6a89bd0eeffadb3e15b2cae7b8bfbf4ff4aeb173..ac2ea97c6ed63702ba22efb9669e8d2a413fe622 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -9175,21 +9175,13 @@ AstNode* Parser::MakeAssertCall(TokenPosition begin, TokenPosition end) {
}
-AstNode* Parser::InsertClosureCallNodes(AstNode* condition) {
- if (condition->IsClosureNode() ||
- (condition->IsStoreLocalNode() &&
- condition->AsStoreLocalNode()->value()->IsClosureNode())) {
- // Function literal in assert implies a call.
- const TokenPosition pos = condition->token_pos();
- condition = BuildClosureCall(pos,
- condition,
- new(Z) 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::HandleAssertCondition(AstNode* condition) {
+ const TokenPosition pos = condition->token_pos();
+ ArgumentListNode* arguments = new(Z) ArgumentListNode(pos);
+ arguments->Add(condition);
+ return MakeStaticCall(Symbols::AssertionError(),
+ Library::PrivateCoreLibName(Symbols::HandleCondition()),
+ arguments);
}
@@ -9206,7 +9198,7 @@ AstNode* Parser::ParseAssertStatement() {
AstNode* condition = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
const TokenPosition condition_end = TokenPos();
ExpectToken(Token::kRPAREN);
- condition = InsertClosureCallNodes(condition);
+ condition = HandleAssertCondition(condition);
condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition);
AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end);
return new(Z) IfNode(
hausner 2016/06/14 17:51:31 Since you now call a Dart function to evaluate the
Lasse Reichstein Nielsen 2016/06/15 05:57:02 I'm not particularly worried about passing two ext
« runtime/lib/errors_patch.dart ('K') | « runtime/vm/parser.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698