Class Frame

java.lang.Object
javassist.bytecode.analysis.Frame

public class Frame extends Object
Represents the stack frame and local variable table at a particular point in time.
Author:
Jason T. Greene
  • Constructor Summary

    Constructors
    Constructor
    Description
    Frame(int locals, int stack)
    Create a new frame with the specified local variable table size, and max stack size
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Empties the stack
    Makes a shallow copy of this frame, i.e.
    Makes a shallow copy of the stack portion of this frame.
    getLocal(int index)
    Returns the local varaible table entry at index.
    getStack(int index)
    Returns the type on the stack at the specified index.
    int
    Gets the index of the type sitting at the top of the stack.
    int
    Returns the number of local variable table entries, specified at construction.
    boolean
    merge(Frame frame)
    Merges all types on the stack and local variable table of this frame with that of the specified type.
    boolean
    Merges all types on the stack of this frame instance with that of the specified frame.
    Gets the top of the stack without altering it
    pop()
    Alters the stack to contain one less element and return it.
    void
    push(Type type)
    Alters the stack by placing the passed type on the top
    void
    setLocal(int index, Type type)
    Sets the local variable table entry at index to a type.
    void
    setStack(int index, Type type)
    Sets the type of the stack position
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Frame

      public Frame(int locals, int stack)
      Create a new frame with the specified local variable table size, and max stack size
      Parameters:
      locals - the number of local variable table entries
      stack - the maximum stack size
  • Method Details

    • getLocal

      public Type getLocal(int index)
      Returns the local varaible table entry at index.
      Parameters:
      index - the position in the table
      Returns:
      the type if one exists, or null if the position is empty
    • setLocal

      public void setLocal(int index, Type type)
      Sets the local variable table entry at index to a type.
      Parameters:
      index - the position in the table
      type - the type to set at the position
    • getStack

      public Type getStack(int index)
      Returns the type on the stack at the specified index.
      Parameters:
      index - the position on the stack
      Returns:
      the type of the stack position
    • setStack

      public void setStack(int index, Type type)
      Sets the type of the stack position
      Parameters:
      index - the position on the stack
      type - the type to set
    • clearStack

      public void clearStack()
      Empties the stack
    • getTopIndex

      public int getTopIndex()
      Gets the index of the type sitting at the top of the stack. This is not to be confused with a length operation which would return the number of elements, not the position of the last element.
      Returns:
      the position of the element at the top of the stack
    • localsLength

      public int localsLength()
      Returns the number of local variable table entries, specified at construction.
      Returns:
      the number of local variable table entries
    • peek

      public Type peek()
      Gets the top of the stack without altering it
      Returns:
      the top of the stack
    • pop

      public Type pop()
      Alters the stack to contain one less element and return it.
      Returns:
      the element popped from the stack
    • push

      public void push(Type type)
      Alters the stack by placing the passed type on the top
      Parameters:
      type - the type to add to the top
    • copy

      public Frame copy()
      Makes a shallow copy of this frame, i.e. the type instances will remain the same.
      Returns:
      the shallow copy
    • copyStack

      public Frame copyStack()
      Makes a shallow copy of the stack portion of this frame. The local variable table size will be copied, but its contents will be empty.
      Returns:
      the shallow copy of the stack
    • mergeStack

      public boolean mergeStack(Frame frame)
      Merges all types on the stack of this frame instance with that of the specified frame. The local variable table is left untouched.
      Parameters:
      frame - the frame to merge the stack from
      Returns:
      true if any changes where made
    • merge

      public boolean merge(Frame frame)
      Merges all types on the stack and local variable table of this frame with that of the specified type.
      Parameters:
      frame - the frame to merge with
      Returns:
      true if any changes to this frame where made by this merge
    • toString

      public String toString()
      Overrides:
      toString in class Object