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

ICONST.java

00001 package de.fub.bytecode.generic;
00002 
00003 /** 
00004  * ICONST - Push value between -1, ..., 5, other values cause an exception
00005  *
00006  * <PRE>Stack: ... -&gt; ..., <i></PRE>
00007  *
00008  * @version $Id: ICONST.java,v 1.1.1.1 2002/01/24 03:41:39 pserver Exp $
00009  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00010  */
00011 public class ICONST extends Instruction
00012   implements ConstantPushInstruction, TypedInstruction {
00013   private int value;
00014 
00015   /**
00016    * Empty constructor needed for the Class.newInstance() statement in
00017    * Instruction.readInstruction(). Not to be used otherwise.
00018    */
00019   ICONST() {}  
00020   public ICONST(int i) {
00021     super(de.fub.bytecode.Constants.ICONST_0, (short)1);
00022 
00023     if((i >= -1) && (i <= 5))
00024       tag    = (short)(de.fub.bytecode.Constants.ICONST_0 + i); // Even works for i == -1
00025     else
00026       throw new ClassGenException("ICONST can be used only for value between -1 and 5: " +
00027                   i);
00028     value = i;
00029   }  
00030   /**
00031    * Call corresponding visitor method(s). The order is:
00032    * Call visitor methods of implemented interfaces first, then
00033    * call methods according to the class hierarchy in descending order,
00034    * i.e., the most specific visitXXX() call comes last.
00035    *
00036    * @param v Visitor object
00037    */
00038   public void accept(Visitor v) {
00039     v.visitPushInstruction(this);
00040     v.visitStackProducer(this);
00041     v.visitTypedInstruction(this);
00042     v.visitConstantPushInstruction(this);
00043     v.visitICONST(this);
00044   }  
00045   /** @return Type.INT
00046    */
00047   public Type getType(ConstantPoolGen cp) {
00048     return Type.INT;
00049   }  
00050   public Number getValue() { return new Integer(value); }  
00051 }

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