package sds.decompile;

import java.util.NoSuchElementException;

/**
 * This adapter class is for
 * {@link LocalStack <code>LocalStack</code>}
 * and
 * {@link OperandStack <code>OperandStack</code>}.
 */
public abstract class SimpleStack {
	String[] stack;
	int current;

	/**
	 * constructor.
	 * @param size max size of stack
	 */
	public SimpleStack(int size) {
		this.stack = new String[size];
		this.current = 0;
	}

	/**
	 * push element to stack.
	 * @param element
	 */
	public void push(String element) {
		if(element == null) {
			throw new IllegalArgumentException("argument is null.");
		}
		if(current >= stack.length) {
			throw new ArrayIndexOutOfBoundsException("stack size is over specified size (" + stack.length + ") .");
		}
		stack[current] = element;
		current++;
	}

	/**
	 * returns top element of stack.
	 * @return top element
	 */
	public String pop() {
		if(current > 0) {
			current--;
		}
		String element = stack[current];
		if(element == null) {
			throw new NoSuchElementException("stack is empty.");
		}
		stack[current - 1] = null;
		return element;
	}
}
@@ -414,24 +414,156 @@
 nt = 0;%0A%09%7D%0A%0A
+%09/**%0A%09 * returns this stack's current size.%0A%09 * @return current size%0A%09 */%0A%09public int getCurrentStackSize() %7B%0A%09%09return current;%0A%09%7D%0A%0A
 %09/**%0A%09 * pus

add method for getting current stack size.