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

Side by Side Diff: runtime/vm/parser.cc

Issue 634603002: Await always waits (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2918 AstNode* guarded_block_statements = 2918 AstNode* guarded_block_statements =
2919 new IfNode(Scanner::kNoSourcePos, comparison, ctor_block, NULL); 2919 new IfNode(Scanner::kNoSourcePos, comparison, ctor_block, NULL);
2920 current_block_->statements->Add(guarded_block_statements); 2920 current_block_->statements->Add(guarded_block_statements);
2921 } 2921 }
2922 current_block_->statements->Add(new ReturnNode(func.end_token_pos())); 2922 current_block_->statements->Add(new ReturnNode(func.end_token_pos()));
2923 SequenceNode* statements = CloseBlock(); 2923 SequenceNode* statements = CloseBlock();
2924 return statements; 2924 return statements;
2925 } 2925 }
2926 2926
2927 2927
2928 // TODO(mlippautz): Once we know where these classes should come from, adjust
2929 // how we get their definition.
2930 RawClass* Parser::GetClassForAsync(const String& class_name) {
2931 const Class& cls = Class::Handle(library_.LookupClass(class_name));
2932 if (cls.IsNull()) {
2933 ReportError("async modifier requires dart:async to be imported without "
2934 "prefix");
2935 }
2936 return cls.raw();
2937 }
2938
2939
2940 // Parser is at the opening parenthesis of the formal parameter 2928 // Parser is at the opening parenthesis of the formal parameter
2941 // declaration of the function or constructor. 2929 // declaration of the function or constructor.
2942 // Parse the formal parameters and code. 2930 // Parse the formal parameters and code.
2943 SequenceNode* Parser::ParseFunc(const Function& func, 2931 SequenceNode* Parser::ParseFunc(const Function& func,
2944 Array* default_parameter_values) { 2932 Array* default_parameter_values) {
2945 TRACE_PARSER("ParseFunc"); 2933 TRACE_PARSER("ParseFunc");
2946 Function& saved_innermost_function = 2934 Function& saved_innermost_function =
2947 Function::Handle(I, innermost_function().raw()); 2935 Function::Handle(I, innermost_function().raw());
2948 innermost_function_ = func.raw(); 2936 innermost_function_ = func.raw();
2949 2937
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3080 OpenBlock(); // Open a nested scope for the outermost function block. 3068 OpenBlock(); // Open a nested scope for the outermost function block.
3081 3069
3082 Function& async_closure = Function::ZoneHandle(I); 3070 Function& async_closure = Function::ZoneHandle(I);
3083 if (func.IsAsyncFunction() && !func.is_async_closure()) { 3071 if (func.IsAsyncFunction() && !func.is_async_closure()) {
3084 async_closure = OpenAsyncFunction(formal_params_pos); 3072 async_closure = OpenAsyncFunction(formal_params_pos);
3085 } else if (func.is_async_closure()) { 3073 } else if (func.is_async_closure()) {
3086 OpenAsyncClosure(); 3074 OpenAsyncClosure();
3087 } 3075 }
3088 3076
3089 bool saved_await_is_keyword = await_is_keyword_; 3077 bool saved_await_is_keyword = await_is_keyword_;
3090 if (func.IsAsyncFunction() || func.is_async_closure()) { 3078 await_is_keyword_ = func.IsAsyncFunction() || func.is_async_closure();
3091 await_is_keyword_ = true;
3092 }
3093 3079
3094 intptr_t end_token_pos = 0; 3080 intptr_t end_token_pos = 0;
3095 if (CurrentToken() == Token::kLBRACE) { 3081 if (CurrentToken() == Token::kLBRACE) {
3096 ConsumeToken(); 3082 ConsumeToken();
3097 if (String::Handle(I, func.name()).Equals( 3083 if (String::Handle(I, func.name()).Equals(
3098 Symbols::EqualOperator())) { 3084 Symbols::EqualOperator())) {
3099 const Class& owner = Class::Handle(I, func.Owner()); 3085 const Class& owner = Class::Handle(I, func.Owner());
3100 if (!owner.IsObjectClass()) { 3086 if (!owner.IsObjectClass()) {
3101 AddEqualityNullCheck(); 3087 AddEqualityNullCheck();
3102 } 3088 }
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
4061 ConsumeToken(); 4047 ConsumeToken();
4062 } 4048 }
4063 ExpectToken(Token::kCLASS); 4049 ExpectToken(Token::kCLASS);
4064 const intptr_t classname_pos = TokenPos(); 4050 const intptr_t classname_pos = TokenPos();
4065 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); 4051 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected");
4066 if (FLAG_trace_parser) { 4052 if (FLAG_trace_parser) {
4067 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); 4053 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString());
4068 } 4054 }
4069 Class& cls = Class::Handle(I); 4055 Class& cls = Class::Handle(I);
4070 TypeArguments& orig_type_parameters = TypeArguments::Handle(I); 4056 TypeArguments& orig_type_parameters = TypeArguments::Handle(I);
4071 Object& obj = Object::Handle(I, 4057 Object& obj = Object::Handle(I, library_.LookupLocalObject(class_name));
4072 library_.LookupLocalObject(class_name));
4073 if (obj.IsNull()) { 4058 if (obj.IsNull()) {
4074 if (is_patch) { 4059 if (is_patch) {
4075 ReportError(classname_pos, "missing class '%s' cannot be patched", 4060 ReportError(classname_pos, "missing class '%s' cannot be patched",
4076 class_name.ToCString()); 4061 class_name.ToCString());
4077 } 4062 }
4078 cls = Class::New(class_name, script_, classname_pos); 4063 cls = Class::New(class_name, script_, classname_pos);
4079 library_.AddClass(cls); 4064 library_.AddClass(cls);
4080 } else { 4065 } else {
4081 if (!obj.IsClass()) { 4066 if (!obj.IsClass()) {
4082 ReportError(classname_pos, "'%s' is already defined", 4067 ReportError(classname_pos, "'%s' is already defined",
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4269 cls.SetFunctions(array); 4254 cls.SetFunctions(array);
4270 4255
4271 // Add an implicit constructor if no explicit constructor is present. 4256 // Add an implicit constructor if no explicit constructor is present.
4272 // No implicit constructors are needed for patch classes. 4257 // No implicit constructors are needed for patch classes.
4273 if (need_implicit_constructor) { 4258 if (need_implicit_constructor) {
4274 AddImplicitConstructor(cls); 4259 AddImplicitConstructor(cls);
4275 } 4260 }
4276 4261
4277 if (cls.is_patch()) { 4262 if (cls.is_patch()) {
4278 // Apply the changes to the patched class looked up above. 4263 // Apply the changes to the patched class looked up above.
4279 Object& obj = Object::Handle(I, 4264 Object& obj = Object::Handle(I, library_.LookupLocalObject(class_name));
4280 library_.LookupLocalObject(class_name));
4281 // The patched class must not be finalized yet. 4265 // The patched class must not be finalized yet.
4282 const Class& orig_class = Class::Cast(obj); 4266 const Class& orig_class = Class::Cast(obj);
4283 ASSERT(!orig_class.is_finalized()); 4267 ASSERT(!orig_class.is_finalized());
4284 Error& error = Error::Handle(I); 4268 Error& error = Error::Handle(I);
4285 if (!orig_class.ApplyPatch(cls, &error)) { 4269 if (!orig_class.ApplyPatch(cls, &error)) {
4286 Report::LongJumpF(error, script_, class_pos, "applying patch failed"); 4270 Report::LongJumpF(error, script_, class_pos, "applying patch failed");
4287 } 4271 }
4288 } 4272 }
4289 } 4273 }
4290 4274
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
4365 const GrowableObjectArray& pending_classes, 4349 const GrowableObjectArray& pending_classes,
4366 const Class& toplevel_class, 4350 const Class& toplevel_class,
4367 intptr_t metadata_pos) { 4351 intptr_t metadata_pos) {
4368 TRACE_PARSER("ParseMixinAppAlias"); 4352 TRACE_PARSER("ParseMixinAppAlias");
4369 const intptr_t classname_pos = TokenPos(); 4353 const intptr_t classname_pos = TokenPos();
4370 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); 4354 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected");
4371 if (FLAG_trace_parser) { 4355 if (FLAG_trace_parser) {
4372 OS::Print("toplevel parsing mixin application alias class '%s'\n", 4356 OS::Print("toplevel parsing mixin application alias class '%s'\n",
4373 class_name.ToCString()); 4357 class_name.ToCString());
4374 } 4358 }
4375 const Object& obj = Object::Handle(I, 4359 const Object& obj = Object::Handle(I, library_.LookupLocalObject(class_name));
4376 library_.LookupLocalObject(class_name));
4377 if (!obj.IsNull()) { 4360 if (!obj.IsNull()) {
4378 ReportError(classname_pos, "'%s' is already defined", 4361 ReportError(classname_pos, "'%s' is already defined",
4379 class_name.ToCString()); 4362 class_name.ToCString());
4380 } 4363 }
4381 const Class& mixin_application = 4364 const Class& mixin_application =
4382 Class::Handle(I, Class::New(class_name, script_, classname_pos)); 4365 Class::Handle(I, Class::New(class_name, script_, classname_pos));
4383 mixin_application.set_is_mixin_app_alias(); 4366 mixin_application.set_is_mixin_app_alias();
4384 library_.AddClass(mixin_application); 4367 library_.AddClass(mixin_application);
4385 set_current_class(mixin_application); 4368 set_current_class(mixin_application);
4386 ParseTypeParameters(mixin_application); 4369 ParseTypeParameters(mixin_application);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
4487 // Wait until we have an owner class before resolving the result type. 4470 // Wait until we have an owner class before resolving the result type.
4488 result_type = ParseType(ClassFinalizer::kDoNotResolve); 4471 result_type = ParseType(ClassFinalizer::kDoNotResolve);
4489 } 4472 }
4490 4473
4491 const intptr_t alias_name_pos = TokenPos(); 4474 const intptr_t alias_name_pos = TokenPos();
4492 const String* alias_name = 4475 const String* alias_name =
4493 ExpectUserDefinedTypeIdentifier("function alias name expected"); 4476 ExpectUserDefinedTypeIdentifier("function alias name expected");
4494 4477
4495 // Lookup alias name and report an error if it is already defined in 4478 // Lookup alias name and report an error if it is already defined in
4496 // the library scope. 4479 // the library scope.
4497 const Object& obj = Object::Handle(I, 4480 const Object& obj =
4498 library_.LookupLocalObject(*alias_name)); 4481 Object::Handle(I, library_.LookupLocalObject(*alias_name));
4499 if (!obj.IsNull()) { 4482 if (!obj.IsNull()) {
4500 ReportError(alias_name_pos, 4483 ReportError(alias_name_pos,
4501 "'%s' is already defined", alias_name->ToCString()); 4484 "'%s' is already defined", alias_name->ToCString());
4502 } 4485 }
4503 4486
4504 // Create the function type alias signature class. It will be linked to its 4487 // Create the function type alias signature class. It will be linked to its
4505 // signature function after it has been parsed. The type parameters, in order 4488 // signature function after it has been parsed. The type parameters, in order
4506 // to be properly finalized, need to be associated to this signature class as 4489 // to be properly finalized, need to be associated to this signature class as
4507 // they are parsed. 4490 // they are parsed.
4508 const Class& function_type_alias = Class::Handle(I, 4491 const Class& function_type_alias = Class::Handle(I,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4553 4536
4554 const String& signature = String::Handle(I, 4537 const String& signature = String::Handle(I,
4555 signature_function.Signature()); 4538 signature_function.Signature());
4556 if (FLAG_trace_parser) { 4539 if (FLAG_trace_parser) {
4557 OS::Print("TopLevel parsing function type alias '%s'\n", 4540 OS::Print("TopLevel parsing function type alias '%s'\n",
4558 signature.ToCString()); 4541 signature.ToCString());
4559 } 4542 }
4560 // Lookup the signature class, i.e. the class whose name is the signature. 4543 // Lookup the signature class, i.e. the class whose name is the signature.
4561 // We only lookup in the current library, but not in its imports, and only 4544 // We only lookup in the current library, but not in its imports, and only
4562 // create a new canonical signature class if it does not exist yet. 4545 // create a new canonical signature class if it does not exist yet.
4563 Class& signature_class = Class::ZoneHandle(I, 4546 Class& signature_class =
4564 library_.LookupLocalClass(signature)); 4547 Class::ZoneHandle(I, library_.LookupLocalClass(signature));
4565 if (signature_class.IsNull()) { 4548 if (signature_class.IsNull()) {
4566 signature_class = Class::NewSignatureClass(signature, 4549 signature_class = Class::NewSignatureClass(signature,
4567 signature_function, 4550 signature_function,
4568 script_, 4551 script_,
4569 alias_name_pos); 4552 alias_name_pos);
4570 // Record the function signature class in the current library. 4553 // Record the function signature class in the current library.
4571 library_.AddClass(signature_class); 4554 library_.AddClass(signature_class);
4572 } else { 4555 } else {
4573 // Forget the just created signature function and use the existing one. 4556 // Forget the just created signature function and use the existing one.
4574 signature_function = signature_class.signature_function(); 4557 signature_function = signature_class.signature_function();
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
4899 ConsumeToken(); 4882 ConsumeToken();
4900 break; 4883 break;
4901 } else { 4884 } else {
4902 ExpectSemicolon(); // Reports error. 4885 ExpectSemicolon(); // Reports error.
4903 } 4886 }
4904 } 4887 }
4905 } 4888 }
4906 4889
4907 4890
4908 RawFunction::AsyncModifier Parser::ParseFunctionModifier() { 4891 RawFunction::AsyncModifier Parser::ParseFunctionModifier() {
4909 if (FLAG_enable_async) { 4892 if (CurrentLiteral()->raw() == Symbols::Async().raw()) {
4910 if (CurrentLiteral()->raw() == Symbols::Async().raw()) { 4893 if (!FLAG_enable_async) {
4911 ConsumeToken(); 4894 ReportError("use flag --enable-async to enable async/await features");
4912 return RawFunction::kAsync;
4913 } 4895 }
4896 ConsumeToken();
4897 return RawFunction::kAsync;
4914 } 4898 }
4915 return RawFunction::kNoModifier; 4899 return RawFunction::kNoModifier;
4916 } 4900 }
4917 4901
4918 4902
4919 void Parser::ParseTopLevelFunction(TopLevel* top_level, 4903 void Parser::ParseTopLevelFunction(TopLevel* top_level,
4920 intptr_t metadata_pos) { 4904 intptr_t metadata_pos) {
4921 TRACE_PARSER("ParseTopLevelFunction"); 4905 TRACE_PARSER("ParseTopLevelFunction");
4922 const intptr_t decl_begin_pos = TokenPos(); 4906 const intptr_t decl_begin_pos = TokenPos();
4923 AbstractType& result_type = Type::Handle(I, Type::DynamicType()); 4907 AbstractType& result_type = Type::Handle(I, Type::DynamicType());
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after
5878 5862
5879 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); 5863 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false);
5880 closure_body->scope()->CaptureVariable(Symbols::AsyncCompleter()); 5864 closure_body->scope()->CaptureVariable(Symbols::AsyncCompleter());
5881 5865
5882 // Create and return a new future that executes a closure with the current 5866 // Create and return a new future that executes a closure with the current
5883 // body. 5867 // body.
5884 5868
5885 // No need to capture parameters or other variables, since they have already 5869 // No need to capture parameters or other variables, since they have already
5886 // been captured in the corresponding scope as the body has been parsed within 5870 // been captured in the corresponding scope as the body has been parsed within
5887 // a nested block (contained in the async funtion's block). 5871 // a nested block (contained in the async funtion's block).
5888 const Class& future = Class::ZoneHandle(I, 5872 const Class& future =
5889 GetClassForAsync(Symbols::Future())); 5873 Class::ZoneHandle(I, I->object_store()->future_class());
5890 ASSERT(!future.IsNull()); 5874 ASSERT(!future.IsNull());
5891 const Function& constructor = Function::ZoneHandle(I, 5875 const Function& constructor = Function::ZoneHandle(I,
5892 future.LookupFunction(Symbols::FutureConstructor())); 5876 future.LookupFunction(Symbols::FutureConstructor()));
5893 ASSERT(!constructor.IsNull()); 5877 ASSERT(!constructor.IsNull());
5894 const Class& completer = Class::ZoneHandle(I, 5878 const Class& completer =
5895 GetClassForAsync(Symbols::Completer())); 5879 Class::ZoneHandle(I, I->object_store()->completer_class());
5896 ASSERT(!completer.IsNull()); 5880 ASSERT(!completer.IsNull());
5897 const Function& completer_constructor = Function::ZoneHandle(I, 5881 const Function& completer_constructor = Function::ZoneHandle(I,
5898 completer.LookupFunction(Symbols::CompleterConstructor())); 5882 completer.LookupFunction(Symbols::CompleterConstructor()));
5899 ASSERT(!completer_constructor.IsNull()); 5883 ASSERT(!completer_constructor.IsNull());
5900 5884
5901 LocalVariable* async_completer = current_block_->scope->LookupVariable( 5885 LocalVariable* async_completer = current_block_->scope->LookupVariable(
5902 Symbols::AsyncCompleter(), false); 5886 Symbols::AsyncCompleter(), false);
5903 5887
5904 // Add to AST: 5888 // Add to AST:
5905 // :async_completer = new Completer(); 5889 // :async_completer = new Completer();
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
6607 } else if (CurrentToken() == Token::kFALSE) { 6591 } else if (CurrentToken() == Token::kFALSE) {
6608 *value = Bool::False().raw(); 6592 *value = Bool::False().raw();
6609 return true; 6593 return true;
6610 } 6594 }
6611 return false; 6595 return false;
6612 } 6596 }
6613 6597
6614 6598
6615 // Returns true if the current token is kIDENT or a pseudo-keyword. 6599 // Returns true if the current token is kIDENT or a pseudo-keyword.
6616 bool Parser::IsIdentifier() { 6600 bool Parser::IsIdentifier() {
6617 return Token::IsIdentifier(CurrentToken()) && !IsAwaitAsKeyword(); 6601 return Token::IsIdentifier(CurrentToken()) && !IsAwaitKeyword();
6618 } 6602 }
6619 6603
6620 6604
6621 // Returns true if the next tokens can be parsed as a an optionally 6605 // Returns true if the next tokens can be parsed as a an optionally
6622 // qualified identifier: [ident '.'] ident. 6606 // qualified identifier: [ident '.'] ident.
6623 // Current token position is not restored. 6607 // Current token position is not restored.
6624 bool Parser::TryParseQualIdent() { 6608 bool Parser::TryParseQualIdent() {
6625 if (CurrentToken() != Token::kIDENT) { 6609 if (CurrentToken() != Token::kIDENT) {
6626 return false; 6610 return false;
6627 } 6611 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
6756 SetPosition(saved_pos); 6740 SetPosition(saved_pos);
6757 return false; 6741 return false;
6758 } 6742 }
6759 // Check parameter list and the following token. 6743 // Check parameter list and the following token.
6760 if (CurrentToken() == Token::kLPAREN) { 6744 if (CurrentToken() == Token::kLPAREN) {
6761 SkipToMatchingParenthesis(); 6745 SkipToMatchingParenthesis();
6762 if ((CurrentToken() == Token::kLBRACE) || 6746 if ((CurrentToken() == Token::kLBRACE) ||
6763 (CurrentToken() == Token::kARROW) || 6747 (CurrentToken() == Token::kARROW) ||
6764 (is_top_level_ && IsLiteral("native")) || 6748 (is_top_level_ && IsLiteral("native")) ||
6765 is_external || 6749 is_external ||
6766 (FLAG_enable_async && 6750 (CurrentLiteral()->raw() == Symbols::Async().raw())) {
6767 CurrentLiteral()->raw() == Symbols::Async().raw())) {
6768 SetPosition(saved_pos); 6751 SetPosition(saved_pos);
6769 return true; 6752 return true;
6770 } 6753 }
6771 } 6754 }
6772 SetPosition(saved_pos); 6755 SetPosition(saved_pos);
6773 return false; 6756 return false;
6774 } 6757 }
6775 6758
6776 6759
6777 bool Parser::IsTopLevelAccessor() { 6760 bool Parser::IsTopLevelAccessor() {
(...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after
8302 ConsumeToken(); 8285 ConsumeToken();
8303 return ident; 8286 return ident;
8304 } 8287 }
8305 8288
8306 8289
8307 bool Parser::IsLiteral(const char* literal) { 8290 bool Parser::IsLiteral(const char* literal) {
8308 return IsIdentifier() && CurrentLiteral()->Equals(literal); 8291 return IsIdentifier() && CurrentLiteral()->Equals(literal);
8309 } 8292 }
8310 8293
8311 8294
8312 bool Parser::IsAwaitAsKeyword() { 8295 bool Parser::IsAwaitKeyword() {
8313 return await_is_keyword_ && 8296 return await_is_keyword_ &&
8314 (CurrentLiteral()->raw() == Symbols::Await().raw()); 8297 (CurrentLiteral()->raw() == Symbols::Await().raw());
8315 } 8298 }
8316 8299
8317 8300
8318 static bool IsIncrementOperator(Token::Kind token) { 8301 static bool IsIncrementOperator(Token::Kind token) {
8319 return token == Token::kINCR || token == Token::kDECR; 8302 return token == Token::kINCR || token == Token::kDECR;
8320 } 8303 }
8321 8304
8322 8305
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
8867 TRACE_PARSER("ParseAwaitableExpr"); 8850 TRACE_PARSER("ParseAwaitableExpr");
8868 parsed_function()->reset_have_seen_await(); 8851 parsed_function()->reset_have_seen_await();
8869 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); 8852 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades);
8870 if (parsed_function()->have_seen_await()) { 8853 if (parsed_function()->have_seen_await()) {
8871 // Make sure we do not reuse the scope to avoid creating contexts that we 8854 // Make sure we do not reuse the scope to avoid creating contexts that we
8872 // are unaware of, i.e, creating contexts that have already been covered. 8855 // are unaware of, i.e, creating contexts that have already been covered.
8873 // See FlowGraphBuilder::VisitSequenceNode() for details on when contexts 8856 // See FlowGraphBuilder::VisitSequenceNode() for details on when contexts
8874 // are created. 8857 // are created.
8875 OpenBlock(); 8858 OpenBlock();
8876 AwaitTransformer at(current_block_->statements, 8859 AwaitTransformer at(current_block_->statements,
8877 library_,
8878 parsed_function(), 8860 parsed_function(),
8879 async_temp_scope_); 8861 async_temp_scope_);
8880 AstNode* result = at.Transform(expr); 8862 AstNode* result = at.Transform(expr);
8881 SequenceNode* preamble = CloseBlock(); 8863 SequenceNode* preamble = CloseBlock();
8882 if (await_preamble == NULL) { 8864 if (await_preamble == NULL) {
8883 current_block_->statements->Add(preamble); 8865 current_block_->statements->Add(preamble);
8884 } else { 8866 } else {
8885 *await_preamble = preamble; 8867 *await_preamble = preamble;
8886 } 8868 }
8887 parsed_function()->reset_have_seen_await(); 8869 parsed_function()->reset_have_seen_await();
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
8978 expr = new(I) ConditionalExprNode(expr_pos, expr, expr1, expr2); 8960 expr = new(I) ConditionalExprNode(expr_pos, expr, expr1, expr2);
8979 } 8961 }
8980 return expr; 8962 return expr;
8981 } 8963 }
8982 8964
8983 8965
8984 AstNode* Parser::ParseUnaryExpr() { 8966 AstNode* Parser::ParseUnaryExpr() {
8985 TRACE_PARSER("ParseUnaryExpr"); 8967 TRACE_PARSER("ParseUnaryExpr");
8986 AstNode* expr = NULL; 8968 AstNode* expr = NULL;
8987 const intptr_t op_pos = TokenPos(); 8969 const intptr_t op_pos = TokenPos();
8988 if (IsAwaitAsKeyword()) { 8970 if (IsAwaitKeyword()) {
8989 TRACE_PARSER("ParseAwaitExpr"); 8971 TRACE_PARSER("ParseAwaitExpr");
8990 ConsumeToken(); 8972 ConsumeToken();
8991 parsed_function()->record_await(); 8973 parsed_function()->record_await();
8992 expr = new (I) AwaitNode(TokenPos(), ParseUnaryExpr()); 8974 expr = new (I) AwaitNode(TokenPos(), ParseUnaryExpr());
8993 } else if (IsPrefixOperator(CurrentToken())) { 8975 } else if (IsPrefixOperator(CurrentToken())) {
8994 Token::Kind unary_op = CurrentToken(); 8976 Token::Kind unary_op = CurrentToken();
8995 if (unary_op == Token::kSUB) { 8977 if (unary_op == Token::kSUB) {
8996 unary_op = Token::kNEGATE; 8978 unary_op = Token::kNEGATE;
8997 } 8979 }
8998 ConsumeToken(); 8980 ConsumeToken();
(...skipping 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after
11808 void Parser::SkipQualIdent() { 11790 void Parser::SkipQualIdent() {
11809 ASSERT(IsIdentifier()); 11791 ASSERT(IsIdentifier());
11810 ConsumeToken(); 11792 ConsumeToken();
11811 if (CurrentToken() == Token::kPERIOD) { 11793 if (CurrentToken() == Token::kPERIOD) {
11812 ConsumeToken(); // Consume the kPERIOD token. 11794 ConsumeToken(); // Consume the kPERIOD token.
11813 ExpectIdentifier("identifier expected after '.'"); 11795 ExpectIdentifier("identifier expected after '.'");
11814 } 11796 }
11815 } 11797 }
11816 11798
11817 } // namespace dart 11799 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698