@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
24 lines (23 loc) • 1.64 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 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';
/**
* Processes `with(data, expr)` and `within(data, expr)`.
*
* When `data` is a variable that holds a tracked {@link InGraphIdentifierDefinition#envState},
* the expression `expr` is evaluated in that environment's scope so that reads of names
* defined there resolve correctly.
*
* - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
* - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
*
* Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
* args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
*
* Falls back to a normal function-call analysis when the data argument cannot be resolved
* to a tracked environment.
*/
export declare function processWithEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;