Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index 7df47357276501a91de28dd5a11ad8b013836c5c..cc209c6d636873a3758bd1447348a7a15b220506 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -47,6 +47,7 @@ DEFINE_FLAG(bool, trace_parser, false, "Trace parser operations."); |
| DEFINE_FLAG(bool, supermixin, false, "Allow super calls in mixins."); |
| DEFINE_FLAG(bool, warn_mixin_typedef, true, "Warning on legacy mixin typedef."); |
| DEFINE_FLAG(bool, link_natives_lazily, false, "Link native calls lazily"); |
| +DEFINE_FLAG(bool, assert_message, false, "Allow message in assert statements"); |
|
Lasse Reichstein Nielsen
2015/08/28 18:51:59
Should it be "enable_assert_message" instead?
Ivan Posva
2015/09/04 06:39:31
Please coordinate across the implementations. Sinc
|
| DECLARE_FLAG(bool, lazy_dispatchers); |
| DECLARE_FLAG(bool, load_deferred_eagerly); |
| @@ -9115,12 +9116,17 @@ AstNode* Parser::MakeStaticCall(const String& cls_name, |
| } |
| -AstNode* Parser::MakeAssertCall(intptr_t begin, intptr_t end) { |
| +AstNode* Parser::MakeAssertCall(intptr_t begin, intptr_t end, |
| + AstNode* message) { |
| ArgumentListNode* arguments = new(Z) ArgumentListNode(begin); |
| arguments->Add(new(Z) LiteralNode(begin, |
| Integer::ZoneHandle(Z, Integer::New(begin)))); |
| arguments->Add(new(Z) LiteralNode(end, |
| Integer::ZoneHandle(Z, Integer::New(end)))); |
| + if (message == NULL) { |
| + message = new(Z) LiteralNode(end, Instance::ZoneHandle(Z)); |
| + } |
| + arguments->Add(message); |
| return MakeStaticCall(Symbols::AssertionError(), |
| Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| arguments); |
| @@ -9152,15 +9158,24 @@ AstNode* Parser::ParseAssertStatement() { |
| const intptr_t condition_pos = TokenPos(); |
| if (!I->flags().asserts() && !I->flags().type_checks()) { |
|
Ivan Posva
2015/09/04 06:39:31
This line here testing the flag configuration is w
|
| SkipExpr(); |
| + if (FLAG_assert_message && CurrentToken() == Token::kCOMMA) { |
| + ConsumeToken(); |
| + SkipExpr(); |
| + } |
| ExpectToken(Token::kRPAREN); |
| return NULL; |
| } |
| AstNode* condition = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| + AstNode* message = NULL; |
| const intptr_t condition_end = TokenPos(); |
| + if (FLAG_assert_message && CurrentToken() == Token::kCOMMA) { |
| + ConsumeToken(); |
| + message = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL); |
| + } |
| ExpectToken(Token::kRPAREN); |
| condition = InsertClosureCallNodes(condition); |
| condition = new(Z) UnaryOpNode(condition_pos, Token::kNOT, condition); |
| - AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end); |
| + AstNode* assert_throw = MakeAssertCall(condition_pos, condition_end, message); |
| return new(Z) IfNode( |
| condition_pos, |
| condition, |