Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/prettyprinter.cc

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/preparser-api.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 118
119 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) { 119 void PrettyPrinter::VisitReturnStatement(ReturnStatement* node) {
120 Print("return "); 120 Print("return ");
121 Visit(node->expression()); 121 Visit(node->expression());
122 Print(";"); 122 Print(";");
123 } 123 }
124 124
125 125
126 void PrettyPrinter::VisitWithEnterStatement(WithEnterStatement* node) { 126 void PrettyPrinter::VisitEnterWithContextStatement(
127 Print("<enter with> ("); 127 EnterWithContextStatement* node) {
128 Print("<enter with context> (");
128 Visit(node->expression()); 129 Visit(node->expression());
129 Print(") "); 130 Print(") ");
130 } 131 }
131 132
132 133
133 void PrettyPrinter::VisitWithExitStatement(WithExitStatement* node) { 134 void PrettyPrinter::VisitExitContextStatement(ExitContextStatement* node) {
134 Print("<exit with>"); 135 Print("<exit context>");
135 } 136 }
136 137
137 138
138 void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) { 139 void PrettyPrinter::VisitSwitchStatement(SwitchStatement* node) {
139 PrintLabels(node->labels()); 140 PrintLabels(node->labels());
140 Print("switch ("); 141 Print("switch (");
141 Visit(node->tag()); 142 Visit(node->tag());
142 Print(") { "); 143 Print(") { ");
143 ZoneList<CaseClause*>* cases = node->cases(); 144 ZoneList<CaseClause*>* cases = node->cases();
144 for (int i = 0; i < cases->length(); i++) 145 for (int i = 0; i < cases->length(); i++)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 Visit(node->enumerable()); 195 Visit(node->enumerable());
195 Print(") "); 196 Print(") ");
196 Visit(node->body()); 197 Visit(node->body());
197 } 198 }
198 199
199 200
200 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 201 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
201 Print("try "); 202 Print("try ");
202 Visit(node->try_block()); 203 Visit(node->try_block());
203 Print(" catch ("); 204 Print(" catch (");
204 Visit(node->catch_var()); 205 const bool quote = false;
206 PrintLiteral(node->variable()->name(), quote);
205 Print(") "); 207 Print(") ");
206 Visit(node->catch_block()); 208 Visit(node->catch_block());
207 } 209 }
208 210
209 211
210 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { 212 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
211 Print("try "); 213 Print("try ");
212 Visit(node->try_block()); 214 Visit(node->try_block());
213 Print(" finally "); 215 Print(" finally ");
214 Visit(node->finally_block()); 216 Visit(node->finally_block());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) { 277 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) {
276 Print("[ "); 278 Print("[ ");
277 for (int i = 0; i < node->values()->length(); i++) { 279 for (int i = 0; i < node->values()->length(); i++) {
278 if (i != 0) Print(","); 280 if (i != 0) Print(",");
279 Visit(node->values()->at(i)); 281 Visit(node->values()->at(i));
280 } 282 }
281 Print(" ]"); 283 Print(" ]");
282 } 284 }
283 285
284 286
285 void PrettyPrinter::VisitCatchExtensionObject(CatchExtensionObject* node) {
286 Print("{ ");
287 Visit(node->key());
288 Print(": ");
289 Visit(node->value());
290 Print(" }");
291 }
292
293
294 void PrettyPrinter::VisitSlot(Slot* node) { 287 void PrettyPrinter::VisitSlot(Slot* node) {
295 switch (node->type()) { 288 switch (node->type()) {
296 case Slot::PARAMETER: 289 case Slot::PARAMETER:
297 Print("parameter[%d]", node->index()); 290 Print("parameter[%d]", node->index());
298 break; 291 break;
299 case Slot::LOCAL: 292 case Slot::LOCAL:
300 Print("local[%d]", node->index()); 293 Print("local[%d]", node->index());
301 break; 294 break;
302 case Slot::CONTEXT: 295 case Slot::CONTEXT:
303 Print("context[%d]", node->index()); 296 Print("context[%d]", node->index());
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 void AstPrinter::VisitBreakStatement(BreakStatement* node) { 791 void AstPrinter::VisitBreakStatement(BreakStatement* node) {
799 PrintLabelsIndented("BREAK", node->target()->labels()); 792 PrintLabelsIndented("BREAK", node->target()->labels());
800 } 793 }
801 794
802 795
803 void AstPrinter::VisitReturnStatement(ReturnStatement* node) { 796 void AstPrinter::VisitReturnStatement(ReturnStatement* node) {
804 PrintIndentedVisit("RETURN", node->expression()); 797 PrintIndentedVisit("RETURN", node->expression());
805 } 798 }
806 799
807 800
808 void AstPrinter::VisitWithEnterStatement(WithEnterStatement* node) { 801 void AstPrinter::VisitEnterWithContextStatement(
809 PrintIndentedVisit("WITH ENTER", node->expression()); 802 EnterWithContextStatement* node) {
803 PrintIndentedVisit("ENTER WITH CONTEXT", node->expression());
810 } 804 }
811 805
812 806
813 void AstPrinter::VisitWithExitStatement(WithExitStatement* node) { 807 void AstPrinter::VisitExitContextStatement(ExitContextStatement* node) {
814 PrintIndented("WITH EXIT\n"); 808 PrintIndented("EXIT CONTEXT\n");
815 } 809 }
816 810
817 811
818 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) { 812 void AstPrinter::VisitSwitchStatement(SwitchStatement* node) {
819 IndentedScope indent(this, "SWITCH"); 813 IndentedScope indent(this, "SWITCH");
820 PrintLabelsIndented(NULL, node->labels()); 814 PrintLabelsIndented(NULL, node->labels());
821 PrintIndentedVisit("TAG", node->tag()); 815 PrintIndentedVisit("TAG", node->tag());
822 for (int i = 0; i < node->cases()->length(); i++) { 816 for (int i = 0; i < node->cases()->length(); i++) {
823 PrintCaseClause(node->cases()->at(i)); 817 PrintCaseClause(node->cases()->at(i));
824 } 818 }
(...skipping 30 matching lines...) Expand all
855 IndentedScope indent(this, "FOR IN"); 849 IndentedScope indent(this, "FOR IN");
856 PrintIndentedVisit("FOR", node->each()); 850 PrintIndentedVisit("FOR", node->each());
857 PrintIndentedVisit("IN", node->enumerable()); 851 PrintIndentedVisit("IN", node->enumerable());
858 PrintIndentedVisit("BODY", node->body()); 852 PrintIndentedVisit("BODY", node->body());
859 } 853 }
860 854
861 855
862 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { 856 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) {
863 IndentedScope indent(this, "TRY CATCH"); 857 IndentedScope indent(this, "TRY CATCH");
864 PrintIndentedVisit("TRY", node->try_block()); 858 PrintIndentedVisit("TRY", node->try_block());
865 PrintIndentedVisit("CATCHVAR", node->catch_var()); 859 PrintLiteralWithModeIndented("CATCHVAR",
860 node->variable(),
861 node->variable()->name());
866 PrintIndentedVisit("CATCH", node->catch_block()); 862 PrintIndentedVisit("CATCH", node->catch_block());
867 } 863 }
868 864
869 865
870 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { 866 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) {
871 IndentedScope indent(this, "TRY FINALLY"); 867 IndentedScope indent(this, "TRY FINALLY");
872 PrintIndentedVisit("TRY", node->try_block()); 868 PrintIndentedVisit("TRY", node->try_block());
873 PrintIndentedVisit("FINALLY", node->finally_block()); 869 PrintIndentedVisit("FINALLY", node->finally_block());
874 } 870 }
875 871
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 IndentedScope indent(this, "ARRAY LITERAL"); 951 IndentedScope indent(this, "ARRAY LITERAL");
956 if (node->values()->length() > 0) { 952 if (node->values()->length() > 0) {
957 IndentedScope indent(this, "VALUES"); 953 IndentedScope indent(this, "VALUES");
958 for (int i = 0; i < node->values()->length(); i++) { 954 for (int i = 0; i < node->values()->length(); i++) {
959 Visit(node->values()->at(i)); 955 Visit(node->values()->at(i));
960 } 956 }
961 } 957 }
962 } 958 }
963 959
964 960
965 void AstPrinter::VisitCatchExtensionObject(CatchExtensionObject* node) {
966 IndentedScope indent(this, "CatchExtensionObject");
967 PrintIndentedVisit("KEY", node->key());
968 PrintIndentedVisit("VALUE", node->value());
969 }
970
971
972 void AstPrinter::VisitSlot(Slot* node) { 961 void AstPrinter::VisitSlot(Slot* node) {
973 PrintIndented("SLOT "); 962 PrintIndented("SLOT ");
974 PrettyPrinter::VisitSlot(node); 963 PrettyPrinter::VisitSlot(node);
975 Print("\n"); 964 Print("\n");
976 } 965 }
977 966
978 967
979 void AstPrinter::VisitVariableProxy(VariableProxy* node) { 968 void AstPrinter::VisitVariableProxy(VariableProxy* node) {
980 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name()); 969 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name());
981 Variable* var = node->var(); 970 Variable* var = node->var();
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 TagScope tag(this, "BreakStatement"); 1187 TagScope tag(this, "BreakStatement");
1199 } 1188 }
1200 1189
1201 1190
1202 void JsonAstBuilder::VisitReturnStatement(ReturnStatement* stmt) { 1191 void JsonAstBuilder::VisitReturnStatement(ReturnStatement* stmt) {
1203 TagScope tag(this, "ReturnStatement"); 1192 TagScope tag(this, "ReturnStatement");
1204 Visit(stmt->expression()); 1193 Visit(stmt->expression());
1205 } 1194 }
1206 1195
1207 1196
1208 void JsonAstBuilder::VisitWithEnterStatement(WithEnterStatement* stmt) { 1197 void JsonAstBuilder::VisitEnterWithContextStatement(
1209 TagScope tag(this, "WithEnterStatement"); 1198 EnterWithContextStatement* stmt) {
1199 TagScope tag(this, "EnterWithContextStatement");
1210 Visit(stmt->expression()); 1200 Visit(stmt->expression());
1211 } 1201 }
1212 1202
1213 1203
1214 void JsonAstBuilder::VisitWithExitStatement(WithExitStatement* stmt) { 1204 void JsonAstBuilder::VisitExitContextStatement(ExitContextStatement* stmt) {
1215 TagScope tag(this, "WithExitStatement"); 1205 TagScope tag(this, "ExitContextStatement");
1216 } 1206 }
1217 1207
1218 1208
1219 void JsonAstBuilder::VisitSwitchStatement(SwitchStatement* stmt) { 1209 void JsonAstBuilder::VisitSwitchStatement(SwitchStatement* stmt) {
1220 TagScope tag(this, "SwitchStatement"); 1210 TagScope tag(this, "SwitchStatement");
1221 } 1211 }
1222 1212
1223 1213
1224 void JsonAstBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) { 1214 void JsonAstBuilder::VisitDoWhileStatement(DoWhileStatement* stmt) {
1225 TagScope tag(this, "DoWhileStatement"); 1215 TagScope tag(this, "DoWhileStatement");
(...skipping 21 matching lines...) Expand all
1247 void JsonAstBuilder::VisitForInStatement(ForInStatement* stmt) { 1237 void JsonAstBuilder::VisitForInStatement(ForInStatement* stmt) {
1248 TagScope tag(this, "ForInStatement"); 1238 TagScope tag(this, "ForInStatement");
1249 Visit(stmt->each()); 1239 Visit(stmt->each());
1250 Visit(stmt->enumerable()); 1240 Visit(stmt->enumerable());
1251 Visit(stmt->body()); 1241 Visit(stmt->body());
1252 } 1242 }
1253 1243
1254 1244
1255 void JsonAstBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { 1245 void JsonAstBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) {
1256 TagScope tag(this, "TryCatchStatement"); 1246 TagScope tag(this, "TryCatchStatement");
1247 { AttributesScope attributes(this);
1248 AddAttribute("variable", stmt->variable()->name());
1249 }
1257 Visit(stmt->try_block()); 1250 Visit(stmt->try_block());
1258 Visit(stmt->catch_var());
1259 Visit(stmt->catch_block()); 1251 Visit(stmt->catch_block());
1260 } 1252 }
1261 1253
1262 1254
1263 void JsonAstBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 1255 void JsonAstBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
1264 TagScope tag(this, "TryFinallyStatement"); 1256 TagScope tag(this, "TryFinallyStatement");
1265 Visit(stmt->try_block()); 1257 Visit(stmt->try_block());
1266 Visit(stmt->finally_block()); 1258 Visit(stmt->finally_block());
1267 } 1259 }
1268 1260
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 void JsonAstBuilder::VisitObjectLiteral(ObjectLiteral* expr) { 1345 void JsonAstBuilder::VisitObjectLiteral(ObjectLiteral* expr) {
1354 TagScope tag(this, "ObjectLiteral"); 1346 TagScope tag(this, "ObjectLiteral");
1355 } 1347 }
1356 1348
1357 1349
1358 void JsonAstBuilder::VisitArrayLiteral(ArrayLiteral* expr) { 1350 void JsonAstBuilder::VisitArrayLiteral(ArrayLiteral* expr) {
1359 TagScope tag(this, "ArrayLiteral"); 1351 TagScope tag(this, "ArrayLiteral");
1360 } 1352 }
1361 1353
1362 1354
1363 void JsonAstBuilder::VisitCatchExtensionObject(CatchExtensionObject* expr) {
1364 TagScope tag(this, "CatchExtensionObject");
1365 Visit(expr->key());
1366 Visit(expr->value());
1367 }
1368
1369
1370 void JsonAstBuilder::VisitAssignment(Assignment* expr) { 1355 void JsonAstBuilder::VisitAssignment(Assignment* expr) {
1371 TagScope tag(this, "Assignment"); 1356 TagScope tag(this, "Assignment");
1372 { 1357 {
1373 AttributesScope attributes(this); 1358 AttributesScope attributes(this);
1374 AddAttribute("op", Token::Name(expr->op())); 1359 AddAttribute("op", Token::Name(expr->op()));
1375 } 1360 }
1376 Visit(expr->target()); 1361 Visit(expr->target());
1377 Visit(expr->value()); 1362 Visit(expr->value());
1378 } 1363 }
1379 1364
1380 1365
1381 void JsonAstBuilder::VisitThrow(Throw* expr) { 1366 void JsonAstBuilder::VisitThrow(Throw* expr) {
1382 TagScope tag(this, "Throw"); 1367 TagScope tag(this, "Throw");
1383 Visit(expr->exception()); 1368 Visit(expr->exception());
1384 } 1369 }
1385 1370
1386 1371
1387 void JsonAstBuilder::VisitProperty(Property* expr) { 1372 void JsonAstBuilder::VisitProperty(Property* expr) {
1388 TagScope tag(this, "Property"); 1373 TagScope tag(this, "Property");
1389 {
1390 AttributesScope attributes(this);
1391 AddAttribute("type", expr->is_synthetic() ? "SYNTHETIC" : "NORMAL");
1392 }
1393 Visit(expr->obj()); 1374 Visit(expr->obj());
1394 Visit(expr->key()); 1375 Visit(expr->key());
1395 } 1376 }
1396 1377
1397 1378
1398 void JsonAstBuilder::VisitCall(Call* expr) { 1379 void JsonAstBuilder::VisitCall(Call* expr) {
1399 TagScope tag(this, "Call"); 1380 TagScope tag(this, "Call");
1400 Visit(expr->expression()); 1381 Visit(expr->expression());
1401 VisitExpressions(expr->arguments()); 1382 VisitExpressions(expr->arguments());
1402 } 1383 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1484 AddAttribute("mode", Variable::Mode2String(decl->mode())); 1465 AddAttribute("mode", Variable::Mode2String(decl->mode()));
1485 } 1466 }
1486 Visit(decl->proxy()); 1467 Visit(decl->proxy());
1487 if (decl->fun() != NULL) Visit(decl->fun()); 1468 if (decl->fun() != NULL) Visit(decl->fun());
1488 } 1469 }
1489 1470
1490 1471
1491 #endif // DEBUG 1472 #endif // DEBUG
1492 1473
1493 } } // namespace v8::internal 1474 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/preparser-api.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698