| 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/log.h" | 8 #include "vm/log.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/os.h" | 10 #include "vm/os.h" |
| 11 #include "vm/parser.h" | 11 #include "vm/parser.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 AstPrinter::AstPrinter() : indent_(0) { } | 15 AstPrinter::AstPrinter() : indent_(0) { } |
| 16 | 16 |
| 17 | 17 |
| 18 AstPrinter::~AstPrinter() { } | 18 AstPrinter::~AstPrinter() { } |
| 19 | 19 |
| 20 | 20 |
| 21 void AstPrinter::VisitGenericAstNode(AstNode* node) { | 21 void AstPrinter::VisitGenericAstNode(AstNode* node) { |
| 22 ISL_Print("(%s ", node->PrettyName()); | 22 ISL_Print("(%s ", node->PrettyName()); |
| 23 node->VisitChildren(this); | 23 node->VisitChildren(this); |
| 24 ISL_Print(")"); | 24 ISL_Print(")"); |
| 25 } | 25 } |
| 26 | 26 |
| 27 | 27 |
| 28 void AstPrinter::VisitSequenceNode(SequenceNode* node) { | 28 void AstPrinter::VisitSequenceNode(SequenceNode* node) { |
| 29 indent_++; | 29 indent_++; |
| 30 ISL_Print("(%s (scope \"%p\")", node->PrettyName(), node->scope()); | 30 LocalScope* scope = node->scope(); |
| 31 ISL_Print("(%s (scope \"%p\"", node->PrettyName(), scope); |
| 32 if (scope != NULL) { |
| 33 ISL_Print(" loop %d", scope->loop_level()); |
| 34 if (scope->HasContextLevel()) { |
| 35 ISL_Print(" context %d captures %d", |
| 36 scope->context_level(), |
| 37 scope->num_context_variables()); |
| 38 } else { |
| 39 ASSERT(scope->num_context_variables() == 0); |
| 40 } |
| 41 } |
| 42 ISL_Print(")"); |
| 31 for (int i = 0; i < node->length(); ++i) { | 43 for (int i = 0; i < node->length(); ++i) { |
| 32 ISL_Print("\n"); | 44 ISL_Print("\n"); |
| 33 for (intptr_t p = 0; p < indent_; p++) { | 45 for (intptr_t p = 0; p < indent_; p++) { |
| 34 ISL_Print(" "); | 46 ISL_Print(" "); |
| 35 } | 47 } |
| 36 node->NodeAt(i)->Visit(this); | 48 node->NodeAt(i)->Visit(this); |
| 37 } | 49 } |
| 38 ISL_Print(")"); | 50 ISL_Print(")"); |
| 39 indent_--; | 51 indent_--; |
| 40 } | 52 } |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 ASSERT(node_sequence != NULL); | 559 ASSERT(node_sequence != NULL); |
| 548 AstPrinter ast_printer; | 560 AstPrinter ast_printer; |
| 549 const char* function_name = | 561 const char* function_name = |
| 550 parsed_function.function().ToFullyQualifiedCString(); | 562 parsed_function.function().ToFullyQualifiedCString(); |
| 551 ISL_Print("Ast for function '%s' {\n", function_name); | 563 ISL_Print("Ast for function '%s' {\n", function_name); |
| 552 node_sequence->Visit(&ast_printer); | 564 node_sequence->Visit(&ast_printer); |
| 553 ISL_Print("}\n"); | 565 ISL_Print("}\n"); |
| 554 } | 566 } |
| 555 | 567 |
| 556 } // namespace dart | 568 } // namespace dart |
| OLD | NEW |