@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
71 lines (70 loc) • 4.09 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 { 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 { 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'];
}
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 RFunctionArgument<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 RFunctionArgument<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
*/
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;