|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnl.tudelft.simulation.dsol.interpreter.OperandStack
public class OperandStack
Each frame (�3.6) contains a last-in-first-out (LIFO) stack known as its operand stack. The maximum depth of the operand stack of a frame is determined at compile time and is supplied along with the code for the method associated with the frame (�4.7.3). Where it is clear by context, we will sometimes refer to the operand stack of the current frame as simply the operand stack.
The operand stack is empty when the frame that contains it is created. The Java virtual machine supplies instructions to load constants or values from local variables or fields onto the operand stack. Other Java virtual machine instructions take operands from the operand stack, operate on them, and push the result back onto the operand stack. The operand stack is also used to prepare parameters to be passed to methods and to receive method results.
For example, the IADD instruction adds two int values together. It requires that the int values to be added be the top two values of the operand stack, pushed there by previous instructions. Both of the int values are popped from the operand stack. They are added, and their sum is pushed back onto the operand stack. Subcomputations may be nested on the operand stack, resulting in values that can be used by the encompassing computation.
(c) copyright 2002-2005 Delft
University of Technology , the Netherlands.
See for project information www.simulation.tudelft.nl
License of use: Lesser
General Public License (LGPL) , no warranty.
Constructor Summary | |
---|---|
OperandStack(int initialSize)
constructs a new OperandStack |
Method Summary | |
---|---|
void |
clear()
clears the operand stack |
Object |
clone()
|
boolean |
isEmpty()
is the OperandStack Empty |
Object |
peek()
peeks the first object from the stack. |
Object |
peek(int depth)
peeks the depth-object from the stack. |
Object |
pop()
pops the first object from the operandstack. |
void |
push(Object object)
pushes object on the stack |
void |
replace(Object oldObject,
Object newObject)
replaces all instances of oldObject by newObject |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public OperandStack(int initialSize)
initialSize
- the stackSizeMethod Detail |
---|
public void clear()
public boolean isEmpty()
public Object pop()
public Object peek()
public Object peek(int depth)
depth
- the depth-object
public void push(Object object)
object
- the object to be pushed to the stackpublic void replace(Object oldObject, Object newObject)
oldObject
- the oldObjectnewObject
- the newObjectpublic Object clone()
clone
in class Object
Object.clone()
public String toString()
toString
in class Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |