1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import com.sun.org.apache.bcel.internal.Constants; 57 63 public abstract class ArithmeticInstruction extends Instruction 64 implements TypedInstruction, StackProducer, StackConsumer { 65 69 ArithmeticInstruction() {} 70 71 74 protected ArithmeticInstruction(short opcode) { 75 super(opcode, (short)1); 76 } 77 78 80 public Type getType(ConstantPoolGen cp) { 81 switch(opcode) { 82 case Constants.DADD: case Constants.DDIV: case Constants.DMUL: 83 case Constants.DNEG: case Constants.DREM: case Constants.DSUB: 84 return Type.DOUBLE; 85 86 case Constants.FADD: case Constants.FDIV: case Constants.FMUL: 87 case Constants.FNEG: case Constants.FREM: case Constants.FSUB: 88 return Type.FLOAT; 89 90 case Constants.IADD: case Constants.IAND: case Constants.IDIV: 91 case Constants.IMUL: case Constants.INEG: case Constants.IOR: case Constants.IREM: 92 case Constants.ISHL: case Constants.ISHR: case Constants.ISUB: 93 case Constants.IUSHR: case Constants.IXOR: 94 return Type.INT; 95 96 case Constants.LADD: case Constants.LAND: case Constants.LDIV: 97 case Constants.LMUL: case Constants.LNEG: case Constants.LOR: case Constants.LREM: 98 case Constants.LSHL: case Constants.LSHR: case Constants.LSUB: 99 case Constants.LUSHR: case Constants.LXOR: 100 return Type.LONG; 101 102 default: throw new ClassGenException("Unknown type " + opcode); 104 } 105 } 106 } 107 | Popular Tags |