aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-12-12 11:50:03 +0200
committerMihai Bazon <mihai@bazon.net>2012-12-12 11:51:55 +0200
commitc4993e1e5cb6ea8ca1f37a6bedf403a67bedbcf6 (patch)
treec4d84bbfdc9478191a86ba2be054fa8617510ff1
parent6064bea3db0814e0fd3514b68f8fa3d8e9a3367c (diff)
downloadtracifyjs-c4993e1e5cb6ea8ca1f37a6bedf403a67bedbcf6.tar.gz
tracifyjs-c4993e1e5cb6ea8ca1f37a6bedf403a67bedbcf6.zip
Small cleanup
-rw-r--r--lib/output.js32
1 files 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){