/** * `for` and `while`, and the `break`/`continue` that leave them: the loop * slots' types, the back-edge pass each body earns, and what a loop's exit * still knows. * * D114 R1f: the loop statement forms leave `analyzer.ts`. The back-edge * machinery itself already lives in `flow/loops.ts`; what moves here is the * statement analysis that pushes a context onto it, so the two halves of a * loop — its flow bookkeeping and its syntax — each have one home. */ import { type BindingPattern, type Expression, type ForStatement, type Statement } from "../../ast.ts"; import { type CollectionRuntimeKind } from "../../contracts.ts"; import { type PermanentNamespaceName } from "../../core-vocabulary.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type ValueType } from "../../types.ts"; import { type FlowFactInvalidations, type FlowFactsSnapshot } from "../flow/facts.ts"; import { type LoopBackEdgeOutcome, type LoopFlowContext } from "../flow/loops.ts"; import { type PendingScopeDeclaration, type VisibleScopeDepth } from "../scopes.ts"; /** The lowering facts a loop records for the emitter. */ export interface LoopLoweringFacts { readonly asyncForStatements: Set; readonly builtinValueReferences: Map; readonly collectionIterations: Map; readonly nativeRangeForStatements: Set; } /** * Everything the loop statements ask of the analyzer that hosts them, and * nothing more. The walk state a loop moves — the loop depth, the scope stack's * pending declarations, the contexts the back-edge pass reads — arrives as live * accessors, because a loop body is analyzed while all three are being written. */ export interface LoopStatementsHost { adviseSwappedLoopSlots(statement: ForStatement, iterable: ValueType): void; analyzeBlock(statements: readonly Statement[], narrowed?: ReadonlyMap): ReadonlyMap; analyzeIsolatedFlow(snapshot: FlowFactsSnapshot, analyze: () => void): FlowFactInvalidations; analyzeStatements(statements: readonly Statement[]): void; applyFlowInvalidations(branches: readonly FlowFactInvalidations[], includeBaseline?: boolean): void; readonly asynchronousFunctions: boolean[]; asyncPullElementType(source: ValueType, sourceSpan: Span, statementStart: number): ValueType; blockAlwaysExits(statements: readonly Statement[]): boolean; blockAlwaysReturns(statements: readonly Statement[]): boolean; clearCachedFlowTypesInSpan(sourceSpan: Span): void; collectPatternNames(pattern: BindingPattern, add: (name: string) => void): void; commonNarrowings(branches: readonly ReadonlyMap[]): ReadonlyMap; readonly constructorDepth: number; declarePattern(pattern: BindingPattern, mutable: boolean, type: ValueType, declaredType?: ValueType): void; readonly diagnostics: Diagnostic[]; enterScope(): void; exitScope(): void; readonly finallyLoopDepths: number[]; flowInvalidationsSince(snapshot: FlowFactsSnapshot): FlowFactInvalidations; readonly functionDepth: number; inferAnnotationFreeHead(expression: Expression): ValueType; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; invalidExtensionAwaitContext(): boolean; invalidExtensionAwaitMessage(): string | null; iterationGuidance(type: ValueType): string; iterationSource(expression: Expression, type: ValueType): ValueType; joinedNarrowings(left: ReadonlyMap, right: ReadonlyMap): ReadonlyMap; readonly loopCaptureFloor: number; readonly loopContexts: LoopFlowContext[]; loopDepth: number; readonly lowering: LoopLoweringFacts; narrowingFor(expression: Expression, knownType?: ValueType): ReadonlyMap; narrowingsForVisibleBindings(visible: VisibleScopeDepth): ReadonlyMap; negativeNarrowingFor(expression: Expression, knownType?: ValueType): ReadonlyMap; readonly nonFallthroughWhileStatements: Set; readonly pendingScopeDeclarations: Map[]; persistNarrowings(narrowed: ReadonlyMap): void; readonlyDataViewOf(type: ValueType): ValueType; reanalyzeLoopBackEdge(baseline: FlowFactsSnapshot, visible: VisibleScopeDepth, backEdges: readonly FlowFactInvalidations[], body: readonly Statement[], diagnosticStart: number, analyze: () => void): LoopBackEdgeOutcome; requireCondition(type: ValueType, condition: Expression): void; snapshotFlowFacts(): FlowFactsSnapshot; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; validateKnownBindingShape(pattern: BindingPattern, value: Expression): void; visibleBindings(): VisibleScopeDepth; } export declare class LoopStatements { private readonly host; constructor(host: LoopStatementsHost); analyzeForStatement(statement: Extract): void; /** * What the two `for` slots hold: `value, index` for the synchronous forms, and * the pulled element with its ordinal for `async for`. */ private loopSlotTypes; analyzeWhileStatement(statement: Extract): void; analyzeBreakStatement(statement: Extract | Extract): void; } //# sourceMappingURL=loops.d.ts.map