Package de.fraunhofer.aisec.cpg.helpers
Class SubgraphWalker
java.lang.Object
de.fraunhofer.aisec.cpg.helpers.SubgraphWalker
public class SubgraphWalker
extends java.lang.Object
Helper class for graph walking: Walking through ast-, cfg-, ...- edges
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSubgraphWalker.BorderFor better readability:result.entriesinstead ofresult.get(0)when working with getEOGPathEdges.static classSubgraphWalker.IterativeGraphWalkerstatic classSubgraphWalker.ScopedWalkerHandles declaration scope monitoring for iterative traversals. -
Method Summary
Modifier and Type Method Description static voidactivateTypes(de.fraunhofer.aisec.cpg.graph.Node node, de.fraunhofer.aisec.cpg.passes.scopes.ScopeManager scopeManager)static java.util.List<de.fraunhofer.aisec.cpg.graph.Node>flattenAST(de.fraunhofer.aisec.cpg.graph.Node n)Flattens the tree, starting at Node n into a list.static java.util.List<de.fraunhofer.aisec.cpg.graph.Node>getAstChildren(de.fraunhofer.aisec.cpg.graph.Node node)Retrieves a list of AST children of the specified node by iterating all fields that are annotated with theSubGraphannotation and its value "AST".static SubgraphWalker.BordergetEOGPathEdges(de.fraunhofer.aisec.cpg.graph.Node n)Function returns two lists in a list.static voidrefreshType(de.fraunhofer.aisec.cpg.graph.Node node)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
getAstChildren
public static java.util.List<de.fraunhofer.aisec.cpg.graph.Node> getAstChildren(de.fraunhofer.aisec.cpg.graph.Node node)Retrieves a list of AST children of the specified node by iterating all fields that are annotated with theSubGraphannotation and its value "AST".- Parameters:
node- the start node- Returns:
- a list of children from the node's AST
-
flattenAST
public static java.util.List<de.fraunhofer.aisec.cpg.graph.Node> flattenAST(de.fraunhofer.aisec.cpg.graph.Node n)Flattens the tree, starting at Node n into a list.- Parameters:
n- the node which contains the ast children to flatten- Returns:
- the flattened nodes
-
getEOGPathEdges
Function returns two lists in a list. The first list contains all eog nodes with no predecesor in the subgraph with root 'n'. The second list contains eog edges that have no successor in the subgraph with root 'n'. The first List marks the entry and the second marks the exit nodes of the cfg in this subgraph.- Parameters:
n- - root of the subgraph.- Returns:
- Two lists, list 1 contains all eog entries and list 2 contains all exits.
-
refreshType
public static void refreshType(de.fraunhofer.aisec.cpg.graph.Node node) -
activateTypes
public static void activateTypes(de.fraunhofer.aisec.cpg.graph.Node node, de.fraunhofer.aisec.cpg.passes.scopes.ScopeManager scopeManager)
-