Package sootup.core.graph
Class MutableBlockControlFlowGraph
java.lang.Object
sootup.core.graph.ControlFlowGraph<MutableBasicBlock>
sootup.core.graph.MutableControlFlowGraph
sootup.core.graph.MutableBlockControlFlowGraph
-
Constructor Summary
ConstructorsConstructorDescriptionMutableBlockControlFlowGraph(boolean isStatic, MethodSignature sig, LocalGenerator localgen) MutableBlockControlFlowGraph(@NonNull ControlFlowGraph<? extends BasicBlock<?>> graph) copies a ControlFlowGraph into this Mutable instance -
Method Summary
Modifier and TypeMethodDescriptionvoidThe list of Stmts must contain only fallsthrough Stmts; A flow manipulating Stmt (BranchingStmt, return, throw) is only allowed at the Tail.voidaddExceptionalEdge(@NonNull Stmt stmt, @NonNull ClassType exceptionType, @NonNull Stmt traphandlerStmt) Adds an exceptional flow with the type "exception" to a "stmt" which will reach "traphandlerStmt"voidinserts a "stmt" with exceptional flows "traps" into the ControlFlowGraphprotected org.apache.commons.lang3.tuple.Pair<Integer,MutableBasicBlock> addNodeToBlock(@NonNull MutableBasicBlock block, @NonNull Stmt stmt) Adds a Stmt to the end of a block i.e. stmt will become the new tail.voidclearBlockFromAllExceptionalBlocks(MutableBasicBlock blockOfRemovedStmt) voidclearExceptionalEdges(@NonNull Stmt node) Modifications of exceptional flows removes all exceptional flows from "stmt"booleancontainsNode(@NonNull Stmt node) protected @NonNull org.apache.commons.lang3.tuple.Pair<Integer,MutableBasicBlock> createStmtsBlock(@NonNull Stmt stmt) creates a Block and inserts the given Stmt.static ControlFlowGraph<?>createUnmodifiableControlFlowGraph(ControlFlowGraph<?> controlFlowGraph) List<? extends BasicBlock<?>>exceptionalPredecessorBlocks(@NonNull BasicBlock<?> block) exceptionalPredecessors(@NonNull MutableBasicBlock block) exceptionalPredecessors(@NonNull Stmt node) it is possible to reach traphandlers through inline code i.e. without any exceptional flowexceptionalSuccessors(@NonNull Stmt node) @Nullable BasicBlock<?>getBlockOf(@NonNull Stmt stmt) @NonNull Set<? extends BasicBlock<?>>@NonNull List<? extends BasicBlock<?>>getNodes()returns the nodes in this graph in a non-deterministic order (->Set) to get the nodes in linearized, ordered manner use iterator() or getStmts.@Nullable Stmt@Nullable BasicBlock<?>@NonNull List<BasicBlock<?>>booleanhasEdgeConnecting(@NonNull Stmt source, @NonNull Stmt target) returns true if there is a flow between source and target throws an Exception if at least one of the parameters is not contained in the graph.intreturns the amount of ingoing flows into nodevoidinitializeWith(@NonNull List<List<Stmt>> blocks, @NonNull Map<BranchingStmt, List<Stmt>> successorMap, @NonNull List<Trap> traps) Creates a Graph representation from the 'legacy' representation i.e. a List of Stmts and Traps.@NonNull BasicBlock<?>insertAfter(@NonNull Stmt existingStmt, @NonNull List<FallsThroughStmt> stmts, @NonNull Map<ClassType, Stmt> exceptionMap) @NonNull BasicBlock<?>insertBefore(@NonNull Stmt existingStmt, @NonNull List<FallsThroughStmt> stmts, @NonNull Map<ClassType, Stmt> exceptionMap) protected booleanisMergeable(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock followingBlock) intreturns the amount of flows that start from nodepredecessors(@NonNull Stmt node) returns the ingoing flows to node as an List with no reliable/specific order and possibly duplicate entries i.e. if a JSwitchStmt has multiple cases that brnach to `node`voidputEdge(@NonNull BranchingStmt stmtA, int succesorIdx, @NonNull Stmt stmtB) voidputEdge(@NonNull FallsThroughStmt stmtA, @NonNull Stmt stmtB) Modifications of unexceptional flowsprotected voidputEdge_internal(@NonNull Stmt stmtA, int succesorIdx, @NonNull Stmt stmtB) voidremoveBlock(BasicBlock<?> block) removeEdge(@NonNull Stmt from, @NonNull Stmt to) removes the current outgoing flows of "from" to "to"voidremoveExceptionalEdge(@NonNull Stmt node, @NonNull ClassType exceptionType) removes an exceptional flow of the type "exception" flow from "stmt"voidremoveExceptionalFlowFromAllBlocks(@NonNull ClassType exceptionType, @NonNull Stmt exceptionHandlerStmt) Removes the specified exceptional flow from all blocks.voidremoveNode(@NonNull Stmt stmt) removes "stmt" from the ControlFlowGraphvoidremoveNode(@NonNull Stmt stmt, boolean keepFlow) Removes a Stmt from the ControlFlowGraph.voidreplaceNode(@NonNull Stmt oldStmt, @NonNull Stmt newStmt) Modification of stmts (without manipulating any flows; possible assigned exceptional flows stay the same as well)booleanreplaceSucessorEdge(@NonNull Stmt from, @NonNull Stmt oldTo, @NonNull Stmt newTo) Replaces all SuccessorEdge(s) of from to oldTo by mewTovoidsetEdges(@NonNull BranchingStmt fromStmt, @NonNull List<Stmt> targets) replaces the current outgoing flows of "from" to "targets"voidsetStartingStmt(@NonNull Stmt startingStmt) successors(@NonNull Stmt node) returns the outgoing flows of node as ordered List.protected booleantryMergeBlocks(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock followingBlock) trys to merge the second block into the first one if possible@NonNull ControlFlowGraph<?>protected voidupdateIndexRangeAfterMerge(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock secondBlock) voidMethods inherited from class sootup.core.graph.MutableControlFlowGraph
addBlock, addNode, insertAfter, insertBefore, setEdgesMethods inherited from class sootup.core.graph.ControlFlowGraph
degree, equals, getAllSuccessors, getBlockIterator, getBranchTargetsOf, getEntrypoints, getExtendedBasicBlockPathBetween, getStmts, getTails, isStmtBranchTarget, iterator, toString, validateStmtConnectionsInGraphMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MutableBlockControlFlowGraph
public MutableBlockControlFlowGraph() -
MutableBlockControlFlowGraph
-
MutableBlockControlFlowGraph
copies a ControlFlowGraph into this Mutable instance
-
-
Method Details
-
createUnmodifiableControlFlowGraph
public static ControlFlowGraph<?> createUnmodifiableControlFlowGraph(ControlFlowGraph<?> controlFlowGraph) -
initializeWith
public void initializeWith(@NonNull List<List<Stmt>> blocks, @NonNull Map<BranchingStmt, List<Stmt>> successorMap, @NonNull List<Trap> traps) Creates a Graph representation from the 'legacy' representation i.e. a List of Stmts and Traps. -
addExceptionalEdge
public void addExceptionalEdge(@NonNull Stmt stmt, @NonNull ClassType exceptionType, @NonNull Stmt traphandlerStmt) Description copied from class:MutableControlFlowGraphAdds an exceptional flow with the type "exception" to a "stmt" which will reach "traphandlerStmt"- Specified by:
addExceptionalEdgein classMutableControlFlowGraph
-
removeExceptionalEdge
Description copied from class:MutableControlFlowGraphremoves an exceptional flow of the type "exception" flow from "stmt"- Specified by:
removeExceptionalEdgein classMutableControlFlowGraph
-
clearExceptionalEdges
Description copied from class:MutableControlFlowGraphModifications of exceptional flows removes all exceptional flows from "stmt"- Specified by:
clearExceptionalEdgesin classMutableControlFlowGraph
-
getBlocks
- Specified by:
getBlocksin classControlFlowGraph<MutableBasicBlock>
-
getBlocksSorted
- Specified by:
getBlocksSortedin classControlFlowGraph<MutableBasicBlock>
-
addBlock
The list of Stmts must contain only fallsthrough Stmts; A flow manipulating Stmt (BranchingStmt, return, throw) is only allowed at the Tail. (like the conditions of a Block)- Specified by:
addBlockin classMutableControlFlowGraph
-
removeBlock
- Specified by:
removeBlockin classMutableControlFlowGraph
-
addNode
Description copied from class:MutableControlFlowGraphinserts a "stmt" with exceptional flows "traps" into the ControlFlowGraph- Specified by:
addNodein classMutableControlFlowGraph
-
updateIndexRangeAfterMerge
protected void updateIndexRangeAfterMerge(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock secondBlock) -
isMergeable
protected boolean isMergeable(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock followingBlock) -
tryMergeBlocks
protected boolean tryMergeBlocks(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock followingBlock) trys to merge the second block into the first one if possible -
createStmtsBlock
protected @NonNull org.apache.commons.lang3.tuple.Pair<Integer,MutableBasicBlock> createStmtsBlock(@NonNull Stmt stmt) creates a Block and inserts the given Stmt.- Returns:
- -1 if Stmt is already in the graph!
-
addNodeToBlock
protected org.apache.commons.lang3.tuple.Pair<Integer,MutableBasicBlock> addNodeToBlock(@NonNull MutableBasicBlock block, @NonNull Stmt stmt) Adds a Stmt to the end of a block i.e. stmt will become the new tail. -
removeNode
Description copied from class:MutableControlFlowGraphremoves "stmt" from the ControlFlowGraph- Specified by:
removeNodein classMutableControlFlowGraph
-
removeNode
Removes a Stmt from the ControlFlowGraph.It can optionally keep the flow (edges) of the statement by connecting the predecessors of the statement with successors of the statement. Keeping the flow does not work when the statement has multiple successors.
- Specified by:
removeNodein classMutableControlFlowGraph- Parameters:
stmt- the Stmt to be removedkeepFlow- flag indicating whether to keep the flow or not- Throws:
IllegalArgumentException- if keepFlow is true but the stmt has multiple successors
-
clearBlockFromAllExceptionalBlocks
-
replaceNode
Description copied from class:MutableControlFlowGraphModification of stmts (without manipulating any flows; possible assigned exceptional flows stay the same as well)- Specified by:
replaceNodein classMutableControlFlowGraph
-
validateBlocks
public void validateBlocks() -
insertBefore
public @NonNull BasicBlock<?> insertBefore(@NonNull Stmt existingStmt, @NonNull List<FallsThroughStmt> stmts, @NonNull Map<ClassType, Stmt> exceptionMap) - Specified by:
insertBeforein classMutableControlFlowGraph
-
insertAfter
public @NonNull BasicBlock<?> insertAfter(@NonNull Stmt existingStmt, @NonNull List<FallsThroughStmt> stmts, @NonNull Map<ClassType, Stmt> exceptionMap) - Specified by:
insertAfterin classMutableControlFlowGraph
-
replaceSucessorEdge
Replaces all SuccessorEdge(s) of from to oldTo by mewTo- Specified by:
replaceSucessorEdgein classMutableControlFlowGraph
-
putEdge
Description copied from class:MutableControlFlowGraphModifications of unexceptional flowsAdds a flow "from" to "to". if at least one of the parameter Stmts is not already in the ControlFlowGraph it will be added. if "to" needs to be added to the ControlFlowGraph i.e. "to" is not already in the ControlFlowGraph the method assumes "to" has the same exceptional flows as "from".
- Specified by:
putEdgein classMutableControlFlowGraph
-
putEdge
- Specified by:
putEdgein classMutableControlFlowGraph
-
putEdge_internal
-
removeEdge
Description copied from class:MutableControlFlowGraphremoves the current outgoing flows of "from" to "to"- Specified by:
removeEdgein classMutableControlFlowGraph- Returns:
- returns List of the successor indices of "from" that were connected to "to" - items are 0 in case of FallsThroughStmts or idx > 0 in case of BranchingStmts with multiple successors
-
setEdges
Description copied from class:MutableControlFlowGraphreplaces the current outgoing flows of "from" to "targets"- Specified by:
setEdgesin classMutableControlFlowGraph
-
getStartingStmt
- Specified by:
getStartingStmtin classControlFlowGraph<MutableBasicBlock>
-
getStartingStmtBlock
- Specified by:
getStartingStmtBlockin classControlFlowGraph<MutableBasicBlock>
-
getTailStmtBlocks
- Specified by:
getTailStmtBlocksin classControlFlowGraph<MutableBasicBlock>
-
getBlockOf
- Specified by:
getBlockOfin classControlFlowGraph<MutableBasicBlock>
-
unmodifiableControlFlowGraph
- Specified by:
unmodifiableControlFlowGraphin classMutableControlFlowGraph
-
setStartingStmt
- Specified by:
setStartingStmtin classMutableControlFlowGraph
-
getNodes
Description copied from class:ControlFlowGraphreturns the nodes in this graph in a non-deterministic order (->Set) to get the nodes in linearized, ordered manner use iterator() or getStmts.- Specified by:
getNodesin classControlFlowGraph<MutableBasicBlock>
-
containsNode
- Specified by:
containsNodein classControlFlowGraph<MutableBasicBlock>
-
predecessors
Description copied from class:ControlFlowGraphreturns the ingoing flows to node as an List with no reliable/specific order and possibly duplicate entries i.e. if a JSwitchStmt has multiple cases that brnach to `node`- Specified by:
predecessorsin classControlFlowGraph<MutableBasicBlock>
-
exceptionalPredecessors
Description copied from class:ControlFlowGraphit is possible to reach traphandlers through inline code i.e. without any exceptional flow- Specified by:
exceptionalPredecessorsin classControlFlowGraph<MutableBasicBlock>
-
exceptionalPredecessors
-
exceptionalPredecessorBlocks
-
successors
Description copied from class:ControlFlowGraphreturns the outgoing flows of node as ordered List. The List can have duplicate entries!- Specified by:
successorsin classControlFlowGraph<MutableBasicBlock>
-
exceptionalSuccessors
- Specified by:
exceptionalSuccessorsin classControlFlowGraph<MutableBasicBlock>
-
inDegree
Description copied from class:ControlFlowGraphreturns the amount of ingoing flows into node- Specified by:
inDegreein classControlFlowGraph<MutableBasicBlock>
-
outDegree
Description copied from class:ControlFlowGraphreturns the amount of flows that start from node- Specified by:
outDegreein classControlFlowGraph<MutableBasicBlock>
-
hasEdgeConnecting
Description copied from class:ControlFlowGraphreturns true if there is a flow between source and target throws an Exception if at least one of the parameters is not contained in the graph.- Specified by:
hasEdgeConnectingin classControlFlowGraph<MutableBasicBlock>
-
removeExceptionalFlowFromAllBlocks
public void removeExceptionalFlowFromAllBlocks(@NonNull ClassType exceptionType, @NonNull Stmt exceptionHandlerStmt) Description copied from class:ControlFlowGraphRemoves the specified exceptional flow from all blocks.- Specified by:
removeExceptionalFlowFromAllBlocksin classControlFlowGraph<MutableBasicBlock>- Parameters:
exceptionType- The class type of the exceptional flow.exceptionHandlerStmt- The handler statement of the exceptional flow.
-