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:de.tuberlin.uebb.jbop.optimizer.utils.LoopMatcher.java

License:Open Source License

/**
 * Gets the loop.//from w  ww .j a  v a 2  s.  c om
 * 
 * @param node
 *          the node
 * @return the loop
 */
public static Loop getLoop(final AbstractInsnNode node) {
    if (node == null) {
        return null;
    }

    final int opcode = node.getOpcode();
    if (opcode != ISTORE) {
        return null;
    }

    final AbstractInsnNode next = node.getNext();

    if (NodeHelper.isGoto(next)) {
        return getTypeOneLoop(node, next);
    }
    return getTypeTwoLoop(node, next);
}

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

License:Open Source License

/**
 * Checks if node is store of loop.//from   w ww  .ja v  a 2  s .  c  o m
 * 
 * @param node
 *          the node
 * @return true if node is store of loop
 */
public static boolean isStoreOfLoop(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }

    final int opcode = node.getOpcode();
    if (opcode != ISTORE) {
        return false;
    }

    final AbstractInsnNode next = node.getNext();
    if (NodeHelper.isGoto(next)) {
        return getTypeOneLoop(node, next) != null;
    }
    if (next instanceof LabelNode) {
        return getTypeTwoLoop(node, next) != null;
    }
    return false;
}

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

License:Open Source License

/**
 * Checks if node is aload./*w  w  w.  j a v a 2  s  .  c  om*/
 * 
 * @param node
 *          the node
 * @return true if node is aload
 */
public static boolean isAload(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    return node.getOpcode() == Opcodes.ALOAD;

}

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

License:Open Source License

/**
 * Checks if node is getField.//  w  w  w  . ja  va  2s.  c  o  m
 * 
 * @param node
 *          the node
 * @return true if node is a getField
 */
public static boolean isGetField(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    return node.getOpcode() == Opcodes.GETFIELD;
}

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

License:Open Source License

/**
 * Checks if node is array length./*  w  w w . j  a  v a2  s . com*/
 * 
 * @param node
 *          the node
 * @return true if node is array length
 */
public static boolean isArrayLength(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    return node.getOpcode() == Opcodes.ARRAYLENGTH;
}

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

License:Open Source License

/**
 * Checks if node is iconst./*from ww  w  .  ja va  2 s  .  c om*/
 * 
 * @param node
 *          the node
 * @return true, if is iconst
 */
public static boolean isIconst(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    return node.getOpcode() >= Opcodes.ICONST_M1 && node.getOpcode() <= Opcodes.ICONST_5;
}

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

License:Open Source License

/**
 * Checks if node is iconst_i.//from  w  ww . j  av  a2  s .c  o  m
 * 
 * @param node
 *          the node
 * @param i
 *          the i
 * @return true, if is iconst_i
 */
public static boolean isIconst(final AbstractInsnNode node, final int i) {
    if (node == null) {
        return false;
    }
    if (node instanceof InsnNode) {
        return node.getOpcode() == Opcodes.ICONST_0 + i;
    }
    return false;
}

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

License:Open Source License

/**
 * Checks if node is goto.//from ww  w.j  a  v a2 s .  com
 * 
 * @param node
 *          the node
 * @return true if node1 is goto
 */
public static boolean isGoto(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    if (node instanceof JumpInsnNode) {
        return node.getOpcode() == Opcodes.GOTO;
    }

    return false;
}

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

License:Open Source License

/**
 * Checks if node is iload_i.//from ww w . ja va2s.  co  m
 * 
 * @param node
 *          the node
 * @param i
 *          the i
 * @return true, if is iload_i (-1 for any I_LOAD)
 */
public static boolean isIload(final AbstractInsnNode node, final int i) {
    if (node == null) {
        return false;
    }
    if (node instanceof VarInsnNode) {
        final boolean isIload = node.getOpcode() == Opcodes.ILOAD;
        return isIload && ((VarInsnNode) node).var == i || i == CONST_M1;
    }
    return false;
}

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

License:Open Source License

/**
 * Checks if node is bipush./*from   ww w  . jav  a  2  s .  c  o  m*/
 * 
 * @param node
 *          the node
 * @return true if node is bipush
 */
public static boolean isBipush(final AbstractInsnNode node) {
    if (node == null) {
        return false;
    }
    return node.getOpcode() == Opcodes.BIPUSH;
}