28 #ifndef V8_PRETTYPRINTER_H_
29 #define V8_PRETTYPRINTER_H_
39 class PrettyPrinter:
public AstVisitor {
42 virtual ~PrettyPrinter();
46 const char*
Print(AstNode* node);
47 const char* PrintExpression(FunctionLiteral* program);
48 const char* PrintProgram(FunctionLiteral* program);
50 void Print(
const char* format, ...);
53 static void PrintOut(AstNode* node);
56 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
67 const char* Output()
const {
return output_; }
69 virtual void PrintStatements(ZoneList<Statement*>* statements);
71 virtual void PrintArguments(ZoneList<Expression*>* arguments);
72 void PrintLiteral(Handle<Object> value,
bool quote);
73 void PrintParameters(Scope* scope);
74 void PrintDeclarations(ZoneList<Declaration*>* declarations);
75 void PrintFunctionLiteral(FunctionLiteral*
function);
76 void PrintCaseClause(CaseClause* clause);
81 class AstPrinter:
public PrettyPrinter {
84 virtual ~AstPrinter();
86 const char* PrintProgram(FunctionLiteral* program);
89 #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
94 friend class IndentedScope;
95 void PrintIndented(
const char* txt);
96 void PrintIndentedVisit(
const char* s, AstNode* node);
98 void PrintStatements(ZoneList<Statement*>* statements);
99 void PrintDeclarations(ZoneList<Declaration*>* declarations);
100 void PrintParameters(Scope* scope);
101 void PrintArguments(ZoneList<Expression*>* arguments);
102 void PrintCaseClause(CaseClause* clause);
103 void PrintLiteralIndented(
const char* info, Handle<Object> value,
bool quote);
104 void PrintLiteralWithModeIndented(
const char* info,
106 Handle<Object> value);
107 void PrintLabelsIndented(
const char* info,
ZoneStringList* labels);
109 void inc_indent() { indent_++; }
110 void dec_indent() { indent_--; }
119 #endif // V8_PRETTYPRINTER_H_
#define DECLARE_VISIT(type)
v8::Handle< v8::Value > Print(const v8::Arguments &args)
ZoneList< Handle< String > > ZoneStringList