public void cast(final Type from,final Type to){
  if (from != to) {
    if (from == Type.DOUBLE_TYPE) {
      if (to == Type.FLOAT_TYPE) {
        mv.visitInsn(Opcodes.D2F);
      }
 else       if (to == Type.LONG_TYPE) {
        mv.visitInsn(Opcodes.D2L);
      }
 else {
        mv.visitInsn(Opcodes.D2I);
        cast(Type.INT_TYPE,to);
      }
    }
 else     if (from == Type.FLOAT_TYPE) {
      if (to == Type.DOUBLE_TYPE) {
        mv.visitInsn(Opcodes.F2D);
      }
 else       if (to == Type.LONG_TYPE) {
        mv.visitInsn(Opcodes.F2L);
      }
 else {
        mv.visitInsn(Opcodes.F2I);
        cast(Type.INT_TYPE,to);
      }
    }
 else     if (from == Type.LONG_TYPE) {
      if (to == Type.DOUBLE_TYPE) {
        mv.visitInsn(Opcodes.L2D);
      }
 else       if (to == Type.FLOAT_TYPE) {
        mv.visitInsn(Opcodes.L2F);
      }
 else {
        mv.visitInsn(Opcodes.L2I);
        cast(Type.INT_TYPE,to);
      }
    }
 else {
      if (to == Type.BYTE_TYPE) {
        mv.visitInsn(Opcodes.I2B);
      }
 else       if (to == Type.CHAR_TYPE) {
        mv.visitInsn(Opcodes.I2C);
      }
 else       if (to == Type.DOUBLE_TYPE) {
        mv.visitInsn(Opcodes.I2D);
      }
 else       if (to == Type.FLOAT_TYPE) {
        mv.visitInsn(Opcodes.I2F);
      }
 else       if (to == Type.LONG_TYPE) {
        mv.visitInsn(Opcodes.I2L);
      }
 else       if (to == Type.SHORT_TYPE) {
        mv.visitInsn(Opcodes.I2S);
      }
    }
  }
}

public void cast ( final Type from , final Type to ) { if ( from != to ) { if ( from == Type . DOUBLE_TYPE ) { if ( to == Type . FLOAT_TYPE ) { mv . visitInsn ( Opcodes . D2F ) ; } else if ( to == Type . LONG_TYPE ) { mv . visitInsn ( Opcodes . D2L ) ; } else { mv . visitInsn ( Opcodes . D2I ) ; cast ( Type . INT_TYPE , to ) ; } } else if ( from == Type . FLOAT_TYPE ) { if ( to == Type . DOUBLE_TYPE ) { mv . visitInsn ( Opcodes . F2D ) ; } else if ( to == Type . LONG_TYPE ) { mv . visitInsn ( Opcodes . F2L ) ; } else { mv . visitInsn ( Opcodes . F2I ) ; cast ( Type . INT_TYPE , to ) ; } } else if ( from == Type . LONG_TYPE ) { if ( to == Type . DOUBLE_TYPE ) { mv . visitInsn ( Opcodes . L2D ) ; } else if ( to == Type . FLOAT_TYPE ) { mv . visitInsn ( Opcodes . L2F ) ; } else { mv . visitInsn ( Opcodes . L2I ) ; cast ( Type . INT_TYPE , to ) ; } } else { if ( to == Type . BYTE_TYPE ) { mv . visitInsn ( Opcodes . I2B ) ; } else if ( to == Type . CHAR_TYPE ) { mv . visitInsn ( Opcodes . I2C ) ; } else if ( to == Type . DOUBLE_TYPE ) { mv . visitInsn ( Opcodes . I2D ) ; } else if ( to == Type . FLOAT_TYPE ) { mv . visitInsn ( Opcodes . I2F ) ; } else if ( to == Type . LONG_TYPE ) { mv . visitInsn ( Opcodes . I2L ) ; } else if ( to == Type . SHORT_TYPE ) { mv . visitInsn ( Opcodes . I2S ) ; } } } }
generates the instructions to cast a numerical value from one type to another .
