UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

28 lines (27 loc) 2.46 kB
import type { DataflowProcessorInformation } from '../../processor'; import type { DataflowInformation } from '../../info'; import type { RAstNodeBase, RNode, Location } from '../../../r-bridge/lang-4.x/ast/model/model'; import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate'; import { EmptyArgument, type RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call'; import type { Identifier } from '../../environments/identifier'; import type { RBinaryOp } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op'; import type { RPipe } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe'; /** * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function. */ export declare function processAsNamedCall<OtherInfo>({ info, lexeme, location }: RNode<OtherInfo & ParentInformation> & RAstNodeBase<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, name: Identifier, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation; type RBinaryOpOrPipe<OtherInfo> = (RBinaryOp<OtherInfo & ParentInformation> | RPipe<OtherInfo & ParentInformation>) & RAstNodeBase<OtherInfo> & Location; /** A named, infix-special call, e.g. magrittr's `lhs %>% rhs`: normalized as a {@link RType#FunctionCall}, not as {@link RType#BinaryOp}. */ type RInfixSpecialCall<OtherInfo> = RNamedFunctionCall<OtherInfo & ParentInformation>; /** Any node shape that forms a left-associative operator chain through its first/left operand. */ type ChainNode<OtherInfo> = RBinaryOpOrPipe<OtherInfo> | RInfixSpecialCall<OtherInfo>; /** * Processes a {@link ChainNode}: {@link RType#BinaryOp}, {@link RType#Pipe}, and magrittr-style `%op%` calls * (infix-special {@link RType#FunctionCall}s) all nest on their left operand, so a long `a + b + c + ...` or * `a %>% f() %>% f() %>% ...` chain buries it arbitrarily deep. * This walks the left spine of chain nodes with an explicit loop (bounded stack usage regardless of * chain length), processes the innermost (leftmost) node normally, and then folds outward: each level's left * operand is wrapped via {@link processFunctionArgument}. */ export declare function processChainedCall<OtherInfo>(node: ChainNode<OtherInfo>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation; export {};