From: Mihai Bazon Date: Tue, 2 Oct 2012 09:45:17 +0000 (+0300) Subject: more constant folding (for names defined with `const`) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=211792757cf8cb8529f99122efa52f5f5d558132;p=UglifyJS.git more constant folding (for names defined with `const`) --- diff --git a/lib/compress.js b/lib/compress.js index 86d1ce7c..a6edf413 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -582,6 +582,16 @@ merge(Compressor.prototype, { ? ev(this.consequent) : ev(this.alternative); }); + def(AST_SymbolRef, function(){ + var d = this.definition(); + if (d && d.constant) { + var orig = d.orig[0]; + if (orig) orig = orig.init[0]; + orig = orig && orig.value; + if (orig) return ev(orig); + } + throw def; + }); })(function(node, func){ node.DEFMETHOD("_eval", func); });