@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
39 lines (38 loc) • 2.81 kB
TypeScript
import type { FlowrConfigOptions } from '../../config';
import { type ControlFlowInformation } from '../../control-flow/control-flow-graph';
import type { DataflowGraph } from '../../dataflow/graph/graph';
import type { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import { type AbstractInterpretationInfo } from './absint-info';
import { type DataFrameDomain, type DataFrameStateDomain } from './domain';
/**
* Infers the shape of data frames by performing abstract interpretation using the control flow graph of a program.
* This directly attaches the inferred data frames shapes to the AST (see {@link AbstractInterpretationInfo}).
*
* @param cfinfo - The control flow information containing the control flow graph
* @param dfg - The data flow graph to resolve variable origins and function arguments
* @param ast - The abstract syntax tree to resolve node IDs to AST nodes
* @param config - The flowR configuration to use for the shape inference
* @returns The abstract data frame state at the exit node of the control flow graph (see {@link DataFrameStateDomain}).
* The abstract data frame states for all other nodes are attached to the AST.
*/
export declare function inferDataFrameShapes(cfinfo: ControlFlowInformation, dfg: DataflowGraph, ast: NormalizedAst<ParentInformation & AbstractInterpretationInfo>, config: FlowrConfigOptions): DataFrameStateDomain;
/**
* Resolves the abstract data frame shape of a node in the AST.
* This requires that the data frame shape inference has been executed before using {@link inferDataFrameShapes}.
*
* @param id - The node or node ID to get the data frame shape for
* @param dfg - The data flow graph used to resolve the data frame shape
* @param domain - An optional abstract data frame state domain used to resolve the data frame shape (defaults to the state at the requested node)
* @returns The abstract data frame shape of the node, or `undefined` if no data frame shape was inferred for the node
*/
export declare function resolveIdToDataFrameShape(id: RNode<ParentInformation & AbstractInterpretationInfo> | NodeId | undefined, dfg: DataflowGraph | undefined, domain?: DataFrameStateDomain): DataFrameDomain | undefined;
/**
* Gets all origins of a variable in the data flow graph that have already been visited.
*
* @param node - The node to get the origins for
* @param dfg - The data flow graph for resolving the origins
* @returns The origins nodes of the variable
*/
export declare function getVariableOrigins(node: NodeId, dfg: DataflowGraph): RNode<ParentInformation & AbstractInterpretationInfo>[];