Package javassist.bytecode.analysis
Class Frame
java.lang.Object
javassist.bytecode.analysis.Frame
Represents the stack frame and local variable table at a particular point in time.
- Author:
- Jason T. Greene
-
Constructor Summary
ConstructorDescriptionFrame
(int locals, int stack) Create a new frame with the specified local variable table size, and max stack size -
Method Summary
Modifier and TypeMethodDescriptionvoid
Empties the stackcopy()
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
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.peek()
Gets the top of the stack without altering itpop()
Alters the stack to contain one less element and return it.void
Alters the stack by placing the passed type on the topvoid
Sets the local variable table entry at index to a type.void
Sets the type of the stack positiontoString()
-
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 entriesstack
- the maximum stack size
-
-
Method Details
-
getLocal
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
Sets the local variable table entry at index to a type.- Parameters:
index
- the position in the tabletype
- the type to set at the position
-
getStack
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
Sets the type of the stack position- Parameters:
index
- the position on the stacktype
- 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
Gets the top of the stack without altering it- Returns:
- the top of the stack
-
pop
Alters the stack to contain one less element and return it.- Returns:
- the element popped from the stack
-
push
Alters the stack by placing the passed type on the top- Parameters:
type
- the type to add to the top
-
copy
Makes a shallow copy of this frame, i.e. the type instances will remain the same.- Returns:
- the shallow copy
-
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
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
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
-