/** * `x = value`, `x.field = value`, `x[key] = value`: what may be written to, * what the written value is judged against, and the flow facts a write * establishes or retracts. * * D115 §三: this was `analyzeAssignment` (208 lines) and the one helper it * reads. It is split here into the three targets it always distinguished — a * name, a member, and an index — so each is a screen rather than a scroll. The * three write one record of target facts between them, which is what the one * method's three `let`s were, and the value half that reads those facts runs * exactly where it ran before. */ import { type AssignmentStatement, type AssignmentTarget, type Expression } from "../../ast.ts"; import { type ClassField, type ClassInfo } from "../../contracts.ts"; import { type Diagnostic, type DiagnosticFix } from "../../diagnostic.ts"; import { type Span } from "../../source.ts"; import { type ValueType } from "../../types.ts"; import { LoweringRecorder } from "../lowering-recorder.ts"; import { type Binding, type MutableCellTarget } from "../scopes.ts"; /** What an assignment statement asks of the analyzer that hosts it, and nothing more. */ export interface AssignmentAnalysisHost { bindingScopeDepth(name: string): number; carriedOwnedResource(expression: Expression | null): { readonly handle: string; readonly depth: number; } | null; checkShadowedRead(name: string, span: Span): void; classInfo(key: string): ClassInfo | undefined; readonly constructorFieldInitializations: Set; contextuallyAssignable(actual: ValueType, expected: ValueType, valueSpan: Span): boolean; readonly currentClass: string | null; dataFieldIsReadonly(original: ValueType, property: string): boolean; readonly diagnostics: Diagnostic[]; establishAssignedFact(name: string, assigned: ValueType): void; establishAssignedMemberFact(target: Extract, assigned: ValueType, declaredMemberType: ValueType): void; expandAliases(type: ValueType, seen?: ReadonlySet): ValueType; fieldsOf(identity: string): ReadonlyMap | null; findField(className: string, name: string): ClassField | null; findGetter(className: string, name: string): { readonly owner: string; readonly type: ValueType; readonly abstract: boolean; } | null; findMethod(className: string, name: string): { readonly owner: string; readonly type: ValueType; readonly abstract: boolean; } | null; findStaticField(className: string, name: string): ClassField | null; findStaticGetter(className: string, name: string): ValueType | null; findStaticMethod(className: string, name: string): ValueType | null; readonly importedBindingOrigins: Map; inferExpression(expression: Expression, contextualType?: ValueType): ValueType; inferMember(objectExpression: Expression, property: string, optional: boolean, memberSpan: Span, useNarrowing?: boolean, readValue?: boolean): ValueType; inferredOrAnalyze(expression: Expression): ValueType; invalidateAliasableMemberNarrowings(target: Extract): void; invalidateAssignmentNarrowings(target: AssignmentTarget, binding: Binding | null): void; invalidateShadowedNarrowings(name: string, target: Binding | null): void; lookup(name: string): Binding | null; readonly lowering: LoweringRecorder; readonly primitiveMutableFields: Map>; readonly primitiveNames: Set; readonly primitiveParents: Map>; privateFieldForAccess(className: string, name: string, staticMember: boolean): ClassField | null; readonly privateGetters: Map>; privateMethodForAccess(className: string, name: string, staticMember: boolean): ValueType | null; readonlyFieldsOf(identity: string): ReadonlySet | null; recordFlowFactOrigin(binding: Binding): void; rejectOwnedResourceEscape(expression: Expression | null, action: string, errorSpan: Span): boolean; reportUnresolvedName(name: string, span: Span): void; requireAssignable(actual: ValueType, expected: ValueType, valueSpan: Span, mutableCell?: MutableCellTarget | null): void; typeError(message: string, errorSpan: Span, fix?: DiagnosticFix): void; } export declare class AssignmentAnalysis { private readonly host; constructor(host: AssignmentAnalysisHost); analyzeAssignment(statement: AssignmentStatement): void; /** * A bare name: the binding it resolves to, whether it may be written, and * the declared type a plain `=` is judged against. Answers false when the * name resolves to nothing, which is the whole of the assignment. * * D115 §三 split this out of `analyzeAssignment`; the checks and their order * are unchanged. */ private resolveNameTarget; /** * A member: what the owner publishes under that name, and the eight ways a * member can be unwritable — a private getter or const field, a private * method, a const field, a getter, a method, a read-only view, a read-only * field, and a primitive member no extension made writable. * * D115 §三 split this out of `analyzeAssignment`; the checks and their order * are unchanged. */ private resolveMemberTarget; /** * An index: the four receivers a bracket assignment is defined for — a * binary view, a List, a Record, and the Map that is refused in favour of * `Map.set` — and the index type each of them requires. * * D115 §三 split this out of `analyzeAssignment`; the checks and their order * are unchanged. */ private resolveIndexTarget; private primitiveFieldWritable; } //# sourceMappingURL=assignment.d.ts.map