OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/ast-expression-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2713 // ES6 14.6.1 Static Semantics: IsInTailPosition | 2713 // ES6 14.6.1 Static Semantics: IsInTailPosition |
2714 Scanner::Location loc(pos, pos + 1); | 2714 Scanner::Location loc(pos, pos + 1); |
2715 function_state_->AddExpressionInTailPosition(return_value, loc); | 2715 function_state_->AddExpressionInTailPosition(return_value, loc); |
2716 } | 2716 } |
2717 } | 2717 } |
2718 } | 2718 } |
2719 ExpectSemicolon(CHECK_OK); | 2719 ExpectSemicolon(CHECK_OK); |
2720 | 2720 |
2721 if (is_generator()) { | 2721 if (is_generator()) { |
2722 return_value = BuildIteratorResult(return_value, true); | 2722 return_value = BuildIteratorResult(return_value, true); |
| 2723 } else if (is_async_function()) { |
| 2724 return_value = EmitPromiseResolve(return_value, return_value->position()); |
2723 } | 2725 } |
2724 | 2726 |
2725 result = factory()->NewReturnStatement(return_value, loc.beg_pos); | 2727 result = factory()->NewReturnStatement(return_value, loc.beg_pos); |
2726 | 2728 |
2727 Scope* decl_scope = scope_->DeclarationScope(); | 2729 Scope* decl_scope = scope_->DeclarationScope(); |
2728 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { | 2730 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { |
2729 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); | 2731 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); |
2730 *ok = false; | 2732 *ok = false; |
2731 return NULL; | 2733 return NULL; |
2732 } | 2734 } |
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3953 expr = assignment->target(); | 3955 expr = assignment->target(); |
3954 | 3956 |
3955 // TODO(adamk): Only call this if necessary. | 3957 // TODO(adamk): Only call this if necessary. |
3956 RewriteParameterInitializerScope(parser_->stack_limit(), initializer, | 3958 RewriteParameterInitializerScope(parser_->stack_limit(), initializer, |
3957 parser_->scope_, parameters->scope); | 3959 parser_->scope_, parameters->scope); |
3958 } | 3960 } |
3959 | 3961 |
3960 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); | 3962 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); |
3961 } | 3963 } |
3962 | 3964 |
| 3965 void ParserTraits::ParseAsyncArrowSingleExpressionBody( |
| 3966 ZoneList<Statement*>* body, bool accept_IN, |
| 3967 Type::ExpressionClassifier* classifier, int pos, bool* ok) { |
| 3968 parser_->DesugarAsyncFunctionBody( |
| 3969 parser_->ast_value_factory()->empty_string(), parser_->scope_, body, |
| 3970 classifier, kAsyncArrowFunction, FunctionBody::ArrowConcise, accept_IN, |
| 3971 pos, ok); |
| 3972 } |
| 3973 |
| 3974 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, |
| 3975 Scope* scope, ZoneList<Statement*>* body, |
| 3976 ExpressionClassifier* classifier, |
| 3977 FunctionKind kind, FunctionBody body_type, |
| 3978 bool accept_IN, int pos, bool* ok) { |
| 3979 scope->ForceContextAllocation(); |
| 3980 // Calling a generator returns a generator object. That object is |
| 3981 // stored |
| 3982 // in a temporary variable, a definition that is used by "yield" |
| 3983 // expressions. This also marks the FunctionState as a generator. |
| 3984 Variable* temp = |
| 3985 scope_->NewTemporary(ast_value_factory()->dot_generator_object_string()); |
| 3986 function_state_->set_generator_object_variable(temp); |
| 3987 |
| 3988 // Create generator, but do not yield. |
| 3989 Expression* allocation = EmitCreateJSGeneratorObject(pos); |
| 3990 Expression* assign_yield = |
| 3991 factory()->NewAssignment(Token::INIT, factory()->NewVariableProxy(temp), |
| 3992 allocation, RelocInfo::kNoPosition); |
| 3993 |
| 3994 body->Add( |
| 3995 factory()->NewExpressionStatement(assign_yield, RelocInfo::kNoPosition), |
| 3996 zone()); |
| 3997 |
| 3998 Block* try_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition); |
| 3999 |
| 4000 ZoneList<Statement*>* inner_body = try_block->statements(); |
| 4001 |
| 4002 Expression* return_value = nullptr; |
| 4003 if (body_type == FunctionBody::Normal) { |
| 4004 ParseStatementList(inner_body, Token::RBRACE, ok); |
| 4005 if (!*ok) return; |
| 4006 return_value = factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); |
| 4007 } else { |
| 4008 return_value = ParseAssignmentExpression(accept_IN, classifier, ok); |
| 4009 if (!*ok) return; |
| 4010 ParserTraits::RewriteNonPattern(classifier, ok); |
| 4011 if (!*ok) return; |
| 4012 } |
| 4013 |
| 4014 return_value = EmitPromiseResolve(return_value, return_value->position()); |
| 4015 inner_body->Add( |
| 4016 factory()->NewReturnStatement(return_value, return_value->position()), |
| 4017 zone()); |
| 4018 |
| 4019 Block* catch_block = BuildRejectPromiseOnException(try_block); |
| 4020 |
| 4021 body->Add(catch_block, zone()); |
| 4022 |
| 4023 scope->set_end_position(scanner()->location().end_pos); |
| 4024 } |
3963 | 4025 |
3964 DoExpression* Parser::ParseDoExpression(bool* ok) { | 4026 DoExpression* Parser::ParseDoExpression(bool* ok) { |
3965 // AssignmentExpression :: | 4027 // AssignmentExpression :: |
3966 // do '{' StatementList '}' | 4028 // do '{' StatementList '}' |
3967 int pos = peek_position(); | 4029 int pos = peek_position(); |
3968 | 4030 |
3969 Expect(Token::DO, CHECK_OK); | 4031 Expect(Token::DO, CHECK_OK); |
3970 Variable* result = | 4032 Variable* result = |
3971 scope_->NewTemporary(ast_value_factory()->dot_result_string()); | 4033 scope_->NewTemporary(ast_value_factory()->dot_result_string()); |
3972 Block* block = ParseBlock(nullptr, false, CHECK_OK); | 4034 Block* block = ParseBlock(nullptr, false, CHECK_OK); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4080 if (is_generator) { | 4142 if (is_generator) { |
4081 // For generators, allocating variables in contexts is currently a win | 4143 // For generators, allocating variables in contexts is currently a win |
4082 // because it minimizes the work needed to suspend and resume an | 4144 // because it minimizes the work needed to suspend and resume an |
4083 // activation. The machine code produced for generators (by full-codegen) | 4145 // activation. The machine code produced for generators (by full-codegen) |
4084 // relies on this forced context allocation, but not in an essential way. | 4146 // relies on this forced context allocation, but not in an essential way. |
4085 scope_->ForceContextAllocation(); | 4147 scope_->ForceContextAllocation(); |
4086 | 4148 |
4087 // Calling a generator returns a generator object. That object is stored | 4149 // Calling a generator returns a generator object. That object is stored |
4088 // in a temporary variable, a definition that is used by "yield" | 4150 // in a temporary variable, a definition that is used by "yield" |
4089 // expressions. This also marks the FunctionState as a generator. | 4151 // expressions. This also marks the FunctionState as a generator. |
4090 Variable* temp = scope_->NewTemporary( | 4152 if (is_generator) { |
4091 ast_value_factory()->dot_generator_object_string()); | 4153 Variable* temp = scope_->NewTemporary( |
4092 function_state.set_generator_object_variable(temp); | 4154 ast_value_factory()->dot_generator_object_string()); |
| 4155 function_state.set_generator_object_variable(temp); |
| 4156 } |
4093 } | 4157 } |
4094 | 4158 |
4095 Expect(Token::LPAREN, CHECK_OK); | 4159 Expect(Token::LPAREN, CHECK_OK); |
4096 int start_position = scanner()->location().beg_pos; | 4160 int start_position = scanner()->location().beg_pos; |
4097 scope_->set_start_position(start_position); | 4161 scope_->set_start_position(start_position); |
4098 ParserFormalParameters formals(scope); | 4162 ParserFormalParameters formals(scope); |
4099 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 4163 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); |
4100 arity = formals.Arity(); | 4164 arity = formals.Arity(); |
4101 Expect(Token::RPAREN, CHECK_OK); | 4165 Expect(Token::RPAREN, CHECK_OK); |
4102 int formals_end_position = scanner()->location().end_pos; | 4166 int formals_end_position = scanner()->location().end_pos; |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4501 param_scope = param_scope->FinalizeBlockScope(); | 4565 param_scope = param_scope->FinalizeBlockScope(); |
4502 if (param_scope != nullptr) { | 4566 if (param_scope != nullptr) { |
4503 CheckConflictingVarDeclarations(param_scope, CHECK_OK); | 4567 CheckConflictingVarDeclarations(param_scope, CHECK_OK); |
4504 } | 4568 } |
4505 init_block->statements()->Add(param_block, zone()); | 4569 init_block->statements()->Add(param_block, zone()); |
4506 } | 4570 } |
4507 } | 4571 } |
4508 return init_block; | 4572 return init_block; |
4509 } | 4573 } |
4510 | 4574 |
| 4575 Block* Parser::BuildRejectPromiseOnException(Block* block) { |
| 4576 // try { <block> } catch (error) { return Promise.reject(error); } |
| 4577 Block* try_block = block; |
| 4578 Scope* catch_scope = NewScope(scope_, CATCH_SCOPE); |
| 4579 catch_scope->set_is_hidden(); |
| 4580 Variable* catch_variable = |
| 4581 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
| 4582 kCreatedInitialized, Variable::NORMAL); |
| 4583 Block* catch_block = |
| 4584 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
| 4585 |
| 4586 Expression* promise_reject = EmitPromiseReject( |
| 4587 factory()->NewVariableProxy(catch_variable), RelocInfo::kNoPosition); |
| 4588 |
| 4589 ReturnStatement* return_promise_reject = |
| 4590 factory()->NewReturnStatement(promise_reject, RelocInfo::kNoPosition); |
| 4591 catch_block->statements()->Add(return_promise_reject, zone()); |
| 4592 TryStatement* try_catch_statement = |
| 4593 factory()->NewTryCatchStatement(try_block, catch_scope, catch_variable, |
| 4594 catch_block, RelocInfo::kNoPosition); |
| 4595 |
| 4596 block = factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
| 4597 block->statements()->Add(try_catch_statement, zone()); |
| 4598 return block; |
| 4599 } |
| 4600 |
| 4601 Expression* Parser::EmitCreateJSGeneratorObject(int pos) { |
| 4602 DCHECK_NOT_NULL(function_state_->generator_object_variable()); |
| 4603 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); |
| 4604 args->Add(factory()->NewThisFunction(pos), zone()); |
| 4605 args->Add(ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); |
| 4606 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, |
| 4607 pos); |
| 4608 } |
| 4609 |
| 4610 Expression* Parser::EmitPromiseResolve(Expression* value, int pos) { |
| 4611 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); |
| 4612 args->Add(value, zone()); |
| 4613 return factory()->NewCallRuntime(Context::PROMISE_CREATE_RESOLVED_INDEX, args, |
| 4614 pos); |
| 4615 } |
| 4616 |
| 4617 Expression* Parser::EmitPromiseReject(Expression* value, int pos) { |
| 4618 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); |
| 4619 args->Add(value, zone()); |
| 4620 return factory()->NewCallRuntime(Context::PROMISE_CREATE_REJECTED_INDEX, args, |
| 4621 pos); |
| 4622 } |
4511 | 4623 |
4512 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4624 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4513 const AstRawString* function_name, int pos, | 4625 const AstRawString* function_name, int pos, |
4514 const ParserFormalParameters& parameters, FunctionKind kind, | 4626 const ParserFormalParameters& parameters, FunctionKind kind, |
4515 FunctionLiteral::FunctionType function_type, bool* ok) { | 4627 FunctionLiteral::FunctionType function_type, bool* ok) { |
4516 // Everything inside an eagerly parsed function will be parsed eagerly | 4628 // Everything inside an eagerly parsed function will be parsed eagerly |
4517 // (see comment above). | 4629 // (see comment above). |
4518 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 4630 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
4519 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); | 4631 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); |
4520 | 4632 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4554 // - InitialYield yields the actual generator object. | 4666 // - InitialYield yields the actual generator object. |
4555 // - Any return statement inside the body will have its argument wrapped | 4667 // - Any return statement inside the body will have its argument wrapped |
4556 // in a "done" iterator result object. | 4668 // in a "done" iterator result object. |
4557 // - If the generator terminates for whatever reason, we must close it. | 4669 // - If the generator terminates for whatever reason, we must close it. |
4558 // Hence the finally clause. | 4670 // Hence the finally clause. |
4559 | 4671 |
4560 Block* try_block = | 4672 Block* try_block = |
4561 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); | 4673 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); |
4562 | 4674 |
4563 { | 4675 { |
4564 ZoneList<Expression*>* arguments = | 4676 Expression* allocation = EmitCreateJSGeneratorObject(pos); |
4565 new (zone()) ZoneList<Expression*>(2, zone()); | |
4566 arguments->Add(factory()->NewThisFunction(pos), zone()); | |
4567 arguments->Add( | |
4568 ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); | |
4569 CallRuntime* allocation = factory()->NewCallRuntime( | |
4570 Runtime::kCreateJSGeneratorObject, arguments, pos); | |
4571 | |
4572 VariableProxy* init_proxy = factory()->NewVariableProxy( | 4677 VariableProxy* init_proxy = factory()->NewVariableProxy( |
4573 function_state_->generator_object_variable()); | 4678 function_state_->generator_object_variable()); |
4574 Assignment* assignment = factory()->NewAssignment( | 4679 Assignment* assignment = factory()->NewAssignment( |
4575 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); | 4680 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); |
4576 VariableProxy* get_proxy = factory()->NewVariableProxy( | 4681 VariableProxy* get_proxy = factory()->NewVariableProxy( |
4577 function_state_->generator_object_variable()); | 4682 function_state_->generator_object_variable()); |
4578 Yield* yield = | 4683 Yield* yield = |
4579 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); | 4684 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); |
| 4685 |
4580 try_block->statements()->Add( | 4686 try_block->statements()->Add( |
4581 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), | 4687 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), |
4582 zone()); | 4688 zone()); |
4583 } | 4689 } |
4584 | 4690 |
4585 ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK); | 4691 ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK); |
4586 | 4692 |
4587 Statement* final_return = factory()->NewReturnStatement( | 4693 Statement* final_return = factory()->NewReturnStatement( |
4588 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); | 4694 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); |
4589 try_block->statements()->Add(final_return, zone()); | 4695 try_block->statements()->Add(final_return, zone()); |
4590 | 4696 |
4591 Block* finally_block = | 4697 Block* finally_block = |
4592 factory()->NewBlock(nullptr, 1, false, RelocInfo::kNoPosition); | 4698 factory()->NewBlock(nullptr, 1, false, RelocInfo::kNoPosition); |
4593 ZoneList<Expression*>* args = | 4699 ZoneList<Expression*>* args = |
4594 new (zone()) ZoneList<Expression*>(1, zone()); | 4700 new (zone()) ZoneList<Expression*>(1, zone()); |
4595 VariableProxy* call_proxy = factory()->NewVariableProxy( | 4701 VariableProxy* call_proxy = factory()->NewVariableProxy( |
4596 function_state_->generator_object_variable()); | 4702 function_state_->generator_object_variable()); |
4597 args->Add(call_proxy, zone()); | 4703 args->Add(call_proxy, zone()); |
4598 Expression* call = factory()->NewCallRuntime( | 4704 Expression* call = factory()->NewCallRuntime( |
4599 Runtime::kGeneratorClose, args, RelocInfo::kNoPosition); | 4705 Runtime::kGeneratorClose, args, RelocInfo::kNoPosition); |
4600 finally_block->statements()->Add( | 4706 finally_block->statements()->Add( |
4601 factory()->NewExpressionStatement(call, RelocInfo::kNoPosition), | 4707 factory()->NewExpressionStatement(call, RelocInfo::kNoPosition), |
4602 zone()); | 4708 zone()); |
4603 | 4709 |
4604 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, | 4710 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, |
4605 RelocInfo::kNoPosition), | 4711 RelocInfo::kNoPosition), |
4606 zone()); | 4712 zone()); |
| 4713 } else if (IsAsyncFunction(kind)) { |
| 4714 const bool accept_IN = true; |
| 4715 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind, |
| 4716 FunctionBody::Normal, accept_IN, pos, CHECK_OK); |
4607 } else { | 4717 } else { |
4608 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4718 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
4609 } | 4719 } |
4610 | 4720 |
4611 if (IsSubclassConstructor(kind)) { | 4721 if (IsSubclassConstructor(kind)) { |
4612 body->Add( | 4722 body->Add( |
4613 factory()->NewReturnStatement( | 4723 factory()->NewReturnStatement( |
4614 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), | 4724 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), |
4615 RelocInfo::kNoPosition), | 4725 RelocInfo::kNoPosition), |
4616 zone()); | 4726 zone()); |
4617 } | 4727 } |
4618 } | 4728 } |
4619 | 4729 |
4620 Expect(Token::RBRACE, CHECK_OK); | 4730 Expect(Token::RBRACE, CHECK_OK); |
4621 scope_->set_end_position(scanner()->location().end_pos); | 4731 scope_->set_end_position(scanner()->location().end_pos); |
4622 | 4732 |
4623 if (!parameters.is_simple) { | 4733 if (!parameters.is_simple) { |
4624 DCHECK_NOT_NULL(inner_scope); | 4734 DCHECK_NOT_NULL(inner_scope); |
4625 DCHECK_EQ(body, inner_block->statements()); | 4735 DCHECK_EQ(body, inner_block->statements()); |
4626 SetLanguageMode(scope_, inner_scope->language_mode()); | 4736 SetLanguageMode(scope_, inner_scope->language_mode()); |
4627 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); | 4737 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); |
| 4738 |
| 4739 if (IsAsyncFunction(kind)) { |
| 4740 init_block = BuildRejectPromiseOnException(init_block); |
| 4741 } |
| 4742 |
4628 DCHECK_NOT_NULL(init_block); | 4743 DCHECK_NOT_NULL(init_block); |
4629 | 4744 |
4630 inner_scope->set_end_position(scanner()->location().end_pos); | 4745 inner_scope->set_end_position(scanner()->location().end_pos); |
4631 inner_scope = inner_scope->FinalizeBlockScope(); | 4746 inner_scope = inner_scope->FinalizeBlockScope(); |
4632 if (inner_scope != nullptr) { | 4747 if (inner_scope != nullptr) { |
4633 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); | 4748 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); |
4634 InsertShadowingVarBindingInitializers(inner_block); | 4749 InsertShadowingVarBindingInitializers(inner_block); |
4635 } | 4750 } |
4636 | 4751 |
4637 result->Add(init_block, zone()); | 4752 result->Add(init_block, zone()); |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5423 int pos) { | 5538 int pos) { |
5424 return parser_->RewriteAssignExponentiation(left, right, pos); | 5539 return parser_->RewriteAssignExponentiation(left, right, pos); |
5425 } | 5540 } |
5426 | 5541 |
5427 void ParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, | 5542 void ParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, |
5428 bool* ok) { | 5543 bool* ok) { |
5429 parser_->RewriteNonPattern(classifier, ok); | 5544 parser_->RewriteNonPattern(classifier, ok); |
5430 } | 5545 } |
5431 | 5546 |
5432 Expression* ParserTraits::RewriteAwaitExpression(Expression* value, int pos) { | 5547 Expression* ParserTraits::RewriteAwaitExpression(Expression* value, int pos) { |
5433 // TODO(caitp): Implement AsyncFunctionAwait() | 5548 Expression* generator_object = parser_->factory()->NewVariableProxy( |
5434 // per tc39.github.io/ecmascript-asyncawait/#abstract-ops-async-function-await | 5549 parser_->function_state_->generator_object_variable()); |
5435 return value; | 5550 |
| 5551 ZoneList<Expression*>* async_function_await_args = |
| 5552 new (zone()) ZoneList<Expression*>(2, zone()); |
| 5553 async_function_await_args->Add(generator_object, zone()); |
| 5554 async_function_await_args->Add(value, zone()); |
| 5555 Expression* async_function_await = parser_->factory()->NewCallRuntime( |
| 5556 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, |
| 5557 RelocInfo::kNoPosition); |
| 5558 |
| 5559 generator_object = parser_->factory()->NewVariableProxy( |
| 5560 parser_->function_state_->generator_object_variable()); |
| 5561 return parser_->factory()->NewYield(generator_object, async_function_await, |
| 5562 pos); |
5436 } | 5563 } |
5437 | 5564 |
5438 Zone* ParserTraits::zone() const { | 5565 Zone* ParserTraits::zone() const { |
5439 return parser_->function_state_->scope()->zone(); | 5566 return parser_->function_state_->scope()->zone(); |
5440 } | 5567 } |
5441 | 5568 |
5442 | 5569 |
5443 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { | 5570 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { |
5444 return parser_->function_state_->non_patterns_to_rewrite(); | 5571 return parser_->function_state_->non_patterns_to_rewrite(); |
5445 } | 5572 } |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6919 try_block, target); | 7046 try_block, target); |
6920 final_loop = target; | 7047 final_loop = target; |
6921 } | 7048 } |
6922 | 7049 |
6923 return final_loop; | 7050 return final_loop; |
6924 } | 7051 } |
6925 | 7052 |
6926 | 7053 |
6927 } // namespace internal | 7054 } // namespace internal |
6928 } // namespace v8 | 7055 } // namespace v8 |
OLD | NEW |