/** * Runtime `Type` declaration emission: the validator and the copier a record, * alias or enum declaration compiles to, and the copy plans a nested record * shares between them. */ import type { EnumDeclaration, Program, TypeAliasDeclaration, TypeDeclaration, TypeSyntax, TypeReference } from "../ast.ts"; import { type GenericApplication, type ValueType } from "../types.ts"; import { type LoweringHints } from "../contracts.ts"; export interface TypeValidatorEmitterHost { readonly moduleAccess: import("./module-access.ts").ModuleAccessEmitter; readonly copyPlanDeclarations: string[]; copyPlanProbe: boolean; readonly copyPlans: Map; emitTypeCheck(type: ValueType, value: string, state?: string): string; enumAliasTarget(name: string, seen?: readonly string[]): string | null; readonly expandedRuntimeTypes: Set; readonly externModuleExports: Map>; genericCopyPlanNames: Map | null; genericCopyPlans: string[] | null; genericInstanceExpression(application: GenericApplication): string; genericTypeBinding(name: string): boolean; genericTypeParameters: readonly string[] | null; readonly hints: LoweringHints; needsRuntimeTypeHelpers: boolean; pendingGenericCopyPlans: readonly string[]; resolveDeclarationType(reference: TypeReference): ValueType; runtimeTypeBinding(name: string): boolean; runtimeTypeCheckName(name: string): string; runtimeTypeNeedsTraversalGuard(name: string): boolean; runtimeTypeObjectExpression(type: ValueType): string | null; readonly runtimeTypes: Set; readonly typeDeclarations: Map; readonly typeCheckDeclarations: string[]; typeTextExpression(type: ValueType, syntax: TypeSyntax | null): string; } export declare class TypeValidatorEmitter { private readonly host; constructor(host: TypeValidatorEmitterHost); collectDeclarations(program: Program): void; markRuntimeType(type: ValueType): void; markRuntimeNarrowingType(type: ValueType, structural?: Set): void; emitTypeDeclaration(statement: TypeDeclaration, depth: number): string; private emitRecordTypeDeclaration; /** * A lazy diagnostic plan preserves declaration bindings across module and * generic boundaries. The shared failure walker reads it only after is() * refuses, without running parse(), copying data, or invoking getters. */ private recordExplainLines; /** * The Type object itself: `is`, `parse` and `copy`, plus the metadata the * registry and a validation error read off it. */ private recordTypeObjectLines; /** * A generic record's emission (D55 rule 121). Its checker, copier and copy * plan are built per instantiation rather than once, because each reads the * arguments the instantiation was applied to. */ private emitGenericRecordType; /** The record predicate itself: identical for a plain record and a generic one but for the arguments it carries. */ private recordCheckFunctionLines; private runtimeTypeCopyName; /** * D90 rule R5: the record's copy — one fresh object per source object *and* * declared type, with every declared field rebuilt. The plan the caller is * copying under is threaded in and passed on to the base, so a value reached * once as `Base` and once as `Derived` in the same parse is two copies, each * complete for its own type, rather than the base's copy with the derived * fields written over it. Within one plan a base still builds the object and * records it, and the derived fields land on that same copy, so one source * object still maps to exactly one copy however deep the chain is. */ private recordCopyFunctionLines; /** * D90 rule R5: the module-level function that carries one copy plan, or null * when the position rebuilds nothing. Interning is by the plan's own emitted * text — which is what the plan means, module-locally — so two positions that * copy the same shape share one plan and one memo entry, and two that copy * different shapes can never be handed each other's copy. */ private copyPlanName; /** * One copy plan's body. A container names itself where its memo key goes, * because the copy it files is the one a later visit under the same plan must * find — including the visit that reaches it through its own elements. */ private copyPlanBody; /** Whether a position rebuilds anything, asked without interning the plan it would need. */ private typeCopiesAnything; /** * D90 rule R5: the expression that rebuilds one validated position, or null * when the position has nothing to copy — a primitive, an enum member, a * class instance, or an opaque `unknown`. The copy follows the declared * shape rather than the value, so an `unknown` field keeps handing back the * reference the author was given: copying an opaque value structurally would * change what parse returns. */ private typeCopyExpression; /** The per-element copy a container hands its runtime helper, or `null` when the element position has nothing to copy. */ private typeCopyCallback; emitTypeAliasDeclaration(statement: TypeAliasDeclaration, depth: number): string; emitEnumDeclaration(statement: EnumDeclaration, depth: number): string; } //# sourceMappingURL=validators.d.ts.map