import * as binaryen from "./wasm-encoder.js"; import type { StructuredError } from "../errors/structured-errors.js"; import type { StringTable } from "./string-table.js"; import type { TypeExpr } from "../ast/types.js"; import type { TypedModuleInfo } from "../checker/check.js"; export declare function edictTypeToWasm(type: TypeExpr): binaryen.Type; /** * Bundles the compile-wide state shared across all expression compilers. * Created once per `compile()` call. `FunctionContext` is separate because * it changes per function/lambda scope. * * `lambdaCounter` is scoped here (not module-global) so multiple * `compile()` calls in the same process don't leak state. */ export interface CompilationContext { readonly mod: binaryen.Module; readonly strings: StringTable; readonly fnSigs: Map; readonly errors: StructuredError[]; readonly constGlobals: Map; readonly recordLayouts: Map; readonly enumLayouts: Map; readonly fnTableIndices: Map; readonly tableFunctions: string[]; /** Side-table of inferred types from type checker (optional for backward compat) */ readonly typeInfo?: TypedModuleInfo; lambdaCounter: number; } export interface CompileSuccess { ok: true; wasm: Uint8Array; wat?: string; /** Debug metadata — maps WASM function names to AST nodeIds. Only present when debugMode is true. */ debugMetadata?: DebugMetadata; } /** Maps WASM function names to their AST node IDs for crash location mapping. */ export interface DebugMetadata { fnMap: Record; } export interface CompileFailure { ok: false; errors: StructuredError[]; } export type CompileResult = CompileSuccess | CompileFailure; /** Options for WASM code generation */ export interface CompileOptions { /** Maximum WASM memory pages (64KB each). Default: 16 (= 1MB) */ maxMemoryPages?: number; /** Emit WAT text alongside binary. Default: false */ emitWat?: boolean; /** Side-table of inferred types from type checker */ typeInfo?: TypedModuleInfo; /** Enable debug instrumentation — injects __trace_enter/__trace_exit calls for call stack tracking */ debugMode?: boolean; } export interface FunctionSig { returnType: binaryen.Type; paramTypes?: binaryen.Type[]; } export interface LocalEntry { index: number; type: binaryen.Type; edictTypeName?: string; /** Full Edict type — used for tuple element access type resolution */ edictType?: TypeExpr; } export interface FieldLayout { name: string; offset: number; wasmType: binaryen.Type; } export interface EnumVariantLayout { name: string; tag: number; fields: FieldLayout[]; totalSize: number; } export interface EnumLayout { variants: EnumVariantLayout[]; } export interface RecordLayout { fields: FieldLayout[]; totalSize: number; } /** * Manages per-function local variables and their WASM indices. * Compile-wide state (layouts, globals, table indices) lives in * `CompilationContext` — not here. */ export declare class FunctionContext { private nextIndex; private locals; readonly varTypes: binaryen.Type[]; constructor(params: { name: string; wasmType: binaryen.Type; edictTypeName?: string; edictType?: TypeExpr; }[]); getLocal(name: string): LocalEntry | undefined; addLocal(name: string, type: binaryen.Type, edictTypeName?: string, edictType?: TypeExpr): number; } //# sourceMappingURL=types.d.ts.map