Class OperandStack

java.lang.Object
org.apache.bcel.verifier.structurals.OperandStack
All Implemented Interfaces:
Cloneable

public class OperandStack extends Object implements 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 Link icon

    Constructors
    Constructor
    Description
    OperandStack(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 Link icon

    Modifier and Type
    Method
    Description
    void
    Clears the stack.
    Returns a deep copy of this object; that means, the clone operates on a new stack.
    boolean
    Returns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.
    Returns a (typed!) clone of this.
    int
     
    void
    Replaces all occurrences of u in this OperandStack instance with an "initialized" ObjectType.
    boolean
    Returns true IFF this OperandStack is empty.
    int
    Returns the number of stack slots this stack can hold.
    void
    Merges another stack state into this instance's stack state.
    Returns the element on top of the stack.
    peek(int i)
    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.
    void
    push(Type type)
    Pushes a Type object onto the stack.
    int
    Returns the size of this OperandStack; that means, how many Type objects there are.
    int
    Returns the number of stack slots used.
    Returns a String representation of this OperandStack instance.

    Methods inherited from class java.lang.Object Link icon

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details Link icon

    • OperandStack Link icon

      public OperandStack(int maxStack)
      Creates an empty stack with a maximum of maxStack slots.
    • OperandStack Link icon

      public OperandStack(int maxStack, ObjectType obj)
      Creates an otherwise empty stack with a maximum of maxStack slots and the ObjectType 'obj' at the top.
  • Method Details Link icon

    • clear Link icon

      public void clear()
      Clears the stack.
    • clone Link icon

      public Object clone()
      Returns a deep copy of this object; that means, the clone operates on a new stack. However, the Type objects on the stack are shared.
      Overrides:
      clone in class Object
    • equals Link icon

      public boolean equals(Object o)
      Returns true if and only if this OperandStack equals another, meaning equal lengths and equal objects on the stacks.
      Overrides:
      equals in class Object
    • getClone Link icon

      Returns a (typed!) clone of this.
      See Also:
    • hashCode Link icon

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for the object.
    • initializeObject Link icon

      Replaces all occurrences of u in this OperandStack instance with an "initialized" ObjectType.
    • isEmpty Link icon

      public boolean isEmpty()
      Returns true IFF this OperandStack is empty.
    • maxStack Link icon

      public int maxStack()
      Returns the number of stack slots this stack can hold.
    • merge Link icon

      public void merge(OperandStack s)
      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.
    • peek Link icon

      public Type peek()
      Returns the element on top of the stack. The element is not popped off the stack!
    • peek Link icon

      public Type peek(int i)
      Returns the element that's i elements below the top element; that means, iff i==0 the top element is returned. The element is not popped off the stack!
    • pop Link icon

      public Type pop()
      Returns the element on top of the stack. The element is popped off the stack.
    • pop Link icon

      public Type pop(int count)
      Pops i elements off the stack. Always returns null.
      Returns:
      Always returns null.
    • push Link icon

      public void push(Type type)
      Pushes a Type object onto the stack.
    • size Link icon

      public int size()
      Returns the size of this OperandStack; that means, how many Type objects there are.
    • slotsUsed Link icon

      public int slotsUsed()
      Returns the number of stack slots used.
      See Also:
    • toString Link icon

      public String toString()
      Returns a String representation of this OperandStack instance.
      Overrides:
      toString in class Object