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

Side by Side Diff: src/parsing/parser-base.h

Issue 2452403003: Changed statement ZoneList to a ZoneChunkList
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 ExpressionT value; 2289 ExpressionT value;
2290 if (has_initializer) { 2290 if (has_initializer) {
2291 value = this->ParseAssignmentExpression( 2291 value = this->ParseAssignmentExpression(
2292 true, CHECK_OK_CUSTOM(EmptyFunctionLiteral)); 2292 true, CHECK_OK_CUSTOM(EmptyFunctionLiteral));
2293 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(EmptyFunctionLiteral)); 2293 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(EmptyFunctionLiteral));
2294 } else { 2294 } else {
2295 value = factory()->NewUndefinedLiteral(kNoSourcePosition); 2295 value = factory()->NewUndefinedLiteral(kNoSourcePosition);
2296 } 2296 }
2297 initializer_scope->set_end_position(scanner()->location().end_pos); 2297 initializer_scope->set_end_position(scanner()->location().end_pos);
2298 typename Types::StatementList body = impl()->NewStatementList(1); 2298 typename Types::StatementList body = impl()->NewStatementList(1);
2299 body->Add(factory()->NewReturnStatement(value, kNoSourcePosition), zone()); 2299 body->push_back(factory()->NewReturnStatement(value, kNoSourcePosition));
2300 FunctionLiteralT function_literal = factory()->NewFunctionLiteral( 2300 FunctionLiteralT function_literal = factory()->NewFunctionLiteral(
2301 impl()->EmptyIdentifierString(), initializer_scope, body, 2301 impl()->EmptyIdentifierString(), initializer_scope, body,
2302 initializer_state.materialized_literal_count(), 2302 initializer_state.materialized_literal_count(),
2303 initializer_state.expected_property_count(), 0, 0, 2303 initializer_state.expected_property_count(), 0, 0,
2304 FunctionLiteral::kNoDuplicateParameters, 2304 FunctionLiteral::kNoDuplicateParameters,
2305 FunctionLiteral::kAnonymousExpression, default_eager_compile_hint_, 2305 FunctionLiteral::kAnonymousExpression, default_eager_compile_hint_,
2306 initializer_scope->start_position()); 2306 initializer_scope->start_position());
2307 function_literal->set_is_class_field_initializer(true); 2307 function_literal->set_is_class_field_initializer(true);
2308 return function_literal; 2308 return function_literal;
2309 } 2309 }
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
3544 // declaration syntax. 3544 // declaration syntax.
3545 3545
3546 DCHECK_NOT_NULL(parsing_result); 3546 DCHECK_NOT_NULL(parsing_result);
3547 parsing_result->descriptor.declaration_kind = DeclarationDescriptor::NORMAL; 3547 parsing_result->descriptor.declaration_kind = DeclarationDescriptor::NORMAL;
3548 parsing_result->descriptor.declaration_pos = peek_position(); 3548 parsing_result->descriptor.declaration_pos = peek_position();
3549 parsing_result->descriptor.initialization_pos = peek_position(); 3549 parsing_result->descriptor.initialization_pos = peek_position();
3550 3550
3551 BlockT init_block = impl()->NullBlock(); 3551 BlockT init_block = impl()->NullBlock();
3552 if (var_context != kForStatement) { 3552 if (var_context != kForStatement) {
3553 init_block = factory()->NewBlock( 3553 init_block = factory()->NewBlock(
3554 nullptr, 1, true, parsing_result->descriptor.declaration_pos); 3554 nullptr, true, parsing_result->descriptor.declaration_pos);
3555 } 3555 }
3556 3556
3557 switch (peek()) { 3557 switch (peek()) {
3558 case Token::VAR: 3558 case Token::VAR:
3559 parsing_result->descriptor.mode = VAR; 3559 parsing_result->descriptor.mode = VAR;
3560 Consume(Token::VAR); 3560 Consume(Token::VAR);
3561 break; 3561 break;
3562 case Token::CONST: 3562 case Token::CONST:
3563 Consume(Token::CONST); 3563 Consume(Token::CONST);
3564 DCHECK(var_context != kStatement); 3564 DCHECK(var_context != kStatement);
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
4001 formal_parameters, body, kind == kAsyncArrowFunction, CHECK_OK); 4001 formal_parameters, body, kind == kAsyncArrowFunction, CHECK_OK);
4002 ExpressionClassifier classifier(this); 4002 ExpressionClassifier classifier(this);
4003 if (kind == kAsyncArrowFunction) { 4003 if (kind == kAsyncArrowFunction) {
4004 ParseAsyncFunctionBody(scope(), body, kAsyncArrowFunction, 4004 ParseAsyncFunctionBody(scope(), body, kAsyncArrowFunction,
4005 FunctionBodyType::kSingleExpression, accept_IN, 4005 FunctionBodyType::kSingleExpression, accept_IN,
4006 pos, CHECK_OK); 4006 pos, CHECK_OK);
4007 impl()->RewriteNonPattern(CHECK_OK); 4007 impl()->RewriteNonPattern(CHECK_OK);
4008 } else { 4008 } else {
4009 ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK); 4009 ExpressionT expression = ParseAssignmentExpression(accept_IN, CHECK_OK);
4010 impl()->RewriteNonPattern(CHECK_OK); 4010 impl()->RewriteNonPattern(CHECK_OK);
4011 body->Add(factory()->NewReturnStatement(expression, pos), zone()); 4011 body->push_back(factory()->NewReturnStatement(expression, pos));
4012 if (allow_tailcalls() && !is_sloppy(language_mode())) { 4012 if (allow_tailcalls() && !is_sloppy(language_mode())) {
4013 // ES6 14.6.1 Static Semantics: IsInTailPosition 4013 // ES6 14.6.1 Static Semantics: IsInTailPosition
4014 impl()->MarkTailPosition(expression); 4014 impl()->MarkTailPosition(expression);
4015 } 4015 }
4016 } 4016 }
4017 materialized_literal_count = function_state.materialized_literal_count(); 4017 materialized_literal_count = function_state.materialized_literal_count();
4018 expected_property_count = function_state.expected_property_count(); 4018 expected_property_count = function_state.expected_property_count();
4019 impl()->MarkCollectedTailCallExpressions(); 4019 impl()->MarkCollectedTailCallExpressions();
4020 } 4020 }
4021 4021
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
4121 template <typename Impl> 4121 template <typename Impl>
4122 void ParserBase<Impl>::ParseAsyncFunctionBody(Scope* scope, StatementListT body, 4122 void ParserBase<Impl>::ParseAsyncFunctionBody(Scope* scope, StatementListT body,
4123 FunctionKind kind, 4123 FunctionKind kind,
4124 FunctionBodyType body_type, 4124 FunctionBodyType body_type,
4125 bool accept_IN, int pos, 4125 bool accept_IN, int pos,
4126 bool* ok) { 4126 bool* ok) {
4127 scope->ForceContextAllocation(); 4127 scope->ForceContextAllocation();
4128 4128
4129 impl()->PrepareAsyncFunctionBody(body, kind, pos); 4129 impl()->PrepareAsyncFunctionBody(body, kind, pos);
4130 4130
4131 BlockT block = factory()->NewBlock(nullptr, 8, true, kNoSourcePosition); 4131 BlockT block = factory()->NewBlock(nullptr, true, kNoSourcePosition);
4132 4132
4133 ExpressionT return_value = impl()->EmptyExpression(); 4133 ExpressionT return_value = impl()->EmptyExpression();
4134 if (body_type == FunctionBodyType::kNormal) { 4134 if (body_type == FunctionBodyType::kNormal) {
4135 ParseStatementList(block->statements(), Token::RBRACE, 4135 ParseStatementList(block->statements(), Token::RBRACE,
4136 CHECK_OK_CUSTOM(Void)); 4136 CHECK_OK_CUSTOM(Void));
4137 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition); 4137 return_value = factory()->NewUndefinedLiteral(kNoSourcePosition);
4138 } else { 4138 } else {
4139 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void)); 4139 return_value = ParseAssignmentExpression(accept_IN, CHECK_OK_CUSTOM(Void));
4140 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(Void)); 4140 impl()->RewriteNonPattern(CHECK_OK_CUSTOM(Void));
4141 } 4141 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
4432 // - over kLazyParseTrialLimit statements 4432 // - over kLazyParseTrialLimit statements
4433 // - all starting with an identifier (i.e., no if, for, while, etc.) 4433 // - all starting with an identifier (i.e., no if, for, while, etc.)
4434 if (may_abort) { 4434 if (may_abort) {
4435 if (!starts_with_identifier) { 4435 if (!starts_with_identifier) {
4436 may_abort = false; 4436 may_abort = false;
4437 } else if (++count_statements > kLazyParseTrialLimit) { 4437 } else if (++count_statements > kLazyParseTrialLimit) {
4438 return kLazyParsingAborted; 4438 return kLazyParsingAborted;
4439 } 4439 }
4440 } 4440 }
4441 4441
4442 body->Add(stat, zone()); 4442 body->push_back(stat);
4443 } 4443 }
4444 return kLazyParsingComplete; 4444 return kLazyParsingComplete;
4445 } 4445 }
4446 4446
4447 template <typename Impl> 4447 template <typename Impl>
4448 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatementListItem( 4448 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStatementListItem(
4449 bool* ok) { 4449 bool* ok) {
4450 // ECMA 262 6th Edition 4450 // ECMA 262 6th Edition
4451 // StatementListItem[Yield, Return] : 4451 // StatementListItem[Yield, Return] :
4452 // Statement[?Yield, ?Return] 4452 // Statement[?Yield, ?Return]
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
4537 case Token::RETURN: 4537 case Token::RETURN:
4538 case Token::THROW: 4538 case Token::THROW:
4539 case Token::TRY: { 4539 case Token::TRY: {
4540 // These statements must have their labels preserved in an enclosing 4540 // These statements must have their labels preserved in an enclosing
4541 // block, as the corresponding AST nodes do not currently store their 4541 // block, as the corresponding AST nodes do not currently store their
4542 // labels. 4542 // labels.
4543 // TODO(nikolaos, marja): Consider adding the labels to the AST nodes. 4543 // TODO(nikolaos, marja): Consider adding the labels to the AST nodes.
4544 if (labels == nullptr) { 4544 if (labels == nullptr) {
4545 return ParseStatementAsUnlabelled(labels, ok); 4545 return ParseStatementAsUnlabelled(labels, ok);
4546 } else { 4546 } else {
4547 BlockT result = 4547 BlockT result = factory()->NewBlock(labels, false, kNoSourcePosition);
4548 factory()->NewBlock(labels, 1, false, kNoSourcePosition);
4549 typename Types::Target target(this, result); 4548 typename Types::Target target(this, result);
4550 StatementT statement = ParseStatementAsUnlabelled(labels, CHECK_OK); 4549 StatementT statement = ParseStatementAsUnlabelled(labels, CHECK_OK);
4551 result->statements()->Add(statement, zone()); 4550 result->statements()->push_back(statement);
4552 return result; 4551 return result;
4553 } 4552 }
4554 } 4553 }
4555 case Token::WITH: 4554 case Token::WITH:
4556 return ParseWithStatement(labels, ok); 4555 return ParseWithStatement(labels, ok);
4557 case Token::SWITCH: 4556 case Token::SWITCH:
4558 return ParseSwitchStatement(labels, ok); 4557 return ParseSwitchStatement(labels, ok);
4559 case Token::FUNCTION: 4558 case Token::FUNCTION:
4560 // FunctionDeclaration only allowed as a StatementListItem, not in 4559 // FunctionDeclaration only allowed as a StatementListItem, not in
4561 // an arbitrary Statement position. Exceptions such as 4560 // an arbitrary Statement position. Exceptions such as
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4601 } 4600 }
4602 } 4601 }
4603 4602
4604 template <typename Impl> 4603 template <typename Impl>
4605 typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock( 4604 typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock(
4606 ZoneList<const AstRawString*>* labels, bool* ok) { 4605 ZoneList<const AstRawString*>* labels, bool* ok) {
4607 // Block :: 4606 // Block ::
4608 // '{' StatementList '}' 4607 // '{' StatementList '}'
4609 4608
4610 // Construct block expecting 16 statements. 4609 // Construct block expecting 16 statements.
4611 BlockT body = factory()->NewBlock(labels, 16, false, kNoSourcePosition); 4610 BlockT body = factory()->NewBlock(labels, false, kNoSourcePosition);
4612 4611
4613 // Parse the statements and collect escaping labels. 4612 // Parse the statements and collect escaping labels.
4614 Expect(Token::LBRACE, CHECK_OK_CUSTOM(NullBlock)); 4613 Expect(Token::LBRACE, CHECK_OK_CUSTOM(NullBlock));
4615 { 4614 {
4616 BlockState block_state(zone(), &scope_state_); 4615 BlockState block_state(zone(), &scope_state_);
4617 block_state.set_start_position(scanner()->location().beg_pos); 4616 block_state.set_start_position(scanner()->location().beg_pos);
4618 typename Types::Target target(this, body); 4617 typename Types::Target target(this, body);
4619 4618
4620 while (peek() != Token::RBRACE) { 4619 while (peek() != Token::RBRACE) {
4621 StatementT stat = ParseStatementListItem(CHECK_OK_CUSTOM(NullBlock)); 4620 StatementT stat = ParseStatementListItem(CHECK_OK_CUSTOM(NullBlock));
4622 if (!impl()->IsNullStatement(stat) && !impl()->IsEmptyStatement(stat)) { 4621 if (!impl()->IsNullStatement(stat) && !impl()->IsEmptyStatement(stat)) {
4623 body->statements()->Add(stat, zone()); 4622 body->statements()->push_back(stat);
4624 } 4623 }
4625 } 4624 }
4626 4625
4627 Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock)); 4626 Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock));
4628 block_state.set_end_position(scanner()->location().end_pos); 4627 block_state.set_end_position(scanner()->location().end_pos);
4629 body->set_scope(block_state.FinalizedBlockScope()); 4628 body->set_scope(block_state.FinalizedBlockScope());
4630 } 4629 }
4631 return body; 4630 return body;
4632 } 4631 }
4633 4632
4634 template <typename Impl> 4633 template <typename Impl>
4635 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement( 4634 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement(
4636 ZoneList<const AstRawString*>* labels, bool legacy, bool* ok) { 4635 ZoneList<const AstRawString*>* labels, bool legacy, bool* ok) {
4637 if (is_strict(language_mode()) || peek() != Token::FUNCTION || 4636 if (is_strict(language_mode()) || peek() != Token::FUNCTION ||
4638 (legacy && allow_harmony_restrictive_declarations())) { 4637 (legacy && allow_harmony_restrictive_declarations())) {
4639 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok); 4638 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok);
4640 } else { 4639 } else {
4641 if (legacy) { 4640 if (legacy) {
4642 impl()->CountUsage(v8::Isolate::kLegacyFunctionDeclaration); 4641 impl()->CountUsage(v8::Isolate::kLegacyFunctionDeclaration);
4643 } 4642 }
4644 // Make a block around the statement for a lexical binding 4643 // Make a block around the statement for a lexical binding
4645 // is introduced by a FunctionDeclaration. 4644 // is introduced by a FunctionDeclaration.
4646 BlockState block_state(zone(), &scope_state_); 4645 BlockState block_state(zone(), &scope_state_);
4647 block_state.set_start_position(scanner()->location().beg_pos); 4646 block_state.set_start_position(scanner()->location().beg_pos);
4648 BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition); 4647 BlockT block = factory()->NewBlock(NULL, false, kNoSourcePosition);
4649 StatementT body = ParseFunctionDeclaration(CHECK_OK); 4648 StatementT body = ParseFunctionDeclaration(CHECK_OK);
4650 block->statements()->Add(body, zone()); 4649 block->statements()->push_back(body);
4651 block_state.set_end_position(scanner()->location().end_pos); 4650 block_state.set_end_position(scanner()->location().end_pos);
4652 block->set_scope(block_state.FinalizedBlockScope()); 4651 block->set_scope(block_state.FinalizedBlockScope());
4653 return block; 4652 return block;
4654 } 4653 }
4655 } 4654 }
4656 4655
4657 template <typename Impl> 4656 template <typename Impl>
4658 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseVariableStatement( 4657 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseVariableStatement(
4659 VariableDeclarationContext var_context, 4658 VariableDeclarationContext var_context,
4660 ZoneList<const AstRawString*>* names, bool* ok) { 4659 ZoneList<const AstRawString*>* names, bool* ok) {
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
5035 return impl()->NullStatement(); 5034 return impl()->NullStatement();
5036 } 5035 }
5037 default_seen = true; 5036 default_seen = true;
5038 } 5037 }
5039 Expect(Token::COLON, CHECK_OK); 5038 Expect(Token::COLON, CHECK_OK);
5040 int clause_pos = position(); 5039 int clause_pos = position();
5041 StatementListT statements = impl()->NewStatementList(5); 5040 StatementListT statements = impl()->NewStatementList(5);
5042 while (peek() != Token::CASE && peek() != Token::DEFAULT && 5041 while (peek() != Token::CASE && peek() != Token::DEFAULT &&
5043 peek() != Token::RBRACE) { 5042 peek() != Token::RBRACE) {
5044 StatementT stat = ParseStatementListItem(CHECK_OK); 5043 StatementT stat = ParseStatementListItem(CHECK_OK);
5045 statements->Add(stat, zone()); 5044 statements->push_back(stat);
5046 } 5045 }
5047 auto clause = factory()->NewCaseClause(label, statements, clause_pos); 5046 auto clause = factory()->NewCaseClause(label, statements, clause_pos);
5048 cases->Add(clause, zone()); 5047 cases->Add(clause, zone());
5049 } 5048 }
5050 Expect(Token::RBRACE, CHECK_OK); 5049 Expect(Token::RBRACE, CHECK_OK);
5051 5050
5052 cases_block_state.set_end_position(scanner()->location().end_pos); 5051 cases_block_state.set_end_position(scanner()->location().end_pos);
5053 return impl()->RewriteSwitchStatement( 5052 return impl()->RewriteSwitchStatement(
5054 tag, switch_statement, cases, cases_block_state.FinalizedBlockScope()); 5053 tag, switch_statement, cases, cases_block_state.FinalizedBlockScope());
5055 } 5054 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
5093 Expect(Token::LPAREN, CHECK_OK); 5092 Expect(Token::LPAREN, CHECK_OK);
5094 catch_info.scope = NewScope(CATCH_SCOPE); 5093 catch_info.scope = NewScope(CATCH_SCOPE);
5095 catch_info.scope->set_start_position(scanner()->location().beg_pos); 5094 catch_info.scope->set_start_position(scanner()->location().beg_pos);
5096 5095
5097 { 5096 {
5098 CollectExpressionsInTailPositionToListScope 5097 CollectExpressionsInTailPositionToListScope
5099 collect_tail_call_expressions_scope( 5098 collect_tail_call_expressions_scope(
5100 function_state_, &catch_info.tail_call_expressions); 5099 function_state_, &catch_info.tail_call_expressions);
5101 BlockState catch_block_state(&scope_state_, catch_info.scope); 5100 BlockState catch_block_state(&scope_state_, catch_info.scope);
5102 5101
5103 catch_block = factory()->NewBlock(nullptr, 16, false, kNoSourcePosition); 5102 catch_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
5104 5103
5105 // Create a block scope to hold any lexical declarations created 5104 // Create a block scope to hold any lexical declarations created
5106 // as part of destructuring the catch parameter. 5105 // as part of destructuring the catch parameter.
5107 { 5106 {
5108 BlockState catch_variable_block_state(zone(), &scope_state_); 5107 BlockState catch_variable_block_state(zone(), &scope_state_);
5109 catch_variable_block_state.set_start_position( 5108 catch_variable_block_state.set_start_position(
5110 scanner()->location().beg_pos); 5109 scanner()->location().beg_pos);
5111 typename Types::Target target(this, catch_block); 5110 typename Types::Target target(this, catch_block);
5112 5111
5113 // This does not simply call ParsePrimaryExpression to avoid 5112 // This does not simply call ParsePrimaryExpression to avoid
5114 // ExpressionFromIdentifier from being called in the first 5113 // ExpressionFromIdentifier from being called in the first
5115 // branch, which would introduce an unresolved symbol and mess 5114 // branch, which would introduce an unresolved symbol and mess
5116 // with arrow function names. 5115 // with arrow function names.
5117 if (peek_any_identifier()) { 5116 if (peek_any_identifier()) {
5118 catch_info.name = 5117 catch_info.name =
5119 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK); 5118 ParseIdentifier(kDontAllowRestrictedIdentifiers, CHECK_OK);
5120 } else { 5119 } else {
5121 ExpressionClassifier pattern_classifier(this); 5120 ExpressionClassifier pattern_classifier(this);
5122 catch_info.pattern = ParsePrimaryExpression(CHECK_OK); 5121 catch_info.pattern = ParsePrimaryExpression(CHECK_OK);
5123 ValidateBindingPattern(CHECK_OK); 5122 ValidateBindingPattern(CHECK_OK);
5124 } 5123 }
5125 5124
5126 Expect(Token::RPAREN, CHECK_OK); 5125 Expect(Token::RPAREN, CHECK_OK);
5127 impl()->RewriteCatchPattern(&catch_info, CHECK_OK); 5126 impl()->RewriteCatchPattern(&catch_info, CHECK_OK);
5128 if (!impl()->IsNullStatement(catch_info.init_block)) { 5127 if (!impl()->IsNullStatement(catch_info.init_block)) {
5129 catch_block->statements()->Add(catch_info.init_block, zone()); 5128 catch_block->statements()->push_back(catch_info.init_block);
5130 } 5129 }
5131 5130
5132 catch_info.inner_block = ParseBlock(nullptr, CHECK_OK); 5131 catch_info.inner_block = ParseBlock(nullptr, CHECK_OK);
5133 catch_block->statements()->Add(catch_info.inner_block, zone()); 5132 catch_block->statements()->push_back(catch_info.inner_block);
5134 impl()->ValidateCatchBlock(catch_info, CHECK_OK); 5133 impl()->ValidateCatchBlock(catch_info, CHECK_OK);
5135 catch_variable_block_state.set_end_position( 5134 catch_variable_block_state.set_end_position(
5136 scanner()->location().end_pos); 5135 scanner()->location().end_pos);
5137 catch_block->set_scope( 5136 catch_block->set_scope(
5138 catch_variable_block_state.FinalizedBlockScope()); 5137 catch_variable_block_state.FinalizedBlockScope());
5139 } 5138 }
5140 } 5139 }
5141 5140
5142 catch_info.scope->set_end_position(scanner()->location().end_pos); 5141 catch_info.scope->set_end_position(scanner()->location().end_pos);
5143 } 5142 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
5227 ReturnExprContext::kInsideForInOfBody); 5226 ReturnExprContext::kInsideForInOfBody);
5228 BlockState block_state(zone(), &scope_state_); 5227 BlockState block_state(zone(), &scope_state_);
5229 block_state.set_start_position(scanner()->location().beg_pos); 5228 block_state.set_start_position(scanner()->location().beg_pos);
5230 5229
5231 StatementT body = ParseScopedStatement(nullptr, true, CHECK_OK); 5230 StatementT body = ParseScopedStatement(nullptr, true, CHECK_OK);
5232 5231
5233 BlockT body_block = impl()->NullBlock(); 5232 BlockT body_block = impl()->NullBlock();
5234 ExpressionT each_variable = impl()->EmptyExpression(); 5233 ExpressionT each_variable = impl()->EmptyExpression();
5235 impl()->DesugarBindingInForEachStatement(&for_info, &body_block, 5234 impl()->DesugarBindingInForEachStatement(&for_info, &body_block,
5236 &each_variable, CHECK_OK); 5235 &each_variable, CHECK_OK);
5237 body_block->statements()->Add(body, zone()); 5236 body_block->statements()->push_back(body);
5238 final_loop = impl()->InitializeForEachStatement( 5237 final_loop = impl()->InitializeForEachStatement(
5239 loop, each_variable, enumerable, body_block, each_keyword_pos); 5238 loop, each_variable, enumerable, body_block, each_keyword_pos);
5240 5239
5241 block_state.set_end_position(scanner()->location().end_pos); 5240 block_state.set_end_position(scanner()->location().end_pos);
5242 body_block->set_scope(block_state.FinalizedBlockScope()); 5241 body_block->set_scope(block_state.FinalizedBlockScope());
5243 } 5242 }
5244 5243
5245 init_block = 5244 init_block =
5246 impl()->CreateForEachStatementTDZ(init_block, for_info, ok); 5245 impl()->CreateForEachStatementTDZ(init_block, for_info, ok);
5247 5246
5248 for_state.set_end_position(scanner()->location().end_pos); 5247 for_state.set_end_position(scanner()->location().end_pos);
5249 Scope* for_scope = for_state.FinalizedBlockScope(); 5248 Scope* for_scope = for_state.FinalizedBlockScope();
5250 // Parsed for-in loop w/ variable declarations. 5249 // Parsed for-in loop w/ variable declarations.
5251 if (!impl()->IsNullStatement(init_block)) { 5250 if (!impl()->IsNullStatement(init_block)) {
5252 init_block->statements()->Add(final_loop, zone()); 5251 init_block->statements()->push_back(final_loop);
5253 init_block->set_scope(for_scope); 5252 init_block->set_scope(for_scope);
5254 return init_block; 5253 return init_block;
5255 } else { 5254 } else {
5256 DCHECK_NULL(for_scope); 5255 DCHECK_NULL(for_scope);
5257 return final_loop; 5256 return final_loop;
5258 } 5257 }
5259 } else { 5258 } else {
5260 // One or more declaration not followed by in/of. 5259 // One or more declaration not followed by in/of.
5261 init = impl()->BuildInitializationBlock( 5260 init = impl()->BuildInitializationBlock(
5262 &for_info.parsing_result, 5261 &for_info.parsing_result,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
5388 // } 5387 // }
5389 // 5388 //
5390 // or, desugar 5389 // or, desugar
5391 // for (; c; n) b 5390 // for (; c; n) b
5392 // into 5391 // into
5393 // { 5392 // {
5394 // for (; c; n) b 5393 // for (; c; n) b
5395 // } 5394 // }
5396 // just in case b introduces a lexical binding some other way, e.g., if b 5395 // just in case b introduces a lexical binding some other way, e.g., if b
5397 // is a FunctionDeclaration. 5396 // is a FunctionDeclaration.
5398 BlockT block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition); 5397 BlockT block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
5399 if (!impl()->IsNullStatement(init)) { 5398 if (!impl()->IsNullStatement(init)) {
5400 block->statements()->Add(init, zone()); 5399 block->statements()->push_back(init);
5401 } 5400 }
5402 block->statements()->Add(loop, zone()); 5401 block->statements()->push_back(loop);
5403 block->set_scope(for_scope); 5402 block->set_scope(for_scope);
5404 loop->Initialize(init, cond, next, body); 5403 loop->Initialize(init, cond, next, body);
5405 return block; 5404 return block;
5406 } else { 5405 } else {
5407 loop->Initialize(init, cond, next, body); 5406 loop->Initialize(init, cond, next, body);
5408 return loop; 5407 return loop;
5409 } 5408 }
5410 } 5409 }
5411 } 5410 }
5412 5411
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5461 has_seen_constructor_ = true; 5460 has_seen_constructor_ = true;
5462 return; 5461 return;
5463 } 5462 }
5464 } 5463 }
5465 5464
5466 5465
5467 } // namespace internal 5466 } // namespace internal
5468 } // namespace v8 5467 } // namespace v8
5469 5468
5470 #endif // V8_PARSING_PARSER_BASE_H 5469 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698