aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/compress.js b/lib/compress.js
index d890caf7..4a2a436b 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3685,8 +3685,9 @@ merge(Compressor.prototype, {
if (compressor.option("reduce_vars") && fn instanceof AST_SymbolRef) {
fn = fn.fixed_value();
}
+ var is_func = fn instanceof AST_Lambda;
if (compressor.option("unused")
- && fn instanceof AST_Function
+ && is_func
&& !fn.uses_arguments
&& !fn.uses_eval) {
var pos = 0, last = 0;
@@ -3855,7 +3856,7 @@ merge(Compressor.prototype, {
if (func instanceof AST_SymbolRef) {
func = func.fixed_value();
}
- if (func instanceof AST_Function && !func.contains_this()) {
+ if (func instanceof AST_Lambda && !func.contains_this()) {
return make_sequence(this, [
self.args[0],
make_node(AST_Call, self, {
@@ -3925,7 +3926,7 @@ merge(Compressor.prototype, {
}
}
}
- var stat = fn instanceof AST_Function && fn.body[0];
+ var stat = is_func && fn.body[0];
if (compressor.option("inline") && stat instanceof AST_Return) {
var value = stat.value;
if (!value || value.is_constant_expression()) {
@@ -3933,7 +3934,7 @@ merge(Compressor.prototype, {
return make_sequence(self, args).optimize(compressor);
}
}
- if (fn instanceof AST_Function) {
+ if (is_func) {
var def, value, scope, level = -1;
if (compressor.option("inline")
&& !fn.uses_arguments
@@ -4670,11 +4671,8 @@ merge(Compressor.prototype, {
&& is_lhs(self, compressor.parent()) !== self) {
var d = self.definition();
var fixed = self.fixed_value();
- if (fixed instanceof AST_Defun) {
- d.fixed = fixed = make_node(AST_Function, fixed, fixed);
- }
var single_use = d.single_use;
- if (single_use && fixed instanceof AST_Function) {
+ if (single_use && fixed instanceof AST_Lambda) {
if (d.scope !== self.scope
&& (!compressor.option("reduce_funcs")
|| d.escaped == 1
@@ -4695,6 +4693,9 @@ merge(Compressor.prototype, {
}
}
if (single_use && fixed) {
+ if (fixed instanceof AST_Defun) {
+ fixed = make_node(AST_Function, fixed, fixed);
+ }
var value;
if (d.recursive_refs > 0 && fixed.name instanceof AST_SymbolDefun) {
value = fixed.clone(true);
@@ -4705,6 +4706,7 @@ merge(Compressor.prototype, {
value.walk(new TreeWalker(function(node) {
if (node instanceof AST_SymbolRef && node.definition() === defun_def) {
node.thedef = lambda_def;
+ lambda_def.references.push(node);
}
}));
} else {