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

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

Issue 2699793002: [parser cleanup] Simplify statement parsing logic (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // a pointer whereas the preparser does not really modify the body. 1227 // a pointer whereas the preparser does not really modify the body.
1228 V8_INLINE void ParseStatementList(StatementListT body, int end_token, 1228 V8_INLINE void ParseStatementList(StatementListT body, int end_token,
1229 bool* ok) { 1229 bool* ok) {
1230 LazyParsingResult result = ParseStatementList(body, end_token, false, ok); 1230 LazyParsingResult result = ParseStatementList(body, end_token, false, ok);
1231 USE(result); 1231 USE(result);
1232 DCHECK_EQ(result, kLazyParsingComplete); 1232 DCHECK_EQ(result, kLazyParsingComplete);
1233 } 1233 }
1234 LazyParsingResult ParseStatementList(StatementListT body, int end_token, 1234 LazyParsingResult ParseStatementList(StatementListT body, int end_token,
1235 bool may_abort, bool* ok); 1235 bool may_abort, bool* ok);
1236 StatementT ParseStatementListItem(bool* ok); 1236 StatementT ParseStatementListItem(bool* ok);
1237 StatementT ParseStatement(ZoneList<const AstRawString*>* labels, bool* ok) {
1238 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok);
1239 }
1237 StatementT ParseStatement(ZoneList<const AstRawString*>* labels, 1240 StatementT ParseStatement(ZoneList<const AstRawString*>* labels,
1238 AllowLabelledFunctionStatement allow_function, 1241 AllowLabelledFunctionStatement allow_function,
1239 bool* ok); 1242 bool* ok);
1240 StatementT ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels, 1243 StatementT ParseStatementAsUnlabelled(ZoneList<const AstRawString*>* labels,
1241 bool* ok); 1244 bool* ok);
1242 BlockT ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok); 1245 BlockT ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok);
1243 1246
1244 // Parse a SubStatement in strict mode, or with an extra block scope in 1247 // Parse a SubStatement in strict mode, or with an extra block scope in
1245 // sloppy mode to handle 1248 // sloppy mode to handle
1246 // ES#sec-functiondeclarations-in-ifstatement-statement-clauses 1249 // ES#sec-functiondeclarations-in-ifstatement-statement-clauses
1247 // The legacy parameter indicates whether function declarations are
1248 // banned by the ES2015 specification in this location, and they are being
1249 // permitted here to match previous V8 behavior.
1250 StatementT ParseScopedStatement(ZoneList<const AstRawString*>* labels, 1250 StatementT ParseScopedStatement(ZoneList<const AstRawString*>* labels,
1251 bool legacy, bool* ok); 1251 bool* ok);
1252 1252
1253 StatementT ParseVariableStatement(VariableDeclarationContext var_context, 1253 StatementT ParseVariableStatement(VariableDeclarationContext var_context,
1254 ZoneList<const AstRawString*>* names, 1254 ZoneList<const AstRawString*>* names,
1255 bool* ok); 1255 bool* ok);
1256 1256
1257 // Magical syntax support. 1257 // Magical syntax support.
1258 ExpressionT ParseV8Intrinsic(bool* ok); 1258 ExpressionT ParseV8Intrinsic(bool* ok);
1259 1259
1260 ExpressionT ParseDoExpression(bool* ok); 1260 ExpressionT ParseDoExpression(bool* ok);
1261 1261
(...skipping 3637 matching lines...) Expand 10 before | Expand all | Expand 10 after
4899 4899
4900 Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock)); 4900 Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock));
4901 block_state.set_end_position(scanner()->location().end_pos); 4901 block_state.set_end_position(scanner()->location().end_pos);
4902 body->set_scope(block_state.FinalizedBlockScope()); 4902 body->set_scope(block_state.FinalizedBlockScope());
4903 } 4903 }
4904 return body; 4904 return body;
4905 } 4905 }
4906 4906
4907 template <typename Impl> 4907 template <typename Impl>
4908 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement( 4908 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement(
4909 ZoneList<const AstRawString*>* labels, bool legacy, bool* ok) { 4909 ZoneList<const AstRawString*>* labels, bool* ok) {
4910 if (is_strict(language_mode()) || peek() != Token::FUNCTION || legacy) { 4910 if (is_strict(language_mode()) || peek() != Token::FUNCTION) {
4911 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok); 4911 return ParseStatement(labels, ok);
4912 } else { 4912 } else {
4913 if (legacy) {
4914 impl()->CountUsage(v8::Isolate::kLegacyFunctionDeclaration);
4915 }
4916 // Make a block around the statement for a lexical binding 4913 // Make a block around the statement for a lexical binding
4917 // is introduced by a FunctionDeclaration. 4914 // is introduced by a FunctionDeclaration.
4918 BlockState block_state(zone(), &scope_state_); 4915 BlockState block_state(zone(), &scope_state_);
4919 block_state.set_start_position(scanner()->location().beg_pos); 4916 block_state.set_start_position(scanner()->location().beg_pos);
4920 BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition); 4917 BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
4921 StatementT body = ParseFunctionDeclaration(CHECK_OK); 4918 StatementT body = ParseFunctionDeclaration(CHECK_OK);
4922 block->statements()->Add(body, zone()); 4919 block->statements()->Add(body, zone());
4923 block_state.set_end_position(scanner()->location().end_pos); 4920 block_state.set_end_position(scanner()->location().end_pos);
4924 block->set_scope(block_state.FinalizedBlockScope()); 4921 block->set_scope(block_state.FinalizedBlockScope());
4925 return block; 4922 return block;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
4996 bool starts_with_identifier = peek_any_identifier(); 4993 bool starts_with_identifier = peek_any_identifier();
4997 ExpressionT expr = ParseExpression(true, CHECK_OK); 4994 ExpressionT expr = ParseExpression(true, CHECK_OK);
4998 if (peek() == Token::COLON && starts_with_identifier && 4995 if (peek() == Token::COLON && starts_with_identifier &&
4999 impl()->IsIdentifier(expr)) { 4996 impl()->IsIdentifier(expr)) {
5000 // The whole expression was a single identifier, and not, e.g., 4997 // The whole expression was a single identifier, and not, e.g.,
5001 // something starting with an identifier or a parenthesized identifier. 4998 // something starting with an identifier or a parenthesized identifier.
5002 labels = impl()->DeclareLabel(labels, impl()->AsIdentifierExpression(expr), 4999 labels = impl()->DeclareLabel(labels, impl()->AsIdentifierExpression(expr),
5003 CHECK_OK); 5000 CHECK_OK);
5004 Consume(Token::COLON); 5001 Consume(Token::COLON);
5005 // ES#sec-labelled-function-declarations Labelled Function Declarations 5002 // ES#sec-labelled-function-declarations Labelled Function Declarations
5006 if (peek() == Token::FUNCTION && is_sloppy(language_mode())) { 5003 if (peek() == Token::FUNCTION && is_sloppy(language_mode()) &&
5007 if (allow_function == kAllowLabelledFunctionStatement) { 5004 allow_function == kAllowLabelledFunctionStatement) {
5008 return ParseFunctionDeclaration(ok); 5005 return ParseFunctionDeclaration(ok);
5009 } else {
5010 return ParseScopedStatement(labels, true, ok);
5011 }
5012 } 5006 }
5013 return ParseStatement(labels, kDisallowLabelledFunctionStatement, ok); 5007 return ParseStatement(labels, ok);
5014 } 5008 }
5015 5009
5016 // If we have an extension, we allow a native function declaration. 5010 // If we have an extension, we allow a native function declaration.
5017 // A native function declaration starts with "native function" with 5011 // A native function declaration starts with "native function" with
5018 // no line-terminator between the two words. 5012 // no line-terminator between the two words.
5019 if (extension_ != nullptr && peek() == Token::FUNCTION && 5013 if (extension_ != nullptr && peek() == Token::FUNCTION &&
5020 !scanner()->HasAnyLineTerminatorBeforeNext() && impl()->IsNative(expr) && 5014 !scanner()->HasAnyLineTerminatorBeforeNext() && impl()->IsNative(expr) &&
5021 !scanner()->literal_contains_escapes()) { 5015 !scanner()->literal_contains_escapes()) {
5022 return ParseNativeDeclaration(ok); 5016 return ParseNativeDeclaration(ok);
5023 } 5017 }
5024 5018
5025 // Parsed expression statement, followed by semicolon. 5019 // Parsed expression statement, followed by semicolon.
5026 ExpectSemicolon(CHECK_OK); 5020 ExpectSemicolon(CHECK_OK);
5027 return factory()->NewExpressionStatement(expr, pos); 5021 return factory()->NewExpressionStatement(expr, pos);
5028 } 5022 }
5029 5023
5030 template <typename Impl> 5024 template <typename Impl>
5031 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseIfStatement( 5025 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseIfStatement(
5032 ZoneList<const AstRawString*>* labels, bool* ok) { 5026 ZoneList<const AstRawString*>* labels, bool* ok) {
5033 // IfStatement :: 5027 // IfStatement ::
5034 // 'if' '(' Expression ')' Statement ('else' Statement)? 5028 // 'if' '(' Expression ')' Statement ('else' Statement)?
5035 5029
5036 int pos = peek_position(); 5030 int pos = peek_position();
5037 Expect(Token::IF, CHECK_OK); 5031 Expect(Token::IF, CHECK_OK);
5038 Expect(Token::LPAREN, CHECK_OK); 5032 Expect(Token::LPAREN, CHECK_OK);
5039 ExpressionT condition = ParseExpression(true, CHECK_OK); 5033 ExpressionT condition = ParseExpression(true, CHECK_OK);
5040 Expect(Token::RPAREN, CHECK_OK); 5034 Expect(Token::RPAREN, CHECK_OK);
5041 StatementT then_statement = ParseScopedStatement(labels, false, CHECK_OK); 5035 StatementT then_statement = ParseScopedStatement(labels, CHECK_OK);
5042 StatementT else_statement = impl()->NullStatement(); 5036 StatementT else_statement = impl()->NullStatement();
5043 if (Check(Token::ELSE)) { 5037 if (Check(Token::ELSE)) {
5044 else_statement = ParseScopedStatement(labels, false, CHECK_OK); 5038 else_statement = ParseScopedStatement(labels, CHECK_OK);
5045 } else { 5039 } else {
5046 else_statement = factory()->NewEmptyStatement(kNoSourcePosition); 5040 else_statement = factory()->NewEmptyStatement(kNoSourcePosition);
5047 } 5041 }
5048 return factory()->NewIfStatement(condition, then_statement, else_statement, 5042 return factory()->NewIfStatement(condition, then_statement, else_statement,
5049 pos); 5043 pos);
5050 } 5044 }
5051 5045
5052 template <typename Impl> 5046 template <typename Impl>
5053 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseContinueStatement( 5047 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseContinueStatement(
5054 bool* ok) { 5048 bool* ok) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
5189 5183
5190 Expect(Token::LPAREN, CHECK_OK); 5184 Expect(Token::LPAREN, CHECK_OK);
5191 ExpressionT expr = ParseExpression(true, CHECK_OK); 5185 ExpressionT expr = ParseExpression(true, CHECK_OK);
5192 Expect(Token::RPAREN, CHECK_OK); 5186 Expect(Token::RPAREN, CHECK_OK);
5193 5187
5194 Scope* with_scope = NewScope(WITH_SCOPE); 5188 Scope* with_scope = NewScope(WITH_SCOPE);
5195 StatementT body = impl()->NullStatement(); 5189 StatementT body = impl()->NullStatement();
5196 { 5190 {
5197 BlockState block_state(&scope_state_, with_scope); 5191 BlockState block_state(&scope_state_, with_scope);
5198 with_scope->set_start_position(scanner()->peek_location().beg_pos); 5192 with_scope->set_start_position(scanner()->peek_location().beg_pos);
5199 body = ParseScopedStatement(labels, true, CHECK_OK); 5193 body = ParseStatement(labels, CHECK_OK);
5200 with_scope->set_end_position(scanner()->location().end_pos); 5194 with_scope->set_end_position(scanner()->location().end_pos);
5201 } 5195 }
5202 return factory()->NewWithStatement(with_scope, expr, body, pos); 5196 return factory()->NewWithStatement(with_scope, expr, body, pos);
5203 } 5197 }
5204 5198
5205 template <typename Impl> 5199 template <typename Impl>
5206 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseDoWhileStatement( 5200 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseDoWhileStatement(
5207 ZoneList<const AstRawString*>* labels, bool* ok) { 5201 ZoneList<const AstRawString*>* labels, bool* ok) {
5208 // DoStatement :: 5202 // DoStatement ::
5209 // 'do' Statement 'while' '(' Expression ')' ';' 5203 // 'do' Statement 'while' '(' Expression ')' ';'
5210 5204
5211 auto loop = factory()->NewDoWhileStatement(labels, peek_position()); 5205 auto loop = factory()->NewDoWhileStatement(labels, peek_position());
5212 typename Types::Target target(this, loop); 5206 typename Types::Target target(this, loop);
5213 5207
5214 Expect(Token::DO, CHECK_OK); 5208 Expect(Token::DO, CHECK_OK);
5215 StatementT body = ParseScopedStatement(nullptr, true, CHECK_OK); 5209 StatementT body = ParseStatement(nullptr, CHECK_OK);
5216 Expect(Token::WHILE, CHECK_OK); 5210 Expect(Token::WHILE, CHECK_OK);
5217 Expect(Token::LPAREN, CHECK_OK); 5211 Expect(Token::LPAREN, CHECK_OK);
5218 5212
5219 ExpressionT cond = ParseExpression(true, CHECK_OK); 5213 ExpressionT cond = ParseExpression(true, CHECK_OK);
5220 Expect(Token::RPAREN, CHECK_OK); 5214 Expect(Token::RPAREN, CHECK_OK);
5221 5215
5222 // Allow do-statements to be terminated with and without 5216 // Allow do-statements to be terminated with and without
5223 // semi-colons. This allows code such as 'do;while(0)return' to 5217 // semi-colons. This allows code such as 'do;while(0)return' to
5224 // parse, which would not be the case if we had used the 5218 // parse, which would not be the case if we had used the
5225 // ExpectSemicolon() functionality here. 5219 // ExpectSemicolon() functionality here.
5226 Check(Token::SEMICOLON); 5220 Check(Token::SEMICOLON);
5227 5221
5228 loop->Initialize(cond, body); 5222 loop->Initialize(cond, body);
5229 return loop; 5223 return loop;
5230 } 5224 }
5231 5225
5232 template <typename Impl> 5226 template <typename Impl>
5233 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWhileStatement( 5227 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWhileStatement(
5234 ZoneList<const AstRawString*>* labels, bool* ok) { 5228 ZoneList<const AstRawString*>* labels, bool* ok) {
5235 // WhileStatement :: 5229 // WhileStatement ::
5236 // 'while' '(' Expression ')' Statement 5230 // 'while' '(' Expression ')' Statement
5237 5231
5238 auto loop = factory()->NewWhileStatement(labels, peek_position()); 5232 auto loop = factory()->NewWhileStatement(labels, peek_position());
5239 typename Types::Target target(this, loop); 5233 typename Types::Target target(this, loop);
5240 5234
5241 Expect(Token::WHILE, CHECK_OK); 5235 Expect(Token::WHILE, CHECK_OK);
5242 Expect(Token::LPAREN, CHECK_OK); 5236 Expect(Token::LPAREN, CHECK_OK);
5243 ExpressionT cond = ParseExpression(true, CHECK_OK); 5237 ExpressionT cond = ParseExpression(true, CHECK_OK);
5244 Expect(Token::RPAREN, CHECK_OK); 5238 Expect(Token::RPAREN, CHECK_OK);
5245 StatementT body = ParseScopedStatement(nullptr, true, CHECK_OK); 5239 StatementT body = ParseStatement(nullptr, CHECK_OK);
5246 5240
5247 loop->Initialize(cond, body); 5241 loop->Initialize(cond, body);
5248 return loop; 5242 return loop;
5249 } 5243 }
5250 5244
5251 template <typename Impl> 5245 template <typename Impl>
5252 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseThrowStatement( 5246 typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseThrowStatement(
5253 bool* ok) { 5247 bool* ok) {
5254 // ThrowStatement :: 5248 // ThrowStatement ::
5255 // 'throw' Expression ';' 5249 // 'throw' Expression ';'
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
5532 5526
5533 Expect(Token::RPAREN, CHECK_OK); 5527 Expect(Token::RPAREN, CHECK_OK);
5534 5528
5535 StatementT final_loop = impl()->NullStatement(); 5529 StatementT final_loop = impl()->NullStatement();
5536 { 5530 {
5537 ReturnExprScope no_tail_calls(function_state_, 5531 ReturnExprScope no_tail_calls(function_state_,
5538 ReturnExprContext::kInsideForInOfBody); 5532 ReturnExprContext::kInsideForInOfBody);
5539 BlockState block_state(zone(), &scope_state_); 5533 BlockState block_state(zone(), &scope_state_);
5540 block_state.set_start_position(scanner()->location().beg_pos); 5534 block_state.set_start_position(scanner()->location().beg_pos);
5541 5535
5542 StatementT body = ParseScopedStatement(nullptr, true, CHECK_OK); 5536 StatementT body = ParseStatement(nullptr, CHECK_OK);
5543 5537
5544 BlockT body_block = impl()->NullBlock(); 5538 BlockT body_block = impl()->NullBlock();
5545 ExpressionT each_variable = impl()->EmptyExpression(); 5539 ExpressionT each_variable = impl()->EmptyExpression();
5546 impl()->DesugarBindingInForEachStatement(for_info, &body_block, 5540 impl()->DesugarBindingInForEachStatement(for_info, &body_block,
5547 &each_variable, CHECK_OK); 5541 &each_variable, CHECK_OK);
5548 body_block->statements()->Add(body, zone()); 5542 body_block->statements()->Add(body, zone());
5549 final_loop = impl()->InitializeForEachStatement( 5543 final_loop = impl()->InitializeForEachStatement(
5550 loop, each_variable, enumerable, body_block, each_keyword_pos); 5544 loop, each_variable, enumerable, body_block, each_keyword_pos);
5551 5545
5552 block_state.set_end_position(scanner()->location().end_pos); 5546 block_state.set_end_position(scanner()->location().end_pos);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5596 } 5590 }
5597 5591
5598 Expect(Token::RPAREN, CHECK_OK); 5592 Expect(Token::RPAREN, CHECK_OK);
5599 5593
5600 { 5594 {
5601 ReturnExprScope no_tail_calls(function_state_, 5595 ReturnExprScope no_tail_calls(function_state_,
5602 ReturnExprContext::kInsideForInOfBody); 5596 ReturnExprContext::kInsideForInOfBody);
5603 BlockState block_state(zone(), &scope_state_); 5597 BlockState block_state(zone(), &scope_state_);
5604 block_state.set_start_position(scanner()->location().beg_pos); 5598 block_state.set_start_position(scanner()->location().beg_pos);
5605 5599
5606 // For legacy compat reasons, give for loops similar treatment to 5600 StatementT body = ParseStatement(nullptr, CHECK_OK);
5607 // if statements in allowing a function declaration for a body
5608 StatementT body = ParseScopedStatement(nullptr, true, CHECK_OK);
5609 block_state.set_end_position(scanner()->location().end_pos); 5601 block_state.set_end_position(scanner()->location().end_pos);
5610 StatementT final_loop = impl()->InitializeForEachStatement( 5602 StatementT final_loop = impl()->InitializeForEachStatement(
5611 loop, expression, enumerable, body, each_keyword_pos); 5603 loop, expression, enumerable, body, each_keyword_pos);
5612 5604
5613 Scope* for_scope = for_state->FinalizedBlockScope(); 5605 Scope* for_scope = for_state->FinalizedBlockScope();
5614 DCHECK_NULL(for_scope); 5606 DCHECK_NULL(for_scope);
5615 USE(for_scope); 5607 USE(for_scope);
5616 Scope* block_scope = block_state.FinalizedBlockScope(); 5608 Scope* block_scope = block_state.FinalizedBlockScope();
5617 DCHECK_NULL(block_scope); 5609 DCHECK_NULL(block_scope);
5618 USE(block_scope); 5610 USE(block_scope);
(...skipping 30 matching lines...) Expand all
5649 cond = ParseExpression(true, CHECK_OK); 5641 cond = ParseExpression(true, CHECK_OK);
5650 } 5642 }
5651 Expect(Token::SEMICOLON, CHECK_OK); 5643 Expect(Token::SEMICOLON, CHECK_OK);
5652 5644
5653 if (peek() != Token::RPAREN) { 5645 if (peek() != Token::RPAREN) {
5654 ExpressionT exp = ParseExpression(true, CHECK_OK); 5646 ExpressionT exp = ParseExpression(true, CHECK_OK);
5655 next = factory()->NewExpressionStatement(exp, exp->position()); 5647 next = factory()->NewExpressionStatement(exp, exp->position());
5656 } 5648 }
5657 Expect(Token::RPAREN, CHECK_OK); 5649 Expect(Token::RPAREN, CHECK_OK);
5658 5650
5659 body = ParseScopedStatement(nullptr, true, CHECK_OK); 5651 body = ParseStatement(nullptr, CHECK_OK);
5660 } 5652 }
5661 5653
5662 if (bound_names_are_lexical && for_info->bound_names.length() > 0) { 5654 if (bound_names_are_lexical && for_info->bound_names.length() > 0) {
5663 auto result = impl()->DesugarLexicalBindingsInForStatement( 5655 auto result = impl()->DesugarLexicalBindingsInForStatement(
5664 loop, init, cond, next, body, inner_scope, *for_info, CHECK_OK); 5656 loop, init, cond, next, body, inner_scope, *for_info, CHECK_OK);
5665 for_state->set_end_position(scanner()->location().end_pos); 5657 for_state->set_end_position(scanner()->location().end_pos);
5666 inner_scope->set_end_position(scanner()->location().end_pos); 5658 inner_scope->set_end_position(scanner()->location().end_pos);
5667 return result; 5659 return result;
5668 } 5660 }
5669 5661
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
5798 5790
5799 Expect(Token::RPAREN, CHECK_OK); 5791 Expect(Token::RPAREN, CHECK_OK);
5800 5792
5801 StatementT final_loop = impl()->NullStatement(); 5793 StatementT final_loop = impl()->NullStatement();
5802 { 5794 {
5803 ReturnExprScope no_tail_calls(function_state_, 5795 ReturnExprScope no_tail_calls(function_state_,
5804 ReturnExprContext::kInsideForInOfBody); 5796 ReturnExprContext::kInsideForInOfBody);
5805 BlockState block_state(zone(), &scope_state_); 5797 BlockState block_state(zone(), &scope_state_);
5806 block_state.set_start_position(scanner()->location().beg_pos); 5798 block_state.set_start_position(scanner()->location().beg_pos);
5807 5799
5808 const bool kDisallowLabelledFunctionStatement = true; 5800 StatementT body = ParseStatement(nullptr, CHECK_OK);
5809 StatementT body = ParseScopedStatement(
5810 nullptr, kDisallowLabelledFunctionStatement, CHECK_OK);
5811 block_state.set_end_position(scanner()->location().end_pos); 5801 block_state.set_end_position(scanner()->location().end_pos);
5812 5802
5813 if (has_declarations) { 5803 if (has_declarations) {
5814 BlockT body_block = impl()->NullBlock(); 5804 BlockT body_block = impl()->NullBlock();
5815 impl()->DesugarBindingInForEachStatement(&for_info, &body_block, 5805 impl()->DesugarBindingInForEachStatement(&for_info, &body_block,
5816 &each_variable, CHECK_OK); 5806 &each_variable, CHECK_OK);
5817 body_block->statements()->Add(body, zone()); 5807 body_block->statements()->Add(body, zone());
5818 body_block->set_scope(block_state.FinalizedBlockScope()); 5808 body_block->set_scope(block_state.FinalizedBlockScope());
5819 for_state.set_end_position(scanner()->location().end_pos); 5809 for_state.set_end_position(scanner()->location().end_pos);
5820 5810
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5905 } 5895 }
5906 5896
5907 #undef CHECK_OK 5897 #undef CHECK_OK
5908 #undef CHECK_OK_CUSTOM 5898 #undef CHECK_OK_CUSTOM
5909 #undef CHECK_OK_VOID 5899 #undef CHECK_OK_VOID
5910 5900
5911 } // namespace internal 5901 } // namespace internal
5912 } // namespace v8 5902 } // namespace v8
5913 5903
5914 #endif // V8_PARSING_PARSER_BASE_H 5904 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698