@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
53 lines (52 loc) • 3.88 kB
TypeScript
import { DefaultMap } from '../../util/defaultmap';
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { IdentifierReference } from '../environments/identifier';
import type { DataflowGraph, FunctionArgument } from '../graph/graph';
import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition, DataflowGraphVertexInfo } from '../graph/vertex';
import type { REnvironmentInformation } from '../environments/environment';
export type NameIdMap = DefaultMap<string, IdentifierReference[]>;
export declare function findNonLocalReads(graph: DataflowGraph, ignore: readonly IdentifierReference[]): IdentifierReference[];
export declare function produceNameSharedIdMap(references: IdentifierReference[]): NameIdMap;
export declare function linkArgumentsOnCall(args: FunctionArgument[], params: RParameter<ParentInformation>[], graph: DataflowGraph): void;
export declare function linkFunctionCallWithSingleTarget(graph: DataflowGraph, def: DataflowGraphVertexFunctionDefinition, info: DataflowGraphVertexFunctionCall, idMap: AstIdMap): void;
/**
* Returns the called functions within the current graph, which can be used to merge the environments with the call.
* Furthermore, it links the corresponding arguments.
*
* @param graph - The graph to use for search and resolution traversals (ideally a superset of the `thisGraph`)
* @param idMap - The map to resolve ids to names
* @param thisGraph - The graph to search for function calls in
*/
export declare function linkFunctionCalls(graph: DataflowGraph, idMap: AstIdMap, thisGraph: DataflowGraph): {
functionCall: NodeId;
called: readonly DataflowGraphVertexInfo[];
}[];
/**
* convenience function returning all known call targets, as well as the name source which defines them
*/
export declare function getAllFunctionCallTargets(call: NodeId, graph: DataflowGraph, environment?: REnvironmentInformation): NodeId[];
export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadIds: ReadonlySet<NodeId>, dataflowGraph: DataflowGraph): Set<DataflowGraphVertexInfo>;
/**
* This method links a set of read variables to definitions in an environment.
*
* @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
* @param environmentInformation - The environment information to link against
* @param givenInputs - The existing list of inputs that might be extended
* @param graph - The graph to enter the found links
* @param maybeForRemaining - Each input that can not be linked, will be added to `givenInputs`. If this flag is `true`, it will be marked as `maybe`.
*
* @returns the given inputs, possibly extended with the remaining inputs (those of `referencesToLinkAgainstEnvironment` that could not be linked against the environment)
*/
export declare function linkInputs(referencesToLinkAgainstEnvironment: readonly IdentifierReference[], environmentInformation: REnvironmentInformation, givenInputs: IdentifierReference[], graph: DataflowGraph, maybeForRemaining: boolean): IdentifierReference[];
/** all loops variables which are open read (not already bound by a redefinition within the loop) get a maybe read marker to their last definition within the loop
* e.g. with:
* ```R
* for(i in 1:10) {
* x_1 <- x_2 + 1
* }
* ```
* `x_2` must get a read marker to `x_1` as `x_1` is the active redefinition in the second loop iteration.
*/
export declare function linkCircularRedefinitionsWithinALoop(graph: DataflowGraph, openIns: NameIdMap, outgoing: readonly IdentifierReference[]): void;