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