/** * Where branches meet: which facts a construct's arms agree on, which of them * were still standing when a scope closed, and what a set of branch * invalidations does to the facts they all leave behind. * * D114 R1d: the merge half of the flow cluster. It was nine private methods of * `Analyzer` grouped around `VisibleScopeDepth` — the depth of the scope chain * at some earlier moment — and around `applyFlowInvalidations`, the one writer * that turns "these branches disagreed" back into "so nobody knows". They move * together because every one of them answers a question about *two* moments, * which is the thing the rest of the analyzer never asks. */ import { type ValueType } from "../../types.ts"; import { type Binding, type MemberNarrowing, type VisibleScopeDepth } from "../scopes.ts"; import { type FlowFactInvalidations, type FlowFactsSnapshot } from "./facts.ts"; /** * Everything the merge half asks of the analyzer that hosts it, and nothing * more. The scope stack and the flow-fact store move under it, so both arrive * as live getters rather than as values captured at construction. */ export interface FlowMergeHost { readonly flowFrameDepth: number; lookup(name: string): Binding | null; readonly memberNarrowings: Map[]; readonly narrowedNames: Set[]; recordFlowFactOrigin(binding: Binding): void; restoreFlowFacts(snapshot: FlowFactsSnapshot): void; readonly scopes: Map[]; } export declare class FlowMerge { private readonly host; constructor(host: FlowMergeHost); visibleBindings(): VisibleScopeDepth; /** The binding a name resolved to when `visible` was captured. */ visibleBinding(visible: VisibleScopeDepth, name: string): Binding | null; /** * Only a name a narrowing has written can carry a fact, and `narrowedNames` * is the roster of those per scope — so this walks the narrowings rather * than every name in scope. The member half matches a dotted path against * the binding its root names instead of spreading the whole root set per * path, which is O(one lookup) rather than O(names in the module). */ narrowingsForVisibleBindings(visible: VisibleScopeDepth): ReadonlyMap; /** Whether a member path's root — `:` — names a binding visible then. */ private memberNarrowingRootIsVisible; narrowingsInSnapshot(snapshot: FlowFactsSnapshot, visible: VisibleScopeDepth, restore: FlowFactsSnapshot): ReadonlyMap; commonNarrowings(branches: readonly ReadonlyMap[]): ReadonlyMap; /** * FLW-S1: a `while` is left through the condition test taken either on * entry or after the back edge, so the fact that holds afterwards is the * union of what the two tests prove. A location only one of them names is * dropped, because the other test proves nothing about it. */ joinedNarrowings(first: ReadonlyMap, second: ReadonlyMap): ReadonlyMap; /** Of the facts a scope was entered with, the ones still standing at its end. */ survivingNarrowings(narrowed: ReadonlyMap): ReadonlyMap; applyFlowInvalidations(branches: readonly FlowFactInvalidations[], includeBaseline?: boolean): void; } //# sourceMappingURL=merge.d.ts.map