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

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

Issue 10448008: fix for index operation unparses (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix long line Created 8 years, 6 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 | « no previous file | 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) 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 class Unparser implements Visitor { 5 class Unparser implements Visitor {
6 StringBuffer sb; 6 StringBuffer sb;
7 final bool printDebugInfo; 7 final bool printDebugInfo;
8 8
9 Unparser([this.printDebugInfo = false]); 9 Unparser([this.printDebugInfo = false]);
10 10
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 visitReturn(Return node) { 173 visitReturn(Return node) {
174 add(node.beginToken.value); 174 add(node.beginToken.value);
175 if (node.hasExpression) { 175 if (node.hasExpression) {
176 sb.add(' '); 176 sb.add(' ');
177 visit(node.expression); 177 visit(node.expression);
178 } 178 }
179 if (node.endToken !== null) add(node.endToken.value); 179 if (node.endToken !== null) add(node.endToken.value);
180 } 180 }
181 181
182
183 unparseSendPart(Send node) { 182 unparseSendPart(Send node) {
184 if (node.isPrefix) { 183 if (node.isPrefix) {
185 visit(node.selector); 184 visit(node.selector);
186 } 185 }
187 if (node.receiver !== null) { 186 if (node.receiver !== null) {
188 visit(node.receiver); 187 visit(node.receiver);
189 if (node.selector is !Operator) sb.add('.'); 188 if (node.selector is !Operator) sb.add('.');
190 } 189 }
191 if (!node.isPrefix) { 190 if (!node.isPrefix && !node.isIndex) {
192 visit(node.selector); 191 visit(node.selector);
193 } 192 }
194 } 193 }
195 194
196 visitSend(Send node) { 195 visitSend(Send node) {
197 unparseSendPart(node); 196 unparseSendPart(node);
198 visit(node.argumentsNode); 197 visit(node.argumentsNode);
199 } 198 }
200 199
200 // Special case for assignments like "list[0] = 1".
ahe 2012/05/30 10:03:12 This should be a doc comment.
Roman 2012/05/30 10:44:04 Done.
201 visitListIndexSet(SendSet node) {
ahe 2012/05/30 10:03:12 This is not a visitor method. So it should be name
Roman 2012/05/30 10:44:04 Done.
202 visit(node.receiver);
203 sb.add('[');
204 sb.add(node.arguments.head);
205 sb.add(']');
206 add(node.assignmentOperator.token.value);
207 NodeList tailArguments = new NodeList(
Roman 2012/05/30 09:09:55 not sure about this one. beginToken and endToken w
ahe 2012/05/30 10:03:12 I don't like constructing fake AST nodes just for
Roman 2012/05/30 10:44:04 Done.
208 node.argumentsNode.beginToken, node.argumentsNode.nodes.tail,
209 node.argumentsNode.endToken, node.argumentsNode.delimiter);
210 visit(tailArguments);
211 }
212
201 visitSendSet(SendSet node) { 213 visitSendSet(SendSet node) {
202 unparseSendPart(node); 214 if (node.isIndex) {
203 add(node.assignmentOperator.token.value); 215 visitListIndexSet(node);
204 visit(node.argumentsNode); 216 } else {
217 unparseSendPart(node);
218 add(node.assignmentOperator.token.value);
219 visit(node.argumentsNode);
220 }
205 } 221 }
206 222
207 visitThrow(Throw node) { 223 visitThrow(Throw node) {
208 add(node.throwToken.value); 224 add(node.throwToken.value);
209 if (node.expression !== null) { 225 if (node.expression !== null) {
210 sb.add(' '); 226 sb.add(' ');
211 visit(node.expression); 227 visit(node.expression);
212 } 228 }
213 node.endToken.value.printOn(sb); 229 node.endToken.value.printOn(sb);
214 } 230 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 sb.add(' '); 419 sb.add(' ');
404 } 420 }
405 visit(node.name); 421 visit(node.name);
406 if (node.typeParameters !== null) { 422 if (node.typeParameters !== null) {
407 visit(node.typeParameters); 423 visit(node.typeParameters);
408 } 424 }
409 visit(node.formals); 425 visit(node.formals);
410 add(node.endToken.value); 426 add(node.endToken.value);
411 } 427 }
412 } 428 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698