From c4993e1e5cb6ea8ca1f37a6bedf403a67bedbcf6 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Wed, 12 Dec 2012 11:50:03 +0200 Subject: [PATCH] Small cleanup --- lib/output.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/output.js b/lib/output.js index 72f49b94..ee5e9d9b 100644 --- a/lib/output.js +++ b/lib/output.js @@ -340,23 +340,25 @@ function OutputStream(options) { /* -----[ utils ]----- */ function DEFPRINT(nodetype, generator) { - nodetype.DEFMETHOD("print", function(stream, force_parens){ - var self = this; - stream.push_node(self); - if (force_parens || self.needs_parens(stream)) { - stream.with_parens(function(){ - self.add_comments(stream); - self.add_source_map(stream); - generator(self, stream); - }); - } else { + nodetype.DEFMETHOD("_codegen", generator); + }; + + 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)) { + stream.with_parens(function(){ self.add_comments(stream); self.add_source_map(stream); generator(self, stream); - } - stream.pop_node(); - }); - }; + }); + } else { + self.add_comments(stream); + self.add_source_map(stream); + generator(self, stream); + } + stream.pop_node(); + }); AST_Node.DEFMETHOD("print_to_string", function(options){ var s = OutputStream(options); @@ -902,7 +904,7 @@ function OutputStream(options) { DEFPRINT(AST_New, function(self, output){ output.print("new"); output.space(); - AST_Call.prototype.print.call(self, output); + AST_Call.prototype._codegen(self, output); }); AST_Seq.DEFMETHOD("_do_print", function(output){ -- 2.34.1