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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 Print("switch ("); | 140 Print("switch ("); |
141 Visit(node->tag()); | 141 Visit(node->tag()); |
142 Print(") { "); | 142 Print(") { "); |
143 ZoneList<CaseClause*>* cases = node->cases(); | 143 ZoneList<CaseClause*>* cases = node->cases(); |
144 for (int i = 0; i < cases->length(); i++) | 144 for (int i = 0; i < cases->length(); i++) |
145 PrintCaseClause(cases->at(i)); | 145 PrintCaseClause(cases->at(i)); |
146 Print("}"); | 146 Print("}"); |
147 } | 147 } |
148 | 148 |
149 | 149 |
150 void PrettyPrinter::VisitLoopStatement(LoopStatement* node) { | 150 void PrettyPrinter::VisitDoWhileStatement(DoWhileStatement* node) { |
151 PrintLabels(node->labels()); | 151 PrintLabels(node->labels()); |
152 switch (node->type()) { | 152 Print("do "); |
153 case LoopStatement::DO_LOOP: | 153 Visit(node->body()); |
154 ASSERT(node->init() == NULL); | 154 Print(" while ("); |
155 ASSERT(node->next() == NULL); | 155 Visit(node->cond()); |
156 Print("do "); | 156 Print(");"); |
157 Visit(node->body()); | |
158 Print(" while ("); | |
159 Visit(node->cond()); | |
160 Print(");"); | |
161 break; | |
162 | |
163 case LoopStatement::FOR_LOOP: | |
164 Print("for ("); | |
165 if (node->init() != NULL) { | |
166 Visit(node->init()); | |
167 Print(" "); | |
168 } else { | |
169 Print("; "); | |
170 } | |
171 if (node->cond() != NULL) | |
172 Visit(node->cond()); | |
173 Print("; "); | |
174 if (node->next() != NULL) | |
175 Visit(node->next()); // prints extra ';', unfortunately | |
176 // to fix: should use Expression for next | |
177 Print(") "); | |
178 Visit(node->body()); | |
179 break; | |
180 | |
181 case LoopStatement::WHILE_LOOP: | |
182 ASSERT(node->init() == NULL); | |
183 ASSERT(node->next() == NULL); | |
184 Print("while ("); | |
185 Visit(node->cond()); | |
186 Print(") "); | |
187 Visit(node->body()); | |
188 break; | |
189 } | |
190 } | 157 } |
191 | 158 |
192 | 159 |
160 void PrettyPrinter::VisitWhileStatement(WhileStatement* node) { | |
161 PrintLabels(node->labels()); | |
162 Print("while ("); | |
163 Visit(node->cond()); | |
164 Print(") "); | |
165 Visit(node->body()); | |
166 } | |
167 | |
168 | |
169 void PrettyPrinter::VisitForStatement(ForStatement* node) { | |
170 PrintLabels(node->labels()); | |
171 Print("for ("); | |
172 if (node->init() != NULL) { | |
173 Visit(node->init()); | |
174 Print(" "); | |
175 } else { | |
176 Print("; "); | |
177 } | |
178 if (node->cond() != NULL) Visit(node->cond()); | |
179 Print("; "); | |
180 if (node->next() != NULL) { | |
181 Visit(node->next()); // prints extra ';', unfortunately | |
William Hesse
2009/10/12 11:45:35
I don't understand this comment.
| |
182 // to fix: should use Expression for next | |
183 } | |
184 Print(") "); | |
185 Visit(node->body()); | |
186 } | |
187 | |
188 | |
193 void PrettyPrinter::VisitForInStatement(ForInStatement* node) { | 189 void PrettyPrinter::VisitForInStatement(ForInStatement* node) { |
194 PrintLabels(node->labels()); | 190 PrintLabels(node->labels()); |
195 Print("for ("); | 191 Print("for ("); |
196 Visit(node->each()); | 192 Visit(node->each()); |
197 Print(" in "); | 193 Print(" in "); |
198 Visit(node->enumerable()); | 194 Visit(node->enumerable()); |
199 Print(") "); | 195 Print(") "); |
200 Visit(node->body()); | 196 Visit(node->body()); |
201 } | 197 } |
202 | 198 |
203 | 199 |
204 void PrettyPrinter::VisitTryCatch(TryCatch* node) { | 200 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) { |
205 Print("try "); | 201 Print("try "); |
206 Visit(node->try_block()); | 202 Visit(node->try_block()); |
207 Print(" catch ("); | 203 Print(" catch ("); |
208 Visit(node->catch_var()); | 204 Visit(node->catch_var()); |
209 Print(") "); | 205 Print(") "); |
210 Visit(node->catch_block()); | 206 Visit(node->catch_block()); |
211 } | 207 } |
212 | 208 |
213 | 209 |
214 void PrettyPrinter::VisitTryFinally(TryFinally* node) { | 210 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { |
215 Print("try "); | 211 Print("try "); |
216 Visit(node->try_block()); | 212 Visit(node->try_block()); |
217 Print(" finally "); | 213 Print(" finally "); |
218 Visit(node->finally_block()); | 214 Visit(node->finally_block()); |
219 } | 215 } |
220 | 216 |
221 | 217 |
222 void PrettyPrinter::VisitDebuggerStatement(DebuggerStatement* node) { | 218 void PrettyPrinter::VisitDebuggerStatement(DebuggerStatement* node) { |
223 Print("debugger "); | 219 Print("debugger "); |
224 } | 220 } |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { | 830 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { |
835 IndentedScope indent("SWITCH"); | 831 IndentedScope indent("SWITCH"); |
836 PrintLabelsIndented(NULL, node->labels()); | 832 PrintLabelsIndented(NULL, node->labels()); |
837 PrintIndentedVisit("TAG", node->tag()); | 833 PrintIndentedVisit("TAG", node->tag()); |
838 for (int i = 0; i < node->cases()->length(); i++) { | 834 for (int i = 0; i < node->cases()->length(); i++) { |
839 PrintCaseClause(node->cases()->at(i)); | 835 PrintCaseClause(node->cases()->at(i)); |
840 } | 836 } |
841 } | 837 } |
842 | 838 |
843 | 839 |
844 void AstPrinter::VisitLoopStatement(LoopStatement* node) { | 840 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { |
845 IndentedScope indent(node->OperatorString()); | 841 IndentedScope indent("DO"); |
842 PrintLabelsIndented(NULL, node->labels()); | |
843 PrintIndentedVisit("BODY", node->body()); | |
844 PrintIndentedVisit("COND", node->cond()); | |
845 } | |
846 | |
847 | |
848 void AstPrinter::VisitWhileStatement(WhileStatement* node) { | |
849 IndentedScope indent("WHILE"); | |
850 PrintLabelsIndented(NULL, node->labels()); | |
851 PrintIndentedVisit("COND", node->cond()); | |
852 PrintIndentedVisit("BODY", node->body()); | |
853 } | |
854 | |
855 | |
856 void AstPrinter::VisitForStatement(ForStatement* node) { | |
857 IndentedScope indent("FOR"); | |
846 PrintLabelsIndented(NULL, node->labels()); | 858 PrintLabelsIndented(NULL, node->labels()); |
847 if (node->init()) PrintIndentedVisit("INIT", node->init()); | 859 if (node->init()) PrintIndentedVisit("INIT", node->init()); |
848 if (node->cond()) PrintIndentedVisit("COND", node->cond()); | 860 if (node->cond()) PrintIndentedVisit("COND", node->cond()); |
849 if (node->body()) PrintIndentedVisit("BODY", node->body()); | 861 PrintIndentedVisit("BODY", node->body()); |
850 if (node->next()) PrintIndentedVisit("NEXT", node->next()); | 862 if (node->next()) PrintIndentedVisit("NEXT", node->next()); |
851 } | 863 } |
852 | 864 |
853 | 865 |
854 void AstPrinter::VisitForInStatement(ForInStatement* node) { | 866 void AstPrinter::VisitForInStatement(ForInStatement* node) { |
855 IndentedScope indent("FOR IN"); | 867 IndentedScope indent("FOR IN"); |
856 PrintIndentedVisit("FOR", node->each()); | 868 PrintIndentedVisit("FOR", node->each()); |
857 PrintIndentedVisit("IN", node->enumerable()); | 869 PrintIndentedVisit("IN", node->enumerable()); |
858 PrintIndentedVisit("BODY", node->body()); | 870 PrintIndentedVisit("BODY", node->body()); |
859 } | 871 } |
860 | 872 |
861 | 873 |
862 void AstPrinter::VisitTryCatch(TryCatch* node) { | 874 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { |
863 IndentedScope indent("TRY CATCH"); | 875 IndentedScope indent("TRY CATCH"); |
864 PrintIndentedVisit("TRY", node->try_block()); | 876 PrintIndentedVisit("TRY", node->try_block()); |
865 PrintIndentedVisit("CATCHVAR", node->catch_var()); | 877 PrintIndentedVisit("CATCHVAR", node->catch_var()); |
866 PrintIndentedVisit("CATCH", node->catch_block()); | 878 PrintIndentedVisit("CATCH", node->catch_block()); |
867 } | 879 } |
868 | 880 |
869 | 881 |
870 void AstPrinter::VisitTryFinally(TryFinally* node) { | 882 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { |
871 IndentedScope indent("TRY FINALLY"); | 883 IndentedScope indent("TRY FINALLY"); |
872 PrintIndentedVisit("TRY", node->try_block()); | 884 PrintIndentedVisit("TRY", node->try_block()); |
873 PrintIndentedVisit("FINALLY", node->finally_block()); | 885 PrintIndentedVisit("FINALLY", node->finally_block()); |
874 } | 886 } |
875 | 887 |
876 | 888 |
877 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) { | 889 void AstPrinter::VisitDebuggerStatement(DebuggerStatement* node) { |
878 IndentedScope indent("DEBUGGER"); | 890 IndentedScope indent("DEBUGGER"); |
879 } | 891 } |
880 | 892 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1085 | 1097 |
1086 void AstPrinter::VisitThisFunction(ThisFunction* node) { | 1098 void AstPrinter::VisitThisFunction(ThisFunction* node) { |
1087 IndentedScope indent("THIS-FUNCTION"); | 1099 IndentedScope indent("THIS-FUNCTION"); |
1088 } | 1100 } |
1089 | 1101 |
1090 | 1102 |
1091 | 1103 |
1092 #endif // DEBUG | 1104 #endif // DEBUG |
1093 | 1105 |
1094 } } // namespace v8::internal | 1106 } } // namespace v8::internal |
OLD | NEW |