module lang::php::analysis::cfg::Util
Usage
import lang::php::analysis::cfg::Util;
Source code
http://github.com/cwi-swat/php-analysis/blob/main/src/main/rascal/lang/php/analysis/cfg/Util.rsc
Dependencies
import lang::php::ast::AbstractSyntax;
import lang::php::analysis::cfg::CFG;
import lang::php::analysis::cfg::FlowEdge;
import lang::php::analysis::cfg::BasicBlocks;
import lang::php::analysis::NamePaths;
import lang::php::analysis::cfg::Label;
import lang::php::analysis::cfg::FlowEdge;
import analysis::graphs::Graph;
import Relation;
import Set;
import List;
import Node;
import Map;
function pred
set[CFGNode] pred(CFG cfg, CFGNode n)
set[CFGNode] pred(Graph[CFGNode] g, CFGNode n)
function succ
set[CFGNode] succ(CFG cfg, CFGNode n)
set[CFGNode] succ(Graph[CFGNode] g, CFGNode n)
function reachable
set[CFGNode] reachable(Graph[CFGNode] g, CFGNode n)
function reaches
set[CFGNode] reaches(Graph[CFGNode] g, CFGNode n)
function findNodeForExpr
CFGNode findNodeForExpr(CFG cfg, Expr expr)
CFGNode findNodeForExpr(CFG cfg, loc l)
Given an existing expression, find the node that represents this expression
function findNodeForStmt
CFGNode findNodeForStmt(CFG cfg, Stmt stmt)
CFGNode findNodeForStmt(CFG cfg, loc l)
Given an existing statement, find the node that represents this statement
function findNodeForLocation
CFGNode findNodeForLocation(CFG cfg, loc l)
Given the location, find the node at this location
function trueOnAReachedPath
bool trueOnAReachedPath(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred)
Given a starting node and the graph, see if the predicate is true on any successor nodes.
function trueOnAReachingPath
bool trueOnAReachingPath(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred)
Given a starting node and the graph, see if the predicate is true on any predecessor nodes.
function findContainingCFGLoc
loc findContainingCFGLoc(Script s, loc l)
Return the location/path of the CFG for the node at the given location
function findContainingCFG
CFG findContainingCFG(Script s, map[loc,CFG] cfgs, loc l)
Return the CFG for the node at the given location
function trueOnAllReachedPaths
bool trueOnAllReachedPaths(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred, bool includeStartNode = false)
Check to see if the predicate can be satisfied on all paths from the start node.
function trueOnAllReachingPaths
bool trueOnAllReachingPaths(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred, bool includeStartNode = false)
Check to see if the predicate can be satisfied on all paths that reach the start node.
alias GatherResult
tuple[bool trueOnAllPaths, set[&T] results]
function gatherOnAllReachedPaths
GatherResult[&T] gatherOnAllReachedPaths(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred, bool(CFGNode cn) stop, &T (CFGNode cn) gather, bool includeStartNode = false)
function gatherOnAllReachingPaths
GatherResult[&T] gatherOnAllReachingPaths(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred, bool(CFGNode cn) stop, &T (CFGNode cn) gather, bool includeStartNode = false)
Check to see if the predicate can be satisfied on all paths that reach the start node.
function findAllReachedUntil
set[&T] findAllReachedUntil(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred, bool(CFGNode cn) stop, &T (CFGNode cn) gather, bool includeStartNode = false)
Find all matching cases on all reached paths.
function findAllReachingUntil
set[&T] findAllReachingUntil(Graph[CFGNode] g, CFGNode startNode, bool(CFGNode cn) pred, bool(CFGNode cn) stop, &T (CFGNode cn) gather, bool includeStartNode = false)
Find all matched cases on all reaching paths.
function removeNode
CFG removeNode(CFG inputCFG, CFGNode n)
Remove a node from the CFG, relinking edges as necessary
function removeNodes
CFG removeNodes(CFG inputCFG, set[CFGNode] ns)
function transformUnlinkedConditions
CFG transformUnlinkedConditions(CFG inputCFG, set[CFGNode] alsoCheck = { })
Turn condition edges into regular edges if the header for the associated condition is no longer present
function mergeEdges
FlowEdge mergeEdges(FlowEdge e1, FlowEdge e2)
Merge two edges into a single edge from the source of the first to the target of the second
function removeBackEdges
CFG removeBackEdges(CFG inputCFG)
Remove any backedges from the CFG
function buildForwardWorklist
list[CFGNode] buildForwardWorklist(CFG inputCFG)