drop unused function arguments

also add test for "drop_unused" (the last one fails for now)
This commit is contained in:
Mihai Bazon
2012-10-13 15:04:44 +03:00
parent b071c9d079
commit fcc0229087
3 changed files with 118 additions and 0 deletions

View File

@@ -856,6 +856,21 @@ merge(Compressor.prototype, {
// pass 3: we should drop declarations not in_use
var tt = new TreeTransformer(
function before(node, descend) {
if (node instanceof AST_Lambda) {
for (var a = node.argnames, i = a.length; --i >= 0;) {
var sym = a[i];
if (sym.unreferenced()) {
a.pop();
compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
name : sym.name,
file : sym.start.file,
line : sym.start.line,
col : sym.start.col
});
}
else break;
}
}
if (node instanceof AST_Defun && node !== self) {
if (!member(node.name.definition(), in_use)) {
compressor.warn("Dropping unused function {name} [{file}:{line},{col}]", {