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.
This commit is contained in:
10
lib/ast.js
10
lib/ast.js
@@ -304,11 +304,17 @@ var AST_Switch = DEFNODE("Switch", "expression", {
|
|||||||
}, AST_Statement);
|
}, AST_Statement);
|
||||||
|
|
||||||
var AST_SwitchBlock = DEFNODE("SwitchBlock", null, {
|
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);
|
}, AST_BlockStatement);
|
||||||
|
|
||||||
var AST_SwitchBranch = DEFNODE("SwitchBranch", null, {
|
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);
|
}, AST_BlockStatement);
|
||||||
|
|
||||||
var AST_Default = DEFNODE("Default", null, {
|
var AST_Default = DEFNODE("Default", null, {
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ function OutputStream(options) {
|
|||||||
current_pos++;
|
current_pos++;
|
||||||
}
|
}
|
||||||
might_need_space = false;
|
might_need_space = false;
|
||||||
maybe_newline();
|
|
||||||
}
|
}
|
||||||
var a = str.split(/\r?\n/), n = a.length - 1;
|
var a = str.split(/\r?\n/), n = a.length - 1;
|
||||||
current_line += n;
|
current_line += n;
|
||||||
@@ -466,7 +465,6 @@ function OutputStream(options) {
|
|||||||
});
|
});
|
||||||
DEFPRINT(AST_BlockStatement, function(self, output){
|
DEFPRINT(AST_BlockStatement, function(self, output){
|
||||||
var body = self.body;
|
var body = self.body;
|
||||||
//if (!(body instanceof Array)) body = [ body ];
|
|
||||||
if (body.length > 0) output.with_block(function(){
|
if (body.length > 0) output.with_block(function(){
|
||||||
display_body(body, false, output);
|
display_body(body, false, output);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user