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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 FindStatements(node->statements()); | 94 FindStatements(node->statements()); |
95 } | 95 } |
96 | 96 |
97 | 97 |
98 void CallPrinter::VisitVariableDeclaration(VariableDeclaration* node) {} | 98 void CallPrinter::VisitVariableDeclaration(VariableDeclaration* node) {} |
99 | 99 |
100 | 100 |
101 void CallPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {} | 101 void CallPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) {} |
102 | 102 |
103 | 103 |
104 void CallPrinter::VisitImportDeclaration(ImportDeclaration* node) { | |
105 } | |
106 | |
107 | |
108 void CallPrinter::VisitExpressionStatement(ExpressionStatement* node) { | 104 void CallPrinter::VisitExpressionStatement(ExpressionStatement* node) { |
109 Find(node->expression()); | 105 Find(node->expression()); |
110 } | 106 } |
111 | 107 |
112 | 108 |
113 void CallPrinter::VisitEmptyStatement(EmptyStatement* node) {} | 109 void CallPrinter::VisitEmptyStatement(EmptyStatement* node) {} |
114 | 110 |
115 | 111 |
116 void CallPrinter::VisitSloppyBlockFunctionStatement( | 112 void CallPrinter::VisitSloppyBlockFunctionStatement( |
117 SloppyBlockFunctionStatement* node) { | 113 SloppyBlockFunctionStatement* node) { |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 503 |
508 void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { | 504 void PrettyPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { |
509 Print("function "); | 505 Print("function "); |
510 PrintLiteral(node->proxy()->name(), false); | 506 PrintLiteral(node->proxy()->name(), false); |
511 Print(" = "); | 507 Print(" = "); |
512 PrintFunctionLiteral(node->fun()); | 508 PrintFunctionLiteral(node->fun()); |
513 Print(";"); | 509 Print(";"); |
514 } | 510 } |
515 | 511 |
516 | 512 |
517 void PrettyPrinter::VisitImportDeclaration(ImportDeclaration* node) { | |
518 Print("import "); | |
519 PrintLiteral(node->proxy()->name(), false); | |
520 Print(" from "); | |
521 PrintLiteral(node->module_specifier()->string(), true); | |
522 Print(";"); | |
523 } | |
524 | |
525 | |
526 void PrettyPrinter::VisitExpressionStatement(ExpressionStatement* node) { | 513 void PrettyPrinter::VisitExpressionStatement(ExpressionStatement* node) { |
527 Visit(node->expression()); | 514 Visit(node->expression()); |
528 Print(";"); | 515 Print(";"); |
529 } | 516 } |
530 | 517 |
531 | 518 |
532 void PrettyPrinter::VisitEmptyStatement(EmptyStatement* node) { | 519 void PrettyPrinter::VisitEmptyStatement(EmptyStatement* node) { |
533 Print(";"); | 520 Print(";"); |
534 } | 521 } |
535 | 522 |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 // TODO(svenpanne) Start with IndentedScope. | 1274 // TODO(svenpanne) Start with IndentedScope. |
1288 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { | 1275 void AstPrinter::VisitFunctionDeclaration(FunctionDeclaration* node) { |
1289 PrintIndented("FUNCTION "); | 1276 PrintIndented("FUNCTION "); |
1290 PrintLiteral(node->proxy()->name(), true); | 1277 PrintLiteral(node->proxy()->name(), true); |
1291 Print(" = function "); | 1278 Print(" = function "); |
1292 PrintLiteral(node->fun()->name(), false); | 1279 PrintLiteral(node->fun()->name(), false); |
1293 Print("\n"); | 1280 Print("\n"); |
1294 } | 1281 } |
1295 | 1282 |
1296 | 1283 |
1297 void AstPrinter::VisitImportDeclaration(ImportDeclaration* node) { | |
1298 IndentedScope indent(this, "IMPORT", node->position()); | |
1299 PrintLiteralIndented("NAME", node->proxy()->name(), true); | |
1300 PrintLiteralIndented("FROM", node->module_specifier()->string(), true); | |
1301 } | |
1302 | |
1303 | |
1304 void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) { | 1284 void AstPrinter::VisitExpressionStatement(ExpressionStatement* node) { |
1305 IndentedScope indent(this, "EXPRESSION STATEMENT", node->position()); | 1285 IndentedScope indent(this, "EXPRESSION STATEMENT", node->position()); |
1306 Visit(node->expression()); | 1286 Visit(node->expression()); |
1307 } | 1287 } |
1308 | 1288 |
1309 | 1289 |
1310 void AstPrinter::VisitEmptyStatement(EmptyStatement* node) { | 1290 void AstPrinter::VisitEmptyStatement(EmptyStatement* node) { |
1311 IndentedScope indent(this, "EMPTY", node->position()); | 1291 IndentedScope indent(this, "EMPTY", node->position()); |
1312 } | 1292 } |
1313 | 1293 |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 | 1717 |
1738 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { | 1718 void AstPrinter::VisitRewritableExpression(RewritableExpression* node) { |
1739 Visit(node->expression()); | 1719 Visit(node->expression()); |
1740 } | 1720 } |
1741 | 1721 |
1742 | 1722 |
1743 #endif // DEBUG | 1723 #endif // DEBUG |
1744 | 1724 |
1745 } // namespace internal | 1725 } // namespace internal |
1746 } // namespace v8 | 1726 } // namespace v8 |
OLD | NEW |