boolean addError)
{
int numOfChild = node.jjtGetNumChildren();
if (numOfChild > 0) {
TypeInfo operandTypeInfo = null;
for (int i=0; i < numOfChild; i++) {
Node child = node.jjtGetChild(i);
TypeInfo info = getTypeInfoForNode(child);
if (info != null) {
// Is this a known numeric type or does it support
// arithmetic operations.
if (!PrimitiveTypeProvider.isNumericType(info) &&
!(info instanceof NullTypeInfo) &&
ArithmeticOperations.getByName(info.getName()) == null) {
if (addError) {
addError(node, Fmt.S(
"Operands in expression '%s' must be numeric.",
node));
}
return null;
}
// Is this a known floating point numeric?
if (PrimitiveTypeProvider.isNumericType(info)) {
// Do we allow floating point numeric?
if (!allowFloatingPoint &&
PrimitiveTypeProvider.isFloatingPointNumericType(info)) {
if (addError) {
addError(node, Fmt.S(
"Expression '%s' does not allow floating point operands.",
node));
}
return null;
}
}
// Let's checkin if this operand is compatible with the others.
if (operandTypeInfo == null ||
operandTypeInfo instanceof NullTypeInfo) {
// first operand, nothing to compare.
operandTypeInfo = info;
}
else if (PrimitiveTypeProvider.isNumericType(operandTypeInfo) &&
PrimitiveTypeProvider.isNumericType(info)) {
// If the operands are both known numeric type, then
// look for a coerced type that can be the resulting
// type of containing expression.
TypeInfo coercedTypeInfo =
PrimitiveTypeProvider.getCoercedType(operandTypeInfo, info);
if (coercedTypeInfo != null) {
operandTypeInfo = coercedTypeInfo;
}
}