概述
/**
* 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.
*/
public void ifCmp(final Type type, final int mode, final Label label) {
switch (type.getSort()) {
case Type.LONG:
mv.visitInsn(Opcodes.LCMP);
break;
case Type.DOUBLE:
mv.visitInsn(mode == GE || mode == GT ? Opcodes.DCMPL
: Opcodes.DCMPG);
break;
case Type.FLOAT:
mv.visitInsn(mode == GE || mode == GT ? Opcodes.FCMPL
: Opcodes.FCMPG);
break;
case Type.ARRAY:
case Type.OBJECT:
switch (mode) {
case EQ:
mv.visitJumpInsn(Opcodes.IF_ACMPEQ, label);
return;
case NE:
mv.visitJumpInsn(Opcodes.IF_ACMPNE, label);
return;
}
throw new IllegalArgumentException("Bad comparison for type "
+ type);
default:
int intOp = -1;
switch (mode) {
case EQ:
intOp = Opcodes.IF_ICMPEQ;
break;
case NE:
intOp = Opcodes.IF_ICMPNE;
break;
case GE:
intOp = Opcodes.IF_ICMPGE;
break;
case LT:
intOp = Opcodes.IF_ICMPLT;
break;
case LE:
intOp = Opcodes.IF_ICMPLE;
break;
case GT:
intOp = Opcodes.IF_ICMPGT;
break;
}
mv.visitJumpInsn(intOp, label);
return;
}
mv.visitJumpInsn(mode, label);
}
最后
以上就是霸气哈密瓜为你收集整理的java中if项目实例_Java Opcodes.IF_ICMPLT属性代码示例的全部内容,希望文章能够帮你解决java中if项目实例_Java Opcodes.IF_ICMPLT属性代码示例所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复