import { IntrinsicFunctionDeclaration } from './declaration'; import { Definition, Expression, FunctionDefinition, FunctionParameter, StructDefinition, VariableDefinition } from './expression'; import { StructDescriptor, Type } from './types'; export declare class IntrinsicFunctionDefinition { readonly type = "intrinsic-function"; readonly name: string; readonly parameters: readonly FunctionParameter[]; readonly varArgs: FunctionParameter | undefined; readonly assert: Expression; readonly fn: (scope: Scope, ...args: Type[]) => Type; constructor(name: string, fn: (scope: Scope, ..._: Type[]) => Type, parameters: readonly FunctionParameter[], varArgs?: FunctionParameter, assert?: Expression); static from({ name, parameters, varArgs, assert }: IntrinsicFunctionDeclaration, fn: (scope: Scope, ...args: Type[]) => Type): IntrinsicFunctionDefinition; } export declare class ParameterDefinition { readonly type = "parameter"; readonly name: string; readonly value: Type; constructor(name: string, value?: Type); } export declare type ScopeBuilderDefinition = Definition | IntrinsicFunctionDefinition | ParameterDefinition; export declare class ScopeBuilder { name: string; parent: Scope | undefined; private readonly definitions; private readonly descriptors; constructor(name: string, parent?: Scope); private assertNameAvailable; private assertCompatibleStructDescriptor; add(definition: ScopeBuilderDefinition): void; addStructDescriptor(descriptor: StructDescriptor): void; createScope(): Scope; } declare type ScopeDefinition = ScopeStructDefinition | ScopeFunctionDefinition | ScopeVariableDefinition | ScopeIntrinsicFunctionDefinition | ScopeParameterDefinition; export interface ScopeStructDefinition { readonly type: 'struct'; readonly definition: StructDefinition; descriptor?: StructDescriptor; } export interface ScopeFunctionDefinition { readonly type: 'function'; readonly definition: FunctionDefinition; parameters?: readonly Type[]; assert?: Type; varArgs?: undefined; } export interface ScopeVariableDefinition { readonly type: 'variable'; readonly definition: VariableDefinition; assert?: Type; value?: Type; } export interface ScopeParameterDefinition { readonly type: 'parameter'; readonly definition: ParameterDefinition; value: Type; } export interface ScopeIntrinsicFunctionDefinition { readonly type: 'intrinsic-function'; readonly definition: IntrinsicFunctionDefinition; parameters?: readonly Type[]; varArgs?: Type; } export declare class NameResolutionError extends Error { similar: string[]; constructor(message: string, similar: string[]); } export declare class ParameterAssignmentError extends Error { } export interface ResolvedName { definition: D; scope: Scope; } export declare class Scope { readonly name: string; readonly parent: Scope | undefined; private readonly definitions; constructor(name: string, parent: Scope | undefined, definitions: Iterable, structDescriptors: ReadonlyMap); private static toScopeDefinition; private getOptional; has(name: string): boolean; get(name: string): ResolvedName; assignParameter(name: string, value: Type): void; /** * Returns a iterable of all definition in this scope, not including parent scopes. */ entries(): Iterable<[string, ScopeDefinition]>; } export {};