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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 outIndentLn("}"); | 483 outIndentLn("}"); |
484 } | 484 } |
485 | 485 |
486 visitCase(Case node) { | 486 visitCase(Case node) { |
487 outIndent("case"); | 487 outIndent("case"); |
488 pendingSpace = true; | 488 pendingSpace = true; |
489 visitNestedExpression(node.expression, EXPRESSION, | 489 visitNestedExpression(node.expression, EXPRESSION, |
490 newInForInit: false, newAtStatementBegin: false); | 490 newInForInit: false, newAtStatementBegin: false); |
491 outLn(":"); | 491 outLn(":"); |
492 if (!node.body.statements.isEmpty) { | 492 if (!node.body.statements.isEmpty) { |
493 indentMore(); | 493 blockOut(node.body, true, true); |
494 blockOutWithoutBraces(node.body); | |
495 indentLess(); | |
496 } | 494 } |
497 } | 495 } |
498 | 496 |
499 visitDefault(Default node) { | 497 visitDefault(Default node) { |
500 outIndentLn("default:"); | 498 outIndentLn("default:"); |
501 if (!node.body.statements.isEmpty) { | 499 if (!node.body.statements.isEmpty) { |
502 indentMore(); | 500 blockOut(node.body, true, true); |
503 blockOutWithoutBraces(node.body); | |
504 indentLess(); | |
505 } | 501 } |
506 } | 502 } |
507 | 503 |
508 visitLabeledStatement(LabeledStatement node) { | 504 visitLabeledStatement(LabeledStatement node) { |
509 outIndent("${node.label}:"); | 505 outIndent("${node.label}:"); |
510 blockBody(node.body, needsSeparation: false, needsNewline: true); | 506 blockBody(node.body, needsSeparation: false, needsNewline: true); |
511 } | 507 } |
512 | 508 |
513 void functionOut(Fun fun, Node name, Node scope) { | 509 void functionOut(Fun fun, Node name, Node scope) { |
514 out("function"); | 510 out("function"); |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); | 1365 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); |
1370 } | 1366 } |
1371 codes.add(charCodes.$0 + digit); | 1367 codes.add(charCodes.$0 + digit); |
1372 newName = new String.fromCharCodes(codes); | 1368 newName = new String.fromCharCodes(codes); |
1373 } | 1369 } |
1374 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); | 1370 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); |
1375 maps.last[oldName] = newName; | 1371 maps.last[oldName] = newName; |
1376 return newName; | 1372 return newName; |
1377 } | 1373 } |
1378 } | 1374 } |
OLD | NEW |