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

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

Issue 2394403002: [cleanup] Remove dead code from Variable and simplify PatternRewriter slightly (Closed)
Patch Set: Created 4 years, 2 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') | 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 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Expression* Parser::PatternRewriter::RewriteDestructuringAssignment( 60 Expression* Parser::PatternRewriter::RewriteDestructuringAssignment(
61 Parser* parser, Assignment* assignment, Scope* scope) { 61 Parser* parser, Assignment* assignment, Scope* scope) {
62 DCHECK_NOT_NULL(assignment); 62 DCHECK_NOT_NULL(assignment);
63 DCHECK_EQ(Token::ASSIGN, assignment->op()); 63 DCHECK_EQ(Token::ASSIGN, assignment->op());
64 auto to_rewrite = parser->factory()->NewRewritableExpression(assignment); 64 auto to_rewrite = parser->factory()->NewRewritableExpression(assignment);
65 RewriteDestructuringAssignment(parser, to_rewrite, scope); 65 RewriteDestructuringAssignment(parser, to_rewrite, scope);
66 return to_rewrite->expression(); 66 return to_rewrite->expression();
67 } 67 }
68 68
69 69
70 bool Parser::PatternRewriter::IsAssignmentContext(PatternContext c) const {
71 return c == ASSIGNMENT || c == ASSIGNMENT_INITIALIZER;
72 }
73
74
75 bool Parser::PatternRewriter::IsBindingContext(PatternContext c) const {
76 return c == BINDING || c == INITIALIZER;
77 }
78
79
80 Parser::PatternRewriter::PatternContext 70 Parser::PatternRewriter::PatternContext
81 Parser::PatternRewriter::SetAssignmentContextIfNeeded(Expression* node) { 71 Parser::PatternRewriter::SetAssignmentContextIfNeeded(Expression* node) {
82 PatternContext old_context = context(); 72 PatternContext old_context = context();
83 // AssignmentExpressions may occur in the Initializer position of a 73 // AssignmentExpressions may occur in the Initializer position of a
84 // SingleNameBinding. Such expressions should not prompt a change in the 74 // SingleNameBinding. Such expressions should not prompt a change in the
85 // pattern's context. 75 // pattern's context.
86 if (node->IsAssignment() && node->AsAssignment()->op() == Token::ASSIGN && 76 if (node->IsAssignment() && node->AsAssignment()->op() == Token::ASSIGN &&
87 !IsInitializerContext()) { 77 !IsInitializerContext()) {
88 set_context(ASSIGNMENT); 78 set_context(ASSIGNMENT);
89 } 79 }
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 NOT_A_PATTERN(TryFinallyStatement) 688 NOT_A_PATTERN(TryFinallyStatement)
699 NOT_A_PATTERN(UnaryOperation) 689 NOT_A_PATTERN(UnaryOperation)
700 NOT_A_PATTERN(VariableDeclaration) 690 NOT_A_PATTERN(VariableDeclaration)
701 NOT_A_PATTERN(WhileStatement) 691 NOT_A_PATTERN(WhileStatement)
702 NOT_A_PATTERN(WithStatement) 692 NOT_A_PATTERN(WithStatement)
703 NOT_A_PATTERN(Yield) 693 NOT_A_PATTERN(Yield)
704 694
705 #undef NOT_A_PATTERN 695 #undef NOT_A_PATTERN
706 } // namespace internal 696 } // namespace internal
707 } // namespace v8 697 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698