@eagleoutice/flowr-dev
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
77 lines (76 loc) • 6.07 kB
TypeScript
import type { RAstNodeBase, Location, NoInfo } from '../model';
import { RNode } from '../model';
import { RType } from '../type';
import type { RSymbol } from './r-symbol';
import type { RArgument } from './r-argument';
export declare const EmptyArgument = "<>";
export type PotentiallyEmptyRArgument<Info = NoInfo> = RArgument<Info> | typeof EmptyArgument;
/**
* Calls of functions like `a()` and `foo(42, "hello")`.
* @see RUnnamedFunctionCall
*/
export interface RNamedFunctionCall<Info = NoInfo> extends RAstNodeBase<Info>, Location {
readonly type: RType.FunctionCall;
readonly named: true;
functionName: RSymbol<Info>;
/** arguments can be empty, for example when calling as `a(1, ,3)` */
readonly arguments: readonly PotentiallyEmptyRArgument<Info>[];
}
/**
* Direct calls of functions like `(function(x) { x })(3)`.
* @see RNamedFunctionCall
*/
export interface RUnnamedFunctionCall<Info = NoInfo> extends RAstNodeBase<Info>, Location {
readonly type: RType.FunctionCall;
readonly named: false | undefined;
calledFunction: RNode<Info>;
/** marks function calls like `3 %xx% 4` which have been written in special infix notation; deprecated in v2 */
infixSpecial?: boolean;
/** arguments can be undefined, for example when calling as `a(1, ,3)` */
readonly arguments: readonly PotentiallyEmptyRArgument<Info>[];
}
export type RFunctionCall<Info = NoInfo> = RNamedFunctionCall<Info> | RUnnamedFunctionCall<Info>;
/**
* Helper for working with {@link RFunctionCall} AST nodes.
*/
export declare const RFunctionCall: {
readonly name: "RFunctionCall";
/**
* Type guard for {@link RFunctionCall} nodes.
*/
readonly is: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RFunctionCall<Info>;
/**
* Type guard for {@link RNamedFunctionCall} nodes.
*/
readonly isNamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RNamedFunctionCall<Info>;
/**
* Type guard for {@link RUnnamedFunctionCall} nodes.
*/
readonly isUnnamed: <Info = object>(this: void, node: RNode<Info> | undefined) => node is RUnnamedFunctionCall<Info>;
/**
* Bind a call's `arguments` to the formal `paramNames` with {@link matchArgumentsToParameters}, R's argument
* matching. Returns a map from parameter name to the argument bound to it, so
* `matchArgsToParams(call.arguments, names).get('X')` answers "which argument is mapped to parameter `X`".
* An empty argument (`f(1, ,3)`) takes its formal but never appears in the map, as there is nothing to bind.
*/
readonly matchArgsToParams: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[], paramNames: readonly string[]) => ReadonlyMap<string, RArgument<Info>>;
/** The one argument a call was given, `undefined` unless there is exactly one and it is not empty. */
readonly soleArgument: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[]) => RArgument<Info> | undefined;
readonly getLocation: (this: void, node: RNode) => import("../../../../../util/range").SourceLocation | undefined;
readonly getId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => import("../processing/node-id").NodeId;
readonly stableId: (this: void, node: RNode<import("../processing/decorate").ParentInformation>) => string | undefined;
readonly span: <OtherInfo>(this: void, node: RNode<OtherInfo> | undefined) => import("../../../../../util/range").SourceRange | undefined;
readonly topLevelStatement: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation>;
readonly getType: (this: void, node: RNode) => RType;
readonly visitAst: <OtherInfo = object>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo>>, onVisit?: import("../processing/visitor").OnEnter<OtherInfo>, onExit?: import("../processing/visitor").OnExit<OtherInfo>) => void;
readonly collectAllIds: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>) => Set<import("../processing/node-id").NodeId>;
readonly directChildren: <OtherInfo>(this: void, node: RNode<OtherInfo>) => readonly (RNode<OtherInfo> | typeof EmptyArgument)[];
readonly directParent: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => RNode<OtherInfo & import("../processing/decorate").ParentInformation> | undefined;
readonly iterateParents: <OtherInfo>(this: void, node: RNode<OtherInfo & import("../processing/decorate").ParentInformation> | undefined, idMap: import("../processing/decorate").AstIdMap<OtherInfo & import("../processing/decorate").ParentInformation>) => Generator<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>;
readonly depth: (this: void, node: RNode<import("../processing/decorate").ParentInformation>, idMap: import("../processing/decorate").AstIdMap<import("../processing/decorate").ParentInformation>) => number;
readonly collectAllIdsWithStop: <OtherInfo>(this: void, nodes: import("../model").SingleOrArrayOrNothing<RNode<OtherInfo & import("../processing/decorate").ParentInformation>>, stop: (node: RNode<OtherInfo & import("../processing/decorate").ParentInformation>) => boolean) => Set<import("../processing/node-id").NodeId>;
readonly lexeme: <R extends RNode<import("../processing/decorate").ParentInformation>>(this: void, node: R | undefined) => R extends {
lexeme: string;
} ? string : string | undefined;
readonly documentation: typeof import("../../../../roxygen2/documentation-provider").getDocumentationOf;
};