@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
84 lines (83 loc) • 5.25 kB
TypeScript
import type { DataflowProcessorInformation } from '../../../../../processor';
import type { DataflowInformation } from '../../../../../info';
import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
import type { PotentiallyEmptyRArgument } 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 { Identifier, type InGraphIdentifierDefinition } from '../../../../../environments/identifier';
import type { DataflowGraphVertexFunctionDefinition } from '../../../../../graph/vertex';
import type { ForceArguments } from '../common';
import type { REnvironmentInformation } from '../../../../../environments/environment';
import type { DataflowGraph } from '../../../../../graph/graph';
export interface AssignmentConfiguration extends ForceArguments {
readonly superAssignment?: boolean;
readonly swapSourceAndTarget?: boolean;
/** Make maybe if assigned to symbol */
readonly makeMaybe?: boolean;
readonly quoteSource?: boolean;
readonly canBeReplacement?: boolean;
/** is the target a variable pointing at the actual name? */
readonly targetVariable?: boolean;
readonly mayHaveMoreArgs?: boolean;
readonly modesForFn?: DataflowGraphVertexFunctionDefinition['mode'];
/**
* The name of the argument that selects the target environment (e.g. `'envir'` for `assign`).
* When present and the argument resolves to a variable with a tracked {@link InGraphIdentifierDefinition#envState},
* the assignment is routed into that environment instead of the current scope.
*/
readonly environmentArg?: string;
}
export interface ExtendedAssignmentConfiguration extends AssignmentConfiguration {
readonly source: {
idx?: number;
name: string;
};
readonly target: {
idx?: number;
name: string;
};
}
/**
* In contrast to `processAssignment`, this function allows more flexible handling of assignment-like functions.
*/
export declare function processAssignmentLike<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: ExtendedAssignmentConfiguration): DataflowInformation;
/**
* Processes an assignment, i.e., `<target> <- <source>`.
* Handling it as a function call \`<-\` `(<target>, <source>)`.
* This includes handling of replacement functions (e.g., `names(x) <- ...` as \`names<-\` `(x, ...)`).
*/
export declare function processAssignment<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: AssignmentConfiguration): DataflowInformation;
export interface AssignmentToSymbolParameters<OtherInfo> extends AssignmentConfiguration {
readonly nameOfAssignmentFunction: Identifier;
readonly source: RNode<OtherInfo & ParentInformation>;
readonly args: [DataflowInformation, DataflowInformation];
readonly targetId: NodeId;
/** pass only if the assignment target differs from normal R assignments (i.e., if the symbol is to be resolved) */
readonly targetName?: Identifier;
readonly rootId: NodeId;
readonly data: DataflowProcessorInformation<OtherInfo>;
readonly information: DataflowInformation;
}
/**
* Consider a call like `x <- v`
* @param information - the information to define the assignment within
* @param nodeToDefine - `x`
* @param sourceIds - `v`
* @param rootIdOfAssignment - `<-`
* @param data - The dataflow analysis fold backpack
* @param assignmentConfig - configuration for the assignment processing
*/
/**
* Model a call like `Hmisc::getHdata(x)` that loads a dataset into the variable it is *given*: the argument symbol
* `x` is both **read** (as the call's argument, its value comes from outside the code) and **defined** by the call.
* Unlike {@link markAsAssignment} we keep the read edge.
*/
export declare function processDefineArgument<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: AssignmentConfiguration): DataflowInformation;
/** Define `nodeToDefine` in the environment and wire the `DefinedBy` edges from it to its sources and the assignment root (dropping the child-added read edges). */
export declare function markAsAssignment<OtherInfo>(information: {
environment: REnvironmentInformation;
graph: DataflowGraph;
}, nodeToDefine: InGraphIdentifierDefinition & {
name: Identifier;
}, sourceIds: readonly NodeId[], rootIdOfAssignment: NodeId, data: DataflowProcessorInformation<OtherInfo>, assignmentConfig?: AssignmentConfiguration): void;