Class VolatileMethodSummary
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)
- Since:
- 2013-09-08
- Author:
- Tobias Blaschke <code@tobiasblaschke.de>
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConstant
(Integer vn, ConstantValue value) Assigns a new Constant to a SSA-Value.void
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.Retrieves a mapping from SSA-Number to a constant.A mapping from SSA-Values to Variable-names.Retrieve the Method this Summary implements.Generates the MethodSummary and locks class.int
Gets you a non-reserved ProgramCounter you can write to.int
Get the count of parameters of the Method this Summary implements.getParameterType
(int i) Gets you the TypeReference of a parameter.Retrieves the poison set usingaddPoison(java.lang.String)
byte
Retrieves the value of Poison-Level.Retrieves the return-type of the Function whose body this Summary implements.getStatementAt
(int programCounter) Get all statements added to the Summary.boolean
Returns if Poison has been added usingaddPoison(java.lang.String)
.boolean
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 toisFree(int)
.boolean
overwriteStatement
(SSAInstruction statement) LikeaddStatement(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 byisFactory()
void
setLocalName
(int number, String name) Optionally add a name for a local variable.void
setLocalNames
(Map<Integer, Atom> merge) Set localNames merges with existing names.void
setPoisonLevel
(byte b) Set the value returned bygetPoisonLevel()
void
setStatic
(boolean b) Set the value returned byisStatic()
toString()
Generates a String-Representation of an instance of the class.
-
Constructor Details
-
VolatileMethodSummary
- Parameters:
summary
- a "real" summary methods get added to.- Throws:
IllegalArgumentException
- if this summary is null or not empty
-
-
Method Details
-
getStatementAt
- Parameters:
programCounter
- the ProgramCounter to retrieve the Instruction from- Returns:
- The instruction or null if there is none
- Throws:
IllegalArgumentException
- if the ProgramCounter is negative
-
reserveProgramCounters
public void reserveProgramCounters(int count) Reserves an amount of ProgramCounters for later use.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)
.- Parameters:
count
- The amount of ProgramCounters to reserve ongoing from the current ProgramCounter- Throws:
IllegalArgumentException
- if the count is negative (a count of zero is however ok)
-
allowReserved
public boolean allowReserved(boolean enable) (Dis-)allows the usage of reserved ProgramCounters.The setting of this function defaults to disallow upon class creation
- Parameters:
enable
- A value of true allows the usage of all reserved ProgramCounters- Returns:
- the previous value of allowReserved
-
isReserved
public boolean isReserved(int programCounter) Returns if the ProgramCounter is reserved.- Parameters:
programCounter
- the ProgramCounter in question- Returns:
- true if the position is reserved
- Throws:
IllegalArgumentException
- if the ProgramCounter is negative
-
isFree
public boolean isFree(int programCounter) Returns if the ProgramCounter is writable.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)
.- Parameters:
programCounter
- the ProgramCounter in question- Returns:
- true if you may write to the location
- Throws:
IllegalArgumentException
- if the ProgramCounter is negative
-
isUsed
public boolean isUsed(int programCounter) Not exactly dual toisFree(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.- Parameters:
programCounter
- the ProgramCounter in question- Returns:
- true if there's an instruction at that program counter
- Throws:
IllegalArgumentException
- if the ProgramCounter is negative
-
overwriteStatement
LikeaddStatement(SSAInstruction)
but may replace an existing one.- Parameters:
statement
- The statement to add without care of overwriting- Returns:
- true if a statement has actually been overwritten
- Throws:
IllegalStateException
- if you may not write to the ProgramCounter due to the setting ofallowReserved(boolean)
orgetMethodSummary()
has been called and thus this summary got locked.NullPointerException
- if statement is nullIllegalArgumentException
- if the statement has set an invalid ProgramCounter
-
getMethodSummary
Generates the MethodSummary and locks class.- Returns:
- the finished MethodSummary
- Throws:
IllegalStateException
- if you altered the referenced (by constructor) summary
-
addStatement
Adds a statement to the MethodSummary.- Parameters:
statement
- The statement to be added- Throws:
IllegalStateException
- if you may not write to the ProgramCounter due to the setting ofallowReserved(boolean)
orgetMethodSummary()
has been called and thus this summary got locked.NullPointerException
- if statement is nullIllegalArgumentException
- if the statement has set an invalid ProgramCounter or if there is already a statement at the statements iindex. In this case you can useoverwriteStatement(SSAInstruction)
.
-
setLocalName
Optionally add a name for a local variable. -
setLocalNames
-
getLocalNames
-
addConstant
Assigns a new Constant to a SSA-Value.- Throws:
IllegalStateException
- if you redefine a constant or use the number of an existent SSA-VariableIllegalArgumentException
- if value is null or negative
-
addPoison
Adds posion to the function.This call gets passed directly to the internal MethodSummary.
-
getConstants
Retrieves a mapping from SSA-Number to a constant.You can add Constants using the function
addConstant(java.lang.Integer, ConstantValue)
. A call to this function gets passed directly to the internal MethodSummary.- Returns:
- a mapping from SSA-Number to assigned ConstantValue
-
getMethod
Retrieve the Method this Summary implements.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.
- Returns:
- the implemented method as stated above
-
getNextProgramCounter
public int getNextProgramCounter()Gets you a non-reserved ProgramCounter you can write to.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 usingallowReserved(boolean)
! You'll have to keep track of them on your own.- Returns:
- A non-reserved writable ProgramCounter
-
getNumberOfParameters
public int getNumberOfParameters()Get the count of parameters of the Method this Summary implements.This call gets passed directly to the internal MethodSummary.
- Returns:
- Number of parameters
-
getParameterType
Gets you the TypeReference of a parameter.This call gets passed directly to the internal MethodSummary after some checks.
- Returns:
- the TypeReference of the i-th parameter.
- Throws:
IllegalArgumentException
- if the parameter is zero or negativeArrayIndexOutOfBoundsException
- if the parameter is to large
-
getPoison
Retrieves the poison set usingaddPoison(java.lang.String)
- Returns:
- The poison-String
-
getPoisonLevel
public byte getPoisonLevel()Retrieves the value of Poison-Level.This call gets passed directly to the internal MethodSummary.
- Returns:
- the poison level
-
getReturnType
Retrieves the return-type of the Function whose body this Summary implements.This call gets passed directly to the internal MethodSummary.
-
getStatements
Get all statements added to the Summary.This builds a copy of the internal list and may contain 'null'-values if no instruction has been placed at a particular pc.
- Returns:
- The statements of the summary
-
hasPoison
public boolean hasPoison()Returns if Poison has been added usingaddPoison(java.lang.String)
.This call gets passed directly to the internal MethodSummary.
- Returns:
- true if poison has been added
-
isFactory
public boolean isFactory()Returns if the implemented method is a factory.This call gets passed directly to the internal MethodSummary.
- Returns:
- true if it's a factory
-
isNative
public boolean isNative()Return if the implemented method is a native one (which it shouldn't be).This call gets passed directly to the internal MethodSummary.
- Returns:
- almost always false
-
isStatic
public boolean isStatic()Return if the implemented method is static.A static method may not access non-static (and thus instance-specific) content.
- Returns:
- true if the method is static.
-
setFactory
public void setFactory(boolean b) Set the value returned byisFactory()
- Throws:
IllegalStateException
- if summary was locked
-
setPoisonLevel
public void setPoisonLevel(byte b) Set the value returned bygetPoisonLevel()
- Throws:
IllegalStateException
- if summary was locked
-
setStatic
public void setStatic(boolean b) Set the value returned byisStatic()
- Throws:
IllegalStateException
- if summary was locked
-
toString
-