List of usage examples for org.objectweb.asm.tree AbstractInsnNode getOpcode
public int getOpcode()
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Checks if node is if cmp lt.//from w w w .j av a 2s . c om * * @param node * the node * @return true if node is if cmp lt */ public static boolean isIfCmpLt(final AbstractInsnNode node) { if (node == null) { return false; } return node.getOpcode() == Opcodes.IF_ICMPLT; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Checks if node is daload.//from ww w . ja v a 2 s . co m * * @param node * the node * @return true if node is daload */ public static boolean isDAload(final AbstractInsnNode node) { if (node == null) { return false; } return node.getOpcode() == Opcodes.DALOAD; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Checks if node is aaload./*from w ww . ja v a2s. co m*/ * * @param node * the node * @return true if node is a aload */ public static boolean isAAload(final AbstractInsnNode node) { if (node == null) { return false; } return node.getOpcode() == Opcodes.AALOAD; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
public static Number cast(final Number number, final AbstractInsnNode numberNode, final AbstractInsnNode castNode) { if (castNode == null) { return null; }/*from w w w . j a v a 2 s. co m*/ if (castNode == numberNode) { return number; } final int opcode = castNode.getOpcode(); if (opcode == I2B) { return (byte) number.intValue(); } // if(opcode==I2C) { // return (char)number.intValue(); // } if (opcode == I2L) { return (long) number.intValue(); } if (opcode == I2S) { return (short) number.intValue(); } if (opcode == I2D) { return (double) number.intValue(); } if (opcode == I2F) { return (float) number.intValue(); } if (opcode == D2F) { return (float) number.doubleValue(); } if (opcode == D2I) { return (int) number.doubleValue(); } if (opcode == D2L) { return (long) number.doubleValue(); } if (opcode == F2D) { return (double) number.floatValue(); } if (opcode == F2I) { return (int) number.floatValue(); } if (opcode == F2L) { return (long) number.floatValue(); } if (opcode == L2D) { return (long) number.longValue(); } if (opcode == L2F) { return (float) number.longValue(); } if (opcode == L2I) { return (int) number.longValue(); } return number; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Gets the value.// ww w . ja v a 2s . c om * * @param node * the node * @return the value * @throws NotANumberException * if node is not a number-Node */ public static Number getNumberValue(final AbstractInsnNode node) throws NotANumberException { if (node == null) { throw new NotANumberException(); } AbstractInsnNode checkNode = node; if (isCast(node)) { checkNode = node.getPrevious(); } if (isIconst(checkNode)) { return cast(Integer.valueOf(checkNode.getOpcode() - Opcodes.ICONST_0), checkNode, node); } if (checkNode.getOpcode() == Opcodes.LCONST_0) { return cast(Long.valueOf(0), checkNode, node); } if (checkNode.getOpcode() == Opcodes.LCONST_1) { return cast(Long.valueOf(1), checkNode, node); } if (checkNode.getOpcode() == Opcodes.FCONST_0) { return cast(Float.valueOf(0), checkNode, node); } if (checkNode.getOpcode() == Opcodes.FCONST_1) { return cast(Float.valueOf(1), checkNode, node); } if (checkNode.getOpcode() == Opcodes.FCONST_2) { return cast(Float.valueOf(1), checkNode, node); } if (checkNode.getOpcode() == Opcodes.DCONST_0) { return cast(Double.valueOf(0), checkNode, node); } if (checkNode.getOpcode() == Opcodes.DCONST_1) { return cast(Double.valueOf(1), checkNode, node); } if (checkNode instanceof IntInsnNode) { return cast(Integer.valueOf(((IntInsnNode) checkNode).operand), checkNode, node); } return cast(getConstantValue(checkNode, Number.class), checkNode, node); }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
private static <T> T getConstantValue(final AbstractInsnNode node, final Class<T> clazz) throws NotANumberException { if (node == null) { throw new NotANumberException(); }/*from w w w . j a v a 2 s . co m*/ if (node.getOpcode() == ACONST_NULL) { return null; } if (!(node instanceof LdcInsnNode)) { throw new NotANumberException(); } try { final Object value = ((LdcInsnNode) node).cst; return clazz.cast(value); } catch (final ClassCastException cce) { throw new NotANumberException(); } }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Checks if node is astore.//from www.j ava 2 s . c o m * * @param node * the node * @return true if node is astore */ public static boolean isAstore(final AbstractInsnNode node) { if (node == null) { return false; } return node.getOpcode() == Opcodes.ASTORE; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Checks if node is sipush./*from ww w . j ava 2s . c om*/ * * @param node * the node * @return true if node is sipush */ public static boolean isSipush(final AbstractInsnNode node) { if (node == null) { return false; } return node.getOpcode() == Opcodes.SIPUSH; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Checks if this is a cast.//w ww . j a v a2 s. c o m * <p> * i2l 0x85 value result convert an int into a long<br/> * i2f 0x86 value result convert an int into a float<br/> * i2d 0x87 value result convert an int into a double<br/> * l2i 0x88 value result convert a long to a int<br/> * l2f 0x89 value result convert a long to a float<br/> * l2d 0x8a value result convert a long to a double<br/> * f2i 0x8b value result convert a float to an int<br/> * f2l 0x8c value result convert a float to a long<br/> * f2d 0x8d value result convert a float to a double<br/> * d2i 0x8e value result convert a double to an int<br/> * d2l 0x8f value result convert a double to a long<br/> * d2f 0x90 value result convert a double to a float<br/> * i2b 0x91 value result convert an int into a byte<br/> * i2c 0x92 value result convert an int into a character<br/> * i2s 0x93 value result convert an int into a short * * @param numberNode * the number node * @return true if numberNode is cast */ public static boolean isCast(final AbstractInsnNode numberNode) { if (numberNode == null) { return false; } if (numberNode.getOpcode() >= I2L && numberNode.getOpcode() <= I2S) { return true; } return false; }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
License:Open Source License
/** * Returns true if node is an one-param-if-Statement. * //from w w w .j a va 2 s.co m * @param node * the node * @return true if node is one value if */ public static boolean isOneValueIf(final AbstractInsnNode node) { if (node == null) { return false; } if (node.getOpcode() == Opcodes.IFNULL) { return true; } if (node.getOpcode() == Opcodes.IFNONNULL) { return true; } if (node.getOpcode() >= Opcodes.IFEQ && node.getOpcode() <= Opcodes.IFLE) { return true; } return false; }