public class VolatileMethodSummary
extends java.lang.Object
The later position of the instruction is determined by it's iindex. Additionally this Summary may be instructed to prune unnecessary instructions.
However don't go berserk with the iindex as this will consume loads of memory.
You can get an ordinary MethodSummary using the getMethodSummary()-Method.
It extends the MethodSummarys capabilities by the functions: * getStatementAt(int) *
reserveProgramCounters(int) * allowReserved(boolean)
SSAInstructionFactory,
FakeRootMethod,
MethodSummary| Constructor and Description |
|---|
VolatileMethodSummary(MethodSummary summary) |
| Modifier and Type | Method and Description |
|---|---|
void |
addConstant(java.lang.Integer vn,
ConstantValue value)
Assigns a new Constant to a SSA-Value.
|
void |
addPoison(java.lang.String reason)
Adds posion to the function.
|
void |
addStatement(SSAInstruction statement)
Adds a statement to the MethodSummary.
|
boolean |
allowReserved(boolean enable)
(Dis-)allows the usage of reserved ProgramCounters.
|
java.util.Map<java.lang.Integer,ConstantValue> |
getConstants()
Retrieves a mapping from SSA-Number to a constant.
|
java.util.Map<java.lang.Integer,Atom> |
getLocalNames()
A mapping from SSA-Values to Variable-names.
|
MemberReference |
getMethod()
Retrieve the Method this Summary implements.
|
MethodSummary |
getMethodSummary()
Generates the MethodSummary and locks class.
|
int |
getNextProgramCounter()
Gets you a non-reserved ProgramCounter you can write to.
|
int |
getNumberOfParameters()
Get the count of parameters of the Method this Summary implements.
|
TypeReference |
getParameterType(int i)
Gets you the TypeReference of a parameter.
|
java.lang.String |
getPoison()
Retrieves the poison set using
addPoison(java.lang.String) |
byte |
getPoisonLevel()
Retrieves the value of Poison-Level.
|
TypeReference |
getReturnType()
Retrieves the return-type of the Function whose body this Summary implements.
|
SSAInstruction |
getStatementAt(int programCounter) |
SSAInstruction[] |
getStatements()
Get all statements added to the Summary.
|
boolean |
hasPoison()
Returns if Poison has been added using
addPoison(java.lang.String). |
boolean |
isFactory()
Returns if the implemented method is a factory.
|
boolean |
isFree(int programCounter)
Returns if the ProgramCounter is writable.
|
boolean |
isNative()
Return if the implemented method is a native one (which it shouldn't be).
|
boolean |
isReserved(int programCounter)
Returns if the ProgramCounter is reserved.
|
boolean |
isStatic()
Return if the implemented method is static.
|
boolean |
isUsed(int programCounter)
Not exactly dual to
isFree(int). |
boolean |
overwriteStatement(SSAInstruction statement)
Like
addStatement(SSAInstruction) but may replace an existing one. |
void |
reserveProgramCounters(int count)
Reserves an amount of ProgramCounters for later use.
|
void |
setFactory(boolean b)
Set the value returned by
isFactory() |
void |
setLocalName(int number,
java.lang.String name)
Optionally add a name for a local variable.
|
void |
setLocalNames(java.util.Map<java.lang.Integer,Atom> merge)
Set localNames merges with existing names.
|
void |
setPoisonLevel(byte b)
Set the value returned by
getPoisonLevel() |
void |
setStatic(boolean b)
Set the value returned by
isStatic() |
java.lang.String |
toString()
Generates a String-Representation of an instance of the class.
|
public VolatileMethodSummary(MethodSummary summary)
summary - a "real" summary methods get added to.java.lang.IllegalArgumentException - if this summary is null or not emptypublic SSAInstruction getStatementAt(int programCounter)
programCounter - the ProgramCounter to retrieve the Instruction fromjava.lang.IllegalArgumentException - if the ProgramCounter is negativepublic void reserveProgramCounters(int count)
This method reserves a count of ProgramCounters and thus affects the value returned by
getNextProgramCounter. It also marks these ProgramCounters as reserved so you can't use them
unless you explicitly allow it by allowReserved(boolean).
count - The amount of ProgramCounters to reserve ongoing from the current ProgramCounterjava.lang.IllegalArgumentException - if the count is negative (a count of zero is however ok)public boolean allowReserved(boolean enable)
The setting of this function defaults to disallow upon class creation
enable - A value of true allows the usage of all reserved ProgramCounterspublic boolean isReserved(int programCounter)
programCounter - the ProgramCounter in questionjava.lang.IllegalArgumentException - if the ProgramCounter is negativepublic boolean isFree(int programCounter)
The ProgramCounter is not writable if there is already an instruction located at that
ProgramCounter or if the reserved ProgramCounters forbid usage. Thus the answer may depend on
the setting of allowReserved(boolean).
programCounter - the ProgramCounter in questionjava.lang.IllegalArgumentException - if the ProgramCounter is negativepublic boolean isUsed(int programCounter)
isFree(int).
Returns whether an instruction is located at ProgramCounter. Thus it is a shortcut to getStatementAt(int) != null.
It is not the exact dual to isFree(int) as it does not consider reserved
ProgramCounters.
programCounter - the ProgramCounter in questionjava.lang.IllegalArgumentException - if the ProgramCounter is negativepublic boolean overwriteStatement(SSAInstruction statement)
addStatement(SSAInstruction) but may replace an existing one.statement - The statement to add without care of overwritingjava.lang.IllegalStateException - if you may not write to the ProgramCounter due to the setting of
allowReserved(boolean) or getMethodSummary() has been called and thus
this summary got locked.java.lang.NullPointerException - if statement is nulljava.lang.IllegalArgumentException - if the statement has set an invalid ProgramCounterpublic MethodSummary getMethodSummary()
java.lang.IllegalStateException - if you altered the referenced (by constructor) summarypublic void addStatement(SSAInstruction statement)
statement - The statement to be addedjava.lang.IllegalStateException - if you may not write to the ProgramCounter due to the setting of
allowReserved(boolean) or getMethodSummary() has been called and thus
this summary got locked.java.lang.NullPointerException - if statement is nulljava.lang.IllegalArgumentException - if the statement has set an invalid ProgramCounter or if there
is already a statement at the statements iindex. In this case you can use overwriteStatement(SSAInstruction).public void setLocalName(int number,
java.lang.String name)
public void setLocalNames(java.util.Map<java.lang.Integer,Atom> merge)
If a key in merge exists the value is overwritten if not the value is kept (it's a putAll on the internal map).
public java.util.Map<java.lang.Integer,Atom> getLocalNames()
public void addConstant(java.lang.Integer vn,
ConstantValue value)
java.lang.IllegalStateException - if you redefine a constant or use the number of an existent
SSA-Variablejava.lang.IllegalArgumentException - if value is null or negativepublic void addPoison(java.lang.String reason)
This call gets passed directly to the internal MethodSummary.
public java.util.Map<java.lang.Integer,ConstantValue> getConstants()
You can add Constants using the function addConstant(java.lang.Integer,
ConstantValue). A call to this function gets passed directly to the internal MethodSummary.
public MemberReference getMethod()
You'll get a MemberReference which contains the declaring class (which should be the FakeRootClass in most cases) and the signature of the method.
This call gets passed directly to the internal MethodSummary.
public int getNextProgramCounter()
This function returns the next ProgramCounter for which not(isUsed(int)) holds.
Thus it will _not_ give you a ProgramCounter which is reserved even if you enabled writing to
reserved ProgramCounters using allowReserved(boolean)! You'll have to keep track of
them on your own.
public int getNumberOfParameters()
This call gets passed directly to the internal MethodSummary.
public TypeReference getParameterType(int i)
This call gets passed directly to the internal MethodSummary after some checks.
java.lang.IllegalArgumentException - if the parameter is zero or negativejava.lang.ArrayIndexOutOfBoundsException - if the parameter is to largepublic java.lang.String getPoison()
addPoison(java.lang.String)public byte getPoisonLevel()
This call gets passed directly to the internal MethodSummary.
public TypeReference getReturnType()
This call gets passed directly to the internal MethodSummary.
public SSAInstruction[] getStatements()
This builds a copy of the internal list and may contain 'null'-values if no instruction has been placed at a particular pc.
public boolean hasPoison()
addPoison(java.lang.String).
This call gets passed directly to the internal MethodSummary.
public boolean isFactory()
This call gets passed directly to the internal MethodSummary.
public boolean isNative()
This call gets passed directly to the internal MethodSummary.
public boolean isStatic()
A static method may not access non-static (and thus instance-specific) content.
public void setFactory(boolean b)
isFactory()java.lang.IllegalStateException - if summary was lockedpublic void setPoisonLevel(byte b)
getPoisonLevel()java.lang.IllegalStateException - if summary was lockedpublic void setStatic(boolean b)
isStatic()java.lang.IllegalStateException - if summary was lockedpublic java.lang.String toString()
toString in class java.lang.Object