@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
53 lines (52 loc) • 3.37 kB
TypeScript
import type { REnvironmentInformation } from './environment';
import { Ternary } from '../../util/logic';
import type { Identifier, IdentifierDefinition } from './identifier';
import { ReferenceType } from './identifier';
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
import type { DataflowGraph } from '../graph/graph';
import type { AstIdMap, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
/**
* Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
*
* @param name - The name of the identifier to resolve
* @param environment - The current environment used for name resolution
* @param target - The target (meta) type of the identifier to resolve
*
* @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
* if the identifier is undefined in the current scope/with the current environment information.
*/
export declare function resolveByName(name: Identifier, environment: REnvironmentInformation, target?: ReferenceType): IdentifierDefinition[] | undefined;
export declare function resolvesToBuiltInConstant(name: Identifier | undefined, environment: REnvironmentInformation, wantedValue: unknown): Ternary;
/** Please use {@link resolveValueOfVariable} */
export declare function resolveToConstants(name: Identifier | undefined, environment: REnvironmentInformation): unknown[] | undefined;
export declare function getAliases(sourceIds: readonly NodeId[], dataflow: DataflowGraph, environment: REnvironmentInformation): NodeId[] | undefined;
/** Please use {@link resolveValueOfVariable} */
export declare function trackAliasInEnvironments(identifier: Identifier | undefined, use: REnvironmentInformation, idMap?: AstIdMap): unknown[] | undefined;
export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, idMap?: AstIdMap): unknown[] | undefined;
/**
* Convenience function using the variable resolver as specified within the configuration file
* In the future we may want to have this set once at the start of the analysis
*
* @see {@link resolveIdToValue} - for a more general approach which "evaluates" a node based on value resolve
*/
export declare function resolveValueOfVariable(identifier: Identifier | undefined, environment: REnvironmentInformation, idMap?: AstIdMap): unknown[] | undefined;
export interface ResolveInfo {
/** The current environment used for name resolution */
environment?: REnvironmentInformation;
/** The id map to resolve the node if given as an id */
idMap?: AstIdMap;
/** The graph to resolve in */
graph?: DataflowGraph;
/** Whether to track variables */
full?: boolean;
}
/**
* Generalized {@link resolveValueOfVariable} function which evaluates a node based on the value resolve
*
* @param id - The node id or node to resolve
* @param environment - The current environment used for name resolution
* @param graph - The graph to resolve in
* @param idMap - The id map to resolve the node if given as an id
* @param full - Whether to track variables
*/
export declare function resolveIdToValue(id: NodeId | RNodeWithParent, { environment, graph, idMap, full }: ResolveInfo): unknown[] | undefined;