Line data Source code
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
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_AST_AST_EXPRESSION_REWRITER_H_
6 : #define V8_AST_AST_EXPRESSION_REWRITER_H_
7 :
8 : #include "src/allocation.h"
9 : #include "src/ast/ast.h"
10 : #include "src/ast/scopes.h"
11 : #include "src/zone/zone.h"
12 :
13 : namespace v8 {
14 : namespace internal {
15 :
16 : // A rewriting Visitor over a CompilationInfo's AST that invokes
17 : // VisitExpression on each expression node.
18 :
19 : // This AstVistor is not final, and provides the AstVisitor methods as virtual
20 : // methods so they can be specialized by subclasses.
21 : class AstExpressionRewriter : public AstVisitor<AstExpressionRewriter> {
22 : public:
23 : explicit AstExpressionRewriter(Isolate* isolate) {
24 : InitializeAstRewriter(isolate);
25 : }
26 2072 : explicit AstExpressionRewriter(uintptr_t stack_limit) {
27 : InitializeAstRewriter(stack_limit);
28 : }
29 2072 : virtual ~AstExpressionRewriter() {}
30 :
31 : virtual void VisitDeclarations(Declaration::List* declarations);
32 : virtual void VisitStatements(ZoneList<Statement*>* statements);
33 : virtual void VisitExpressions(ZoneList<Expression*>* expressions);
34 :
35 : virtual void VisitLiteralProperty(LiteralProperty* property);
36 :
37 : protected:
38 : virtual bool RewriteExpression(Expression* expr) = 0;
39 :
40 : private:
41 40384 : DEFINE_AST_REWRITER_SUBCLASS_MEMBERS();
42 :
43 : #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
44 : AST_NODE_LIST(DECLARE_VISIT)
45 : #undef DECLARE_VISIT
46 :
47 : DISALLOW_COPY_AND_ASSIGN(AstExpressionRewriter);
48 : };
49 :
50 : } // namespace internal
51 : } // namespace v8
52 :
53 : #endif // V8_AST_AST_EXPRESSION_REWRITER_H_
|