var scan_lhs = lhs && !side_effects && !is_lhs_read_only(lhs, compressor);
var scan_rhs = foldable(get_rhs(candidate));
if (!scan_lhs && !scan_rhs) continue;
+ var modify_toplevel = false;
// Locate symbols which may execute code outside of scanning range
var lvalues = get_lvalues(candidate);
var lhs_local = is_lhs_local(lhs);
if (candidate instanceof AST_VarDef) {
lvalues[candidate.name.name] = lhs;
}
+ var scan_iife = scope instanceof AST_Toplevel;
var tw = new TreeWalker(function(node) {
+ if (scan_iife && node.TYPE == "Call") {
+ var exp = node.expression;
+ if (exp instanceof AST_PropAccess) return;
+ if (exp instanceof AST_Function && !exp.contains_this()) return;
+ modify_toplevel = true;
+ scan_iife = false;
+ return;
+ }
var value;
if (node instanceof AST_SymbolRef) {
value = node.fixed_value() || node;
var def = sym.definition();
if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun) return false;
if (def.scope !== scope) return true;
+ if (modify_toplevel && compressor.exposed(def)) return true;
return !all(def.references, function(ref) {
return ref.scope.resolve() === scope;
});