| 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 typedef String Renamer(Name); | 8 typedef String Renamer(Name); |
| 9 | 9 |
| 10 class JavaScriptPrintingOptions { | 10 class JavaScriptPrintingOptions { |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 | 671 |
| 672 @override | 672 @override |
| 673 visitVariableDeclarationList(VariableDeclarationList list) { | 673 visitVariableDeclarationList(VariableDeclarationList list) { |
| 674 out("var "); | 674 out("var "); |
| 675 visitCommaSeparated(list.declarations, ASSIGNMENT, | 675 visitCommaSeparated(list.declarations, ASSIGNMENT, |
| 676 newInForInit: inForInit, newAtStatementBegin: false); | 676 newInForInit: inForInit, newAtStatementBegin: false); |
| 677 } | 677 } |
| 678 | 678 |
| 679 @override | 679 @override |
| 680 visitAssignment(Assignment assignment) { | 680 visitAssignment(Assignment assignment) { |
| 681 visitNestedExpression(assignment.leftHandSide, LEFT_HAND_SIDE, | 681 visitNestedExpression(assignment.leftHandSide, CALL, |
| 682 newInForInit: inForInit, | 682 newInForInit: inForInit, |
| 683 newAtStatementBegin: atStatementBegin); | 683 newAtStatementBegin: atStatementBegin); |
| 684 if (assignment.value != null) { | 684 if (assignment.value != null) { |
| 685 spaceOut(); | 685 spaceOut(); |
| 686 String op = assignment.op; | 686 String op = assignment.op; |
| 687 if (op != null) out(op); | 687 if (op != null) out(op); |
| 688 out("="); | 688 out("="); |
| 689 spaceOut(); | 689 spaceOut(); |
| 690 visitNestedExpression(assignment.value, ASSIGNMENT, | 690 visitNestedExpression(assignment.value, ASSIGNMENT, |
| 691 newInForInit: inForInit, | 691 newInForInit: inForInit, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 712 spaceOut(); | 712 spaceOut(); |
| 713 out(":"); | 713 out(":"); |
| 714 spaceOut(); | 714 spaceOut(); |
| 715 visitNestedExpression(cond.otherwise, ASSIGNMENT, | 715 visitNestedExpression(cond.otherwise, ASSIGNMENT, |
| 716 newInForInit: inForInit, newAtStatementBegin: false); | 716 newInForInit: inForInit, newAtStatementBegin: false); |
| 717 } | 717 } |
| 718 | 718 |
| 719 @override | 719 @override |
| 720 visitNew(New node) { | 720 visitNew(New node) { |
| 721 out("new "); | 721 out("new "); |
| 722 visitNestedExpression(node.target, CALL, | 722 visitNestedExpression(node.target, LEFT_HAND_SIDE, |
| 723 newInForInit: inForInit, newAtStatementBegin: false); | 723 newInForInit: inForInit, newAtStatementBegin: false); |
| 724 out("("); | 724 out("("); |
| 725 visitCommaSeparated(node.arguments, ASSIGNMENT, | 725 visitCommaSeparated(node.arguments, ASSIGNMENT, |
| 726 newInForInit: false, newAtStatementBegin: false); | 726 newInForInit: false, newAtStatementBegin: false); |
| 727 out(")"); | 727 out(")"); |
| 728 } | 728 } |
| 729 | 729 |
| 730 @override | 730 @override |
| 731 visitCall(Call call) { | 731 visitCall(Call call) { |
| 732 visitNestedExpression(call.target, LEFT_HAND_SIDE, | 732 visitNestedExpression(call.target, CALL, |
| 733 newInForInit: inForInit, | 733 newInForInit: inForInit, |
| 734 newAtStatementBegin: atStatementBegin); | 734 newAtStatementBegin: atStatementBegin); |
| 735 out("("); | 735 out("("); |
| 736 visitCommaSeparated(call.arguments, ASSIGNMENT, | 736 visitCommaSeparated(call.arguments, ASSIGNMENT, |
| 737 newInForInit: false, newAtStatementBegin: false); | 737 newInForInit: false, newAtStatementBegin: false); |
| 738 out(")"); | 738 out(")"); |
| 739 } | 739 } |
| 740 | 740 |
| 741 @override | 741 @override |
| 742 void visitBinary(Binary binary) { | 742 void visitBinary(Binary binary) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 break; | 865 break; |
| 866 default: | 866 default: |
| 867 out(op); | 867 out(op); |
| 868 } | 868 } |
| 869 visitNestedExpression(unary.argument, UNARY, | 869 visitNestedExpression(unary.argument, UNARY, |
| 870 newInForInit: inForInit, newAtStatementBegin: false); | 870 newInForInit: inForInit, newAtStatementBegin: false); |
| 871 } | 871 } |
| 872 | 872 |
| 873 @override | 873 @override |
| 874 void visitPostfix(Postfix postfix) { | 874 void visitPostfix(Postfix postfix) { |
| 875 visitNestedExpression(postfix.argument, LEFT_HAND_SIDE, | 875 visitNestedExpression(postfix.argument, CALL, |
| 876 newInForInit: inForInit, | 876 newInForInit: inForInit, |
| 877 newAtStatementBegin: atStatementBegin); | 877 newAtStatementBegin: atStatementBegin); |
| 878 out(postfix.op); | 878 out(postfix.op); |
| 879 } | 879 } |
| 880 | 880 |
| 881 @override | 881 @override |
| 882 void visitVariableUse(VariableUse ref) { | 882 void visitVariableUse(VariableUse ref) { |
| 883 out(localNamer.getName(ref.name)); | 883 out(localNamer.getName(ref.name)); |
| 884 } | 884 } |
| 885 | 885 |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 } | 1497 } |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { | 1500 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { |
| 1501 // Enter must happen before exit. | 1501 // Enter must happen before exit. |
| 1502 addToNode(context, position); | 1502 addToNode(context, position); |
| 1503 context.exitNode(node, startPosition, position, closingPosition); | 1503 context.exitNode(node, startPosition, position, closingPosition); |
| 1504 return parent; | 1504 return parent; |
| 1505 } | 1505 } |
| 1506 } | 1506 } |
| OLD | NEW |