}
}
+ function is_arguments(def) {
+ if (def.name != "arguments") return false;
+ var orig = def.orig;
+ return orig.length == 1 && orig[0] instanceof AST_SymbolFunarg;
+ }
+
(function(def) {
def(AST_Node, noop);
if (def.single_use == "m") return false;
if (tw.safe_ids[def.id]) {
if (def.fixed == null) {
- var orig = def.orig[0];
- if (orig instanceof AST_SymbolFunarg || orig.name == "arguments") return false;
- def.fixed = make_node(AST_Undefined, orig);
+ if (is_arguments(def)) return false;
+ def.fixed = make_node(AST_Undefined, def.orig);
}
return true;
}
if (!(node instanceof AST_Sub)) return;
var expr = node.expression;
var prop = node.property;
- if (expr instanceof AST_SymbolRef && expr.name == "arguments" && prop instanceof AST_Number) {
+ if (expr instanceof AST_SymbolRef
+ && is_arguments(expr.definition())
+ && prop instanceof AST_Number) {
expr.definition().reassigned = true;
}
}
});
def(AST_Unary, function(tw, descend) {
var node = this;
- if (node.operator != "++" && node.operator != "--") return;
+ if (!unary_arithmetic[node.operator]) return;
var exp = node.expression;
if (!(exp instanceof AST_SymbolRef)) {
mark_assignment_to_arguments(exp);
extract_candidates(expr.expression);
expr.body.forEach(extract_candidates);
} else if (expr instanceof AST_Unary) {
- if (expr.operator == "++" || expr.operator == "--") {
+ if (unary_arithmetic[expr.operator]) {
candidates.push(hit_stack.slice());
} else {
extract_candidates(expr.expression);
function mangleable_var(var_def) {
var value = var_def.value;
if (!(value instanceof AST_SymbolRef)) return;
- if (value.name == "arguments") return;
var def = value.definition();
if (def.undeclared) return;
+ if (is_arguments(def)) return;
return value_def = def;
}
if (!is_strict(compressor)) return false;
if (is_undeclared_ref(this) && this.is_declared(compressor)) return false;
if (this.is_immutable()) return false;
+ if (is_arguments(this.definition())) return false;
var fixed = this.fixed_value();
if (!fixed) return true;
this._dot_throw = return_true;
});
var lazy_op = makePredicate("&& ||");
+ var unary_arithmetic = makePredicate("++ --");
var unary_side_effects = makePredicate("delete ++ --");
function is_lhs(node, parent) {
OPT(AST_For, function(self, compressor) {
if (!compressor.option("loops")) return self;
- if (compressor.option("side_effects") && self.init) {
- self.init = self.init.drop_side_effect_free(compressor);
+ if (compressor.option("side_effects")) {
+ if (self.init) self.init = self.init.drop_side_effect_free(compressor);
+ if (self.step) self.step = self.step.drop_side_effect_free(compressor);
}
if (self.condition) {
var cond = self.condition.evaluate(compressor);
var fn;
if (compressor.option("arguments")
&& expr instanceof AST_SymbolRef
- && expr.name == "arguments"
- && expr.definition().orig.length == 1
+ && is_arguments(expr.definition())
&& prop instanceof AST_Number
&& (fn = expr.scope) === compressor.find_parent(AST_Lambda)) {
var index = prop.getValue();