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

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

Issue 2169833002: [parser] Refactor AstTraversalVisitor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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
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 <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "src/ast/ast.h" 11 #include "src/ast/ast-traversal-visitor.h"
12 #include "src/ast/ast-expression-visitor.h"
13 #include "src/ast/scopes.h"
14 12
15 namespace v8 { 13 namespace v8 {
16 namespace internal { 14 namespace internal {
17 15
18 namespace { 16 namespace {
19 17
20 18
21 class Rewriter final : public AstExpressionVisitor { 19 class Rewriter final : public AstTraversalVisitor<Rewriter> {
22 public: 20 public:
23 Rewriter(uintptr_t stack_limit, Expression* initializer, Scope* old_scope, 21 Rewriter(uintptr_t stack_limit, Expression* initializer, Scope* old_scope,
24 Scope* new_scope) 22 Scope* new_scope)
25 : AstExpressionVisitor(stack_limit, initializer), 23 : AstTraversalVisitor(stack_limit, initializer),
26 old_scope_(old_scope), 24 old_scope_(old_scope),
27 new_scope_(new_scope), 25 new_scope_(new_scope),
28 old_scope_closure_(old_scope->ClosureScope()), 26 old_scope_closure_(old_scope->ClosureScope()),
29 new_scope_closure_(new_scope->ClosureScope()) {} 27 new_scope_closure_(new_scope->ClosureScope()) {}
30 ~Rewriter(); 28 ~Rewriter();
31 29
30 protected:
adamk 2016/07/21 18:11:57 "protected" + "final" doesn't make sense to me. Pr
nickie 2016/07/22 08:40:18 You're right. I'm making them private again. The
31 friend class AstTraversalVisitor<Rewriter>;
32
33 void VisitFunctionLiteral(FunctionLiteral* expr);
34 void VisitClassLiteral(ClassLiteral* expr);
35 void VisitVariableProxy(VariableProxy* expr);
36
37 void VisitBlock(Block* stmt);
38 void VisitTryCatchStatement(TryCatchStatement* stmt);
39 void VisitWithStatement(WithStatement* stmt);
40
32 private: 41 private:
33 void VisitExpression(Expression* expr) override {}
34
35 void VisitFunctionLiteral(FunctionLiteral* expr) override;
36 void VisitClassLiteral(ClassLiteral* expr) override;
37 void VisitVariableProxy(VariableProxy* expr) override;
38
39 void VisitBlock(Block* stmt) override;
40 void VisitTryCatchStatement(TryCatchStatement* stmt) override;
41 void VisitWithStatement(WithStatement* stmt) override;
42
43 Scope* old_scope_; 42 Scope* old_scope_;
44 Scope* new_scope_; 43 Scope* new_scope_;
45 Scope* old_scope_closure_; 44 Scope* old_scope_closure_;
46 Scope* new_scope_closure_; 45 Scope* new_scope_closure_;
47 std::vector<std::pair<Variable*, int>> temps_; 46 std::vector<std::pair<Variable*, int>> temps_;
48 }; 47 };
49 48
50 struct LessThanSecond { 49 struct LessThanSecond {
51 bool operator()(const std::pair<Variable*, int>& left, 50 bool operator()(const std::pair<Variable*, int>& left,
52 const std::pair<Variable*, int>& right) { 51 const std::pair<Variable*, int>& right) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void RewriteParameterInitializerScope(uintptr_t stack_limit, 133 void RewriteParameterInitializerScope(uintptr_t stack_limit,
135 Expression* initializer, Scope* old_scope, 134 Expression* initializer, Scope* old_scope,
136 Scope* new_scope) { 135 Scope* new_scope) {
137 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope); 136 Rewriter rewriter(stack_limit, initializer, old_scope, new_scope);
138 rewriter.Run(); 137 rewriter.Run();
139 } 138 }
140 139
141 140
142 } // namespace internal 141 } // namespace internal
143 } // namespace v8 142 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698