@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
213 lines (212 loc) • 9.5 kB
TypeScript
import { DataFrameDomain } from './dataframe-domain';
/**
* Represents the different types of resulting constraints that are inferred by abstract data frame operations.
*/
export declare enum ConstraintType {
/** The inferred constraints must hold for the operand at the point of the operation */
OperandPrecondition = 0,
/** The inferred constraints are applied to the operand during the operation */
OperandModification = 1,
/** The inferred constraints must hold for the returned result of the operation */
ResultPostcondition = 2
}
/**
* Mapper for defining the abstract data frame operations and mapping them to semantics applier functions,
* including information about the type of the resulting constraints that are inferred by the operation.
*/
declare const DataFrameSemanticsMapper: {
readonly create: {
readonly apply: typeof applyCreateSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly read: {
readonly apply: typeof applyReadSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly accessCols: {
readonly apply: typeof applyAccessColsSemantics;
readonly type: ConstraintType.OperandPrecondition;
};
readonly accessRows: {
readonly apply: typeof applyAccessRowsSemantics;
readonly type: ConstraintType.OperandPrecondition;
};
readonly assignCols: {
readonly apply: typeof applyAssignColsSemantics;
readonly type: ConstraintType.OperandModification;
};
readonly assignRows: {
readonly apply: typeof applyAssignRowsSemantics;
readonly type: ConstraintType.OperandModification;
};
readonly setColNames: {
readonly apply: typeof applySetColNamesSemantics;
readonly type: ConstraintType.OperandModification;
};
readonly addCols: {
readonly apply: typeof applyAddColsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly addRows: {
readonly apply: typeof applyAddRowsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly removeCols: {
readonly apply: typeof applyRemoveColsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly removeRows: {
readonly apply: typeof applyRemoveRowsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly concatCols: {
readonly apply: typeof applyConcatColsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly concatRows: {
readonly apply: typeof applyConcatRowsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly subsetCols: {
readonly apply: typeof applySubsetColsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly subsetRows: {
readonly apply: typeof applySubsetRowsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly filterRows: {
readonly apply: typeof applyFilterRowsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly mutateCols: {
readonly apply: typeof applyMutateColsSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly groupBy: {
readonly apply: typeof applyGroupBySemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly summarize: {
readonly apply: typeof applySummarizeSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly join: {
readonly apply: typeof applyJoinSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly unknown: {
readonly apply: typeof applyUnknownSemantics;
readonly type: ConstraintType.ResultPostcondition;
};
readonly identity: {
readonly apply: typeof applyIdentitySemantics;
readonly type: ConstraintType.ResultPostcondition;
};
};
/** All available abstract data frame operations */
export type DataFrameOperationName = keyof typeof DataFrameSemanticsMapper;
/** The names of all abstract data frame operations */
export declare const DataFrameOperationNames: readonly DataFrameOperationName[];
/** The required arguments for an abstract data frame operation */
export type DataFrameOperationArgs<N extends DataFrameOperationName> = Parameters<typeof DataFrameSemanticsMapper[N]['apply']>[1];
/** The optional addition options for an abstract data frame operation */
export type DataFrameOperationOptions<N extends DataFrameOperationName> = Parameters<typeof DataFrameSemanticsMapper[N]['apply']>[2];
/**
* Applies the abstract semantics of an abstract data frame operation with respect to the data frame shape domain.
* This expects that all arguments have already been sanitized according to the original concrete data frame function (e.g. by replacing duplicate/invalid column names).
* @param operation - The name of the abstract operation to apply the semantics of
* @param value - The abstract data frame shape of the operand of the abstract operation
* @param args - The arguments for applying the abstract semantics of the abstract operation
* @param options - The optional additional options of the abstract operation
* @returns The resulting new data frame shape constraints.
* The semantic type of the resulting constraints depends on the {@link ConstraintType} of the abstract operation.
*/
export declare function applyDataFrameSemantics<Name extends DataFrameOperationName>(operation: Name, value: DataFrameDomain, args: DataFrameOperationArgs<Name>, options?: DataFrameOperationOptions<Name>): DataFrameDomain;
/**
* Gets the default resulting constraint type for an abstract data frame operation.
*/
export declare function getConstraintType(operation: DataFrameOperationName): ConstraintType;
declare function applyCreateSemantics(value: DataFrameDomain, { colnames, rows }: {
colnames: (string | undefined)[] | undefined;
rows: number | [number, number] | undefined;
}): DataFrameDomain;
declare function applyReadSemantics(value: DataFrameDomain, { colnames, rows }: {
source: string | undefined;
colnames: (string | undefined)[] | undefined;
rows: number | [number, number] | undefined;
}): DataFrameDomain;
declare function applyAccessColsSemantics(value: DataFrameDomain, { columns }: {
columns: string[] | number[] | undefined;
}): DataFrameDomain;
declare function applyAccessRowsSemantics(value: DataFrameDomain, { rows }: {
rows: number[] | undefined;
}): DataFrameDomain;
declare function applyAssignColsSemantics(value: DataFrameDomain, { columns }: {
columns: string[] | number[] | undefined;
}): DataFrameDomain;
declare function applyAssignRowsSemantics(value: DataFrameDomain, { rows }: {
rows: number[] | undefined;
}): DataFrameDomain;
declare function applySetColNamesSemantics(value: DataFrameDomain, { colnames }: {
colnames: (string | undefined)[] | undefined;
}, options?: {
partial?: boolean;
}): DataFrameDomain;
declare function applyAddColsSemantics(value: DataFrameDomain, { colnames }: {
colnames: (string | undefined)[] | undefined;
}): DataFrameDomain;
declare function applyAddRowsSemantics(value: DataFrameDomain, { rows }: {
rows: number | undefined;
}): DataFrameDomain;
declare function applyRemoveColsSemantics(value: DataFrameDomain, { colnames }: {
colnames: (string | undefined)[] | undefined;
}, options?: {
maybe?: boolean;
}): DataFrameDomain;
declare function applyRemoveRowsSemantics(value: DataFrameDomain, { rows }: {
rows: number | undefined;
}, options?: {
maybe?: boolean;
}): DataFrameDomain;
declare function applyConcatColsSemantics(value: DataFrameDomain, { other }: {
other: DataFrameDomain;
}): DataFrameDomain;
declare function applyConcatRowsSemantics(value: DataFrameDomain, { other }: {
other: DataFrameDomain;
}): DataFrameDomain;
declare function applySubsetColsSemantics(value: DataFrameDomain, { colnames }: {
colnames: (string | undefined)[] | undefined;
}, options?: {
duplicateCols?: boolean;
renamedCols?: boolean;
}): DataFrameDomain;
declare function applySubsetRowsSemantics(value: DataFrameDomain, { rows }: {
rows: number | undefined;
}, options?: {
duplicateRows?: boolean;
}): DataFrameDomain;
declare function applyFilterRowsSemantics(value: DataFrameDomain, { condition }: {
condition: boolean | undefined;
}): DataFrameDomain;
declare function applyMutateColsSemantics(value: DataFrameDomain, { colnames }: {
colnames: (string | undefined)[] | undefined;
}): DataFrameDomain;
declare function applyGroupBySemantics(value: DataFrameDomain, { by }: {
by: (string | undefined)[];
}, options?: {
mutatedCols?: boolean;
}): DataFrameDomain;
declare function applySummarizeSemantics(value: DataFrameDomain, { colnames }: {
colnames: (string | undefined)[] | undefined;
}): DataFrameDomain;
declare function applyJoinSemantics(value: DataFrameDomain, { other, by }: {
other: DataFrameDomain;
by: (string | undefined)[] | undefined;
}, options?: {
join?: 'inner' | 'left' | 'right' | 'full';
natural?: boolean;
}): DataFrameDomain;
declare function applyIdentitySemantics(value: DataFrameDomain, _args: {}): DataFrameDomain;
declare function applyUnknownSemantics(value: DataFrameDomain, _args: {}): DataFrameDomain;
export {};