UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

69 lines (68 loc) 3.75 kB
import type { REnvironmentInformation } from '../dataflow/environments/environment'; import type { Identifier } from '../dataflow/environments/identifier'; import type { ContainerIndices, ContainerIndicesCollection, IndexIdentifier } from '../dataflow/graph/vertex'; import type { RAccess } from '../r-bridge/lang-4.x/ast/model/nodes/r-access'; import type { RArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-argument'; import type { RFunctionArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-call'; import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate'; /** * Returns the accessed and access argument of an access operation by filtering the operation arguments. */ export declare function getAccessOperands<OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[]): { accessedArg: RArgument<OtherInfo & ParentInformation> | undefined; accessArg: RArgument<OtherInfo & ParentInformation> | undefined; }; /** * Resolves the passed name in the passed environment and returns the indicesCollection of the resolved definitions. * * @param name - Name to resolve * @param environment - Environment in which name is resolved * @returns The indicesCollection of the resolved definitions */ export declare function resolveIndicesByName(name: Identifier, environment: REnvironmentInformation): ContainerIndices[] | undefined; /** * Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}. * * If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation. * * @param accessedArg - The argument to resolve * @param accessArg - The argument which is used to filter the indices * @param environment - The environment in which {@link accessedArg} is resolved * @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg} */ export declare function resolveSingleIndex(accessedArg: { lexeme: string; }, accessArg: { lexeme: string; }, environment: REnvironmentInformation, isIndexBasedAccess: boolean): ContainerIndicesCollection; /** * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}. * * @param indicesCollection - The {@link ContainerIndicesCollection} to filter * @param accessArg - The argument which is used to filter {@link indicesCollection} * @returns The filtered copy of {@link indicesCollection} */ export declare function filterIndices(indicesCollection: ContainerIndicesCollection, accessArg: { lexeme: string; }, isIndexBasedAccess: boolean): ContainerIndicesCollection; /** * Constructs the definition of a nested access. * * Example: * ```r * person$credentials$username * ``` * would result in a list with the index `credentials`, which has the subIndex `username`. * * @param accessedArg - The top level argument that is accessed * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`. * @returns The constructed nested access */ export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<OtherInfo & ParentInformation>, leafIndices: ContainerIndices, constructIdentifier: (arg: RArgument<OtherInfo & ParentInformation>) => IndexIdentifier): ContainerIndices[]; /** * Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}. * * @param indicesCollection - Indices where to add the sub indices. * @param leafSubIndices - Indices that are added to the leaf indices. */ export declare function addSubIndicesToLeafIndices(indicesCollection: ContainerIndices[], leafSubIndices: ContainerIndices[]): ContainerIndices[];