/** * Generates the instruction to push a local variable on the stack. * * @param type * the type of the local variable to be loaded. * @param index * an index in the frame's local variables array. */ private void loadInsn(final Type type, final int index) { mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), index); }
/** * Generates the instruction to store the top stack value in a local * variable. * * @param type * the type of the local variable to be stored. * @param index * an index in the frame's local variables array. */ private void storeInsn(final Type type, final int index) { mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), index); }
/** * Generates the instruction to load an element from an array. * * @param type * the type of the array element to be loaded. */ public void arrayLoad(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IALOAD)); }
/** * Generates the instruction to return the top stack value to the caller. */ public void returnValue() { mv.visitInsn(returnType.getOpcode(Opcodes.IRETURN)); }
/** * Generates the instruction to do the specified mathematical or logical * operation. * * @param op * a mathematical or logical operation. Must be one of ADD, SUB, * MUL, DIV, REM, NEG, SHL, SHR, USHR, AND, OR, XOR. * @param type * the type of the operand(s) for this operation. */ public void math(final int op, final Type type) { mv.visitInsn(type.getOpcode(op)); }
/** * Generates the instruction to store an element in an array. * * @param type * the type of the array element to be stored. */ public void arrayStore(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IASTORE)); }
public void aload(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IALOAD)); }
public void add(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IADD)); }
public void shr(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.ISHR)); }
public void and(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IAND)); }
protected final void load(int registry) { mv.visitVarInsn(storedTypes.get(registry).getOpcode(ILOAD), registry); }
public void neg(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.INEG)); }
public void ushr(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IUSHR)); }
public void areturn(final Type t) { mv.visitInsn(t.getOpcode(Opcodes.IRETURN)); }
protected final int getCodeForType(Class<?> typeClass, int opcode) { return Type.getType(typeClass).getOpcode(opcode); }
public void load(final int var, final Type type) { mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), var); }
protected final int store(int registry, Type t) { if (storedTypes == null) storedTypes = new HashMap<Integer, Type>(); mv.visitVarInsn(t.getOpcode(ISTORE), registry); storedTypes.put(registry, t); return t.getSize(); }
protected final void loadAsObject(int registry) { Type type = storedTypes.get(registry); mv.visitVarInsn(type.getOpcode(ILOAD), registry); String typeName = type.getClassName(); convertPrimitiveToObject(typeName); }
protected final void printLastRegistry(Class<?> clazz) { Type t = Type.getType(clazz); mv.visitVarInsn(t.getOpcode(ISTORE), 100); mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); mv.visitVarInsn(t.getOpcode(ILOAD), 100); invokeVirtual(PrintStream.class, "print", null, clazz); }
protected final void printRegistryValue(int reg, Class<?> clazz) { mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;"); mv.visitVarInsn(Type.getType(clazz).getOpcode(ILOAD), reg); invokeVirtual(PrintStream.class, "print", null, clazz); }