Example usage for org.objectweb.asm Opcodes IF_ACMPNE

List of usage examples for org.objectweb.asm Opcodes IF_ACMPNE

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes IF_ACMPNE.

Prototype

int IF_ACMPNE

To view the source code for org.objectweb.asm Opcodes IF_ACMPNE.

Click Source Link

Usage

From source file:com.retroduction.carma.transformer.asm.ror.IF_ACMPNE_2_IF_ACMPEQ_Transition.java

License:Open Source License

public IF_ACMPNE_2_IF_ACMPEQ_Transition() {
    super();
    this.sourceInstruction = Opcodes.IF_ACMPNE;
    this.targetInstruction = Opcodes.IF_ACMPEQ;
}

From source file:com.trigersoft.jaque.expression.ExpressionMethodVisitor.java

License:Apache License

@Override
public void visitJumpInsn(int opcode, Label label) {
    int etype;/* ww  w .  ja va 2  s . co m*/
    switch (opcode) {
    case Opcodes.GOTO:

        go(label);

        return;
    default:
    case Opcodes.JSR:
        throw notLambda(opcode);
    case Opcodes.IFEQ:
        etype = ExpressionType.NotEqual; // Equal
        pushZeroConstantOrReduce();
        break;
    case Opcodes.IFNE:
        etype = ExpressionType.Equal; // NotEqual
        pushZeroConstantOrReduce();
        break;
    case Opcodes.IFLT:
        etype = ExpressionType.GreaterThanOrEqual; // LessThan
        pushZeroConstantOrReduce();
        break;
    case Opcodes.IFGE:
        etype = ExpressionType.LessThan; // GreaterThanOrEqual
        pushZeroConstantOrReduce();
        break;
    case Opcodes.IFGT:
        etype = ExpressionType.LessThanOrEqual; // GreaterThan
        pushZeroConstantOrReduce();
        break;
    case Opcodes.IFLE:
        etype = ExpressionType.GreaterThan; // LessThanOrEqual
        pushZeroConstantOrReduce();
        break;
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ACMPEQ: // ??
        etype = ExpressionType.NotEqual; // Equal
        break;
    case Opcodes.IF_ICMPNE:
    case Opcodes.IF_ACMPNE: // ??
        etype = ExpressionType.Equal; // NotEqual
        break;
    case Opcodes.IF_ICMPLT:
        etype = ExpressionType.GreaterThanOrEqual; // LessThan
        break;
    case Opcodes.IF_ICMPGE:
        etype = ExpressionType.LessThan; // GreaterThanOrEqual
        break;
    case Opcodes.IF_ICMPGT:
        etype = ExpressionType.LessThanOrEqual; // GreaterThan
        break;
    case Opcodes.IF_ICMPLE:
        etype = ExpressionType.GreaterThan; // LessThanOrEqual
        break;
    case Opcodes.IFNULL:
    case Opcodes.IFNONNULL:
        Expression e = Expression.isNull(_exprStack.pop());
        if (opcode == Opcodes.IFNULL) // IFNONNULL
            e = Expression.logicalNot(e);

        branch(label, e);

        return;
    }

    Expression second = _exprStack.pop();
    Expression first = _exprStack.pop();
    Expression e = Expression.binary(etype, first, second);

    branch(label, e);
}

From source file:de.codesourcery.asm.util.ASMUtil.java

License:Apache License

/**
 * Check whether an instruction is a conditional branch operation.
 *  //from   w  ww. j a v a  2  s.  c o m
 * @param node
 * @return
 */
public static boolean isConditionalJump(AbstractInsnNode node) {
    if (node.getType() == AbstractInsnNode.JUMP_INSN) {
        switch (node.getOpcode()) {
        case Opcodes.IFEQ:
        case Opcodes.IFNE:
        case Opcodes.IFLT:
        case Opcodes.IFGE:
        case Opcodes.IFGT:
        case Opcodes.IFLE:
        case Opcodes.IF_ICMPEQ:
        case Opcodes.IF_ICMPNE:
        case Opcodes.IF_ICMPLT:
        case Opcodes.IF_ICMPGE:
        case Opcodes.IF_ICMPGT:
        case Opcodes.IF_ICMPLE:
        case Opcodes.IF_ACMPEQ:
        case Opcodes.IF_ACMPNE:
        case Opcodes.IFNULL:
        case Opcodes.IFNONNULL:
            return true;
        }
    }
    return false;
}

From source file:de.sanandrew.core.manpack.transformer.TransformHorseArmor.java

License:Creative Commons License

private static void transformOnInvChanged(MethodNode method) {
    InsnList needle = new InsnList();
    needle.add(new VarInsnNode(Opcodes.ALOAD, 0));
    needle.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_HORSE_IS_SADDLED, false));
    needle.add(new VarInsnNode(Opcodes.ISTORE, 3));

    AbstractInsnNode pointer = ASMHelper.findLastNodeFromNeedle(method.instructions, needle);

    InsnList newInstr = new InsnList();
    newInstr.add(new LabelNode());
    newInstr.add(new VarInsnNode(Opcodes.ALOAD, 0));
    newInstr.add(//ww w . ja v a 2 s  . co  m
            ASMHelper.getMethodInsnNode(Opcodes.INVOKESPECIAL, ASMNames.MD_SAP_GET_CUSTOM_ARMOR_ITEM, false));
    newInstr.add(new VarInsnNode(Opcodes.ASTORE, 4));

    method.instructions.insert(pointer, newInstr);

    needle = new InsnList();
    needle.add(new LdcInsnNode("mob.horse.armor"));
    needle.add(new LdcInsnNode(0.5F));
    needle.add(new InsnNode(Opcodes.FCONST_1));
    needle.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_HORSE_PLAY_SOUND, false));
    needle.add(new LabelNode());

    pointer = ASMHelper.findLastNodeFromNeedle(method.instructions, needle);

    newInstr = new InsnList();
    newInstr.add(new VarInsnNode(Opcodes.ALOAD, 4));
    newInstr.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_ITEMSTACK_GET_ITEM, false));
    newInstr.add(ASMHelper.getFieldInsnNode(Opcodes.GETSTATIC, ASMNames.FD_ITEMS_IRON_SHOVEL));
    LabelNode l9 = new LabelNode();
    newInstr.add(new JumpInsnNode(Opcodes.IF_ACMPNE, l9));
    newInstr.add(new VarInsnNode(Opcodes.ALOAD, 4));
    newInstr.add(new VarInsnNode(Opcodes.ALOAD, 0));
    newInstr.add(
            ASMHelper.getMethodInsnNode(Opcodes.INVOKESPECIAL, ASMNames.MD_SAP_GET_CUSTOM_ARMOR_ITEM, false));
    newInstr.add(
            ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_ITEMSTACK_IS_ITEM_EQUAL, false));
    newInstr.add(new JumpInsnNode(Opcodes.IFNE, l9));
    newInstr.add(new LabelNode());
    newInstr.add(new VarInsnNode(Opcodes.ALOAD, 0));
    newInstr.add(new LdcInsnNode("mob.horse.armor"));
    newInstr.add(new LdcInsnNode(0.5F));
    newInstr.add(new InsnNode(Opcodes.FCONST_1));
    newInstr.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_HORSE_PLAY_SOUND, false));
    newInstr.add(l9);

    method.instructions.insert(pointer, newInstr);
}

From source file:de.sanandrew.core.manpack.transformer.TransformHorseArmor.java

License:Creative Commons License

private static void transformInteract(MethodNode method) {

    InsnList needle = new InsnList();
    needle.add(ASMHelper.getFieldInsnNode(Opcodes.GETSTATIC, ASMNames.FD_ITEMS_DIAMOND_HORSE_ARMOR));
    needle.add(new JumpInsnNode(Opcodes.IF_ACMPNE, new LabelNode()));
    needle.add(new LabelNode());
    needle.add(new LineNumberNode(-1, new LabelNode()));
    needle.add(new InsnNode(Opcodes.ICONST_3));
    needle.add(new VarInsnNode(Opcodes.ISTORE, 4));
    needle.add(new LabelNode());
    needle.add(new LineNumberNode(-1, new LabelNode()));
    needle.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));

    AbstractInsnNode node = ASMHelper.findLastNodeFromNeedle(method.instructions, needle);

    InsnList newInstr = new InsnList();
    newInstr.add(new LabelNode());
    newInstr.add(new VarInsnNode(Opcodes.ALOAD, 2));
    newInstr.add(ASMHelper.getMethodInsnNode(Opcodes.INVOKEVIRTUAL, ASMNames.MD_ITEMSTACK_GET_ITEM, false));
    newInstr.add(new TypeInsnNode(Opcodes.INSTANCEOF, ASMNames.CL_ITEM_HORSE_ARMOR));
    LabelNode l8 = new LabelNode();
    newInstr.add(new JumpInsnNode(Opcodes.IFEQ, l8));
    newInstr.add(new LabelNode());
    newInstr.add(new InsnNode(Opcodes.ICONST_4));
    newInstr.add(new VarInsnNode(Opcodes.ISTORE, 4));
    newInstr.add(l8);/*  w  w  w.jav  a 2  s  .co m*/
    newInstr.add(new FrameNode(Opcodes.F_SAME, 0, null, 0, null));

    method.instructions.insert(node, newInstr);
}

From source file:de.scoopgmbh.copper.instrument.BuildStackInfoAdapter.java

License:Apache License

@Override
public void visitJumpInsn(int arg0, Label arg1) {
    savePreviousFrame();/*from   w ww  .j a  v  a  2  s .  c o m*/
    switch (arg0) {
    case Opcodes.IF_ACMPEQ:
    case Opcodes.IF_ACMPNE:
    case Opcodes.IF_ICMPEQ:
    case Opcodes.IF_ICMPGE:
    case Opcodes.IF_ICMPGT:
    case Opcodes.IF_ICMPLE:
    case Opcodes.IF_ICMPLT:
    case Opcodes.IF_ICMPNE:
        currentFrame.popStack();
    case Opcodes.IFEQ:
    case Opcodes.IFGE:
    case Opcodes.IFGT:
    case Opcodes.IFLE:
    case Opcodes.IFLT:
    case Opcodes.IFNE:
    case Opcodes.IFNONNULL:
    case Opcodes.IFNULL:
        currentFrame.popStack();
    case Opcodes.GOTO:
        forwardFrames.put(arg1, new StackInfo(currentFrame));
        break;
    case Opcodes.JSR:
        currentFrame.pushStack(retAddressType);
        forwardFrames.put(arg1, new StackInfo(currentFrame));
        break;
    default:
        logger.debug("Unhandled: ");
    }
    if (logger.isDebugEnabled())
        logger.debug("jumpInsn " + getOpCode(arg0) + " " + arg1);
    delegate.visitJumpInsn(arg0, arg1);
}

From source file:de.tuberlin.uebb.jbop.optimizer.controlflow.ConstantIfInliner.java

License:Open Source License

private boolean evalTwoOpValue(final Number op1, final Number op2, final int opcode) {
    switch (opcode) {
    case Opcodes.IF_ICMPEQ:
        return op1.intValue() == op2.intValue();
    case Opcodes.IF_ICMPNE:
        return op1.intValue() != op2.intValue();
    case Opcodes.IF_ICMPLT:
        return op1.intValue() < op2.intValue();
    case Opcodes.IF_ICMPGE:
        return op1.intValue() >= op2.intValue();
    case Opcodes.IF_ICMPGT:
        return op1.intValue() > op2.intValue();
    case Opcodes.IF_ICMPLE:
        return op1.intValue() <= op2.intValue();
    case Opcodes.IF_ACMPEQ:
        return op1 == op2;
    case Opcodes.IF_ACMPNE:
        return op1 != op2;
    default:/*w  w  w .  j  a v  a 2s.  c o m*/
        return false;
    }
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

License:Open Source License

/**
 * Returns true if node is an two-param-if-Statement.
 * /* w  w  w .  ja v  a2 s  .  c  om*/
 * @param node
 *          the node
 * @return true if node is two value if
 */
public static boolean isTwoValueIf(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    return node.getOpcode() >= Opcodes.IF_ICMPEQ && node.getOpcode() <= Opcodes.IF_ACMPNE;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction.java

License:Open Source License

@Override
public String toString() {
    String condition;/*  w w  w .  j a v a  2 s. c o  m*/
    switch (getOpcode()) {
    case Opcodes.IFEQ:
        condition = "IFEQ";
        break;
    case Opcodes.IFNE:
        condition = "IFNE";
        break;
    case Opcodes.IFLT:
        condition = "IFLT";
        break;
    case Opcodes.IFGE:
        condition = "IFGE";
        break;
    case Opcodes.IFGT:
        condition = "IFGT";
        break;
    case Opcodes.IFLE:
        condition = "IFLE";
        break;
    case Opcodes.IF_ICMPEQ:
        condition = "IF_ICMPEQ";
        break;
    case Opcodes.IF_ICMPNE:
        condition = "IF_ICMPNE";
        break;
    case Opcodes.IF_ICMPLT:
        condition = "IF_ICMPLT";
        break;
    case Opcodes.IF_ICMPGE:
        condition = "IF_ICMPGE";
        break;
    case Opcodes.IF_ICMPGT:
        condition = "IF_ICMPGT";
        break;
    case Opcodes.IF_ICMPLE:
        condition = "IF_ICMPLE";
        break;
    case Opcodes.IF_ACMPEQ:
        condition = "IF_ACMPEQ";
        break;
    case Opcodes.IF_ACMPNE:
        condition = "IF_ACMPNE";
        break;
    case Opcodes.GOTO:
        condition = "GOTO";
        break;
    case Opcodes.JSR:
        condition = "JSR";
        break;
    case Opcodes.IFNULL:
        condition = "IFNULL";
        break;
    case Opcodes.IFNONNULL:
        condition = "IFNONNULL";
        break;
    default:
        assert false;
        condition = "--ERROR--";
        break;
    }

    return condition + " " + this.label;
}

From source file:de.unisb.cs.st.javaslicer.common.classRepresentation.instructions.JumpInstruction2.java

License:Open Source License

@Override
public String toString() {
    String condition;//  ww  w  .j a va  2s.  c  o  m
    switch (getOpcode()) {
    case Opcodes.IFEQ:
        condition = "IFEQ";
        break;
    case Opcodes.IFNE:
        condition = "IFNE";
        break;
    case Opcodes.IFLT:
        condition = "IFLT";
        break;
    case Opcodes.IFGE:
        condition = "IFGE";
        break;
    case Opcodes.IFGT:
        condition = "IFGT";
        break;
    case Opcodes.IFLE:
        condition = "IFLE";
        break;
    case Opcodes.IF_ICMPEQ:
        condition = "IF_ICMPEQ";
        break;
    case Opcodes.IF_ICMPNE:
        condition = "IF_ICMPNE";
        break;
    case Opcodes.IF_ICMPLT:
        condition = "IF_ICMPLT";
        break;
    case Opcodes.IF_ICMPGE:
        condition = "IF_ICMPGE";
        break;
    case Opcodes.IF_ICMPGT:
        condition = "IF_ICMPGT";
        break;
    case Opcodes.IF_ICMPLE:
        condition = "IF_ICMPLE";
        break;
    case Opcodes.IF_ACMPEQ:
        condition = "IF_ACMPEQ";
        break;
    case Opcodes.IF_ACMPNE:
        condition = "IF_ACMPNE";
        break;
    case Opcodes.GOTO:
        condition = "GOTO";
        break;
    case Opcodes.JSR:
        condition = "JSR";
        break;
    case Opcodes.IFNULL:
        condition = "IFNULL";
        break;
    case Opcodes.IFNONNULL:
        condition = "IFNONNULL";
        break;
    default:
        assert false;
        condition = "--ERROR--";
        break;
    }

    return condition + " " + this.target;
}