Example usage for org.objectweb.asm.tree AbstractInsnNode getOpcode

List of usage examples for org.objectweb.asm.tree AbstractInsnNode getOpcode

Introduction

In this page you can find the example usage for org.objectweb.asm.tree AbstractInsnNode getOpcode.

Prototype

public int getOpcode() 

Source Link

Document

Returns the opcode of this instruction.

Usage

From source file:org.mutabilitydetector.checkers.settermethod.AliasFinder.java

License:Apache License

private boolean isGetfieldForVariable(final AbstractInsnNode insn) {
    boolean result = false;
    if (Opcodes.GETFIELD == insn.getOpcode()) {
        final FieldInsnNode getfield = (FieldInsnNode) insn;
        result = variableName.equals(getfield.name);
    }//  w  w w.j av a2 s.com
    return result;
}

From source file:org.mutabilitydetector.checkers.settermethod.AliasFinder.java

License:Apache License

private static boolean isStoreInstruction(final AbstractInsnNode insn) {
    switch (insn.getOpcode()) {
    case ISTORE:// w ww . j  a  va 2 s.c  o m
    case LSTORE:
    case FSTORE:
    case DSTORE:
    case ASTORE:
        return true;
    default:
        return false;
    }
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuard.java

License:Apache License

@Override
public boolean equals(final Object obj) {
    if (this == obj) {
        return true;
    }/*from  ww w  .java2s .c o m*/
    if (obj == null) {
        return false;
    }
    if (!(obj instanceof AssignmentGuard)) {
        return false;
    }
    final AssignmentGuard other = (AssignmentGuard) obj;
    final JumpInsnNode jumpInsnNodeThis = delegationTarget.getJumpInsnNode();
    final JumpInsnNode jumpInsnNodeOther = other.getJumpInsnNode();
    if (jumpInsnNodeThis.getOpcode() != jumpInsnNodeOther.getOpcode()) {
        return false;
    }
    if (predecessorInstructions.size() != other.predecessorInstructions.size()) {
        return false;
    }
    final InstructionNodesComparator inc = new InstructionNodesComparator();
    for (int i = 0; i < predecessorInstructions.size(); i++) {
        final AbstractInsnNode insnsThis = predecessorInstructions.get(i);
        final AbstractInsnNode insnsOther = other.predecessorInstructions.get(i);
        if (insnsThis.getOpcode() != insnsOther.getOpcode()) {
            return false;
        }
        if (instructionsAreUnequal(insnsThis, insnsOther, inc)) {
            return false;
        }
    }
    return true;
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardFinder.java

License:Apache License

private static boolean isConditionCheckInstruction(final AbstractInsnNode insn) {
    final int opcode = insn.getOpcode();
    return AbstractInsnNode.JUMP_INSN == insn.getType() && opcode != Opcodes.GOTO && opcode != Opcodes.JSR
            && opcode != Opcodes.RET;
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardFinder.java

License:Apache License

private boolean isGetfieldOrGetstaticForCandidate(final AbstractInsnNode insn) {
    boolean result = false;
    if (GETFIELD == insn.getOpcode() || GETSTATIC == insn.getOpcode()) {
        final FieldInsnNode getInstruction = (FieldInsnNode) insn;
        result = candidateName.equals(getInstruction.name);
    }//from   w  w w  . ja  v a2s.c  o m
    return result;
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardFinder.java

License:Apache License

private static boolean isPushNullOntoStackInstruction(final AbstractInsnNode insn) {
    return ACONST_NULL == insn.getOpcode();
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardFinder.java

License:Apache License

private static boolean isComparisonInstruction(final AbstractInsnNode insn) {
    switch (insn.getOpcode()) {
    case LCMP:/*from  w ww .java  2 s  .  c o  m*/
    case FCMPL:
    case FCMPG:
    case DCMPL:
    case DCMPG:
    case IF_ICMPEQ:
    case IF_ICMPNE:
    case IF_ICMPLT:
    case IF_ICMPGE:
    case IF_ICMPGT:
    case IF_ICMPLE:
    case IF_ACMPEQ:
    case IF_ACMPNE:
        return true;
    default:
        return false;
    }
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardVerifier.java

License:Apache License

private static boolean isGetInstructionForVariable(final AbstractInsnNode insn, final FieldNode candidate) {
    boolean result = false;
    if (GETFIELD == insn.getOpcode() || GETSTATIC == insn.getOpcode()) {
        final FieldInsnNode getfield = (FieldInsnNode) insn;
        result = candidate.name.equals(getfield.name);
    }//w w w  .  j  av a2s .  com
    return result;
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardVerifier.java

License:Apache License

private static boolean isComparisonInsn(final AbstractInsnNode abstractInsnNode) {
    switch (abstractInsnNode.getOpcode()) {
    case LCMP://from w ww  . j  av a2s  .  co m
    case FCMPL:
    case FCMPG:
    case DCMPL:
    case DCMPG:
    case IF_ICMPEQ:
    case IF_ICMPNE:
    case IF_ICMPLT:
    case IF_ICMPGE:
    case IF_ICMPGT:
    case IF_ICMPLE:
    case IF_ACMPEQ:
    case IF_ACMPNE:
        return true;
    default:
        return false;
    }
}

From source file:org.mutabilitydetector.checkers.settermethod.AssignmentGuardVerifier.java

License:Apache License

private static UnknownTypeValue getComparativeValue(final AbstractInsnNode insn) {
    UnknownTypeValue result = null;//  w  w w  .j a v  a  2 s  .c om
    if (AbstractInsnNode.INSN == insn.getType()) {
        final Opcode opcode = Opcode.forInt(insn.getOpcode());
        result = opcode.stackValue();
    } else if (AbstractInsnNode.LDC_INSN == insn.getType()) {
        final LdcInsnNode ldcInsn = (LdcInsnNode) insn;
        result = DefaultUnknownTypeValue.getInstance(ldcInsn.cst);
    } else if (AbstractInsnNode.INT_INSN == insn.getType()) {
        final IntInsnNode intInsnNode = (IntInsnNode) insn;
        result = DefaultUnknownTypeValue.getInstance(intInsnNode.operand);
    }
    return result;
}