| 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 part of js; |
| 6 |
| 5 class Printer implements NodeVisitor { | 7 class Printer implements NodeVisitor { |
| 6 final bool shouldCompressOutput; | 8 final bool shouldCompressOutput; |
| 7 leg.Compiler compiler; | 9 leg.Compiler compiler; |
| 8 leg.CodeBuffer outBuffer; | 10 leg.CodeBuffer outBuffer; |
| 9 int indentLevel = 0; | 11 int indentLevel = 0; |
| 10 bool inForInit = false; | 12 bool inForInit = false; |
| 11 bool atStatementBegin = false; | 13 bool atStatementBegin = false; |
| 12 final DanglingElseVisitor danglingElseVisitor; | 14 final DanglingElseVisitor danglingElseVisitor; |
| 13 final Namer namer; | 15 final Namer namer; |
| 14 | 16 |
| 15 Printer(leg.Compiler compiler) | 17 Printer(leg.Compiler compiler) |
| 16 : shouldCompressOutput = compiler.enableMinification, | 18 : shouldCompressOutput = compiler.enableMinification, |
| 17 this.compiler = compiler, | 19 this.compiler = compiler, |
| 18 outBuffer = new leg.CodeBuffer(), | 20 outBuffer = new leg.CodeBuffer(), |
| 19 danglingElseVisitor = new DanglingElseVisitor(compiler), | 21 danglingElseVisitor = new DanglingElseVisitor(compiler), |
| 20 namer = determineRenamer(compiler.enableMinification); | 22 namer = determineRenamer(compiler.enableMinification); |
| 21 | 23 |
| 22 static Namer determineRenamer(bool shouldCompressOutput) { | 24 static Namer determineRenamer(bool shouldCompressOutput) { |
| 23 // TODO(erikcorry): Re-enable the MinifyRenamer after M1. | 25 // TODO(erikcorry): Re-enable the MinifyRenamer after M1. |
| 24 return new IdentityNamer(); | 26 return new IdentityNamer(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 void spaceOut() { | 29 void spaceOut() { |
| 28 if (!shouldCompressOutput) out(" "); | 30 if (!shouldCompressOutput) out(" "); |
| 29 } | 31 } |
| 30 void lineOut() { | 32 void lineOut() { |
| 31 if (!shouldCompressOutput) out("\n"); | 33 if (!shouldCompressOutput) out("\n"); |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } | 977 } |
| 976 codes.add(charCodes.$0 + digit); | 978 codes.add(charCodes.$0 + digit); |
| 977 newName = new String.fromCharCodes(codes); | 979 newName = new String.fromCharCodes(codes); |
| 978 } | 980 } |
| 979 assert(const RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); | 981 assert(const RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); |
| 980 nameNumber++; | 982 nameNumber++; |
| 981 maps.last()[oldName] = newName; | 983 maps.last()[oldName] = newName; |
| 982 return newName; | 984 return newName; |
| 983 } | 985 } |
| 984 } | 986 } |
| OLD | NEW |