this.longType = longType;
}
@Override
public void endVisit(JBinaryOperation x, Context ctx) {
JType lhsType = x.getLhs().getType();
JType rhsType = x.getRhs().getType();
JType resultType = x.getType();
if (resultType == program.getTypeJavaLangString()) {
// Don't mess with concat.
return;
}
// Special case: shift operators always coerce a long RHS to int.
if (x.getOp().isShiftOperator()) {
if (rhsType == longType) {
rhsType = program.getTypePrimitiveInt();
}
} else if (lhsType == longType || rhsType == longType) {
// We must coerce lhs and rhs to the same type, either long or a float.
// Assume a long type.
JType coerceTo = longType;
// But double / float takes precedence over long.
JPrimitiveType floatType = program.getTypePrimitiveFloat();
JPrimitiveType doubleType = program.getTypePrimitiveDouble();
// See if the lhs can coerce the rhs