generator: add ensureSemicolon and printBlock methods
This commit is contained in:
parent
e88505aba6
commit
fca3a0c56f
@ -70,11 +70,24 @@ CodeGenerator.prototype.semicolon = function () {
|
||||
this._push(";");
|
||||
};
|
||||
|
||||
CodeGenerator.prototype.ensureSemicolon = function () {
|
||||
if (!this.isLast(";")) this.semicolon();
|
||||
};
|
||||
|
||||
CodeGenerator.prototype.keyword = function (name) {
|
||||
this.push(name);
|
||||
this.push(" ");
|
||||
};
|
||||
|
||||
CodeGenerator.prototype.printBlock = function (print, node) {
|
||||
if (t.isEmptyStatement(node)) {
|
||||
this.semicolon();
|
||||
} else {
|
||||
this.push(" ");
|
||||
print(node);
|
||||
}
|
||||
};
|
||||
|
||||
CodeGenerator.prototype.push = function (str, noIndent) {
|
||||
if (this._indent && !noIndent && str !== "\n") {
|
||||
// we have an indent level and we aren't pushing a newline
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user