CompilerContext context = generatorContext.getContext();
RowExpression first = arguments.get(0);
RowExpression second = arguments.get(1);
LabelNode notMatch = new LabelNode("notMatch");
// push first arg on the stack
Block block = new Block(context)
.comment("check if first arg is null")
.append(generatorContext.generate(first))
.append(ByteCodeUtils.ifWasNullPopAndGoto(context, notMatch, void.class));
Type firstType = first.getType();
Type secondType = second.getType();
// this is a hack! We shouldn't be determining type coercions at this point, but there's no way
// around it in the current expression AST
Type commonType = FunctionRegistry.getCommonSuperType(firstType, secondType).get();
FunctionBinding castFirst = generatorContext.getBootstrapBinder().bindCastOperator(
generatorContext.generateGetSession(),
new Block(context).dup(firstType.getJavaType()),
firstType,
commonType);
FunctionBinding castSecond = generatorContext.getBootstrapBinder().bindCastOperator(
generatorContext.generateGetSession(),
generatorContext.generate(second),
secondType,
commonType);
// if (equal(cast(first as <common type>), cast(second as <common type>))
FunctionBinding functionBinding = generatorContext.getBootstrapBinder().bindOperator(
OperatorType.EQUAL,
generatorContext.generateGetSession(),
ImmutableList.of(
invoke(context, castFirst, "cast(first)"),
invoke(context, castSecond, "cast(second)")),
ImmutableList.of(firstType, secondType));
MethodType methodType = functionBinding.getCallSite().type();
Class<?> unboxedReturnType = Primitives.unwrap(methodType.returnType());
LabelNode end = new LabelNode("end");
Block equalsCall = new Block(context)
.setDescription("invoke")
.comment("equal");
ArrayList<Class<?>> stackTypes = new ArrayList<>();