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 #ifndef V8_AST_EXPRESSION_VISITOR_H_ | 5 #ifndef V8_AST_EXPRESSION_VISITOR_H_ |
6 #define V8_AST_EXPRESSION_VISITOR_H_ | 6 #define V8_AST_EXPRESSION_VISITOR_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/ast.h" | 9 #include "src/ast.h" |
10 #include "src/effects.h" | 10 #include "src/effects.h" |
11 #include "src/scopes.h" | 11 #include "src/scopes.h" |
12 #include "src/type-info.h" | 12 #include "src/type-info.h" |
13 #include "src/types.h" | 13 #include "src/types.h" |
14 #include "src/zone.h" | 14 #include "src/zone.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 // A Visitor over a CompilationInfo's AST that invokes | 19 // A Visitor over a CompilationInfo's AST that invokes |
20 // VisitExpression on each expression node. | 20 // VisitExpression on each expression node. |
21 | 21 |
22 class AstExpressionVisitor : public AstVisitor { | 22 class AstExpressionVisitor : public AstVisitor { |
23 public: | 23 public: |
24 explicit AstExpressionVisitor(CompilationInfo* info); | 24 AstExpressionVisitor(Isolate* isolate, Zone* zone, FunctionLiteral* root); |
25 void Run(); | 25 void Run(); |
26 | 26 |
27 protected: | 27 protected: |
28 virtual void VisitExpression(Expression* expression) = 0; | 28 virtual void VisitExpression(Expression* expression) = 0; |
29 int depth() { return depth_; } | 29 int depth() { return depth_; } |
30 | 30 |
31 private: | 31 private: |
32 void VisitDeclarations(ZoneList<Declaration*>* d) override; | 32 void VisitDeclarations(ZoneList<Declaration*>* d) override; |
33 void VisitStatements(ZoneList<Statement*>* s) override; | 33 void VisitStatements(ZoneList<Statement*>* s) override; |
34 | 34 |
35 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 35 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
36 | 36 |
37 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) override; | 37 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) override; |
38 AST_NODE_LIST(DECLARE_VISIT) | 38 AST_NODE_LIST(DECLARE_VISIT) |
39 #undef DECLARE_VISIT | 39 #undef DECLARE_VISIT |
40 | 40 |
41 CompilationInfo* compilation_info_; | 41 FunctionLiteral* root_; |
42 int depth_; | 42 int depth_; |
43 | 43 |
44 DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor); | 44 DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor); |
45 }; | 45 }; |
46 } | 46 } |
47 } // namespace v8::internal | 47 } // namespace v8::internal |
48 | 48 |
49 #endif // V8_AST_EXPRESSION_VISITOR_H_ | 49 #endif // V8_AST_EXPRESSION_VISITOR_H_ |
OLD | NEW |