return newChildren != null
? new Block(n.getFilePosition(), newChildren) : n;
} else if (n instanceof SwitchStmt) {
return optimizeSwitch((SwitchStmt) n);
} else if (n instanceof ReturnStmt) {
ReturnStmt rs = (ReturnStmt) n;
Expression returnValue = rs.getReturnValue();
Expression optReturnValue = returnValue != null
? (Expression) optimize(returnValue, false)
: null;
if (optReturnValue != null && returnValue != null // 2nd implied by 1st
&& "undefined".equals(returnValue.typeOf())
&& optReturnValue.simplifyForSideEffect() == null) {
return new ReturnStmt(rs.getFilePosition(), null);
} else if (optReturnValue != returnValue) {
return new ReturnStmt(rs.getFilePosition(), optReturnValue);
}
return rs;
} else {
List<? extends ParseTreeNode> children = n.children();
int nChildren = children.size();