summaryrefslogtreecommitdiff
path: root/deps/v8/src/ast/ast-expression-rewriter.h
blob: 1da3fa82474646725f9713a40415eb9b9a38480a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_AST_AST_EXPRESSION_REWRITER_H_
#define V8_AST_AST_EXPRESSION_REWRITER_H_

#include "src/allocation.h"
#include "src/ast/ast.h"
#include "src/ast/scopes.h"
#include "src/type-info.h"
#include "src/zone.h"

namespace v8 {
namespace internal {

// A rewriting Visitor over a CompilationInfo's AST that invokes
// VisitExpression on each expression node.

class AstExpressionRewriter : public AstVisitor {
 public:
  explicit AstExpressionRewriter(Isolate* isolate) : AstVisitor() {
    InitializeAstRewriter(isolate);
  }
  explicit AstExpressionRewriter(uintptr_t stack_limit) : AstVisitor() {
    InitializeAstRewriter(stack_limit);
  }
  ~AstExpressionRewriter() override {}

  void VisitDeclarations(ZoneList<Declaration*>* declarations) override;
  void VisitStatements(ZoneList<Statement*>* statements) override;
  void VisitExpressions(ZoneList<Expression*>* expressions) override;

  virtual void VisitObjectLiteralProperty(ObjectLiteralProperty* property);

 protected:
  virtual bool RewriteExpression(Expression* expr) = 0;

 private:
  DEFINE_AST_REWRITER_SUBCLASS_MEMBERS();

#define DECLARE_VISIT(type) void Visit##type(type* node) override;
  AST_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT

  DISALLOW_COPY_AND_ASSIGN(AstExpressionRewriter);
};

}  // namespace internal
}  // namespace v8

#endif  // V8_AST_AST_EXPRESSION_REWRITER_H_