MCPcopy Index your code
hub / github.com/clojure/clojure / ifCmp

Method ifCmp

src/jvm/clojure/asm/commons/GeneratorAdapter.java:955–1005  ·  view source on GitHub ↗

Generates the instructions to jump to a label based on the comparison of the top two stack values. @param type the type of the top two stack values. @param mode how these values must be compared. One of EQ, NE, LT, GE, GT, LE. @param label where to jump if the comparison result is true .

(final Type type, final int mode, final Label label)

Source from the content-addressed store, hash-verified

953 * @param label where to jump if the comparison result is <tt>true</tt>.
954 */
955 public void ifCmp(final Type type, final int mode, final Label label) {
956 switch (type.getSort()) {
957 case Type.LONG:
958 mv.visitInsn(Opcodes.LCMP);
959 break;
960 case Type.DOUBLE:
961 mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL : Opcodes.DCMPG);
962 break;
963 case Type.FLOAT:
964 mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL : Opcodes.FCMPG);
965 break;
966 case Type.ARRAY:
967 case Type.OBJECT:
968 if (mode == EQ) {
969 mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
970 return;
971 } else if (mode == NE) {
972 mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
973 return;
974 } else {
975 throw new IllegalArgumentException("Bad comparison for type " + type);
976 }
977 default:
978 int intOp = -1;
979 switch (mode) {
980 case EQ:
981 intOp = Opcodes.IF_ICMPEQ;
982 break;
983 case NE:
984 intOp = Opcodes.IF_ICMPNE;
985 break;
986 case GE:
987 intOp = Opcodes.IF_ICMPGE;
988 break;
989 case LT:
990 intOp = Opcodes.IF_ICMPLT;
991 break;
992 case LE:
993 intOp = Opcodes.IF_ICMPLE;
994 break;
995 case GT:
996 intOp = Opcodes.IF_ICMPGT;
997 break;
998 default:
999 throw new IllegalArgumentException("Bad comparison mode " + mode);
1000 }
1001 mv.visitJumpInsn(intOp, label);
1002 return;
1003 }
1004 mv.visitJumpInsn(mode, label);
1005 }
1006
1007 /**
1008 * Generates the instructions to jump to a label based on the comparison of the top two integer

Callers 2

ifICmpMethod · 0.95
emitThenForIntsMethod · 0.80

Calls 3

getSortMethod · 0.45
visitInsnMethod · 0.45
visitJumpInsnMethod · 0.45

Tested by

no test coverage detected