java中if项目实例_Java Opcodes.IF_ICMPLT属性代码示例

/**

* 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);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值