Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: runtime/vm/ast_printer.cc

Issue 1011783005: Nicer AST formatting. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/ast_printer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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() { } 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 ISL_Print("(%s (scope \"%p\")", node->PrettyName(), node->scope()); 30 ISL_Print("(%s (scope \"%p\")", node->PrettyName(), node->scope());
30 for (int i = 0; i < node->length(); ++i) { 31 for (int i = 0; i < node->length(); ++i) {
31 ISL_Print("\n"); 32 ISL_Print("\n");
33 for (intptr_t i = 0; i < indent_; i++) {
34 ISL_Print(" ");
35 }
32 node->NodeAt(i)->Visit(this); 36 node->NodeAt(i)->Visit(this);
33 } 37 }
34 ISL_Print(")"); 38 ISL_Print(")");
39 indent_--;
35 } 40 }
36 41
37 42
38 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) { 43 void AstPrinter::VisitCloneContextNode(CloneContextNode* node) {
39 VisitGenericAstNode(node); 44 VisitGenericAstNode(node);
40 } 45 }
41 46
42 47
43 void AstPrinter::VisitArgumentListNode(ArgumentListNode* arguments) { 48 void AstPrinter::VisitArgumentListNode(ArgumentListNode* arguments) {
44 VisitGenericAstNode(arguments); 49 VisitGenericAstNode(arguments);
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 ASSERT(node_sequence != NULL); 547 ASSERT(node_sequence != NULL);
543 AstPrinter ast_printer; 548 AstPrinter ast_printer;
544 const char* function_name = 549 const char* function_name =
545 parsed_function.function().ToFullyQualifiedCString(); 550 parsed_function.function().ToFullyQualifiedCString();
546 ISL_Print("Ast for function '%s' {\n", function_name); 551 ISL_Print("Ast for function '%s' {\n", function_name);
547 node_sequence->Visit(&ast_printer); 552 node_sequence->Visit(&ast_printer);
548 ISL_Print("}\n"); 553 ISL_Print("}\n");
549 } 554 }
550 555
551 } // namespace dart 556 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/ast_printer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698