@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
28 lines (27 loc) • 1.77 kB
TypeScript
import { type ControlFlowGraph } from './control-flow-graph';
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
export type SimpleCfgVisitor = (graph: ControlFlowGraph, nodes: readonly NodeId[], visitor: (node: NodeId) => boolean | void) => void;
/**
* Visit all nodes reachable from the start node in the control flow graph, traversing the dependencies but ignoring cycles.
* @param graph - The control flow graph.
* @param startNodes - The nodes to start the traversal from.
* @param visitor - The visitor function to call for each node, if you return true the traversal from this node will be stopped.
*
* This function is of type {@link SimpleCfgVisitor}.
* @see {@link visitCfgInOrder} for a traversal in order
*/
export declare function visitCfgInReverseOrder(graph: ControlFlowGraph, startNodes: readonly NodeId[], visitor: (node: NodeId) => boolean | void): void;
/**
* Visit all nodes reachable from the start node in the control flow graph, traversing the dependencies in execution order but ignoring cycles.
* @param graph - The control flow graph.
* @param startNodes - The nodes to start the traversal from.
* @param visitor - The visitor function to call for each node, if you return true the traversal from this node will be stopped.
*
* This function is of type {@link SimpleCfgVisitor}.
* @see {@link visitCfgInReverseOrder} for a traversal in reversed order
*/
export declare function visitCfgInOrder(graph: ControlFlowGraph, startNodes: readonly NodeId[], visitor: (node: NodeId) => boolean | void): Set<NodeId>;
/**
* Check if a node can reach another node in the control flow graph.
*/
export declare function canReach(graph: ControlFlowGraph, from: NodeId[], to: NodeId): boolean;