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

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

Issue 2312263002: [parser] Refactor of Parse*Statement*, part 2 (Closed)
Patch Set: The real patch Created 4 years, 3 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 | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('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 #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 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 Declaration* decl = DeclareVariable(variable_name, LET, pos, CHECK_OK); 1593 Declaration* decl = DeclareVariable(variable_name, LET, pos, CHECK_OK);
1594 decl->proxy()->var()->set_initializer_position(position()); 1594 decl->proxy()->var()->set_initializer_position(position());
1595 Assignment* assignment = 1595 Assignment* assignment =
1596 factory()->NewAssignment(Token::INIT, decl->proxy(), value, pos); 1596 factory()->NewAssignment(Token::INIT, decl->proxy(), value, pos);
1597 Statement* assignment_statement = 1597 Statement* assignment_statement =
1598 factory()->NewExpressionStatement(assignment, kNoSourcePosition); 1598 factory()->NewExpressionStatement(assignment, kNoSourcePosition);
1599 if (names) names->Add(variable_name, zone()); 1599 if (names) names->Add(variable_name, zone());
1600 return assignment_statement; 1600 return assignment_statement;
1601 } 1601 }
1602 1602
1603 Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) {
1604 // The harmony mode uses block elements instead of statements.
1605 //
1606 // Block ::
1607 // '{' StatementList '}'
1608
1609 // Construct block expecting 16 statements.
1610 Block* body = factory()->NewBlock(labels, 16, false, kNoSourcePosition);
1611
1612 // Parse the statements and collect escaping labels.
1613 Expect(Token::LBRACE, CHECK_OK);
1614 {
1615 BlockState block_state(&scope_state_);
1616 block_state.set_start_position(scanner()->location().beg_pos);
1617 ParserTarget target(this, body);
1618
1619 while (peek() != Token::RBRACE) {
1620 Statement* stat = ParseStatementListItem(CHECK_OK);
1621 if (stat && !stat->IsEmpty()) {
1622 body->statements()->Add(stat, zone());
1623 }
1624 }
1625
1626 Expect(Token::RBRACE, CHECK_OK);
1627 block_state.set_end_position(scanner()->location().end_pos);
1628 body->set_scope(block_state.FinalizedBlockScope());
1629 }
1630 return body;
1631 }
1632
1633 Block* Parser::BuildInitializationBlock( 1603 Block* Parser::BuildInitializationBlock(
1634 DeclarationParsingResult* parsing_result, 1604 DeclarationParsingResult* parsing_result,
1635 ZoneList<const AstRawString*>* names, bool* ok) { 1605 ZoneList<const AstRawString*>* names, bool* ok) {
1636 Block* result = factory()->NewBlock( 1606 Block* result = factory()->NewBlock(
1637 NULL, 1, true, parsing_result->descriptor.declaration_pos); 1607 NULL, 1, true, parsing_result->descriptor.declaration_pos);
1638 for (auto declaration : parsing_result->declarations) { 1608 for (auto declaration : parsing_result->declarations) {
1639 PatternRewriter::DeclareAndInitializeVariables( 1609 PatternRewriter::DeclareAndInitializeVariables(
1640 this, result, &(parsing_result->descriptor), &declaration, names, 1610 this, result, &(parsing_result->descriptor), &declaration, names,
1641 CHECK_OK); 1611 CHECK_OK);
1642 } 1612 }
(...skipping 4548 matching lines...) Expand 10 before | Expand all | Expand 10 after
6191 node->Print(Isolate::Current()); 6161 node->Print(Isolate::Current());
6192 } 6162 }
6193 #endif // DEBUG 6163 #endif // DEBUG
6194 6164
6195 #undef CHECK_OK 6165 #undef CHECK_OK
6196 #undef CHECK_OK_VOID 6166 #undef CHECK_OK_VOID
6197 #undef CHECK_FAILED 6167 #undef CHECK_FAILED
6198 6168
6199 } // namespace internal 6169 } // namespace internal
6200 } // namespace v8 6170 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698