MethodType methodType = binding.getType();
Signature signature = function.getSignature();
Class<?> unboxedReturnType = Primitives.unwrap(methodType.returnType());
LabelNode end = new LabelNode("end");
Block block = new Block(context)
.setDescription("invoke " + signature);
ArrayList<Class<?>> stackTypes = new ArrayList<>();
int index = 0;
for (Class<?> type : methodType.parameterArray()) {
stackTypes.add(type);
if (type == ConnectorSession.class) {
block.append(getSessionByteCode);
}
else {
block.append(arguments.get(index));
index++;
block.append(ByteCodeUtils.ifWasNullPopAndGoto(context, end, unboxedReturnType, Lists.reverse(stackTypes)));
}
}
block.append(invoke(context, binding));
if (function.isNullable()) {
if (unboxedReturnType.isPrimitive()) {
LabelNode notNull = new LabelNode("notNull");
block.dup(methodType.returnType())
.ifNotNullGoto(notNull)
.putVariable("wasNull", true)
.comment("swap boxed null with unboxed default")
.pop(methodType.returnType())