00001 package de.fub.bytecode.generic;
00002
00003 import java.io.*;
00004 import de.fub.bytecode.util.ByteSequence;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 public class NEWARRAY extends Instruction
00015 implements AllocationInstruction, ExceptionThrower, StackProducer {
00016 private byte type;
00017
00018
00019
00020
00021
00022 NEWARRAY() {}
00023 public NEWARRAY(byte type) {
00024 super(de.fub.bytecode.Constants.NEWARRAY, (short)2);
00025 this.type = type;
00026 }
00027 public NEWARRAY(BasicType type) {
00028 this(type.getType());
00029 }
00030
00031
00032
00033
00034
00035
00036
00037
00038 public void accept(Visitor v) {
00039 v.visitAllocationInstruction(this);
00040 v.visitExceptionThrower(this);
00041 v.visitStackProducer(this);
00042 v.visitNEWARRAY(this);
00043 }
00044
00045
00046
00047
00048 public void dump(DataOutputStream out) throws IOException {
00049 out.writeByte(tag);
00050 out.writeByte(type);
00051 }
00052 public Class[] getExceptions() {
00053 return new Class[] { de.fub.bytecode.ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION };
00054 }
00055
00056
00057
00058 public final Type getType() {
00059 return new ArrayType(BasicType.getType(type), 1);
00060 }
00061
00062
00063
00064 public final byte getTypecode() { return type; }
00065
00066
00067
00068 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
00069 {
00070 type = bytes.readByte();
00071 length = 2;
00072 }
00073
00074
00075
00076 public String toString(boolean verbose) {
00077 return super.toString(verbose) + " " + de.fub.bytecode.Constants.TYPE_NAMES[type];
00078 }
00079 }