aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-18 19:22:24 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-21 13:29:58 +0800
commit974247c8c0e57901ef776e86784c8c9a1b87b5de (patch)
tree308ab620fca91f6eb2389674ed048fa43cb8b9b0 /lib/compress.js
parenta0f4fd390a0a1af80964aab9754bf5358db575e2 (diff)
downloadtracifyjs-974247c8c0e57901ef776e86784c8c9a1b87b5de.tar.gz
tracifyjs-974247c8c0e57901ef776e86784c8c9a1b87b5de.zip
evaluate AST_SymbolRef as parameter
fix invalid boolean conversion now exposed in `make_node_from_constant()` closes #1477
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 72afe92a..a60ba1a1 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -234,7 +234,7 @@ merge(Compressor.prototype, {
case "string":
return make_node(AST_String, orig, {
value: val
- }).optimize(compressor);
+ });
case "number":
if (isNaN(val)) {
return make_node(AST_NaN, orig);
@@ -247,17 +247,17 @@ merge(Compressor.prototype, {
});
}
- return make_node(AST_Number, orig, { value: val }).optimize(compressor);
+ return make_node(AST_Number, orig, { value: val });
case "boolean":
- return make_node(val ? AST_True : AST_False, orig).optimize(compressor);
+ return make_node(val ? AST_True : AST_False, orig).transform(compressor);
case "undefined":
- return make_node(AST_Undefined, orig).optimize(compressor);
+ return make_node(AST_Undefined, orig).transform(compressor);
default:
if (val === null) {
- return make_node(AST_Null, orig, { value: null }).optimize(compressor);
+ return make_node(AST_Null, orig, { value: null });
}
if (val instanceof RegExp) {
- return make_node(AST_RegExp, orig, { value: val }).optimize(compressor);
+ return make_node(AST_RegExp, orig, { value: val });
}
throw new Error(string_template("Can't handle constant of type: {type}", {
type: typeof val
@@ -2179,6 +2179,9 @@ merge(Compressor.prototype, {
});
OPT(AST_Call, function(self, compressor){
+ self.args = self.args.map(function(arg) {
+ return arg.evaluate(compressor)[0];
+ });
if (compressor.option("unsafe")) {
var exp = self.expression;
if (exp instanceof AST_SymbolRef && exp.undeclared()) {