import { KeyedSet, FlexSet, Position, DictionaryMap } from "@preserves/core"; import * as M from "../meta.js"; import { Item } from "./block.js"; import { RefType, SimpleType, Type } from "./type.js"; export interface CompilerOptions { preservesModule?: string; defaultEmbeddedType?: M.Ref; warn?(message: string, pos: Position | null): void; } export interface Capture { fieldName: string; sourceExpr: string; } export declare const RECURSION_LIMIT = 128; export declare class ModuleContext { readonly env: M.Environment; readonly modulePath: M.ModulePath; readonly schema: M.Schema; readonly options: CompilerOptions; readonly embeddedType: Item; readonly literals: DictionaryMap; readonly preamble: Item[]; readonly typedefs: Item[]; readonly functiondefs: Item[]; readonly imports: KeyedSet; constructor(env: M.Environment, modulePath: M.ModulePath, schema: M.Schema, options: CompilerOptions); literal(v: M.Input): Item; derefPattern(p: M.Definition, refCount?: number): M.Definition; definePreamble(i: Item): void; defineType(f: Item): void; defineFunctions(definitionName: string, f: (ctx: FunctionContext) => Item[]): void; resolver(modulePath?: M.ModulePath): (ref: M.Ref) => RefType; lookupType(name: M.Ref, modulePath?: M.ModulePath): Type | null; lookup(name: M.Ref, kLocal: (p: M.Definition, t: () => Type) => R, kOther: (modPath: M.ModulePath, modId: string, modFile: string, modExpr: string, p: M.Definition | null, t: (() => Type) | null) => R, modulePath?: M.ModulePath): R; genericParameters(): Item; genericParametersFor(t: Type): Item; genericArgs(): Item; genericArgsFor(t: Type): Item; hasEmbedded(t: Type): boolean; } export declare class FunctionContext { readonly mod: ModuleContext; readonly definitionName: string; tempCounter: number; temps: Map; captures: Capture[]; variantName: string | undefined; constructor(mod: ModuleContext, definitionName: string); gentempname(): string; gentemp(vartype?: Type): string; block(f: () => Item[]): Item; withCapture(fieldName: string | undefined, valueType: SimpleType, sourceExpr: string, ks: (sourceExpr: string) => R): R; convertCapture(fieldName: string | undefined, valueType: SimpleType, sourceExpr: string, ks: () => Item[]): Item; buildCapturedCompound(dest: string): Item; } export declare function buildProduct(definitionName: string, variant: string | undefined, initializers: Capture[]): Item; export declare class WalkState { modulePath: M.ModulePath; readonly seen: FlexSet; constructor(modulePath: M.ModulePath); cycleCheck(r0: M.Ref, step: (ref: M.Ref) => E, ks: (e: E) => R, kf: () => R): R; }