| 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 19 matching lines...) Expand all Loading... |
| 30 rewriter.names_ = names; | 30 rewriter.names_ = names; |
| 31 rewriter.ok_ = ok; | 31 rewriter.ok_ = ok; |
| 32 rewriter.recursion_level_ = 0; | 32 rewriter.recursion_level_ = 0; |
| 33 | 33 |
| 34 rewriter.RecurseIntoSubpattern(rewriter.pattern_, declaration->initializer); | 34 rewriter.RecurseIntoSubpattern(rewriter.pattern_, declaration->initializer); |
| 35 } | 35 } |
| 36 | 36 |
| 37 | 37 |
| 38 void Parser::PatternRewriter::RewriteDestructuringAssignment( | 38 void Parser::PatternRewriter::RewriteDestructuringAssignment( |
| 39 Parser* parser, RewritableExpression* to_rewrite, Scope* scope) { | 39 Parser* parser, RewritableExpression* to_rewrite, Scope* scope) { |
| 40 PatternRewriter rewriter; | 40 DCHECK(!scope->HasBeenRemoved()); |
| 41 | |
| 42 DCHECK(!to_rewrite->is_rewritten()); | 41 DCHECK(!to_rewrite->is_rewritten()); |
| 43 | 42 |
| 44 bool ok = true; | 43 bool ok = true; |
| 44 |
| 45 PatternRewriter rewriter; |
| 45 rewriter.scope_ = scope; | 46 rewriter.scope_ = scope; |
| 46 rewriter.parser_ = parser; | 47 rewriter.parser_ = parser; |
| 47 rewriter.context_ = ASSIGNMENT; | 48 rewriter.context_ = ASSIGNMENT; |
| 48 rewriter.pattern_ = to_rewrite; | 49 rewriter.pattern_ = to_rewrite; |
| 49 rewriter.block_ = nullptr; | 50 rewriter.block_ = nullptr; |
| 50 rewriter.descriptor_ = nullptr; | 51 rewriter.descriptor_ = nullptr; |
| 51 rewriter.names_ = nullptr; | 52 rewriter.names_ = nullptr; |
| 52 rewriter.ok_ = &ok; | 53 rewriter.ok_ = &ok; |
| 53 rewriter.recursion_level_ = 0; | 54 rewriter.recursion_level_ = 0; |
| 54 | 55 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 loop->Initialize(condition, body); | 580 loop->Initialize(condition, body); |
| 580 } | 581 } |
| 581 | 582 |
| 582 block_->statements()->Add(loop, zone()); | 583 block_->statements()->Add(loop, zone()); |
| 583 RecurseIntoSubpattern(spread->expression(), | 584 RecurseIntoSubpattern(spread->expression(), |
| 584 factory()->NewVariableProxy(array)); | 585 factory()->NewVariableProxy(array)); |
| 585 } | 586 } |
| 586 | 587 |
| 587 Expression* closing_condition = factory()->NewUnaryOperation( | 588 Expression* closing_condition = factory()->NewUnaryOperation( |
| 588 Token::NOT, factory()->NewVariableProxy(done), nopos); | 589 Token::NOT, factory()->NewVariableProxy(done), nopos); |
| 589 parser_->FinalizeIteratorUse(completion, closing_condition, iterator, block_, | 590 |
| 590 target); | 591 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, |
| 592 block_, target); |
| 591 block_ = target; | 593 block_ = target; |
| 592 } | 594 } |
| 593 | 595 |
| 594 | 596 |
| 595 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { | 597 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { |
| 596 Variable* temp_var = nullptr; | 598 Variable* temp_var = nullptr; |
| 597 VisitArrayLiteral(node, &temp_var); | 599 VisitArrayLiteral(node, &temp_var); |
| 598 } | 600 } |
| 599 | 601 |
| 600 | 602 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 NOT_A_PATTERN(TryFinallyStatement) | 689 NOT_A_PATTERN(TryFinallyStatement) |
| 688 NOT_A_PATTERN(UnaryOperation) | 690 NOT_A_PATTERN(UnaryOperation) |
| 689 NOT_A_PATTERN(VariableDeclaration) | 691 NOT_A_PATTERN(VariableDeclaration) |
| 690 NOT_A_PATTERN(WhileStatement) | 692 NOT_A_PATTERN(WhileStatement) |
| 691 NOT_A_PATTERN(WithStatement) | 693 NOT_A_PATTERN(WithStatement) |
| 692 NOT_A_PATTERN(Yield) | 694 NOT_A_PATTERN(Yield) |
| 693 | 695 |
| 694 #undef NOT_A_PATTERN | 696 #undef NOT_A_PATTERN |
| 695 } // namespace internal | 697 } // namespace internal |
| 696 } // namespace v8 | 698 } // namespace v8 |
| OLD | NEW |