/** * Helper method to generate an instance of a subclass of * {@link LoadInstruction} based on the specified {@link Type} that will * load the specified local variable * @param index the JVM stack frame index of the variable that is to be * loaded * @param type the {@link Type} of the variable * @return the generated {@link LoadInstruction} */ private static Instruction loadLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ILOAD(index); } else if (type == Type.INT) { return new ILOAD(index); } else if (type == Type.SHORT) { return new ILOAD(index); } else if (type == Type.LONG) { return new LLOAD(index); } else if (type == Type.BYTE) { return new ILOAD(index); } else if (type == Type.CHAR) { return new ILOAD(index); } else if (type == Type.FLOAT) { return new FLOAD(index); } else if (type == Type.DOUBLE) { return new DLOAD(index); } else { return new ALOAD(index); } }
@SuppressWarnings("unused") // Called using reflection private Instruction createInstructionLload(Element inst) throws IllegalXMLVMException { int idx= Integer.parseInt(inst.getAttributeValue("index")); return new LLOAD(idx); }
/** * @param index index of local variable */ public static LocalVariableInstruction createLoad(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 ILOAD(index); case Constants.T_FLOAT: return new FLOAD(index); case Constants.T_DOUBLE: return new DLOAD(index); case Constants.T_LONG: return new LLOAD(index); case Constants.T_ARRAY: case Constants.T_OBJECT: return new ALOAD(index); default: throw new RuntimeException("Invalid type " + type); } }
/** * @param index index of local variable */ public static LocalVariableInstruction createLoad( 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 ILOAD(index); case Const.T_FLOAT: return new FLOAD(index); case Const.T_DOUBLE: return new DLOAD(index); case Const.T_LONG: return new LLOAD(index); case Const.T_ARRAY: case Const.T_OBJECT: return new ALOAD(index); default: throw new RuntimeException("Invalid type " + type); } }
/** * Helper method to generate an instance of a subclass of * {@link LoadInstruction} based on the specified {@link Type} that will * load the specified local variable * @param index the JVM stack frame index of the variable that is to be * loaded * @param type the {@link Type} of the variable * @return the generated {@link LoadInstruction} */ private static Instruction loadLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ILOAD(index); } else if (type == Type.INT) { return new ILOAD(index); } else if (type == Type.SHORT) { return new ILOAD(index); } else if (type == Type.LONG) { return new LLOAD(index); } else if (type == Type.BYTE) { return new ILOAD(index); } else if (type == Type.CHAR) { return new ILOAD(index); } else if (type == Type.FLOAT) { return new FLOAD(index); } else if (type == Type.DOUBLE) { return new DLOAD(index); } else { return new ALOAD(index); } }
/** * Helper method to generate an instance of a subclass of * {@link LoadInstruction} based on the specified {@link Type} that will * load the specified local variable * @param index the JVM stack frame index of the variable that is to be * loaded * @param type the {@link Type} of the variable * @return the generated {@link LoadInstruction} */ private static Instruction loadLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ILOAD(index); } else if (type == Type.INT) { return new ILOAD(index); } else if (type == Type.SHORT) { return new ILOAD(index); } else if (type == Type.LONG) { return new LLOAD(index); } else if (type == Type.BYTE) { return new ILOAD(index); } else if (type == Type.CHAR) { return new ILOAD(index); } else if (type == Type.FLOAT) { return new FLOAD(index); } else if (type == Type.DOUBLE) { return new DLOAD(index); } else { return new ALOAD(index); } }
/** * Helper method to generate an instance of a subclass of * {@link LoadInstruction} based on the specified {@link Type} that will * load the specified local variable * @param index the JVM stack frame index of the variable that is to be * loaded * @param type the {@link Type} of the variable * @return the generated {@link LoadInstruction} */ private static Instruction loadLocal(int index, Type type) { if (type == Type.BOOLEAN) { return new ILOAD(index); } else if (type == Type.INT) { return new ILOAD(index); } else if (type == Type.SHORT) { return new ILOAD(index); } else if (type == Type.LONG) { return new LLOAD(index); } else if (type == Type.BYTE) { return new ILOAD(index); } else if (type == Type.CHAR) { return new ILOAD(index); } else if (type == Type.FLOAT) { return new FLOAD(index); } else if (type == Type.DOUBLE) { return new DLOAD(index); } else { return new ALOAD(index); } }
static InstructionHandle emitLoad(InstructionList il, int index, Type type) { switch (type.getType()) { case Constants.T_BOOLEAN: case Constants.T_CHAR: case Constants.T_BYTE: case Constants.T_SHORT: case Constants.T_INT: return il.append(new ILOAD(index)); case Constants.T_LONG: return il.append(new LLOAD(index)); case Constants.T_FLOAT: return il.append(new FLOAD(index)); case Constants.T_DOUBLE: return il.append(new DLOAD(index)); default: return il.append(new ALOAD(index)); } }
il.append(new ASTORE(6)); il.append(new ALOAD(6)); il.append(new LLOAD(4)); il.append(new INVOKESPECIAL(constrIndex)); il.append(new ALOAD(6));
il.append(new ASTORE(6)); il.append(new ALOAD(6)); il.append(new LLOAD(4)); il.append(new INVOKESPECIAL(constrIndex)); il.append(new ALOAD(6));