| 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_AST_EXPRESSION_VISITOR_H_ | 5 #ifndef V8_AST_AST_EXPRESSION_VISITOR_H_ |
| 6 #define V8_AST_AST_EXPRESSION_VISITOR_H_ | 6 #define V8_AST_AST_EXPRESSION_VISITOR_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
| 10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
| 11 #include "src/type-info.h" | 11 #include "src/type-info.h" |
| 12 #include "src/zone.h" | 12 #include "src/zone.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 // A Visitor over a CompilationInfo's AST that invokes | 17 // A Visitor over a CompilationInfo's AST that invokes |
| 18 // VisitExpression on each expression node. | 18 // VisitExpression on each expression node. |
| 19 | 19 |
| 20 class AstExpressionVisitor : public AstVisitor { | 20 class AstExpressionVisitor : public AstVisitor { |
| 21 public: | 21 public: |
| 22 AstExpressionVisitor(Isolate* isolate, Expression* root); | 22 enum Mode { |
| 23 AstExpressionVisitor(uintptr_t stack_limit, Expression* root); | 23 Normal = 0, |
| 24 // A Shallow AstExpressionVisitor will not visit nested Function bodies |
| 25 Shallow |
| 26 }; |
| 27 |
| 28 AstExpressionVisitor(Isolate* isolate, Expression* root, Mode mode = Normal); |
| 29 AstExpressionVisitor(uintptr_t stack_limit, Expression* root, |
| 30 Mode mode = Normal); |
| 24 void Run(); | 31 void Run(); |
| 25 | 32 |
| 33 Mode mode() const { return mode_; } |
| 34 bool is_shallow() const { return mode_ == Shallow; } |
| 35 |
| 26 protected: | 36 protected: |
| 27 virtual void VisitExpression(Expression* expression) = 0; | 37 virtual void VisitExpression(Expression* expression) = 0; |
| 28 int depth() { return depth_; } | 38 int depth() { return depth_; } |
| 29 | 39 |
| 30 private: | 40 private: |
| 31 void VisitDeclarations(ZoneList<Declaration*>* d) override; | 41 void VisitDeclarations(ZoneList<Declaration*>* d) override; |
| 32 void VisitStatements(ZoneList<Statement*>* s) override; | 42 void VisitStatements(ZoneList<Statement*>* s) override; |
| 33 | 43 |
| 34 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 44 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 35 | 45 |
| 36 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 46 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 37 AST_NODE_LIST(DECLARE_VISIT) | 47 AST_NODE_LIST(DECLARE_VISIT) |
| 38 #undef DECLARE_VISIT | 48 #undef DECLARE_VISIT |
| 39 | 49 |
| 40 Expression* root_; | 50 Expression* root_; |
| 41 int depth_; | 51 int depth_; |
| 52 Mode mode_; |
| 42 | 53 |
| 43 DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor); | 54 DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor); |
| 44 }; | 55 }; |
| 45 } // namespace internal | 56 } // namespace internal |
| 46 } // namespace v8 | 57 } // namespace v8 |
| 47 | 58 |
| 48 #endif // V8_AST_AST_EXPRESSION_VISITOR_H_ | 59 #endif // V8_AST_AST_EXPRESSION_VISITOR_H_ |
| OLD | NEW |