import { AliasElem, ExtendsElem, FnElem, StructElem, StructMemberElem, TreeImportElem, VarElem } from './AbstractElems.js'; import { GeneratorModule } from './ModuleRegistry.js'; import { ParsedRegistry } from './ParsedRegistry.js'; import { TextModule } from './ParseModule.js'; /** * A wrapper around a wgsl element targeted for inclusion in the link * There is one FoundRef per unique target element. * . Multiple references to a single target element share the same FoundRef. * . But multiple versions of a target element from generic expansion * result in multiple FoundRefs. */ export type FoundRef = TextRef | GeneratorRef; export type StringPairs = [string, string][]; interface FoundRefBase { /** proposed name to use for this referent, either fn/struct name or 'as' name from the import. * name might still be rewritten by global uniqueness remapping */ proposedName: string; /** rename needed for the referent element due to the global uniqueness mapping */ rename?: string; } export interface ExportInfo { /** reference that led us to find this ref */ fromRef: FoundRef; /** import or extends elem that resolved to this export (so we can later separate out extends) */ fromImport: ExtendsElem | TreeImportElem; /** mapping from export arguments to import arguments * (could be mapping to import args prior to this import, via chain of importing) */ expImpArgs: [string, string][]; } export interface GeneratorRef extends FoundRefBase { kind: "gen"; expInfo: ExportInfo; /** module containing the exported function */ expMod: GeneratorModule; /** name of the generated function (may be renamed by import as) */ name: string; mergeRefs?: undefined; } /** A reference to a target wgsl element (e.g. a function). */ export interface TextRef extends FoundRefBase { kind: "txt"; /** module containing the referenced element */ expMod: TextModule; /** referenced element */ elem: FnElem | StructElem | VarElem | AliasElem | StructMemberElem; /** extra data if the referenced element is from another module */ expInfo?: ExportInfo; /** refs to extends elements on this struct element * (added in a post processing step after traverse) */ mergeRefs?: TextRef[]; } /** * Recursively walk through all imported references starting from a src module, calling * a function for each reference to an addressable wgsl element (fn, struct, etc.). * * Note that the reference graph may have multiple references to the same src element. * (Currently the linker will recurse through the the same node multiple times * to handle varied import parameters.) */ export declare function traverseRefs(srcModule: TextModule, registry: ParsedRegistry, fn: (ref: FoundRef) => void): void; export declare function textRefs(refs: FoundRef[]): TextRef[]; export declare function refName(ref: FoundRef): string; export {};