return elseExpr;
}
} else if (thenExpr instanceof JBooleanLiteral) {
if (((JBooleanLiteral) thenExpr).getValue()) {
// e.g. (cond ? true : else) -> cond || else
JBinaryOperation binOp = new JBinaryOperation(program,
original.getSourceInfo(), original.getType(), JBinaryOperator.OR,
condExpr, elseExpr);
return binOp;
} else {
// e.g. (cond ? false : else) -> !cond && else
JPrefixOperation notCondExpr = new JPrefixOperation(program,
condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
JBinaryOperation binOp = new JBinaryOperation(program,
original.getSourceInfo(), original.getType(), JBinaryOperator.AND,
notCondExpr, elseExpr);
return binOp;
}
} else if (elseExpr instanceof JBooleanLiteral) {
if (((JBooleanLiteral) elseExpr).getValue()) {
// e.g. (cond ? then : true) -> !cond || then
JPrefixOperation notCondExpr = new JPrefixOperation(program,
condExpr.getSourceInfo(), JUnaryOperator.NOT, condExpr);
JBinaryOperation binOp = new JBinaryOperation(program,
original.getSourceInfo(), original.getType(), JBinaryOperator.OR,
notCondExpr, thenExpr);
return binOp;
} else {
// e.g. (cond ? then : false) -> cond && then
JBinaryOperation binOp = new JBinaryOperation(program,
original.getSourceInfo(), original.getType(), JBinaryOperator.AND,
condExpr, thenExpr);
return binOp;
}
} else {