/* * Created on Nov 24, 2004 */ package fr.lifl.stc.stan.execution.stack; import java.util.Iterator; import java.util.Stack; import fr.lifl.stc.stan.execution.Interpreter; /** * @author yann */ public class ExecutionStack { private Stack m_stack; /** * */ public ExecutionStack() { super(); m_stack = new Stack(); } public void push(MultiObject o) { m_stack.push(o); } public MultiObject pop() { return m_stack.pop(); } public MultiObject peek() { return m_stack.peek(); } public MultiObject peek(int n) { Stack tmp = new Stack(); for(int i = 0; i it = m_stack.iterator(); while(it.hasNext()) { res.m_stack.push((MultiObject)(it.next()).clone()); } return res; } public int size() { return m_stack.size(); } private MultiObject get(int index) { return m_stack.get(index); } public void clear() { m_stack.clear(); } public boolean merge(ExecutionStack s) { if(size() != s.size()) { System.err.println("--------------------------->>>>>>>>>>>>>>>>>>>>>Error: Execution.merge(): TOS differ on same instruction. Our size = "+this.size()+" other size = "+s.size()); System.exit(1); return false; } boolean res = false; for(int i = 0; i it = m_stack.iterator(); while(it.hasNext()) { res += it.next(); } return res + "\n"; } public boolean equals(Object o){ ExecutionStack es = (ExecutionStack)o; return this.m_stack.equals(es.m_stack); } private MultiObject[] content() { MultiObject res[] = new MultiObject[this.size()]; int size = this.size(); ExecutionStack tmp = new ExecutionStack(); for(int i = 0; i