Java源码
源代码在线查看: orstack.java~4~
package AM.vm_impl.vm_data_structure;
import java.util.Stack;
import java.util.ArrayList;
import AM.vm_impl.util.Tracer;
/**
* Created by IntelliJ IDEA. User: yellowicq Date: 2004-4-27 Time: 13:35:05
* To change this template use File | Settings | File Templates.
*/
public class OrStack {
private Stack opStack;
private ArrayList localVars;
public OrStack() {
}
public void Init() {
opStack = new Stack();
localVars = new ArrayList();
}
public void push(Object obj) {
opStack.push(obj);
}
public void addLocalEntry(int index, Object obj) {
localVars.add(index, obj);
}
public void setLocalEntry(int index, Object obj) {
try {
if (localVars.get(index) == null) {
localVars.add(index, obj);
}
else
localVars.set(index, obj);
} catch (Exception e) {
localVars.add(index, obj);
}
}
public void removeLocalEntry(int index) {
localVars.remove(index);
}
public Object getLocalEntry(int index) {
Object tmpobj = localVars.get(index);
return tmpobj;
}
public Object pop() {
Object tmpobj = opStack.pop();
return tmpobj;
}
public void traceOrStack() {
Tracer.debug("Current opStack:[" + opStack.toString() + "]");
Tracer.debug("Current localVars:[" + localVars.toString() + "]");
}
}