| OLD | NEW |
| 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 Printer implements NodeVisitor { | 5 class Printer implements NodeVisitor { |
| 6 final bool shouldCompressOutput = false; | 6 final bool shouldCompressOutput; |
| 7 leg.Compiler compiler; | 7 leg.Compiler compiler; |
| 8 var positionElement; | 8 var positionElement; |
| 9 leg.CodeBuffer outBuffer; | 9 leg.CodeBuffer outBuffer; |
| 10 int indentLevel = 0; | 10 int indentLevel = 0; |
| 11 bool inForInit = false; | 11 bool inForInit = false; |
| 12 bool atStatementBegin = false; | 12 bool atStatementBegin = false; |
| 13 final DanglingElseVisitor danglingElseVisitor; | 13 final DanglingElseVisitor danglingElseVisitor; |
| 14 | 14 |
| 15 Printer(leg.Compiler compiler, this.positionElement) | 15 Printer(leg.Compiler compiler, this.positionElement) |
| 16 : this.compiler = compiler, | 16 : shouldCompressOutput = compiler.enableMinification, |
| 17 this.compiler = compiler, |
| 17 outBuffer = new leg.CodeBuffer(), | 18 outBuffer = new leg.CodeBuffer(), |
| 18 danglingElseVisitor = new DanglingElseVisitor(compiler); | 19 danglingElseVisitor = new DanglingElseVisitor(compiler); |
| 19 | 20 |
| 20 void spaceOut() { | 21 void spaceOut() { |
| 21 if (!shouldCompressOutput) out(" "); | 22 if (!shouldCompressOutput) out(" "); |
| 22 } | 23 } |
| 23 void lineOut() { | 24 void lineOut() { |
| 24 if (!shouldCompressOutput) out("\n"); | 25 if (!shouldCompressOutput) out("\n"); |
| 25 } | 26 } |
| 26 | 27 |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 } | 818 } |
| 818 | 819 |
| 819 | 820 |
| 820 leg.CodeBuffer prettyPrint(Node node, | 821 leg.CodeBuffer prettyPrint(Node node, |
| 821 leg.Compiler compiler, | 822 leg.Compiler compiler, |
| 822 Dynamic positionElement) { | 823 Dynamic positionElement) { |
| 823 Printer printer = new Printer(compiler, positionElement); | 824 Printer printer = new Printer(compiler, positionElement); |
| 824 printer.visit(node); | 825 printer.visit(node); |
| 825 return printer.outBuffer; | 826 return printer.outBuffer; |
| 826 } | 827 } |
| OLD | NEW |