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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 factory()->NewExpressionStatement(assignment, kNoSourcePosition), | 254 factory()->NewExpressionStatement(assignment, kNoSourcePosition), |
255 zone()); | 255 zone()); |
256 } | 256 } |
257 return temp; | 257 return temp; |
258 } | 258 } |
259 | 259 |
260 | 260 |
261 void Parser::PatternRewriter::VisitRewritableExpression( | 261 void Parser::PatternRewriter::VisitRewritableExpression( |
262 RewritableExpression* node) { | 262 RewritableExpression* node) { |
263 // If this is not a destructuring assignment... | 263 // If this is not a destructuring assignment... |
264 if (!IsAssignmentContext() || !node->expression()->IsAssignment()) { | 264 if (!IsAssignmentContext()) { |
265 // Mark the node as rewritten to prevent redundant rewriting, and | 265 // Mark the node as rewritten to prevent redundant rewriting, and |
266 // perform BindingPattern rewriting | 266 // perform BindingPattern rewriting |
267 DCHECK(!node->is_rewritten()); | 267 DCHECK(!node->is_rewritten()); |
268 node->Rewrite(node->expression()); | 268 node->Rewrite(node->expression()); |
269 return Visit(node->expression()); | 269 return Visit(node->expression()); |
270 } else if (!node->expression()->IsAssignment()) { | |
271 return Visit(node->expression()); | |
caitp
2016/09/01 15:34:41
my understanding is, this will recursively continu
| |
270 } | 272 } |
271 | 273 |
272 if (node->is_rewritten()) return; | 274 if (node->is_rewritten()) return; |
273 DCHECK(IsAssignmentContext()); | 275 DCHECK(IsAssignmentContext()); |
274 Assignment* assign = node->expression()->AsAssignment(); | 276 Assignment* assign = node->expression()->AsAssignment(); |
275 DCHECK_NOT_NULL(assign); | 277 DCHECK_NOT_NULL(assign); |
276 DCHECK_EQ(Token::ASSIGN, assign->op()); | 278 DCHECK_EQ(Token::ASSIGN, assign->op()); |
277 | 279 |
278 auto initializer = assign->value(); | 280 auto initializer = assign->value(); |
279 auto value = initializer; | 281 auto value = initializer; |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
696 NOT_A_PATTERN(TryFinallyStatement) | 698 NOT_A_PATTERN(TryFinallyStatement) |
697 NOT_A_PATTERN(UnaryOperation) | 699 NOT_A_PATTERN(UnaryOperation) |
698 NOT_A_PATTERN(VariableDeclaration) | 700 NOT_A_PATTERN(VariableDeclaration) |
699 NOT_A_PATTERN(WhileStatement) | 701 NOT_A_PATTERN(WhileStatement) |
700 NOT_A_PATTERN(WithStatement) | 702 NOT_A_PATTERN(WithStatement) |
701 NOT_A_PATTERN(Yield) | 703 NOT_A_PATTERN(Yield) |
702 | 704 |
703 #undef NOT_A_PATTERN | 705 #undef NOT_A_PATTERN |
704 } // namespace internal | 706 } // namespace internal |
705 } // namespace v8 | 707 } // namespace v8 |
OLD | NEW |