generator: use new keyword method for keywords
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
var _ = require("lodash");
|
||||
|
||||
exports.WithStatement = function (node, print) {
|
||||
this.push("with (");
|
||||
this.keyword("with");
|
||||
this.push("(");
|
||||
print(node.object);
|
||||
this.push(") ");
|
||||
print(node.body);
|
||||
};
|
||||
|
||||
exports.IfStatement = function (node, print) {
|
||||
this.push("if (");
|
||||
this.keyword("if");
|
||||
this.push("(");
|
||||
print(node.test);
|
||||
this.push(") ");
|
||||
print(node.consequent);
|
||||
@@ -29,7 +31,8 @@ exports.BlockStatement = function (node, print) {
|
||||
};
|
||||
|
||||
exports.ForStatement = function (node, print) {
|
||||
this.push("for (");
|
||||
this.keyword("for");
|
||||
this.push("(");
|
||||
|
||||
print(node.init);
|
||||
this.push("; ");
|
||||
@@ -44,14 +47,16 @@ exports.ForStatement = function (node, print) {
|
||||
};
|
||||
|
||||
exports.WhileStatement = function (node, print) {
|
||||
this.push("while (");
|
||||
this.keyword("while");
|
||||
this.push("(");
|
||||
print(node.test);
|
||||
this.push(") ");
|
||||
print(node.body);
|
||||
};
|
||||
|
||||
exports.ForInStatement = function (node, print) {
|
||||
this.push(node.each ? "for each (" : "for (");
|
||||
this.keyword("for");
|
||||
this.push("(");
|
||||
print(node.left);
|
||||
this.push(" in ");
|
||||
print(node.right);
|
||||
@@ -60,7 +65,8 @@ exports.ForInStatement = function (node, print) {
|
||||
};
|
||||
|
||||
exports.ForOfStatement = function (node, print) {
|
||||
this.push("for (");
|
||||
this.keyword("for");
|
||||
this.push("(");
|
||||
print(node.left);
|
||||
this.push(" of ");
|
||||
print(node.right);
|
||||
@@ -103,7 +109,7 @@ exports.LabeledStatement = function (node, print) {
|
||||
};
|
||||
|
||||
exports.TryStatement = function (node, print) {
|
||||
this.push("try ");
|
||||
this.keyword("try");
|
||||
print(node.block);
|
||||
this.push(" ");
|
||||
print(node.handler);
|
||||
@@ -114,7 +120,8 @@ exports.TryStatement = function (node, print) {
|
||||
};
|
||||
|
||||
exports.CatchClause = function (node, print) {
|
||||
this.push("catch (");
|
||||
this.keyword("catch");
|
||||
this.push("(");
|
||||
print(node.param);
|
||||
this.push(") ");
|
||||
print(node.body);
|
||||
@@ -127,7 +134,8 @@ exports.ThrowStatement = function (node, print) {
|
||||
};
|
||||
|
||||
exports.SwitchStatement = function (node, print) {
|
||||
this.push("switch (");
|
||||
this.keyword("switch");
|
||||
this.push("(");
|
||||
print(node.discriminant);
|
||||
this.push(") {");
|
||||
if (node.cases.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user