@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
41 lines (40 loc) • 3.44 kB
TypeScript
import type { NodeToSlice } from './slicer-types';
import type { VisitingQueue } from './visiting-queue';
import { type Fingerprint } from './fingerprint';
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { DataflowInformation } from '../../dataflow/info';
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
/**
* Returns the function call targets (definitions) by the given caller
*/
export declare function getAllFunctionCallTargetsForSlice(dataflowGraph: DataflowGraph, callerInfo: DataflowGraphVertexFunctionCall, baseEnvironment: REnvironmentInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): [Set<DataflowGraphVertexInfo>, REnvironmentInformation];
/** returns the new threshold hit count */
export declare function sliceForCall(current: NodeToSlice, callerInfo: DataflowGraphVertexFunctionCall, { graph }: DataflowInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): void;
/**
* Finds the nearest enclosing function-definition node for the given id by walking up the AST parent chain.
* Used by `includeCallees` to detect the function-definition boundary a node sits inside, as backward slicing
* does not otherwise visit the function-definition vertex itself (nothing within the body links to it).
*/
export declare function findEnclosingFunctionDefinition(id: NodeId, idMap: AstIdMap): NodeId | undefined;
/**
* For `includeCallees`: decides whether the current slice of a function definition's body actually depends on
* the function's interface, i.e., whether the callers can influence the sliced result at all. This is the case iff
* the slice reaches one of the definition's parameters, or it reads a free reference captured from the enclosing
* scope. If the sliced body is self-contained (only locally-defined variables, no parameter and no captured
* variable), the callers are irrelevant and the boundary must not be crossed.
*/
export declare function sliceReachesFunctionInterface(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, idMap: AstIdMap, ctx: ReadOnlyFlowrAnalyzerContext): boolean;
/**
* For `includeCallees`: given the id of a function-definition vertex, enqueues the vertex that binds/defines
* the function (e.g. `f <- function...`, via the `defined-by` edge) as well as all of its call sites (via
* `calls` edges). Call site arguments are picked up automatically once the call vertex is processed normally,
* as `argument` edges are always traversed.
* This is the reverse of what {@link sliceForCall} does for call -\> definition linking.
*/
export declare function includeCalleesOfDefinition(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, baseEnvironment: REnvironmentInformation, baseEnvFingerprint: Fingerprint): void;
/** Returns true if we found at least one return edge */
export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges: OutgoingEdges, baseEnvFingerprint: Fingerprint, baseEnvironment: REnvironmentInformation): boolean;