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

BIPUSH.java

00001 package de.fub.bytecode.generic;
00002 
00003 import java.io.*;
00004 import de.fub.bytecode.util.ByteSequence;
00005 
00006 /** 
00007  * BIPUSH - Push byte on stack
00008  *
00009  * <PRE>Stack: ... -&gt; ..., value</PRE>
00010  *
00011  * @version $Id: BIPUSH.java,v 1.1.1.1 2002/01/24 03:41:38 pserver Exp $
00012  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00013  */
00014 public class BIPUSH extends Instruction implements ConstantPushInstruction {
00015   private byte b;
00016 
00017   /**
00018    * Empty constructor needed for the Class.newInstance() statement in
00019    * Instruction.readInstruction(). Not to be used otherwise.
00020    */
00021   BIPUSH() {}  
00022   /** Push byte on stack
00023    */
00024   public BIPUSH(byte b) {
00025     super(de.fub.bytecode.Constants.BIPUSH, (short)2);
00026     this.b = b;
00027   }  
00028   /**
00029    * Call corresponding visitor method(s). The order is:
00030    * Call visitor methods of implemented interfaces first, then
00031    * call methods according to the class hierarchy in descending order,
00032    * i.e., the most specific visitXXX() call comes last.
00033    *
00034    * @param v Visitor object
00035    */
00036   public void accept(Visitor v) {
00037     v.visitPushInstruction(this);
00038     v.visitStackProducer(this);
00039     v.visitTypedInstruction(this);
00040     v.visitConstantPushInstruction(this);
00041     v.visitBIPUSH(this);
00042   }  
00043   /**
00044    * Dump instruction as byte code to stream out.
00045    */
00046   public void dump(DataOutputStream out) throws IOException {
00047     super.dump(out);
00048     out.writeByte(b);
00049   }  
00050   /** @return Type.BYTE
00051    */
00052   public Type getType(ConstantPoolGen cp) {
00053     return Type.BYTE;
00054   }  
00055   public Number getValue() { return new Integer(b); }  
00056   /**
00057    * Read needed data (e.g. index) from file.
00058    */
00059   protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00060   {
00061     length = 2;
00062     b      = bytes.readByte();
00063   }  
00064   /**
00065    * @return mnemonic for instruction
00066    */
00067   public String toString(boolean verbose) {
00068     return super.toString(verbose) + " " + b;
00069   }  
00070 }

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