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

Side by Side Diff: src/parsing/parameter-initializer-rewriter.cc

Issue 1887743002: Re-scope inner scopes in arrow parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase and mark mjsunit/harmony/regress/regress-4658 as good for ignition Created 4 years, 8 months 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/ast/ast-expression-visitor.h ('k') | test/mjsunit/harmony/regress/regress-4904.js » ('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/parsing/parameter-initializer-rewriter.h" 5 #include "src/parsing/parameter-initializer-rewriter.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/ast-expression-visitor.h" 8 #include "src/ast/ast-expression-visitor.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 10
(...skipping 11 matching lines...) Expand all
22 old_scope_(old_scope), 22 old_scope_(old_scope),
23 new_scope_(new_scope) {} 23 new_scope_(new_scope) {}
24 24
25 private: 25 private:
26 void VisitExpression(Expression* expr) override {} 26 void VisitExpression(Expression* expr) override {}
27 27
28 void VisitFunctionLiteral(FunctionLiteral* expr) override; 28 void VisitFunctionLiteral(FunctionLiteral* expr) override;
29 void VisitClassLiteral(ClassLiteral* expr) override; 29 void VisitClassLiteral(ClassLiteral* expr) override;
30 void VisitVariableProxy(VariableProxy* expr) override; 30 void VisitVariableProxy(VariableProxy* expr) override;
31 31
32 void VisitBlock(Block* stmt) override;
33 void VisitTryCatchStatement(TryCatchStatement* stmt) override;
34 void VisitWithStatement(WithStatement* stmt) override;
35
32 Scope* old_scope_; 36 Scope* old_scope_;
33 Scope* new_scope_; 37 Scope* new_scope_;
34 }; 38 };
35 39
36 40
37 void Rewriter::VisitFunctionLiteral(FunctionLiteral* function_literal) { 41 void Rewriter::VisitFunctionLiteral(FunctionLiteral* function_literal) {
38 function_literal->scope()->ReplaceOuterScope(new_scope_); 42 function_literal->scope()->ReplaceOuterScope(new_scope_);
39 } 43 }
40 44
41 45
(...skipping 24 matching lines...) Expand all
66 if (old_scope_->RemoveTemporary(var)) { 70 if (old_scope_->RemoveTemporary(var)) {
67 var->set_scope(new_scope_); 71 var->set_scope(new_scope_);
68 new_scope_->AddTemporary(var); 72 new_scope_->AddTemporary(var);
69 } 73 }
70 } else if (old_scope_->RemoveUnresolved(proxy)) { 74 } else if (old_scope_->RemoveUnresolved(proxy)) {
71 new_scope_->AddUnresolved(proxy); 75 new_scope_->AddUnresolved(proxy);
72 } 76 }
73 } 77 }
74 78
75 79
80 void Rewriter::VisitBlock(Block* stmt) {
81 if (stmt->scope() != nullptr)
82 stmt->scope()->ReplaceOuterScope(new_scope_);
83 else
84 VisitStatements(stmt->statements());
85 }
86
87
88 void Rewriter::VisitTryCatchStatement(TryCatchStatement* stmt) {
89 Visit(stmt->try_block());
90 stmt->scope()->ReplaceOuterScope(new_scope_);
91 }
92
93
94 void Rewriter::VisitWithStatement(WithStatement* stmt) {
95 Visit(stmt->expression());
96 stmt->scope()->ReplaceOuterScope(new_scope_);
97 }
98
99
76 } // anonymous namespace 100 } // anonymous namespace
77 101
78 102
79 void RewriteParameterInitializerScope(uintptr_t stack_limit, 103 void RewriteParameterInitializerScope(uintptr_t stack_limit,
80 Expression* initializer, Scope* old_scope, 104 Expression* initializer, Scope* old_scope,
81 Scope* new_scope) { 105 Scope* new_scope) {
82 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); 106 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope);
83 rewriter.Run(); 107 rewriter.Run();
84 } 108 }
85 109
86 110
87 } // namespace internal 111 } // namespace internal
88 } // namespace v8 112 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/ast-expression-visitor.h ('k') | test/mjsunit/harmony/regress/regress-4904.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698