an AST_If is too a StatementWithBody
This commit is contained in:
@@ -447,6 +447,10 @@ function OutputStream(options) {
|
||||
});
|
||||
};
|
||||
|
||||
AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output){
|
||||
force_statement(this.body, output);
|
||||
});
|
||||
|
||||
DEFPRINT(AST_Statement, function(self, output){
|
||||
self.body.print(output);
|
||||
output.semicolon();
|
||||
@@ -476,7 +480,7 @@ function OutputStream(options) {
|
||||
DEFPRINT(AST_Do, function(self, output){
|
||||
output.print("do");
|
||||
output.space();
|
||||
force_statement(self.body, output);
|
||||
self._do_print_body(output);
|
||||
output.space();
|
||||
output.print("while");
|
||||
output.space();
|
||||
@@ -492,7 +496,7 @@ function OutputStream(options) {
|
||||
self.condition.print(output);
|
||||
});
|
||||
output.space();
|
||||
force_statement(self.body, output);
|
||||
self._do_print_body(output);
|
||||
});
|
||||
DEFPRINT(AST_For, function(self, output){
|
||||
output.print("for");
|
||||
@@ -517,7 +521,7 @@ function OutputStream(options) {
|
||||
}
|
||||
});
|
||||
output.space();
|
||||
force_statement(self.body, output);
|
||||
self._do_print_body(output);
|
||||
});
|
||||
DEFPRINT(AST_ForIn, function(self, output){
|
||||
output.print("for");
|
||||
@@ -530,7 +534,7 @@ function OutputStream(options) {
|
||||
self.object.print(output);
|
||||
});
|
||||
output.space();
|
||||
force_statement(self.body, output);
|
||||
self._do_print_body(output);
|
||||
});
|
||||
DEFPRINT(AST_With, function(self, output){
|
||||
output.print("with");
|
||||
@@ -539,7 +543,7 @@ function OutputStream(options) {
|
||||
self.expression.print(output);
|
||||
});
|
||||
output.space();
|
||||
force_statement(self.body, output);
|
||||
self._do_print_body(output);
|
||||
});
|
||||
|
||||
/* -----[ functions ]----- */
|
||||
@@ -606,22 +610,22 @@ function OutputStream(options) {
|
||||
// IF *without* an ELSE block (then the outer ELSE would refer
|
||||
// to the inner IF). This function checks for this case and
|
||||
// adds the block brackets if needed.
|
||||
if (!self.consequent)
|
||||
if (!self.body)
|
||||
return output.semicolon();
|
||||
if (self.consequent instanceof AST_Do
|
||||
if (self.body instanceof AST_Do
|
||||
&& output.option("ie_proof")) {
|
||||
// https://github.com/mishoo/UglifyJS/issues/#issue/57 IE
|
||||
// croaks with "syntax error" on code like this: if (foo)
|
||||
// do ... while(cond); else ... we need block brackets
|
||||
// around do/while
|
||||
make_block(self.consequent, output);
|
||||
make_block(self.body, output);
|
||||
return;
|
||||
}
|
||||
var b = self.consequent;
|
||||
var b = self.body;
|
||||
while (true) {
|
||||
if (b instanceof AST_If) {
|
||||
if (!b.alternative) {
|
||||
make_block(self.consequent, output);
|
||||
make_block(self.body, output);
|
||||
return;
|
||||
}
|
||||
b = b.alternative;
|
||||
@@ -631,7 +635,7 @@ function OutputStream(options) {
|
||||
}
|
||||
else break;
|
||||
}
|
||||
self.consequent.print(output);
|
||||
self.body.print(output);
|
||||
};
|
||||
DEFPRINT(AST_If, function(self, output){
|
||||
output.print("if");
|
||||
@@ -647,7 +651,7 @@ function OutputStream(options) {
|
||||
output.space();
|
||||
self.alternative.print(output);
|
||||
} else {
|
||||
force_statement(self.consequent, output);
|
||||
self._do_print_body(output);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user