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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 params = new Set<String>(); | 1399 params = new Set<String>(); |
1400 | 1400 |
1401 void forEachVar(void fn(String v)) => vars.forEach(fn); | 1401 void forEachVar(void fn(String v)) => vars.forEach(fn); |
1402 void forEachParam(void fn(String p)) => params.forEach(fn); | 1402 void forEachParam(void fn(String p)) => params.forEach(fn); |
1403 | 1403 |
1404 void collectVarsInFunction(FunctionExpression fun) { | 1404 void collectVarsInFunction(FunctionExpression fun) { |
1405 if (!nested) { | 1405 if (!nested) { |
1406 nested = true; | 1406 nested = true; |
1407 if (fun.params != null) { | 1407 if (fun.params != null) { |
1408 for (var param in fun.params) { | 1408 for (var param in fun.params) { |
1409 params.add(param.name); | 1409 // TODO(jmesserly): add ES6 support. Currently not needed because |
| 1410 // dart2js does not emit ES6 rest param or destructuring. |
| 1411 params.add((param as Identifier).name); |
1410 } | 1412 } |
1411 } | 1413 } |
1412 fun.body.accept(this); | 1414 fun.body.accept(this); |
1413 nested = false; | 1415 nested = false; |
1414 } | 1416 } |
1415 } | 1417 } |
1416 | 1418 |
1417 void visitFunctionDeclaration(FunctionDeclaration declaration) { | 1419 void visitFunctionDeclaration(FunctionDeclaration declaration) { |
1418 // Note that we don't bother collecting the name of the function. | 1420 // Note that we don't bother collecting the name of the function. |
1419 collectVarsInFunction(declaration.function); | 1421 collectVarsInFunction(declaration.function); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 declare(node.name); | 1699 declare(node.name); |
1698 node.function.accept(this); | 1700 node.function.accept(this); |
1699 } | 1701 } |
1700 | 1702 |
1701 visitClassExpression(ClassExpression node) { | 1703 visitClassExpression(ClassExpression node) { |
1702 declare(node.name); | 1704 declare(node.name); |
1703 if (node.heritage != null) node.heritage.accept(this); | 1705 if (node.heritage != null) node.heritage.accept(this); |
1704 for (Method element in node.methods) element.accept(this); | 1706 for (Method element in node.methods) element.accept(this); |
1705 } | 1707 } |
1706 } | 1708 } |
OLD | NEW |