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

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

Issue 10543051: Fix unparse for empty initializer or conditionStatement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 visitExpressionStatement(ExpressionStatement node) { 71 visitExpressionStatement(ExpressionStatement node) {
72 visit(node.expression); 72 visit(node.expression);
73 add(node.endToken.value); 73 add(node.endToken.value);
74 } 74 }
75 75
76 visitFor(For node) { 76 visitFor(For node) {
77 add(node.forToken.value); 77 add(node.forToken.value);
78 sb.add('('); 78 sb.add('(');
79 visit(node.initializer); 79 visitPart(part) {
Anton Muhin 2012/06/07 15:31:29 another option would be to yield empty statements
80 visit(node.conditionStatement); 80 if (part === null) {
81 sb.add(';');
82 } else {
83 visit(part);
84 }
85 }
86 visitPart(node.initializer);
87 visitPart(node.conditionStatement);
81 visit(node.update); 88 visit(node.update);
82 sb.add(')'); 89 sb.add(')');
83 visit(node.body); 90 visit(node.body);
84 } 91 }
85 92
86 visitFunctionDeclaration(FunctionDeclaration node) { 93 visitFunctionDeclaration(FunctionDeclaration node) {
87 visit(node.function); 94 visit(node.function);
88 } 95 }
89 96
90 visitFunctionExpression(FunctionExpression node) { 97 visitFunctionExpression(FunctionExpression node) {
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 sb.add(' '); 445 sb.add(' ');
439 } 446 }
440 visit(node.name); 447 visit(node.name);
441 if (node.typeParameters !== null) { 448 if (node.typeParameters !== null) {
442 visit(node.typeParameters); 449 visit(node.typeParameters);
443 } 450 }
444 visit(node.formals); 451 visit(node.formals);
445 add(node.endToken.value); 452 add(node.endToken.value);
446 } 453 }
447 } 454 }
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