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

Side by Side Diff: src/parsing/pattern-rewriter.cc

Issue 2142233003: Templatize AstVisitor with its subclass (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 4 years, 5 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-base.h ('k') | src/parsing/preparser.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/ast/ast.h" 5 #include "src/ast/ast.h"
6 #include "src/messages.h" 6 #include "src/messages.h"
7 #include "src/parsing/parameter-initializer-rewriter.h" 7 #include "src/parsing/parameter-initializer-rewriter.h"
8 #include "src/parsing/parser.h" 8 #include "src/parsing/parser.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 322
323 void Parser::PatternRewriter::VisitRewritableExpression( 323 void Parser::PatternRewriter::VisitRewritableExpression(
324 RewritableExpression* node) { 324 RewritableExpression* node) {
325 // If this is not a destructuring assignment... 325 // If this is not a destructuring assignment...
326 if (!IsAssignmentContext() || !node->expression()->IsAssignment()) { 326 if (!IsAssignmentContext() || !node->expression()->IsAssignment()) {
327 // Mark the node as rewritten to prevent redundant rewriting, and 327 // Mark the node as rewritten to prevent redundant rewriting, and
328 // perform BindingPattern rewriting 328 // perform BindingPattern rewriting
329 DCHECK(!node->is_rewritten()); 329 DCHECK(!node->is_rewritten());
330 node->Rewrite(node->expression()); 330 node->Rewrite(node->expression());
331 return node->expression()->Accept(this); 331 return Visit(node->expression());
332 } 332 }
333 333
334 if (node->is_rewritten()) return; 334 if (node->is_rewritten()) return;
335 DCHECK(IsAssignmentContext()); 335 DCHECK(IsAssignmentContext());
336 Assignment* assign = node->expression()->AsAssignment(); 336 Assignment* assign = node->expression()->AsAssignment();
337 DCHECK_NOT_NULL(assign); 337 DCHECK_NOT_NULL(assign);
338 DCHECK_EQ(Token::ASSIGN, assign->op()); 338 DCHECK_EQ(Token::ASSIGN, assign->op());
339 339
340 auto initializer = assign->value(); 340 auto initializer = assign->value();
341 auto value = initializer; 341 auto value = initializer;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 Assignment* assignment = 723 Assignment* assignment =
724 factory()->NewAssignment(Token::ASSIGN, node, value, node->position()); 724 factory()->NewAssignment(Token::ASSIGN, node, value, node->position());
725 725
726 block_->statements()->Add( 726 block_->statements()->Add(
727 factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone()); 727 factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
728 } 728 }
729 729
730 730
731 // =============== UNREACHABLE ============================= 731 // =============== UNREACHABLE =============================
732 732
733 void Parser::PatternRewriter::Visit(AstNode* node) { UNREACHABLE(); }
734
735 #define NOT_A_PATTERN(Node) \ 733 #define NOT_A_PATTERN(Node) \
736 void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \ 734 void Parser::PatternRewriter::Visit##Node(v8::internal::Node*) { \
737 UNREACHABLE(); \ 735 UNREACHABLE(); \
738 } 736 }
739 737
740 NOT_A_PATTERN(BinaryOperation) 738 NOT_A_PATTERN(BinaryOperation)
741 NOT_A_PATTERN(Block) 739 NOT_A_PATTERN(Block)
742 NOT_A_PATTERN(BreakStatement) 740 NOT_A_PATTERN(BreakStatement)
743 NOT_A_PATTERN(Call) 741 NOT_A_PATTERN(Call)
744 NOT_A_PATTERN(CallNew) 742 NOT_A_PATTERN(CallNew)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 NOT_A_PATTERN(TryFinallyStatement) 775 NOT_A_PATTERN(TryFinallyStatement)
778 NOT_A_PATTERN(UnaryOperation) 776 NOT_A_PATTERN(UnaryOperation)
779 NOT_A_PATTERN(VariableDeclaration) 777 NOT_A_PATTERN(VariableDeclaration)
780 NOT_A_PATTERN(WhileStatement) 778 NOT_A_PATTERN(WhileStatement)
781 NOT_A_PATTERN(WithStatement) 779 NOT_A_PATTERN(WithStatement)
782 NOT_A_PATTERN(Yield) 780 NOT_A_PATTERN(Yield)
783 781
784 #undef NOT_A_PATTERN 782 #undef NOT_A_PATTERN
785 } // namespace internal 783 } // namespace internal
786 } // namespace v8 784 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser-base.h ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698