Move support for negate_iife in the compressor, rather than code generator

(the code generator doesn't maintain enough context to know whether
the return value is important or discarded)

Fixes #272
This commit is contained in:
Mihai Bazon
2013-08-20 17:45:52 +03:00
parent 4f09df238e
commit ed80b4a534
4 changed files with 126 additions and 16 deletions

View File

@@ -61,7 +61,6 @@ function OutputStream(options) {
comments : false,
preserve_line : false,
screw_ie8 : false,
negate_iife : !(options && options.beautify),
}, true);
var indentation = 0;
@@ -351,21 +350,17 @@ function OutputStream(options) {
AST_Node.DEFMETHOD("print", function(stream, force_parens){
var self = this, generator = self._codegen;
stream.push_node(self);
var needs_parens = self.needs_parens(stream);
var fc = self instanceof AST_Function && stream.option("negate_iife");
if (force_parens || (needs_parens && !fc)) {
stream.with_parens(function(){
self.add_comments(stream);
self.add_source_map(stream);
generator(self, stream);
});
} else {
function doit() {
self.add_comments(stream);
if (needs_parens && fc) stream.print("!");
self.add_source_map(stream);
generator(self, stream);
}
stream.push_node(self);
if (force_parens || self.needs_parens(stream)) {
stream.with_parens(doit);
} else {
doit();
}
stream.pop_node();
});