| 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("(%d: %s ", node->id(), node->Name()); | 21 OS::Print("(%s ", node->Name()); |
| 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_sequence) { | 27 void AstPrinter::VisitSequenceNode(SequenceNode* node_sequence) { |
| 28 // TODO(regis): Make the output more readable by indenting the nested | 28 // TODO(regis): Make the output more readable by indenting the nested |
| 29 // sequences. This could be achieved using a AstPrinterContext similar to the | 29 // sequences. This could be achieved using a AstPrinterContext similar to the |
| 30 // CodeGeneratorContext. | 30 // CodeGeneratorContext. |
| 31 ASSERT(node_sequence != NULL); | 31 ASSERT(node_sequence != NULL); |
| 32 for (int i = 0; i < node_sequence->length(); i++) { | 32 for (int i = 0; i < node_sequence->length(); i++) { |
| 33 OS::Print("id %d, scope 0x%x: ", | 33 OS::Print("scope 0x%x: ", |
| 34 node_sequence->NodeAt(i)->id(), | |
| 35 node_sequence->scope()); | 34 node_sequence->scope()); |
| 36 node_sequence->NodeAt(i)->Visit(this); | 35 node_sequence->NodeAt(i)->Visit(this); |
| 37 OS::Print("\n"); | 36 OS::Print("\n"); |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 | 40 |
| 42 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { | 41 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { |
| 43 VisitGenericAstNode(node); | 42 VisitGenericAstNode(node); |
| 44 } | 43 } |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 ASSERT(node_sequence != NULL); | 471 ASSERT(node_sequence != NULL); |
| 473 AstPrinter ast_printer; | 472 AstPrinter ast_printer; |
| 474 const char* function_name = | 473 const char* function_name = |
| 475 parsed_function.function().ToFullyQualifiedCString(); | 474 parsed_function.function().ToFullyQualifiedCString(); |
| 476 OS::Print("Ast for function '%s' {\n", function_name); | 475 OS::Print("Ast for function '%s' {\n", function_name); |
| 477 node_sequence->Visit(&ast_printer); | 476 node_sequence->Visit(&ast_printer); |
| 478 OS::Print("}\n"); | 477 OS::Print("}\n"); |
| 479 } | 478 } |
| 480 | 479 |
| 481 } // namespace dart | 480 } // namespace dart |
| OLD | NEW |