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

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

Issue 10824280: Fix unparse of sendset and add Unparser constructor TODO (Closed) Base URL: https://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
« 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 // 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;
11 11
12 Unparser() { 12 Unparser() {
13 // TODO(smok): Move this to initializer once dart2js stops complaining
14 // about closures in initializers.
13 rename = (Node node) => null; 15 rename = (Node node) => null;
14 } 16 }
15 Unparser.withRenamer(this.rename); 17 Unparser.withRenamer(this.rename);
16 18
17 String unparse(Node node) { 19 String unparse(Node node) {
18 sb = new StringBuffer(); 20 sb = new StringBuffer();
19 visit(node); 21 visit(node);
20 return sb.toString(); 22 return sb.toString();
21 } 23 }
22 24
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 266 }
265 267
266 visitSendSet(SendSet node) { 268 visitSendSet(SendSet node) {
267 if (node.isPrefix) { 269 if (node.isPrefix) {
268 sb.add(' '); 270 sb.add(' ');
269 visit(node.assignmentOperator); 271 visit(node.assignmentOperator);
270 } 272 }
271 unparseSendReceiver(node); 273 unparseSendReceiver(node);
272 if (node.isIndex) { 274 if (node.isIndex) {
273 sb.add('['); 275 sb.add('[');
274 sb.add(node.arguments.head); 276 visit(node.arguments.head);
275 sb.add(']'); 277 sb.add(']');
276 if (!node.isPrefix) visit(node.assignmentOperator); 278 if (!node.isPrefix) visit(node.assignmentOperator);
277 unparseNodeListFrom(node.argumentsNode, node.argumentsNode.nodes.tail); 279 unparseNodeListFrom(node.argumentsNode, node.argumentsNode.nodes.tail);
278 } else { 280 } else {
279 visit(node.selector); 281 visit(node.selector);
280 if (!node.isPrefix) { 282 if (!node.isPrefix) {
281 visit(node.assignmentOperator); 283 visit(node.assignmentOperator);
282 if (node.assignmentOperator.source.slowToString() != '=') sb.add(' '); 284 if (node.assignmentOperator.source.slowToString() != '=') sb.add(' ');
283 } 285 }
284 visit(node.argumentsNode); 286 visit(node.argumentsNode);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 sb.add(' '); 483 sb.add(' ');
482 } 484 }
483 visit(node.name); 485 visit(node.name);
484 if (node.typeParameters !== null) { 486 if (node.typeParameters !== null) {
485 visit(node.typeParameters); 487 visit(node.typeParameters);
486 } 488 }
487 visit(node.formals); 489 visit(node.formals);
488 add(node.endToken.value); 490 add(node.endToken.value);
489 } 491 }
490 } 492 }
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