@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
63 lines (62 loc) • 4.17 kB
TypeScript
import { type DataflowInformation } from '../../../../info';
import { type DataflowProcessorInformation } from '../../../../processor';
import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
import { EmptyArgument, type RFunctionArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
import type { DataflowGraph, FunctionArgument } from '../../../../graph/graph';
import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { REnvironmentInformation } from '../../../../environments/environment';
import { type IdentifierReference } from '../../../../environments/identifier';
import { type DataflowGraphVertexAstLink, type FunctionOriginInformation } from '../../../../graph/vertex';
import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
export interface ForceArguments {
/** which of the arguments should be forced? this may be all, e.g., if the function itself is unknown on encounter */
readonly forceArgs?: 'all' | readonly boolean[];
}
export interface ProcessAllArgumentInput<OtherInfo> extends ForceArguments {
readonly functionName: DataflowInformation;
readonly args: readonly (RNode<OtherInfo & ParentInformation> | RFunctionArgument<OtherInfo & ParentInformation>)[];
readonly data: DataflowProcessorInformation<OtherInfo & ParentInformation>;
readonly finalGraph: DataflowGraph;
readonly functionRootId: NodeId;
readonly patchData?: (data: DataflowProcessorInformation<OtherInfo & ParentInformation>, i: number) => DataflowProcessorInformation<OtherInfo & ParentInformation>;
/** which arguments are to be marked as {@link EdgeType#NonStandardEvaluation|non-standard-evaluation}? */
readonly markAsNSE?: readonly number[];
}
export interface ProcessAllArgumentResult {
readonly finalEnv: REnvironmentInformation;
readonly callArgs: FunctionArgument[];
readonly remainingReadInArgs: IdentifierReference[];
readonly processedArguments: (DataflowInformation | undefined)[];
}
/**
* Converts function arguments into function argument references for a function call vertex.
* Please be aware, that the ids here are those inferred from the AST, not from the dataflow graph!
* This function also works after the arguments were unpacked, e.g., by {@link tryUnpackNoNameArg}.
* @see convertFnArgument
*/
export declare function convertFnArguments<OtherInfo>(args: readonly (typeof EmptyArgument | RNode<OtherInfo & ParentInformation>)[]): FunctionArgument[];
/**
* Transforms a function argument into a function argument reference for a function call vertex.
* Please be aware, that the ids here are those inferred from the AST, not from the dataflow graph!
*/
export declare function convertFnArgument<OtherInfo>(this: void, arg: typeof EmptyArgument | RNode<OtherInfo & ParentInformation>): FunctionArgument;
/**
* Processes all arguments for a function call, updating the given final graph and environment.
*/
export declare function processAllArguments<OtherInfo>({ functionName, args, data, finalGraph, functionRootId, forceArgs, patchData }: ProcessAllArgumentInput<OtherInfo>): ProcessAllArgumentResult;
export interface PatchFunctionCallInput<OtherInfo> {
readonly nextGraph: DataflowGraph;
readonly rootId: NodeId;
readonly name: RSymbol<OtherInfo & ParentInformation>;
readonly data: DataflowProcessorInformation<OtherInfo & ParentInformation>;
readonly argumentProcessResult: readonly (Pick<DataflowInformation, 'entryPoint'> | undefined)[];
readonly origin: FunctionOriginInformation;
readonly link?: DataflowGraphVertexAstLink;
}
/**
* Patches a function call vertex into the given dataflow graph.
* This is mostly useful for built-in processors that have custom argument processing.
* Otherwise, rely on {@link processKnownFunctionCall} instead.
*/
export declare function patchFunctionCall<OtherInfo>({ nextGraph, rootId, name, data, argumentProcessResult, origin, link }: PatchFunctionCallInput<OtherInfo>): void;