public abstract class Frame<ValueType>
extends java.lang.Object
getNumLocals() - 1
represent
the local variables. Slots getNumLocals()
..
getNumSlots() - 1
represent the Java operand stack.
Frame is parametized by "ValueType", which is the type of value to be stored in the Frame's slots. This type must form a lattice, according to the abstract mergeValues() operation in the corresponding analysis class (which should be derived from FrameDataflowAnalysis). When a Frame is constructed, all of its slots will contain null. The analysis is responsible for initializing created Frames with default values at the appropriate time. Typically, only initEntryFact() will need to do this.
A Frame may have the special "TOP" value. Such frames serve as the identity element for the meet operation operation.
A Frame may have the special "BOTTOM" value. The result of merging any frame with BOTTOM is BOTTOM.
FrameDataflowAnalysis
Constructor and Description |
---|
Frame(int numLocals)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.util.Collection<ValueType> |
allSlots() |
void |
clearStack()
Clear the Java operand stack.
|
boolean |
contains(ValueType value) |
void |
copyFrom(Frame<ValueType> other)
Make this Frame exactly the same as the one given as a parameter.
|
ValueType |
getArgument(org.apache.bcel.generic.InvokeInstruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg,
int i,
int numArguments)
Deprecated.
|
ValueType |
getArgument(org.apache.bcel.generic.InvokeInstruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg,
int i,
SignatureParser sigParser)
Get the ith argument passed to given method invocation.
|
java.util.BitSet |
getArgumentSet(org.apache.bcel.generic.InvokeInstruction invokeInstruction,
org.apache.bcel.generic.ConstantPoolGen cpg,
DataflowValueChooser<ValueType> chooser)
Get set of arguments passed to a method invocation which match given
predicate.
|
int |
getArgumentSlot(int i,
int numArguments)
Get the stack slot that will contain given method argument.
|
ValueType |
getInstance(org.apache.bcel.generic.Instruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Get the value corresponding to the object instance used in the given
instruction.
|
int |
getInstanceSlot(org.apache.bcel.generic.Instruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Get the slot the object instance referred to by given instruction is
located in.
|
int |
getInstanceStackLocation(org.apache.bcel.generic.Instruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Get the stack location (counting down from top of stack, starting at 0)
containing the object instance referred to by given instruction.
|
int |
getLastUpdateTimestamp() |
int |
getNumArguments(org.apache.bcel.generic.InvokeInstruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Get the number of arguments passed to given method invocation.
|
int |
getNumArgumentsIncludingObjectInstance(org.apache.bcel.generic.InvokeInstruction ins,
org.apache.bcel.generic.ConstantPoolGen cpg)
Get the number of arguments passed to given method invocation, including
the object instance if the call is to an instance method.
|
int |
getNumLocals()
Get the number of locals.
|
int |
getNumSlots()
Get the number of slots (locals plus stack values).
|
ValueType |
getOperand(org.apache.bcel.generic.StackConsumer ins,
org.apache.bcel.generic.ConstantPoolGen cpg,
int i)
Get the ith operand used by given instruction.
|
int |
getStackDepth()
Get the depth of the Java operand stack.
|
int |
getStackLocation(int loc)
Get a the location in the frame of a value on the operand stack.
|
ValueType |
getStackValue(int loc)
Get a value on the operand stack.
|
void |
getTopStackWords(ValueType[] valueList)
Get the values on the top of the Java operand stack.
|
ValueType |
getTopValue()
Get the value on the top of the Java operand stack.
|
ValueType |
getValue(int n)
Get the value at the nth slot.
|
boolean |
isBottom()
Return whether or not this object is the special "BOTTOM" value for
Frames.
|
boolean |
isTop()
Return whether or not this object the special "TOP" value for Frames.
|
boolean |
isValid()
Is the frame valid (meaning it is not TOP or BOTTOM)?
|
ValueType |
popValue()
Pop a value off of the Java operand stack.
|
void |
pushValue(ValueType value)
Push a value onto the Java operand stack.
|
boolean |
sameAs(Frame<ValueType> other)
Return true if this stack frame is the same as the one given as a
parameter.
|
void |
setBottom()
Make this Frame the special "BOTTOM" value.
|
void |
setLastUpdateTimestamp(int lastUpdateTimestamp) |
void |
setTop()
Make this frame the special "TOP" value.
|
void |
setValid()
Set the Frame to be valid (neither TOP nor BOTTOM).
|
void |
setValue(int n,
ValueType value)
Set the value at the nth slot.
|
java.lang.String |
toString()
Convert to string.
|
protected java.lang.String |
valueToString(ValueType value)
Subclasses may override this if they want to do something special to
convert Value objects to Strings.
|
public Frame(int numLocals)
numLocals
- number of local variable slots in the methodpublic boolean isTop()
public void setTop()
public boolean isBottom()
public void setBottom()
public void setValid()
public boolean isValid()
public void pushValue(ValueType value)
value
- the ValueType to pushpublic ValueType popValue() throws DataflowAnalysisException
DataflowAnalysisException
- if the Java operand stack is emptypublic ValueType getTopValue() throws DataflowAnalysisException
DataflowAnalysisException
- if the Java operand stack is emptypublic void getTopStackWords(ValueType[] valueList) throws DataflowAnalysisException
DataflowAnalysisException
public ValueType getStackValue(int loc) throws DataflowAnalysisException
loc
- the stack location, counting downwards from the top (location
0)DataflowAnalysisException
public int getStackLocation(int loc) throws DataflowAnalysisException
loc
- the stack location, counting downwards from the top (location
0)DataflowAnalysisException
public ValueType getInstance(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException
ins
- the instructioncpg
- the ConstantPoolGen for the methodDataflowAnalysisException
public int getInstanceStackLocation(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException
The value returned may be passed to getStackValue(int).
ins
- the Instructioncpg
- the ConstantPoolGen for the methodDataflowAnalysisException
public int getInstanceSlot(org.apache.bcel.generic.Instruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException
ins
- the Instructioncpg
- the ConstantPoolGen for the methodDataflowAnalysisException
public int getNumArguments(org.apache.bcel.generic.InvokeInstruction ins, org.apache.bcel.generic.ConstantPoolGen cpg)
ins
- the method invocation instructioncpg
- the ConstantPoolGen for the class containing the methodpublic int getNumArgumentsIncludingObjectInstance(org.apache.bcel.generic.InvokeInstruction ins, org.apache.bcel.generic.ConstantPoolGen cpg) throws DataflowAnalysisException
ins
- the method invocation instructioncpg
- the ConstantPoolGen for the class containing the methodDataflowAnalysisException
@Deprecated public ValueType getArgument(org.apache.bcel.generic.InvokeInstruction ins, org.apache.bcel.generic.ConstantPoolGen cpg, int i, int numArguments) throws DataflowAnalysisException
ins
- the method invocation instructioncpg
- the ConstantPoolGen for the class containing the methodi
- index of the argument; 0 for the first argument, etc.numArguments
- total number of arguments to the methodDataflowAnalysisException
public ValueType getArgument(org.apache.bcel.generic.InvokeInstruction ins, org.apache.bcel.generic.ConstantPoolGen cpg, int i, SignatureParser sigParser) throws DataflowAnalysisException
ins
- the method invocation instructioncpg
- the ConstantPoolGen for the class containing the methodi
- index of the argument; 0 for the first argument, etc.DataflowAnalysisException
public int getArgumentSlot(int i, int numArguments)
i
- the argument index: 0 for first arg, etc.numArguments
- total number of arguments to the called methodpublic ValueType getOperand(org.apache.bcel.generic.StackConsumer ins, org.apache.bcel.generic.ConstantPoolGen cpg, int i) throws DataflowAnalysisException
ins
- the instruction, which must be a StackConsumercpg
- the ConstantPoolGeni
- index of operand to get: 0 for the first operand, etc.DataflowAnalysisException
public java.util.BitSet getArgumentSet(org.apache.bcel.generic.InvokeInstruction invokeInstruction, org.apache.bcel.generic.ConstantPoolGen cpg, DataflowValueChooser<ValueType> chooser) throws DataflowAnalysisException
invokeInstruction
- the InvokeInstructioncpg
- the ConstantPoolGenchooser
- predicate to choose which argument values should be in the
returned setDataflowAnalysisException
public void clearStack()
public int getStackDepth()
public int getNumLocals()
public int getNumSlots()
public boolean contains(ValueType value)
public ValueType getValue(int n)
n
- the slot to get the value ofpublic void setValue(int n, ValueType value)
n
- the slot in which to set a new valuevalue
- the value to setpublic boolean sameAs(Frame<ValueType> other)
other
- the other Framepublic void copyFrom(Frame<ValueType> other)
other
- the Frame to make this object the same aspublic java.lang.String toString()
toString
in class java.lang.Object
protected java.lang.String valueToString(ValueType value)
public java.util.Collection<ValueType> allSlots()
public void setLastUpdateTimestamp(int lastUpdateTimestamp)
lastUpdateTimestamp
- The lastUpdateTimestamp to set.public int getLastUpdateTimestamp()
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.