return this.pure = pure;
});
+ var global_pure_fns = makePredicate("Boolean decodeURI decodeURIComponent Date encodeURI encodeURIComponent Error escape EvalError isFinite isNaN Number Object parseFloat parseInt RangeError ReferenceError String SyntaxError TypeError unescape URIError");
+ AST_Call.DEFMETHOD("is_expr_pure", function(compressor) {
+ if (compressor.option("unsafe")) {
+ var expr = this.expression;
+ if (is_undeclared_ref(expr) && global_pure_fns(expr.name)) return true;
+ }
+ return this.has_pure_annotation(compressor) || !compressor.pure_funcs(this);
+ });
+
// determine if expression has side effects
(function(def){
def(AST_Node, return_true);
def(AST_This, return_false);
def(AST_Call, function(compressor){
- if (!this.has_pure_annotation(compressor) && compressor.pure_funcs(this)) return true;
+ if (!this.is_expr_pure(compressor)) return true;
for (var i = this.args.length; --i >= 0;) {
if (this.args[i].has_side_effects(compressor))
return true;
def(AST_Constant, return_null);
def(AST_This, return_null);
def(AST_Call, function(compressor, first_in_statement){
- if (!this.has_pure_annotation(compressor) && compressor.pure_funcs(this)) {
+ if (!this.is_expr_pure(compressor)) {
if (this.expression instanceof AST_Function
&& (!this.expression.name || !this.expression.name.definition().references.length)) {
var node = this.clone();