aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-10-02 12:45:17 +0300
committerMihai Bazon <mihai@bazon.net>2012-10-02 12:45:17 +0300
commit211792757cf8cb8529f99122efa52f5f5d558132 (patch)
treee83415bedc6272b22eceae1551136e1a75dada00 /lib
parent347160c63138dcd7fbe107ae80309ad86d58a2e1 (diff)
downloadtracifyjs-211792757cf8cb8529f99122efa52f5f5d558132.tar.gz
tracifyjs-211792757cf8cb8529f99122efa52f5f5d558132.zip
more constant folding (for names defined with `const`)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js10
1 files changed, 10 insertions, 0 deletions
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);
});