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

Unified Diff: runtime/vm/parser.cc

Issue 543433003: Parse await as part of an unary expression. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | « no previous file | tests/language/await_future_test.dart » ('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 d2ce185de0210d552083566be687a88b91e93f30..d2f6e35789e771dd43e2b7b16be7bb5bf17ec450 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -8712,7 +8712,12 @@ AstNode* Parser::ParseUnaryExpr() {
TRACE_PARSER("ParseUnaryExpr");
AstNode* expr = NULL;
const intptr_t op_pos = TokenPos();
- if (IsPrefixOperator(CurrentToken())) {
+ if (IsAwaitAsKeyword()) {
+ TRACE_PARSER("ParseAwaitExpr");
+ ConsumeToken();
+ parsed_function()->record_await();
+ expr = new (I) AwaitNode(TokenPos(), ParseUnaryExpr());
+ } else if (IsPrefixOperator(CurrentToken())) {
Token::Kind unary_op = CurrentToken();
if (unary_op == Token::kSUB) {
unary_op = Token::kNEGATE;
@@ -10998,16 +11003,6 @@ AstNode* Parser::ParsePrimary() {
OpenBlock();
primary = ParseFunctionStatement(true);
CloseBlock();
- } else if (IsAwaitAsKeyword()) {
- // The body of an async function is parsed multiple times. The first time
- // when setting up an AsyncFunction() for generating relevant scope
- // information. The second time the body is parsed for actually generating
- // code.
- TRACE_PARSER("ParseAwaitExpr");
- ConsumeToken();
- parsed_function()->record_await();
- primary = new(I) AwaitNode(
- TokenPos(), ParseExpr(kAllowConst, kConsumeCascades));
} else if (IsIdentifier()) {
intptr_t qual_ident_pos = TokenPos();
const LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(I, ParsePrefix());
« no previous file with comments | « no previous file | tests/language/await_future_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698