| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 lineOut(); | 449 lineOut(); |
| 450 } | 450 } |
| 451 | 451 |
| 452 visitNestedExpression(Expression node, int requiredPrecedence, | 452 visitNestedExpression(Expression node, int requiredPrecedence, |
| 453 {bool newInForInit, bool newAtStatementBegin}) { | 453 {bool newInForInit, bool newAtStatementBegin}) { |
| 454 bool needsParentheses = | 454 bool needsParentheses = |
| 455 // a - (b + c). | 455 // a - (b + c). |
| 456 (requiredPrecedence != EXPRESSION && | 456 (requiredPrecedence != EXPRESSION && |
| 457 node.precedenceLevel < requiredPrecedence) || | 457 node.precedenceLevel < requiredPrecedence) || |
| 458 // for (a = (x in o); ... ; ... ) { ... } | 458 // for (a = (x in o); ... ; ... ) { ... } |
| 459 (newInForInit && node is Binary && (node as Binary).op == "in") || | 459 (newInForInit && node is Binary && node.op == "in") || |
| 460 // (function() { ... })(). | 460 // (function() { ... })(). |
| 461 // ({a: 2, b: 3}.toString()). | 461 // ({a: 2, b: 3}.toString()). |
| 462 (newAtStatementBegin && (node is NamedFunction || | 462 (newAtStatementBegin && (node is NamedFunction || |
| 463 node is Fun || | 463 node is Fun || |
| 464 node is ObjectInitializer)); | 464 node is ObjectInitializer)); |
| 465 if (needsParentheses) { | 465 if (needsParentheses) { |
| 466 inForInit = false; | 466 inForInit = false; |
| 467 atStatementBegin = false; | 467 atStatementBegin = false; |
| 468 out("("); | 468 out("("); |
| 469 visit(node); | 469 visit(node); |
| (...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); | 1141 codes.add(nthLetter((n ~/ nameSpaceSize) % LETTERS)); |
| 1142 } | 1142 } |
| 1143 codes.add(charCodes.$0 + digit); | 1143 codes.add(charCodes.$0 + digit); |
| 1144 newName = new String.fromCharCodes(codes); | 1144 newName = new String.fromCharCodes(codes); |
| 1145 } | 1145 } |
| 1146 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); | 1146 assert(new RegExp(r'[a-zA-Z][a-zA-Z0-9]*').hasMatch(newName)); |
| 1147 maps.last[oldName] = newName; | 1147 maps.last[oldName] = newName; |
| 1148 return newName; | 1148 return newName; |
| 1149 } | 1149 } |
| 1150 } | 1150 } |
| OLD | NEW |