Class OperandStack
java.lang.Object
org.apache.bcel.verifier.structurals.OperandStack
- All Implemented Interfaces:
Cloneable
This class implements a stack used for symbolic JVM stack simulation. [It's used as an operand stack substitute.]
Elements of this stack are
Type objects.-
Constructor Summary
ConstructorsConstructorDescriptionOperandStack(int maxStack) Creates an empty stack with a maximum of maxStack slots.OperandStack(int maxStack, ObjectType obj) Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the stack.clone()Returns a deep copy of this object; that means, the clone operates on a new stack.booleanReturns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.getClone()Returns a (typed!)inthashCode()Gets the hash code.voidReplaces all occurrences of u in this OperandStack instance with an "initialized" ObjectType.booleanisEmpty()Returns true IFF this OperandStack is empty.intmaxStack()Returns the number of stack slots this stack can hold.voidMerges another stack state into this instance's stack state.peek()Returns the element on top of the stack.peek(int depth) Returns the element that's i elements below the top element; that means, iff i==0 the top element is returned.pop()Returns the element on top of the stack.pop(int count) Pops i elements off the stack.voidPushes a Type object onto the stack.intsize()Returns the size of this OperandStack; that means, how many Type objects there are.intReturns the number of stack slots used.toString()Returns a String representation of this OperandStack instance.
-
Constructor Details
-
OperandStack
Creates an empty stack with a maximum of maxStack slots.- Parameters:
maxStack- The maximum stack size.
-
OperandStack
Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top.- Parameters:
maxStack- The maximum stack size.obj- The object type to place at the top.
-
-
Method Details
-
clear
Clears the stack. -
clone
-
equals
-
getClone
Returns a (typed!) clone of this.- Returns:
- A clone of this operand stack.
- See Also:
-
hashCode
-
initializeObject
Replaces all occurrences of u in this OperandStack instance with an "initialized" ObjectType.- Parameters:
u- The uninitialized object type.
-
isEmpty
Returns true IFF this OperandStack is empty.- Returns:
- true if empty, false otherwise.
-
maxStack
Returns the number of stack slots this stack can hold.- Returns:
- The maximum stack size.
-
merge
Merges another stack state into this instance's stack state. See the Java Virtual Machine Specification, Second Edition, page 146: 4.9.2 for details.- Parameters:
s- The stack to merge.
-
peek
-
peek
-
pop
-
pop
-
push
-
size
Returns the size of this OperandStack; that means, how many Type objects there are.- Returns:
- The stack size.
-
slotsUsed
Returns the number of stack slots used.- Returns:
- The number of slots used.
- See Also:
-
toString
-