1 17 package org.apache.bcel.generic; 18 19 import org.apache.bcel.Constants; 20 21 27 public abstract class ConversionInstruction extends Instruction implements TypedInstruction, 28 StackProducer, StackConsumer { 29 30 34 ConversionInstruction() { 35 } 36 37 38 41 protected ConversionInstruction(short opcode) { 42 super(opcode, (short) 1); 43 } 44 45 46 48 public Type getType( ConstantPoolGen cp ) { 49 switch (opcode) { 50 case Constants.D2I: 51 case Constants.F2I: 52 case Constants.L2I: 53 return Type.INT; 54 case Constants.D2F: 55 case Constants.I2F: 56 case Constants.L2F: 57 return Type.FLOAT; 58 case Constants.D2L: 59 case Constants.F2L: 60 case Constants.I2L: 61 return Type.LONG; 62 case Constants.F2D: 63 case Constants.I2D: 64 case Constants.L2D: 65 return Type.DOUBLE; 66 case Constants.I2B: 67 return Type.BYTE; 68 case Constants.I2C: 69 return Type.CHAR; 70 case Constants.I2S: 71 return Type.SHORT; 72 default: throw new ClassGenException("Unknown type " + opcode); 74 } 75 } 76 } 77 | Popular Tags |