import type { ParseResult, SourceSpan } from "../parse.js"; import { type InterpreterYieldPoint } from "./async.js"; import type { GeneratorCompletion } from "./generator.js"; import { Budget } from "./budget.js"; import { type SandboxValue } from "./values.js"; import { Scope } from "./scope.js"; export type InterpreterValue = SandboxValue; export type InterpreterStats = { nodeVisits: number; currentDataSize: number; peakDataSize: number; }; export type InterpreterSnapshot = { bindings: Record; loopIterations?: Record; }; export type LoopIterationSnapshot = number | { index: number; values: InterpreterValue[]; }; export type InterpreterErrorCode = "LABEL_NOT_FOUND" | "UNBOUND_IDENTIFIER" | "UNSUPPORTED_NODE"; export type InterpreterError = { code: InterpreterErrorCode; message: string; name: string; nodeId?: number; nodeType: ParseResult["type"]; span: SourceSpan; stack: string; }; export type InterpreterResult = { ok: true; returnValue?: InterpreterValue; snapshot: InterpreterSnapshot; stats: InterpreterStats; } | { ok: false; error: InterpreterError; snapshot: InterpreterSnapshot; stats: InterpreterStats; }; export type InterpretOptions = { bindings?: Record; budget?: Budget; onYield?: (yieldPoint: InterpreterYieldPoint) => void; scope?: Scope; surfaceUnhandledThrows?: boolean; useScopeDirectly?: boolean; generatorYield?: (value?: SandboxValue, yieldNodeId?: number) => Promise; generatorResume?: { sent: GeneratorCompletion[]; yieldNodeId: number; }; snapshot?: InterpreterSnapshot; }; export declare function interpret(node: ParseResult, options?: InterpretOptions): Promise; export { Scope } from "./scope.js";