| Index: lib/src/js/printer.dart
|
| diff --git a/lib/src/js/printer.dart b/lib/src/js/printer.dart
|
| index 1903e81f09facf9378313a133d1b73f97caaccfb..fa1a8e6e141a2ff0cbb28d720461f6eefc8389e5 100644
|
| --- a/lib/src/js/printer.dart
|
| +++ b/lib/src/js/printer.dart
|
| @@ -595,6 +595,38 @@ class Printer implements NodeVisitor {
|
| newInForInit: inForInit, newAtStatementBegin: false);
|
| }
|
|
|
| + visitArrayDestructuring(ArrayDestructuring node) {
|
| + out("[");
|
| + visitCommaSeparated(node.variables, EXPRESSION,
|
| + newInForInit: false, newAtStatementBegin: false);
|
| + out("]");
|
| + }
|
| + visitObjectDestructuring(ObjectDestructuring node) {
|
| + out("{");
|
| + visitCommaSeparated(node.variables, EXPRESSION,
|
| + newInForInit: false, newAtStatementBegin: false);
|
| + out("}");
|
| + }
|
| +
|
| + visitDestructuredVariable(DestructuredVariable node) {
|
| + var hasName = node.name != null;
|
| + if (hasName) visit(node.name);
|
| + if (node.structure != null) {
|
| + if (hasName) {
|
| + out(":");
|
| + spaceOut();
|
| + }
|
| + visit(node.structure);
|
| + }
|
| + if (node.defaultValue != null) {
|
| + spaceOut();
|
| + out("=");
|
| + spaceOut();
|
| + visitNestedExpression(node.defaultValue, EXPRESSION,
|
| + newInForInit: false, newAtStatementBegin: false);
|
| + }
|
| + }
|
| +
|
| visitAssignment(Assignment assignment) {
|
| visitNestedExpression(assignment.leftHandSide, LEFT_HAND_SIDE,
|
| newInForInit: inForInit,
|
| @@ -1472,14 +1504,23 @@ abstract class VariableDeclarationVisitor<T> extends BaseVisitor<T> {
|
| declare(Identifier node);
|
|
|
| visitFunctionExpression(FunctionExpression node) {
|
| - for (var p in node.params) {
|
| - declare(p is RestParameter ? p.parameter : p);
|
| - }
|
| + node.params.forEach(_scanDeclarator);
|
| node.body.accept(this);
|
| }
|
|
|
| + _scanDeclarator(Declarator d) {
|
| + if (d is Identifier) declare(d);
|
| + if (d is RestParameter) _scanDeclarator(d.parameter);
|
| + else if (d is Destructuring) {
|
| + for (var v in d.variables) {
|
| + if (v.name != null) declare(v.name);
|
| + if (v.structure != null) _scanDeclarator(v.structure);
|
| + }
|
| + }
|
| + }
|
| +
|
| visitVariableInitialization(VariableInitialization node) {
|
| - declare(node.declaration);
|
| + _scanDeclarator(node.declaration);
|
| if (node.value != null) node.value.accept(this);
|
| }
|
|
|
|
|