OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 3029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3040 // `at` and `Set`. | 3040 // `at` and `Set`. |
3041 #define AST_REWRITE_LIST_ELEMENT(Type, list, index) \ | 3041 #define AST_REWRITE_LIST_ELEMENT(Type, list, index) \ |
3042 do { \ | 3042 do { \ |
3043 auto _list = (list); \ | 3043 auto _list = (list); \ |
3044 auto _index = (index); \ | 3044 auto _index = (index); \ |
3045 AST_REWRITE(Type, _list->at(_index), _list->Set(_index, replacement)); \ | 3045 AST_REWRITE(Type, _list->at(_index), _list->Set(_index, replacement)); \ |
3046 } while (false) | 3046 } while (false) |
3047 | 3047 |
3048 | 3048 |
3049 // ---------------------------------------------------------------------------- | 3049 // ---------------------------------------------------------------------------- |
| 3050 // Traversing visitor |
| 3051 // - fully traverses the entire AST. |
| 3052 |
| 3053 class AstTraversalVisitor : public AstVisitor { |
| 3054 public: |
| 3055 explicit AstTraversalVisitor(Isolate* isolate); |
| 3056 virtual ~AstTraversalVisitor() {} |
| 3057 |
| 3058 // Iteration left-to-right. |
| 3059 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; |
| 3060 void VisitStatements(ZoneList<Statement*>* statements) override; |
| 3061 void VisitExpressions(ZoneList<Expression*>* expressions) override; |
| 3062 |
| 3063 // Individual nodes |
| 3064 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 3065 AST_NODE_LIST(DECLARE_VISIT) |
| 3066 #undef DECLARE_VISIT |
| 3067 |
| 3068 private: |
| 3069 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 3070 DISALLOW_COPY_AND_ASSIGN(AstTraversalVisitor); |
| 3071 }; |
| 3072 |
| 3073 // ---------------------------------------------------------------------------- |
3050 // AstNode factory | 3074 // AstNode factory |
3051 | 3075 |
3052 class AstNodeFactory final BASE_EMBEDDED { | 3076 class AstNodeFactory final BASE_EMBEDDED { |
3053 public: | 3077 public: |
3054 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3078 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
3055 : local_zone_(ast_value_factory->zone()), | 3079 : local_zone_(ast_value_factory->zone()), |
3056 parser_zone_(ast_value_factory->zone()), | 3080 parser_zone_(ast_value_factory->zone()), |
3057 ast_value_factory_(ast_value_factory) {} | 3081 ast_value_factory_(ast_value_factory) {} |
3058 | 3082 |
3059 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } | 3083 AstValueFactory* ast_value_factory() const { return ast_value_factory_; } |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3544 : NULL; \ | 3568 : NULL; \ |
3545 } | 3569 } |
3546 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3570 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3547 #undef DECLARE_NODE_FUNCTIONS | 3571 #undef DECLARE_NODE_FUNCTIONS |
3548 | 3572 |
3549 | 3573 |
3550 } // namespace internal | 3574 } // namespace internal |
3551 } // namespace v8 | 3575 } // namespace v8 |
3552 | 3576 |
3553 #endif // V8_AST_AST_H_ | 3577 #endif // V8_AST_AST_H_ |
OLD | NEW |