@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
52 lines (51 loc) • 2.38 kB
TypeScript
import type { BuiltInMappingName, ConfigOfBuiltInMappingName } from './built-in';
import type { Identifier } from './identifier';
export interface BaseBuiltInDefinition {
/** The type of the built-in configuration */
readonly type: string;
/** The function name to define to the given configuration */
readonly names: readonly Identifier[];
/** Should we assume that the value is a primitive? */
readonly assumePrimitive?: boolean;
}
/**
* Define a built-in constant (like `NULL` or `TRUE`) and the TS value it should have
*
* @template Value - The type of the constant value
*/
export interface BuiltInConstantDefinition<Value> extends BaseBuiltInDefinition {
readonly type: 'constant';
/** The constant value to define */
readonly value: Value;
}
/**
* Define a built-in function (like `print` or `c`) and the processor to use.
*
* @template BuiltInProcessor - The processor to use for this function
*/
export interface BuiltInFunctionDefinition<BuiltInProcessor extends BuiltInMappingName> extends BaseBuiltInDefinition {
readonly type: 'function';
readonly processor: BuiltInProcessor;
readonly config?: ConfigOfBuiltInMappingName<BuiltInProcessor>;
readonly evalHandler?: string;
}
/**
* Define a built-in replacement (like `[` or `$`) and the processor to use.
* This is a convenience for manually combined function calls with `builtin:replacement`.
*/
export interface BuiltInReplacementDefinition extends BaseBuiltInDefinition {
readonly type: 'replacement';
readonly suffixes: readonly ('<<-' | '<-')[];
readonly config: {
readIndices: boolean;
};
}
export type BuiltInDefinition = BuiltInConstantDefinition<any> | BuiltInFunctionDefinition<any> | BuiltInReplacementDefinition;
/**
* @see DefaultBuiltinConfig
*/
export type BuiltInDefinitions = readonly BuiltInDefinition[];
export declare function registerBuiltInFunctions<BuiltInProcessor extends BuiltInMappingName>({ names, processor, config, assumePrimitive }: BuiltInFunctionDefinition<BuiltInProcessor>): void;
export declare function registerReplacementFunctions({ names, suffixes, assumePrimitive, config }: BuiltInReplacementDefinition): void;
export declare function registerBuiltInDefinition(definition: BuiltInDefinition): void;
export declare function registerBuiltInDefinitions(definitions: BuiltInDefinitions): void;