public class AndroidModelParameterManager
extends java.lang.Object
This class comes in handy if you want to use loops or mix a return value of a function into the parameter of a later function. It supports multiple levels of cascading code blocks and delivers information which SSA-Value is the latest to use or which aught to be combined using a Phi-Statement.
However it does no allocations or Phi-Statements on its own. It just juggles with the numbers.
TODO:
AbstractAndroidModel| Constructor and Description |
|---|
AndroidModelParameterManager(IInstantiationBehavior behaviour)
Setting the behaviour may be handy in the later model.
|
AndroidModelParameterManager(com.ibm.wala.types.MethodReference mRef,
boolean isStatic) |
AndroidModelParameterManager(com.ibm.wala.util.ssa.ParameterAccessor acc) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.Integer> |
getAllForPhi(com.ibm.wala.types.TypeReference type) |
int |
getCurrent(com.ibm.wala.types.TypeReference type)
Retreive the SSA-Number that is valid for a type in the current scope.
|
int |
getFree(com.ibm.wala.types.TypeReference type)
Returns and registers a free SSA-Number to a Type.
|
int |
getSuper(com.ibm.wala.types.TypeReference type)
Retreive the SSA-Number that is valid for a type in the super-ordinate scope.
|
int |
getUnallocated(com.ibm.wala.types.TypeReference type)
Get an unused number to assign to.
|
int |
getUnmanaged()
Retreive a SSA-Value that is not under management.
|
void |
invalidate(com.ibm.wala.types.TypeReference type) |
boolean |
isCreate(com.ibm.wala.types.TypeReference type)
Shorthand for not(
isReuse(TypeReference). |
boolean |
isReuse(com.ibm.wala.types.TypeReference type)
Handed through to an IInstantiationBehavior if set in the constructor.
|
boolean |
isSeen(com.ibm.wala.types.TypeReference type) |
boolean |
isSeen(com.ibm.wala.types.TypeReference type,
boolean withSuper)
Return if the type is managed by this class.
|
boolean |
needsAllocation(com.ibm.wala.types.TypeReference type)
Returns if an instance for that type needs to be allocated.
|
boolean |
needsPhi(com.ibm.wala.types.TypeReference type)
Returns if a PhiInstruction (still) has to be added.
|
int |
scopeDown(boolean doesLoop)
Enter a subordinate scope.
|
int |
scopeUp()
Leave a subordinate scope.
|
void |
setAllocation(com.ibm.wala.util.ssa.SSAValue val) |
void |
setAllocation(com.ibm.wala.types.TypeReference type,
int ssaValue) |
void |
setAllocation(com.ibm.wala.types.TypeReference type,
int ssaValue,
com.ibm.wala.ssa.SSAInstruction setBy)
Register a variable _after_ allocation.
|
void |
setPhi(com.ibm.wala.types.TypeReference type,
int ssaValue,
com.ibm.wala.ssa.SSAInstruction setBy)
Register a Phi-Instruction _after_ added to the model.
|
java.lang.String |
toString() |
public AndroidModelParameterManager(IInstantiationBehavior behaviour)
However it brings no benefit to the AndroidModelParameterManager.
public AndroidModelParameterManager(com.ibm.wala.types.MethodReference mRef,
boolean isStatic)
public AndroidModelParameterManager(com.ibm.wala.util.ssa.ParameterAccessor acc)
public void setAllocation(com.ibm.wala.types.TypeReference type,
int ssaValue,
com.ibm.wala.ssa.SSAInstruction setBy)
The proper way to add an allocation is to get a Variable using getUnallocated(com.ibm.wala.types.TypeReference). Then
assign it a value. And at last call this function.
You can however directly call the function if the type has not been seen before.
type - The type allocatedssaValue - an unallocated SSA-Variable to assign the allocation tosetBy - The instruction that set the valuejava.lang.IllegalStateException - if you set more than one allocation for that type (TODO better
check!)java.lang.IllegalArgumentException - if type is null or ssaValue is zero or negativepublic void setAllocation(com.ibm.wala.types.TypeReference type,
int ssaValue)
public void setAllocation(com.ibm.wala.util.ssa.SSAValue val)
public void setPhi(com.ibm.wala.types.TypeReference type,
int ssaValue,
com.ibm.wala.ssa.SSAInstruction setBy)
type - the type the Phi-Instruction setsssaValue - the number the SSA-Instruction assignes tosetBy - the Phi-Instruction itself - may be nulljava.lang.IllegalArgumentException - if you assign to a number requested using getFree(TypeReference) but types mismach.java.lang.IllegalStateException - if you forgot to close some Phispublic int getFree(com.ibm.wala.types.TypeReference type)
You have to set the type using a Phi-Instruction. Also you don't have to add that instruction immediatly it is required that it is added before the Model gets finished.
You can request the List of unmet Phi-Instructions by using XXX
java.lang.IllegalArgumentException - if type is nullpublic int getUnallocated(com.ibm.wala.types.TypeReference type)
There may only be one unallocated value for each type at a time. XXX: Really?
java.lang.IllegalStateException - if there is already an unallocated variable of that typejava.lang.IllegalArgumentException - if type is nullpublic int getUnmanaged()
Use instead of 'nextLocal++', else SSA-Values will clash!
public int getCurrent(com.ibm.wala.types.TypeReference type)
Either that number origins from an allocation or a PhiInstruction (to be).
java.lang.IllegalStateException - if no number is assignablejava.lang.IllegalArgumentException - if type was not seen before or is nullpublic int getSuper(com.ibm.wala.types.TypeReference type)
Either that number origins from an allocation or a PhiInstruction (to be).
java.lang.IllegalStateException - if no number is assignablejava.lang.IllegalArgumentException - if type was not seen before or is nullpublic java.util.List<java.lang.Integer> getAllForPhi(com.ibm.wala.types.TypeReference type)
java.lang.IllegalArgumentException - if type was not seen before or is nullpublic boolean isSeen(com.ibm.wala.types.TypeReference type,
boolean withSuper)
withSuper - when true return true if a managed key may be cast to type, when false type
has to match exactlytype - the type in questionjava.lang.IllegalArgumentException - if type is nullpublic boolean isSeen(com.ibm.wala.types.TypeReference type)
public boolean needsAllocation(com.ibm.wala.types.TypeReference type)
However this function does not respect weather a PhiInstruction is needed.
java.lang.IllegalArgumentException - if type is nullpublic boolean needsPhi(com.ibm.wala.types.TypeReference type)
This is true if the Value has changed in a deeper scope, has been invalidated or requested using getFree
java.lang.IllegalArgumentException - if type is null or has not been seen beforepublic void invalidate(com.ibm.wala.types.TypeReference type)
java.lang.IllegalArgumentException - if type was not seen before or is nullpublic int scopeDown(boolean doesLoop)
Call this whenever a new code block starts i.e. when ever you would have to put a left curly-bracket in yout java code.
This function influences the placement of Phi-Functions. Thus if you don't change values you don't have to call it.
doesLoop - set to true if the scope is introduced for a looppublic int scopeUp()
All changes are marked invalid thus to be expected to be collected by a PhiInstruction.
java.lang.IllegalStateException - if already at top levelpublic boolean isReuse(com.ibm.wala.types.TypeReference type)
java.lang.IllegalStateException - if AndroidModelParameterManager was constructed without an
IInstanciationBehaviorpublic boolean isCreate(com.ibm.wala.types.TypeReference type)
isReuse(TypeReference).java.lang.IllegalStateException - if AndroidModelParameterManager was constructed without an
IInstanciationBehaviorpublic java.lang.String toString()
toString in class java.lang.Object