/** * What a class name stands for: its shape table, its type parameters, the * instantiations of it a module reaches, and the extern classes a foreign * module declares. * * D114 R1d: the registration half of the class cluster. `classes`, * `classApplications`, `classInstantiations` and `classDeclarations` stay * fields of `Analyzer` — every other cluster reads them — and arrive here * through the shared class host. */ import { type ClassDeclaration, type ClassIterateBlock, type Expression, type FunctionDeclaration, type Program, type Statement, type TypeParameterDeclaration, type TypeReference } from "../../ast.ts"; import { type ClassField, type ClassInfo } from "../../contracts.ts"; import { type Diagnostic } from "../../diagnostic.ts"; import { type GenericApplication, type TypeParameterBound, type ValueType } from "../../types.ts"; import { type GenericDeclarations } from "../declarations/generics.ts"; /** * Everything this half of the class cluster asks of the analyzer that hosts * it. The four halves share one host object; the union of their interfaces is * what the analyzer builds. */ export interface ClassRegistryHost { readonly classApplications: Map; readonly classDeclarations: Map; readonly classInstantiations: Map; classShapesRegistered: boolean; readonly classes: Map; readonly diagnostics: Diagnostic[]; extensionExpressionContainsDirectAwait(expression: Expression, contains: (expression: Expression) => boolean): boolean | undefined; extensionStatementContainsDirectAwait(statement: Statement, containsExpression: (expression: Expression) => boolean, containsBlock: (statements: readonly Statement[]) => boolean): boolean | undefined; readonly externClassDeclarations: Map>; functionType(statement: FunctionDeclaration, classParameters?: readonly TypeParameterDeclaration[]): ValueType; readonly generics: GenericDeclarations; readonly invalidExternTypeReferences: WeakSet; readonly privateFields: Map>; readonly privateGetters: Map>; readonly privateMethods: Map>; readonly privateStaticFields: Map>; readonly privateStaticGetters: Map>; readonly privateStaticMethods: Map>; resolveAnnotation(reference: TypeReference | null): ValueType; resolveExternAnnotation(reference: TypeReference | null, source: string, classNames: ReadonlySet): ValueType; resolveValidatedAnnotation(reference: TypeReference | null): ValueType; resolveValidatedResult(reference: TypeReference | null): ValueType; seededIterationInfo(block: ClassIterateBlock): { readonly iterate: ValueType; } | { readonly iterateAsync: ValueType; }; staticMemberTypeParameters: { readonly className: string; readonly names: ReadonlySet; } | null; typeParameterBoundVector(declarations: readonly TypeParameterDeclaration[] | undefined): readonly (TypeParameterBound | null)[] | null; typeParameterFrame(declarations: readonly TypeParameterDeclaration[] | undefined): ReadonlyMap; readonly typeParameterFrames: ReadonlyMap[]; validateTypeReference(reference: TypeReference, resolve?: (reference: TypeReference) => ValueType): boolean; withTypeParameterFrame(frame: ReadonlyMap, action: () => T): T; } export declare class ClassRegistry { private readonly host; constructor(host: ClassRegistryHost); registerClassNames(program: Program): void; /** D55 rule 120 layer two: the declared parameter list of a class, as the class entry carries it. */ classTypeParameterFacts(statement: ClassDeclaration): { readonly typeParameterNames?: readonly string[]; readonly typeParameterBounds?: readonly (TypeParameterBound | null)[]; }; /** The class type parameters in scope for a member of `className`, or undefined outside a generic class. */ classTypeParameterDeclarations(className: string | null): readonly TypeParameterDeclaration[] | undefined; /** * D55 rule 120 layer two: the frame a class member is resolved under. The * member's own parameters take the low indexes and the class's take the ones * above them, so a method may declare `` beside the class's `` and the * two never share a De Bruijn index. The order matters and is this way round * for one reason: a callable's `typeParameterNames` must line up with index * 0 upward, and only the member's own parameters belong on that list — the * class's are fixed by the receiver, not solved at the call. Everything above * `typeParameterNames.length` is therefore a class parameter, in every * member, whatever its own arity, which is what lets one substitution rule * serve them all (`substituteClassMemberType`). */ memberTypeParameterFrame(classParameters: readonly TypeParameterDeclaration[] | undefined, ownParameters: readonly TypeParameterDeclaration[] | undefined): ReadonlyMap; registerClassShapes(program: Program): void; registerClassShape(statement: ClassDeclaration): void; /** * D55 rule 120 layer two: the class entry behind a key, building the * instantiation the key names if that is what it is. Every question about a * class member goes through here rather than through `this.host.classes`, so a * generic class's members can never be read with their parameters still in * them. */ classInfo(key: string): ClassInfo | undefined; /** Records an instantiation so `classInfo` can build its member table when asked. */ noteClassApplication(identity: string, application: GenericApplication): void; /** * D55 rule 121's mechanism on the class side: an instantiation's member table * is the declaration's with the arguments substituted, keyed by the * instantiation's own identity. Building it on demand rather than where the * application was written is what makes `class Node: let next: Node?` * terminate — the application is noted while the declaration is still being * read, and substituted only once someone asks. */ buildClassInstantiation(identity: string): ClassInfo | undefined; /** * Substitutes the class's own type arguments into one member type. A method * that declares its own `` carries both lists — the class's first — so the * substitution replaces the class's indexes and renumbers the method's own * back down to zero, which is exactly what makes `Stack.mapTo` * a one-parameter generic method again. */ substituteClassMemberType(type: ValueType, bindings: readonly ValueType[]): ValueType; /** * D55 rule 120 layer two: `self` inside a generic class is that class at its * own parameters. The arguments are read out of the frame in force here, * because a class parameter's index depends on how many the member itself * declared — which is exactly what makes `self.push(value)` compare `T` * against the same `T` the annotation resolved to. */ selfClassType(className: string): ValueType; /** The method type of a class member, read under the class's type parameters as well as its own. */ classMethodType(statement: ClassDeclaration, method: ClassDeclaration["methods"][number]): ValueType; /** * D55 rule 120 layer two: `extends Stack` resolved under this class's * own parameters, so `class MyStack extends Stack` passes them through * and instantiating `MyStack` reaches `Stack`. */ resolvedClassBaseApplication(statement: ClassDeclaration): GenericApplication | undefined; /** The arguments a receiver's chain applies to one declaration in it. */ classApplicationFor(receiverKey: string, declarationKey: string): GenericApplication | null; registerExternClassDeclarations(program: Program): void; validateExternDeclarations(program: Program): void; } //# sourceMappingURL=registry.d.ts.map