| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/ast_printer.h" | 5 #include "vm/ast_printer.h" |
| 6 | 6 |
| 7 #include "vm/handles.h" | 7 #include "vm/handles.h" |
| 8 #include "vm/object.h" | 8 #include "vm/object.h" |
| 9 #include "vm/os.h" | 9 #include "vm/os.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| 11 | 11 |
| 12 namespace dart { | 12 namespace dart { |
| 13 | 13 |
| 14 AstPrinter::AstPrinter() { } | 14 AstPrinter::AstPrinter() { } |
| 15 | 15 |
| 16 | 16 |
| 17 AstPrinter::~AstPrinter() { } | 17 AstPrinter::~AstPrinter() { } |
| 18 | 18 |
| 19 | 19 |
| 20 void AstPrinter::VisitGenericAstNode(AstNode* node) { | 20 void AstPrinter::VisitGenericAstNode(AstNode* node) { |
| 21 OS::Print("(%s ", node->PrettyName()); | 21 OS::Print("(%s ", node->PrettyName()); |
| 22 node->VisitChildren(this); | 22 node->VisitChildren(this); |
| 23 OS::Print(")"); | 23 OS::Print(")"); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 void AstPrinter::VisitSequenceNode(SequenceNode* node) { | 27 void AstPrinter::VisitSequenceNode(SequenceNode* node) { |
| 28 // TODO(regis): Make the output more readable by indenting the nested | |
| 29 // sequences. This could be achieved using a AstPrinterContext similar to the | |
| 30 // CodeGeneratorContext. | |
| 31 OS::Print("(%s (scope \"%p\")", node->PrettyName(), node->scope()); | 28 OS::Print("(%s (scope \"%p\")", node->PrettyName(), node->scope()); |
| 32 for (int i = 0; i < node->length(); ++i) { | 29 for (int i = 0; i < node->length(); ++i) { |
| 33 OS::Print("\n"); | 30 OS::Print("\n"); |
| 34 node->NodeAt(i)->Visit(this); | 31 node->NodeAt(i)->Visit(this); |
| 35 } | 32 } |
| 36 OS::Print(")"); | 33 OS::Print(")"); |
| 37 } | 34 } |
| 38 | 35 |
| 39 | 36 |
| 40 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { | 37 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 ASSERT(node_sequence != NULL); | 494 ASSERT(node_sequence != NULL); |
| 498 AstPrinter ast_printer; | 495 AstPrinter ast_printer; |
| 499 const char* function_name = | 496 const char* function_name = |
| 500 parsed_function.function().ToFullyQualifiedCString(); | 497 parsed_function.function().ToFullyQualifiedCString(); |
| 501 OS::Print("Ast for function '%s' {\n", function_name); | 498 OS::Print("Ast for function '%s' {\n", function_name); |
| 502 node_sequence->Visit(&ast_printer); | 499 node_sequence->Visit(&ast_printer); |
| 503 OS::Print("}\n"); | 500 OS::Print("}\n"); |
| 504 } | 501 } |
| 505 | 502 |
| 506 } // namespace dart | 503 } // namespace dart |
| OLD | NEW |