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

FCONST.java

00001 package de.fub.bytecode.generic;
00002 
00003 /** 
00004  * FCONST - Push 0.0, 1.0 or 2.0, other values cause an exception
00005  *
00006  * <PRE>Stack: ... -&gt; ..., <i></PRE>
00007  *
00008  * @version $Id: FCONST.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 FCONST extends Instruction
00012   implements ConstantPushInstruction, TypedInstruction {
00013   private float value;
00014 
00015   /**
00016    * Empty constructor needed for the Class.newInstance() statement in
00017    * Instruction.readInstruction(). Not to be used otherwise.
00018    */
00019   FCONST() {}  
00020   public FCONST(float f) {
00021     super(de.fub.bytecode.Constants.FCONST_0, (short)1);
00022 
00023     if(f == 0.0)
00024       tag = de.fub.bytecode.Constants.FCONST_0;
00025     else if(f == 1.0)
00026       tag = de.fub.bytecode.Constants.FCONST_1;
00027     else if(f == 2.0)
00028       tag = de.fub.bytecode.Constants.FCONST_2;
00029     else
00030       throw new ClassGenException("FCONST can be used only for 0.0, 1.0 and 2.0: " + f);
00031 
00032     value = f;
00033   }  
00034   /**
00035    * Call corresponding visitor method(s). The order is:
00036    * Call visitor methods of implemented interfaces first, then
00037    * call methods according to the class hierarchy in descending order,
00038    * i.e., the most specific visitXXX() call comes last.
00039    *
00040    * @param v Visitor object
00041    */
00042   public void accept(Visitor v) {
00043     v.visitPushInstruction(this);
00044     v.visitStackProducer(this);
00045     v.visitTypedInstruction(this);
00046     v.visitConstantPushInstruction(this);
00047     v.visitFCONST(this);
00048   }  
00049   /** @return Type.FLOAT
00050    */
00051   public Type getType(ConstantPoolGen cp) {
00052     return Type.FLOAT;
00053   }  
00054   public Number getValue() { return new Float(value); }  
00055 }

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