@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
30 lines (29 loc) • 1.84 kB
TypeScript
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { DataflowGraph } from '../../graph/graph';
import type { ControlFlowGraph } from '../../../control-flow/control-flow-graph';
import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
import { ControlDependency } from '../../info';
/** a resolved `setwd`-style call: its `dir` is `undefined` when it cannot be determined statically */
export interface WorkingDirectoryChange {
readonly id: NodeId;
readonly dir: string | undefined;
readonly cds: readonly ControlDependency[];
readonly iterated: boolean;
readonly enclosedInFunction: boolean;
}
/** over-approximating candidate set (empty means unbounded), and whether exactly one directory is guaranteed */
export interface WorkingDirectoryResolution {
readonly candidates: readonly string[];
readonly certain: boolean;
}
type Guards = readonly ControlDependency[];
declare function resolveAt(target: NodeId, targetCds: Guards, baseWd: string, changes: readonly WorkingDirectoryChange[], cfg: ControlFlowGraph): WorkingDirectoryResolution;
declare function collect(graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): WorkingDirectoryChange[];
/** Resolve R's process-global working directory (sensitive to `setwd`) at a program point; path-sensitive, unbounded rather than wrong under loops/functions. */
export declare const WorkingDirectory: {
readonly collect: typeof collect;
readonly resolveAt: typeof resolveAt;
/** reusable `(callId, scriptFile?) => candidate roots`, collecting the changes once for the whole graph */
readonly rootsResolver: (graph: DataflowGraph, cfg: ControlFlowGraph, ctx: ReadOnlyFlowrAnalyzerContext) => (id: NodeId, file?: string) => readonly string[];
};
export {};