5 #ifndef V8_AST_PRETTYPRINTER_H_ 6 #define V8_AST_PRETTYPRINTER_H_ 8 #include "src/allocation.h" 9 #include "src/ast/ast.h" 10 #include "src/base/compiler-specific.h" 15 class IncrementalStringBuilder;
29 kCallAndNormalIterator,
32 ErrorHint GetErrorHint()
const;
35 #define DECLARE_VISIT(type) void Visit##type(type* node); 36 AST_NODE_LIST(DECLARE_VISIT)
40 void Print(
const char* str);
43 void Find(
AstNode* node,
bool print =
false);
48 std::unique_ptr<IncrementalStringBuilder> builder_;
53 bool is_iterator_error_;
54 bool is_async_iterator_error_;
56 FunctionKind function_kind_;
57 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
61 void PrintLiteral(
const AstRawString* value,
bool quote);
69 class AstPrinter final :
public AstVisitor<AstPrinter> {
71 explicit AstPrinter(
uintptr_t stack_limit);
76 const char* Print(
AstNode* node);
79 void PRINTF_FORMAT(2, 3) Print(const
char* format, ...);
85 #define DECLARE_VISIT(type) void Visit##type(type* node); 86 AST_NODE_LIST(DECLARE_VISIT)
90 friend class IndentedScope;
95 void PrintLiteral(
const AstRawString* value,
bool quote);
97 void PrintLiteral(
Literal* literal,
bool quote);
98 void PrintIndented(
const char* txt);
99 void PrintIndentedVisit(
const char* s,
AstNode* node);
106 void PrintLiteralIndented(
const char* info,
Literal* literal,
bool quote);
107 void PrintLiteralIndented(
const char* info,
const AstRawString* value,
109 void PrintLiteralIndented(
const char* info,
const AstConsString* value,
111 void PrintLiteralWithModeIndented(
const char* info,
Variable* var,
114 const char* prefix =
"");
115 void PrintObjectProperties(
117 void PrintClassProperties(
120 void inc_indent() { indent_++; }
121 void dec_indent() { indent_--; }
123 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
136 #endif // V8_AST_PRETTYPRINTER_H_