Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: src/parsing/parser.cc

Issue 1895603002: [esnext] prototype runtime implementation for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@AsyncFunction
Patch Set: remove weird arrow-generator thing Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 1103
1104 scope->set_start_position(shared_info->start_position()); 1104 scope->set_start_position(shared_info->start_position());
1105 ExpressionClassifier formals_classifier(this); 1105 ExpressionClassifier formals_classifier(this);
1106 ParserFormalParameters formals(scope); 1106 ParserFormalParameters formals(scope);
1107 Checkpoint checkpoint(this); 1107 Checkpoint checkpoint(this);
1108 { 1108 {
1109 // Parsing patterns as variable reference expression creates 1109 // Parsing patterns as variable reference expression creates
1110 // NewUnresolved references in current scope. Entrer arrow function 1110 // NewUnresolved references in current scope. Entrer arrow function
1111 // scope for formal parameter parsing. 1111 // scope for formal parameter parsing.
1112 BlockState block_state(&scope_, scope); 1112 BlockState block_state(&scope_, scope);
1113 function_state.set_parse_phase(FunctionParsePhase::FormalParameters);
1113 if (Check(Token::LPAREN)) { 1114 if (Check(Token::LPAREN)) {
1114 // '(' StrictFormalParameters ')' 1115 // '(' StrictFormalParameters ')'
1115 ParseFormalParameterList(&formals, &formals_classifier, &ok); 1116 ParseFormalParameterList(&formals, &formals_classifier, &ok);
1116 if (ok) ok = Check(Token::RPAREN); 1117 if (ok) ok = Check(Token::RPAREN);
1117 } else { 1118 } else {
1118 // BindingIdentifier 1119 // BindingIdentifier
1119 ParseFormalParameter(&formals, &formals_classifier, &ok); 1120 ParseFormalParameter(&formals, &formals_classifier, &ok);
1120 if (ok) { 1121 if (ok) {
1121 DeclareFormalParameter(formals.scope, formals.at(0), 1122 DeclareFormalParameter(formals.scope, formals.at(0),
1122 &formals_classifier); 1123 &formals_classifier);
1123 } 1124 }
1124 } 1125 }
1125 } 1126 }
1126 1127
1127 if (ok) { 1128 if (ok) {
1129 function_state.set_parse_phase(FunctionParsePhase::FunctionBody);
1128 checkpoint.Restore(&formals.materialized_literals_count); 1130 checkpoint.Restore(&formals.materialized_literals_count);
1129 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should 1131 // Pass `accept_IN=true` to ParseArrowFunctionLiteral --- This should
1130 // not be observable, or else the preparser would have failed. 1132 // not be observable, or else the preparser would have failed.
1131 Expression* expression = ParseArrowFunctionLiteral( 1133 Expression* expression = ParseArrowFunctionLiteral(
1132 true, formals, is_async, formals_classifier, &ok); 1134 true, formals, is_async, formals_classifier, &ok);
1133 if (ok) { 1135 if (ok) {
1134 // Scanning must end at the same position that was recorded 1136 // Scanning must end at the same position that was recorded
1135 // previously. If not, parsing has been interrupted due to a stack 1137 // previously. If not, parsing has been interrupted due to a stack
1136 // overflow, at which point the partially parsed arrow function 1138 // overflow, at which point the partially parsed arrow function
1137 // concise body happens to be a valid expression. This is a problem 1139 // concise body happens to be a valid expression. This is a problem
(...skipping 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 // ES6 14.6.1 Static Semantics: IsInTailPosition 2715 // ES6 14.6.1 Static Semantics: IsInTailPosition
2714 Scanner::Location loc(pos, pos + 1); 2716 Scanner::Location loc(pos, pos + 1);
2715 function_state_->AddExpressionInTailPosition(return_value, loc); 2717 function_state_->AddExpressionInTailPosition(return_value, loc);
2716 } 2718 }
2717 } 2719 }
2718 } 2720 }
2719 ExpectSemicolon(CHECK_OK); 2721 ExpectSemicolon(CHECK_OK);
2720 2722
2721 if (is_generator()) { 2723 if (is_generator()) {
2722 return_value = BuildIteratorResult(return_value, true); 2724 return_value = BuildIteratorResult(return_value, true);
2725 } else if (is_async_function()) {
2726 return_value = EmitPromiseResolve(return_value, return_value->position());
neis 2016/05/11 09:45:16 Can you call these functions Build* rather than Em
2723 } 2727 }
2724 2728
2725 result = factory()->NewReturnStatement(return_value, loc.beg_pos); 2729 result = factory()->NewReturnStatement(return_value, loc.beg_pos);
2726 2730
2727 Scope* decl_scope = scope_->DeclarationScope(); 2731 Scope* decl_scope = scope_->DeclarationScope();
2728 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) { 2732 if (decl_scope->is_script_scope() || decl_scope->is_eval_scope()) {
2729 ReportMessageAt(loc, MessageTemplate::kIllegalReturn); 2733 ReportMessageAt(loc, MessageTemplate::kIllegalReturn);
2730 *ok = false; 2734 *ok = false;
2731 return NULL; 2735 return NULL;
2732 } 2736 }
(...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 expr = assignment->target(); 3957 expr = assignment->target();
3954 3958
3955 // TODO(adamk): Only call this if necessary. 3959 // TODO(adamk): Only call this if necessary.
3956 RewriteParameterInitializerScope(parser_->stack_limit(), initializer, 3960 RewriteParameterInitializerScope(parser_->stack_limit(), initializer,
3957 parser_->scope_, parameters->scope); 3961 parser_->scope_, parameters->scope);
3958 } 3962 }
3959 3963
3960 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); 3964 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest);
3961 } 3965 }
3962 3966
3967 void ParserTraits::ParseAsyncArrowSingleExpressionBody(
3968 ZoneList<Statement*>* body, bool accept_IN,
3969 Type::ExpressionClassifier* classifier, int pos, bool* ok) {
3970 parser_->DesugarAsyncFunctionBody(
3971 parser_->ast_value_factory()->empty_string(), parser_->scope_, body,
3972 classifier, kAsyncArrowFunction, FunctionBody::ArrowConcise, accept_IN,
3973 pos, ok);
3974 }
3975
3976 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name,
3977 Scope* scope, ZoneList<Statement*>* body,
3978 ExpressionClassifier* classifier,
3979 FunctionKind kind, FunctionBody body_type,
3980 bool accept_IN, int pos, bool* ok) {
neis 2016/05/11 09:45:16 Please add a comment here on what the desugaring i
caitp (gmail) 2016/05/11 13:42:23 Done.
3981 scope->ForceContextAllocation();
3982 // Calling a generator returns a generator object. That object is
3983 // stored
neis 2016/05/11 09:45:16 format (but not sure it's worth to duplicate this
caitp (gmail) 2016/05/11 13:42:23 Removed it
3984 // in a temporary variable, a definition that is used by "yield"
3985 // expressions. This also marks the FunctionState as a generator.
3986 Variable* temp =
3987 scope_->NewTemporary(ast_value_factory()->dot_generator_object_string());
3988 function_state_->set_generator_object_variable(temp);
3989
3990 // Create generator, but do not yield.
3991 Expression* allocation = EmitCreateJSGeneratorObject(pos);
3992 Expression* assign_yield =
neis 2016/05/11 09:45:16 assign_yield is a very misleading name.
caitp (gmail) 2016/05/11 13:42:23 Renamed to `init_generator_variable`
3993 factory()->NewAssignment(Token::INIT, factory()->NewVariableProxy(temp),
3994 allocation, RelocInfo::kNoPosition);
3995
3996 body->Add(
3997 factory()->NewExpressionStatement(assign_yield, RelocInfo::kNoPosition),
3998 zone());
3999
neis 2016/05/11 09:45:16 I would rewrite this as follows: // Create genera
4000 Block* try_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition);
4001
4002 ZoneList<Statement*>* inner_body = try_block->statements();
4003
4004 Expression* return_value = nullptr;
4005 if (body_type == FunctionBody::Normal) {
4006 ParseStatementList(inner_body, Token::RBRACE, ok);
4007 if (!*ok) return;
4008 return_value = factory()->NewUndefinedLiteral(RelocInfo::kNoPosition);
4009 } else {
4010 return_value = ParseAssignmentExpression(accept_IN, classifier, ok);
4011 if (!*ok) return;
4012 ParserTraits::RewriteNonPattern(classifier, ok);
4013 if (!*ok) return;
4014 }
4015
4016 return_value = EmitPromiseResolve(return_value, return_value->position());
4017 inner_body->Add(
4018 factory()->NewReturnStatement(return_value, return_value->position()),
4019 zone());
4020
4021 Block* catch_block = BuildRejectPromiseOnException(try_block);
neis 2016/05/11 09:45:17 Calling this catch_block is confusing, as it's the
4022
4023 body->Add(catch_block, zone());
4024
4025 scope->set_end_position(scanner()->location().end_pos);
4026 }
3963 4027
3964 DoExpression* Parser::ParseDoExpression(bool* ok) { 4028 DoExpression* Parser::ParseDoExpression(bool* ok) {
3965 // AssignmentExpression :: 4029 // AssignmentExpression ::
3966 // do '{' StatementList '}' 4030 // do '{' StatementList '}'
3967 int pos = peek_position(); 4031 int pos = peek_position();
3968 4032
3969 Expect(Token::DO, CHECK_OK); 4033 Expect(Token::DO, CHECK_OK);
3970 Variable* result = 4034 Variable* result =
3971 scope_->NewTemporary(ast_value_factory()->dot_result_string()); 4035 scope_->NewTemporary(ast_value_factory()->dot_result_string());
3972 Block* block = ParseBlock(nullptr, false, CHECK_OK); 4036 Block* block = ParseBlock(nullptr, false, CHECK_OK);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4089 // expressions. This also marks the FunctionState as a generator. 4153 // expressions. This also marks the FunctionState as a generator.
4090 Variable* temp = scope_->NewTemporary( 4154 Variable* temp = scope_->NewTemporary(
4091 ast_value_factory()->dot_generator_object_string()); 4155 ast_value_factory()->dot_generator_object_string());
4092 function_state.set_generator_object_variable(temp); 4156 function_state.set_generator_object_variable(temp);
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);
4163 function_state.set_parse_phase(FunctionParsePhase::FormalParameters);
4099 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK); 4164 ParseFormalParameterList(&formals, &formals_classifier, CHECK_OK);
4100 arity = formals.Arity(); 4165 arity = formals.Arity();
4101 Expect(Token::RPAREN, CHECK_OK); 4166 Expect(Token::RPAREN, CHECK_OK);
4102 int formals_end_position = scanner()->location().end_pos; 4167 int formals_end_position = scanner()->location().end_pos;
4103 4168
4104 CheckArityRestrictions(arity, kind, formals.has_rest, start_position, 4169 CheckArityRestrictions(arity, kind, formals.has_rest, start_position,
4105 formals_end_position, CHECK_OK); 4170 formals_end_position, CHECK_OK);
4106 Expect(Token::LBRACE, CHECK_OK); 4171 Expect(Token::LBRACE, CHECK_OK);
4107 4172 function_state.set_parse_phase(FunctionParsePhase::FunctionBody);
4108 // Don't include the rest parameter into the function's formal parameter 4173 // Don't include the rest parameter into the function's formal parameter
4109 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count, 4174 // count (esp. the SharedFunctionInfo::internal_formal_parameter_count,
4110 // which says whether we need to create an arguments adaptor frame). 4175 // which says whether we need to create an arguments adaptor frame).
4111 if (formals.has_rest) arity--; 4176 if (formals.has_rest) arity--;
4112 4177
4113 // Determine if the function can be parsed lazily. Lazy parsing is different 4178 // Determine if the function can be parsed lazily. Lazy parsing is different
4114 // from lazy compilation; we need to parse more eagerly than we compile. 4179 // from lazy compilation; we need to parse more eagerly than we compile.
4115 4180
4116 // We can only parse lazily if we also compile lazily. The heuristics for 4181 // We can only parse lazily if we also compile lazily. The heuristics for
4117 // lazy compilation are: 4182 // lazy compilation are:
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
4501 param_scope = param_scope->FinalizeBlockScope(); 4566 param_scope = param_scope->FinalizeBlockScope();
4502 if (param_scope != nullptr) { 4567 if (param_scope != nullptr) {
4503 CheckConflictingVarDeclarations(param_scope, CHECK_OK); 4568 CheckConflictingVarDeclarations(param_scope, CHECK_OK);
4504 } 4569 }
4505 init_block->statements()->Add(param_block, zone()); 4570 init_block->statements()->Add(param_block, zone());
4506 } 4571 }
4507 } 4572 }
4508 return init_block; 4573 return init_block;
4509 } 4574 }
4510 4575
4576 Block* Parser::BuildRejectPromiseOnException(Block* block) {
4577 // try { <block> } catch (error) { return Promise.reject(error); }
4578 Block* try_block = block;
4579 Scope* catch_scope = NewScope(scope_, CATCH_SCOPE);
4580 catch_scope->set_is_hidden();
4581 Variable* catch_variable =
4582 catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
4583 kCreatedInitialized, Variable::NORMAL);
4584 Block* catch_block =
4585 factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition);
4586
4587 Expression* promise_reject = EmitPromiseReject(
4588 factory()->NewVariableProxy(catch_variable), RelocInfo::kNoPosition);
4589
4590 ReturnStatement* return_promise_reject =
4591 factory()->NewReturnStatement(promise_reject, RelocInfo::kNoPosition);
4592 catch_block->statements()->Add(return_promise_reject, zone());
4593 TryStatement* try_catch_statement =
4594 factory()->NewTryCatchStatement(try_block, catch_scope, catch_variable,
4595 catch_block, RelocInfo::kNoPosition);
4596
4597 block = factory()->NewBlock(nullptr, 1, true, RelocInfo::kNoPosition);
4598 block->statements()->Add(try_catch_statement, zone());
4599 return block;
4600 }
4601
4602 Expression* Parser::EmitCreateJSGeneratorObject(int pos) {
4603 DCHECK_NOT_NULL(function_state_->generator_object_variable());
4604 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone());
4605 args->Add(factory()->NewThisFunction(pos), zone());
4606 args->Add(ThisExpression(scope_, factory(), RelocInfo::kNoPosition), zone());
4607 return factory()->NewCallRuntime(Runtime::kCreateJSGeneratorObject, args,
4608 pos);
4609 }
4610
4611 Expression* Parser::EmitPromiseResolve(Expression* value, int pos) {
4612 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
4613 args->Add(value, zone());
4614 return factory()->NewCallRuntime(Context::PROMISE_CREATE_RESOLVED_INDEX, args,
4615 pos);
4616 }
4617
4618 Expression* Parser::EmitPromiseReject(Expression* value, int pos) {
4619 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
4620 args->Add(value, zone());
4621 return factory()->NewCallRuntime(Context::PROMISE_CREATE_REJECTED_INDEX, args,
4622 pos);
4623 }
4511 4624
4512 ZoneList<Statement*>* Parser::ParseEagerFunctionBody( 4625 ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
4513 const AstRawString* function_name, int pos, 4626 const AstRawString* function_name, int pos,
4514 const ParserFormalParameters& parameters, FunctionKind kind, 4627 const ParserFormalParameters& parameters, FunctionKind kind,
4515 FunctionLiteral::FunctionType function_type, bool* ok) { 4628 FunctionLiteral::FunctionType function_type, bool* ok) {
4516 // Everything inside an eagerly parsed function will be parsed eagerly 4629 // Everything inside an eagerly parsed function will be parsed eagerly
4517 // (see comment above). 4630 // (see comment above).
4518 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 4631 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
4519 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone()); 4632 ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone());
4520 4633
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4554 // - InitialYield yields the actual generator object. 4667 // - InitialYield yields the actual generator object.
4555 // - Any return statement inside the body will have its argument wrapped 4668 // - Any return statement inside the body will have its argument wrapped
4556 // in a "done" iterator result object. 4669 // in a "done" iterator result object.
4557 // - If the generator terminates for whatever reason, we must close it. 4670 // - If the generator terminates for whatever reason, we must close it.
4558 // Hence the finally clause. 4671 // Hence the finally clause.
4559 4672
4560 Block* try_block = 4673 Block* try_block =
4561 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition); 4674 factory()->NewBlock(nullptr, 3, false, RelocInfo::kNoPosition);
4562 4675
4563 { 4676 {
4564 ZoneList<Expression*>* arguments = 4677 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( 4678 VariableProxy* init_proxy = factory()->NewVariableProxy(
4573 function_state_->generator_object_variable()); 4679 function_state_->generator_object_variable());
4574 Assignment* assignment = factory()->NewAssignment( 4680 Assignment* assignment = factory()->NewAssignment(
4575 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition); 4681 Token::INIT, init_proxy, allocation, RelocInfo::kNoPosition);
4576 VariableProxy* get_proxy = factory()->NewVariableProxy( 4682 VariableProxy* get_proxy = factory()->NewVariableProxy(
4577 function_state_->generator_object_variable()); 4683 function_state_->generator_object_variable());
4578 Yield* yield = 4684 Yield* yield =
4579 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition); 4685 factory()->NewYield(get_proxy, assignment, RelocInfo::kNoPosition);
4580 try_block->statements()->Add( 4686 try_block->statements()->Add(
4581 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition), 4687 factory()->NewExpressionStatement(yield, RelocInfo::kNoPosition),
(...skipping 15 matching lines...) Expand all
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 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
5422 Expression* right, 5537 Expression* right,
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) {
neis 2016/05/11 09:45:17 Also add a comment here please.
5433 // TODO(caitp): Implement AsyncFunctionAwait() 5548 Variable* generator_object_variable =
5434 // per tc39.github.io/ecmascript-asyncawait/#abstract-ops-async-function-await 5549 parser_->function_state_->generator_object_variable();
5435 return value; 5550
5551 DCHECK_NOT_NULL(generator_object_variable);
5552
5553 Expression* generator_object =
5554 parser_->factory()->NewVariableProxy(generator_object_variable);
5555
5556 ZoneList<Expression*>* async_function_await_args =
5557 new (zone()) ZoneList<Expression*>(2, zone());
5558 async_function_await_args->Add(generator_object, zone());
5559 async_function_await_args->Add(value, zone());
5560 Expression* async_function_await = parser_->factory()->NewCallRuntime(
5561 Context::ASYNC_FUNCTION_AWAIT_INDEX, async_function_await_args,
5562 RelocInfo::kNoPosition);
5563
5564 generator_object =
5565 parser_->factory()->NewVariableProxy(generator_object_variable);
5566 return parser_->factory()->NewYield(generator_object, async_function_await,
5567 pos);
5436 } 5568 }
5437 5569
5438 Zone* ParserTraits::zone() const { 5570 Zone* ParserTraits::zone() const {
5439 return parser_->function_state_->scope()->zone(); 5571 return parser_->function_state_->scope()->zone();
5440 } 5572 }
5441 5573
5442 5574
5443 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const { 5575 ZoneList<Expression*>* ParserTraits::GetNonPatternList() const {
5444 return parser_->function_state_->non_patterns_to_rewrite(); 5576 return parser_->function_state_->non_patterns_to_rewrite();
5445 } 5577 }
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after
6919 try_block, target); 7051 try_block, target);
6920 final_loop = target; 7052 final_loop = target;
6921 } 7053 }
6922 7054
6923 return final_loop; 7055 return final_loop;
6924 } 7056 }
6925 7057
6926 7058
6927 } // namespace internal 7059 } // namespace internal
6928 } // namespace v8 7060 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698