final class OperandStack extends Object
BC2IR
.This class is intended to be used by a single thread. Methods from this class do not provide any error handling.
The total amount of Operand
s that can be accepted by an operand stack
is called the capacity of the operand stack. It is determined when the stack is
created. The capacity is distinct from the current number of operands on the stack
which is called the size of the operand stack.
Modifier and Type | Field and Description |
---|---|
private Operand[] |
stack |
private int |
top |
Constructor and Description |
---|
OperandStack(int capacity)
Creates an operand stack.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
clear() |
(package private) OperandStack |
createEmptyOperandStackWithSameCapacity()
Returns a new, empty operand stack that has the same capacity
as this one.
|
(package private) OperandStack |
deepCopy()
Returns a deep copy of the stack.
|
(package private) Operand |
getFromBottom(int pos) |
(package private) Operand |
getFromTop(int n) |
(package private) int |
getSize()
Returns the current size of the stack.
|
(package private) boolean |
isEmpty() |
(package private) Operand |
pop() |
(package private) void |
pop2()
Pops the two topmost operands from the stack and discards them.
|
(package private) void |
push(Operand val) |
(package private) void |
replaceFromTop(int n,
Operand op) |
(package private) void |
swap()
Swaps the two topmost operands on the stack.
|
OperandStack(int capacity)
capacity
- the maximum number of operands that the stack
must be able to hold, must be >= 0
void pop2()
This implements the pop2 bytecode.
Operand getFromBottom(int pos)
Operand getFromTop(int n)
void replaceFromTop(int n, Operand op)
void swap()
This implements the swap bytecode.
void clear()
OperandStack deepCopy()
The copied stack has copies of the operands from the original stack. The size and capacity of the copied stack are equal to the original stack at the time of the copy.
boolean isEmpty()
int getSize()
OperandStack createEmptyOperandStackWithSameCapacity()