Package sootup.core.model
Class Body
java.lang.Object
sootup.core.model.Body
- All Implemented Interfaces:
HasPosition
Class that models the Jimple body (code attribute) of a method.
- Author:
- Linghui Luo
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The BodyBuilder helps to create a new Body in a fluent way (see Builder Pattern) -
Method Summary
Modifier and TypeMethodDescriptionstatic Body.BodyBuilder
builder()
static Body.BodyBuilder
builder
(MutableStmtGraph graph) static Body.BodyBuilder
builder
(Body body, Set<MethodModifier> modifiers) static Map<LValue,
Collection<Stmt>> collectDefs
(Collection<Stmt> stmts) Collects all defining statements of a Local from a list of statementsstatic Map<Value,
Collection<Stmt>> collectUses
(Collection<Stmt> stmts) Collects all using statements of a Local from a list of statementsgetBranchTargetsOf
(BranchingStmt fromStmt) returns a List of Branch targets of Branching StmtsgetDefs()
Returns the results of iterating through all Stmts in this Body and querying them for Values defined.static Collection<LValue>
Returns the first non-identity stmt in this body.int
Returns the number of locals declared in this body.Returns a backed chain of the locals declared in this Body.Returns the MethodSignature associated with this Body.getParameterLocal
(int i) Return LHS of the first identity stmt assigning from \@parameter i.Get all the LHS of the identity statements assigning from parameter references.Line and column information of the corresponding code object that this represents.StmtGraph<?>
getStmts()
returns the control flow graph that represents this body into a linear List of statements.Return LHS of the first identity stmt assigning from \@this.static Local
getThisLocal
(StmtGraph<?> stmtGraph) Returns the LHS of the first identity stmt assigning from \@this.Return unit containing the \@this-assignment *getTraps()
Deprecated.getUses()
Returns the results of iterating through all Stmts in this Body and querying them for Values defined.boolean
isStmtBranchTarget
(Stmt targetStmt) toString()
withLocals
(Set<Local> locals)
-
Method Details
-
getThisLocal
Returns the LHS of the first identity stmt assigning from \@this.- Returns:
- The this local
-
getMethodSignature
Returns the MethodSignature associated with this Body.- Returns:
- the method that owns this body.
-
getLocalCount
public int getLocalCount()Returns the number of locals declared in this body. -
getLocals
Returns a backed chain of the locals declared in this Body. -
getTraps
Deprecated.Returns an unmodifiable view of the traps found in this Body. @Deprecated the exceptional flow information is already integrated into the StmtGraphs BasicBlocks.getExceptionalFlows() - exists to make porting tools from Soot easier -
getThisStmt
Return unit containing the \@this-assignment * -
getThisLocal
Return LHS of the first identity stmt assigning from \@this. -
getParameterLocal
Return LHS of the first identity stmt assigning from \@parameter i. -
getParameterLocals
Get all the LHS of the identity statements assigning from parameter references.- Returns:
- a list of size as per
getMethod().getParameterCount()
with all elements ordered as per the parameter index. - Throws:
RuntimeException
- if a JParameterRef is missing
-
getStmts
returns the control flow graph that represents this body into a linear List of statements. for more detailed information of the underlying CFG - or just parts of it - have a look at getStmtGraph()- Returns:
- the statements in this Body
-
getStmtGraph
-
toString
-
getPosition
Description copied from interface:HasPosition
Line and column information of the corresponding code object that this represents.- Specified by:
getPosition
in interfaceHasPosition
- Returns:
- a
Position
containing position information.
-
getBranchTargetsOf
returns a List of Branch targets of Branching Stmts -
isStmtBranchTarget
-
getFirstNonIdentityStmt
Returns the first non-identity stmt in this body. -
getUses
Returns the results of iterating through all Stmts in this Body and querying them for Values defined. All of the Values found are then returned as a List.- Returns:
- a List of all the Values for Values defined by this Body's Stmts.
-
getDefs
Returns the results of iterating through all Stmts in this Body and querying them for Values defined. All of the Values found are then returned as a List.- Returns:
- a List of all the Values for Values defined by this Body's Stmts.
-
getDefs
-
withLocals
-
builder
-
builder
-
builder
-
collectDefs
Collects all defining statements of a Local from a list of statements- Parameters:
stmts
- The searched list of statements- Returns:
- A map of Locals and their using statements
-
collectUses
Collects all using statements of a Local from a list of statements- Parameters:
stmts
- The searched list of statements- Returns:
- A map of Locals and their using statements
-