UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

58 lines (57 loc) 4.5 kB
import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id'; import type { ParentInformation, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate'; import type { DataflowProcessorInformation } from '../../processor'; import type { DataflowGraph } from '../../graph/graph'; import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context'; import type { ResolveInfo, ResolveResult } from './alias-tracking'; import { soleValue } from '../values/general'; import type { Value, ValueSet } from '../values/r-value'; /** The node to resolve, given either by id or directly. */ type Target = NodeId | RNodeWithParent | undefined; declare function infoOf<OtherInfo>(this: void, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>): ResolveInfo; /** * The value(s) a node may hold, resolved against the state the current processor sees. * Use {@link NodeValue.inGraph} to resolve against a finished {@link DataflowGraph} instead. * Every entry point accepts overrides for the cases that deviate (e.g. another environment). * * This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to * constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening. * Anything needing an abstract state lives in `src/abstract-interpretation/`. * @example * ```ts * NodeValue.of(id, data); // during processing * NodeValue.inGraph(id, graph, ctx); // on a finished graph * NodeValue.sole(NodeValue.setOf(id, data)); // the single value, if there is exactly one * ``` */ export declare const NodeValue: { readonly name: "NodeValue"; /** The resolve info the processor's state stands for, for repeated resolutions. */ readonly infoOf: typeof infoOf; /** The value(s) the node may hold. */ readonly of: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ResolveResult; /** The value set the node may hold, `undefined` if it resolves to top or bottom. */ readonly setOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined; /** The strings the node may hold, `undefined` if it does not resolve to strings. */ readonly stringsOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string[] | undefined; /** The single string the node resolves to, `undefined` if it is not exactly one. */ readonly singleStringOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string | undefined; /** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */ readonly sole: typeof soleValue; /** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */ readonly soleOf: <OtherInfo, T extends Value["type"]>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, { type: T; }> | undefined; /** The same questions, asked of a finished dataflow graph instead of a running processor. */ readonly inGraph: { /** The value set the node may hold, `undefined` if it resolves to top or bottom. */ readonly setOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined; /** The single string the node resolves to, `undefined` if it is not exactly one. */ readonly singleStringOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => string | undefined; /** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */ readonly soleOf: <T extends Value["type"]>(this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, { type: T; }> | undefined; }; }; export {};