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

Unified Diff: dart/runtime/vm/parser.cc

Issue 754763003: Version 1.8.3 (Closed) Base URL: http://dart.googlecode.com/svn/branches/1.8/
Patch Set: Created 6 years 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 | « dart/runtime/vm/object.cc ('k') | dart/sdk/lib/collection/list.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, &params);
}
- 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 {
« no previous file with comments | « dart/runtime/vm/object.cc ('k') | dart/sdk/lib/collection/list.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698