blob: 283bc7bfd24502be226a6e05d65fb0fccfd2009b [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
3// found in the LICENSE file.
4
5#ifndef V8_AST_AST_EXPRESSION_VISITOR_H_
6#define V8_AST_AST_EXPRESSION_VISITOR_H_
7
8#include "src/allocation.h"
9#include "src/ast/ast.h"
10#include "src/ast/scopes.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000011#include "src/type-info.h"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000012#include "src/zone.h"
13
14namespace v8 {
15namespace internal {
16
17// A Visitor over a CompilationInfo's AST that invokes
18// VisitExpression on each expression node.
19
20class AstExpressionVisitor : public AstVisitor {
21 public:
22 AstExpressionVisitor(Isolate* isolate, Expression* root);
23 AstExpressionVisitor(uintptr_t stack_limit, Expression* root);
24 void Run();
25
26 protected:
27 virtual void VisitExpression(Expression* expression) = 0;
28 int depth() { return depth_; }
29
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000030 void VisitDeclarations(ZoneList<Declaration*>* d) override;
31 void VisitStatements(ZoneList<Statement*>* s) override;
32
Ben Murdochc5610432016-08-08 18:44:38 +010033 private:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000034 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
35
36#define DECLARE_VISIT(type) void Visit##type(type* node) override;
37 AST_NODE_LIST(DECLARE_VISIT)
38#undef DECLARE_VISIT
39
40 Expression* root_;
41 int depth_;
42
43 DISALLOW_COPY_AND_ASSIGN(AstExpressionVisitor);
44};
45} // namespace internal
46} // namespace v8
47
48#endif // V8_AST_AST_EXPRESSION_VISITOR_H_