UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

31 lines (30 loc) 2.6 kB
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 { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'; import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol'; import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id'; import { type REnvironmentInformation } from '../../../../../environments/environment'; import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model'; /** The context needed to resolve a stack env: the current environment (for the global) and the built-in environment. */ type StackEnvContext = Pick<DataflowProcessorInformation<never>, 'environment' | 'ctx'>; /** * Processes the env-returning builtins (`globalenv`/`baseenv`/`emptyenv`), tagging the call with the * {@link BuiltInProcName.StackEnv} origin so an assignment (`e <- globalenv()`) attaches the stack env as the * variable's `envState`. Direct forms (`globalenv()$x`, `.GlobalEnv`) go through {@link resolveNodeToStackEnv}. */ export declare function processStackEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation; /** * The stack environment an AST `node` denotes directly: a `.GlobalEnv`/`.BaseEnv` symbol, a * `globalenv()`/`baseenv()`/`emptyenv()` call, the current env via `environment()`, the parent via `parent.env(e)`, * or a named search-path entry via `as.environment("package:x")`. Returns `undefined` otherwise. */ export declare function resolveNodeToStackEnv<Info>(node: RNode<Info> | undefined, data: StackEnvContext): REnvironmentInformation | undefined; /** The stack environment `sourceInfo`'s entry call refers to (`e <- globalenv()`, `e <- environment()`), or `undefined`. */ export declare function stackEnvStateFromSource(sourceInfo: DataflowInformation, data: StackEnvContext): REnvironmentInformation | undefined; /** * Whether a `$`/`[[` on the stack env `node` denotes reads through the enclosing scopes. * Only the rlang pronoun `.env` does: it names the surrounding scope, while `$` on a real environment stays in its frame. */ export declare function stackEnvInheritsFields<Info>(node: RNode<Info> | undefined): boolean; export {};