Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

ArithmeticInstruction.java

00001 package de.fub.bytecode.generic;
00002 
00003 import de.fub.bytecode.Constants;
00004 /**
00005  * Super class for the family of arithmetic instructions.
00006  *
00007  * @version $Id: ArithmeticInstruction.java,v 1.1.1.1 2002/01/24 03:41:38 pserver Exp $
00008  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00009  */
00010 public abstract class ArithmeticInstruction extends Instruction
00011   implements TypedInstruction, StackProducer, StackConsumer {
00012   /**
00013    * Empty constructor needed for the Class.newInstance() statement in
00014    * Instruction.readInstruction(). Not to be used otherwise.
00015    */
00016   ArithmeticInstruction() {}  
00017   /**
00018    * @param tag opcode of instruction
00019    */
00020   protected ArithmeticInstruction(short tag) {
00021     super(tag, (short)1);
00022   }  
00023   /** @return type associated with the instruction
00024    */
00025   public Type getType(ConstantPoolGen cp) {
00026     switch(tag) {
00027     case Constants.DADD: case Constants.DDIV: case Constants.DMUL:
00028     case Constants.DNEG: case Constants.DREM: case Constants.DSUB:
00029       return Type.DOUBLE;
00030 
00031     case Constants.FADD: case Constants.FDIV: case Constants.FMUL:
00032     case Constants.FNEG: case Constants.FREM: case Constants.FSUB:
00033       return Type.FLOAT;
00034 
00035     case Constants.IADD: case Constants.IAND: case Constants.IDIV:
00036     case Constants.IMUL: case Constants.INEG: case Constants.IOR: case Constants.IREM:
00037     case Constants.ISHL: case Constants.ISHR: case Constants.ISUB:
00038     case Constants.IUSHR: case Constants.IXOR:
00039       return Type.INT;
00040 
00041     case Constants.LADD: case Constants.LAND: case Constants.LDIV:
00042     case Constants.LMUL: case Constants.LNEG: case Constants.LOR: case Constants.LREM:
00043     case Constants.LSHL: case Constants.LSHR: case Constants.LSUB:
00044     case Constants.LUSHR: case Constants.LXOR:
00045       return Type.LONG;
00046 
00047     default: // Never reached
00048       throw new ClassGenException("Unknown type " + tag);
00049     }
00050   }  
00051 }

Generated at Thu Feb 7 06:39:25 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001