OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ast/prettyprinter.h" | 5 #include "src/ast/prettyprinter.h" |
6 | 6 |
7 #include <stdarg.h> | 7 #include <stdarg.h> |
8 | 8 |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 | 1185 |
1186 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { | 1186 void AstPrinter::PrintIndentedVisit(const char* s, AstNode* node) { |
1187 IndentedScope indent(this, s, node->position()); | 1187 IndentedScope indent(this, s, node->position()); |
1188 Visit(node); | 1188 Visit(node); |
1189 } | 1189 } |
1190 | 1190 |
1191 | 1191 |
1192 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { | 1192 const char* AstPrinter::PrintProgram(FunctionLiteral* program) { |
1193 Init(); | 1193 Init(); |
1194 { IndentedScope indent(this, "FUNC", program->position()); | 1194 { IndentedScope indent(this, "FUNC", program->position()); |
| 1195 PrintIndented("KIND"); |
| 1196 Print(" %d\n", program->kind()); |
| 1197 PrintIndented("YIELD COUNT"); |
| 1198 Print(" %d\n", program->yield_count()); |
1195 PrintLiteralIndented("NAME", program->name(), true); | 1199 PrintLiteralIndented("NAME", program->name(), true); |
1196 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); | 1200 PrintLiteralIndented("INFERRED NAME", program->inferred_name(), true); |
1197 PrintParameters(program->scope()); | 1201 PrintParameters(program->scope()); |
1198 PrintDeclarations(program->scope()->declarations()); | 1202 PrintDeclarations(program->scope()->declarations()); |
1199 PrintStatements(program->body()); | 1203 PrintStatements(program->body()); |
1200 } | 1204 } |
1201 return Output(); | 1205 return Output(); |
1202 } | 1206 } |
1203 | 1207 |
1204 | 1208 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 } else { | 1357 } else { |
1354 IndentedScope indent(this, "CASE", clause->position()); | 1358 IndentedScope indent(this, "CASE", clause->position()); |
1355 Visit(clause->label()); | 1359 Visit(clause->label()); |
1356 PrintStatements(clause->statements()); | 1360 PrintStatements(clause->statements()); |
1357 } | 1361 } |
1358 } | 1362 } |
1359 | 1363 |
1360 | 1364 |
1361 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { | 1365 void AstPrinter::VisitDoWhileStatement(DoWhileStatement* node) { |
1362 IndentedScope indent(this, "DO", node->position()); | 1366 IndentedScope indent(this, "DO", node->position()); |
| 1367 PrintIndented("YIELD COUNT"); |
| 1368 Print(" %d\n", node->yield_count()); |
1363 PrintLabelsIndented(node->labels()); | 1369 PrintLabelsIndented(node->labels()); |
1364 PrintIndentedVisit("BODY", node->body()); | 1370 PrintIndentedVisit("BODY", node->body()); |
1365 PrintIndentedVisit("COND", node->cond()); | 1371 PrintIndentedVisit("COND", node->cond()); |
1366 } | 1372 } |
1367 | 1373 |
1368 | 1374 |
1369 void AstPrinter::VisitWhileStatement(WhileStatement* node) { | 1375 void AstPrinter::VisitWhileStatement(WhileStatement* node) { |
1370 IndentedScope indent(this, "WHILE", node->position()); | 1376 IndentedScope indent(this, "WHILE", node->position()); |
| 1377 PrintIndented("YIELD COUNT"); |
| 1378 Print(" %d\n", node->yield_count()); |
1371 PrintLabelsIndented(node->labels()); | 1379 PrintLabelsIndented(node->labels()); |
1372 PrintIndentedVisit("COND", node->cond()); | 1380 PrintIndentedVisit("COND", node->cond()); |
1373 PrintIndentedVisit("BODY", node->body()); | 1381 PrintIndentedVisit("BODY", node->body()); |
1374 } | 1382 } |
1375 | 1383 |
1376 | 1384 |
1377 void AstPrinter::VisitForStatement(ForStatement* node) { | 1385 void AstPrinter::VisitForStatement(ForStatement* node) { |
1378 IndentedScope indent(this, "FOR", node->position()); | 1386 IndentedScope indent(this, "FOR", node->position()); |
| 1387 PrintIndented("YIELD COUNT"); |
| 1388 Print(" %d\n", node->yield_count()); |
1379 PrintLabelsIndented(node->labels()); | 1389 PrintLabelsIndented(node->labels()); |
1380 if (node->init()) PrintIndentedVisit("INIT", node->init()); | 1390 if (node->init()) PrintIndentedVisit("INIT", node->init()); |
1381 if (node->cond()) PrintIndentedVisit("COND", node->cond()); | 1391 if (node->cond()) PrintIndentedVisit("COND", node->cond()); |
1382 PrintIndentedVisit("BODY", node->body()); | 1392 PrintIndentedVisit("BODY", node->body()); |
1383 if (node->next()) PrintIndentedVisit("NEXT", node->next()); | 1393 if (node->next()) PrintIndentedVisit("NEXT", node->next()); |
1384 } | 1394 } |
1385 | 1395 |
1386 | 1396 |
1387 void AstPrinter::VisitForInStatement(ForInStatement* node) { | 1397 void AstPrinter::VisitForInStatement(ForInStatement* node) { |
1388 IndentedScope indent(this, "FOR IN", node->position()); | 1398 IndentedScope indent(this, "FOR IN", node->position()); |
| 1399 PrintIndented("YIELD COUNT"); |
| 1400 Print(" %d\n", node->yield_count()); |
1389 PrintIndentedVisit("FOR", node->each()); | 1401 PrintIndentedVisit("FOR", node->each()); |
1390 PrintIndentedVisit("IN", node->enumerable()); | 1402 PrintIndentedVisit("IN", node->enumerable()); |
1391 PrintIndentedVisit("BODY", node->body()); | 1403 PrintIndentedVisit("BODY", node->body()); |
1392 } | 1404 } |
1393 | 1405 |
1394 | 1406 |
1395 void AstPrinter::VisitForOfStatement(ForOfStatement* node) { | 1407 void AstPrinter::VisitForOfStatement(ForOfStatement* node) { |
1396 IndentedScope indent(this, "FOR OF", node->position()); | 1408 IndentedScope indent(this, "FOR OF", node->position()); |
| 1409 PrintIndented("YIELD COUNT"); |
| 1410 Print(" %d\n", node->yield_count()); |
1397 PrintIndentedVisit("FOR", node->each()); | 1411 PrintIndentedVisit("FOR", node->each()); |
1398 PrintIndentedVisit("OF", node->iterable()); | 1412 PrintIndentedVisit("OF", node->iterable()); |
1399 PrintIndentedVisit("BODY", node->body()); | 1413 PrintIndentedVisit("BODY", node->body()); |
1400 PrintIndentedVisit("INIT", node->assign_iterator()); | 1414 PrintIndentedVisit("INIT", node->assign_iterator()); |
1401 PrintIndentedVisit("NEXT", node->next_result()); | 1415 PrintIndentedVisit("NEXT", node->next_result()); |
1402 PrintIndentedVisit("EACH", node->assign_each()); | 1416 PrintIndentedVisit("EACH", node->assign_each()); |
1403 PrintIndentedVisit("DONE", node->result_done()); | 1417 PrintIndentedVisit("DONE", node->result_done()); |
1404 } | 1418 } |
1405 | 1419 |
1406 | 1420 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 | 1719 |
1706 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { | 1720 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { |
1707 Visit(node->expression()); | 1721 Visit(node->expression()); |
1708 } | 1722 } |
1709 | 1723 |
1710 | 1724 |
1711 #endif // DEBUG | 1725 #endif // DEBUG |
1712 | 1726 |
1713 } // namespace internal | 1727 } // namespace internal |
1714 } // namespace v8 | 1728 } // namespace v8 |
OLD | NEW |