/** * 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); } }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ public void visitLLOAD(LLOAD o){ int idx = o.getIndex(); if (idx < 0){ constraintViolated(o, "Index '"+idx+"' must be non-negative. [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); } else{ int maxminus2 = max_locals()-2; if (idx > maxminus2){ constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'."); } } }
/** Checks if the constraints of operands of the said instruction(s) are satisfied. */ @Override public void visitLLOAD(final LLOAD o) { final int idx = o.getIndex(); if (idx < 0) { constraintViolated(o, "Index '"+idx+"' must be non-negative."+ " [Constraint by JustIce as an analogon to the single-slot xLOAD/xSTORE instructions; may not happen anyway.]"); } else{ final int maxminus2 = max_locals()-2; if (idx > maxminus2) { constraintViolated(o, "Index '"+idx+"' must not be greater than max_locals-2 '"+maxminus2+"'."); } } }
@SuppressWarnings("unused") // Called using reflection private Instruction createInstructionLload(Element inst) throws IllegalXMLVMException { int idx= Integer.parseInt(inst.getAttributeValue("index")); return new LLOAD(idx); }
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ public void visitLLOAD(LLOAD o){ stack().push(locals().get(o.getIndex())); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */
/** * @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); } }
/** Symbolically executes the corresponding Java Virtual Machine instruction. */ @Override public void visitLLOAD(final LLOAD o) { stack().push(locals().get(o.getIndex())); } /** Symbolically executes the corresponding Java Virtual Machine instruction. */
/** * @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));