in lib/generator.js [3189:3232]
visitIf(ast, level, env) {
assert.equal(ast.type, 'if');
let argHasThrowFunc;
if (ast.condition.type === 'not' && ast.condition.expr && ast.condition.expr.type === 'call') {
argHasThrowFunc = this.visitFunctionNested(ast.condition.expr, level, env);
} else if (ast.condition.type === 'call') {
argHasThrowFunc = this.visitFunctionNested(ast.condition, level, env);
}
this.emit('if ', level);
let setFunc;
if(ast.condition && ast.condition.type === 'call') {
let dealFunc = this.getVarDealFunc(ast.condition, true);
setFunc = dealFunc && dealFunc(_name(ast.condition.inferred));
}
if(setFunc) {
this.emit(`${setFunc}`);
}
this.visitExpr(ast.condition, level + 1, env, false, argHasThrowFunc);
if(setFunc) {
this.emit(')');
}
this.emit(' {\n');
this.visitStmts(ast.stmts, level + 1, env);
if (ast.elseIfs) {
for (let i = 0; i < ast.elseIfs.length; i++) {
let elseIf = ast.elseIfs[i];
this.emit(`} else if `, level);
let setFunc;
if(elseIf.condition && elseIf.condition.type === 'call') {
let dealFunc = this.getVarDealFunc(elseIf.condition, true);
setFunc = dealFunc && dealFunc(_name(elseIf.condition.inferred));
}
if(setFunc) {
this.emit(`${setFunc}`);
}
this.visitExpr(elseIf.condition, level + 1, env, false, argHasThrowFunc);
if(setFunc) {
this.emit(')');
}
this.emit(' {\n');
this.visitStmts(elseIf.stmts, level + 1, env);
}
}