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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 | 71 |
72 bool Parser::PatternRewriter::IsBindingContext(PatternContext c) const { | 72 bool Parser::PatternRewriter::IsBindingContext(PatternContext c) const { |
73 return c == BINDING || c == INITIALIZER; | 73 return c == BINDING || c == INITIALIZER; |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 Parser::PatternRewriter::PatternContext | 77 Parser::PatternRewriter::PatternContext |
78 Parser::PatternRewriter::SetAssignmentContextIfNeeded(Expression* node) { | 78 Parser::PatternRewriter::SetAssignmentContextIfNeeded(Expression* node) { |
79 PatternContext old_context = context(); | 79 PatternContext old_context = context(); |
80 if (node->IsAssignment() && node->AsAssignment()->op() == Token::ASSIGN) { | 80 // AssignmentExpressions may occur in the Initializer position of a |
| 81 // SingleNameBinding. Such expressions should not prompt a change in the |
| 82 // pattern's context. |
| 83 if (node->IsAssignment() && node->AsAssignment()->op() == Token::ASSIGN && |
| 84 !IsInitializerContext()) { |
81 set_context(ASSIGNMENT); | 85 set_context(ASSIGNMENT); |
82 } | 86 } |
83 return old_context; | 87 return old_context; |
84 } | 88 } |
85 | 89 |
86 | 90 |
87 Parser::PatternRewriter::PatternContext | 91 Parser::PatternRewriter::PatternContext |
88 Parser::PatternRewriter::SetInitializerContextIfNeeded(Expression* node) { | 92 Parser::PatternRewriter::SetInitializerContextIfNeeded(Expression* node) { |
89 // Set appropriate initializer context for BindingElement and | 93 // Set appropriate initializer context for BindingElement and |
90 // AssignmentElement nodes | 94 // AssignmentElement nodes |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 NOT_A_PATTERN(TryFinallyStatement) | 623 NOT_A_PATTERN(TryFinallyStatement) |
620 NOT_A_PATTERN(UnaryOperation) | 624 NOT_A_PATTERN(UnaryOperation) |
621 NOT_A_PATTERN(VariableDeclaration) | 625 NOT_A_PATTERN(VariableDeclaration) |
622 NOT_A_PATTERN(WhileStatement) | 626 NOT_A_PATTERN(WhileStatement) |
623 NOT_A_PATTERN(WithStatement) | 627 NOT_A_PATTERN(WithStatement) |
624 NOT_A_PATTERN(Yield) | 628 NOT_A_PATTERN(Yield) |
625 | 629 |
626 #undef NOT_A_PATTERN | 630 #undef NOT_A_PATTERN |
627 } // namespace internal | 631 } // namespace internal |
628 } // namespace v8 | 632 } // namespace v8 |
OLD | NEW |