/** * Initialization order: which reads run while the module itself evaluates, and * which are deferred into a function body that runs later. * * D114 R1d: the initialization half of the module cluster. The frames * (`deferredReadFrames`, `localFunctionFrames`, `arrowDeferredFrames`) stay * fields of `Analyzer`, because the statement dispatch pushes and pops them. */ import { type Expression, type BindingPattern } from "../../ast.ts"; import { type InitializationImportRead } from "../../contracts.ts"; import { type Span } from "../../source.ts"; import { type Binding } from "../scopes.ts"; /** * A deferred body — a module-local `def` or an arrow bound to a module-local * name — with the imported bindings it reads and the local functions it calls. * Calls are held as bindings rather than as resolved frames because a `def` is * hoisted: `const x = pull()` may be analyzed before `def pull()` is. */ export interface DeferredReadFrame { readonly reads: InitializationImportRead[]; readonly calls: Binding[]; } /** * Everything this half of the module cluster asks of the analyzer that hosts * it. The three halves share one host object. */ export interface ModuleInitializationHost { readonly arrowDeferredFrames: Map; readonly deferredReadFrames: DeferredReadFrame[]; readonly importedBindingSources: Map; inModuleInitializationPosition(): boolean; readonly initializationImportReadSites: Map; readonly initializationLocalCalls: { readonly binding: Binding; readonly span: Span; }[]; readonly localFunctionFrames: Map; lookup(name: string): Binding | null; readonly scopes: Map[]; } export declare class ModuleInitialization { private readonly host; constructor(host: ModuleInitializationHost); recordInitializationImportRead(binding: Binding, local: string, span: Span): void; /** * D31 item 23: the call edge. Inside a deferred body it is an edge of the * reachability graph; at module top level it is a root, because that call * runs the callee while the module itself evaluates. The callee is held as * a binding, not as a frame — a `def` is hoisted, so `const x = pull()` can * be analyzed before `def pull()` is. */ recordDeferredCallEdge(callee: Expression, span: Span): void; /** Files an arrow's deferred frame under the module-local name it was bound to. */ claimArrowDeferredFrame(pattern: BindingPattern, initializer: Expression): void; /** * Initialization-position reads of imported bindings, for the project * module-cycle check. * * D31 item 23 recorded the indirect shape as a v1 residual: a top-level call * of a module-local function runs that body while the module evaluates, so * an imported binding read inside it is an initialization-position read too * — and following VEL3019's own remediation ("Move this read into a * function") and then calling that function at top level re-created the bare * `ReferenceError` the check exists to delete. The closure below is the * intra-module reachability pass that closes it: one module, one walk over * the call edges already collected, no cross-module analysis. * * An indirect read is reported at the *call*, not at the read. The call is * the line that runs during module evaluation and the line an author can * move; the read inside the body is already in a function, which is what the * remediation asks for. */ moduleInitializationImportReads(): readonly InitializationImportRead[]; } //# sourceMappingURL=initialization.d.ts.map