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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 189 |
190 void* operator new(size_t size, Zone* zone) { return zone->New(size); } | 190 void* operator new(size_t size, Zone* zone) { return zone->New(size); } |
191 | 191 |
192 explicit AstNode(int position): position_(position) {} | 192 explicit AstNode(int position): position_(position) {} |
193 virtual ~AstNode() {} | 193 virtual ~AstNode() {} |
194 | 194 |
195 virtual void Accept(AstVisitor* v) = 0; | 195 virtual void Accept(AstVisitor* v) = 0; |
196 virtual NodeType node_type() const = 0; | 196 virtual NodeType node_type() const = 0; |
197 int position() const { return position_; } | 197 int position() const { return position_; } |
198 | 198 |
| 199 #ifdef DEBUG |
| 200 void PrettyPrint(Isolate* isolate); |
| 201 void PrettyPrint(); |
| 202 void PrintAst(Isolate* isolate); |
| 203 void PrintAst(); |
| 204 #endif // DEBUG |
| 205 |
199 // Type testing & conversion functions overridden by concrete subclasses. | 206 // Type testing & conversion functions overridden by concrete subclasses. |
200 #define DECLARE_NODE_FUNCTIONS(type) \ | 207 #define DECLARE_NODE_FUNCTIONS(type) \ |
201 bool Is##type() const { return node_type() == AstNode::k##type; } \ | 208 bool Is##type() const { return node_type() == AstNode::k##type; } \ |
202 type* As##type() { \ | 209 type* As##type() { \ |
203 return Is##type() ? reinterpret_cast<type*>(this) : NULL; \ | 210 return Is##type() ? reinterpret_cast<type*>(this) : NULL; \ |
204 } \ | 211 } \ |
205 const type* As##type() const { \ | 212 const type* As##type() const { \ |
206 return Is##type() ? reinterpret_cast<const type*>(this) : NULL; \ | 213 return Is##type() ? reinterpret_cast<const type*>(this) : NULL; \ |
207 } | 214 } |
208 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 215 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
(...skipping 3317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3526 // the parser-level zone. | 3533 // the parser-level zone. |
3527 Zone* parser_zone_; | 3534 Zone* parser_zone_; |
3528 AstValueFactory* ast_value_factory_; | 3535 AstValueFactory* ast_value_factory_; |
3529 }; | 3536 }; |
3530 | 3537 |
3531 | 3538 |
3532 } // namespace internal | 3539 } // namespace internal |
3533 } // namespace v8 | 3540 } // namespace v8 |
3534 | 3541 |
3535 #endif // V8_AST_AST_H_ | 3542 #endif // V8_AST_AST_H_ |
OLD | NEW |