OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #ifdef DEBUG | 36 #ifdef DEBUG |
37 | 37 |
38 class PrettyPrinter: public AstVisitor { | 38 class PrettyPrinter: public AstVisitor { |
39 public: | 39 public: |
40 PrettyPrinter(); | 40 PrettyPrinter(); |
41 virtual ~PrettyPrinter(); | 41 virtual ~PrettyPrinter(); |
42 | 42 |
43 // The following routines print a node into a string. | 43 // The following routines print a node into a string. |
44 // The result string is alive as long as the PrettyPrinter is alive. | 44 // The result string is alive as long as the PrettyPrinter is alive. |
45 const char* Print(Node* node); | 45 const char* Print(AstNode* node); |
46 const char* PrintExpression(FunctionLiteral* program); | 46 const char* PrintExpression(FunctionLiteral* program); |
47 const char* PrintProgram(FunctionLiteral* program); | 47 const char* PrintProgram(FunctionLiteral* program); |
48 | 48 |
49 // Print a node to stdout. | 49 // Print a node to stdout. |
50 static void PrintOut(Node* node); | 50 static void PrintOut(AstNode* node); |
51 | 51 |
52 // Individual nodes | 52 // Individual nodes |
53 #define DEF_VISIT(type) \ | 53 #define DEF_VISIT(type) \ |
54 virtual void Visit##type(type* node); | 54 virtual void Visit##type(type* node); |
55 NODE_LIST(DEF_VISIT) | 55 NODE_LIST(DEF_VISIT) |
56 #undef DEF_VISIT | 56 #undef DEF_VISIT |
57 | 57 |
58 private: | 58 private: |
59 char* output_; // output string buffer | 59 char* output_; // output string buffer |
60 int size_; // output_ size | 60 int size_; // output_ size |
(...skipping 24 matching lines...) Expand all Loading... |
85 const char* PrintProgram(FunctionLiteral* program); | 85 const char* PrintProgram(FunctionLiteral* program); |
86 | 86 |
87 // Individual nodes | 87 // Individual nodes |
88 #define DEF_VISIT(type) \ | 88 #define DEF_VISIT(type) \ |
89 virtual void Visit##type(type* node); | 89 virtual void Visit##type(type* node); |
90 NODE_LIST(DEF_VISIT) | 90 NODE_LIST(DEF_VISIT) |
91 #undef DEF_VISIT | 91 #undef DEF_VISIT |
92 private: | 92 private: |
93 friend class IndentedScope; | 93 friend class IndentedScope; |
94 void PrintIndented(const char* txt); | 94 void PrintIndented(const char* txt); |
95 void PrintIndentedVisit(const char* s, Node* node); | 95 void PrintIndentedVisit(const char* s, AstNode* node); |
96 | 96 |
97 void PrintStatements(ZoneList<Statement*>* statements); | 97 void PrintStatements(ZoneList<Statement*>* statements); |
98 void PrintDeclarations(ZoneList<Declaration*>* declarations); | 98 void PrintDeclarations(ZoneList<Declaration*>* declarations); |
99 void PrintParameters(Scope* scope); | 99 void PrintParameters(Scope* scope); |
100 void PrintArguments(ZoneList<Expression*>* arguments); | 100 void PrintArguments(ZoneList<Expression*>* arguments); |
101 void PrintCaseClause(CaseClause* clause); | 101 void PrintCaseClause(CaseClause* clause); |
102 void PrintLiteralIndented(const char* info, Handle<Object> value, bool quote); | 102 void PrintLiteralIndented(const char* info, Handle<Object> value, bool quote); |
103 void PrintLiteralWithModeIndented(const char* info, | 103 void PrintLiteralWithModeIndented(const char* info, |
104 Variable* var, | 104 Variable* var, |
105 Handle<Object> value, | 105 Handle<Object> value, |
106 SmiAnalysis* type); | 106 SmiAnalysis* type); |
107 void PrintLabelsIndented(const char* info, ZoneStringList* labels); | 107 void PrintLabelsIndented(const char* info, ZoneStringList* labels); |
108 | 108 |
109 void inc_indent() { indent_++; } | 109 void inc_indent() { indent_++; } |
110 void dec_indent() { indent_--; } | 110 void dec_indent() { indent_--; } |
111 | 111 |
112 static int indent_; | 112 static int indent_; |
113 }; | 113 }; |
114 | 114 |
115 #endif // DEBUG | 115 #endif // DEBUG |
116 | 116 |
117 } } // namespace v8::internal | 117 } } // namespace v8::internal |
118 | 118 |
119 #endif // V8_PRETTYPRINTER_H_ | 119 #endif // V8_PRETTYPRINTER_H_ |
OLD | NEW |