| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4060 ConsumeToken(); | 4046 ConsumeToken(); |
| 4061 } | 4047 } |
| 4062 ExpectToken(Token::kCLASS); | 4048 ExpectToken(Token::kCLASS); |
| 4063 const intptr_t classname_pos = TokenPos(); | 4049 const intptr_t classname_pos = TokenPos(); |
| 4064 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); | 4050 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); |
| 4065 if (FLAG_trace_parser) { | 4051 if (FLAG_trace_parser) { |
| 4066 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); | 4052 OS::Print("TopLevel parsing class '%s'\n", class_name.ToCString()); |
| 4067 } | 4053 } |
| 4068 Class& cls = Class::Handle(I); | 4054 Class& cls = Class::Handle(I); |
| 4069 TypeArguments& orig_type_parameters = TypeArguments::Handle(I); | 4055 TypeArguments& orig_type_parameters = TypeArguments::Handle(I); |
| 4070 Object& obj = Object::Handle(I, | 4056 Object& obj = Object::Handle(I, library_.LookupLocalObject(class_name)); |
| 4071 library_.LookupLocalObject(class_name)); | |
| 4072 if (obj.IsNull()) { | 4057 if (obj.IsNull()) { |
| 4073 if (is_patch) { | 4058 if (is_patch) { |
| 4074 ReportError(classname_pos, "missing class '%s' cannot be patched", | 4059 ReportError(classname_pos, "missing class '%s' cannot be patched", |
| 4075 class_name.ToCString()); | 4060 class_name.ToCString()); |
| 4076 } | 4061 } |
| 4077 cls = Class::New(class_name, script_, classname_pos); | 4062 cls = Class::New(class_name, script_, classname_pos); |
| 4078 library_.AddClass(cls); | 4063 library_.AddClass(cls); |
| 4079 } else { | 4064 } else { |
| 4080 if (!obj.IsClass()) { | 4065 if (!obj.IsClass()) { |
| 4081 ReportError(classname_pos, "'%s' is already defined", | 4066 ReportError(classname_pos, "'%s' is already defined", |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4268 cls.SetFunctions(array); | 4253 cls.SetFunctions(array); |
| 4269 | 4254 |
| 4270 // Add an implicit constructor if no explicit constructor is present. | 4255 // Add an implicit constructor if no explicit constructor is present. |
| 4271 // No implicit constructors are needed for patch classes. | 4256 // No implicit constructors are needed for patch classes. |
| 4272 if (need_implicit_constructor) { | 4257 if (need_implicit_constructor) { |
| 4273 AddImplicitConstructor(cls); | 4258 AddImplicitConstructor(cls); |
| 4274 } | 4259 } |
| 4275 | 4260 |
| 4276 if (cls.is_patch()) { | 4261 if (cls.is_patch()) { |
| 4277 // Apply the changes to the patched class looked up above. | 4262 // Apply the changes to the patched class looked up above. |
| 4278 Object& obj = Object::Handle(I, | 4263 Object& obj = Object::Handle(I, library_.LookupLocalObject(class_name)); |
| 4279 library_.LookupLocalObject(class_name)); | |
| 4280 // The patched class must not be finalized yet. | 4264 // The patched class must not be finalized yet. |
| 4281 const Class& orig_class = Class::Cast(obj); | 4265 const Class& orig_class = Class::Cast(obj); |
| 4282 ASSERT(!orig_class.is_finalized()); | 4266 ASSERT(!orig_class.is_finalized()); |
| 4283 Error& error = Error::Handle(I); | 4267 Error& error = Error::Handle(I); |
| 4284 if (!orig_class.ApplyPatch(cls, &error)) { | 4268 if (!orig_class.ApplyPatch(cls, &error)) { |
| 4285 Report::LongJumpF(error, script_, class_pos, "applying patch failed"); | 4269 Report::LongJumpF(error, script_, class_pos, "applying patch failed"); |
| 4286 } | 4270 } |
| 4287 } | 4271 } |
| 4288 } | 4272 } |
| 4289 | 4273 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 const GrowableObjectArray& pending_classes, | 4348 const GrowableObjectArray& pending_classes, |
| 4365 const Class& toplevel_class, | 4349 const Class& toplevel_class, |
| 4366 intptr_t metadata_pos) { | 4350 intptr_t metadata_pos) { |
| 4367 TRACE_PARSER("ParseMixinAppAlias"); | 4351 TRACE_PARSER("ParseMixinAppAlias"); |
| 4368 const intptr_t classname_pos = TokenPos(); | 4352 const intptr_t classname_pos = TokenPos(); |
| 4369 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); | 4353 String& class_name = *ExpectUserDefinedTypeIdentifier("class name expected"); |
| 4370 if (FLAG_trace_parser) { | 4354 if (FLAG_trace_parser) { |
| 4371 OS::Print("toplevel parsing mixin application alias class '%s'\n", | 4355 OS::Print("toplevel parsing mixin application alias class '%s'\n", |
| 4372 class_name.ToCString()); | 4356 class_name.ToCString()); |
| 4373 } | 4357 } |
| 4374 const Object& obj = Object::Handle(I, | 4358 const Object& obj = Object::Handle(I, library_.LookupLocalObject(class_name)); |
| 4375 library_.LookupLocalObject(class_name)); | |
| 4376 if (!obj.IsNull()) { | 4359 if (!obj.IsNull()) { |
| 4377 ReportError(classname_pos, "'%s' is already defined", | 4360 ReportError(classname_pos, "'%s' is already defined", |
| 4378 class_name.ToCString()); | 4361 class_name.ToCString()); |
| 4379 } | 4362 } |
| 4380 const Class& mixin_application = | 4363 const Class& mixin_application = |
| 4381 Class::Handle(I, Class::New(class_name, script_, classname_pos)); | 4364 Class::Handle(I, Class::New(class_name, script_, classname_pos)); |
| 4382 mixin_application.set_is_mixin_app_alias(); | 4365 mixin_application.set_is_mixin_app_alias(); |
| 4383 library_.AddClass(mixin_application); | 4366 library_.AddClass(mixin_application); |
| 4384 set_current_class(mixin_application); | 4367 set_current_class(mixin_application); |
| 4385 ParseTypeParameters(mixin_application); | 4368 ParseTypeParameters(mixin_application); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4486 // Wait until we have an owner class before resolving the result type. | 4469 // Wait until we have an owner class before resolving the result type. |
| 4487 result_type = ParseType(ClassFinalizer::kDoNotResolve); | 4470 result_type = ParseType(ClassFinalizer::kDoNotResolve); |
| 4488 } | 4471 } |
| 4489 | 4472 |
| 4490 const intptr_t alias_name_pos = TokenPos(); | 4473 const intptr_t alias_name_pos = TokenPos(); |
| 4491 const String* alias_name = | 4474 const String* alias_name = |
| 4492 ExpectUserDefinedTypeIdentifier("function alias name expected"); | 4475 ExpectUserDefinedTypeIdentifier("function alias name expected"); |
| 4493 | 4476 |
| 4494 // Lookup alias name and report an error if it is already defined in | 4477 // Lookup alias name and report an error if it is already defined in |
| 4495 // the library scope. | 4478 // the library scope. |
| 4496 const Object& obj = Object::Handle(I, | 4479 const Object& obj = |
| 4497 library_.LookupLocalObject(*alias_name)); | 4480 Object::Handle(I, library_.LookupLocalObject(*alias_name)); |
| 4498 if (!obj.IsNull()) { | 4481 if (!obj.IsNull()) { |
| 4499 ReportError(alias_name_pos, | 4482 ReportError(alias_name_pos, |
| 4500 "'%s' is already defined", alias_name->ToCString()); | 4483 "'%s' is already defined", alias_name->ToCString()); |
| 4501 } | 4484 } |
| 4502 | 4485 |
| 4503 // Create the function type alias signature class. It will be linked to its | 4486 // Create the function type alias signature class. It will be linked to its |
| 4504 // signature function after it has been parsed. The type parameters, in order | 4487 // signature function after it has been parsed. The type parameters, in order |
| 4505 // to be properly finalized, need to be associated to this signature class as | 4488 // to be properly finalized, need to be associated to this signature class as |
| 4506 // they are parsed. | 4489 // they are parsed. |
| 4507 const Class& function_type_alias = Class::Handle(I, | 4490 const Class& function_type_alias = Class::Handle(I, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4552 | 4535 |
| 4553 const String& signature = String::Handle(I, | 4536 const String& signature = String::Handle(I, |
| 4554 signature_function.Signature()); | 4537 signature_function.Signature()); |
| 4555 if (FLAG_trace_parser) { | 4538 if (FLAG_trace_parser) { |
| 4556 OS::Print("TopLevel parsing function type alias '%s'\n", | 4539 OS::Print("TopLevel parsing function type alias '%s'\n", |
| 4557 signature.ToCString()); | 4540 signature.ToCString()); |
| 4558 } | 4541 } |
| 4559 // Lookup the signature class, i.e. the class whose name is the signature. | 4542 // Lookup the signature class, i.e. the class whose name is the signature. |
| 4560 // We only lookup in the current library, but not in its imports, and only | 4543 // We only lookup in the current library, but not in its imports, and only |
| 4561 // create a new canonical signature class if it does not exist yet. | 4544 // create a new canonical signature class if it does not exist yet. |
| 4562 Class& signature_class = Class::ZoneHandle(I, | 4545 Class& signature_class = |
| 4563 library_.LookupLocalClass(signature)); | 4546 Class::ZoneHandle(I, library_.LookupLocalClass(signature)); |
| 4564 if (signature_class.IsNull()) { | 4547 if (signature_class.IsNull()) { |
| 4565 signature_class = Class::NewSignatureClass(signature, | 4548 signature_class = Class::NewSignatureClass(signature, |
| 4566 signature_function, | 4549 signature_function, |
| 4567 script_, | 4550 script_, |
| 4568 alias_name_pos); | 4551 alias_name_pos); |
| 4569 // Record the function signature class in the current library. | 4552 // Record the function signature class in the current library. |
| 4570 library_.AddClass(signature_class); | 4553 library_.AddClass(signature_class); |
| 4571 } else { | 4554 } else { |
| 4572 // Forget the just created signature function and use the existing one. | 4555 // Forget the just created signature function and use the existing one. |
| 4573 signature_function = signature_class.signature_function(); | 4556 signature_function = signature_class.signature_function(); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4898 ConsumeToken(); | 4881 ConsumeToken(); |
| 4899 break; | 4882 break; |
| 4900 } else { | 4883 } else { |
| 4901 ExpectSemicolon(); // Reports error. | 4884 ExpectSemicolon(); // Reports error. |
| 4902 } | 4885 } |
| 4903 } | 4886 } |
| 4904 } | 4887 } |
| 4905 | 4888 |
| 4906 | 4889 |
| 4907 RawFunction::AsyncModifier Parser::ParseFunctionModifier() { | 4890 RawFunction::AsyncModifier Parser::ParseFunctionModifier() { |
| 4908 if (FLAG_enable_async) { | 4891 if (CurrentLiteral()->raw() == Symbols::Async().raw()) { |
| 4909 if (CurrentLiteral()->raw() == Symbols::Async().raw()) { | 4892 if (!FLAG_enable_async) { |
| 4910 ConsumeToken(); | 4893 ReportError("use flag --enable-async to enable async/await features"); |
| 4911 return RawFunction::kAsync; | |
| 4912 } | 4894 } |
| 4895 ConsumeToken(); |
| 4896 return RawFunction::kAsync; |
| 4913 } | 4897 } |
| 4914 return RawFunction::kNoModifier; | 4898 return RawFunction::kNoModifier; |
| 4915 } | 4899 } |
| 4916 | 4900 |
| 4917 | 4901 |
| 4918 void Parser::ParseTopLevelFunction(TopLevel* top_level, | 4902 void Parser::ParseTopLevelFunction(TopLevel* top_level, |
| 4919 intptr_t metadata_pos) { | 4903 intptr_t metadata_pos) { |
| 4920 TRACE_PARSER("ParseTopLevelFunction"); | 4904 TRACE_PARSER("ParseTopLevelFunction"); |
| 4921 const intptr_t decl_begin_pos = TokenPos(); | 4905 const intptr_t decl_begin_pos = TokenPos(); |
| 4922 AbstractType& result_type = Type::Handle(I, Type::DynamicType()); | 4906 AbstractType& result_type = Type::Handle(I, Type::DynamicType()); |
| (...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5856 | 5840 |
| 5857 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); | 5841 closure_body->scope()->LookupVariable(Symbols::AwaitJumpVar(), false); |
| 5858 closure_body->scope()->CaptureVariable(Symbols::AsyncCompleter()); | 5842 closure_body->scope()->CaptureVariable(Symbols::AsyncCompleter()); |
| 5859 | 5843 |
| 5860 // Create and return a new future that executes a closure with the current | 5844 // Create and return a new future that executes a closure with the current |
| 5861 // body. | 5845 // body. |
| 5862 | 5846 |
| 5863 // No need to capture parameters or other variables, since they have already | 5847 // No need to capture parameters or other variables, since they have already |
| 5864 // been captured in the corresponding scope as the body has been parsed within | 5848 // been captured in the corresponding scope as the body has been parsed within |
| 5865 // a nested block (contained in the async funtion's block). | 5849 // a nested block (contained in the async funtion's block). |
| 5866 const Class& future = Class::ZoneHandle(I, | 5850 const Class& future = |
| 5867 GetClassForAsync(Symbols::Future())); | 5851 Class::ZoneHandle(I, I->object_store()->future_class()); |
| 5868 ASSERT(!future.IsNull()); | 5852 ASSERT(!future.IsNull()); |
| 5869 const Function& constructor = Function::ZoneHandle(I, | 5853 const Function& constructor = Function::ZoneHandle(I, |
| 5870 future.LookupFunction(Symbols::FutureConstructor())); | 5854 future.LookupFunction(Symbols::FutureConstructor())); |
| 5871 ASSERT(!constructor.IsNull()); | 5855 ASSERT(!constructor.IsNull()); |
| 5872 const Class& completer = Class::ZoneHandle(I, | 5856 const Class& completer = |
| 5873 GetClassForAsync(Symbols::Completer())); | 5857 Class::ZoneHandle(I, I->object_store()->completer_class()); |
| 5874 ASSERT(!completer.IsNull()); | 5858 ASSERT(!completer.IsNull()); |
| 5875 const Function& completer_constructor = Function::ZoneHandle(I, | 5859 const Function& completer_constructor = Function::ZoneHandle(I, |
| 5876 completer.LookupFunction(Symbols::CompleterConstructor())); | 5860 completer.LookupFunction(Symbols::CompleterConstructor())); |
| 5877 ASSERT(!completer_constructor.IsNull()); | 5861 ASSERT(!completer_constructor.IsNull()); |
| 5878 | 5862 |
| 5879 LocalVariable* async_completer = current_block_->scope->LookupVariable( | 5863 LocalVariable* async_completer = current_block_->scope->LookupVariable( |
| 5880 Symbols::AsyncCompleter(), false); | 5864 Symbols::AsyncCompleter(), false); |
| 5881 | 5865 |
| 5882 // Add to AST: | 5866 // Add to AST: |
| 5883 // :async_completer = new Completer(); | 5867 // :async_completer = new Completer(); |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6585 } else if (CurrentToken() == Token::kFALSE) { | 6569 } else if (CurrentToken() == Token::kFALSE) { |
| 6586 *value = Bool::False().raw(); | 6570 *value = Bool::False().raw(); |
| 6587 return true; | 6571 return true; |
| 6588 } | 6572 } |
| 6589 return false; | 6573 return false; |
| 6590 } | 6574 } |
| 6591 | 6575 |
| 6592 | 6576 |
| 6593 // Returns true if the current token is kIDENT or a pseudo-keyword. | 6577 // Returns true if the current token is kIDENT or a pseudo-keyword. |
| 6594 bool Parser::IsIdentifier() { | 6578 bool Parser::IsIdentifier() { |
| 6595 return Token::IsIdentifier(CurrentToken()) && !IsAwaitAsKeyword(); | 6579 return Token::IsIdentifier(CurrentToken()) && !IsAwaitKeyword(); |
| 6596 } | 6580 } |
| 6597 | 6581 |
| 6598 | 6582 |
| 6599 // Returns true if the next tokens can be parsed as a an optionally | 6583 // Returns true if the next tokens can be parsed as a an optionally |
| 6600 // qualified identifier: [ident '.'] ident. | 6584 // qualified identifier: [ident '.'] ident. |
| 6601 // Current token position is not restored. | 6585 // Current token position is not restored. |
| 6602 bool Parser::TryParseQualIdent() { | 6586 bool Parser::TryParseQualIdent() { |
| 6603 if (CurrentToken() != Token::kIDENT) { | 6587 if (CurrentToken() != Token::kIDENT) { |
| 6604 return false; | 6588 return false; |
| 6605 } | 6589 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6734 SetPosition(saved_pos); | 6718 SetPosition(saved_pos); |
| 6735 return false; | 6719 return false; |
| 6736 } | 6720 } |
| 6737 // Check parameter list and the following token. | 6721 // Check parameter list and the following token. |
| 6738 if (CurrentToken() == Token::kLPAREN) { | 6722 if (CurrentToken() == Token::kLPAREN) { |
| 6739 SkipToMatchingParenthesis(); | 6723 SkipToMatchingParenthesis(); |
| 6740 if ((CurrentToken() == Token::kLBRACE) || | 6724 if ((CurrentToken() == Token::kLBRACE) || |
| 6741 (CurrentToken() == Token::kARROW) || | 6725 (CurrentToken() == Token::kARROW) || |
| 6742 (is_top_level_ && IsLiteral("native")) || | 6726 (is_top_level_ && IsLiteral("native")) || |
| 6743 is_external || | 6727 is_external || |
| 6744 (FLAG_enable_async && | 6728 (CurrentLiteral()->raw() == Symbols::Async().raw())) { |
| 6745 CurrentLiteral()->raw() == Symbols::Async().raw())) { | |
| 6746 SetPosition(saved_pos); | 6729 SetPosition(saved_pos); |
| 6747 return true; | 6730 return true; |
| 6748 } | 6731 } |
| 6749 } | 6732 } |
| 6750 SetPosition(saved_pos); | 6733 SetPosition(saved_pos); |
| 6751 return false; | 6734 return false; |
| 6752 } | 6735 } |
| 6753 | 6736 |
| 6754 | 6737 |
| 6755 bool Parser::IsTopLevelAccessor() { | 6738 bool Parser::IsTopLevelAccessor() { |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8280 ConsumeToken(); | 8263 ConsumeToken(); |
| 8281 return ident; | 8264 return ident; |
| 8282 } | 8265 } |
| 8283 | 8266 |
| 8284 | 8267 |
| 8285 bool Parser::IsLiteral(const char* literal) { | 8268 bool Parser::IsLiteral(const char* literal) { |
| 8286 return IsIdentifier() && CurrentLiteral()->Equals(literal); | 8269 return IsIdentifier() && CurrentLiteral()->Equals(literal); |
| 8287 } | 8270 } |
| 8288 | 8271 |
| 8289 | 8272 |
| 8290 bool Parser::IsAwaitAsKeyword() { | 8273 bool Parser::IsAwaitKeyword() { |
| 8291 return await_is_keyword_ && | 8274 return await_is_keyword_ && |
| 8292 (CurrentLiteral()->raw() == Symbols::Await().raw()); | 8275 (CurrentLiteral()->raw() == Symbols::Await().raw()); |
| 8293 } | 8276 } |
| 8294 | 8277 |
| 8295 | 8278 |
| 8296 static bool IsIncrementOperator(Token::Kind token) { | 8279 static bool IsIncrementOperator(Token::Kind token) { |
| 8297 return token == Token::kINCR || token == Token::kDECR; | 8280 return token == Token::kINCR || token == Token::kDECR; |
| 8298 } | 8281 } |
| 8299 | 8282 |
| 8300 | 8283 |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8845 TRACE_PARSER("ParseAwaitableExpr"); | 8828 TRACE_PARSER("ParseAwaitableExpr"); |
| 8846 parsed_function()->reset_have_seen_await(); | 8829 parsed_function()->reset_have_seen_await(); |
| 8847 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); | 8830 AstNode* expr = ParseExpr(require_compiletime_const, consume_cascades); |
| 8848 if (parsed_function()->have_seen_await()) { | 8831 if (parsed_function()->have_seen_await()) { |
| 8849 // Make sure we do not reuse the scope to avoid creating contexts that we | 8832 // Make sure we do not reuse the scope to avoid creating contexts that we |
| 8850 // are unaware of, i.e, creating contexts that have already been covered. | 8833 // are unaware of, i.e, creating contexts that have already been covered. |
| 8851 // See FlowGraphBuilder::VisitSequenceNode() for details on when contexts | 8834 // See FlowGraphBuilder::VisitSequenceNode() for details on when contexts |
| 8852 // are created. | 8835 // are created. |
| 8853 OpenBlock(); | 8836 OpenBlock(); |
| 8854 AwaitTransformer at(current_block_->statements, | 8837 AwaitTransformer at(current_block_->statements, |
| 8855 library_, | |
| 8856 parsed_function(), | 8838 parsed_function(), |
| 8857 async_temp_scope_); | 8839 async_temp_scope_); |
| 8858 AstNode* result = at.Transform(expr); | 8840 AstNode* result = at.Transform(expr); |
| 8859 SequenceNode* preamble = CloseBlock(); | 8841 SequenceNode* preamble = CloseBlock(); |
| 8860 if (await_preamble == NULL) { | 8842 if (await_preamble == NULL) { |
| 8861 current_block_->statements->Add(preamble); | 8843 current_block_->statements->Add(preamble); |
| 8862 } else { | 8844 } else { |
| 8863 *await_preamble = preamble; | 8845 *await_preamble = preamble; |
| 8864 } | 8846 } |
| 8865 parsed_function()->reset_have_seen_await(); | 8847 parsed_function()->reset_have_seen_await(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8953 expr = new(I) ConditionalExprNode(expr_pos, expr, expr1, expr2); | 8935 expr = new(I) ConditionalExprNode(expr_pos, expr, expr1, expr2); |
| 8954 } | 8936 } |
| 8955 return expr; | 8937 return expr; |
| 8956 } | 8938 } |
| 8957 | 8939 |
| 8958 | 8940 |
| 8959 AstNode* Parser::ParseUnaryExpr() { | 8941 AstNode* Parser::ParseUnaryExpr() { |
| 8960 TRACE_PARSER("ParseUnaryExpr"); | 8942 TRACE_PARSER("ParseUnaryExpr"); |
| 8961 AstNode* expr = NULL; | 8943 AstNode* expr = NULL; |
| 8962 const intptr_t op_pos = TokenPos(); | 8944 const intptr_t op_pos = TokenPos(); |
| 8963 if (IsAwaitAsKeyword()) { | 8945 if (IsAwaitKeyword()) { |
| 8964 TRACE_PARSER("ParseAwaitExpr"); | 8946 TRACE_PARSER("ParseAwaitExpr"); |
| 8965 ConsumeToken(); | 8947 ConsumeToken(); |
| 8966 parsed_function()->record_await(); | 8948 parsed_function()->record_await(); |
| 8967 expr = new (I) AwaitNode(TokenPos(), ParseUnaryExpr()); | 8949 expr = new (I) AwaitNode(TokenPos(), ParseUnaryExpr()); |
| 8968 } else if (IsPrefixOperator(CurrentToken())) { | 8950 } else if (IsPrefixOperator(CurrentToken())) { |
| 8969 Token::Kind unary_op = CurrentToken(); | 8951 Token::Kind unary_op = CurrentToken(); |
| 8970 if (unary_op == Token::kSUB) { | 8952 if (unary_op == Token::kSUB) { |
| 8971 unary_op = Token::kNEGATE; | 8953 unary_op = Token::kNEGATE; |
| 8972 } | 8954 } |
| 8973 ConsumeToken(); | 8955 ConsumeToken(); |
| (...skipping 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11783 void Parser::SkipQualIdent() { | 11765 void Parser::SkipQualIdent() { |
| 11784 ASSERT(IsIdentifier()); | 11766 ASSERT(IsIdentifier()); |
| 11785 ConsumeToken(); | 11767 ConsumeToken(); |
| 11786 if (CurrentToken() == Token::kPERIOD) { | 11768 if (CurrentToken() == Token::kPERIOD) { |
| 11787 ConsumeToken(); // Consume the kPERIOD token. | 11769 ConsumeToken(); // Consume the kPERIOD token. |
| 11788 ExpectIdentifier("identifier expected after '.'"); | 11770 ExpectIdentifier("identifier expected after '.'"); |
| 11789 } | 11771 } |
| 11790 } | 11772 } |
| 11791 | 11773 |
| 11792 } // namespace dart | 11774 } // namespace dart |
| OLD | NEW |