javassist.bytecode.analysis
Class Frame

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

public class Frame
extends java.lang.Object

Represents the stack frame and local variable table at a particular point in time.

Author:
Jason T. Greene

Constructor Summary
Frame(int locals, int stack)
          Create a new frame with the specified local variable table size, and max stack size
 
Method Summary
 void clearStack()
          Empties the stack
 Frame copy()
          Makes a shallow copy of this frame, i.e.
 Frame copyStack()
          Makes a shallow copy of the stack portion of this frame.
 Type getLocal(int index)
          Returns the local varaible table entry at index.
 Type getStack(int index)
          Returns the type on the stack at the specified index.
 int getTopIndex()
          Gets the index of the type sitting at the top of the stack.
 int localsLength()
          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 mergeStack(Frame frame)
          Merges all types on the stack of this frame instance with that of the specified frame.
 Type peek()
          Gets the top of the stack without altering it
 Type 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
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 Detail

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 java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2011. All Rights Reserved.