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

SIPUSH.java

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

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