aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index efc7c47f..498729d0 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -380,6 +380,16 @@ merge(Compressor.prototype, {
mark(tw, def, true);
}
});
+ scope.may_call_this = function() {
+ scope.may_call_this = noop;
+ if (!scope.contains_this()) return;
+ scope.functions.each(function(def) {
+ if (def.init instanceof AST_Defun && !(def.id in tw.defun_ids)) {
+ tw.defun_ids[def.id] = false;
+ }
+ });
+ return true;
+ };
}
function mark_defun(tw, def) {
@@ -556,6 +566,7 @@ merge(Compressor.prototype, {
return true;
});
def(AST_Call, function(tw, descend) {
+ if (tw.find_parent(AST_Scope).may_call_this()) return;
var exp = this.expression;
if (!(exp instanceof AST_SymbolRef)) return;
var def = exp.definition();
@@ -6278,7 +6289,7 @@ merge(Compressor.prototype, {
return self;
});
- AST_Lambda.DEFMETHOD("contains_this", function() {
+ AST_Scope.DEFMETHOD("contains_this", function() {
var result;
var self = this;
self.walk(new TreeWalker(function(node) {