1 package com.sun.org.apache.bcel.internal.generic; 2 3 56 import java.io.*; 57 import com.sun.org.apache.bcel.internal.util.ByteSequence; 58 59 67 public class NEWARRAY extends Instruction 68 implements AllocationInstruction, ExceptionThrower, StackProducer { 69 private byte type; 70 71 75 NEWARRAY() {} 76 77 public NEWARRAY(byte type) { 78 super(com.sun.org.apache.bcel.internal.Constants.NEWARRAY, (short)2); 79 this.type = type; 80 } 81 82 public NEWARRAY(BasicType type) { 83 this(type.getType()); 84 } 85 86 90 public void dump(DataOutputStream out) throws IOException { 91 out.writeByte(opcode); 92 out.writeByte(type); 93 } 94 95 98 public final byte getTypecode() { return type; } 99 100 103 public final Type getType() { 104 return new ArrayType(BasicType.getType(type), 1); 105 } 106 107 110 public String toString(boolean verbose) { 111 return super.toString(verbose) + " " + com.sun.org.apache.bcel.internal.Constants.TYPE_NAMES[type]; 112 } 113 116 protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException 117 { 118 type = bytes.readByte(); 119 length = 2; 120 } 121 122 public Class [] getExceptions() { 123 return new Class [] { com.sun.org.apache.bcel.internal.ExceptionConstants.NEGATIVE_ARRAY_SIZE_EXCEPTION }; 124 } 125 126 127 135 public void accept(Visitor v) { 136 v.visitAllocationInstruction(this); 137 v.visitExceptionThrower(this); 138 v.visitStackProducer(this); 139 v.visitNEWARRAY(this); 140 } 141 } 142 | Popular Tags |