@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
60 lines (59 loc) • 3.17 kB
TypeScript
import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { GenericDiffConfiguration, GenericDifferenceInformation, WriteableDifferenceReport } from './diff';
import type { DataflowGraph } from '../dataflow/graph/graph';
export interface NamedGraph<Graph = DataflowGraph> {
name: string;
graph: Graph;
}
interface ProblematicVertex {
tag: 'vertex';
id: NodeId;
}
interface ProblematicEdge {
tag: 'edge';
from: NodeId;
to: NodeId;
}
export type ProblematicDiffInfo = ProblematicVertex | ProblematicEdge;
/**
* To be produced by a function differencing two graphs (e.g., {@link DataflowGraph|DFGs} or {@link ControlFlowGraph|CFGs}).
* @see {@link GraphDifferenceReport#isEqual|isEqual} - to check whether the graphs are equal
* @see {@link GraphDifferenceReport#addComment|addComment} - to add comments to the report
* @see {@link GraphDifferenceReport#comments|comments} - to get the attached comments
* @see {@link GraphDifferenceReport#problematic|problematic} - to get the problematic vertices/edges
*/
export declare class GraphDifferenceReport implements WriteableDifferenceReport {
_comments: string[] | undefined;
_problematic: ProblematicDiffInfo[] | undefined;
addComment(comment: string, ...related: readonly ProblematicDiffInfo[]): void;
comments(): readonly string[] | undefined;
problematic(): readonly ProblematicDiffInfo[] | undefined;
isEqual(): boolean;
}
/**
* A context that can be used by differencing functions to compare two graphs
* See {@link initDiffContext} for a function that creates such a context.
*/
export interface GraphDiffContext<Graph = DataflowGraph> extends GenericDifferenceInformation<GraphDifferenceReport> {
left: Graph;
right: Graph;
config: GenericDiffConfiguration;
}
/**
* Create the context for differencing two graphs
*/
export declare function initDiffContext<Graph>(left: NamedGraph<Graph>, right: NamedGraph<Graph>, config?: Partial<GenericDiffConfiguration>): GraphDiffContext<Graph>;
/** The minimum a graph has to offer for {@link GraphDiff} to compare its edges. */
interface EdgeIndexedGraph<EdgeMap> {
edges(): Iterable<readonly [NodeId, EdgeMap]>;
hasVertex(id: NodeId): boolean;
}
/** The edge-differencing steps shared by the dataflow and the control flow graph diff. */
export declare const GraphDiff: {
readonly name: "GraphDiff";
/** Compares all edges of both graphs vertex by vertex, handing each pair to `diffEdges`. */
readonly outgoingEdges: <EdgeMap, Graph extends EdgeIndexedGraph<EdgeMap>>(this: void, ctx: GraphDiffContext<Graph>, diffEdges: (ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: EdgeMap | undefined, rEdges: EdgeMap | undefined) => void) => void;
/** Compares the outgoing edges of a single vertex, handing each pair of edges to `diffEdge`. */
readonly edges: <Edge, Graph>(this: void, ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: ReadonlyMap<NodeId, Edge> | undefined, rEdges: ReadonlyMap<NodeId, Edge> | undefined, diffEdge: (edge: Edge, otherEdge: Edge, ctx: GraphDiffContext<Graph>, id: NodeId, target: NodeId) => void) => void;
};
export {};