binaryOp(cw, op, long.class, realOp, integerOp);
}
static void binaryOp(ClassWriter cw, String op, Class<?> returnType, Consumer<GeneratorAdapter> realOp,
Consumer<GeneratorAdapter> integerOp) {
GeneratorAdapter mv = new GeneratorAdapter(ACC_PUBLIC + ACC_STATIC,
method(toBytecodeName(op), desc(returnType, long.class, long.class)), null, null, cw);
isInteger(mv, 0);
Label argOneIsLong = new Label();
mv.ifZCmp(IFNE, argOneIsLong);
asDouble(mv, 0);
isInteger(mv, 1);
Label argTwoIsLong = new Label();
mv.ifZCmp(IFNE, argTwoIsLong);
asDouble(mv, 1);
Label doubleOperation = new Label();
mv.goTo(doubleOperation);
mv.visitLabel(argTwoIsLong);
asLong(mv, 1);
mv.visitInsn(L2D);
mv.goTo(doubleOperation);
mv.visitLabel(argOneIsLong);
isInteger(mv, 1);
Label longOperation = new Label();
mv.ifZCmp(IFNE, longOperation);
asLong(mv, 0);
mv.visitInsn(L2D);
asDouble(mv, 1);
mv.visitLabel(doubleOperation);
realOp.accept(mv);
mv.returnValue();
mv.visitLabel(longOperation);
asLong(mv, 0);
asLong(mv, 1);
integerOp.accept(mv);
mv.returnValue();
mv.endMethod();
}