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 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2674 is_object_conditional, pos); | 2674 is_object_conditional, pos); |
2675 } | 2675 } |
2676 | 2676 |
2677 // ES6 14.6.1 Static Semantics: IsInTailPosition | 2677 // ES6 14.6.1 Static Semantics: IsInTailPosition |
2678 if (allow_tailcalls() && !is_sloppy(language_mode())) { | 2678 if (allow_tailcalls() && !is_sloppy(language_mode())) { |
2679 function_state_->AddExpressionInTailPosition(return_value); | 2679 function_state_->AddExpressionInTailPosition(return_value); |
2680 } | 2680 } |
2681 } | 2681 } |
2682 ExpectSemicolon(CHECK_OK); | 2682 ExpectSemicolon(CHECK_OK); |
2683 | 2683 |
2684 if (is_generator()) { | 2684 if (is_generator() || is_async_function()) { |
2685 return_value = BuildIteratorResult(return_value, true); | 2685 return_value = BuildIteratorResult(return_value, true); |
2686 } | 2686 } |
2687 | 2687 |
2688 result = factory()->NewReturnStatement(return_value, loc.beg_pos); | 2688 result = factory()->NewReturnStatement(return_value, loc.beg_pos); |
2689 | 2689 |
2690 Scope* decl_scope = scope_->DeclarationScope(); | 2690 Scope* decl_scope = scope_->DeclarationScope(); |
2691 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { | 2691 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { |
2692 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); | 2692 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); |
2693 *ok = false; | 2693 *ok = false; |
2694 return NULL; | 2694 return NULL; |
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4019 // Getter :: | 4019 // Getter :: |
4020 // '(' ')' '{' FunctionBody '}' | 4020 // '(' ')' '{' FunctionBody '}' |
4021 // | 4021 // |
4022 // Setter :: | 4022 // Setter :: |
4023 // '(' PropertySetParameterList ')' '{' FunctionBody '}' | 4023 // '(' PropertySetParameterList ')' '{' FunctionBody '}' |
4024 | 4024 |
4025 int pos = function_token_pos == RelocInfo::kNoPosition | 4025 int pos = function_token_pos == RelocInfo::kNoPosition |
4026 ? peek_position() : function_token_pos; | 4026 ? peek_position() : function_token_pos; |
4027 | 4027 |
4028 bool is_generator = IsGeneratorFunction(kind); | 4028 bool is_generator = IsGeneratorFunction(kind); |
4029 bool is_async = IsAsyncFunction(kind); | |
4029 | 4030 |
4030 // Anonymous functions were passed either the empty symbol or a null | 4031 // Anonymous functions were passed either the empty symbol or a null |
4031 // handle as the function name. Remember if we were passed a non-empty | 4032 // handle as the function name. Remember if we were passed a non-empty |
4032 // handle to decide whether to invoke function name inference. | 4033 // handle to decide whether to invoke function name inference. |
4033 bool should_infer_name = function_name == NULL; | 4034 bool should_infer_name = function_name == NULL; |
4034 | 4035 |
4035 // We want a non-null handle as the function name. | 4036 // We want a non-null handle as the function name. |
4036 if (should_infer_name) { | 4037 if (should_infer_name) { |
4037 function_name = ast_value_factory()->empty_string(); | 4038 function_name = ast_value_factory()->empty_string(); |
4038 } | 4039 } |
(...skipping 11 matching lines...) Expand all Loading... | |
4050 bool should_be_used_once_hint = false; | 4051 bool should_be_used_once_hint = false; |
4051 bool has_duplicate_parameters; | 4052 bool has_duplicate_parameters; |
4052 // Parse function. | 4053 // Parse function. |
4053 { | 4054 { |
4054 AstNodeFactory function_factory(ast_value_factory()); | 4055 AstNodeFactory function_factory(ast_value_factory()); |
4055 FunctionState function_state(&function_state_, &scope_, scope, kind, | 4056 FunctionState function_state(&function_state_, &scope_, scope, kind, |
4056 &function_factory); | 4057 &function_factory); |
4057 scope_->SetScopeName(function_name); | 4058 scope_->SetScopeName(function_name); |
4058 ExpressionClassifier formals_classifier(this, &duplicate_finder); | 4059 ExpressionClassifier formals_classifier(this, &duplicate_finder); |
4059 | 4060 |
4060 if (is_generator) { | 4061 if (is_generator || is_async) { |
4061 // For generators, allocating variables in contexts is currently a win | 4062 // For generators, allocating variables in contexts is currently a win |
4062 // because it minimizes the work needed to suspend and resume an | 4063 // because it minimizes the work needed to suspend and resume an |
4063 // activation. The machine code produced for generators (by full-codegen) | 4064 // activation. The machine code produced for generators (by full-codegen) |
4064 // relies on this forced context allocation, but not in an essential way. | 4065 // relies on this forced context allocation, but not in an essential way. |
4065 scope_->ForceContextAllocation(); | 4066 scope_->ForceContextAllocation(); |
4066 | 4067 |
4067 // Calling a generator returns a generator object. That object is stored | 4068 // Calling a generator returns a generator object. That object is stored |
4068 // in a temporary variable, a definition that is used by "yield" | 4069 // in a temporary variable, a definition that is used by "yield" |
4069 // expressions. This also marks the FunctionState as a generator. | 4070 // expressions. This also marks the FunctionState as a generator. |
4070 Variable* temp = scope_->NewTemporary( | 4071 if (is_generator) { |
4071 ast_value_factory()->dot_generator_object_string()); | 4072 Variable* temp = scope_->NewTemporary( |
4072 function_state.set_generator_object_variable(temp); | 4073 ast_value_factory()->dot_generator_object_string()); |
4074 function_state.set_generator_object_variable(temp); | |
4075 } | |
4073 } | 4076 } |
4074 | 4077 |
4075 Expect(Token::LPAREN, CHECK_OK); | 4078 Expect(Token::LPAREN, CHECK_OK); |
4076 int start_position = scanner()->location().beg_pos; | 4079 int start_position = scanner()->location().beg_pos; |
4077 scope_->set_start_position(start_position); | 4080 scope_->set_start_position(start_position); |
4078 ParserFormalParameters formals(scope); | 4081 ParserFormalParameters formals(scope); |
4079 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); | 4082 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); |
4080 arity = formals.Arity(); | 4083 arity = formals.Arity(); |
4081 Expect(Token::RPAREN, CHECK_OK); | 4084 Expect(Token::RPAREN, CHECK_OK); |
4082 int formals_end_position = scanner()->location().end_pos; | 4085 int formals_end_position = scanner()->location().end_pos; |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4482 param_scope = param_scope->FinalizeBlockScope(); | 4485 param_scope = param_scope->FinalizeBlockScope(); |
4483 if (param_scope != nullptr) { | 4486 if (param_scope != nullptr) { |
4484 CheckConflictingVarDeclarations(param_scope, CHECK_OK); | 4487 CheckConflictingVarDeclarations(param_scope, CHECK_OK); |
4485 } | 4488 } |
4486 init_block->statements()->Add(param_block, zone()); | 4489 init_block->statements()->Add(param_block, zone()); |
4487 } | 4490 } |
4488 } | 4491 } |
4489 return init_block; | 4492 return init_block; |
4490 } | 4493 } |
4491 | 4494 |
4495 Expression* Parser::EmitCreateJSGeneratorObject(int pos) { | |
4496 DCHECK_NOT_NULL(function_state_->generator_object_variable()); | |
caitp (gmail)
2016/04/26 22:01:30
these don't really add much, but since they're use
| |
4497 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); | |
4498 args->Add(factory()->NewThisFunction(pos), zone()); | |
4499 args->Add(ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); | |
4500 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, | |
4501 pos); | |
4502 } | |
4503 | |
4504 Expression* Parser::EmitYieldJSGeneratorObject(Expression* allocation) { | |
4505 VariableProxy* init_proxy = | |
4506 factory()->NewVariableProxy(function_state_->generator_object_variable()); | |
4507 Assignment* assignment = factory()->NewAssignment( | |
4508 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); | |
4509 VariableProxy* get_proxy = | |
4510 factory()->NewVariableProxy(function_state_->generator_object_variable()); | |
4511 return factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); | |
4512 } | |
4492 | 4513 |
4493 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4514 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4494 const AstRawString* function_name, int pos, | 4515 const AstRawString* function_name, int pos, |
4495 const ParserFormalParameters& parameters, FunctionKind kind, | 4516 const ParserFormalParameters& parameters, FunctionKind kind, |
4496 FunctionLiteral::FunctionType function_type, bool* ok) { | 4517 FunctionLiteral::FunctionType function_type, bool* ok) { |
4497 // Everything inside an eagerly parsed function will be parsed eagerly | 4518 // Everything inside an eagerly parsed function will be parsed eagerly |
4498 // (see comment above). | 4519 // (see comment above). |
4499 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 4520 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
4500 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); | 4521 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); |
4501 | 4522 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4535 // - InitialYield yields the actual generator object. | 4556 // - InitialYield yields the actual generator object. |
4536 // - Any return statement inside the body will have its argument wrapped | 4557 // - Any return statement inside the body will have its argument wrapped |
4537 // in a "done" iterator result object. | 4558 // in a "done" iterator result object. |
4538 // - If the generator terminates for whatever reason, we must close it. | 4559 // - If the generator terminates for whatever reason, we must close it. |
4539 // Hence the finally clause. | 4560 // Hence the finally clause. |
4540 | 4561 |
4541 Block* try_block = | 4562 Block* try_block = |
4542 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); | 4563 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); |
4543 | 4564 |
4544 { | 4565 { |
4545 ZoneList<Expression*>* arguments = | 4566 Expression* allocation = EmitCreateJSGeneratorObject(pos); |
4546 new (zone()) ZoneList<Expression*>(2, zone()); | 4567 Expression* yield = EmitYieldJSGeneratorObject(allocation); |
4547 arguments->Add(factory()->NewThisFunction(pos), zone()); | |
4548 arguments->Add( | |
4549 ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone()); | |
4550 CallRuntime* allocation = factory()->NewCallRuntime( | |
4551 Runtime::kCreateJSGeneratorObject, arguments, pos); | |
4552 | 4568 |
4553 VariableProxy* init_proxy = factory()->NewVariableProxy( | |
4554 function_state_->generator_object_variable()); | |
4555 Assignment* assignment = factory()->NewAssignment( | |
4556 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); | |
4557 VariableProxy* get_proxy = factory()->NewVariableProxy( | |
4558 function_state_->generator_object_variable()); | |
4559 Yield* yield = | |
4560 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); | |
4561 try_block->statements()->Add( | 4569 try_block->statements()->Add( |
4562 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), | 4570 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), |
4563 zone()); | 4571 zone()); |
4564 } | 4572 } |
4565 | 4573 |
4566 ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK); | 4574 ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK); |
4567 | 4575 |
4568 Statement* final_return = factory()->NewReturnStatement( | 4576 Statement* final_return = factory()->NewReturnStatement( |
4569 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); | 4577 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); |
4570 try_block->statements()->Add(final_return, zone()); | 4578 try_block->statements()->Add(final_return, zone()); |
4571 | 4579 |
4572 Block* finally_block = | 4580 Block* finally_block = |
4573 factory()->NewBlock(nullptr, 1, false, RelocInfo::kNoPosition); | 4581 factory()->NewBlock(nullptr, 1, false, RelocInfo::kNoPosition); |
4574 ZoneList<Expression*>* args = | 4582 ZoneList<Expression*>* args = |
4575 new (zone()) ZoneList<Expression*>(1, zone()); | 4583 new (zone()) ZoneList<Expression*>(1, zone()); |
4576 VariableProxy* call_proxy = factory()->NewVariableProxy( | 4584 VariableProxy* call_proxy = factory()->NewVariableProxy( |
4577 function_state_->generator_object_variable()); | 4585 function_state_->generator_object_variable()); |
4578 args->Add(call_proxy, zone()); | 4586 args->Add(call_proxy, zone()); |
4579 Expression* call = factory()->NewCallRuntime( | 4587 Expression* call = factory()->NewCallRuntime( |
4580 Runtime::kGeneratorClose, args, RelocInfo::kNoPosition); | 4588 Runtime::kGeneratorClose, args, RelocInfo::kNoPosition); |
4581 finally_block->statements()->Add( | 4589 finally_block->statements()->Add( |
4582 factory()->NewExpressionStatement(call, RelocInfo::kNoPosition), | 4590 factory()->NewExpressionStatement(call, RelocInfo::kNoPosition), |
4583 zone()); | 4591 zone()); |
4584 | 4592 |
4585 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, | 4593 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, |
4586 RelocInfo::kNoPosition), | 4594 RelocInfo::kNoPosition), |
4587 zone()); | 4595 zone()); |
4596 } else if (IsAsyncFunction(kind)) { | |
4597 Expression* inner_generator = nullptr; | |
4598 { | |
4599 Scope* generator_scope = | |
4600 NewScope(inner_scope, FUNCTION_SCOPE, kAsyncFunction); | |
4601 | |
4602 // For generators, allocating variables in contexts is currently a win | |
4603 // because it minimizes the work needed to suspend and resume an | |
4604 // activation. The machine code produced for generators (by | |
4605 // full-codegen) | |
4606 // relies on this forced context allocation, but not in an essential | |
4607 // way. | |
4608 generator_scope->ForceContextAllocation(); | |
4609 | |
4610 FunctionState generator_state_(&function_state_, &scope_, | |
4611 generator_scope, kAsyncFunction, | |
4612 factory()); | |
4613 generator_scope->set_start_position(pos); | |
4614 ZoneList<Statement*>* generator_body = | |
4615 new (zone()) ZoneList<Statement*>(8, zone()); | |
4616 | |
4617 // Calling a generator returns a generator object. That object is | |
4618 // stored | |
4619 // in a temporary variable, a definition that is used by "yield" | |
4620 // expressions. This also marks the FunctionState as a generator. | |
4621 Variable* temp = scope_->NewTemporary( | |
4622 ast_value_factory()->dot_generator_object_string()); | |
4623 generator_state_.set_generator_object_variable(temp); | |
4624 | |
4625 Expression* allocation = EmitCreateJSGeneratorObject(pos); | |
4626 Expression* yield = EmitYieldJSGeneratorObject(allocation); | |
4627 | |
4628 generator_body->Add( | |
4629 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), | |
4630 zone()); | |
4631 | |
4632 ParseStatementList(generator_body, Token::RBRACE, CHECK_OK); | |
4633 | |
4634 Statement* final_return = factory()->NewReturnStatement( | |
4635 BuildIteratorResult(nullptr, true), RelocInfo::kNoPosition); | |
4636 generator_body->Add(final_return, zone()); | |
4637 generator_scope->set_end_position(scanner()->location().end_pos); | |
4638 | |
4639 inner_generator = factory()->NewFunctionLiteral( | |
4640 function_name, generator_scope, generator_body, | |
4641 generator_state_.materialized_literal_count(), | |
4642 generator_state_.expected_property_count(), 0, | |
4643 FunctionLiteral::kNoDuplicateParameters, | |
4644 FunctionLiteral::kAnonymousExpression, | |
4645 FunctionLiteral::kShouldEagerCompile, kGeneratorFunction, | |
4646 RelocInfo::kNoPosition); | |
4647 } | |
4648 | |
4649 ZoneList<Expression*>* call_generator_args = | |
4650 new (zone()) ZoneList<Expression*>(2, zone()); | |
4651 call_generator_args->Add(inner_generator, zone()); | |
4652 call_generator_args->Add( | |
4653 ThisExpression(inner_scope, factory(), RelocInfo::kNoPosition), | |
4654 zone()); | |
4655 Expression* call_generator = factory()->NewCallRuntime( | |
4656 Runtime::kInlineCall, call_generator_args, RelocInfo::kNoPosition); | |
4657 | |
4658 ZoneList<Expression*>* async_function_start_args = | |
4659 new (zone()) ZoneList<Expression*>(1, zone()); | |
4660 async_function_start_args->Add(call_generator, zone()); | |
4661 Expression* async_function_start = factory()->NewCallRuntime( | |
4662 Context::ASYNC_FUNCTION_START_INDEX, async_function_start_args, | |
4663 RelocInfo::kNoPosition); | |
4664 body->Add(factory()->NewReturnStatement(async_function_start, | |
4665 RelocInfo::kNoPosition), | |
4666 zone()); | |
4588 } else { | 4667 } else { |
4589 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4668 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
4590 } | 4669 } |
4591 | 4670 |
4592 if (IsSubclassConstructor(kind)) { | 4671 if (IsSubclassConstructor(kind)) { |
4593 body->Add( | 4672 body->Add( |
4594 factory()->NewReturnStatement( | 4673 factory()->NewReturnStatement( |
4595 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), | 4674 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), |
4596 RelocInfo::kNoPosition), | 4675 RelocInfo::kNoPosition), |
4597 zone()); | 4676 zone()); |
4598 } | 4677 } |
4599 } | 4678 } |
4600 | 4679 |
4601 Expect(Token::RBRACE, CHECK_OK); | 4680 Expect(Token::RBRACE, CHECK_OK); |
4602 scope_->set_end_position(scanner()->location().end_pos); | 4681 scope_->set_end_position(scanner()->location().end_pos); |
4603 | 4682 |
4604 if (!parameters.is_simple) { | 4683 if (!parameters.is_simple) { |
4605 DCHECK_NOT_NULL(inner_scope); | 4684 DCHECK_NOT_NULL(inner_scope); |
4606 DCHECK_EQ(body, inner_block->statements()); | 4685 DCHECK_EQ(body, inner_block->statements()); |
4607 SetLanguageMode(scope_, inner_scope->language_mode()); | 4686 SetLanguageMode(scope_, inner_scope->language_mode()); |
4608 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); | 4687 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); |
4688 | |
4689 if (IsAsyncFunction(kind)) { | |
4690 // If an exception occurs during parameter initialization, return a | |
4691 // rejected promise. | |
4692 // | |
4693 // try { <init_block> } catch (error) { return Promise.reject(error); } | |
4694 Block* try_block = init_block; | |
4695 Scope* catch_scope = NewScope(scope_, CATCH_SCOPE); | |
4696 Variable* catch_variable = | |
4697 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), | |
4698 VAR, kCreatedInitialized, Variable::NORMAL); | |
4699 Block* catch_block = | |
4700 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); | |
4701 | |
4702 ZoneList<Expression*>* promise_reject_arguments = | |
4703 new (zone()) ZoneList<Expression*>(1, zone()); | |
4704 promise_reject_arguments->Add(factory()->NewVariableProxy(catch_variable), | |
4705 zone()); | |
4706 CallRuntime* promise_reject = factory()->NewCallRuntime( | |
4707 Context::PROMISE_CREATE_REJECTED_INDEX, promise_reject_arguments, | |
4708 RelocInfo::kNoPosition); | |
4709 ReturnStatement* return_promise_reject = | |
4710 factory()->NewReturnStatement(promise_reject, RelocInfo::kNoPosition); | |
4711 catch_block->statements()->Add(return_promise_reject, zone()); | |
4712 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( | |
4713 try_block, catch_scope, catch_variable, catch_block, | |
4714 RelocInfo::kNoPosition); | |
4715 | |
4716 init_block = | |
4717 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition); | |
4718 init_block->statements()->Add(try_catch_statement, zone()); | |
4719 } | |
4720 | |
4609 DCHECK_NOT_NULL(init_block); | 4721 DCHECK_NOT_NULL(init_block); |
4610 | 4722 |
4611 inner_scope->set_end_position(scanner()->location().end_pos); | 4723 inner_scope->set_end_position(scanner()->location().end_pos); |
4612 inner_scope = inner_scope->FinalizeBlockScope(); | 4724 inner_scope = inner_scope->FinalizeBlockScope(); |
4613 if (inner_scope != nullptr) { | 4725 if (inner_scope != nullptr) { |
4614 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); | 4726 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); |
4615 InsertShadowingVarBindingInitializers(inner_block); | 4727 InsertShadowingVarBindingInitializers(inner_block); |
4616 } | 4728 } |
4617 | 4729 |
4618 result->Add(init_block, zone()); | 4730 result->Add(init_block, zone()); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5389 } | 5501 } |
5390 | 5502 |
5391 void ParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, | 5503 void ParserTraits::RewriteNonPattern(Type::ExpressionClassifier* classifier, |
5392 bool* ok) { | 5504 bool* ok) { |
5393 parser_->RewriteNonPattern(classifier, ok); | 5505 parser_->RewriteNonPattern(classifier, ok); |
5394 } | 5506 } |
5395 | 5507 |
5396 Expression* ParserTraits::RewriteAwaitExpression(Expression* value, int pos) { | 5508 Expression* ParserTraits::RewriteAwaitExpression(Expression* value, int pos) { |
5397 // TODO(caitp): Implement AsyncFunctionAwait() | 5509 // TODO(caitp): Implement AsyncFunctionAwait() |
5398 // per tc39.github.io/ecmascript-asyncawait/#abstract-ops-async-function-await | 5510 // per tc39.github.io/ecmascript-asyncawait/#abstract-ops-async-function-await |
5399 return value; | 5511 Expression* generator_object = parser_->factory()->NewVariableProxy( |
5512 parser_->function_state_->generator_object_variable()); | |
5513 value = BuildIteratorResult(value, false); | |
5514 return parser_->factory()->NewYield(generator_object, value, pos); | |
5400 } | 5515 } |
5401 | 5516 |
5402 Zone* ParserTraits::zone() const { | 5517 Zone* ParserTraits::zone() const { |
5403 return parser_->function_state_->scope()->zone(); | 5518 return parser_->function_state_->scope()->zone(); |
5404 } | 5519 } |
5405 | 5520 |
5406 | 5521 |
5407 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { | 5522 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { |
5408 return parser_->function_state_->non_patterns_to_rewrite(); | 5523 return parser_->function_state_->non_patterns_to_rewrite(); |
5409 } | 5524 } |
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6880 try_block, target); | 6995 try_block, target); |
6881 final_loop = target; | 6996 final_loop = target; |
6882 } | 6997 } |
6883 | 6998 |
6884 return final_loop; | 6999 return final_loop; |
6885 } | 7000 } |
6886 | 7001 |
6887 | 7002 |
6888 } // namespace internal | 7003 } // namespace internal |
6889 } // namespace v8 | 7004 } // namespace v8 |
OLD | NEW |