@Override
public TPreptimeValue evaluateConstant(QueryContext queryContext) {
// First check both sides. If either is a constant null, the result is null
TPreptimeValue leftPrep = left.evaluateConstant(queryContext);
ValueSource oneVal = leftPrep.value();
if (oneVal != null && oneVal.isNull()) {
TInstance type = AkBool.INSTANCE.instance(true);
return new TPreptimeValue(ValueSources.getNullSource(type));
}
TPreptimeValue rightPrep = right.evaluateConstant(queryContext);
ValueSource twoVal = rightPrep.value();
if (twoVal != null && twoVal.isNull()) {
TInstance type = AkBool.INSTANCE.instance(true);
return new TPreptimeValue(ValueSources.getNullSource(type));
}
// Neither side is constant null. If both sides are constant, evaluate
ValueSource resultSource = null;
boolean nullable;
if (oneVal != null && twoVal != null) {
final boolean result = doEval(leftPrep.type(), oneVal, rightPrep.type(), twoVal);
resultSource = new Value(AkBool.INSTANCE.instance(false), result);
nullable = resultSource.isNull();
}
else {
nullable = left.resultType().nullability() || right.resultType().nullability();
}
return new TPreptimeValue(MNumeric.INT.instance(nullable), resultSource);