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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2628 // ES6 14.6.1 Static Semantics: IsInTailPosition | 2628 // ES6 14.6.1 Static Semantics: IsInTailPosition |
2629 function_state_->AddImplicitTailCallExpression(return_value); | 2629 function_state_->AddImplicitTailCallExpression(return_value); |
2630 } | 2630 } |
2631 } | 2631 } |
2632 } | 2632 } |
2633 ExpectSemicolon(CHECK_OK); | 2633 ExpectSemicolon(CHECK_OK); |
2634 | 2634 |
2635 if (is_generator()) { | 2635 if (is_generator()) { |
2636 return_value = BuildIteratorResult(return_value, true); | 2636 return_value = BuildIteratorResult(return_value, true); |
2637 } else if (is_async_function()) { | 2637 } else if (is_async_function()) { |
2638 return_value = BuildPromiseResolve(return_value, return_value->position()); | 2638 return_value = BuildResolvePromise(return_value, return_value->position()); |
2639 } | 2639 } |
2640 | 2640 |
2641 result = factory()->NewReturnStatement(return_value, loc.beg_pos); | 2641 result = factory()->NewReturnStatement(return_value, loc.beg_pos); |
2642 | 2642 |
2643 DeclarationScope* decl_scope = GetDeclarationScope(); | 2643 DeclarationScope* decl_scope = GetDeclarationScope(); |
2644 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { | 2644 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { |
2645 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); | 2645 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); |
2646 *ok = false; | 2646 *ok = false; |
2647 return NULL; | 2647 return NULL; |
2648 } | 2648 } |
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3958 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); | 3958 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); |
3959 } | 3959 } |
3960 | 3960 |
3961 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, | 3961 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, |
3962 Scope* scope, ZoneList<Statement*>* body, | 3962 Scope* scope, ZoneList<Statement*>* body, |
3963 ExpressionClassifier* classifier, | 3963 ExpressionClassifier* classifier, |
3964 FunctionKind kind, | 3964 FunctionKind kind, |
3965 FunctionBodyType body_type, | 3965 FunctionBodyType body_type, |
3966 bool accept_IN, int pos, bool* ok) { | 3966 bool accept_IN, int pos, bool* ok) { |
3967 // function async_function() { | 3967 // function async_function() { |
3968 // try { | 3968 // BuildRejectPromiseOnException({ |
3969 // .generator_object = %CreateGeneratorObject(); | 3969 // .generator_object = %CreateGeneratorObject(); |
neis
2016/08/24 09:48:51
The .generator_object assignment is actually outsi
Dan Ehrenberg
2016/08/24 18:03:22
Fixed
| |
3970 // ... function body ... | 3970 // ... function body ... |
3971 // } catch (e) { | 3971 // return %ResolvePromise(.promise, expr), .promise; |
3972 // return Promise.reject(e); | 3972 // }) |
3973 // } | |
3974 // } | 3973 // } |
3975 scope->ForceContextAllocation(); | 3974 scope->ForceContextAllocation(); |
3976 Variable* temp = | 3975 Variable* temp = |
3977 NewTemporary(ast_value_factory()->dot_generator_object_string()); | 3976 NewTemporary(ast_value_factory()->dot_generator_object_string()); |
3978 function_state_->set_generator_object_variable(temp); | 3977 function_state_->set_generator_object_variable(temp); |
3979 | 3978 |
3980 Expression* init_generator_variable = factory()->NewAssignment( | 3979 Expression* init_generator_variable = factory()->NewAssignment( |
3981 Token::INIT, factory()->NewVariableProxy(temp), | 3980 Token::INIT, factory()->NewVariableProxy(temp), |
3982 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); | 3981 BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition); |
3983 body->Add(factory()->NewExpressionStatement(init_generator_variable, | 3982 body->Add(factory()->NewExpressionStatement(init_generator_variable, |
3984 kNoSourcePosition), | 3983 kNoSourcePosition), |
3985 zone()); | 3984 zone()); |
3986 | 3985 |
3987 Block* try_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); | 3986 Block* try_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition); |
neis
2016/08/24 09:48:51
This shouldn't be called try_block anymore.
| |
3988 | 3987 |
3989 ZoneList<Statement*>* inner_body = try_block->statements(); | 3988 ZoneList<Statement*>* inner_body = try_block->statements(); |
neis
2016/08/24 09:48:51
Can you get rid of inner_body and just inline it?
| |
3990 | 3989 |
3991 Expression* return_value = nullptr; | 3990 Expression* return_value = nullptr; |
3992 if (body_type == FunctionBodyType::kNormal) { | 3991 if (body_type == FunctionBodyType::kNormal) { |
3993 ParseStatementList(inner_body, Token::RBRACE, CHECK_OK_VOID); | 3992 ParseStatementList(inner_body, Token::RBRACE, CHECK_OK_VOID); |
3994 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); | 3993 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); |
3995 } else { | 3994 } else { |
3996 return_value = | 3995 return_value = |
3997 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID); | 3996 ParseAssignmentExpression(accept_IN, classifier, CHECK_OK_VOID); |
3998 RewriteNonPattern(classifier, CHECK_OK_VOID); | 3997 RewriteNonPattern(classifier, CHECK_OK_VOID); |
3999 } | 3998 } |
4000 | 3999 |
4001 return_value = BuildPromiseResolve(return_value, return_value->position()); | 4000 return_value = BuildResolvePromise(return_value, return_value->position()); |
4002 inner_body->Add( | 4001 inner_body->Add( |
4003 factory()->NewReturnStatement(return_value, return_value->position()), | 4002 factory()->NewReturnStatement(return_value, return_value->position()), |
4004 zone()); | 4003 zone()); |
4005 body->Add(BuildRejectPromiseOnException(try_block), zone()); | 4004 Statement* block = BuildRejectPromiseOnException(try_block, CHECK_OK_VOID); |
4005 body->Add(block, zone()); | |
4006 scope->set_end_position(scanner()->location().end_pos); | 4006 scope->set_end_position(scanner()->location().end_pos); |
4007 } | 4007 } |
4008 | 4008 |
4009 DoExpression* Parser::ParseDoExpression(bool* ok) { | 4009 DoExpression* Parser::ParseDoExpression(bool* ok) { |
4010 // AssignmentExpression :: | 4010 // AssignmentExpression :: |
4011 // do '{' StatementList '}' | 4011 // do '{' StatementList '}' |
4012 int pos = peek_position(); | 4012 int pos = peek_position(); |
4013 | 4013 |
4014 Expect(Token::DO, CHECK_OK); | 4014 Expect(Token::DO, CHECK_OK); |
4015 Variable* result = NewTemporary(ast_value_factory()->dot_result_string()); | 4015 Variable* result = NewTemporary(ast_value_factory()->dot_result_string()); |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4555 param_scope = block_state.FinalizedBlockScope(); | 4555 param_scope = block_state.FinalizedBlockScope(); |
4556 if (param_scope != nullptr) { | 4556 if (param_scope != nullptr) { |
4557 CheckConflictingVarDeclarations(param_scope, CHECK_OK); | 4557 CheckConflictingVarDeclarations(param_scope, CHECK_OK); |
4558 } | 4558 } |
4559 init_block->statements()->Add(param_block, zone()); | 4559 init_block->statements()->Add(param_block, zone()); |
4560 } | 4560 } |
4561 } | 4561 } |
4562 return init_block; | 4562 return init_block; |
4563 } | 4563 } |
4564 | 4564 |
4565 Block* Parser::BuildRejectPromiseOnException(Block* block) { | 4565 Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) { |
neis
2016/08/24 09:48:51
s/inner_block/block/ to match the comment.
Dan Ehrenberg
2016/08/24 18:03:22
Changed the name in the other direction
| |
4566 // try { <block> } catch (error) { return Promise.reject(error); } | 4566 // var .promise = %CreatePromise(); |
4567 Block* try_block = block; | 4567 // var .debug_is_active = %_DebugIsActive() !== 0; |
neis
2016/08/24 09:48:51
I think we don't need the !== 0 comparison. (But
Dan Ehrenberg
2016/08/24 18:03:22
Right, I was considering this but left it out as t
| |
4568 // try { | |
4569 // if (.debug_is_active) %DebugPushPromise(.promise); | |
neis
2016/08/24 09:48:51
Can't we move this out of the try-block? Seems cl
Dan Ehrenberg
2016/08/24 18:03:22
Done.
| |
4570 // <block> | |
4571 // } catch (.catch) { | |
4572 // %RejectPromise(.promise, .catch); | |
4573 // return .promise; | |
4574 // } finally { | |
4575 // if (.debug_is_active) %DebugPopPromise(); | |
4576 // } | |
4577 Block* block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | |
jgruber
2016/08/24 09:16:36
We could set the initial size to 3 to avoid having
neis
2016/08/24 09:48:51
s/block/result/ for clarity (and to avoid conflict
Dan Ehrenberg
2016/08/24 18:03:22
Done, and fixed the initial size to 4.
| |
4578 | |
4579 // var .promise = %CreatePromise(); | |
4580 Statement* set_promise; | |
4581 { | |
4582 DeclareVariable(ast_value_factory()->dot_promise_string(), VAR, | |
jgruber
2016/08/24 09:16:36
Since I'm not familiar with the parser, a question
Dan Ehrenberg
2016/08/24 18:03:22
I could do that, but then I'd have to store the te
| |
4583 kNoSourcePosition, CHECK_OK); | |
4584 Expression* create_promise = factory()->NewCallRuntime( | |
4585 Context::PROMISE_CREATE_INDEX, | |
4586 new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); | |
4587 Assignment* assign_promise = factory()->NewAssignment( | |
4588 Token::INIT, BuildDotPromise(), create_promise, kNoSourcePosition); | |
4589 set_promise = | |
4590 factory()->NewExpressionStatement(assign_promise, kNoSourcePosition); | |
4591 } | |
4592 block->statements()->Add(set_promise, zone()); | |
4593 | |
4594 // var .debug_is_active = %_DebugIsActive() != 0; | |
jgruber
2016/08/24 09:16:36
Nit: This differs from !== above.
Dan Ehrenberg
2016/08/24 18:03:22
Removed the comparison, as it is unnecessary.
| |
4595 Statement* set_debug_is_active; | |
4596 { | |
4597 DeclareVariable(ast_value_factory()->dot_debug_is_active_string(), VAR, | |
4598 kNoSourcePosition, CHECK_OK); | |
4599 Expression* debug_is_active_num = factory()->NewCallRuntime( | |
4600 Runtime::kInlineDebugIsActive, | |
4601 new (zone()) ZoneList<Expression*>(0, zone()), kNoSourcePosition); | |
4602 Expression* debug_is_active = factory()->NewCompareOperation( | |
4603 Token::EQ_STRICT, debug_is_active_num, | |
4604 factory()->NewSmiLiteral(0, kNoSourcePosition), kNoSourcePosition); | |
4605 debug_is_active = factory()->NewUnaryOperation(Token::NOT, debug_is_active, | |
4606 kNoSourcePosition); | |
4607 Assignment* assign_debug_is_active = factory()->NewAssignment( | |
4608 Token::INIT, BuildDebugIsActive(), debug_is_active, kNoSourcePosition); | |
4609 set_debug_is_active = factory()->NewExpressionStatement( | |
4610 assign_debug_is_active, kNoSourcePosition); | |
4611 } | |
4612 block->statements()->Add(set_debug_is_active, zone()); | |
4613 | |
4614 Block* try_block = factory()->NewBlock(nullptr, 2, true, kNoSourcePosition); | |
4615 // if (.debug_is_active) %DebugPushPromise(.promise); | |
4616 Statement* conditionally_debug_push_promise; | |
4617 { | |
4618 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); | |
4619 args->Add(BuildDotPromise(), zone()); | |
4620 Expression* call_push_promise = factory()->NewCallRuntime( | |
4621 Runtime::kDebugPushPromise, args, kNoSourcePosition); | |
4622 Statement* debug_push_promise = | |
4623 factory()->NewExpressionStatement(call_push_promise, kNoSourcePosition); | |
4624 conditionally_debug_push_promise = factory()->NewIfStatement( | |
4625 BuildDebugIsActive(), debug_push_promise, | |
4626 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); | |
4627 } | |
4628 try_block->statements()->Add(conditionally_debug_push_promise, zone()); | |
4629 try_block->statements()->Add(inner_block, zone()); | |
4630 | |
4631 // catch (.catch) { return %RejectPromise(.promise, .catch), .promise } | |
4568 Scope* catch_scope = NewScope(CATCH_SCOPE); | 4632 Scope* catch_scope = NewScope(CATCH_SCOPE); |
4569 catch_scope->set_is_hidden(); | 4633 catch_scope->set_is_hidden(); |
4570 Variable* catch_variable = | 4634 Variable* catch_variable = |
4571 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, | 4635 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
4572 kCreatedInitialized, Variable::NORMAL); | 4636 kCreatedInitialized, Variable::NORMAL); |
4573 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 4637 Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); |
4574 | 4638 |
4575 Expression* promise_reject = BuildPromiseReject( | 4639 Expression* promise_reject = BuildRejectPromise( |
4576 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); | 4640 factory()->NewVariableProxy(catch_variable), kNoSourcePosition); |
4577 | |
4578 ReturnStatement* return_promise_reject = | 4641 ReturnStatement* return_promise_reject = |
4579 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); | 4642 factory()->NewReturnStatement(promise_reject, kNoSourcePosition); |
4580 catch_block->statements()->Add(return_promise_reject, zone()); | 4643 catch_block->statements()->Add(return_promise_reject, zone()); |
4644 | |
4581 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( | 4645 TryStatement* try_catch_statement = factory()->NewTryCatchStatement( |
4582 try_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); | 4646 try_block, catch_scope, catch_variable, catch_block, kNoSourcePosition); |
4583 | 4647 |
4584 block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | 4648 // There is no TryCatchFinally node, so wrap it in an outer try/finally |
4585 block->statements()->Add(try_catch_statement, zone()); | 4649 Block* outer_try_block = |
4650 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | |
4651 outer_try_block->statements()->Add(try_catch_statement, zone()); | |
4652 | |
4653 // finally { if (.debug_is_active) %DebugPopPromise(); } | |
4654 Block* finally_block = | |
4655 factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); | |
4656 { | |
4657 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(0, zone()); | |
4658 Expression* call_pop_promise = factory()->NewCallRuntime( | |
4659 Runtime::kDebugPopPromise, args, kNoSourcePosition); | |
4660 Statement* debug_pop_promise = | |
4661 factory()->NewExpressionStatement(call_pop_promise, kNoSourcePosition); | |
4662 Statement* conditionally_debug_pop_promise = factory()->NewIfStatement( | |
4663 BuildDebugIsActive(), debug_pop_promise, | |
4664 factory()->NewEmptyStatement(kNoSourcePosition), kNoSourcePosition); | |
4665 finally_block->statements()->Add(conditionally_debug_pop_promise, zone()); | |
4666 } | |
4667 | |
4668 Statement* try_finally_statement = factory()->NewTryFinallyStatement( | |
4669 outer_try_block, finally_block, kNoSourcePosition); | |
4670 | |
4671 block->statements()->Add(try_finally_statement, zone()); | |
4586 return block; | 4672 return block; |
4587 } | 4673 } |
4588 | 4674 |
4589 Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) { | 4675 Expression* Parser::BuildCreateJSGeneratorObject(int pos, FunctionKind kind) { |
4590 DCHECK_NOT_NULL(function_state_->generator_object_variable()); | 4676 DCHECK_NOT_NULL(function_state_->generator_object_variable()); |
4591 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); | 4677 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); |
4592 args->Add(factory()->NewThisFunction(pos), zone()); | 4678 args->Add(factory()->NewThisFunction(pos), zone()); |
4593 args->Add(IsArrowFunction(kind) ? GetLiteralUndefined(pos) | 4679 args->Add(IsArrowFunction(kind) ? GetLiteralUndefined(pos) |
4594 : ThisExpression(kNoSourcePosition), | 4680 : ThisExpression(kNoSourcePosition), |
4595 zone()); | 4681 zone()); |
4596 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, | 4682 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args, |
4597 pos); | 4683 pos); |
4598 } | 4684 } |
4599 | 4685 |
4600 Expression* Parser::BuildPromiseResolve(Expression* value, int pos) { | 4686 Expression* Parser::BuildResolvePromise(Expression* value, int pos) { |
4601 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); | 4687 // %ResolvePromise(.promise, value), .promise |
4688 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); | |
4689 args->Add(BuildDotPromise(), zone()); | |
4602 args->Add(value, zone()); | 4690 args->Add(value, zone()); |
4603 return factory()->NewCallRuntime(Context::PROMISE_CREATE_RESOLVED_INDEX, args, | 4691 Expression* call_runtime = |
4604 pos); | 4692 factory()->NewCallRuntime(Context::PROMISE_RESOLVE_INDEX, args, pos); |
4693 return factory()->NewBinaryOperation(Token::COMMA, call_runtime, | |
4694 BuildDotPromise(), pos); | |
4605 } | 4695 } |
4606 | 4696 |
4607 Expression* Parser::BuildPromiseReject(Expression* value, int pos) { | 4697 Expression* Parser::BuildRejectPromise(Expression* value, int pos) { |
4608 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); | 4698 // %RejectPromise(.promise, value, true), .promise |
4699 // The 'true' flag disables the additional debug event for the rejection | |
4700 // since a debug event already happened for the exception that got us here. | |
neis
2016/08/24 09:48:51
I think you mean 'false' here, not 'true', but sin
Dan Ehrenberg
2016/08/24 18:03:22
I made it a separate function because RejectPromis
| |
4701 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(3, zone()); | |
jgruber
2016/08/24 09:16:36
Should this be 2? There's only two args added.
Dan Ehrenberg
2016/08/24 18:03:22
Fixed
| |
4702 args->Add(BuildDotPromise(), zone()); | |
4609 args->Add(value, zone()); | 4703 args->Add(value, zone()); |
4610 return factory()->NewCallRuntime(Context::PROMISE_CREATE_REJECTED_INDEX, args, | 4704 Expression* call_runtime = factory()->NewCallRuntime( |
4611 pos); | 4705 Context::PROMISE_REJECT_NO_DEBUG_EVENT_INDEX, args, pos); |
4706 return factory()->NewBinaryOperation(Token::COMMA, call_runtime, | |
4707 BuildDotPromise(), pos); | |
4708 } | |
4709 | |
4710 VariableProxy* Parser::BuildDotPromise() { | |
4711 return NewUnresolved(ast_value_factory()->dot_promise_string(), VAR); | |
4712 } | |
4713 | |
4714 VariableProxy* Parser::BuildDebugIsActive() { | |
jgruber
2016/08/24 09:16:36
This should be BuildDotDebugIsActive for consisten
Dan Ehrenberg
2016/08/24 18:03:22
Done
| |
4715 return NewUnresolved(ast_value_factory()->dot_debug_is_active_string(), VAR); | |
4612 } | 4716 } |
4613 | 4717 |
4614 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( | 4718 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( |
4615 const AstRawString* function_name, int pos, | 4719 const AstRawString* function_name, int pos, |
4616 const ParserFormalParameters& parameters, FunctionKind kind, | 4720 const ParserFormalParameters& parameters, FunctionKind kind, |
4617 FunctionLiteral::FunctionType function_type, bool* ok) { | 4721 FunctionLiteral::FunctionType function_type, bool* ok) { |
4618 // Everything inside an eagerly parsed function will be parsed eagerly | 4722 // Everything inside an eagerly parsed function will be parsed eagerly |
4619 // (see comment above). | 4723 // (see comment above). |
4620 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 4724 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
4621 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); | 4725 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4727 DCHECK_EQ(function_scope, inner_scope->outer_scope()); | 4831 DCHECK_EQ(function_scope, inner_scope->outer_scope()); |
4728 DCHECK_EQ(body, inner_block->statements()); | 4832 DCHECK_EQ(body, inner_block->statements()); |
4729 SetLanguageMode(function_scope, inner_scope->language_mode()); | 4833 SetLanguageMode(function_scope, inner_scope->language_mode()); |
4730 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); | 4834 Block* init_block = BuildParameterInitializationBlock(parameters, CHECK_OK); |
4731 | 4835 |
4732 if (is_sloppy(inner_scope->language_mode())) { | 4836 if (is_sloppy(inner_scope->language_mode())) { |
4733 InsertSloppyBlockFunctionVarBindings(inner_scope, function_scope, | 4837 InsertSloppyBlockFunctionVarBindings(inner_scope, function_scope, |
4734 CHECK_OK); | 4838 CHECK_OK); |
4735 } | 4839 } |
4736 | 4840 |
4841 // TODO(littledan): Merge the two rejection blocks into one | |
4737 if (IsAsyncFunction(kind)) { | 4842 if (IsAsyncFunction(kind)) { |
4738 init_block = BuildRejectPromiseOnException(init_block); | 4843 init_block = BuildRejectPromiseOnException(init_block, CHECK_OK); |
4739 } | 4844 } |
4740 | 4845 |
4741 DCHECK_NOT_NULL(init_block); | 4846 DCHECK_NOT_NULL(init_block); |
4742 | 4847 |
4743 inner_scope->set_end_position(scanner()->location().end_pos); | 4848 inner_scope->set_end_position(scanner()->location().end_pos); |
4744 if (inner_scope->FinalizeBlockScope() != nullptr) { | 4849 if (inner_scope->FinalizeBlockScope() != nullptr) { |
4745 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); | 4850 CheckConflictingVarDeclarations(inner_scope, CHECK_OK); |
4746 InsertShadowingVarBindingInitializers(inner_block); | 4851 InsertShadowingVarBindingInitializers(inner_block); |
4747 } | 4852 } |
4748 inner_scope = nullptr; | 4853 inner_scope = nullptr; |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6841 node->Print(Isolate::Current()); | 6946 node->Print(Isolate::Current()); |
6842 } | 6947 } |
6843 #endif // DEBUG | 6948 #endif // DEBUG |
6844 | 6949 |
6845 #undef CHECK_OK | 6950 #undef CHECK_OK |
6846 #undef CHECK_OK_VOID | 6951 #undef CHECK_OK_VOID |
6847 #undef CHECK_FAILED | 6952 #undef CHECK_FAILED |
6848 | 6953 |
6849 } // namespace internal | 6954 } // namespace internal |
6850 } // namespace v8 | 6955 } // namespace v8 |
OLD | NEW |