Package sootup.core.graph
Class MutableBlockStmtGraph
java.lang.Object
sootup.core.graph.StmtGraph<MutableBasicBlock>
sootup.core.graph.MutableStmtGraph
sootup.core.graph.MutableBlockStmtGraph
-
Constructor Summary
ConstructorsConstructorDescriptionMutableBlockStmtGraph(boolean isStatic, MethodSignature sig, LocalGenerator localgen) MutableBlockStmtGraph(@NonNull StmtGraph<? extends BasicBlock<?>> graph) copies a StmtGraph 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 StmtGraphprotected 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 StmtGraph<?>createUnmodifiableStmtGraph(StmtGraph<?> stmtGraph) 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 StmtGraphvoidremoveNode(@NonNull Stmt stmt, boolean keepFlow) Removes a Stmt from the StmtGraph.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 StmtGraph<?>protected voidupdateIndexRangeAfterMerge(@NonNull MutableBasicBlock firstBlock, @NonNull MutableBasicBlock secondBlock) voidMethods inherited from class sootup.core.graph.MutableStmtGraph
addBlock, addNode, insertAfter, insertBefore, setEdgesMethods inherited from class sootup.core.graph.StmtGraph
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
-
MutableBlockStmtGraph
public MutableBlockStmtGraph() -
MutableBlockStmtGraph
-
MutableBlockStmtGraph
copies a StmtGraph into this Mutable instance
-
-
Method Details
-
createUnmodifiableStmtGraph
-
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:MutableStmtGraphAdds an exceptional flow with the type "exception" to a "stmt" which will reach "traphandlerStmt"- Specified by:
addExceptionalEdgein classMutableStmtGraph
-
removeExceptionalEdge
Description copied from class:MutableStmtGraphremoves an exceptional flow of the type "exception" flow from "stmt"- Specified by:
removeExceptionalEdgein classMutableStmtGraph
-
clearExceptionalEdges
Description copied from class:MutableStmtGraphModifications of exceptional flows removes all exceptional flows from "stmt"- Specified by:
clearExceptionalEdgesin classMutableStmtGraph
-
getBlocks
- Specified by:
getBlocksin classStmtGraph<MutableBasicBlock>
-
getBlocksSorted
- Specified by:
getBlocksSortedin classStmtGraph<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 classMutableStmtGraph
-
removeBlock
- Specified by:
removeBlockin classMutableStmtGraph
-
addNode
Description copied from class:MutableStmtGraphinserts a "stmt" with exceptional flows "traps" into the StmtGraph- Specified by:
addNodein classMutableStmtGraph
-
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:MutableStmtGraphremoves "stmt" from the StmtGraph- Specified by:
removeNodein classMutableStmtGraph
-
removeNode
Removes a Stmt from the StmtGraph.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 classMutableStmtGraph- 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:MutableStmtGraphModification of stmts (without manipulating any flows; possible assigned exceptional flows stay the same as well)- Specified by:
replaceNodein classMutableStmtGraph
-
validateBlocks
public void validateBlocks() -
insertBefore
public @NonNull BasicBlock<?> insertBefore(@NonNull Stmt existingStmt, @NonNull List<FallsThroughStmt> stmts, @NonNull Map<ClassType, Stmt> exceptionMap) - Specified by:
insertBeforein classMutableStmtGraph
-
insertAfter
public @NonNull BasicBlock<?> insertAfter(@NonNull Stmt existingStmt, @NonNull List<FallsThroughStmt> stmts, @NonNull Map<ClassType, Stmt> exceptionMap) - Specified by:
insertAfterin classMutableStmtGraph
-
replaceSucessorEdge
Replaces all SuccessorEdge(s) of from to oldTo by mewTo- Specified by:
replaceSucessorEdgein classMutableStmtGraph
-
putEdge
Description copied from class:MutableStmtGraphModifications of unexceptional flowsAdds a flow "from" to "to". if at least one of the parameter Stmts is not already in the StmtGraph it will be added. if "to" needs to be added to the StmtGraph i.e. "to" is not already in the StmtGraph the method assumes "to" has the same exceptional flows as "from".
- Specified by:
putEdgein classMutableStmtGraph
-
putEdge
- Specified by:
putEdgein classMutableStmtGraph
-
putEdge_internal
-
removeEdge
Description copied from class:MutableStmtGraphremoves the current outgoing flows of "from" to "to"- Specified by:
removeEdgein classMutableStmtGraph- 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:MutableStmtGraphreplaces the current outgoing flows of "from" to "targets"- Specified by:
setEdgesin classMutableStmtGraph
-
getStartingStmt
- Specified by:
getStartingStmtin classStmtGraph<MutableBasicBlock>
-
getStartingStmtBlock
- Specified by:
getStartingStmtBlockin classStmtGraph<MutableBasicBlock>
-
getTailStmtBlocks
- Specified by:
getTailStmtBlocksin classStmtGraph<MutableBasicBlock>
-
getBlockOf
- Specified by:
getBlockOfin classStmtGraph<MutableBasicBlock>
-
unmodifiableStmtGraph
- Specified by:
unmodifiableStmtGraphin classMutableStmtGraph
-
setStartingStmt
- Specified by:
setStartingStmtin classMutableStmtGraph
-
getNodes
Description copied from class:StmtGraphreturns 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 classStmtGraph<MutableBasicBlock>
-
containsNode
- Specified by:
containsNodein classStmtGraph<MutableBasicBlock>
-
predecessors
Description copied from class:StmtGraphreturns 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 classStmtGraph<MutableBasicBlock>
-
exceptionalPredecessors
Description copied from class:StmtGraphit is possible to reach traphandlers through inline code i.e. without any exceptional flow- Specified by:
exceptionalPredecessorsin classStmtGraph<MutableBasicBlock>
-
exceptionalPredecessors
-
exceptionalPredecessorBlocks
-
successors
Description copied from class:StmtGraphreturns the outgoing flows of node as ordered List. The List can have duplicate entries!- Specified by:
successorsin classStmtGraph<MutableBasicBlock>
-
exceptionalSuccessors
- Specified by:
exceptionalSuccessorsin classStmtGraph<MutableBasicBlock>
-
inDegree
Description copied from class:StmtGraphreturns the amount of ingoing flows into node- Specified by:
inDegreein classStmtGraph<MutableBasicBlock>
-
outDegree
Description copied from class:StmtGraphreturns the amount of flows that start from node- Specified by:
outDegreein classStmtGraph<MutableBasicBlock>
-
hasEdgeConnecting
Description copied from class:StmtGraphreturns 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 classStmtGraph<MutableBasicBlock>
-
removeExceptionalFlowFromAllBlocks
public void removeExceptionalFlowFromAllBlocks(@NonNull ClassType exceptionType, @NonNull Stmt exceptionHandlerStmt) Description copied from class:StmtGraphRemoves the specified exceptional flow from all blocks.- Specified by:
removeExceptionalFlowFromAllBlocksin classStmtGraph<MutableBasicBlock>- Parameters:
exceptionType- The class type of the exceptional flow.exceptionHandlerStmt- The handler statement of the exceptional flow.
-