package sds.decompile;

import java.util.Stack;

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

	/**
	 * constructor.
	 */
	public SimpleStack() {
		this.stack = new Stack<>();
		this.current = 0;
	}

	/**
	 * returns this stack's current size.
	 * @return current size
	 */
	public int getCurrentStackSize() {
		return current;
	}

	/**
	 * push element to stack.
	 * @param element
	 */
	public void push(String element) {
		if(element == null) {
			throw new IllegalArgumentException("argument is null.");
		}
		stack.push(element);
		current++;
	}

	/**
	 * returns top element of stack.
	 * @return top element
	 */
	public String pop() {
		if(stack.empty()) {
			throw new IllegalStateException("stack is empty.");
		}
		String element = stack.pop();
		current--;
		return element;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(stack);
		return sb.toString();
	}
}
@@ -709,24 +709,285 @@
 rent++;%0A%09%7D%0A%0A
+%09/**%0A%09 * push element to stack in specified index.%0A%09 * @param index%0A%09 * @param element %0A%09 */%0A%09public void push(int index, String element) %7B%0A%09%09if(element == null) %7B%0A%09%09%09throw new IllegalArgumentException(%22argument is null.%22);%0A%09%09%7D%0A%09%09stack.add(index, element);%0A%09%7D%0A%0A
 %09/**%0A%09 * ret

add method for adding element to stack in specified index.