package sds.classfile.bytecode;

import java.io.IOException;
import sds.classfile.ClassFileStream;

/**
 * This class is for
 * <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html#jvms-6.5.newarray">
 * newarray
 * </a>.
 * @author inagaki
 */
public class NewArray extends OpcodeInfo {
	private String atype;

	/**
	 * constructor.
	 * @param pc index into the code array
	 */
	public NewArray(int pc) {
		super(MnemonicTable.newarray, pc);
	}

	@Override
	public void read(ClassFileStream data) throws IOException {
		int type = data.readUnsignedByte();
		switch(type) {
			case 4:  this.atype = "T_BOOLEAN"; break;
			case 5:  this.atype = "T_CHAR";    break;
			case 6:  this.atype = "T_FLOAT";   break;
			case 7:  this.atype = "T_DOUBLE";  break;
			case 8:  this.atype = "T_BYTE";    break;
			case 9:  this.atype = "T_SHORT";   break;
			case 10: this.atype = "T_INT";     break;
			case 11: this.atype = "T_LONG";    break;
			default:
				System.out.println("[unknown type]: " + type);
				break;
		}
	}

	/**
	 * returns array type.
	 * @return array type
	 */
	public String getType() {
		return atype;
	}

	@Override
	public String toString() {
		return super.toString() + ": " + atype;
	}
}
@@ -616,17 +616,15 @@
  = %22
-T_BOOLEAN
+boolean
 %22; b
@@ -659,14 +659,12 @@
  = %22
-T_CHAR
+char
 %22;  
@@ -702,15 +702,13 @@
  = %22
-T_FLOAT
+float
 %22;  
@@ -745,16 +745,14 @@
  = %22
-T_DOUBLE
+double
 %22;  
@@ -788,14 +788,12 @@
  = %22
-T_BYTE
+byte
 %22;  
@@ -831,15 +831,13 @@
  = %22
-T_SHORT
+short
 %22;  
@@ -874,13 +874,11 @@
  = %22
-T_INT
+int
 %22;  
@@ -917,14 +917,12 @@
  = %22
-T_LONG
+long
 %22;  

change stored string of array type.