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

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

Issue 2519333005: Revert of [parser] Fix scopes in rewriting of for-of and destructuring assignments. (Closed)
Patch Set: Created 4 years 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.cc ('k') | test/cctest/interpreter/bytecode_expectations/Generators.golden » ('j') | 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 19 matching lines...) Expand all
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 DCHECK(!scope->HasBeenRemoved()); 40 PatternRewriter rewriter;
41
41 DCHECK(!to_rewrite->is_rewritten()); 42 DCHECK(!to_rewrite->is_rewritten());
42 43
43 bool ok = true; 44 bool ok = true;
44
45 PatternRewriter rewriter;
46 rewriter.scope_ = scope; 45 rewriter.scope_ = scope;
47 rewriter.parser_ = parser; 46 rewriter.parser_ = parser;
48 rewriter.context_ = ASSIGNMENT; 47 rewriter.context_ = ASSIGNMENT;
49 rewriter.pattern_ = to_rewrite; 48 rewriter.pattern_ = to_rewrite;
50 rewriter.block_ = nullptr; 49 rewriter.block_ = nullptr;
51 rewriter.descriptor_ = nullptr; 50 rewriter.descriptor_ = nullptr;
52 rewriter.names_ = nullptr; 51 rewriter.names_ = nullptr;
53 rewriter.ok_ = &ok; 52 rewriter.ok_ = &ok;
54 rewriter.recursion_level_ = 0; 53 rewriter.recursion_level_ = 0;
55 54
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 loop->Initialize(condition, body); 579 loop->Initialize(condition, body);
581 } 580 }
582 581
583 block_->statements()->Add(loop, zone()); 582 block_->statements()->Add(loop, zone());
584 RecurseIntoSubpattern(spread->expression(), 583 RecurseIntoSubpattern(spread->expression(),
585 factory()->NewVariableProxy(array)); 584 factory()->NewVariableProxy(array));
586 } 585 }
587 586
588 Expression* closing_condition = factory()->NewUnaryOperation( 587 Expression* closing_condition = factory()->NewUnaryOperation(
589 Token::NOT, factory()->NewVariableProxy(done), nopos); 588 Token::NOT, factory()->NewVariableProxy(done), nopos);
590 589 parser_->FinalizeIteratorUse(completion, closing_condition, iterator, block_,
591 parser_->FinalizeIteratorUse(scope(), completion, closing_condition, iterator, 590 target);
592 block_, target);
593 block_ = target; 591 block_ = target;
594 } 592 }
595 593
596 594
597 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { 595 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) {
598 Variable* temp_var = nullptr; 596 Variable* temp_var = nullptr;
599 VisitArrayLiteral(node, &temp_var); 597 VisitArrayLiteral(node, &temp_var);
600 } 598 }
601 599
602 600
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 NOT_A_PATTERN(TryFinallyStatement) 687 NOT_A_PATTERN(TryFinallyStatement)
690 NOT_A_PATTERN(UnaryOperation) 688 NOT_A_PATTERN(UnaryOperation)
691 NOT_A_PATTERN(VariableDeclaration) 689 NOT_A_PATTERN(VariableDeclaration)
692 NOT_A_PATTERN(WhileStatement) 690 NOT_A_PATTERN(WhileStatement)
693 NOT_A_PATTERN(WithStatement) 691 NOT_A_PATTERN(WithStatement)
694 NOT_A_PATTERN(Yield) 692 NOT_A_PATTERN(Yield)
695 693
696 #undef NOT_A_PATTERN 694 #undef NOT_A_PATTERN
697 } // namespace internal 695 } // namespace internal
698 } // namespace v8 696 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | test/cctest/interpreter/bytecode_expectations/Generators.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698