new JBinaryOperation(info, argOp.getType(), newOp, argOp.getLhs(), argOp.getRhs());
return newBinOp;
}
} else if (arg instanceof JPrefixOperation) {
// try to invert the unary operator
JPrefixOperation argOp = (JPrefixOperation) arg;
JUnaryOperator op = argOp.getOp();
// e.g. !!x -> x
if (op == JUnaryOperator.NOT) {
return argOp.getArg();
}
} else if (arg instanceof JBooleanLiteral) {
JBooleanLiteral booleanLit = (JBooleanLiteral) arg;
return JBooleanLiteral.get(!booleanLit.getValue());
}
// no simplification made
if (original != null) {
return original;
}
return new JPrefixOperation(info, JUnaryOperator.NOT, arg);
}