package sophomore.classfile;

import sophomore.classfile.constantpool.ConstantInfo;

/**
 * 
 * @author inagaki
 */
public class ConstantPool {
	/**
	 * 
	 */
	private ConstantInfo[] pool;
	/**
	 * 
	 */
	private int currentIndex;

	/**
	 * 
	 * @param size 
	 */
	public ConstantPool(int size) {
		this.pool = new ConstantInfo[size];
	}

	/**
	 * 
	 * @param element 
	 */
	public void add(ConstantInfo element) {
		if(currentIndex == pool.length) {
			throw new ArrayIndexOutOfBoundsException();
		}
		pool[currentIndex++] = element;
	}

	/**
	 * 
	 * @return 
	 */
	public ConstantInfo[] getPool() {
		return pool;
	}
}
@@ -185,50 +185,8 @@
 ool;
-%0A%09/**%0A%09 * %0A%09 */%0A%09private int currentIndex;
 %0A%0A%09/
@@ -292,32 +292,49 @@
 ;%0A%09%7D%0A%0A%09/**%0A%09 * %0A
+%09 * @param index%0A
 %09 * @param eleme
@@ -359,16 +359,27 @@
 oid add(
+int index, 
 Constant
@@ -403,22 +403,15 @@
 %09if(
-currentI
+i
 ndex 
-=
+%3E
 = po
@@ -485,22 +485,13 @@
 ool%5B
-currentI
+i
 ndex
-++
 %5D = 
@@ -566,16 +566,16 @@
 ool() %7B%0A
-
 %09%09return
@@ -583,10 +583,340 @@
 pool;%0A%09%7D
+%0A%0A%09@Override%0A%09public String toString() %7B%0A%09%09StringBuilder sb = new StringBuilder();%0A%09%09String sep = System.getProperty(%22line.separator%22);%0A%09%09sb.append(%22*** Constant Pool ***%22).append(sep);%0A%09%09for(int i = 0; i %3C pool.length; i++) %7B%0A%09%09%09sb.append(%22%5B%22).append(i+1).append(%22%5D: %22).append(pool%5Bi%5D).append(sep);%0A%09%09%7D%0A%09%09return sb.toString();%0A%09%7D
 %0A%7D

implement 'toString' method for debugging.