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_ast; | 5 part of js_ast; |
6 | 6 |
7 | 7 |
8 class JavaScriptPrintingOptions { | 8 class JavaScriptPrintingOptions { |
9 final bool shouldCompressOutput; | 9 final bool shouldCompressOutput; |
10 final bool minifyLocalVariables; | 10 final bool minifyLocalVariables; |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 * Returns true, if the given node must be wrapped into braces when used | 1278 * Returns true, if the given node must be wrapped into braces when used |
1279 * as then-statement in an [If] that has an else branch. | 1279 * as then-statement in an [If] that has an else branch. |
1280 */ | 1280 */ |
1281 class DanglingElseVisitor extends BaseVisitor<bool> { | 1281 class DanglingElseVisitor extends BaseVisitor<bool> { |
1282 JavaScriptPrintingContext context; | 1282 JavaScriptPrintingContext context; |
1283 | 1283 |
1284 DanglingElseVisitor(this.context); | 1284 DanglingElseVisitor(this.context); |
1285 | 1285 |
1286 bool visitProgram(Program node) => false; | 1286 bool visitProgram(Program node) => false; |
1287 | 1287 |
1288 bool visitNode(Statement node) { | 1288 bool visitNode(Node node) { |
1289 context.error("Forgot node: $node"); | 1289 context.error("Forgot node: $node"); |
1290 return null; | 1290 return null; |
1291 } | 1291 } |
1292 | 1292 |
1293 bool visitBlock(Block node) => false; | 1293 bool visitBlock(Block node) => false; |
1294 bool visitExpressionStatement(ExpressionStatement node) => false; | 1294 bool visitExpressionStatement(ExpressionStatement node) => false; |
1295 bool visitEmptyStatement(EmptyStatement node) => false; | 1295 bool visitEmptyStatement(EmptyStatement node) => false; |
1296 bool visitIf(If node) { | 1296 bool visitIf(If node) { |
1297 if (!node.hasElse) return true; | 1297 if (!node.hasElse) return true; |
1298 return node.otherwise.accept(this); | 1298 return node.otherwise.accept(this); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); | 1458 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); |
1459 } | 1459 } |
1460 codes.add(charCodes.$0 + digit); | 1460 codes.add(charCodes.$0 + digit); |
1461 newName = new String.fromCharCodes(codes); | 1461 newName = new String.fromCharCodes(codes); |
1462 } | 1462 } |
1463 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); | 1463 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); |
1464 maps.last[oldName] = newName; | 1464 maps.last[oldName] = newName; |
1465 return newName; | 1465 return newName; |
1466 } | 1466 } |
1467 } | 1467 } |
OLD | NEW |