Ejemplo n.º 1
0
 public static void storeValue(MethodVisitor mv, int offset, int type) {
   switch (type) {
     case 'V':
       break;
     case 'B':
       AsmUtil.byteValue(mv);
       mv.visitVarInsn(ISTORE, offset);
       break;
     case 'C':
       AsmUtil.charValue(mv);
       mv.visitVarInsn(ISTORE, offset);
       break;
     case 'S':
       AsmUtil.shortValue(mv);
       mv.visitVarInsn(ISTORE, offset);
       break;
     case 'I':
       AsmUtil.intValue(mv);
       mv.visitVarInsn(ISTORE, offset);
       break;
     case 'Z':
       AsmUtil.booleanValue(mv);
       mv.visitVarInsn(ISTORE, offset);
       break;
     case 'J':
       AsmUtil.longValue(mv);
       mv.visitVarInsn(LSTORE, offset);
       break;
     case 'F':
       AsmUtil.floatValue(mv);
       mv.visitVarInsn(FSTORE, offset);
       break;
     case 'D':
       AsmUtil.doubleValue(mv);
       mv.visitVarInsn(DSTORE, offset);
       break;
     default:
       mv.visitVarInsn(ASTORE, offset);
   }
 }
Ejemplo n.º 2
0
  /** Visits return opcodes. */
  public static void visitReturn(MethodVisitor mv, MethodSignatureVisitor msign, boolean isLast) {
    switch (msign.getReturnOpcodeType()) {
      case 'V':
        if (isLast == true) {
          mv.visitInsn(POP);
        }
        mv.visitInsn(RETURN);
        break;

      case 'B':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(ICONST_0);
          mv.visitInsn(IRETURN);
          mv.visitLabel(label);

          AsmUtil.byteValue(mv);
        }
        mv.visitInsn(IRETURN);
        break;

      case 'C':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(ICONST_0);
          mv.visitInsn(IRETURN);
          mv.visitLabel(label);

          AsmUtil.charValue(mv);
        }
        mv.visitInsn(IRETURN);
        break;

      case 'S':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(ICONST_0);
          mv.visitInsn(IRETURN);
          mv.visitLabel(label);

          AsmUtil.shortValue(mv);
        }
        mv.visitInsn(IRETURN);
        break;

      case 'I':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(ICONST_0);
          mv.visitInsn(IRETURN);
          mv.visitLabel(label);

          AsmUtil.intValue(mv);
        }
        mv.visitInsn(IRETURN);
        break;

      case 'Z':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(ICONST_0);
          mv.visitInsn(IRETURN);
          mv.visitLabel(label);

          AsmUtil.booleanValue(mv);
        }
        mv.visitInsn(IRETURN);
        break;

      case 'J':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(LCONST_0);
          mv.visitInsn(LRETURN);
          mv.visitLabel(label);

          AsmUtil.longValue(mv);
        }
        mv.visitInsn(LRETURN);
        break;

      case 'F':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(FCONST_0);
          mv.visitInsn(FRETURN);
          mv.visitLabel(label);

          AsmUtil.floatValue(mv);
        }
        mv.visitInsn(FRETURN);
        break;

      case 'D':
        if (isLast == true) {
          mv.visitInsn(DUP);
          Label label = new Label();
          mv.visitJumpInsn(IFNONNULL, label);
          mv.visitInsn(POP);
          mv.visitInsn(DCONST_0);
          mv.visitInsn(DRETURN);
          mv.visitLabel(label);

          AsmUtil.doubleValue(mv);
        }
        mv.visitInsn(DRETURN);
        break;

      default:
        mv.visitInsn(ARETURN);
        break;
    }
  }