UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

262 lines (261 loc) 11.6 kB
import { type ResolveInfo } from '../../../dataflow/eval/resolve/alias-tracking'; import type { DataflowGraph } from '../../../dataflow/graph/graph'; import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context'; import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model'; import { type RFunctionArgument } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'; import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate'; import type { DataFrameOperations, DataFrameShapeInferenceVisitor } from '../shape-inference'; import { type FunctionParameterLocation } from './arguments'; /** * Represents the different types of data frames in R */ declare enum DataFrameType { DataFrame = "data.frame", Tibble = "tibble", DataTable = "data.table" } /** * Mapper for mapping the supported concrete data frame functions to mapper functions, * including information about the origin library of the functions and the type of the returned data frame. */ declare const DataFrameFunctionMapper: { readonly 'data.frame': { readonly mapper: typeof mapDataFrameCreate; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly 'as.data.frame': { readonly mapper: typeof mapDataFrameConvert; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly 'read.table': { readonly mapper: typeof mapDataFrameRead; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly 'read.csv': { readonly mapper: typeof mapDataFrameRead; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly 'read.csv2': { readonly mapper: typeof mapDataFrameRead; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly 'read.delim': { readonly mapper: typeof mapDataFrameRead; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly 'read.delim2': { readonly mapper: typeof mapDataFrameRead; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly read_table: { readonly mapper: typeof mapDataFrameRead; readonly library: "readr"; readonly returnType: DataFrameType.Tibble; }; readonly read_csv: { readonly mapper: typeof mapDataFrameRead; readonly library: "readr"; readonly returnType: DataFrameType.Tibble; }; readonly read_csv2: { readonly mapper: typeof mapDataFrameRead; readonly library: "readr"; readonly returnType: DataFrameType.Tibble; }; readonly read_tsv: { readonly mapper: typeof mapDataFrameRead; readonly library: "readr"; readonly returnType: DataFrameType.Tibble; }; readonly read_delim: { readonly mapper: typeof mapDataFrameRead; readonly library: "readr"; readonly returnType: DataFrameType.Tibble; }; readonly cbind: { readonly mapper: typeof mapDataFrameColBind; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly rbind: { readonly mapper: typeof mapDataFrameRowBind; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly head: { readonly mapper: typeof mapDataFrameHeadTail; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly tail: { readonly mapper: typeof mapDataFrameHeadTail; readonly library: "utils"; readonly returnType: DataFrameType.DataFrame; }; readonly subset: { readonly mapper: typeof mapDataFrameSubset; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly filter: { readonly mapper: typeof mapDataFrameFilter; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly select: { readonly mapper: typeof mapDataFrameSelect; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly mutate: { readonly mapper: typeof mapDataFrameMutate; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly transform: { readonly mapper: typeof mapDataFrameMutate; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly group_by: { readonly mapper: typeof mapDataFrameGroupBy; readonly library: "dplyr"; readonly returnType: DataFrameType.Tibble; }; readonly summarise: { readonly mapper: typeof mapDataFrameSummarize; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly summarize: { readonly mapper: typeof mapDataFrameSummarize; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly inner_join: { readonly mapper: typeof mapDataFrameJoin; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly left_join: { readonly mapper: typeof mapDataFrameJoin; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly right_join: { readonly mapper: typeof mapDataFrameJoin; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly full_join: { readonly mapper: typeof mapDataFrameJoin; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly merge: { readonly mapper: typeof mapDataFrameJoin; readonly library: "base"; readonly returnType: DataFrameType.DataFrame; }; readonly relocate: { readonly mapper: typeof mapDataFrameIdentity; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; readonly arrange: { readonly mapper: typeof mapDataFrameIdentity; readonly library: "dplyr"; readonly returnType: DataFrameType.DataFrame; }; }; /** All currently supported data frame functions */ type DataFrameFunction = keyof typeof DataFrameFunctionMapper; /** * Maps a concrete data frame function call to abstract data frame operations. * @param node - The R node of the function call * @param inference - The data frame shape inference visitor * @param dfg - The data flow graph for resolving the arguments * @param ctx - The current flowR analyzer context * @returns The mapped abstract data frame operations for the function call, or `undefined` if the node does not represent a data frame function call */ export declare function mapDataFrameFunctionCall<Name extends DataFrameFunction>(node: RNode<ParentInformation>, inference: DataFrameShapeInferenceVisitor, dfg: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): DataFrameOperations; declare function mapDataFrameCreate(args: readonly RFunctionArgument<ParentInformation>[], params: { checkNames: FunctionParameterLocation<boolean>; noDupNames: FunctionParameterLocation<boolean>; special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameConvert(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameRead(args: readonly RFunctionArgument<ParentInformation>[], params: { fileName: FunctionParameterLocation; text?: FunctionParameterLocation; header: FunctionParameterLocation<boolean>; separator: FunctionParameterLocation<string>; quote: FunctionParameterLocation<string>; comment: FunctionParameterLocation<string>; skipLines: FunctionParameterLocation<number>; checkNames: FunctionParameterLocation<boolean>; noDupNames: FunctionParameterLocation<boolean>; noEmptyNames?: boolean; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameColBind(args: readonly RFunctionArgument<ParentInformation>[], params: { special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameRowBind(args: readonly RFunctionArgument<ParentInformation>[], params: { special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameHeadTail(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; amount: FunctionParameterLocation<number>; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameSubset(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; subset: FunctionParameterLocation; select: FunctionParameterLocation; drop: FunctionParameterLocation<boolean>; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameFilter(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameSelect(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameMutate(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; special: string[]; checkNames?: boolean; noDupNames?: boolean; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameGroupBy(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; by: FunctionParameterLocation; special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameSummarize(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; special: string[]; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameJoin(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; otherDataFrame: FunctionParameterLocation; by: FunctionParameterLocation; joinAll: FunctionParameterLocation<boolean>; joinLeft: FunctionParameterLocation<boolean>; joinRight: FunctionParameterLocation<boolean>; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; declare function mapDataFrameIdentity(args: readonly RFunctionArgument<ParentInformation>[], params: { dataFrame: FunctionParameterLocation; special: string[]; disallowNamedArgs?: boolean; }, inference: DataFrameShapeInferenceVisitor, info: ResolveInfo): DataFrameOperations; export {};