public class OperandStack extends Object implements Cloneable
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 and Description |
---|
OperandStack(int initialSize)
constructs a new OperandStack
|
Modifier and Type | Method and Description |
---|---|
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() |
public OperandStack(int initialSize)
initialSize
- the stackSizepublic void clear()
public boolean isEmpty()
public Object pop()
public Object peek()
public Object peek(int depth)
depth
- the depth-objectpublic 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()
Copyright © 2002-2012 Delft University of Technology, the Netherlands. All Rights Reserved.