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

Side by Side Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10834374: Add a field to ClassNode that holds a NodeList of its members. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Returns null if no need to rename a node. 5 // Returns null if no need to rename a node.
6 typedef String Renamer(Node node); 6 typedef String Renamer(Node node);
7 7
8 class Unparser implements Visitor { 8 class Unparser implements Visitor {
9 Renamer rename; 9 Renamer rename;
10 StringBuffer sb; 10 StringBuffer sb;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 visit(node.expression); 53 visit(node.expression);
54 } 54 }
55 55
56 visitCascadeReceiver(CascadeReceiver node) { 56 visitCascadeReceiver(CascadeReceiver node) {
57 visit(node.expression); 57 visit(node.expression);
58 } 58 }
59 59
60 visitClassNode(ClassNode node) { 60 visitClassNode(ClassNode node) {
61 addToken(node.beginToken); 61 addToken(node.beginToken);
62 visit(node.name); 62 visit(node.name);
63 if (node.typeParameters != null) {
64 visit(node.typeParameters);
65 }
63 sb.add(' '); 66 sb.add(' ');
64 if (node.extendsKeyword !== null) { 67 if (node.extendsKeyword !== null) {
65 addToken(node.extendsKeyword); 68 addToken(node.extendsKeyword);
66 visit(node.superclass); 69 visit(node.superclass);
67 sb.add(' '); 70 sb.add(' ');
68 } 71 }
69 visit(node.interfaces); 72 visit(node.interfaces);
70 if (node.defaultClause !== null) { 73 if (node.defaultClause !== null) {
71 visit(node.defaultClause); 74 visit(node.defaultClause);
72 sb.add(' '); 75 sb.add(' ');
73 } 76 }
74 sb.add('{\n'); 77 sb.add('{\n');
78 NodeList body = node.body;
79 if (body != null) {
80 Link nodes = body.nodes;
81 if (!nodes.isEmpty()) {
82 String indent = " ";
83 sb.add(indent);
84 visit(nodes.head);
85 sb.add("\n");
86 for (Link node = nodes.tail; !node.isEmpty(); node = node.tail) {
87 sb.add(indent);
88 visit(node.head);
89 sb.add("\n");
90 }
91 }
92 }
75 sb.add('}\n'); 93 sb.add('}\n');
76 } 94 }
77 95
78 visitConditional(Conditional node) { 96 visitConditional(Conditional node) {
79 visit(node.condition); 97 visit(node.condition);
80 add(node.questionToken.value); 98 add(node.questionToken.value);
81 visit(node.thenExpression); 99 visit(node.thenExpression);
82 add(node.colonToken.value); 100 add(node.colonToken.value);
83 visit(node.elseExpression); 101 visit(node.elseExpression);
84 } 102 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 sb.add(' '); 506 sb.add(' ');
489 } 507 }
490 visit(node.name); 508 visit(node.name);
491 if (node.typeParameters !== null) { 509 if (node.typeParameters !== null) {
492 visit(node.typeParameters); 510 visit(node.typeParameters);
493 } 511 }
494 visit(node.formals); 512 visit(node.formals);
495 add(node.endToken.value); 513 add(node.endToken.value);
496 } 514 }
497 } 515 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698