import { TreeImportElem } from './AbstractElems.js'; import { ModuleExport } from './ModuleRegistry.js'; import { ParsedRegistry } from './ParsedRegistry.js'; import { TextModule } from './ParseModule.js'; import { StringPairs } from './TraverseRefs.js'; /** * Maps to resolve imports to exports. * * We could be bringing two different things into scope when we import mymod::foo * 1) an exported function, used as foo() * 2) a module path, used as foo::bar() (or foo.bar()) * * Two maps are provided: * . from (caller) import path to export path (taking into account 'import as' renaming) * . from export path to exported wgsl element * * For module paths that don't resolve immediately to a wgsl element, * we expect to resolve them to wgsl elements later when combined with * a reference site suffix, e.g.: * import pkg::a as b // pkg::b -> pkg::a map import path to export path * fn foo() { b::bar(); } // can now resolve to exported element pkg::a::bar */ export interface ResolveMap { pathsMap: Array<[string[], string]>; exportMap: Map; } declare class ExportPathToExport { exportPath: string; modExp: ModuleExport; expImpArgs: StringPairs; constructor(exportPath: string, modExp: ModuleExport, expImpArgs: StringPairs); } /** Expand all imports paths to their corresponding export paths * and from the export path to the exported element (fn, struct var) if possible. * * Wildcards and path lists are fully expanded. * * @returns a ResolveMap */ export declare function importResolutionMap(importingModule: TextModule, imports: TreeImportElem[], registry: ParsedRegistry): ResolveMap; export {};