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_REWRITER_H_ | 5 #ifndef V8_AST_AST_EXPRESSION_REWRITER_H_ |
6 #define V8_AST_AST_EXPRESSION_REWRITER_H_ | 6 #define V8_AST_AST_EXPRESSION_REWRITER_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 rewriting Visitor over a CompilationInfo's AST that invokes | 17 // A rewriting Visitor over a CompilationInfo's AST that invokes |
18 // VisitExpression on each expression node. | 18 // VisitExpression on each expression node. |
19 | 19 |
20 // This AstVistor is not final, and provides the AstVisitor methods as virtual | 20 // This AstVistor is not final, and provides the AstVisitor methods as virtual |
21 // methods so they can be specialized by subclasses. | 21 // methods so they can be specialized by subclasses. |
22 class AstExpressionRewriter : public AstVisitor<AstExpressionRewriter> { | 22 class AstExpressionRewriter : public AstVisitor<AstExpressionRewriter> { |
23 public: | 23 public: |
24 explicit AstExpressionRewriter(Isolate* isolate) { | |
25 InitializeAstRewriter(isolate); | |
26 } | |
27 explicit AstExpressionRewriter(uintptr_t stack_limit) { | 24 explicit AstExpressionRewriter(uintptr_t stack_limit) { |
28 InitializeAstRewriter(stack_limit); | 25 InitializeAstRewriter(stack_limit); |
29 } | 26 } |
30 virtual ~AstExpressionRewriter() {} | 27 virtual ~AstExpressionRewriter() {} |
31 | 28 |
32 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); | 29 virtual void VisitDeclarations(ZoneList<Declaration*>* declarations); |
33 virtual void VisitStatements(ZoneList<Statement*>* statements); | 30 virtual void VisitStatements(ZoneList<Statement*>* statements); |
34 virtual void VisitExpressions(ZoneList<Expression*>* expressions); | 31 virtual void VisitExpressions(ZoneList<Expression*>* expressions); |
35 | 32 |
36 virtual void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 33 virtual void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
37 | 34 |
38 protected: | 35 protected: |
39 virtual bool RewriteExpression(Expression* expr) = 0; | 36 virtual bool RewriteExpression(Expression* expr) = 0; |
40 | 37 |
41 private: | 38 private: |
42 DEFINE_AST_REWRITER_SUBCLASS_MEMBERS(); | 39 DEFINE_AST_REWRITER_SUBCLASS_MEMBERS(); |
43 | 40 |
44 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); | 41 #define DECLARE_VISIT(type) virtual void Visit##type(type* node); |
45 AST_NODE_LIST(DECLARE_VISIT) | 42 AST_NODE_LIST(DECLARE_VISIT) |
46 #undef DECLARE_VISIT | 43 #undef DECLARE_VISIT |
47 | 44 |
48 DISALLOW_COPY_AND_ASSIGN(AstExpressionRewriter); | 45 DISALLOW_COPY_AND_ASSIGN(AstExpressionRewriter); |
49 }; | 46 }; |
50 | 47 |
51 } // namespace internal | 48 } // namespace internal |
52 } // namespace v8 | 49 } // namespace v8 |
53 | 50 |
54 #endif // V8_AST_AST_EXPRESSION_REWRITER_H_ | 51 #endif // V8_AST_AST_EXPRESSION_REWRITER_H_ |
OLD | NEW |