}
}
+ function is_identifier_atom(node) {
+ return node instanceof AST_Infinity
+ || node instanceof AST_NaN
+ || node instanceof AST_Undefined;
+ }
+
function tighten_body(statements, compressor) {
var CHANGED, max_iter = 10;
do {
return node;
}
var def = candidate.name.definition();
+ var value = candidate.value;
if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
def.replaced++;
- return maintain_this_binding(parent, node, candidate.value);
+ if (funarg && is_identifier_atom(value)) {
+ return value.transform(compressor);
+ } else {
+ return maintain_this_binding(parent, node, value);
+ }
}
return make_node(AST_Assign, candidate, {
operator: "=",
left: make_node(AST_SymbolRef, candidate.name, candidate.name),
- right: candidate.value
+ right: value
});
}
candidate.write_only = false;
replace_all = def.references.length - def.replaced == 1;
}
var side_effects = value_has_side_effects(candidate);
- var hit = candidate.name instanceof AST_SymbolFunarg;
+ var funarg = candidate.name instanceof AST_SymbolFunarg;
+ var hit = funarg;
var abort = false, replaced = 0, can_replace = !args || !hit;
if (!can_replace) {
for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
if (abort && def.references.length - def.replaced > replaced) replaced = false;
else {
abort = false;
- hit = candidate.name instanceof AST_SymbolFunarg;
+ hit = funarg;
for (var i = stat_index; !abort && i < statements.length; i++) {
statements[i].transform(multi_replacer);
}
if (self.operator == "delete"
&& !(e instanceof AST_SymbolRef
|| e instanceof AST_PropAccess
- || e instanceof AST_NaN
- || e instanceof AST_Infinity
- || e instanceof AST_Undefined)) {
+ || is_identifier_atom(e))) {
if (e instanceof AST_Sequence) {
e = e.expressions.slice();
e.push(make_node(AST_True, self));