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

NEWARRAY.java

00001 package de.fub.bytecode.generic;
00002 
00003 import java.io.*;
00004 import de.fub.bytecode.util.ByteSequence;
00005 
00006 /** 
00007  * NEWARRAY -  Create new array of basic type (int, short, ...)
00008  * <PRE>Stack: ..., count -&gt; ..., arrayref</PRE>
00009  * type mus be one of T_INT, T_SHORT, ...
00010  * 
00011  * @version $Id: NEWARRAY.java,v 1.1.1.1 2002/01/24 03:44:02 pserver Exp $
00012  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00013  */
00014 public class NEWARRAY extends Instruction implements AllocationInstruction, ExceptionThrower{
00015   private byte type;
00016 
00017   /**
00018    * Empty constructor needed for the Class.newInstance() statement in
00019    * Instruction.readInstruction(). Not to be used otherwise.
00020    */
00021   NEWARRAY() {}  
00022   public NEWARRAY(byte type) {
00023     super(NEWARRAY, (short)2);
00024     this.type = type;
00025   }  
00026   /**
00027    * Dump instruction as byte code to stream out.
00028    * @param out Output stream
00029    */
00030   public void dump(DataOutputStream out) throws IOException {
00031     out.writeByte(tag);
00032     out.writeByte(type);
00033   }  
00034   public Class[] getExceptions() { return new Class[] { NEGATIVE_ARRAY_SIZE_EXCEPTION }; }  
00035   /**
00036    * @return type of constructed array
00037    */
00038   public final Type getType() {
00039     return new ArrayType(BasicType.getType(type), 1);
00040   }  
00041   /**
00042    * @return numeric code for basic element type
00043    */
00044   public final byte getTypecode() { return type; }  
00045   /**
00046    * Read needed data (e.g. index) from file.
00047    */
00048   protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00049   {
00050     type   = bytes.readByte();
00051     length = 2;
00052   }  
00053   /**
00054    * @return mnemonic for instruction
00055    */
00056   public String toString(boolean verbose) {
00057     return super.toString(verbose) + " " + TYPE_NAMES[type];
00058   }  
00059 }

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