Don't compile commented out code.
This commit is contained in:
Jonathan Protzenko 2015-06-23 17:07:52 -07:00
Родитель 50094939e8
Коммит 77e39ec5ea
1 изменённых файлов: 13 добавлений и 8 удалений

Просмотреть файл

@ -150,14 +150,19 @@ module TDev {
elseBranch: J.JStmt[],
isElseIf: boolean)
{
return [
env.indent, isElseIf ? "else " : "", "if (" + this.visit(env, cond) + "){\n",
this.visitMany(indent(env), thenBranch) + "\n",
env.indent, "}",
elseBranch ? " else {\n" : "",
elseBranch ? this.visitMany(indent(env), elseBranch) + "\n" : "",
elseBranch ? env.indent + "}" : ""
].join("");
// TouchDevelop abuses "if false" to comment out code. Commented out
// code is not type-checked, so don't try to compile it.
if (cond.tree.nodeType == "booleanLiteral" && (<J.JBooleanLiteral> cond.tree).value === false)
return "";
else
return [
env.indent, isElseIf ? "else " : "", "if (" + this.visit(env, cond) + "){\n",
this.visitMany(indent(env), thenBranch) + "\n",
env.indent, "}",
elseBranch ? " else {\n" : "",
elseBranch ? this.visitMany(indent(env), elseBranch) + "\n" : "",
elseBranch ? env.indent + "}" : ""
].join("");
}
private resolveCall(env: EmitterEnv, receiver: J.JExpr, name: string) {