OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |