// determine the type of the value and result
Class<?> valueType = value.getType().getJavaType();
// evaluate the value and store it in a variable
LabelNode nullValue = new LabelNode("nullCondition");
Variable tempVariable = context.createTempVariable(valueType);
Block block = new Block(context)
.append(valueBytecode)
.append(ByteCodeUtils.ifWasNullClearPopAndGoto(context, nullValue, void.class, valueType))
.putVariable(tempVariable.getLocalVariableDefinition());
ByteCodeNode getTempVariableNode = VariableInstruction.loadVariable(tempVariable.getLocalVariableDefinition());
// build the statements
elseValue = new Block(context).visitLabel(nullValue).append(elseValue);
// reverse list because current if statement builder doesn't support if/else so we need to build the if statements bottom up
for (RowExpression clause : Lists.reverse(whenClauses)) {
Preconditions.checkArgument(clause instanceof CallExpression && ((CallExpression) clause).getSignature().getName().equals("WHEN"));
RowExpression operand = ((CallExpression) clause).getArguments().get(0);
RowExpression result = ((CallExpression) clause).getArguments().get(1);
// call equals(value, operand)
FunctionBinding functionBinding = generatorContext.getBootstrapBinder().bindOperator(
OperatorType.EQUAL,
generatorContext.generateGetSession(),
ImmutableList.of(generatorContext.generate(operand), getTempVariableNode),
ImmutableList.of(value.getType(), operand.getType()));
MethodType methodType = functionBinding.getCallSite().type();
Class<?> unboxedReturnType = Primitives.unwrap(methodType.returnType());
LabelNode end = new LabelNode("end");
Block equalsCall = new Block(context)
.setDescription("invoke")
.comment(operand.toString());
ArrayList<Class<?>> stackTypes = new ArrayList<>();
for (int i = 0; i < functionBinding.getArguments().size(); i++) {