@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
57 lines (56 loc) • 3.88 kB
TypeScript
import { type DataflowProcessorInformation } from '../../../../processor';
import type { DataflowInformation } from '../../../../info';
import { type ForceArguments } from './common';
import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { RFunctionArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
import { type IdentifierReference } from '../../../../environments/identifier';
import type { FunctionArgument } from '../../../../graph/graph';
import { DataflowGraph } from '../../../../graph/graph';
import { type FunctionOriginInformation } from '../../../../graph/vertex';
export interface ProcessKnownFunctionCallInput<OtherInfo> extends ForceArguments {
/** The name of the function being called. */
readonly name: RSymbol<OtherInfo & ParentInformation>;
/** The arguments to the function call. */
readonly args: readonly (RNode<OtherInfo & ParentInformation> | RFunctionArgument<OtherInfo & ParentInformation>)[];
/** The node ID to use for the function call vertex. */
readonly rootId: NodeId;
/** The dataflow processor information at the point of the function call. */
readonly data: DataflowProcessorInformation<OtherInfo & ParentInformation>;
/** should arguments be processed from right to left? This does not affect the order recorded in the call but of the environments */
readonly reverseOrder?: boolean;
/** which arguments are to be marked as {@link EdgeType#NonStandardEvaluation|non-standard-evaluation}? */
readonly markAsNSE?: readonly number[];
/** allows passing a data processor in-between each argument */
readonly patchData?: (data: DataflowProcessorInformation<OtherInfo & ParentInformation>, arg: number) => DataflowProcessorInformation<OtherInfo & ParentInformation>;
/** Does the call have a side effect that we do not know a lot about which may have further consequences? */
readonly hasUnknownSideEffect?: boolean;
/** The origin to use for the function being called. */
readonly origin: FunctionOriginInformation | 'default';
}
/** The result of processing a known function call. */
export interface ProcessKnownFunctionCallResult {
/** This is the overall information about the function call itself. */
readonly information: DataflowInformation;
/** The processed arguments in order, they are included in the information but sometimes useful separately. */
readonly processedArguments: readonly (DataflowInformation | undefined)[];
/** A reference to the function being called. */
readonly fnRef: IdentifierReference;
/**
* The arguments as recorded on the function call vertex.
* They are also part of the information via the function call vertex adde, but sometimes useful separately.
* For example, together with {@link pMatch} to do custom parameter matching.
*/
readonly callArgs: readonly FunctionArgument[];
}
/**
* Marks the given arguments as being involved in R's non-standard evaluation.
*/
export declare function markNonStandardEvaluationEdges(markAsNSE: readonly number[], callArgs: readonly (DataflowInformation | undefined)[], finalGraph: DataflowGraph, rootId: NodeId): void;
/**
* The main processor for function calls for which we know the target but need not
* add any specific handling.
*/
export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;