UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

38 lines (37 loc) 2.16 kB
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 { FlowrConfigOptions } from '../config'; export interface CfgPassInfo { ast?: NormalizedAst; dfg?: DataflowGraph; config: FlowrConfigOptions; } export type CfgSimplificationPass = (cfg: ControlFlowInformation, info: CfgPassInfo) => ControlFlowInformation; 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. * @param cfg - The control flow graph whose reachable nodes to find. */ export declare function cfgFindAllReachable(cfg: ControlFlowInformation): Set<NodeId>; export {};