@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
65 lines (64 loc) • 3.53 kB
TypeScript
import type { DataflowGraphVertexFunctionCall } from '../../dataflow/graph/vertex';
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import { AbstractInterpretationVisitor, type AbsintVisitorConfiguration } from '../absint-visitor';
import { DataFrameDomain } from './dataframe-domain';
import { ConstraintType, type DataFrameOperationArgs, type DataFrameOperationName, type DataFrameOperationOptions } from './semantics';
interface Operation<Name extends DataFrameOperationName> {
/** The type of the abstract data frame operation (see {@link DataFrameOperationName}) */
operation: Name;
/** The ID of the data frame operand of the operation (may be `undefined`) */
operand: NodeId | undefined;
/** The optional constraint type to overwrite the default type of the operation (see {@link ConstraintType}) */
type?: ConstraintType;
/** The optional additional options for the abstract operation (see {@link DataFrameOperationOptions}) */
options?: DataFrameOperationOptions<Name>;
}
/**
* An abstract data frame operation.
*/
export type DataFrameOperation<OperationName extends DataFrameOperationName = DataFrameOperationName> = {
[Name in OperationName]: Operation<Name> & DataFrameOperationArgs<Name>;
}[OperationName];
/**
* An abstract data frame operation without additional options.
*/
export type DataFrameOperationType<OperationName extends DataFrameOperationName = DataFrameOperationName> = {
[Name in OperationName]: Omit<Operation<Name>, 'type' | 'options'> & DataFrameOperationArgs<Name>;
}[OperationName];
/**
* A possible `undefined` array of abstract data frame operations (see {@link DataFrameOperation}).
*/
export type DataFrameOperations<OperationName extends DataFrameOperationName = DataFrameOperationName> = DataFrameOperation<OperationName>[] | undefined;
interface DataFrameShapeInferenceConfiguration extends AbsintVisitorConfiguration {
readonly trackOperations?: boolean;
}
/**
* The control flow graph visitor to infer the shape of data frames using abstract interpretation
*/
export declare class DataFrameShapeInferenceVisitor extends AbstractInterpretationVisitor<DataFrameDomain, DataFrameShapeInferenceConfiguration> {
/**
* The abstract data frame operations the function call nodes are mapped to.
*/
private readonly operations?;
constructor({ trackOperations, ...config }: DataFrameShapeInferenceConfiguration);
/**
* Gets the mapped abstract data frame operations for an AST node (this only includes direct function calls, replacement calls, or access operations).
* This requires that the abstract interpretation visitor has been completed, or at least started.
* @param id - The ID of the node to get the mapped abstract operations for
* @returns The mapped abstract data frame operations for the node, or `undefined` if no abstract operation was mapped for the node or storing mapped abstract operations is disabled via the visitor config.
*/
getAbstractOperations(id: NodeId | undefined): Readonly<DataFrameOperations>;
protected onFunctionCall({ call }: {
call: DataflowGraphVertexFunctionCall;
}): void;
protected onReplacementCall({ call, target, source }: {
call: DataflowGraphVertexFunctionCall;
target?: NodeId;
source?: NodeId;
}): void;
protected onAccessCall({ call }: {
call: DataflowGraphVertexFunctionCall;
}): void;
private applyDataFrameExpression;
}
export {};