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 {
	Stack<String> stack;
	Stack<String> type;

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

	/**
	 * push element and type onto each stack.
	 * @param element
	 * @param type 
	 */
	public void push(String element, String type) {
		if(element == null) {
			throw new IllegalArgumentException("argument is null.");
		}
		if(type == null) {
			throw new IllegalArgumentException("type is null");
		}
		if(element.length() == 0) {
			stack.push("\"\"");
		} else {
			stack.push(element);
		}
		this.type.push(type);
	}

	/**
	 * push element onto stack.
	 * @param element
	 */
	public void push(String element) {
		if(element == null) {
			throw new IllegalArgumentException("argument is null.");
		}
		if(element.length() == 0) {
			stack.push("\"\"");
		} else {
			stack.push(element);
		}
	}

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

	/**
	 * return top element of stack.
	 * @param popType whether pop type stack
	 * @return top element
	 */
	public String pop(boolean popType) {
		if(popType) {
			type.pop();
		}
		return pop();
	}

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

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("stack: ").append(stack).append("\n")
			.append("type : ").append(type);
		return sb.toString();
	}
}
@@ -807,286 +807,8 @@
 %09%7D%0A%0A
-%09/**%0A%09 * push element onto stack.%0A%09 * @param element%0A%09 */%0A%09public void push(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%09if(element.length() == 0) %7B%0A%09%09%09stack.push(%22%5C%22%5C%22%22);%0A%09%09%7D else %7B%0A%09%09%09stack.push(element);%0A%09%09%7D%0A%09%7D%0A%0A
 %09/**

delete unnecessary method.