parent
74801de315
commit
0794aaa2c2
|
|
@ -4003,16 +4003,30 @@ merge(Compressor.prototype, {
|
||||||
})) break;
|
})) break;
|
||||||
}
|
}
|
||||||
if (fn.contains_this()) break;
|
if (fn.contains_this()) break;
|
||||||
var j = fn.argnames.length;
|
var len = fn.argnames.length;
|
||||||
if (j > 0 && compressor.option("inline") < 2) break;
|
if (len > 0 && compressor.option("inline") < 2) break;
|
||||||
if (j > self.argnames.length) break;
|
if (len > self.argnames.length) break;
|
||||||
if (j < self.argnames.length && !compressor.drop_fargs(fn, call)) break;
|
for (var j = 0; j < len; j++) {
|
||||||
while (--j >= 0) {
|
|
||||||
var arg = call.args[j];
|
var arg = call.args[j];
|
||||||
if (!(arg instanceof AST_SymbolRef)) break;
|
if (!(arg instanceof AST_SymbolRef)) break;
|
||||||
if (arg.definition() !== self.argnames[j].definition()) break;
|
if (arg.definition() !== self.argnames[j].definition()) break;
|
||||||
}
|
}
|
||||||
if (j >= 0) break;
|
if (j < len) break;
|
||||||
|
for (; j < call.args.length; j++) {
|
||||||
|
if (call.args[j].has_side_effects(compressor)) break;
|
||||||
|
}
|
||||||
|
if (j < call.args.length) break;
|
||||||
|
if (len < self.argnames.length && !compressor.drop_fargs(self, compressor.parent())) {
|
||||||
|
if (!compressor.drop_fargs(fn, call)) break;
|
||||||
|
do {
|
||||||
|
var argname = make_node(AST_SymbolFunarg, fn, {
|
||||||
|
name: fn.make_var_name("argument_" + len),
|
||||||
|
scope: fn
|
||||||
|
});
|
||||||
|
fn.argnames.push(argname);
|
||||||
|
fn.enclosed.push(fn.def_variable(argname));
|
||||||
|
} while (++len < self.argnames.length);
|
||||||
|
}
|
||||||
return call.expression;
|
return call.expression;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -4151,7 +4151,7 @@ issue_3821_2: {
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
substitude: {
|
substitute: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
|
@ -4189,8 +4189,7 @@ substitude: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
|
@ -4218,25 +4217,56 @@ substitude: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 2",
|
||||||
"PASS",
|
]
|
||||||
"PASS",
|
}
|
||||||
"PASS",
|
|
||||||
"PASS",
|
substitute_add_farg: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
keep_fargs: "strict",
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
function f(g) {
|
||||||
|
console.log(g.length);
|
||||||
|
g(null, "FAIL");
|
||||||
|
}
|
||||||
|
f(function() {
|
||||||
|
return function(a, b) {
|
||||||
|
return function(c) {
|
||||||
|
do {
|
||||||
|
console.log("PASS");
|
||||||
|
} while (c);
|
||||||
|
}(a, b);
|
||||||
|
};
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
function f(g) {
|
||||||
|
console.log(g.length);
|
||||||
|
g(null, "FAIL");
|
||||||
|
}
|
||||||
|
f(function(c, argument_1) {
|
||||||
|
do {
|
||||||
|
console.log("PASS");
|
||||||
|
} while (c);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"2",
|
||||||
"PASS",
|
"PASS",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
substitude_arguments: {
|
substitute_arguments: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
|
@ -4244,7 +4274,7 @@ substitude_arguments: {
|
||||||
}
|
}
|
||||||
input: {
|
input: {
|
||||||
var o = {};
|
var o = {};
|
||||||
function f() {
|
function f(a) {
|
||||||
return arguments[0] === o ? "PASS" : "FAIL";
|
return arguments[0] === o ? "PASS" : "FAIL";
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
|
|
@ -4274,13 +4304,12 @@ substitude_arguments: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
var o = {};
|
var o = {};
|
||||||
function f() {
|
function f(a) {
|
||||||
return arguments[0] === o ? "PASS" : "FAIL";
|
return arguments[0] === o ? "PASS" : "FAIL";
|
||||||
}
|
}
|
||||||
[
|
[
|
||||||
|
|
@ -4310,25 +4339,19 @@ substitude_arguments: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 2",
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
substitude_drop_fargs: {
|
substitute_drop_farg: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
keep_fargs: false,
|
keep_fargs: false,
|
||||||
|
|
@ -4367,8 +4390,7 @@ substitude_drop_fargs: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o));
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
|
@ -4394,25 +4416,19 @@ substitude_drop_fargs: {
|
||||||
return f;
|
return f;
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o));
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"PASS",
|
"PASS PASS",
|
||||||
"PASS",
|
"PASS PASS",
|
||||||
"PASS",
|
"PASS PASS",
|
||||||
"PASS",
|
"PASS PASS",
|
||||||
"PASS",
|
"PASS PASS",
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
substitude_this: {
|
substitute_this: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
|
@ -4450,8 +4466,7 @@ substitude_this: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
|
@ -4486,25 +4501,19 @@ substitude_this: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"false",
|
"false true 1",
|
||||||
"true",
|
"false false 1",
|
||||||
"false",
|
"false false 1",
|
||||||
"false",
|
"false false 1",
|
||||||
"false",
|
"false false 2",
|
||||||
"false",
|
|
||||||
"false",
|
|
||||||
"false",
|
|
||||||
"false",
|
|
||||||
"false",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
substitude_use_strict: {
|
substitute_use_strict: {
|
||||||
options = {
|
options = {
|
||||||
inline: true,
|
inline: true,
|
||||||
reduce_vars: true,
|
reduce_vars: true,
|
||||||
|
|
@ -4543,8 +4552,7 @@ substitude_use_strict: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
|
|
@ -4573,21 +4581,15 @@ substitude_use_strict: {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
].forEach(function(g) {
|
].forEach(function(g) {
|
||||||
console.log(g()(o));
|
console.log(g()(o), g().call(o, o), g().length);
|
||||||
console.log(g().call(o, o));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
expect_stdout: [
|
expect_stdout: [
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 1",
|
||||||
"PASS",
|
"PASS PASS 2",
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
"PASS",
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4637,3 +4639,24 @@ issue_3835: {
|
||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_3836: {
|
||||||
|
options = {
|
||||||
|
inline: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
(function() {
|
||||||
|
return function() {
|
||||||
|
for (var a in 0)
|
||||||
|
console.log(k);
|
||||||
|
}(console.log("PASS"));
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
(function() {
|
||||||
|
for (var a in 0)
|
||||||
|
console.log(k);
|
||||||
|
})(console.log("PASS"));
|
||||||
|
}
|
||||||
|
expect_stdout: "PASS"
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user