Lines Matching refs:def

129         var def = name.definition();
130 if (def.direct_access) return false;
131 var escaped = def.escaped;
165 this.top_retain = function(def) { argument
166 return top_retain.test(def.name);
174 this.top_retain = function(def) { argument
175 return member(def.name, top_retain);
224 Compressor.prototype.exposed = function(def) { argument
225 if (def.exported) return true;
226 if (def.undeclared) return true;
227 if (!(def.global || def.scope.resolve() instanceof AST_Toplevel)) return false;
229 return !all(def.orig, function(sym) {
473 function is_arguments(def) { argument
474 return def.name == "arguments" && def.scope.uses_arguments;
477 function cross_scope(def, sym) { argument
479 if (def === sym) return false;
485 var def = ref.redef || ref.definition();
486 if (ref.in_arg && is_funarg(def)) return false;
487 return all(def.orig, function(sym) {
514 var def = ref.definition();
515 def.references.push(node);
516 def.replaced++;
522 (function(def) { argument
523 def(AST_Node, noop);
525 function reset_def(tw, compressor, def) { argument
526 def.assignments = 0;
527 def.bool_return = 0;
528 def.drop_return = 0;
529 def.cross_loop = false;
530 def.direct_access = false;
531 def.escaped = [];
532 def.fixed = !def.const_redefs
533 && !def.scope.pinned()
534 && !compressor.exposed(def)
535 && !(def.init instanceof AST_LambdaExpression && def.init !== def.scope)
536 && def.init;
537 def.reassigned = 0;
538 def.recursive_refs = 0;
539 def.references = [];
540 def.single_use = undefined;
544 scope.variables.each(function(def) { argument
545 reset_def(tw, compressor, def);
551 scope.variables.each(function(def) { argument
552 reset_def(tw, compressor, def);
553 var init = def.init;
558 if (def.fixed === null) {
559 def.safe_ids = tw.safe_ids;
560 mark(tw, def);
561 } else if (def.fixed) {
562 tw.loop_ids[def.id] = tw.in_loop;
563 mark(tw, def);
572 if (compressor.option("ie")) scope.variables.each(function(def) { argument
573 var d = def.orig[0].definition();
574 if (d !== def) d.fixed = false;
602 function mark_fn_def(tw, def, fn) { argument
617 } else if (tw.fn_scanning && tw.fn_scanning !== def.scope.resolve()) {
655 function mark(tw, def) { argument
656 tw.safe_ids[def.id] = {};
659 function push_ref(def, ref) { argument
660 def.references.push(ref);
661 if (def.last_ref !== false) def.last_ref = ref;
664 function safe_to_read(tw, def) { argument
665 if (def.single_use == "m") return false;
666 var safe = tw.safe_ids[def.id];
668 var in_order = HOP(tw.safe_ids, def.id);
677 if (def.fixed == null) {
678 if (is_arguments(def)) return false;
679 if (def.global && def.name == "arguments") return false;
680 tw.loop_ids[def.id] = null;
681 def.fixed = make_node(AST_Undefined, def.orig[0]);
682 if (in_order) def.safe_ids = undefined;
687 return def.fixed instanceof AST_LambdaDefinition;
690 function safe_to_assign(tw, def, declare) { argument
692 … if (is_funarg(def) && def.scope.uses_arguments && !tw.has_directive("use strict")) return false;
693 if (!all(def.orig, function(sym) {
697 if (def.fixed === undefined) return declare || all(def.orig, function(sym) {
700 if (def.fixed === false || def.fixed === 0) return false;
701 var safe = tw.safe_ids[def.id];
702 if (def.safe_ids) {
703 def.safe_ids[def.id] = false;
704 def.safe_ids = undefined;
705 return def.fixed === null || HOP(tw.safe_ids, def.id) && !safe.read;
707 if (!HOP(tw.safe_ids, def.id)) {
712 if (def.scope.resolve() !== scope.resolve()) return false;
716 if (def.fixed != null && safe.read) {
718 if (tw.loop_ids[def.id] !== tw.in_loop) return false;
720 return safe_to_read(tw, def) && all(def.orig, function(sym) {
725 function ref_once(compressor, def) { argument
727 && !def.scope.pinned()
728 && def.single_use !== false
729 && def.references.length - def.recursive_refs == 1
730 && !(is_funarg(def) && def.scope.uses_arguments);
784 var def = expr.definition();
785 if (!is_arguments(def)) return;
789 def.reassigned++;
790 …(key instanceof AST_Node ? def.scope.argnames : [ def.scope.argnames[key] ]).forEach(function(argn…
965 def(AST_Assign, function(tw, descend, compressor) {
1099 def(AST_Binary, function(tw) {
1107 def(AST_BlockScope, function(tw, descend, compressor) {
1110 def(AST_Call, function(tw, descend) {
1158 var def = node.definition();
1159 def.bool_return++;
1160 if (drop) def.drop_return++;
1164 def(AST_Class, function(tw, descend, compressor) {
1206 def(AST_ClassInitBlock, function(tw, descend, compressor) {
1214 def(AST_Conditional, function(tw) {
1224 def(AST_DefaultValue, function(tw) {
1231 def(AST_Do, function(tw) {
1245 def(AST_For, function(tw, descend, compressor) {
1265 def(AST_ForEnumeration, function(tw, descend, compressor) {
1276 var def = node.definition();
1277 def.assignments++;
1278 def.fixed = false;
1284 var def = node.definition();
1285 push_ref(def, node);
1286 def.assignments++;
1287 if (!node.is_immutable()) def.fixed = false;
1298 def(AST_If, function(tw) {
1310 def(AST_LabeledStatement, function(tw) {
1316 def(AST_Lambda, function(tw, descend, compressor) {
1328 def(AST_LambdaDefinition, function(tw, descend, compressor) {
1330 var def = fn.name.definition();
1332 …if (parent instanceof AST_ExportDeclaration || parent instanceof AST_ExportDefault) def.single_use…
1342 def(AST_Sub, function(tw) {
1350 def(AST_Switch, function(tw, descend, compressor) {
1367 def(AST_SwitchBranch, function(tw) {
1373 def(AST_SymbolCatch, function() {
1376 def(AST_SymbolImport, function() {
1379 def(AST_SymbolRef, function(tw, descend, compressor) {
1388 if (recursive) recursive.enclosed.forEach(function(def) { argument
1389 if (d === def) return;
1390 if (def.scope.resolve() === recursive) return;
1391 var assigns = def.fixed && def.fixed.assigns;
1394 var safe = tw.safe_ids[def.id];
1450 def(AST_Template, function(tw, descend) {
1473 def(AST_Toplevel, function(tw, descend, compressor) {
1475 node.globals.each(function(def) { argument
1476 reset_def(tw, compressor, def);
1484 def(AST_Try, function(tw, descend, compressor) {
1498 def(AST_Unary, function(tw, descend) {
1545 def(AST_VarDef, function(tw, descend, compressor) {
1582 def(AST_While, function(tw, descend) {
1623 var def = this.definition();
1624 var fixed = def.fixed;
1632 if (ref_only && def.escaped.depth != 1 && is_object(value, true)) return value;
1637 var def = this.redef || this.definition();
1638 if (!(def.orig[0] instanceof AST_SymbolLambda)) return false;
1639 if (def.orig.length == 1) return true;
1641 return !(def.orig[1] instanceof AST_SymbolFunarg);
1675 var def = ref.definition();
1676 def.assignments++;
1677 def.references.push(ref);
1770 var def = lhs.definition();
1771 return compressor.exposed(def) && identifier_atom[def.name];
1847 var def = node.definition();
1849 if (!fixed || !fixed_by_id.has(def.id)) {
1850 fixed_by_id.set(def.id, fixed);
1851 } else if (fixed_by_id.get(def.id) !== fixed) {
1852 fixed_by_id.set(def.id, false);
1857 var def = node.definition();
1859 if (!fixed || !fixed_by_id.has(def.id)) return;
1860 if (fixed_by_id.get(def.id) !== fixed) node.fixed = false;
1880 var def = stat.name.definition();
1882 return def.scope === scope || all(def.references, function(ref) {
2236 var def = candidate.name.definition();
2237 if (def.references.length - def.replaced == 1 && !compressor.exposed(def)) {
2238 def.replaced++;
2291 && !(node.variables && node.variables.all(function(def) { argument
2292 return !enclosed.has(def.name) && !lvalues.has(def.name);
2314 def.replaced++;
2325 def.replaced++;
2334 if (node instanceof AST_SymbolRef && node.definition() === def) {
2349 def.replaced++;
2429 var def = lhs.definition();
2438 && def.references.length == def.replaced
2439 && !compressor.exposed(def);
2571 var def, fn = node.expression;
2573 def = fn.definition();
2577 if (def && recursive_ref(compressor, def, fn)) return true;
2647 var def = node.definition();
2648 return (in_try || def.scope.resolve() !== scope) && !can_drop_symbol(node);
2747 var def;
2749 || (def = fn.variables.get(node.name)) && def !== node.definition()) {
2905 var def = expr.name.definition();
2906 if (def.references.length > def.replaced) {
3109 var def = value.definition();
3110 if (def.undeclared) return;
3111 if (is_arguments(def)) return;
3114 var referenced = def.references.length - def.replaced;
3124 return value_def = def;
3127 function remaining_refs(def) { argument
3128 return def.references.length - def.replaced - (assignments.get(def.name) || 0);
3135 var def = lhs.definition();
3136 if (scope.uses_arguments && is_funarg(def)) return lhs;
3137 if (compressor.exposed(def)) return lhs;
3138 remaining = remaining_refs(def);
3139 if (def.fixed && lhs.fixed) {
3140 var matches = def.references.filter(function(ref) {
3156 var def = lhs.definition();
3157 if (def.const_redefs) return;
3158 if (!member(lhs, def.orig)) return;
3159 if (scope.uses_arguments && is_funarg(def)) return;
3160 … var declared = def.orig.length - def.eliminated - (declare_only.get(def.name) || 0);
3161 remaining = remaining_refs(def);
3162 … if (def.fixed) remaining = Math.min(remaining, def.references.filter(function(ref) {
3172 if (mangleable_var(expr.value) || remaining == 1 && !compressor.exposed(def)) {
3291 var def = node.definition();
3292 var escaped = node.fixed && node.fixed.escaped || def.escaped;
3293 if (!def.undeclared
3294 && (def.assignments || !escaped || escaped.cross_scope)
3295 … && (has_escaped(def, node.scope, node, tw.parent()) || !same_scope(def))) {
3327 node.enclosed.forEach(function(def) { argument
3328 if (def.scope !== node) enclosed.set(def.name, true);
3453 var def = lhs.definition();
3454 if (def.references.length - def.replaced == referenced) return true;
3455 if (!def.fixed) return false;
3459 if (!all(def.references, function(ref, index) {
3484 var def = sym.definition();
3485 if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun) return false;
3486 if (def.scope.resolve() !== scope) return true;
3487 if (modify_toplevel && compressor.exposed(def)) return true;
3488 return !all(def.references, function(ref) {
4131 var def = defn.definitions[i];
4132 if (!def.value) continue;
4133 if (trim_assigns(def.name, def.value, exprs)) trimmed = true;
4134 if (merge_conditional_assignments(def, exprs, keep)) trimmed = true;
4161 var def = var_def.name.definition();
4163 var cond = to_conditional_assignment(compressor, def, var_def.value, exprs[0]);
4182 var def = lhs.definition();
4183 if (def.scope !== scope) break;
4184 if (def.orig.length > def.eliminated + 1) break;
4185 if (def.orig[0].TYPE != "SymbolVar") break;
4191 def.orig.push(name);
4192 def.replaced++;
4442 (function(def) { argument
4443 def(AST_Class, return_true);
4444 def(AST_Scope, function(compressor) {
4461 (function(def) { argument
4462 def(AST_Node, return_false);
4463 def(AST_Array, return_true);
4464 def(AST_Assign, function() {
4467 def(AST_Lambda, return_true);
4468 def(AST_Object, return_true);
4469 def(AST_RegExp, return_true);
4470 def(AST_Sequence, function() {
4473 def(AST_SymbolRef, function() {
4487 (function(def) { argument
4488 def(AST_Node, return_true);
4489 def(AST_Array, return_false);
4507 def(AST_Assign, function() {
4512 def(AST_Binary, function() {
4515 def(AST_Constant, function() {
4518 def(AST_Lambda, return_false);
4519 def(AST_Object, return_false);
4520 def(AST_RegExp, return_false);
4521 def(AST_Sequence, function() {
4524 def(AST_SymbolRef, function() {
4532 def(AST_UnaryPrefix, function() {
4542 (function(def) { argument
4549 def(AST_Node, is_strict);
4550 def(AST_Array, return_false);
4551 def(AST_Assign, function(compressor) {
4565 def(AST_Binary, function(compressor) {
4568 def(AST_Class, function(compressor, force) {
4575 def(AST_Conditional, function(compressor) {
4578 def(AST_Constant, return_false);
4579 def(AST_Dot, function(compressor, force) {
4585 def(AST_Lambda, return_false);
4586 def(AST_Null, return_true);
4587 def(AST_Object, function(compressor, force) {
4593 def(AST_ObjectIdentity, function(compressor, force) {
4596 def(AST_Sequence, function(compressor) {
4599 def(AST_SymbolRef, function(compressor, force) {
4604 var def = this.definition();
4605 if (is_arguments(def) && !def.scope.rest && all(def.scope.argnames, function(argname) {
4607 })) return def.scope.uses_arguments > 2;
4618 def(AST_UnaryPrefix, function() {
4621 def(AST_UnaryPostfix, return_false);
4622 def(AST_Undefined, return_true);
4627 (function(def) { argument
4628 def(AST_Node, return_false);
4629 def(AST_Array, return_true);
4642 def(AST_Assign, function(compressor) {
4647 def(AST_Binary, function(compressor) {
4650 def(AST_Conditional, function(compressor) {
4653 def(AST_Constant, return_true);
4654 def(AST_Hole, return_false);
4655 def(AST_Lambda, return_true);
4656 def(AST_Object, return_true);
4657 def(AST_Sequence, function(compressor) {
4660 def(AST_SymbolRef, function(compressor) {
4671 def(AST_UnaryPrefix, function() {
4674 def(AST_UnaryPostfix, return_true);
4675 def(AST_Undefined, return_false);
4683 (function(def) { argument
4684 def(AST_Node, return_false);
4685 def(AST_Assign, function(compressor) {
4689 def(AST_Binary, function(compressor) {
4694 def(AST_Boolean, return_true);
4696 def(AST_Call, function(compressor) {
4702 def(AST_Conditional, function(compressor) {
4705 def(AST_New, return_false);
4706 def(AST_Sequence, function(compressor) {
4709 def(AST_SymbolRef, function(compressor) {
4718 def(AST_UnaryPrefix, function() {
4726 (function(def) { argument
4727 def(AST_Node, return_false);
4729 def(AST_Assign, function(compressor) {
4733 def(AST_Binary, function(compressor) {
4782 def(AST_Call, function(compressor) {
4788 def(AST_Conditional, function(compressor) {
4791 def(AST_New, return_false);
4792 def(AST_Number, return_true);
4793 def(AST_Sequence, function(compressor) {
4796 def(AST_SymbolRef, function(compressor, keep_unary) {
4811 def(AST_Unary, function() {
4819 (function(def) { argument
4820 def(AST_Node, return_false);
4821 def(AST_Assign, function(compressor) {
4829 def(AST_Binary, function(compressor) {
4845 def(AST_Call, function(compressor) {
4850 def(AST_Conditional, function(compressor) {
4853 def(AST_Sequence, function(compressor) {
4856 def(AST_String, return_true);
4857 def(AST_SymbolRef, function(compressor) {
4865 def(AST_Template, function(compressor) {
4868 def(AST_UnaryPrefix, function() {
4877 (function(def) { argument
4906 var def = node._find_defs(compressor, "");
4907 if (!def) return;
4918 return def;
4921 def(AST_Node, noop);
4922 def(AST_Dot, function(compressor, suffix) {
4925 def(AST_SymbolDeclaration, function(compressor) {
4929 def(AST_SymbolRef, function(compressor, suffix) {
5092 (function(def) { argument
5093 def(AST_Node, return_false);
5094 def(AST_Constant, return_true);
5095 def(AST_RegExp, return_false);
5097 def(AST_UnaryPrefix, function() {
5105 (function(def) { argument
5148 def(AST_Statement, function() {
5151 def(AST_Accessor, return_this);
5152 def(AST_BigInt, return_this);
5153 def(AST_Class, return_this);
5154 def(AST_Node, return_this);
5155 def(AST_Constant, function() {
5158 def(AST_Assign, function(compressor, ignore_side_effects, cached, depth) {
5164 var def = lhs.definition();
5165 if (!def.fixed) return this;
5166 if (def.undeclared) return this;
5167 if (def.last_ref !== lhs) return this;
5168 if (def.single_use == "m") return this;
5191 def(AST_Sequence, function(compressor, ignore_side_effects, cached, depth) {
5201 def(AST_Lambda, function(compressor) {
5212 def(AST_Array, function(compressor, ignore_side_effects, cached, depth) {
5226 def(AST_Object, function(compressor, ignore_side_effects, cached, depth) {
5251 def(AST_UnaryPrefix, function(compressor, ignore_side_effects, cached, depth) {
5263 var def = e instanceof AST_SymbolRef && e.definition();
5264 if (!non_converting_unary[op] && !(def && def.fixed)) depth++;
5284 if (!def) return this;
5286 if (def.undeclared) return this;
5287 if (def.last_ref !== e) return this;
5295 def(AST_UnaryPostfix, function(compressor, ignore_side_effects, cached, depth) {
5302 var def = e.definition();
5303 if (!def.fixed) return this;
5304 if (def.undeclared) return this;
5305 if (def.last_ref !== e) return this;
5316 def(AST_Binary, function(compressor, ignore_side_effects, cached, depth) {
5378 def(AST_Conditional, function(compressor, ignore_side_effects, cached, depth) {
5402 def(AST_SymbolRef, function(compressor, ignore_side_effects, cached, depth) {
5447 def(AST_PropAccess, function(compressor, ignore_side_effects, cached, depth) {
5490 def(AST_Call, function(compressor, ignore_side_effects, cached, depth) {
5584 var def = sym.definition();
5585 if (def.orig[def.orig.length - 1] !== sym) return false;
5587 def.references.forEach(function(node) {
5596 def(AST_New, return_this);
5597 def(AST_Template, function(compressor, ignore_side_effects, cached, depth) {
5627 (function(def) { argument
5641 def(AST_Node, function() {
5644 def(AST_Statement, function() {
5647 def(AST_Binary, function(compressor, first_in_statement) {
5675 def(AST_ClassExpression, function() {
5678 def(AST_Conditional, function(compressor, first_in_statement) {
5684 def(AST_LambdaExpression, function() {
5687 def(AST_Sequence, function(compressor) {
5692 def(AST_UnaryPrefix, function() {
5758 (function(def) { argument
5759 def(AST_Node, return_false);
5760 def(AST_Array, return_true);
5761 def(AST_Assign, function() {
5772 def(AST_Binary, function() {
5775 def(AST_Constant, return_true);
5776 def(AST_Lambda, return_true);
5777 def(AST_Object, function() {
5782 def(AST_Sequence, function() {
5785 def(AST_SymbolRef, function() {
5789 def(AST_Unary, return_true);
5795 (function(def) { argument
5807 def(AST_Node, return_true);
5808 def(AST_Array, function(compressor) {
5811 def(AST_Assign, function(compressor) {
5820 def(AST_Binary, function(compressor) {
5825 def(AST_Block, function(compressor) {
5828 def(AST_Call, function(compressor) {
5835 def(AST_Case, function(compressor) {
5839 def(AST_Class, function(compressor) {
5847 def(AST_ClassProperty, function(compressor) {
5851 def(AST_Conditional, function(compressor) {
5856 def(AST_Constant, return_false);
5857 def(AST_Definitions, function(compressor) {
5860 def(AST_DestructuredArray, function(compressor) {
5863 def(AST_DestructuredKeyVal, function(compressor) {
5867 def(AST_DestructuredObject, function(compressor) {
5870 def(AST_Dot, function(compressor) {
5874 def(AST_EmptyStatement, return_false);
5875 def(AST_If, function(compressor) {
5880 def(AST_LabeledStatement, function(compressor) {
5883 def(AST_Lambda, return_false);
5884 def(AST_Object, function(compressor) {
5890 def(AST_ObjectIdentity, return_false);
5891 def(AST_ObjectProperty, function(compressor) {
5895 def(AST_Sequence, function(compressor) {
5898 def(AST_SimpleStatement, function(compressor) {
5901 def(AST_Sub, function(compressor) {
5906 def(AST_Switch, function(compressor) {
5910 def(AST_SymbolDeclaration, return_false);
5911 def(AST_SymbolRef, function(compressor) {
5914 def(AST_Template, function(compressor) {
5917 def(AST_Try, function(compressor) {
5922 def(AST_Unary, function(compressor) {
5926 def(AST_VarDef, function() {
5934 (function(def) { argument
5935 def(AST_Node, return_true);
5937 def(AST_Constant, return_false);
5938 def(AST_EmptyStatement, return_false);
5939 def(AST_Lambda, return_false);
5940 def(AST_ObjectIdentity, return_false);
5941 def(AST_SymbolDeclaration, return_false);
5959 def(AST_Array, function(compressor) {
5962 def(AST_Assign, function(compressor) {
5971 def(AST_Await, function(compressor) {
5974 def(AST_Binary, function(compressor) {
5979 def(AST_Block, function(compressor) {
5982 def(AST_Call, function(compressor) {
5990 def(AST_Case, function(compressor) {
5994 def(AST_Conditional, function(compressor) {
5999 def(AST_DefaultValue, function(compressor) {
6003 def(AST_Definitions, function(compressor) {
6006 def(AST_Dot, function(compressor) {
6010 def(AST_ForEnumeration, function(compressor) {
6018 def(AST_If, function(compressor) {
6023 def(AST_LabeledStatement, function(compressor) {
6026 def(AST_Object, function(compressor) {
6029 def(AST_ObjectProperty, function(compressor) {
6033 def(AST_Return, function(compressor) {
6036 def(AST_Sequence, function(compressor) {
6039 def(AST_SimpleStatement, function(compressor) {
6042 def(AST_Sub, function(compressor) {
6047 def(AST_Switch, function(compressor) {
6051 def(AST_SymbolRef, function(compressor) {
6054 def(AST_Template, function(compressor) {
6063 def(AST_Try, function(compressor) {
6067 def(AST_Unary, function(compressor) {
6071 def(AST_VarDef, function(compressor) {
6080 (function(def) { argument
6087 def(AST_Node, return_false);
6088 def(AST_Array, function(scope) {
6091 def(AST_Binary, function(scope) {
6096 def(AST_Class, function(scope) {
6101 def(AST_ClassProperty, function(scope) {
6104 def(AST_Constant, return_true);
6105 def(AST_Lambda, function(scope) {
6124 var def = node.definition();
6125 if (member(def.scope, scopes)) return true;
6126 if (scope && !def.redefined()) {
6128 if (scope_def ? scope_def === def : def.undeclared) {
6145 def(AST_Object, function(scope) {
6148 def(AST_ObjectProperty, function(scope) {
6151 def(AST_Unary, function(scope) {
6162 (function(def) { argument
6163 def(AST_Statement, return_null);
6164 def(AST_Jump, return_this);
6169 def(AST_BlockStatement, block_aborts);
6170 def(AST_SwitchBranch, block_aborts);
6171 def(AST_If, function() {
6314 if (!all(fn.enclosed, function(def) { argument
6315 return def.scope !== self;
6551 var def = node.definition();
6552 references[def.id] = false;
6553 if (def = def.redefined()) references[def.id] = false;
6660 var def = tail.definition;
6661 var tail_refs = references[def.id];
6664 while (def.id in merged) def = merged[def.id];
6665 tail_refs.start = references[def.id].start;
6676 … || (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
6677 || compressor.option("webkit") && is_funarg(def) !== is_funarg(prev_def)
6680 return scope.find_variable(def.name) === def;
6686 sym.thedef = def;
6687 sym.name = def.name;
6689 def.references.push(sym);
6692 def.orig.push(sym);
6696 if (!prev_def.fixed) def.fixed = false;
6697 merged[prev_def.id] = def;
6745 var def = sym.definition(), ldef;
6750 return ldef !== def
6751 && !def.undeclared
6752 && fn.parent_scope.find_variable(sym.name) !== def;
6753 })) return references[def.id] = references[ldef.id] = false;
6760 if (def.id in references) {
6761 var refs = references[def.id];
6763 if (refs.start.block !== seg.block) return references[def.id] = false;
6766 if (def.id in prev) {
6767 last[prev[def.id]] = null;
6771 } else if ((ldef = self.variables.get(def.name)) !== def) {
6773 return references[def.id] = false;
6774 } else if (compressor.exposed(def) || NO_MERGE[sym.name]) {
6775 return references[def.id] = false;
6777 var refs = declarations.get(def.id) || [];
6780 references[def.id] = refs;
6785 definition: def,
6788 if (seg.block !== self) return references[def.id] = false;
6791 prev[def.id] = last.length;
6794 definition: def,
6881 var def = sym.definition();
6882 if (export_defaults[def.id]) return;
6883 if (compressor.exposed(def)) return;
6916 var def = find(name);
6917 if (def) return def;
6918 def = parent.variables.get(name);
6919 if (def) {
6920 var sym = def.orig[0];
6921 … if (sym instanceof AST_SymbolFunarg || sym instanceof AST_SymbolLambda) return def;
6936 self.variables.each(function(def) { argument
6937 if (compressor.top_retain(def) && !(def.id in in_use_ids)) {
6938 AST_Node.info("Retaining variable {name}", def);
6939 in_use_ids[def.id] = true;
6940 in_use.push(def);
6952 var def = argname.definition();
6953 if (!(def.id in in_use_ids)) {
6954 in_use_ids[def.id] = true;
6955 in_use.push(def);
6962 var def = node.name.definition();
6963 var drop = drop_funcs && !def.exported;
6964 if (!drop && !(def.id in in_use_ids)) {
6965 in_use_ids[def.id] = true;
6966 in_use.push(def);
6970 export_defaults[def.id] = true;
6971 } else if (drop && !(def.id in lambda_ids)) {
6972 lambda_ids[def.id] = 1;
6988 initializations.add(def.id, value);
6993 var def = node.name.definition();
6994 var drop = drop_funcs && !def.exported;
6995 if (!drop && !(def.id in in_use_ids)) {
6996 in_use_ids[def.id] = true;
6997 in_use.push(def);
6999 initializations.add(def.id, node);
7001 export_defaults[def.id] = true;
7004 if (drop && !(def.id in lambda_ids)) lambda_ids[def.id] = 1;
7015 var def = name.definition();
7016 var_defs[def.id] = (var_defs[def.id] || 0) + 1;
7017 if (node instanceof AST_Var && def.orig[0] instanceof AST_SymbolCatch) {
7018 var redef = def.redefined();
7021 if (!(def.id in in_use_ids) && (!drop_vars || def.exported
7022 || (node instanceof AST_Const ? def.redefined() : def.const_redefs)
7023 || !(node instanceof AST_Var || is_safe_lexical(def)))) {
7024 in_use_ids[def.id] = true;
7025 in_use.push(def);
7029 initializations.add(def.id, value);
7031 verify_safe_usage(def, name, value_modified[def.id]);
7033 assignments.add(def.id, defn);
7035 unmark_lambda(def);
7043 var def = node.definition();
7044 var_defs[def.id] = (var_defs[def.id] || 0) + 1;
7045 assignments.add(def.id, node);
7049 var def = node.definition();
7050 if (!(def.id in in_use_ids) && (!drop_vars || !is_safe_lexical(def))) {
7051 in_use_ids[def.id] = true;
7052 in_use.push(def);
7068 …_name = compressor.option("keep_fnames") ? return_false : compressor.option("ie") ? function(def) {
7069 return !compressor.exposed(def) && def.references.length == def.replaced;
7070 } : function(def) {
7071 if (!(def.id in in_use_ids)) return true;
7072 if (def.orig.length - def.eliminated < 2) return false;
7074 if (def.orig[1] instanceof AST_SymbolFunarg) return true;
7076 return all(def.references, function(ref) {
7245 var def = node.name.definition();
7246 if (!(def.id in in_use_ids)) {
7248 def.eliminated++;
7262 var def = node.name.definition();
7263 if (!(def.id in in_use_ids)) {
7265 def.eliminated++;
7318 var def = sym.definition();
7319 if (def.id in in_use_ids) {
7321 if (indexOf_assign(def, sym) < 0) sym.unused = null;
7325 def.eliminated++;
7382 node.definitions.forEach(function(def) { argument
7383 if (def.value) def.value = def.value.transform(tt);
7384 var value = def.value;
7385 if (def.name instanceof AST_Destructured) {
7386 var trimmed = trim_destructured(def.name, value, function(node) {
7394 def = make_node(AST_VarDef, def, {
7404 var sym = def.name.definition();
7405 var drop_sym = is_var ? can_drop_symbol(def.name) : is_safe_lexical(sym);
7408 … if (value && ((index = indexOf_assign(sym, def)) < 0 || self_assign(value.tail_node()))) {
7409 def = def.clone();
7411 … if (value) AST_Node.warn("Side effects in definition of variable {name} [{start}]", def.name);
7413 def.value = value || make_node(AST_Number, def, { value: 0 });
7415 def.value = null;
7419 if (index >= 0) assign_in_use[sym.id][index] = def;
7426 … AST_Node.info("Dropping declaration of variable {name} [{start}]", def.name);
7430 head.push(def);
7443 && (old_def = rename_def(fn, def.name.name)) !== false) {
7444 AST_Node.warn("Declaring {name} as function [{start}]", def.name);
7461 defun.name = make_node(AST_SymbolDefun, def.name);
7462 var name_def = def.name.scope.resolve().def_function(defun.name);
7474 && sym.orig.indexOf(def.name) > sym.eliminated) {
7480 } else if (is_catch(def.name)) {
7484 … AST_Node.warn("Dropping duplicated declaration of variable {name} [{start}]", def.name);
7488 def.value = null;
7489 head.push(def);
7494 … AST_Node.warn("Side effects in initialization of unused variable {name} [{start}]", def.name);
7497 log(def.name, "Dropping unused variable {name}");
7507 if (refs.length == 0) return fn === def.name.fixed_value();
7524 var def = fn.name.definition();
7525 if (def.orig.length > 1) return null;
7526 if (def.assignments > 0) return false;
7527 if (def.name == name) return def;
7538 return all(def.references, function(ref) {
7546 }) && def;
7562 def.value = make_sequence(value, side_effects);
7564 def.value = make_node(AST_UnaryPrefix, def, {
7566 expression: make_sequence(def, side_effects),
7571 tail.push(def);
7578 [].unshift.apply(side_effects, tail.map(function(def) { argument
7579 … AST_Node.info("Dropping duplicated definition of variable {name} [{start}]", def.name);
7580 var sym = def.name.definition();
7581 var ref = make_node(AST_SymbolRef, def.name);
7583 var assign = make_node(AST_Assign, def, {
7586 right: def.value,
7588 var index = indexOf_assign(sym, def);
7679 var def = sym.definition();
7680 if (def.id in in_use_ids) return;
7682 if (for_ins[def.id] === node) delete for_ins[def.id];
7689 … if (node.init instanceof AST_Definitions && def.orig[0] instanceof AST_SymbolCatch) {
7743 function track_assigns(def, node) { argument
7744 if (def.scope.resolve() !== self) return false;
7745 if (!def.fixed || !node.fixed) assign_in_use[def.id] = false;
7746 return assign_in_use[def.id] !== false;
7749 function add_assigns(def, node) { argument
7750 if (!assign_in_use[def.id]) assign_in_use[def.id] = [];
7751 if (node.fixed.assigns) push_uniq(assign_in_use[def.id], node.fixed.assigns);
7754 function indexOf_assign(def, node) { argument
7755 var nodes = assign_in_use[def.id];
7759 function unmark_lambda(def) { argument
7760 if (lambda_ids[def.id] > 1 && !(def.id in in_use_ids)) {
7761 in_use_ids[def.id] = true;
7762 in_use.push(def);
7764 lambda_ids[def.id] = 0;
7767 function verify_safe_usage(def, read, modified) { argument
7768 if (def.id in in_use_ids) return;
7770 in_use_ids[def.id] = read;
7771 in_use.push(def);
7773 value_read[def.id] = read;
7774 value_modified[def.id] = modified;
7779 var def = sym.definition();
7780 var in_use = in_use_ids[def.id];
7783 …return in_use === sym && def.references.length - def.replaced == 1 || indexOf_assign(def, node) < …
7792 var def = assign.left.definition();
7793 if (rhs.left.definition() !== def) return rhs;
7795 if (track_assigns(def, rhs.left)) add_assigns(def, rhs.left);
7811 var def = node.left.definition();
7812 if (def.scope.resolve() === self) assignments.add(def.id, node);
7816 var def = node.expression.definition();
7817 if (def.scope.resolve() === self) assignments.add(def.id, node);
7826 var def = node.definition();
7827 return def.references.length > def.replaced;
7883 var def = sym.definition();
7884 if (def.scope.resolve() !== self) {
7886 if (d === def || d && d.redefined() === def) return;
8356 function can_trim_returns(def, self_returns, compressor) { argument
8357 if (compressor.exposed(def)) return false;
8358 switch (def.references.length - def.replaced - (self_returns[def.id] || 0)) {
8359 case def.drop_return:
8361 case def.bool_return:
8449 function can_trim(def) { argument
8450 switch (can_trim_returns(def, self_returns, compressor)) {
8463 this.enclosed.forEach(function(def) { argument
8464 var_names.set(def.name, true);
8466 this.variables.each(function(def, name) { argument
8491 var def = this.def_variable(sym);
8493 scope.enclosed.push(def);
8577 var def = defs.get(node.get_property());
8579 name: def.name,
8581 thedef: def,
8596 var def = sym.definition();
8597 if (def.assignments != count) return;
8598 if (def.references.length - def.replaced == count) return;
8599 if (def.single_use) return;
8600 if (self.find_variable(sym.name) !== def) return;
8601 if (top_retain(def)) return;
8603 var fixed = sym.fixed || def.fixed;
8617 var def = fn.name.definition();
8618 if (compressor.exposed(def)) return false;
8619 return all(def.references, function(sym) {
8642 var def = exp.name.definition();
8643 drop_body = def.references.length == def.replaced;
8741 (function(def) { argument
8773 def(AST_Node, return_this);
8774 def(AST_Accessor, return_null);
8775 def(AST_Array, function(compressor, first_in_statement) {
8783 def(AST_Assign, function(compressor) {
8796 def(AST_Await, function(compressor) {
8812 def(AST_Binary, function(compressor, first_in_statement) {
8856 def(AST_Call, function(compressor, first_in_statement) {
8905 def(AST_ClassExpression, function(compressor, first_in_statement) {
8983 def(AST_Conditional, function(compressor) {
9021 def(AST_Constant, return_null);
9022 def(AST_Dot, function(compressor, first_in_statement) {
9027 def(AST_Function, function(compressor) {
9030 def(AST_LambdaExpression, return_null);
9031 def(AST_Object, function(compressor, first_in_statement) {
9053 def(AST_ObjectIdentity, return_null);
9054 def(AST_Sequence, function(compressor, first_in_statement) {
9080 def(AST_Sub, function(compressor, first_in_statement) {
9090 def(AST_SymbolRef, function(compressor) {
9093 def(AST_Template, function(compressor, first_in_statement) {
9111 def(AST_Unary, function(compressor, first_in_statement) {
9355 var def = node.definition();
9356 return !same_scope(def) || may_overlap(compressor, def);
9399 var def = sym.definition();
9407 if (!(ref instanceof AST_SymbolRef && ref.definition() === def)) return;
9460 if (node.definition() === def) refs.push(node);
10071 var def = var_def.name.definition().redefined();
10072 if (!def) return;
10074 var_def.name.thedef = def;
10119 var def = defn.name.definition();
10134 fixed.direct_access = def.direct_access;
10135 fixed.escaped = def.escaped;
10137 def.references.forEach(function(ref) {
10146 if (def.fixed === ref.fixed) def.fixed = fixed;
10149 def.references.push(name);
10151 def.assignments++;
10152 def.eliminated++;
10153 def.single_use = false;
10160 function is_safe_lexical(def) { argument
10161 …return def.name != "arguments" && def.orig.length < (def.orig[0] instanceof AST_SymbolLambda ? 3 :…
10164 function may_overlap(compressor, def) { argument
10165 if (compressor.exposed(def)) return true;
10166 var scope = def.scope.resolve();
10167 for (var s = def.scope; s !== scope;) {
10169 if (s.var_names().has(def.name)) return true;
10178 var def = name.definition();
10179 def.orig[def.orig.indexOf(node)] = name;
10180 if (def.scope === scope) return;
10181 def.scope = scope;
10182 scope.variables.set(def.name, def);
10183 scope.enclosed.push(def);
10184 scope.var_names().set(def.name, true);
10193 var def = sym.definition();
10194 return (def.fixed || def.fixed === 0)
10195 && is_safe_lexical(def)
10196 && same_scope(def)
10197 && !may_overlap(compressor, def);
10700 var def, value, var_assigned = false;
10705 && (exp === fn || !recursive_ref(compressor, def = exp.definition(), fn)
10708 … var replacing = exp === fn || def.single_use && def.references.length - def.replaced == 1;
10714 var def = node.definition();
10715 if (fn.variables.get(node.name) !== def) {
10719 var index = resolve_index(def);
10746 var def = ref.definition();
10747 if (replacing) def.replaced++;
10748 def.single_use = false;
10918 function resolve_index(def) { argument
10920 if (fn.argnames[i].definition() === def) return i;
10927 if (!fn.variables.all(function(def) { argument
10928 … return def.references.length - def.replaced < 2 && def.orig[0] instanceof AST_SymbolFunarg;
10946 var def = node.definition();
10947 if (fn.variables.get(node.name) !== def) {
10951 if (def.init instanceof AST_LambdaDefinition) return abort = true;
10953 var index = resolve_index(def);
11016 if (!all(stat.enclosed, function(def) { argument
11017 return def.scope === scope || def.scope === stat || !defined.has(def.name);
11038 if (scope.variables) scope.variables.each(function(def) { argument
11039 defined.set(def.name, true);
11075 var def = name.definition();
11083 scope.variables.set(name.name, def);
11084 scope.enclosed.push(def);
11087 def.assignments++;
11088 def.references.push(sym);
11116 var def = name.definition();
11117 def.orig.push(symbol);
11118 def.eliminated++;
11164 var def = name.definition();
11165 def.assignments++;
11166 def.references.push(ref);
11168 def.orig.push(symbol);
11169 def.eliminated++;
11180 var def = name.definition();
11181 def.fixed = false;
11182 def.orig.push(name);
11183 def.eliminated++;
11188 var def = stat.name.definition();
11189 scope.functions.set(def.name, def);
11190 scope.variables.set(def.name, def);
11191 scope.enclosed.push(def);
11192 scope.var_names().set(def.name, true);
11235 fn.enclosed.forEach(function(def) { argument
11236 if (scope.var_names().has(def.name)) return;
11237 scope.enclosed.push(def);
11238 scope.var_names().set(def.name, true);
11266 function to_conditional_assignment(compressor, def, value, node) { argument
11272 if (node.right.left.definition() !== def) return;
11276 def.replaced++;
11292 if (node instanceof AST_SymbolRef && node.definition() === def) return hit = true;
11348 var def = is_simple_assign(prev);
11349 if (!def) continue;
11352 var cond = to_conditional_assignment(compressor, def, prev.right, expr);
11361 && is_simple_assign(expr) === def
11362 && expr.right.is_constant_expression(def.scope.resolve())) {
11683 var def = lhs.definition();
11684 def.references.push(lhs);
11685 def.replaced++;
12311 function recursive_ref(compressor, def, fn) { argument
12315 if (is_lambda(node) && node.name && node.name.definition() === def) return node;
12319 function same_scope(def) { argument
12320 var scope = def.scope.resolve();
12321 return all(def.references, function(ref) {
12342 var def = self.definition();
12344 …var single_use = def.single_use && !(parent instanceof AST_Call && parent.is_expr_pure(compressor)…
12347 if ((def.scope !== self.scope.resolve(true) || def.in_loop)
12348 … && (!compressor.option("reduce_funcs") || def.escaped.depth == 1 || fixed.inlined)) {
12350 } else if (def.redefined()) {
12352 } else if (recursive_ref(compressor, def, fixed)) {
12354 } else if (fixed.name && fixed.name.definition() !== def) {
12356 } else if (fixed.parent_scope !== self.scope || is_funarg(def)) {
12377 || def.recursive_refs > 0
12384 def.single_use = false;
12394 if (scope === def.scope) break;
12396 fixed.enclosed.forEach(function(def) { argument
12397 if (fixed.variables.has(def.name)) return;
12400 if (!push_uniq(scope.enclosed, def)) return;
12401 scope.var_names().set(def.name, true);
12406 if (def.recursive_refs > 0) {
12424 lambda_def.recursive_refs = def.recursive_refs;
12429 var def = node.definition();
12430 def.orig.push(node);
12431 def.eliminated++;
12436 var def = node.definition();
12437 if (def === defun_def) {
12438 node.thedef = def = lambda_def;
12440 def.single_use = false;
12444 && fn.name.definition() === def
12445 && def.scope === fn.name.scope
12446 && fixed.variables.get(fn.name.name) === def) {
12448 … node.thedef = def = value.variables.get(fn.name.name) || value[def_fn_name](fn.name);
12451 def.references.push(node);
12468 def.replaced++;
12472 if (fixed && (state = self.fixed || def.fixed).should_replace !== false) {
12475 if (!is_funarg(def) && same_scope(def) && !cross_class(def)) init = fixed;
12481 && ev instanceof RegExp && !def.cross_loop && same_scope(def))) {
12490 var name_length = def.name.length;
12491 if (compressor.option("unused") && !compressor.exposed(def)) {
12492 var refs = def.references.length - def.replaced - def.assignments;
12493 refs = Math.min(refs, def.references.filter(function(ref) {
12509 def.replaced++;
12517 function cross_class(def) { argument
12519 while (scope !== def.scope) {