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

Unified Diff: runtime/vm/parser.cc

Issue 508643004: Fix scope/context behavior in await transformer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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_transformer.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « runtime/vm/ast_transformer.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698