Top Description Fields Constructors Methods
javassist.bytecode.analysis

public Class Frame

extends Object
Class Inheritance

Represents the stack frame and local variable table at a particular point in time.
Author
Jason T. Greene

Field Summary

Modifier and TypeField and Description
private boolean
private Type[]
private boolean
private Type[]
private int

Constructor Summary

AccessConstructor and Description
public
Frame(int
the number of local variable table entries
locals
,
int
the maximum stack size
stack
)

Create a new frame with the specified local variable table size, and max stack size

Method Summary

Modifier and TypeMethod and Description
public void
clearStack()

Empties the stack

public Frame

Returns:

the shallow copy
copy
()

Makes a shallow copy of this frame, i.e. the type instances will remain the same.

public Frame

Returns:

the shallow copy of the stack
copyStack
()

Makes a shallow copy of the stack portion of this frame.

public Type

Returns:

the type if one exists, or null if the position is empty
getLocal
(int
the position in the table
index
)

Returns the local varaible table entry at index.

public Type

Returns:

the type of the stack position
getStack
(int
the position on the stack
index
)

Returns the type on the stack at the specified index.

public int

Returns:

the position of the element at the top of the stack
getTopIndex
()

Gets the index of the type sitting at the top of the stack.

pack-priv boolean

Returns:

true if JSR state has been merged
isJsrMerged
()

Whether or not state from the source JSR instruction has been merged

pack-priv boolean

Returns:

true if RET state has been merged
isRetMerged
()

Whether or not state from the RET instruction, of the subroutine that was jumped to has been merged.

public int

Returns:

the number of local variable table entries
localsLength
()

Returns the number of local variable table entries, specified at construction.

public boolean

Returns:

true if any changes to this frame where made by this merge
merge
(Frame
the frame to merge with
frame
)

Merges all types on the stack and local variable table of this frame with that of the specified type.

public boolean

Returns:

true if any changes where made
mergeStack
(Frame
the frame to merge the stack from
frame
)

Merges all types on the stack of this frame instance with that of the specified frame.

public Type

Returns:

the top of the stack
peek
()

Gets the top of the stack without altering it

public Type

Returns:

the element popped from the stack
pop
()

Alters the stack to contain one less element and return it.

public void
push(Type
the type to add to the top
type
)

Alters the stack by placing the passed type on the top

pack-priv void
setJsrMerged(boolean
true if merged, otherwise false
jsrMerged
)

Sets whether of not the state from the source JSR instruction has been merged

public void
setLocal(int
the position in the table
index
,
Type
the type to set at the position
type
)

Sets the local variable table entry at index to a type.

pack-priv void
setRetMerged(boolean
true if RET state has been merged
retMerged
)

Sets whether or not state from the RET instruction, of the subroutine that was jumped to has been merged.

public void
setStack(int
the position on the stack
index
,
Type
the type to set
type
)

Sets the type of the stack position

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

jsrMergedback to summary
private boolean jsrMerged
localsback to summary
private Type[] locals
retMergedback to summary
private boolean retMerged
stackback to summary
private Type[] stack
topback to summary
private int top

Constructor Detail

Frameback to summary
public Frame(int locals, int stack)

Create a new frame with the specified local variable table size, and max stack size

Parameters
locals:int

the number of local variable table entries

stack:int

the maximum stack size

Method Detail

clearStackback to summary
public void clearStack()

Empties the stack

copyback to summary
public Frame copy()

Makes a shallow copy of this frame, i.e. the type instances will remain the same.

Returns:Frame

the shallow copy

copyStackback to summary
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:Frame

the shallow copy of the stack

getLocalback to summary
public Type getLocal(int index)

Returns the local varaible table entry at index.

Parameters
index:int

the position in the table

Returns:Type

the type if one exists, or null if the position is empty

getStackback to summary
public Type getStack(int index)

Returns the type on the stack at the specified index.

Parameters
index:int

the position on the stack

Returns:Type

the type of the stack position

getTopIndexback to summary
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:int

the position of the element at the top of the stack

isJsrMergedback to summary
pack-priv boolean isJsrMerged()

Whether or not state from the source JSR instruction has been merged

Returns:boolean

true if JSR state has been merged

isRetMergedback to summary
pack-priv boolean isRetMerged()

Whether or not state from the RET instruction, of the subroutine that was jumped to has been merged.

Returns:boolean

true if RET state has been merged

localsLengthback to summary
public int localsLength()

Returns the number of local variable table entries, specified at construction.

Returns:int

the number of local variable table entries

mergeback to summary
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:Frame

the frame to merge with

Returns:boolean

true if any changes to this frame where made by this merge

mergeStackback to summary
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:Frame

the frame to merge the stack from

Returns:boolean

true if any changes where made

peekback to summary
public Type peek()

Gets the top of the stack without altering it

Returns:Type

the top of the stack

popback to summary
public Type pop()

Alters the stack to contain one less element and return it.

Returns:Type

the element popped from the stack

pushback to summary
public void push(Type type)

Alters the stack by placing the passed type on the top

Parameters
type:Type

the type to add to the top

setJsrMergedback to summary
pack-priv void setJsrMerged(boolean jsrMerged)

Sets whether of not the state from the source JSR instruction has been merged

Parameters
jsrMerged:boolean

true if merged, otherwise false

setLocalback to summary
public void setLocal(int index, Type type)

Sets the local variable table entry at index to a type.

Parameters
index:int

the position in the table

type:Type

the type to set at the position

setRetMergedback to summary
pack-priv void setRetMerged(boolean retMerged)

Sets whether or not state from the RET instruction, of the subroutine that was jumped to has been merged.

Parameters
retMerged:boolean

true if RET state has been merged

setStackback to summary
public void setStack(int index, Type type)

Sets the type of the stack position

Parameters
index:int

the position on the stack

type:Type

the type to set

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override