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 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2701 | 2701 |
2702 } else if (allow_tailcalls() && !is_sloppy(language_mode())) { | 2702 } else if (allow_tailcalls() && !is_sloppy(language_mode())) { |
2703 // ES6 14.6.1 Static Semantics: IsInTailPosition | 2703 // ES6 14.6.1 Static Semantics: IsInTailPosition |
2704 function_state_->AddExpressionInTailPosition(return_value, pos); | 2704 function_state_->AddExpressionInTailPosition(return_value, pos); |
2705 } | 2705 } |
2706 } | 2706 } |
2707 ExpectSemicolon(CHECK_OK); | 2707 ExpectSemicolon(CHECK_OK); |
2708 | 2708 |
2709 if (is_generator()) { | 2709 if (is_generator()) { |
2710 return_value = BuildIteratorResult(return_value, true); | 2710 return_value = BuildIteratorResult(return_value, true); |
| 2711 } else if (is_async_function()) { |
| 2712 return_value = EmitPromiseResolve(return_value, return_value->position()); |
2711 } | 2713 } |
2712 | 2714 |
2713 result = factory()->NewReturnStatement(return_value, loc.beg_pos); | 2715 result = factory()->NewReturnStatement(return_value, loc.beg_pos); |
2714 | 2716 |
2715 Scope* decl_scope = scope_->DeclarationScope(); | 2717 Scope* decl_scope = scope_->DeclarationScope(); |
2716 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { | 2718 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { |
2717 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); | 2719 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); |
2718 *ok = false; | 2720 *ok = false; |
2719 return NULL; | 2721 return NULL; |
2720 } | 2722 } |
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3939 expr = assignment->target(); | 3941 expr = assignment->target(); |
3940 | 3942 |
3941 // TODO(adamk): Only call this if necessary. | 3943 // TODO(adamk): Only call this if necessary. |
3942 RewriteParameterInitializerScope(parser_->stack_limit(), initializer, | 3944 RewriteParameterInitializerScope(parser_->stack_limit(), initializer, |
3943 parser_->scope_, parameters->scope); | 3945 parser_->scope_, parameters->scope); |
3944 } | 3946 } |
3945 | 3947 |
3946 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); | 3948 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); |
3947 } | 3949 } |
3948 | 3950 |
| 3951 void ParserTraits::ParseAsyncArrowSingleExpressionBody( |
| 3952 ZoneList<Statement*>* body, bool accept_IN, |
| 3953 Type::ExpressionClassifier* classifier, int pos, bool* ok) { |
| 3954 parser_->DesugarAsyncFunctionBody( |
| 3955 parser_->ast_value_factory()->empty_string(), parser_->scope_, body, |
| 3956 classifier, kAsyncArrowFunction, FunctionBody::ArrowConcise, accept_IN, |
| 3957 pos, ok); |
| 3958 } |
| 3959 |
| 3960 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, |
| 3961 Scope* scope, ZoneList<Statement*>* body, |
| 3962 ExpressionClassifier* classifier, |
| 3963 FunctionKind kind, FunctionBody body_type, |
| 3964 bool accept_IN, int pos, bool* ok) { |
| 3965 scope->ForceContextAllocation(); |
| 3966 // Calling a generator returns a generator object. That object is |
| 3967 // stored |
| 3968 // in a temporary variable, a definition that is used by "yield" |
| 3969 // expressions. This also marks the FunctionState as a generator. |
| 3970 Variable* temp = |
| 3971 scope_->NewTemporary(ast_value_factory()->dot_generator_object_string()); |
| 3972 function_state_->set_generator_object_variable(temp); |
| 3973 |
| 3974 // Create generator, but do not yield. |
| 3975 Expression* allocation = EmitCreateJSGeneratorObject(pos); |
| 3976 Expression* assign_yield = |
| 3977 factory()->NewAssignment(Token::INIT, factory()->NewVariableProxy(temp), |
| 3978 allocation, RelocInfo::kNoPosition); |
| 3979 |
| 3980 body->Add( |
| 3981 factory()->NewExpressionStatement(assign_yield, RelocInfo::kNoPosition), |
| 3982 zone()); |
| 3983 |
| 3984 Block* try_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition); |
| 3985 |
| 3986 ZoneList<Statement*>* inner_body = try_block->statements(); |
| 3987 |
| 3988 Expression* return_value = nullptr; |
| 3989 if (body_type == FunctionBody::Normal) { |
| 3990 ParseStatementList(inner_body, Token::RBRACE, ok); |
| 3991 if (!*ok) return; |
| 3992 return_value = factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); |
| 3993 } else { |
| 3994 return_value = ParseAssignmentExpression(accept_IN, classifier, ok); |
| 3995 if (!*ok) return; |
| 3996 ParserTraits::RewriteNonPattern(classifier, ok); |
| 3997 if (!*ok) return; |
| 3998 } |
| 3999 |
| 4000 return_value = EmitPromiseResolve(return_value, return_value->position()); |
| 4001 inner_body->Add( |
| 4002 factory()->NewReturnStatement(return_value, return_value->position()), |
| 4003 zone()); |
| 4004 |
| 4005 Block* catch_block = BuildRejectPromiseOnException(try_block); |
| 4006 |
| 4007 body->Add(catch_block, zone()); |
| 4008 |
| 4009 scope->set_end_position(scanner()->location().end_pos); |
| 4010 } |
3949 | 4011 |
3950 DoExpression* Parser::ParseDoExpression(bool* ok) { | 4012 DoExpression* Parser::ParseDoExpression(bool* ok) { |
3951 // AssignmentExpression :: | 4013 // AssignmentExpression :: |
3952 // do '{' StatementList '}' | 4014 // do '{' StatementList '}' |
3953 int pos = peek_position(); | 4015 int pos = peek_position(); |
3954 | 4016 |
3955 Expect(Token::DO, CHECK_OK); | 4017 Expect(Token::DO, CHECK_OK); |
3956 Variable* result = | 4018 Variable* result = |
3957 scope_->NewTemporary(ast_value_factory()->dot_result_string()); | 4019 scope_->NewTemporary(ast_value_factory()->dot_result_string()); |
3958 Block* block = ParseBlock(nullptr, false, CHECK_OK); | 4020 Block* block = ParseBlock(nullptr, false, CHECK_OK); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4066 if (is_generator) { | 4128 if (is_generator) { |
4067 // For generators, allocating variables in contexts is currently a win | 4129 // For generators, allocating variables in contexts is currently a win |
4068 // because it minimizes the work needed to suspend and resume an | 4130 // because it minimizes the work needed to suspend and resume an |
4069 // activation. The machine code produced for generators (by full-codegen) | 4131 // activation. The machine code produced for generators (by full-codegen) |
4070 // relies on this forced context allocation, but not in an essential way. | 4132 // relies on this forced context allocation, but not in an essential way. |
4071 scope_->ForceContextAllocation(); | 4133 scope_->ForceContextAllocation(); |
4072 | 4134 |
4073 // Calling a generator returns a generator object. That object is stored | 4135 // Calling a generator returns a generator object. That object is stored |
4074 // in a temporary variable, a definition that is used by "yield" | 4136 // in a temporary variable, a definition that is used by "yield" |
4075 // expressions. This also marks the FunctionState as a generator. | 4137 // expressions. This also marks the FunctionState as a generator. |
4076 Variable* temp = scope_->NewTemporary( | 4138 if (is_generator) { |
4077 ast_value_factory()->dot_generator_object_string()); | 4139 Variable* temp = scope_->NewTemporary( |
4078 function_state.set_generator_object_variable(temp); | 4140 ast_value_factory()->dot_generator_object_string()); |
| 4141 function_state.set_generator_object_variable(temp); |
| 4142 } |
4079 } | 4143 } |
4080 | 4144 |
4081 Expect(Token::LPAREN, CHECK_OK); | 4145 Expect(Token::LPAREN, CHECK_OK); |
4082 int start_position = scanner()->location().beg_pos; | 4146 int start_position = scanner()->location().beg_pos; |
4083 scope_->set_start_position(start_position); | 4147 scope_->set_start_position(start_position); |
4084 ParserFormalParameters formals(scope); | 4148 ParserFormalParameters formals(scope); |
4085 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 4149 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); |
4086 arity = formals.Arity(); | 4150 arity = formals.Arity(); |
4087 Expect(Token::RPAREN, CHECK_OK); | 4151 Expect(Token::RPAREN, CHECK_OK); |
4088 int formals_end_position = scanner()->location().end_pos; | 4152 int formals_end_position = scanner()->location().end_pos; |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4487 param_scope = param_scope->FinalizeBlockScope(); | 4551 param_scope = param_scope->FinalizeBlockScope(); |
4488 if (param_scope != nullptr) { | 4552 if (param_scope != nullptr) { |
4489 CheckConflictingVarDeclarations(param_scope, CHECK_OK); | 4553 CheckConflictingVarDeclarations(param_scope, CHECK_OK); |
4490 } | 4554 } |
4491 init_block->statements()->Add(param_block, zone()); | 4555 init_block->statements()->Add(param_block, zone()); |
4492 } | 4556 } |
4493 } | 4557 } |
4494 return init_block; | 4558 return init_block; |
4495 } | 4559 } |
4496 | 4560 |
| 4561 Block* Parser::BuildRejectPromiseOnException(Block* block) { |
| 4562 // try { <block> } catch (error) { return Promise.reject(error); } |
| 4563 Block* try_block = block; |
| 4564 Scope* catch_scope = NewScope(scope_, CATCH_SCOPE); |
| 4565 catch_scope->set_is_hidden(); |
| 4566 Variable* catch_variable = |
| 4567 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
| 4568 kCreatedInitialized, Variable::NORMAL); |
| 4569 Block* catch_block = |
| 4570 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
| 4571 |
| 4572 Expression* promise_reject = EmitPromiseReject( |
| 4573 factory()->NewVariableProxy(catch_variable), RelocInfo::kNoPosition); |
| 4574 |
| 4575 ReturnStatement* return_promise_reject = |
| 4576 factory()->NewReturnStatement(promise_reject, RelocInfo::kNoPosition); |
| 4577 catch_block->statements()->Add(return_promise_reject, zone()); |
| 4578 TryStatement* try_catch_statement = |
| 4579 factory()->NewTryCatchStatement(try_block, catch_scope, catch_variable, |
| 4580 catch_block, RelocInfo::kNoPosition); |
| 4581 |
| 4582 block = factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); |
| 4583 block->statements()->Add(try_catch_statement, zone()); |
| 4584 return block; |
| 4585 } |
| 4586 |
| 4587 Expression* Parser::EmitCreateJSGeneratorObject(int pos) { |
| 4588 DCHECK_NOT_NULL(function_state_->generator_object_variable()); |
| 4589 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); |
| 4590 args->Add(factory()->NewThisFunction(pos), zone()); |
| 4591 args->Add(ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); |
| 4592 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, |
| 4593 pos); |
| 4594 } |
| 4595 |
| 4596 Expression* Parser::EmitPromiseResolve(Expression* value, int pos) { |
| 4597 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); |
| 4598 args->Add(value, zone()); |
| 4599 return factory()->NewCallRuntime(Context::PROMISE_CREATE_RESOLVED_INDEX, args, |
| 4600 pos); |
| 4601 } |
| 4602 |
| 4603 Expression* Parser::EmitPromiseReject(Expression* value, int pos) { |
| 4604 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); |
| 4605 args->Add(value, zone()); |
| 4606 return factory()->NewCallRuntime(Context::PROMISE_CREATE_REJECTED_INDEX, args, |
| 4607 pos); |
| 4608 } |
4497 | 4609 |
4498 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4610 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4499 const AstRawString* function_name, int pos, | 4611 const AstRawString* function_name, int pos, |
4500 const ParserFormalParameters& parameters, FunctionKind kind, | 4612 const ParserFormalParameters& parameters, FunctionKind kind, |
4501 FunctionLiteral::FunctionType function_type, bool* ok) { | 4613 FunctionLiteral::FunctionType function_type, bool* ok) { |
4502 // Everything inside an eagerly parsed function will be parsed eagerly | 4614 // Everything inside an eagerly parsed function will be parsed eagerly |
4503 // (see comment above). | 4615 // (see comment above). |
4504 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 4616 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
4505 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); | 4617 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); |
4506 | 4618 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4540 // - InitialYield yields the actual generator object. | 4652 // - InitialYield yields the actual generator object. |
4541 // - Any return statement inside the body will have its argument wrapped | 4653 // - Any return statement inside the body will have its argument wrapped |
4542 // in a "done" iterator result object. | 4654 // in a "done" iterator result object. |
4543 // - If the generator terminates for whatever reason, we must close it. | 4655 // - If the generator terminates for whatever reason, we must close it. |
4544 // Hence the finally clause. | 4656 // Hence the finally clause. |
4545 | 4657 |
4546 Block* try_block = | 4658 Block* try_block = |
4547 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); | 4659 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); |
4548 | 4660 |
4549 { | 4661 { |
4550 ZoneList<Expression*>* arguments = | 4662 Expression* allocation = EmitCreateJSGeneratorObject(pos); |
4551 new (zone()) ZoneList<Expression*>(2, zone()); | |
4552 arguments->Add(factory()->NewThisFunction(pos), zone()); | |
4553 arguments->Add( | |
4554 ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); | |
4555 CallRuntime* allocation = factory()->NewCallRuntime( | |
4556 Runtime::kCreateJSGeneratorObject, arguments, pos); | |
4557 | |
4558 VariableProxy* init_proxy = factory()->NewVariableProxy( | 4663 VariableProxy* init_proxy = factory()->NewVariableProxy( |
4559 function_state_->generator_object_variable()); | 4664 function_state_->generator_object_variable()); |
4560 Assignment* assignment = factory()->NewAssignment( | 4665 Assignment* assignment = factory()->NewAssignment( |
4561 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); | 4666 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); |
4562 VariableProxy* get_proxy = factory()->NewVariableProxy( | 4667 VariableProxy* get_proxy = factory()->NewVariableProxy( |
4563 function_state_->generator_object_variable()); | 4668 function_state_->generator_object_variable()); |
4564 Yield* yield = | 4669 Yield* yield = |
4565 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); | 4670 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); |
| 4671 |
4566 try_block->statements()->Add( | 4672 try_block->statements()->Add( |
4567 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), | 4673 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), |
4568 zone()); | 4674 zone()); |
4569 } | 4675 } |
4570 | 4676 |
4571 ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK); | 4677 ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK); |
4572 | 4678 |
4573 Statement* final_return = factory()->NewReturnStatement( | 4679 Statement* final_return = factory()->NewReturnStatement( |
4574 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); | 4680 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); |
4575 try_block->statements()->Add(final_return, zone()); | 4681 try_block->statements()->Add(final_return, zone()); |
4576 | 4682 |
4577 Block* finally_block = | 4683 Block* finally_block = |
4578 factory()->NewBlock(nullptr, 1, false, RelocInfo::kNoPosition); | 4684 factory()->NewBlock(nullptr, 1, false, RelocInfo::kNoPosition); |
4579 ZoneList<Expression*>* args = | 4685 ZoneList<Expression*>* args = |
4580 new (zone()) ZoneList<Expression*>(1, zone()); | 4686 new (zone()) ZoneList<Expression*>(1, zone()); |
4581 VariableProxy* call_proxy = factory()->NewVariableProxy( | 4687 VariableProxy* call_proxy = factory()->NewVariableProxy( |
4582 function_state_->generator_object_variable()); | 4688 function_state_->generator_object_variable()); |
4583 args->Add(call_proxy, zone()); | 4689 args->Add(call_proxy, zone()); |
4584 Expression* call = factory()->NewCallRuntime( | 4690 Expression* call = factory()->NewCallRuntime( |
4585 Runtime::kGeneratorClose, args, RelocInfo::kNoPosition); | 4691 Runtime::kGeneratorClose, args, RelocInfo::kNoPosition); |
4586 finally_block->statements()->Add( | 4692 finally_block->statements()->Add( |
4587 factory()->NewExpressionStatement(call, RelocInfo::kNoPosition), | 4693 factory()->NewExpressionStatement(call, RelocInfo::kNoPosition), |
4588 zone()); | 4694 zone()); |
4589 | 4695 |
4590 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, | 4696 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, |
4591 RelocInfo::kNoPosition), | 4697 RelocInfo::kNoPosition), |
4592 zone()); | 4698 zone()); |
| 4699 } else if (IsAsyncFunction(kind)) { |
| 4700 const bool accept_IN = true; |
| 4701 DesugarAsyncFunctionBody(function_name, inner_scope, body, nullptr, kind, |
| 4702 FunctionBody::Normal, accept_IN, pos, CHECK_OK); |
4593 } else { | 4703 } else { |
4594 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4704 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
4595 } | 4705 } |
4596 | 4706 |
4597 if (IsSubclassConstructor(kind)) { | 4707 if (IsSubclassConstructor(kind)) { |
4598 body->Add( | 4708 body->Add( |
4599 factory()->NewReturnStatement( | 4709 factory()->NewReturnStatement( |
4600 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), | 4710 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), |
4601 RelocInfo::kNoPosition), | 4711 RelocInfo::kNoPosition), |
4602 zone()); | 4712 zone()); |
4603 } | 4713 } |
4604 } | 4714 } |
4605 | 4715 |
4606 Expect(Token::RBRACE, CHECK_OK); | 4716 Expect(Token::RBRACE, CHECK_OK); |
4607 scope_->set_end_position(scanner()->location().end_pos); | 4717 scope_->set_end_position(scanner()->location().end_pos); |
4608 | 4718 |
4609 if (!parameters.is_simple) { | 4719 if (!parameters.is_simple) { |
4610 DCHECK_NOT_NULL(inner_scope); | 4720 DCHECK_NOT_NULL(inner_scope); |
4611 DCHECK_EQ(body, inner_block->statements()); | 4721 DCHECK_EQ(body, inner_block->statements()); |
4612 SetLanguageMode(scope_, inner_scope->language_mode()); | 4722 SetLanguageMode(scope_, inner_scope->language_mode()); |
4613 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); | 4723 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); |
| 4724 |
| 4725 if (IsAsyncFunction(kind)) { |
| 4726 init_block = BuildRejectPromiseOnException(init_block); |
| 4727 } |
| 4728 |
4614 DCHECK_NOT_NULL(init_block); | 4729 DCHECK_NOT_NULL(init_block); |
4615 | 4730 |
4616 inner_scope->set_end_position(scanner()->location().end_pos); | 4731 inner_scope->set_end_position(scanner()->location().end_pos); |
4617 inner_scope = inner_scope->FinalizeBlockScope(); | 4732 inner_scope = inner_scope->FinalizeBlockScope(); |
4618 if (inner_scope != nullptr) { | 4733 if (inner_scope != nullptr) { |
4619 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); | 4734 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); |
4620 InsertShadowingVarBindingInitializers(inner_block); | 4735 InsertShadowingVarBindingInitializers(inner_block); |
4621 } | 4736 } |
4622 | 4737 |
4623 result->Add(init_block, zone()); | 4738 result->Add(init_block, zone()); |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5393 int pos) { | 5508 int pos) { |
5394 return parser_->RewriteAssignExponentiation(left, right, pos); | 5509 return parser_->RewriteAssignExponentiation(left, right, pos); |
5395 } | 5510 } |
5396 | 5511 |
5397 void ParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, | 5512 void ParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, |
5398 bool* ok) { | 5513 bool* ok) { |
5399 parser_->RewriteNonPattern(classifier, ok); | 5514 parser_->RewriteNonPattern(classifier, ok); |
5400 } | 5515 } |
5401 | 5516 |
5402 Expression* ParserTraits::RewriteAwaitExpression(Expression* value, int pos) { | 5517 Expression* ParserTraits::RewriteAwaitExpression(Expression* value, int pos) { |
5403 // TODO(caitp): Implement AsyncFunctionAwait() | 5518 Expression* generator_object = parser_->factory()->NewVariableProxy( |
5404 // per tc39.github.io/ecmascript-asyncawait/#abstract-ops-async-function-await | 5519 parser_->function_state_->generator_object_variable()); |
5405 return value; | 5520 |
| 5521 ZoneList<Expression*>* async_function_await_args = |
| 5522 new (zone()) ZoneList<Expression*>(2, zone()); |
| 5523 async_function_await_args->Add(generator_object, zone()); |
| 5524 async_function_await_args->Add(value, zone()); |
| 5525 Expression* async_function_await = parser_->factory()->NewCallRuntime( |
| 5526 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args, |
| 5527 RelocInfo::kNoPosition); |
| 5528 |
| 5529 generator_object = parser_->factory()->NewVariableProxy( |
| 5530 parser_->function_state_->generator_object_variable()); |
| 5531 return parser_->factory()->NewYield(generator_object, async_function_await, |
| 5532 pos); |
5406 } | 5533 } |
5407 | 5534 |
5408 Zone* ParserTraits::zone() const { | 5535 Zone* ParserTraits::zone() const { |
5409 return parser_->function_state_->scope()->zone(); | 5536 return parser_->function_state_->scope()->zone(); |
5410 } | 5537 } |
5411 | 5538 |
5412 | 5539 |
5413 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { | 5540 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { |
5414 return parser_->function_state_->non_patterns_to_rewrite(); | 5541 return parser_->function_state_->non_patterns_to_rewrite(); |
5415 } | 5542 } |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6889 try_block, target); | 7016 try_block, target); |
6890 final_loop = target; | 7017 final_loop = target; |
6891 } | 7018 } |
6892 | 7019 |
6893 return final_loop; | 7020 return final_loop; |
6894 } | 7021 } |
6895 | 7022 |
6896 | 7023 |
6897 } // namespace internal | 7024 } // namespace internal |
6898 } // namespace v8 | 7025 } // namespace v8 |
OLD | NEW |