1 17 package org.apache.bcel.generic; 18 19 import org.apache.bcel.Constants; 20 21 27 public abstract class ArithmeticInstruction extends Instruction implements TypedInstruction, 28 StackProducer, StackConsumer { 29 30 34 ArithmeticInstruction() { 35 } 36 37 38 41 protected ArithmeticInstruction(short opcode) { 42 super(opcode, (short) 1); 43 } 44 45 46 48 public Type getType( ConstantPoolGen cp ) { 49 switch (opcode) { 50 case Constants.DADD: 51 case Constants.DDIV: 52 case Constants.DMUL: 53 case Constants.DNEG: 54 case Constants.DREM: 55 case Constants.DSUB: 56 return Type.DOUBLE; 57 case Constants.FADD: 58 case Constants.FDIV: 59 case Constants.FMUL: 60 case Constants.FNEG: 61 case Constants.FREM: 62 case Constants.FSUB: 63 return Type.FLOAT; 64 case Constants.IADD: 65 case Constants.IAND: 66 case Constants.IDIV: 67 case Constants.IMUL: 68 case Constants.INEG: 69 case Constants.IOR: 70 case Constants.IREM: 71 case Constants.ISHL: 72 case Constants.ISHR: 73 case Constants.ISUB: 74 case Constants.IUSHR: 75 case Constants.IXOR: 76 return Type.INT; 77 case Constants.LADD: 78 case Constants.LAND: 79 case Constants.LDIV: 80 case Constants.LMUL: 81 case Constants.LNEG: 82 case Constants.LOR: 83 case Constants.LREM: 84 case Constants.LSHL: 85 case Constants.LSHR: 86 case Constants.LSUB: 87 case Constants.LUSHR: 88 case Constants.LXOR: 89 return Type.LONG; 90 default: throw new ClassGenException("Unknown type " + opcode); 92 } 93 } 94 } 95 | Popular Tags |