| Index: dart/runtime/vm/parser.cc
|
| ===================================================================
|
| --- dart/runtime/vm/parser.cc (revision 42037)
|
| +++ dart/runtime/vm/parser.cc (working copy)
|
| @@ -99,6 +99,21 @@
|
| #endif // DEBUG
|
|
|
|
|
| +class BoolScope : public ValueObject {
|
| + public:
|
| + BoolScope(bool* addr, bool new_value) : _addr(addr), _saved_value(*addr) {
|
| + *_addr = new_value;
|
| + }
|
| + ~BoolScope() {
|
| + *_addr = _saved_value;
|
| + }
|
| +
|
| + private:
|
| + bool* _addr;
|
| + bool _saved_value;
|
| +};
|
| +
|
| +
|
| static RawTypeArguments* NewTypeArguments(const GrowableObjectArray& objs) {
|
| const TypeArguments& a =
|
| TypeArguments::Handle(TypeArguments::New(objs.Length()));
|
| @@ -3055,9 +3070,8 @@
|
| OpenAsyncClosure();
|
| }
|
|
|
| - bool saved_await_is_keyword = await_is_keyword_;
|
| - await_is_keyword_ = func.IsAsyncFunction() || func.is_async_closure();
|
| -
|
| + BoolScope allow_await(&this->await_is_keyword_,
|
| + func.IsAsyncFunction() || func.is_async_closure());
|
| intptr_t end_token_pos = 0;
|
| if (CurrentToken() == Token::kLBRACE) {
|
| ConsumeToken();
|
| @@ -3080,7 +3094,7 @@
|
| }
|
| }
|
| const intptr_t expr_pos = TokenPos();
|
| - AstNode* expr = ParseExpr(kAllowConst, kConsumeCascades);
|
| + AstNode* expr = ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
|
| ASSERT(expr != NULL);
|
| current_block_->statements->Add(new ReturnNode(expr_pos, expr));
|
| end_token_pos = TokenPos();
|
| @@ -3126,7 +3140,6 @@
|
| current_block_->statements->Add(body);
|
| innermost_function_ = saved_innermost_function.raw();
|
| last_used_try_index_ = saved_try_index;
|
| - await_is_keyword_ = saved_await_is_keyword;
|
| async_temp_scope_ = saved_async_temp_scope;
|
| parsed_function()->set_saved_try_ctx(saved_saved_try_ctx);
|
| parsed_function()->set_async_saved_try_ctx_name(
|
| @@ -3482,6 +3495,8 @@
|
| ExpectToken(Token::kRBRACE);
|
| } else {
|
| ConsumeToken();
|
| + BoolScope allow_await(&this->await_is_keyword_,
|
| + async_modifier != RawFunction::kNoModifier);
|
| SkipExpr();
|
| method_end_pos = TokenPos();
|
| ExpectSemicolon();
|
| @@ -5156,6 +5171,8 @@
|
| ExpectToken(Token::kRBRACE);
|
| } else if (CurrentToken() == Token::kARROW) {
|
| ConsumeToken();
|
| + BoolScope allow_await(&this->await_is_keyword_,
|
| + func_modifier != RawFunction::kNoModifier);
|
| SkipExpr();
|
| function_end_pos = TokenPos();
|
| ExpectSemicolon();
|
| @@ -11814,7 +11831,9 @@
|
| params.skipped = true;
|
| ParseFormalParameterList(allow_explicit_default_values, false, ¶ms);
|
| }
|
| - ParseFunctionModifier();
|
| + RawFunction::AsyncModifier async_modifier = ParseFunctionModifier();
|
| + BoolScope allow_await(&this->await_is_keyword_,
|
| + async_modifier != RawFunction::kNoModifier);
|
| if (CurrentToken() == Token::kLBRACE) {
|
| SkipBlock();
|
| ExpectToken(Token::kRBRACE);
|
| @@ -12061,7 +12080,8 @@
|
|
|
| void Parser::SkipUnaryExpr() {
|
| if (IsPrefixOperator(CurrentToken()) ||
|
| - IsIncrementOperator(CurrentToken())) {
|
| + IsIncrementOperator(CurrentToken()) ||
|
| + IsAwaitKeyword()) {
|
| ConsumeToken();
|
| SkipUnaryExpr();
|
| } else {
|
|
|