return jsBlock;
}
}
private boolean tryStaticEvalIf(JsIf x, CanBooleanEval cond, JsContext ctx) {
JsStatement thenStmt = x.getThenStmt();
JsStatement elseStmt = x.getElseStmt();
if (cond.isBooleanTrue()) {
JsBlock block = new JsBlock(x.getSourceInfo());
block.getStatements().add(x.getIfExpr().makeStmt());
if (thenStmt != null) {
block.getStatements().add(thenStmt);
}
JsStatement decls = ensureDeclarations(elseStmt);
if (decls != null) {
block.getStatements().add(decls);
}
ctx.replaceMe(accept(block));
return true;
} else if (cond.isBooleanFalse()) {
JsBlock block = new JsBlock(x.getSourceInfo());
block.getStatements().add(x.getIfExpr().makeStmt());
if (elseStmt != null) {
block.getStatements().add(elseStmt);
}
JsStatement decls = ensureDeclarations(thenStmt);
if (decls != null) {
block.getStatements().add(decls);
}
ctx.replaceMe(accept(block));
return true;