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

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

Issue 10919033: Rework Unparser/unparse StringBuffer management. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCascade(Cascade node); 8 R visitCascade(Cascade node);
9 R visitCascadeReceiver(CascadeReceiver node); 9 R visitCascadeReceiver(CascadeReceiver node);
10 R visitCaseMatch(CaseMatch node); 10 R visitCaseMatch(CaseMatch node);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 hashCode() => _hashCode; 93 hashCode() => _hashCode;
94 94
95 abstract accept(Visitor visitor); 95 abstract accept(Visitor visitor);
96 96
97 abstract visitChildren(Visitor visitor); 97 abstract visitChildren(Visitor visitor);
98 98
99 /** 99 /**
100 * Returns this node unparsed to Dart source string. 100 * Returns this node unparsed to Dart source string.
101 */ 101 */
102 toString() => unparse(); 102 toString() => unparse(this);
103 103
104 /** 104 /**
105 * Returns Xml-like tree representation of this node. 105 * Returns Xml-like tree representation of this node.
106 */ 106 */
107 toDebugString() { 107 toDebugString() {
108 return PrettyPrinter.prettyPrint(this); 108 return PrettyPrinter.prettyPrint(this);
109 } 109 }
110 110
111 String getObjectDescription() => super.toString(); 111 String getObjectDescription() => super.toString();
112 112
113 String unparse() {
114 Unparser unparser = new Unparser();
115 try {
116 return unparser.unparse(this);
117 } catch (e, trace) {
ahe 2012/09/18 13:29:18 Why was this removed? I'm looking at this stack t
Anton Muhin 2012/09/19 09:38:43 Sorry, I don't immediately see what's the problem:
ahe 2012/09/19 10:33:12 The code is there to handle when something that is
118 print(trace);
119 return '<<unparse error: ${getObjectDescription()}: ${unparser.sb}>>';
120 }
121 }
122
123 abstract Token getBeginToken(); 113 abstract Token getBeginToken();
124 114
125 abstract Token getEndToken(); 115 abstract Token getEndToken();
126 116
127 Block asBlock() => null; 117 Block asBlock() => null;
128 BreakStatement asBreakStatement() => null; 118 BreakStatement asBreakStatement() => null;
129 Cascade asCascade() => null; 119 Cascade asCascade() => null;
130 CascadeReceiver asCascadeReceiver() => null; 120 CascadeReceiver asCascadeReceiver() => null;
131 CaseMatch asCaseMatch() => null; 121 CaseMatch asCaseMatch() => null;
132 CatchBlock asCatchBlock() => null; 122 CatchBlock asCatchBlock() => null;
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1761 * argument). 1751 * argument).
1762 * 1752 *
1763 * TODO(ahe): This method is controversial, the team needs to discuss 1753 * TODO(ahe): This method is controversial, the team needs to discuss
1764 * if top-level methods are acceptable and what naming conventions to 1754 * if top-level methods are acceptable and what naming conventions to
1765 * use. 1755 * use.
1766 */ 1756 */
1767 initializerDo(Node node, f(Node node)) { 1757 initializerDo(Node node, f(Node node)) {
1768 SendSet send = node.asSendSet(); 1758 SendSet send = node.asSendSet();
1769 if (send !== null) return f(send.arguments.head); 1759 if (send !== null) return f(send.arguments.head);
1770 } 1760 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/emitter.dart ('k') | lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698