aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2013-05-09 08:58:47 +0300
committerMihai Bazon <mihai@bazon.net>2013-05-09 08:58:47 +0300
commita9511dfbe5c0d96d8cacb87582aa9a19737bbb98 (patch)
tree2a62f3cb24d2524b642c0ac5773a0d9789812f22
parent064e7aa1bbb70baec40a9812a8801627846bde2f (diff)
downloadtracifyjs-a9511dfbe5c0d96d8cacb87582aa9a19737bbb98.tar.gz
tracifyjs-a9511dfbe5c0d96d8cacb87582aa9a19737bbb98.zip
Use the negation hack rather than parens for a toplevel function expression call
(only in !beautify mode)
-rw-r--r--lib/output.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/output.js b/lib/output.js
index defd0215..a13c92ea 100644
--- a/lib/output.js
+++ b/lib/output.js
@@ -351,7 +351,9 @@ function OutputStream(options) {
AST_Node.DEFMETHOD("print", function(stream, force_parens){
var self = this, generator = self._codegen;
stream.push_node(self);
- if (force_parens || self.needs_parens(stream)) {
+ var needs_parens = self.needs_parens(stream);
+ var fc = self instanceof AST_Function && !stream.option("beautify");
+ if (force_parens || (needs_parens && !fc)) {
stream.with_parens(function(){
self.add_comments(stream);
self.add_source_map(stream);
@@ -359,6 +361,7 @@ function OutputStream(options) {
});
} else {
self.add_comments(stream);
+ if (needs_parens && fc) stream.print("!");
self.add_source_map(stream);
generator(self, stream);
}