/** * Helper method to generate an instance of a subclass of * {@link StoreInstruction} based on the specified {@link Type} that will * store a value in the specified local variable * @param index the JVM stack frame index of the variable that is to be * stored * @param type the {@link Type} of the variable * @return the generated {@link StoredInstruction} */ private static Instruction storeLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ISTORE(index); } else if (type == Type.INT) { return new ISTORE(index); } else if (type == Type.SHORT) { return new ISTORE(index); } else if (type == Type.LONG) { return new LSTORE(index); } else if (type == Type.BYTE) { return new ISTORE(index); } else if (type == Type.CHAR) { return new ISTORE(index); } else if (type == Type.FLOAT) { return new FSTORE(index); } else if (type == Type.DOUBLE) { return new DSTORE(index); } else { return new ASTORE(index); } }
@SuppressWarnings("unused") // Called using reflection private Instruction createInstructionFstore(Element inst) throws IllegalXMLVMException { int idx= Integer.parseInt(inst.getAttributeValue("index")); return new FSTORE(idx); }
/** * @param index index of local variable */ public static LocalVariableInstruction createStore(Type type, int index) { switch(type.getType()) { case Constants.T_BOOLEAN: case Constants.T_CHAR: case Constants.T_BYTE: case Constants.T_SHORT: case Constants.T_INT: return new ISTORE(index); case Constants.T_FLOAT: return new FSTORE(index); case Constants.T_DOUBLE: return new DSTORE(index); case Constants.T_LONG: return new LSTORE(index); case Constants.T_ARRAY: case Constants.T_OBJECT: return new ASTORE(index); default: throw new RuntimeException("Invalid type " + type); } }
/** * @param index index of local variable */ public static LocalVariableInstruction createStore( final Type type, final int index ) { switch (type.getType()) { case Const.T_BOOLEAN: case Const.T_CHAR: case Const.T_BYTE: case Const.T_SHORT: case Const.T_INT: return new ISTORE(index); case Const.T_FLOAT: return new FSTORE(index); case Const.T_DOUBLE: return new DSTORE(index); case Const.T_LONG: return new LSTORE(index); case Const.T_ARRAY: case Const.T_OBJECT: return new ASTORE(index); default: throw new RuntimeException("Invalid type " + type); } }
/** * Helper method to generate an instance of a subclass of * {@link StoreInstruction} based on the specified {@link Type} that will * store a value in the specified local variable * @param index the JVM stack frame index of the variable that is to be * stored * @param type the {@link Type} of the variable * @return the generated {@link StoredInstruction} */ private static Instruction storeLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ISTORE(index); } else if (type == Type.INT) { return new ISTORE(index); } else if (type == Type.SHORT) { return new ISTORE(index); } else if (type == Type.LONG) { return new LSTORE(index); } else if (type == Type.BYTE) { return new ISTORE(index); } else if (type == Type.CHAR) { return new ISTORE(index); } else if (type == Type.FLOAT) { return new FSTORE(index); } else if (type == Type.DOUBLE) { return new DSTORE(index); } else { return new ASTORE(index); } }
/** * Helper method to generate an instance of a subclass of * {@link StoreInstruction} based on the specified {@link Type} that will * store a value in the specified local variable * @param index the JVM stack frame index of the variable that is to be * stored * @param type the {@link Type} of the variable * @return the generated {@link StoredInstruction} */ private static Instruction storeLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ISTORE(index); } else if (type == Type.INT) { return new ISTORE(index); } else if (type == Type.SHORT) { return new ISTORE(index); } else if (type == Type.LONG) { return new LSTORE(index); } else if (type == Type.BYTE) { return new ISTORE(index); } else if (type == Type.CHAR) { return new ISTORE(index); } else if (type == Type.FLOAT) { return new FSTORE(index); } else if (type == Type.DOUBLE) { return new DSTORE(index); } else { return new ASTORE(index); } }
/** * Helper method to generate an instance of a subclass of * {@link StoreInstruction} based on the specified {@link Type} that will * store a value in the specified local variable * @param index the JVM stack frame index of the variable that is to be * stored * @param type the {@link Type} of the variable * @return the generated {@link StoredInstruction} */ private static Instruction storeLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ISTORE(index); } else if (type == Type.INT) { return new ISTORE(index); } else if (type == Type.SHORT) { return new ISTORE(index); } else if (type == Type.LONG) { return new LSTORE(index); } else if (type == Type.BYTE) { return new ISTORE(index); } else if (type == Type.CHAR) { return new ISTORE(index); } else if (type == Type.FLOAT) { return new FSTORE(index); } else if (type == Type.DOUBLE) { return new DSTORE(index); } else { return new ASTORE(index); } }
int constrIndex = cp.addMethodref("java.lang.Float", "<init>", "(F)V"); il.append(new FSTORE(4)); il.append(new NEW(x)); il.append(new ASTORE(5));
int constrIndex = cp.addMethodref("java.lang.Float", "<init>", "(F)V"); il.append(new FSTORE(4)); il.append(new NEW(x)); il.append(new ASTORE(5));
break; case Const.FSTORE: ins = new FSTORE(r.nextInt(slots)); break; case Const.DSTORE: break; case Const.FSTORE_0: ins = new FSTORE(0); break; case Const.FSTORE_1: ins = new FSTORE(1); break; case Const.FSTORE_2: ins = new FSTORE(2); break; case Const.FSTORE_3: ins = new FSTORE(3); break; case Const.DSTORE_0: