operandInstances.add(preptimeValue.type());
if (Boolean.TRUE.equals(preptimeValue.isNullable()))
anyOperandsNullable = true;
}
TOverloadResult overloadResultStrategy = overload.resultStrategy();
TInstance resultInstance;
TInstance castTo;
TPreptimeContext context;
if (createPreptimeContext) {
context = new TPreptimeContext(operandInstances, queryContext);
expression.setPreptimeContext(context);
}
else {
context = null;
}
switch (overloadResultStrategy.category()) {
case CUSTOM:
TInstance castSource = overloadResultStrategy.customRuleCastSource(anyOperandsNullable);
if (context == null)
context = new TPreptimeContext(operandInstances, queryContext);
expression.setPreptimeContext(context);
if (castSource == null) {
castTo = null;
resultInstance = overloadResultStrategy.customRule().resultInstance(operandValues, context);
}
else {
castTo = overloadResultStrategy.customRule().resultInstance(operandValues, context);
resultInstance = castSource;
}
break;
case FIXED:
resultInstance = overloadResultStrategy.fixed(anyOperandsNullable);
castTo = null;
break;
case PICKING:
resultInstance = resolutionResult.getPickedInstance();
castTo = null;
break;
default:
throw new AssertionError(overloadResultStrategy.category());
}
if (createPreptimeContext)
context.setOutputType(resultInstance);
expression.setPreptimeValue(new TPreptimeValue(resultInstance));