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

DCONST.java

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

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