FileDocCategorySizeDatePackage
ArithmeticInstruction.javaAPI DocJava SE 6 API4553Tue Jun 10 00:22:18 BST 2008com.sun.org.apache.bcel.internal.generic

ArithmeticInstruction

public abstract class ArithmeticInstruction extends Instruction implements StackProducer, TypedInstruction, StackConsumer
Super class for the family of arithmetic instructions.
version
$Id: ArithmeticInstruction.java,v 1.1.2.1 2005/07/31 23:45:04 jeffsuttor Exp $
author
M. Dahm

Fields Summary
Constructors Summary
ArithmeticInstruction()
Empty constructor needed for the Class.newInstance() statement in Instruction.readInstruction(). Not to be used otherwise.

protected ArithmeticInstruction(short opcode)

param
opcode of instruction

    super(opcode, (short)1);
  
Methods Summary
public com.sun.org.apache.bcel.internal.generic.TypegetType(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cp)

return
type associated with the instruction

    switch(opcode) {
    case Constants.DADD: case Constants.DDIV: case Constants.DMUL:
    case Constants.DNEG: case Constants.DREM: case Constants.DSUB:
      return Type.DOUBLE;

    case Constants.FADD: case Constants.FDIV: case Constants.FMUL:
    case Constants.FNEG: case Constants.FREM: case Constants.FSUB:
      return Type.FLOAT;

    case Constants.IADD: case Constants.IAND: case Constants.IDIV:
    case Constants.IMUL: case Constants.INEG: case Constants.IOR: case Constants.IREM:
    case Constants.ISHL: case Constants.ISHR: case Constants.ISUB:
    case Constants.IUSHR: case Constants.IXOR:
      return Type.INT;

    case Constants.LADD: case Constants.LAND: case Constants.LDIV:
    case Constants.LMUL: case Constants.LNEG: case Constants.LOR: case Constants.LREM:
    case Constants.LSHL: case Constants.LSHR: case Constants.LSUB:
    case Constants.LUSHR: case Constants.LXOR:
      return Type.LONG;

    default: // Never reached
      throw new ClassGenException("Unknown type " + opcode);
    }