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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 502 } |
503 } | 503 } |
504 | 504 |
505 visitLabeledStatement(LabeledStatement node) { | 505 visitLabeledStatement(LabeledStatement node) { |
506 outIndent("${node.label}:"); | 506 outIndent("${node.label}:"); |
507 blockBody(node.body, needsSeparation: false, needsNewline: true); | 507 blockBody(node.body, needsSeparation: false, needsNewline: true); |
508 } | 508 } |
509 | 509 |
510 void functionOut(Fun fun, Node name) { | 510 void functionOut(Fun fun, Node name) { |
511 out("function"); | 511 out("function"); |
| 512 if (fun.isGenerator) out("*"); |
512 if (name != null) { | 513 if (name != null) { |
513 out(" "); | 514 out(" "); |
514 // Name must be a [Decl]. Therefore only test for primary expressions. | 515 // Name must be a [Decl]. Therefore only test for primary expressions. |
515 visitNestedExpression(name, PRIMARY, | 516 visitNestedExpression(name, PRIMARY, |
516 newInForInit: false, newAtStatementBegin: false); | 517 newInForInit: false, newAtStatementBegin: false); |
517 } | 518 } |
518 localNamer.enterScope(fun); | 519 localNamer.enterScope(fun); |
519 out("("); | 520 out("("); |
520 if (fun.params != null) { | 521 if (fun.params != null) { |
521 visitCommaSeparated(fun.params, PRIMARY, | 522 visitCommaSeparated(fun.params, PRIMARY, |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 break; | 764 break; |
764 default: | 765 default: |
765 out(op); | 766 out(op); |
766 } | 767 } |
767 visitNestedExpression(unary.argument, unary.precedenceLevel, | 768 visitNestedExpression(unary.argument, unary.precedenceLevel, |
768 newInForInit: inForInit, newAtStatementBegin: false); | 769 newInForInit: inForInit, newAtStatementBegin: false); |
769 } | 770 } |
770 | 771 |
771 visitSpread(Spread unary) => visitPrefix(unary); | 772 visitSpread(Spread unary) => visitPrefix(unary); |
772 | 773 |
| 774 visitYield(Yield yield) { |
| 775 out(yield.star ? "yield* " : "yield "); |
| 776 visitNestedExpression(yield.value, yield.precedenceLevel, |
| 777 newInForInit: inForInit, newAtStatementBegin: false); |
| 778 } |
| 779 |
773 visitPostfix(Postfix postfix) { | 780 visitPostfix(Postfix postfix) { |
774 visitNestedExpression(postfix.argument, LEFT_HAND_SIDE, | 781 visitNestedExpression(postfix.argument, LEFT_HAND_SIDE, |
775 newInForInit: inForInit, | 782 newInForInit: inForInit, |
776 newAtStatementBegin: atStatementBegin); | 783 newAtStatementBegin: atStatementBegin); |
777 out(postfix.op); | 784 out(postfix.op); |
778 } | 785 } |
779 | 786 |
780 visitThis(This node) { | 787 visitThis(This node) { |
781 out("this"); | 788 out("this"); |
782 } | 789 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 } | 1032 } |
1026 | 1033 |
1027 visitMethod(Method node) { | 1034 visitMethod(Method node) { |
1028 if (node.isStatic) { | 1035 if (node.isStatic) { |
1029 out('static '); | 1036 out('static '); |
1030 } | 1037 } |
1031 if (node.isGetter) { | 1038 if (node.isGetter) { |
1032 out('get '); | 1039 out('get '); |
1033 } else if (node.isSetter) { | 1040 } else if (node.isSetter) { |
1034 out('set '); | 1041 out('set '); |
| 1042 } else if (node.function.isGenerator) { |
| 1043 out('*'); |
1035 } | 1044 } |
1036 propertyNameOut(node.name, inMethod: true); | 1045 propertyNameOut(node.name, inMethod: true); |
1037 | 1046 |
1038 var fun = node.function; | 1047 var fun = node.function; |
1039 localNamer.enterScope(fun); | 1048 localNamer.enterScope(fun); |
1040 out("("); | 1049 out("("); |
1041 if (fun.params != null) { | 1050 if (fun.params != null) { |
1042 visitCommaSeparated(fun.params, SPREAD, | 1051 visitCommaSeparated(fun.params, SPREAD, |
1043 newInForInit: false, newAtStatementBegin: false); | 1052 newInForInit: false, newAtStatementBegin: false); |
1044 } | 1053 } |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 declare(node.name); | 1460 declare(node.name); |
1452 node.function.accept(this); | 1461 node.function.accept(this); |
1453 } | 1462 } |
1454 | 1463 |
1455 visitClassExpression(ClassExpression node) { | 1464 visitClassExpression(ClassExpression node) { |
1456 declare(node.name); | 1465 declare(node.name); |
1457 if (node.heritage != null) node.heritage.accept(this); | 1466 if (node.heritage != null) node.heritage.accept(this); |
1458 for (Method element in node.methods) element.accept(this); | 1467 for (Method element in node.methods) element.accept(this); |
1459 } | 1468 } |
1460 } | 1469 } |
OLD | NEW |