UNPKG

js-slang

Version:

Javascript-based implementations of Source, written in Typescript

34 lines (33 loc) 1.95 kB
import { Chapter, type Context, type CustomBuiltIns, type Environment, type LanguageOptions, type Value, Variant } from './types'; export declare class EnvTree { private _root; private map; get root(): EnvTreeNode | null; insert(environment: Environment): void; getTreeNode(environment: Environment): EnvTreeNode | undefined; } export declare class EnvTreeNode { readonly environment: Environment; parent: EnvTreeNode | null; private _children; constructor(environment: Environment, parent: EnvTreeNode | null); get children(): EnvTreeNode[]; resetChildren(newChildren: EnvTreeNode[]): void; private clearChildren; private addChildren; addChild(newChild: EnvTreeNode): EnvTreeNode; } export declare const createGlobalEnvironment: () => Environment; export declare const createEmptyContext: <T>(chapter: Chapter, variant: Variant | undefined, languageOptions: LanguageOptions | undefined, externalSymbols: string[], externalContext?: T | undefined) => Context<T>; export declare const ensureGlobalEnvironmentExist: (context: Context) => void; export declare const defineSymbol: (context: Context, name: string, value: Value) => void; export declare function defineBuiltin(context: Context, name: string, // enforce minArgsNeeded value: Value, minArgsNeeded: number): void; export declare function defineBuiltin(context: Context, name: string, value: Value, minArgsNeeded?: number): void; export declare const importExternalSymbols: (context: Context, externalSymbols: string[]) => void; /** * Imports builtins from standard and external libraries. */ export declare const importBuiltins: (context: Context, externalBuiltIns: CustomBuiltIns) => void; declare const createContext: <T>(chapter?: Chapter, variant?: Variant, languageOptions?: LanguageOptions, externalSymbols?: string[], externalContext?: T | undefined, externalBuiltIns?: CustomBuiltIns) => Context; export default createContext;