return new ResolveResult(BuiltinTypes.Null);
}
@Override
public ResolveResult visitBinaryOperatorExpression(final BinaryOperatorExpression node, final Void data) {
final ResolveResult leftResult = node.getLeft().acceptVisitor(this, data);
final ResolveResult rightResult = node.getRight().acceptVisitor(this, data);
if (leftResult == null || rightResult == null) {
return null;
}
final TypeReference leftType = leftResult.getType();
final TypeReference rightType = rightResult.getType();
if (leftType == null || rightType == null) {
return null;
}
final TypeReference operandType = doBinaryPromotionStrict(leftResult, rightResult);
if (operandType == null) {
return null;
}
final TypeReference resultType;
switch (node.getOperator()) {
case LOGICAL_AND:
case LOGICAL_OR:
case GREATER_THAN:
case GREATER_THAN_OR_EQUAL:
case EQUALITY:
case INEQUALITY:
case LESS_THAN:
case LESS_THAN_OR_EQUAL:
resultType = BuiltinTypes.Boolean;
break;
default:
resultType = operandType;
break;
}
if (leftResult.isCompileTimeConstant() && rightResult.isCompileTimeConstant()) {
if (operandType.isPrimitive()) {
final Object result = BinaryOperations.doBinary(
node.getOperator(),
operandType.getSimpleType(),
leftResult.getConstantValue(),
rightResult.getConstantValue()
);
if (result != null) {
return new PrimitiveResolveResult(resultType, result);
}
}
}
return new ResolveResult(resultType);
}