UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

134 lines (133 loc) 8.59 kB
import { DataflowGraph } from './graph'; import { EdgeType } from './edge'; import { emptyGraph } from './dataflowgraph-builder'; import { getOriginInDfg } from '../origin/dfg-get-origin'; import { CallGraph } from './call-graph'; import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id'; import type { REnvironmentInformation } from '../environments/environment'; /** * This is the root helper object to work with the {@link DataflowGraph}. * * - {@link Dataflow.visualize} - for visualization helpers (e.g., rendering the DFG as a mermaid graph), * - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph), * - {@link Dataflow.edge} - for working with the edges in the dataflow graph, */ export declare const Dataflow: { /** * Maps to flowR's dataflow edge helper to work with the edges in the dataflow graph */ readonly edge: { readonly name: "DfEdge"; readonly typesToNames: (this: void, { types }: { types: number; }) => Set<import("./edge").EdgeTypeName>; readonly splitTypes: (this: void, { types }: { types: number; }) => EdgeType[]; readonly typeToName: (this: void, type: EdgeType) => string; readonly includesType: (this: void, { types }: { types: number; }, typesToInclude: EdgeType) => boolean; readonly doesNotIncludeType: (this: void, { types }: { types: number; }, any: EdgeType) => boolean; }; /** * Dispatches to helper objects that relate to (sub-) views of the dataflow graph, e.g. the call graph. */ readonly views: { /** * Maps to flowR's helper object for the call-graph */ readonly callGraph: { readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph; readonly dropTransitiveEdges: (this: void, graph: CallGraph) => CallGraph; readonly compute: (this: void, graph: DataflowGraph) => CallGraph; readonly visualize: { readonly mermaid: { readonly name: "DataflowMermaid"; readonly convert: (this: void, config: import("../../util/mermaid/dfg").MermaidGraphConfiguration) => { string: string; mermaid: import("../../util/mermaid/dfg").MermaidGraph; }; readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string; readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string; }; readonly quads: { readonly convert: typeof import("./quads").df2quads; }; }; readonly diffGraphs: <G extends DataflowGraph>(this: void, left: import("../../util/diff-graph").NamedGraph<G>, right: import("../../util/diff-graph").NamedGraph<G>, config?: Partial<import("../../util/diff").GenericDiffConfiguration>) => import("../../util/diff-graph").GraphDifferenceReport; readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G; readonly resolveGraphCriteria: <G extends DataflowGraph>(graph: G, ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext, idMap?: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap) => G; readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: import("../../util/collections/defaultmap").DefaultMap<NodeId, Set<NodeId>>) => boolean; readonly name: "CallGraph"; }; }; /** * Dispatches to helper functions to create new dataflow graphs, e.g. from a pipeline or an empty graph. */ readonly create: { /** * Creates an empty dataflow graph with the given id map (or a new one if not provided). * @see {@link emptyGraph} */ readonly empty: typeof emptyGraph; }; /** * Returns the origin of a vertex in the dataflow graph * @see {@link getOriginInDfg} - for the underlying function */ readonly origin: typeof getOriginInDfg; /** * Only returns the sub-part of the graph that is determined by the given selection. * In other words, this will return a graph with only vertices that are part of the selected ids, * and edges that are between such selected vertices. * @param graph - the dataflow graph to slice for * @param select - the ids to select in the reduced graph * @param includeMissingTargets - if set to true, this will include edges which target vertices that are not selected! */ readonly reduceGraph: <G extends DataflowGraph>(this: void, graph: G, select: ReadonlySet<NodeId>, includeMissingTargets?: boolean) => G; /** * Given the id of a vertex (usually a variable use), * this returns a reachable provenance set by calculating a non-interprocedural and non-context sensitive backward slice, but stopping at the given ids! * You can obtain the corresponding graph using {@link Dataflow.reduceGraph}. * @param id - The id to use as a seed for provenance calculation * @param graph - The graph to perform the provenance calculation on * @param consider - The ids to restrict the calculation too (e.g., the ids contained within a function definition to restrict the analysis to) * @see {@link Dataflow.provenanceGraph} - for a convenience wrapper to directly obtain the graph of the provenance. */ readonly provenance: (this: void, id: NodeId, graph: DataflowGraph, consider?: ReadonlySet<NodeId>) => Set<NodeId>; /** * A convenience wrapper for {@link Dataflow.reduceGraph|reducing} the {@link Dataflow.provenance|provenance} of a graph. * @param id - The id to use as a seed for provenance calculation * @param graph - The graph to perform the provenance calculation on * @param consider - The ids to restrict the calculation too (e.g., the ids contained within a function definition to restrict the analysis to) * @see {@link Dataflow.provenance} */ readonly provenanceGraph: (this: void, id: NodeId, graph: DataflowGraph, consider?: ReadonlySet<NodeId>) => DataflowGraph; readonly visualize: { readonly mermaid: { readonly name: "DataflowMermaid"; readonly convert: (this: void, config: import("../../util/mermaid/dfg").MermaidGraphConfiguration) => { string: string; mermaid: import("../../util/mermaid/dfg").MermaidGraph; }; readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string; readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string; }; readonly quads: { readonly convert: typeof import("./quads").df2quads; }; }; readonly diffGraphs: <G extends DataflowGraph>(this: void, left: import("../../util/diff-graph").NamedGraph<G>, right: import("../../util/diff-graph").NamedGraph<G>, config?: Partial<import("../../util/diff").GenericDiffConfiguration>) => import("../../util/diff-graph").GraphDifferenceReport; readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G; readonly resolveGraphCriteria: <G extends DataflowGraph>(graph: G, ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext, idMap?: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap) => G; readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: import("../../util/collections/defaultmap").DefaultMap<NodeId, Set<NodeId>>) => boolean; readonly name: "Dataflow"; /** * Maps to flowR's main graph object to store and manipulate the dataflow graph * @see {@link DataflowGraph} */ readonly graph: typeof DataflowGraph; };