Example #1
0
  /**
   * Fetches return value or thrown exception. If return value is of basic type, it is automatically
   * boxed.
   *
   * @param mv output method visitor
   * @param type return data type
   * @return number of JVM stack slots emitted code consumes
   */
  public int emitFetchRetVal(SpyMethodVisitor mv, Type type) {

    if (Type.VOID == type.getSort()) {
      mv.visitInsn(ACONST_NULL);
      return 1;
    }

    mv.visitInsn(DUP);
    emitAutoboxing(mv, type);
    mv.visitVarInsn(ASTORE, mv.getRetValProbeSlot());

    return type.getSize();
  }