public
/
UglifyJS.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
347160c
)
more constant folding (for names defined with `const`)
author
Mihai Bazon
<mihai@bazon.net>
Tue, 2 Oct 2012 09:45:17 +0000
(12:45 +0300)
committer
Mihai Bazon
<mihai@bazon.net>
Tue, 2 Oct 2012 09:45:17 +0000
(12:45 +0300)
lib/compress.js
patch
|
blob
|
history
diff --git
a/lib/compress.js
b/lib/compress.js
index
86d1ce7
..
a6edf41
100644
(file)
--- 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);
});