Chromium Code Reviews| Index: runtime/vm/parser.cc |
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
| index f7db62fa973ae6feac63732acdd0e390194e6428..ef268850ef4b1b755bcbb23252e624d1d1fb68e7 100644 |
| --- a/runtime/vm/parser.cc |
| +++ b/runtime/vm/parser.cc |
| @@ -6255,9 +6255,20 @@ bool Parser::IsSimpleLiteral(const AbstractType& type, Instance* value) { |
| } |
| -// Returns true if the current token is kIDENT or a pseudo-keyword. |
| +// Returns true if the current token is |
| +// * kIDENT, |
| +// * or a pseudo-keyword, |
| +// * or is not the literal "await" in an async function. |
| bool Parser::IsIdentifier() { |
| - return Token::IsIdentifier(CurrentToken()); |
| + bool is_async = false; |
| + if (parsed_function() != NULL) { |
| + const Function& func = parsed_function()->function(); |
| + if (!func.IsNull()) { |
| + is_async = func.IsAsyncFunction() || func.is_async_closure(); |
|
hausner
2014/08/26 20:45:47
I think this is too expensive. I think it would ma
Michael Lippautz (Google)
2014/08/26 22:07:44
Agree. I added the proposed indicator to the parse
|
| + } |
| + } |
| + return Token::IsIdentifier(CurrentToken()) && |
| + (!is_async || (CurrentLiteral()->raw() != Symbols::Await().raw())); |
| } |
| @@ -8454,11 +8465,12 @@ AstNode* Parser::ParseAwaitableExpr(bool require_compiletime_const, |
| // function. |
| return expr; |
| } |
| - SequenceNode* intermediates_block = new(I) SequenceNode( |
| - Scanner::kNoSourcePos, current_block_->scope); |
| - AwaitTransformer at(intermediates_block, library_, parsed_function()); |
| + OpenBlock(); |
| + AwaitTransformer at(current_block_->statements, |
| + library_, |
| + parsed_function()); |
| AstNode* result = at.Transform(expr); |
| - current_block_->statements->Add(intermediates_block); |
| + current_block_->statements->Add(CloseBlock()); |
| parsed_function()->reset_have_seen_await(); |
| return result; |
| } |
| @@ -10843,7 +10855,7 @@ AstNode* Parser::ParsePrimary() { |
| OpenBlock(); |
| primary = ParseFunctionStatement(true); |
| CloseBlock(); |
| - } else if (IsLiteral("await") && |
| + } else if ((CurrentLiteral()->raw() == Symbols::Await().raw()) && |
| (parsed_function()->function().IsAsyncFunction() || |
| parsed_function()->function().is_async_closure())) { |
| // The body of an async function is parsed multiple times. The first time |