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

Side by Side Diff: lib/compiler/implementation/js/printer.dart

Issue 10901002: Hook up the --minify option in dart2js and use it to get rid of unnecessary whitespace inside funct… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. 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 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
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 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/dart_backend/renamer.dart ('k') | lib/compiler/implementation/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698