Do not overwrite options.comments + cleanup

This commit is contained in:
Anthony Van de Gejuchte
2016-10-26 17:34:30 +02:00
committed by Richard van Velzen
parent 057de570e6
commit 79b98a9fe8
4 changed files with 63 additions and 52 deletions

View File

@@ -916,7 +916,7 @@ merge(Compressor.prototype, {
(function (def){
var unary_bool = [ "!", "delete" ];
var binary_bool = [ "in", "instanceof", "==", "!=", "===", "!==", "<", "<=", ">=", ">" ];
def(AST_Node, function(){ return false });
def(AST_Node, return_false);
def(AST_UnaryPrefix, function(){
return member(this.operator, unary_bool);
});
@@ -934,16 +934,16 @@ merge(Compressor.prototype, {
def(AST_Seq, function(){
return this.cdr.is_boolean();
});
def(AST_True, function(){ return true });
def(AST_False, function(){ return true });
def(AST_True, return_true);
def(AST_False, return_true);
})(function(node, func){
node.DEFMETHOD("is_boolean", func);
});
// methods to determine if an expression has a string result type
(function (def){
def(AST_Node, function(){ return false });
def(AST_String, function(){ return true });
def(AST_Node, return_false);
def(AST_String, return_true);
def(AST_UnaryPrefix, function(){
return this.operator == "typeof";
});
@@ -1197,11 +1197,11 @@ merge(Compressor.prototype, {
// determine if expression has side effects
(function(def){
def(AST_Node, function(compressor){ return true });
def(AST_Node, return_true);
def(AST_EmptyStatement, function(compressor){ return false });
def(AST_Constant, function(compressor){ return false });
def(AST_This, function(compressor){ return false });
def(AST_EmptyStatement, return_false);
def(AST_Constant, return_false);
def(AST_This, return_false);
def(AST_Call, function(compressor){
var pure = compressor.option("pure_funcs");
@@ -1221,13 +1221,13 @@ merge(Compressor.prototype, {
def(AST_SimpleStatement, function(compressor){
return this.body.has_side_effects(compressor);
});
def(AST_Defun, function(compressor){ return true });
def(AST_Function, function(compressor){ return false });
def(AST_Defun, return_true);
def(AST_Function, return_false);
def(AST_Binary, function(compressor){
return this.left.has_side_effects(compressor)
|| this.right.has_side_effects(compressor);
});
def(AST_Assign, function(compressor){ return true });
def(AST_Assign, return_true);
def(AST_Conditional, function(compressor){
return this.condition.has_side_effects(compressor)
|| this.consequent.has_side_effects(compressor)