diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-09-03 11:05:59 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-09-03 11:05:59 +0300 |
commit | 66c869c8f6d4392efb56a15c6663a1f93b74da88 (patch) | |
tree | ba6a6dad9e6d0c7202fc3471ba62a3f41660515c /lib | |
parent | 1bf5928b5485db5646515919672e005738d6df81 (diff) | |
download | tracifyjs-66c869c8f6d4392efb56a15c6663a1f93b74da88.tar.gz tracifyjs-66c869c8f6d4392efb56a15c6663a1f93b74da88.zip |
switch branches must be declared `required` so that the compressor doesn't
replace nodes with a single statement.
looks stable for now, though mess begins to sink in. need to review the AST
hierarchy.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ast.js | 10 | ||||
-rw-r--r-- | lib/output.js | 2 |
2 files changed, 8 insertions, 4 deletions
@@ -304,11 +304,17 @@ var AST_Switch = DEFNODE("Switch", "expression", { }, AST_Statement); var AST_SwitchBlock = DEFNODE("SwitchBlock", null, { - $documentation: "The switch block is somewhat special, hence a special node for it" + $documentation: "The switch block is somewhat special, hence a special node for it", + initialize: function() { + this.required = true; + }, }, AST_BlockStatement); var AST_SwitchBranch = DEFNODE("SwitchBranch", null, { - $documentation: "Base class for `switch` branches" + $documentation: "Base class for `switch` branches", + initialize: function() { + this.required = true; + }, }, AST_BlockStatement); var AST_Default = DEFNODE("Default", null, { diff --git a/lib/output.js b/lib/output.js index 05bd9136..6d86a087 100644 --- a/lib/output.js +++ b/lib/output.js @@ -151,7 +151,6 @@ function OutputStream(options) { current_pos++; } might_need_space = false; - maybe_newline(); } var a = str.split(/\r?\n/), n = a.length - 1; current_line += n; @@ -466,7 +465,6 @@ function OutputStream(options) { }); DEFPRINT(AST_BlockStatement, function(self, output){ var body = self.body; - //if (!(body instanceof Array)) body = [ body ]; if (body.length > 0) output.with_block(function(){ display_body(body, false, output); }); |