support const (#4190)
This commit is contained in:
@@ -835,10 +835,6 @@ function OutputStream(options) {
|
||||
use_asm = was_asm;
|
||||
}
|
||||
|
||||
AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output) {
|
||||
force_statement(this.body, output);
|
||||
});
|
||||
|
||||
DEFPRINT(AST_Statement, function(output) {
|
||||
this.body.print(output);
|
||||
output.semicolon();
|
||||
@@ -897,7 +893,7 @@ function OutputStream(options) {
|
||||
self.condition.print(output);
|
||||
});
|
||||
output.space();
|
||||
self._do_print_body(output);
|
||||
force_statement(self.body, output);
|
||||
});
|
||||
DEFPRINT(AST_For, function(output) {
|
||||
var self = this;
|
||||
@@ -927,7 +923,7 @@ function OutputStream(options) {
|
||||
}
|
||||
});
|
||||
output.space();
|
||||
self._do_print_body(output);
|
||||
force_statement(self.body, output);
|
||||
});
|
||||
DEFPRINT(AST_ForIn, function(output) {
|
||||
var self = this;
|
||||
@@ -941,7 +937,7 @@ function OutputStream(options) {
|
||||
self.object.print(output);
|
||||
});
|
||||
output.space();
|
||||
self._do_print_body(output);
|
||||
force_statement(self.body, output);
|
||||
});
|
||||
DEFPRINT(AST_With, function(output) {
|
||||
var self = this;
|
||||
@@ -951,7 +947,7 @@ function OutputStream(options) {
|
||||
self.expression.print(output);
|
||||
});
|
||||
output.space();
|
||||
self._do_print_body(output);
|
||||
force_statement(self.body, output);
|
||||
});
|
||||
|
||||
/* -----[ functions ]----- */
|
||||
@@ -1036,7 +1032,7 @@ function OutputStream(options) {
|
||||
else
|
||||
force_statement(self.alternative, output);
|
||||
} else {
|
||||
self._do_print_body(output);
|
||||
force_statement(self.body, output);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1114,17 +1110,21 @@ function OutputStream(options) {
|
||||
print_braced(this, output);
|
||||
});
|
||||
|
||||
DEFPRINT(AST_Var, function(output) {
|
||||
var self = this;
|
||||
output.print("var");
|
||||
output.space();
|
||||
self.definitions.forEach(function(def, i) {
|
||||
if (i) output.comma();
|
||||
def.print(output);
|
||||
});
|
||||
var p = output.parent();
|
||||
if (p && p.init !== self || !(p instanceof AST_For || p instanceof AST_ForIn)) output.semicolon();
|
||||
});
|
||||
function print_definitinos(type) {
|
||||
return function(output) {
|
||||
var self = this;
|
||||
output.print(type);
|
||||
output.space();
|
||||
self.definitions.forEach(function(def, i) {
|
||||
if (i) output.comma();
|
||||
def.print(output);
|
||||
});
|
||||
var p = output.parent();
|
||||
if (p && p.init !== self || !(p instanceof AST_For || p instanceof AST_ForIn)) output.semicolon();
|
||||
};
|
||||
}
|
||||
DEFPRINT(AST_Const, print_definitinos("const"));
|
||||
DEFPRINT(AST_Var, print_definitinos("var"));
|
||||
|
||||
function parenthesize_for_noin(node, output, noin) {
|
||||
var parens = false;
|
||||
@@ -1383,11 +1383,12 @@ function OutputStream(options) {
|
||||
function force_statement(stat, output) {
|
||||
if (output.option("braces")) {
|
||||
make_block(stat, output);
|
||||
} else if (!stat || stat instanceof AST_EmptyStatement) {
|
||||
output.force_semicolon();
|
||||
} else if (stat instanceof AST_Const) {
|
||||
make_block(stat, output);
|
||||
} else {
|
||||
if (!stat || stat instanceof AST_EmptyStatement)
|
||||
output.force_semicolon();
|
||||
else
|
||||
stat.print(output);
|
||||
stat.print(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user