| 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_PRETTYPRINTER_H_ | 5 #ifndef V8_AST_PRETTYPRINTER_H_ |
| 6 #define V8_AST_PRETTYPRINTER_H_ | 6 #define V8_AST_PRETTYPRINTER_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/base/compiler-specific.h" | |
| 11 | 10 |
| 12 namespace v8 { | 11 namespace v8 { |
| 13 namespace internal { | 12 namespace internal { |
| 14 | 13 |
| 15 class CallPrinter : public AstVisitor { | 14 class CallPrinter : public AstVisitor { |
| 16 public: | 15 public: |
| 17 explicit CallPrinter(Isolate* isolate, bool is_builtin); | 16 explicit CallPrinter(Isolate* isolate, bool is_builtin); |
| 18 virtual ~CallPrinter(); | 17 virtual ~CallPrinter(); |
| 19 | 18 |
| 20 // The following routine prints the node with position |position| into a | 19 // The following routine prints the node with position |position| into a |
| 21 // string. The result string is alive as long as the CallPrinter is alive. | 20 // string. The result string is alive as long as the CallPrinter is alive. |
| 22 const char* Print(FunctionLiteral* program, int position); | 21 const char* Print(FunctionLiteral* program, int position); |
| 23 | 22 |
| 24 void PRINTF_FORMAT(2, 3) Print(const char* format, ...); | 23 void Print(const char* format, ...); |
| 25 | 24 |
| 26 void Find(AstNode* node, bool print = false); | 25 void Find(AstNode* node, bool print = false); |
| 27 | 26 |
| 28 // Individual nodes | 27 // Individual nodes |
| 29 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 28 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 30 AST_NODE_LIST(DECLARE_VISIT) | 29 AST_NODE_LIST(DECLARE_VISIT) |
| 31 #undef DECLARE_VISIT | 30 #undef DECLARE_VISIT |
| 32 | 31 |
| 33 private: | 32 private: |
| 34 void Init(); | 33 void Init(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 public: | 55 public: |
| 57 explicit PrettyPrinter(Isolate* isolate); | 56 explicit PrettyPrinter(Isolate* isolate); |
| 58 virtual ~PrettyPrinter(); | 57 virtual ~PrettyPrinter(); |
| 59 | 58 |
| 60 // The following routines print a node into a string. | 59 // The following routines print a node into a string. |
| 61 // The result string is alive as long as the PrettyPrinter is alive. | 60 // The result string is alive as long as the PrettyPrinter is alive. |
| 62 const char* Print(AstNode* node); | 61 const char* Print(AstNode* node); |
| 63 const char* PrintExpression(FunctionLiteral* program); | 62 const char* PrintExpression(FunctionLiteral* program); |
| 64 const char* PrintProgram(FunctionLiteral* program); | 63 const char* PrintProgram(FunctionLiteral* program); |
| 65 | 64 |
| 66 void PRINTF_FORMAT(2, 3) Print(const char* format, ...); | 65 void Print(const char* format, ...); |
| 67 | 66 |
| 68 // Print a node to stdout. | 67 // Print a node to stdout. |
| 69 static void PrintOut(Isolate* isolate, AstNode* node); | 68 static void PrintOut(Isolate* isolate, AstNode* node); |
| 70 | 69 |
| 71 // Individual nodes | 70 // Individual nodes |
| 72 #define DECLARE_VISIT(type) void Visit##type(type* node) override; | 71 #define DECLARE_VISIT(type) void Visit##type(type* node) override; |
| 73 AST_NODE_LIST(DECLARE_VISIT) | 72 AST_NODE_LIST(DECLARE_VISIT) |
| 74 #undef DECLARE_VISIT | 73 #undef DECLARE_VISIT |
| 75 | 74 |
| 76 private: | 75 private: |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 134 |
| 136 int indent_; | 135 int indent_; |
| 137 }; | 136 }; |
| 138 | 137 |
| 139 #endif // DEBUG | 138 #endif // DEBUG |
| 140 | 139 |
| 141 } // namespace internal | 140 } // namespace internal |
| 142 } // namespace v8 | 141 } // namespace v8 |
| 143 | 142 |
| 144 #endif // V8_AST_PRETTYPRINTER_H_ | 143 #endif // V8_AST_PRETTYPRINTER_H_ |
| OLD | NEW |