From: Alex Lam S.L Date: Fri, 27 Oct 2017 06:28:09 +0000 (+0800) Subject: remove dead code (#2405) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=31f82091930b39ebb5d9358951c39ae20cf8057e;p=UglifyJS.git remove dead code (#2405) --- diff --git a/lib/compress.js b/lib/compress.js index a2dd243f..4817ec5f 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1647,35 +1647,6 @@ merge(Compressor.prototype, { && unaryPrefix(this.operator); } }); - // Obtain the constant value of an expression already known to be constant. - // Result only valid iff this.is_constant() is true. - AST_Node.DEFMETHOD("constant_value", function(compressor){ - // Accomodate when option evaluate=false. - if (this instanceof AST_Constant && !(this instanceof AST_RegExp)) { - return this.value; - } - // Accomodate the common constant expressions !0 and -1 when option evaluate=false. - if (this instanceof AST_UnaryPrefix - && this.expression instanceof AST_Constant) switch (this.operator) { - case "!": - return !this.expression.value; - case "~": - return ~this.expression.value; - case "-": - return -this.expression.value; - case "+": - return +this.expression.value; - default: - throw new Error(string_template("Cannot evaluate unary expression {value}", { - value: this.print_to_string() - })); - } - var result = this.evaluate(compressor); - if (result !== this) { - return result; - } - throw new Error(string_template("Cannot evaluate constant [{file}:{line},{col}]", this.start)); - }); def(AST_Statement, function(){ throw new Error(string_template("Cannot evaluate a statement [{file}:{line},{col}]", this.start)); });