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

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

Issue 2520883002: [parser] Fix scopes in rewriting of for-of and destructuring assignments. (Closed)
Patch Set: Take into account that the scope may have been removed when we get to rewrite. 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
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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 loop->Initialize(condition, body); 579 loop->Initialize(condition, body);
580 } 580 }
581 581
582 block_->statements()->Add(loop, zone()); 582 block_->statements()->Add(loop, zone());
583 RecurseIntoSubpattern(spread->expression(), 583 RecurseIntoSubpattern(spread->expression(),
584 factory()->NewVariableProxy(array)); 584 factory()->NewVariableProxy(array));
585 } 585 }
586 586
587 Expression* closing_condition = factory()->NewUnaryOperation( 587 Expression* closing_condition = factory()->NewUnaryOperation(
588 Token::NOT, factory()->NewVariableProxy(done), nopos); 588 Token::NOT, factory()->NewVariableProxy(done), nopos);
589 parser_->FinalizeIteratorUse(completion, closing_condition, iterator, block_, 589
590 target); 590 // Since assignments are being rewritten at the end of parsing, scope() may
591 // already have been removed by FinalizeBlockScope in the meantime. In that
592 // case, find the first outer non-removed scope.
Dan Ehrenberg 2016/11/22 16:07:00 Should we put this logic to find the appropriate n
neis 2016/11/23 12:51:08 Done.
593 Scope* real_scope = scope();
594 while (real_scope != nullptr && real_scope->HasBeenRemoved()) {
595 real_scope = real_scope->outer_scope();
596 }
597 DCHECK_NOT_NULL(real_scope);
Toon Verwaest 2016/11/22 08:30:18 What about moving this into an aptly named helper
neis 2016/11/23 12:51:08 Done.
598
599 parser_->FinalizeIteratorUse(real_scope, completion, closing_condition,
600 iterator, block_, target);
591 block_ = target; 601 block_ = target;
592 } 602 }
593 603
594 604
595 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) { 605 void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node) {
596 Variable* temp_var = nullptr; 606 Variable* temp_var = nullptr;
597 VisitArrayLiteral(node, &temp_var); 607 VisitArrayLiteral(node, &temp_var);
598 } 608 }
599 609
600 610
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 NOT_A_PATTERN(TryFinallyStatement) 697 NOT_A_PATTERN(TryFinallyStatement)
688 NOT_A_PATTERN(UnaryOperation) 698 NOT_A_PATTERN(UnaryOperation)
689 NOT_A_PATTERN(VariableDeclaration) 699 NOT_A_PATTERN(VariableDeclaration)
690 NOT_A_PATTERN(WhileStatement) 700 NOT_A_PATTERN(WhileStatement)
691 NOT_A_PATTERN(WithStatement) 701 NOT_A_PATTERN(WithStatement)
692 NOT_A_PATTERN(Yield) 702 NOT_A_PATTERN(Yield)
693 703
694 #undef NOT_A_PATTERN 704 #undef NOT_A_PATTERN
695 } // namespace internal 705 } // namespace internal
696 } // namespace v8 706 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698