| 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; | 5 part of js; |
| 6 | 6 |
| 7 class Printer implements NodeVisitor { | 7 class Printer implements NodeVisitor { |
| 8 final bool shouldCompressOutput; | 8 final bool shouldCompressOutput; |
| 9 leg.Compiler compiler; | 9 leg.Compiler compiler; |
| 10 leg.CodeBuffer outBuffer; | 10 leg.CodeBuffer outBuffer; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 133 } |
| 134 | 134 |
| 135 visitAll(List<Node> nodes) { | 135 visitAll(List<Node> nodes) { |
| 136 nodes.forEach(visit); | 136 nodes.forEach(visit); |
| 137 } | 137 } |
| 138 | 138 |
| 139 visitProgram(Program program) { | 139 visitProgram(Program program) { |
| 140 visitAll(program.body); | 140 visitAll(program.body); |
| 141 } | 141 } |
| 142 | 142 |
| 143 visitBlob(Blob node) { |
| 144 outBuffer.addBuffer(node.buffer); |
| 145 } |
| 146 |
| 143 bool blockBody(Node body, {bool needsSeparation, bool needsNewline}) { | 147 bool blockBody(Node body, {bool needsSeparation, bool needsNewline}) { |
| 144 if (body is Block) { | 148 if (body is Block) { |
| 145 spaceOut(); | 149 spaceOut(); |
| 146 blockOut(body, false, needsNewline); | 150 blockOut(body, false, needsNewline); |
| 147 return true; | 151 return true; |
| 148 } | 152 } |
| 149 if (shouldCompressOutput && needsSeparation) { | 153 if (shouldCompressOutput && needsSeparation) { |
| 150 // If [shouldCompressOutput] is false, then the 'lineOut' will insert | 154 // If [shouldCompressOutput] is false, then the 'lineOut' will insert |
| 151 // the separation. | 155 // the separation. |
| 152 out(" "); | 156 out(" "); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); | 1129 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); |
| 1126 } | 1130 } |
| 1127 codes.add(charCodes.$0 + digit); | 1131 codes.add(charCodes.$0 + digit); |
| 1128 newName = new String.fromCharCodes(codes); | 1132 newName = new String.fromCharCodes(codes); |
| 1129 } | 1133 } |
| 1130 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); | 1134 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); |
| 1131 maps.last[oldName] = newName; | 1135 maps.last[oldName] = newName; |
| 1132 return newName; | 1136 return newName; |
| 1133 } | 1137 } |
| 1134 } | 1138 } |
| OLD | NEW |