diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-08-23 05:45:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 05:45:35 +0800 |
commit | 35fe1092d368f3a79df54120d5e1c1dcb268af1a (patch) | |
tree | 2a7a569f3934acbeb520f32611fa1a1308064433 /lib/output.js | |
parent | f2d486e771271ce03f25a50a6107cb87735a681d (diff) | |
download | tracifyjs-35fe1092d368f3a79df54120d5e1c1dcb268af1a.tar.gz tracifyjs-35fe1092d368f3a79df54120d5e1c1dcb268af1a.zip |
simplify traversal logic (#4063)
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/output.js b/lib/output.js index a9e0ca7b..19c37b29 100644 --- a/lib/output.js +++ b/lib/output.js @@ -1174,10 +1174,7 @@ function OutputStream(options) { }); /* -----[ other expressions ]----- */ - DEFPRINT(AST_Call, function(self, output) { - self.expression.print(output); - if (self instanceof AST_New && !need_constructor_parens(self, output)) - return; + function print_call_args(self, output) { if (self.expression instanceof AST_Call || self.expression instanceof AST_Lambda) { output.add_mapping(self.start); } @@ -1187,11 +1184,16 @@ function OutputStream(options) { expr.print(output); }); }); + } + DEFPRINT(AST_Call, function(self, output) { + self.expression.print(output); + print_call_args(self, output); }); DEFPRINT(AST_New, function(self, output) { output.print("new"); output.space(); - AST_Call.prototype._codegen(self, output); + self.expression.print(output); + if (need_constructor_parens(self, output)) print_call_args(self, output); }); DEFPRINT(AST_Sequence, function(self, output) { self.expressions.forEach(function(node, index) { |