@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
42 lines (41 loc) • 2.36 kB
TypeScript
import type { ControlFlowInformation } from './control-flow-graph';
import type { NormalizedAst } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { DataflowGraph } from '../dataflow/graph/graph';
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
import { cfgAnalyzeDeadCode } from './cfg-dead-code';
import type { ReadOnlyFlowrAnalyzerContext } from '../project/context/flowr-analyzer-context';
export interface CfgPassInfo {
ast?: NormalizedAst;
dfg?: DataflowGraph;
ctx: ReadOnlyFlowrAnalyzerContext;
}
export type CfgSimplificationPass = (cfg: ControlFlowInformation, info: CfgPassInfo) => ControlFlowInformation;
/**
* All available control flow graph simplification passes.
*/
export declare const CfgSimplificationPasses: {
readonly 'unique-cf-sets': typeof uniqueControlFlowSets;
readonly 'analyze-dead-code': typeof cfgAnalyzeDeadCode;
readonly 'remove-dead-code': typeof cfgRemoveDeadCode;
readonly 'to-basic-blocks': typeof toBasicBlocks;
};
export type CfgSimplificationPassName = keyof typeof CfgSimplificationPasses;
export declare const DefaultCfgSimplificationOrder: ["unique-cf-sets"];
/**
* Simplify the control flow information by applying the given passes.
* This may reduce the vertex count, in- and outgoing edges, entry and exit points, etc.
*/
export declare function simplifyControlFlowInformation(cfg: ControlFlowInformation, info: CfgPassInfo, passes?: readonly CfgSimplificationPassName[]): ControlFlowInformation;
/**
* removes dead vertices and edges from the control flow graph.
*/
declare function cfgRemoveDeadCode(cfg: ControlFlowInformation, _info?: CfgPassInfo): ControlFlowInformation;
declare function uniqueControlFlowSets(cfg: ControlFlowInformation, _info?: CfgPassInfo): ControlFlowInformation;
declare function toBasicBlocks(cfg: ControlFlowInformation, _info?: CfgPassInfo): ControlFlowInformation;
/**
* Uses {@link visitCfgInOrder} to find all nodes that are reachable from the control flow graph's {@link ControlFlowInformation.entryPoints} and returns them as a set.
* Please note that this will not visit the grouping delimiters of expression list!
* @param cfg - The control flow graph whose reachable nodes to find.
*/
export declare function cfgFindAllReachable(cfg: ControlFlowInformation): Set<NodeId>;
export {};