@mojir/lits
Version:
Lits is a pure functional programming language implemented in TypeScript
38 lines (37 loc) • 1.63 kB
TypeScript
import type { Any } from '../interface';
import type { ContextParams } from '../Lits/Lits';
import type { LitsModule } from '../builtin/modules/interface';
import type { NativeJsFunction, SymbolNode, UserDefinedSymbolNode } from '../parser/types';
import type { SourceCodeInfo } from '../tokenizer/token';
import type { Context, LookUpResult } from './interface';
export type ContextStack = ContextStackImpl;
export declare class ContextStackImpl {
private contexts;
globalContext: Context;
private values?;
private nativeJsFunctions?;
private modules;
private valueModules;
pure: boolean;
constructor({ contexts, values: hostValues, nativeJsFunctions, modules, valueModules, pure, }: {
contexts: Context[];
values?: Record<string, unknown>;
nativeJsFunctions?: Record<string, NativeJsFunction>;
modules?: Map<string, LitsModule>;
valueModules?: Map<string, unknown>;
pure?: boolean;
});
getModule(name: string): LitsModule | undefined;
getValueModule(name: string): {
value: unknown;
found: boolean;
};
registerValueModule(name: string, value: unknown): void;
create(context: Context): ContextStack;
new(context: Context): ContextStack;
addValues(values: Record<string, Any>, sourceCodeInfo: SourceCodeInfo | undefined): void;
getValue(name: string): unknown;
lookUp(node: UserDefinedSymbolNode): LookUpResult;
evaluateSymbol(node: SymbolNode): Any;
}
export declare function createContextStack(params?: ContextParams, modules?: Map<string, LitsModule>, pure?: boolean): ContextStack;