OLD | NEW |
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 Visit(node->enumerable()); | 194 Visit(node->enumerable()); |
195 Print(") "); | 195 Print(") "); |
196 Visit(node->body()); | 196 Visit(node->body()); |
197 } | 197 } |
198 | 198 |
199 | 199 |
200 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) { | 200 void PrettyPrinter::VisitTryCatchStatement(TryCatchStatement* node) { |
201 Print("try "); | 201 Print("try "); |
202 Visit(node->try_block()); | 202 Visit(node->try_block()); |
203 Print(" catch ("); | 203 Print(" catch ("); |
204 Visit(node->catch_var()); | 204 const bool quote = false; |
| 205 PrintLiteral(node->name(), quote); |
205 Print(") "); | 206 Print(") "); |
206 Visit(node->catch_block()); | 207 Visit(node->catch_block()); |
207 } | 208 } |
208 | 209 |
209 | 210 |
210 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { | 211 void PrettyPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { |
211 Print("try "); | 212 Print("try "); |
212 Visit(node->try_block()); | 213 Visit(node->try_block()); |
213 Print(" finally "); | 214 Print(" finally "); |
214 Visit(node->finally_block()); | 215 Visit(node->finally_block()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) { | 276 void PrettyPrinter::VisitArrayLiteral(ArrayLiteral* node) { |
276 Print("[ "); | 277 Print("[ "); |
277 for (int i = 0; i < node->values()->length(); i++) { | 278 for (int i = 0; i < node->values()->length(); i++) { |
278 if (i != 0) Print(","); | 279 if (i != 0) Print(","); |
279 Visit(node->values()->at(i)); | 280 Visit(node->values()->at(i)); |
280 } | 281 } |
281 Print(" ]"); | 282 Print(" ]"); |
282 } | 283 } |
283 | 284 |
284 | 285 |
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) { | 286 void PrettyPrinter::VisitSlot(Slot* node) { |
295 switch (node->type()) { | 287 switch (node->type()) { |
296 case Slot::PARAMETER: | 288 case Slot::PARAMETER: |
297 Print("parameter[%d]", node->index()); | 289 Print("parameter[%d]", node->index()); |
298 break; | 290 break; |
299 case Slot::LOCAL: | 291 case Slot::LOCAL: |
300 Print("local[%d]", node->index()); | 292 Print("local[%d]", node->index()); |
301 break; | 293 break; |
302 case Slot::CONTEXT: | 294 case Slot::CONTEXT: |
303 Print("context[%d]", node->index()); | 295 Print("context[%d]", node->index()); |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 IndentedScope indent(this, "FOR IN"); | 847 IndentedScope indent(this, "FOR IN"); |
856 PrintIndentedVisit("FOR", node->each()); | 848 PrintIndentedVisit("FOR", node->each()); |
857 PrintIndentedVisit("IN", node->enumerable()); | 849 PrintIndentedVisit("IN", node->enumerable()); |
858 PrintIndentedVisit("BODY", node->body()); | 850 PrintIndentedVisit("BODY", node->body()); |
859 } | 851 } |
860 | 852 |
861 | 853 |
862 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { | 854 void AstPrinter::VisitTryCatchStatement(TryCatchStatement* node) { |
863 IndentedScope indent(this, "TRY CATCH"); | 855 IndentedScope indent(this, "TRY CATCH"); |
864 PrintIndentedVisit("TRY", node->try_block()); | 856 PrintIndentedVisit("TRY", node->try_block()); |
865 PrintIndentedVisit("CATCHVAR", node->catch_var()); | 857 const bool quote = false; |
| 858 PrintLiteralIndented("CATCHVAR", node->name(), quote); |
866 PrintIndentedVisit("CATCH", node->catch_block()); | 859 PrintIndentedVisit("CATCH", node->catch_block()); |
867 } | 860 } |
868 | 861 |
869 | 862 |
870 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { | 863 void AstPrinter::VisitTryFinallyStatement(TryFinallyStatement* node) { |
871 IndentedScope indent(this, "TRY FINALLY"); | 864 IndentedScope indent(this, "TRY FINALLY"); |
872 PrintIndentedVisit("TRY", node->try_block()); | 865 PrintIndentedVisit("TRY", node->try_block()); |
873 PrintIndentedVisit("FINALLY", node->finally_block()); | 866 PrintIndentedVisit("FINALLY", node->finally_block()); |
874 } | 867 } |
875 | 868 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 IndentedScope indent(this, "ARRAY LITERAL"); | 948 IndentedScope indent(this, "ARRAY LITERAL"); |
956 if (node->values()->length() > 0) { | 949 if (node->values()->length() > 0) { |
957 IndentedScope indent(this, "VALUES"); | 950 IndentedScope indent(this, "VALUES"); |
958 for (int i = 0; i < node->values()->length(); i++) { | 951 for (int i = 0; i < node->values()->length(); i++) { |
959 Visit(node->values()->at(i)); | 952 Visit(node->values()->at(i)); |
960 } | 953 } |
961 } | 954 } |
962 } | 955 } |
963 | 956 |
964 | 957 |
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) { | 958 void AstPrinter::VisitSlot(Slot* node) { |
973 PrintIndented("SLOT "); | 959 PrintIndented("SLOT "); |
974 PrettyPrinter::VisitSlot(node); | 960 PrettyPrinter::VisitSlot(node); |
975 Print("\n"); | 961 Print("\n"); |
976 } | 962 } |
977 | 963 |
978 | 964 |
979 void AstPrinter::VisitVariableProxy(VariableProxy* node) { | 965 void AstPrinter::VisitVariableProxy(VariableProxy* node) { |
980 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name()); | 966 PrintLiteralWithModeIndented("VAR PROXY", node->AsVariable(), node->name()); |
981 Variable* var = node->var(); | 967 Variable* var = node->var(); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 void JsonAstBuilder::VisitForInStatement(ForInStatement* stmt) { | 1233 void JsonAstBuilder::VisitForInStatement(ForInStatement* stmt) { |
1248 TagScope tag(this, "ForInStatement"); | 1234 TagScope tag(this, "ForInStatement"); |
1249 Visit(stmt->each()); | 1235 Visit(stmt->each()); |
1250 Visit(stmt->enumerable()); | 1236 Visit(stmt->enumerable()); |
1251 Visit(stmt->body()); | 1237 Visit(stmt->body()); |
1252 } | 1238 } |
1253 | 1239 |
1254 | 1240 |
1255 void JsonAstBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { | 1241 void JsonAstBuilder::VisitTryCatchStatement(TryCatchStatement* stmt) { |
1256 TagScope tag(this, "TryCatchStatement"); | 1242 TagScope tag(this, "TryCatchStatement"); |
| 1243 { AttributesScope attributes(this); |
| 1244 AddAttribute("variable", stmt->name()); |
| 1245 } |
1257 Visit(stmt->try_block()); | 1246 Visit(stmt->try_block()); |
1258 Visit(stmt->catch_var()); | |
1259 Visit(stmt->catch_block()); | 1247 Visit(stmt->catch_block()); |
1260 } | 1248 } |
1261 | 1249 |
1262 | 1250 |
1263 void JsonAstBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { | 1251 void JsonAstBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) { |
1264 TagScope tag(this, "TryFinallyStatement"); | 1252 TagScope tag(this, "TryFinallyStatement"); |
1265 Visit(stmt->try_block()); | 1253 Visit(stmt->try_block()); |
1266 Visit(stmt->finally_block()); | 1254 Visit(stmt->finally_block()); |
1267 } | 1255 } |
1268 | 1256 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 void JsonAstBuilder::VisitObjectLiteral(ObjectLiteral* expr) { | 1341 void JsonAstBuilder::VisitObjectLiteral(ObjectLiteral* expr) { |
1354 TagScope tag(this, "ObjectLiteral"); | 1342 TagScope tag(this, "ObjectLiteral"); |
1355 } | 1343 } |
1356 | 1344 |
1357 | 1345 |
1358 void JsonAstBuilder::VisitArrayLiteral(ArrayLiteral* expr) { | 1346 void JsonAstBuilder::VisitArrayLiteral(ArrayLiteral* expr) { |
1359 TagScope tag(this, "ArrayLiteral"); | 1347 TagScope tag(this, "ArrayLiteral"); |
1360 } | 1348 } |
1361 | 1349 |
1362 | 1350 |
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) { | 1351 void JsonAstBuilder::VisitAssignment(Assignment* expr) { |
1371 TagScope tag(this, "Assignment"); | 1352 TagScope tag(this, "Assignment"); |
1372 { | 1353 { |
1373 AttributesScope attributes(this); | 1354 AttributesScope attributes(this); |
1374 AddAttribute("op", Token::Name(expr->op())); | 1355 AddAttribute("op", Token::Name(expr->op())); |
1375 } | 1356 } |
1376 Visit(expr->target()); | 1357 Visit(expr->target()); |
1377 Visit(expr->value()); | 1358 Visit(expr->value()); |
1378 } | 1359 } |
1379 | 1360 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |