@oseo/compiler 0.0.0-stage → 0.1.0-canary.368
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +59 -2
- package/dist/agent-programs.d.ts +28 -0
- package/dist/agent-programs.d.ts.map +1 -0
- package/dist/agent-programs.js +134 -0
- package/dist/agent-programs.js.map +1 -0
- package/dist/agent-templates.d.ts +33 -0
- package/dist/agent-templates.d.ts.map +1 -0
- package/dist/agent-templates.js +45 -0
- package/dist/agent-templates.js.map +1 -0
- package/dist/compile.d.ts +20 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +75 -0
- package/dist/compile.js.map +1 -0
- package/dist/fragments.d.ts +72 -0
- package/dist/fragments.d.ts.map +1 -0
- package/dist/fragments.js +158 -0
- package/dist/fragments.js.map +1 -0
- package/dist/hir-build.d.ts +80 -0
- package/dist/hir-build.d.ts.map +1 -0
- package/dist/hir-build.js +3077 -0
- package/dist/hir-build.js.map +1 -0
- package/dist/hir-print.d.ts +10 -0
- package/dist/hir-print.d.ts.map +1 -0
- package/dist/hir-print.js +271 -0
- package/dist/hir-print.js.map +1 -0
- package/dist/hir.d.ts +1246 -0
- package/dist/hir.d.ts.map +1 -0
- package/dist/hir.js +147 -0
- package/dist/hir.js.map +1 -0
- package/dist/host-scripts.d.ts +14 -0
- package/dist/host-scripts.d.ts.map +1 -0
- package/dist/host-scripts.js +204 -0
- package/dist/host-scripts.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/mir-build.d.ts +8 -0
- package/dist/mir-build.d.ts.map +1 -0
- package/dist/mir-build.js +5113 -0
- package/dist/mir-build.js.map +1 -0
- package/dist/mir-print.d.ts +7 -0
- package/dist/mir-print.d.ts.map +1 -0
- package/dist/mir-print.js +65 -0
- package/dist/mir-print.js.map +1 -0
- package/dist/mir-specialize.d.ts +7 -0
- package/dist/mir-specialize.d.ts.map +1 -0
- package/dist/mir-specialize.js +182 -0
- package/dist/mir-specialize.js.map +1 -0
- package/dist/mir.d.ts +571 -0
- package/dist/mir.d.ts.map +1 -0
- package/dist/mir.js +1 -0
- package/dist/module-builtin.d.ts +20 -0
- package/dist/module-builtin.d.ts.map +1 -0
- package/dist/module-builtin.js +57 -0
- package/dist/module-builtin.js.map +1 -0
- package/dist/module-compile.d.ts +64 -0
- package/dist/module-compile.d.ts.map +1 -0
- package/dist/module-compile.js +690 -0
- package/dist/module-compile.js.map +1 -0
- package/dist/module-json.d.ts +7 -0
- package/dist/module-json.d.ts.map +1 -0
- package/dist/module-json.js +88 -0
- package/dist/module-json.js.map +1 -0
- package/dist/modules.d.ts +87 -0
- package/dist/modules.d.ts.map +1 -0
- package/dist/modules.js +734 -0
- package/dist/modules.js.map +1 -0
- package/dist/native-fragments.d.ts +36 -0
- package/dist/native-fragments.d.ts.map +1 -0
- package/dist/native-fragments.js +110 -0
- package/dist/native-fragments.js.map +1 -0
- package/dist/native.d.ts +282 -0
- package/dist/native.d.ts.map +1 -0
- package/dist/native.js +47 -0
- package/dist/native.js.map +1 -0
- package/dist/regexp-execute.d.ts +74 -0
- package/dist/regexp-execute.d.ts.map +1 -0
- package/dist/regexp-execute.js +480 -0
- package/dist/regexp-execute.js.map +1 -0
- package/dist/regexp-matcher.d.ts +279 -0
- package/dist/regexp-matcher.d.ts.map +1 -0
- package/dist/regexp-matcher.js +1098 -0
- package/dist/regexp-matcher.js.map +1 -0
- package/dist/regexp-parse.d.ts +22 -0
- package/dist/regexp-parse.d.ts.map +1 -0
- package/dist/regexp-parse.js +1440 -0
- package/dist/regexp-parse.js.map +1 -0
- package/dist/regexp-print.d.ts +24 -0
- package/dist/regexp-print.d.ts.map +1 -0
- package/dist/regexp-print.js +147 -0
- package/dist/regexp-print.js.map +1 -0
- package/dist/regexp.d.ts +324 -0
- package/dist/regexp.d.ts.map +1 -0
- package/dist/regexp.js +22 -0
- package/dist/regexp.js.map +1 -0
- package/dist/source.d.ts +38 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +10 -0
- package/dist/source.js.map +1 -0
- package/dist/syntax.d.ts +1232 -0
- package/dist/syntax.d.ts.map +1 -0
- package/dist/syntax.js +1 -0
- package/package.json +32 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modules.js","names":[],"sources":["../src/modules.ts"],"sourcesContent":["/*\n * Oseo, an ahead-of-time compiler for JavaScript and TypeScript.\n * Copyright (C) 2026 Hong Minhee <https://hongminhee.org/>\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\n */\n\nimport type { ByteRange, Diagnostic } from \"./source.ts\";\nimport { moduleNodeSyntax } from \"./module-builtin.ts\";\nimport { jsonModuleSyntax } from \"./module-json.ts\";\nimport type {\n LocatedSyntax,\n ModuleDependency,\n ModuleGraph,\n ModuleGraphNode,\n ModuleGraphOptions,\n ModuleGraphResult,\n ModuleLoadReferrer,\n ModuleLoader,\n ModuleLoadResult,\n ModuleResolution,\n ModuleRequestRecord,\n ModuleRequestReferrer,\n ModuleResolver,\n ModuleSourceFrontend,\n ScriptRequestReferrer,\n ScriptRequestResult,\n SyntaxImportCall,\n SyntaxImportEntry,\n SyntaxModule,\n SyntaxModuleSpecifier,\n} from \"./syntax.ts\";\n\nfunction includePropertiesWhen<const Properties extends object>(\n properties: () => Properties | undefined,\n): Properties | { [Key in keyof Properties]?: never } {\n return properties() ?? {};\n}\n\n/** Retain each syntactic request once without merging distinct source sites. */\nfunction moduleSpecifiers(\n module: SyntaxModule,\n): readonly SyntaxModuleSpecifier[] {\n const specifiers: SyntaxModuleSpecifier[] = [];\n for (const entry of module.imports) specifiers.push(entry.specifier);\n for (const entry of module.exports) {\n if (\n entry.kind === \"indirect\" ||\n entry.kind === \"namespace\" ||\n entry.kind === \"star\"\n ) {\n specifiers.push(entry.specifier);\n }\n }\n const requests = new Set<string>();\n return specifiers\n .toSorted((left, right) => left.byteRange.start - right.byteRange.start)\n .filter((specifier) => {\n const key =\n `${specifier.byteRange.start}:${specifier.byteRange.end}:` +\n specifier.value;\n if (requests.has(key)) return false;\n requests.add(key);\n return true;\n });\n}\n\n/** One request site found while parsing a referrer, before resolution. */\ninterface RequestSite {\n readonly edgeKind: ModuleRequestRecord[\"edgeKind\"];\n readonly location: LocatedSyntax & { readonly byteRange: ByteRange };\n readonly specifier: SyntaxModuleSpecifier;\n}\n\n/** The request that first brought a module into the build. */\ninterface ModuleOrigin {\n readonly edgeKind: ModuleRequestRecord[\"edgeKind\"];\n readonly location: LocatedSyntax;\n readonly referrer: ModuleRequestReferrer;\n}\n\n/** A request site whose specifier resolved to a canonical target. */\ninterface ResolvedSite extends RequestSite {\n readonly canonicalId: string;\n}\n\n/** A resolved site waiting for its target to be visited. */\ninterface PendingRequest {\n readonly origin: ModuleOrigin;\n readonly site: ResolvedSite;\n}\n\nfunction requestSites(\n module: SyntaxModule | undefined,\n importCalls: readonly SyntaxImportCall[] | undefined,\n): readonly RequestSite[] {\n const sites: RequestSite[] = [];\n if (module != null) {\n for (const specifier of moduleSpecifiers(module)) {\n sites.push({ edgeKind: \"evaluation\", location: specifier, specifier });\n }\n }\n for (const call of importCalls ?? []) {\n sites.push({\n edgeKind: \"discovery\",\n location: {\n byteRange: call.byteRange ?? call.specifier.byteRange,\n range: call.range,\n },\n specifier: call.specifier,\n });\n }\n return sites.toSorted(\n (left, right) =>\n left.location.byteRange.start - right.location.byteRange.start,\n );\n}\n\n/** A Script and a module may share an identity, so the key keeps both. */\nfunction referrerKey(referrer: ModuleRequestReferrer): string {\n return `${referrer.kind}:${referrer.id}`;\n}\n\nfunction positionText(sourceId: string, location: LocatedSyntax): string {\n const start = location.range.start;\n return `${sourceId}:${start.line}:${start.column}`;\n}\n\n/**\n * The importer chain of a module as diagnostic notes, nearest request\n * first. The chain is reported only when it, or the failing request,\n * crosses a discovery edge, so a static-only graph keeps the diagnostics\n * it reported before `import()` discovery existed.\n */\nfunction importerChainNotes(\n origins: ReadonlyMap<string, ModuleOrigin>,\n referrer: ModuleRequestReferrer,\n failing?: ModuleRequestRecord[\"edgeKind\"],\n): readonly string[] | undefined {\n const notes: string[] = [];\n let crossesDiscovery = failing === \"discovery\";\n const seen = new Set<string>();\n // A Script is a root: a module with the same identity is a different\n // record whose chain does not describe the Script.\n let origin =\n referrer.kind === \"module\" ? origins.get(referrer.id) : undefined;\n while (origin != null && !seen.has(referrerKey(origin.referrer))) {\n seen.add(referrerKey(origin.referrer));\n if (origin.edgeKind === \"discovery\") crossesDiscovery = true;\n const where = positionText(origin.referrer.id, origin.location);\n const script = origin.referrer.kind === \"script\" ? \" (Script)\" : \"\";\n notes.push(\n origin.edgeKind === \"discovery\"\n ? `requested by import() at ${where}${script}`\n : `imported by a static request at ${where}${script}`,\n );\n origin =\n origin.referrer.kind === \"module\"\n ? origins.get(origin.referrer.id)\n : undefined;\n }\n return crossesDiscovery && notes.length > 0 ? notes : undefined;\n}\n\nfunction withNotes(\n diagnostic: Diagnostic,\n notes: readonly string[] | undefined,\n): Diagnostic {\n return notes == null\n ? diagnostic\n : { ...diagnostic, notes: [...(diagnostic.notes ?? []), ...notes] };\n}\n\n/** The origin of each module, recovered from a discovered graph. */\nfunction graphOrigins(graph: ModuleGraph): ReadonlyMap<string, ModuleOrigin> {\n const origins = new Map<string, ModuleOrigin>();\n const requests = graph.requests ?? [];\n for (const module of graph.modules) {\n const request =\n module.discoveredBy == null ? undefined : requests[module.discoveredBy];\n if (request == null) continue;\n origins.set(module.canonicalId, {\n edgeKind: request.edgeKind,\n location: request,\n referrer: request.referrer,\n });\n }\n return origins;\n}\n\n/**\n * Add the importer chain of each referrer to the diagnostic located in\n * it, when that chain crosses an `import()` edge. Other diagnostics are\n * returned unchanged.\n */\nfunction withReferrerChains(\n graph: ModuleGraph,\n located: readonly {\n readonly diagnostic: Diagnostic;\n readonly referrer: ModuleRequestReferrer;\n }[],\n): readonly Diagnostic[] {\n if (\n !(graph.requests ?? []).some((request) => request.edgeKind === \"discovery\")\n ) {\n return located.map(({ diagnostic }) => diagnostic);\n }\n const origins = graphOrigins(graph);\n return located.map(({ diagnostic, referrer }) =>\n withNotes(diagnostic, importerChainNotes(origins, referrer)),\n );\n}\n\n/** {@link withReferrerChains} for diagnostics located in modules. */\nfunction withImporterChains(\n graph: ModuleGraph,\n diagnostics: readonly Diagnostic[],\n): readonly Diagnostic[] {\n return withReferrerChains(\n graph,\n diagnostics.map((diagnostic) => ({\n diagnostic,\n referrer: { id: diagnostic.sourceId, kind: \"module\" },\n })),\n );\n}\n\ninterface DiscoveryResult {\n readonly diagnostics: readonly Diagnostic[];\n readonly modules: readonly ModuleGraphNode[];\n readonly requests: readonly ModuleRequestRecord[];\n}\n\n/**\n * Discover, load, and parse every module the entry's static closure and\n * the literal `import()` requests reach, without evaluating anything.\n *\n * The entry's static closure is visited first, depth first in source\n * order, exactly as a graph without `import()` is. Script referrers'\n * requests and every `import()` request found along the way join one\n * first-in, first-out queue, and each dequeued target contributes its own\n * static closure the same way. A module is parsed once however many\n * requests reach it.\n */\nfunction pendingRequest(\n referrer: ModuleRequestReferrer,\n site: ResolvedSite,\n): PendingRequest {\n return {\n origin: { edgeKind: site.edgeKind, location: site.location, referrer },\n site,\n };\n}\n\nasync function discoverModules(\n frontend: ModuleSourceFrontend,\n loader: ModuleLoader,\n resolver: ModuleResolver,\n entryId: string | undefined,\n scripts: readonly ScriptRequestReferrer[],\n): Promise<DiscoveryResult> {\n const diagnostics: Diagnostic[] = [];\n const modules: ModuleGraphNode[] = [];\n const discovered = new Set<string>();\n const loadedSources = new Map<string, ModuleLoadResult>();\n const origins = new Map<string, ModuleOrigin>();\n const originSites = new Map<string, ResolvedSite>();\n const moduleSites = new Map<string, readonly ResolvedSite[]>();\n const queue: PendingRequest[] = [];\n\n /** Resolve a referrer's sites in source order, reporting failures. */\n const resolveSites = (\n referrer: ModuleRequestReferrer,\n sites: readonly RequestSite[],\n ): readonly ResolvedSite[] => {\n const resolved: ResolvedSite[] = [];\n for (const site of sites) {\n const notes = importerChainNotes(origins, referrer, site.edgeKind);\n const unsupportedAttribute = site.specifier.attributes?.find(\n (attribute) => attribute.key !== \"type\" || attribute.value !== \"json\",\n );\n if (unsupportedAttribute != null) {\n diagnostics.push(\n withNotes(\n linkDiagnostic(\n referrer.id,\n unsupportedAttribute,\n \"Unsupported static import attribute.\",\n ),\n notes,\n ),\n );\n continue;\n }\n const result = resolver.resolve(referrer.id, site.specifier);\n diagnostics.push(\n ...result.diagnostics.map((diagnostic) => withNotes(diagnostic, notes)),\n );\n if (result.canonicalId == null || result.diagnostics.length > 0) {\n continue;\n }\n resolved.push({ ...site, canonicalId: result.canonicalId });\n }\n return resolved;\n };\n\n const visit = async (\n canonicalId: string,\n request?: PendingRequest,\n ): Promise<void> => {\n const referrer: ModuleLoadReferrer | undefined =\n request == null\n ? undefined\n : {\n importerId: request.origin.referrer.id,\n specifier: request.site.specifier,\n };\n const failingNotes =\n request == null\n ? undefined\n : importerChainNotes(\n origins,\n request.origin.referrer,\n request.origin.edgeKind,\n );\n let loaded = loadedSources.get(canonicalId);\n if (loaded == null) {\n loaded = await loader.load(canonicalId, referrer);\n loadedSources.set(canonicalId, loaded);\n diagnostics.push(\n ...loaded.diagnostics.map((diagnostic) =>\n withNotes(diagnostic, failingNotes),\n ),\n );\n }\n if (loaded.diagnostics.length > 0) return;\n if (loaded.builtin != null) {\n if (canonicalId !== loaded.builtin.specifier) {\n diagnostics.push(\n linkDiagnostic(\n canonicalId,\n {\n range: {\n start: { line: 1, column: 1 },\n end: { line: 1, column: 1 },\n },\n },\n \"A builtin module must use its canonical specifier identity.\",\n ),\n );\n return;\n }\n if (referrer?.specifier.attributes?.length) {\n diagnostics.push(\n linkDiagnostic(\n referrer.importerId,\n referrer.specifier,\n \"A builtin module does not accept import attributes.\",\n ),\n );\n return;\n }\n if (discovered.has(canonicalId)) return;\n discovered.add(canonicalId);\n if (request != null) {\n origins.set(canonicalId, request.origin);\n originSites.set(canonicalId, request.site);\n }\n modules.push({\n canonicalId,\n moduleKind: \"builtin\",\n builtin: loaded.builtin.specifier,\n sourceHash: loaded.builtin.sourceHash,\n dependencies: [],\n resolutions: [],\n });\n return;\n }\n if (loaded.source == null) return;\n if (referrer == null && loaded.source.kind === \"json\") {\n diagnostics.push(\n linkDiagnostic(\n canonicalId,\n {\n range: {\n start: { line: 1, column: 1 },\n end: { line: 1, column: 1 },\n },\n },\n \"A JSON module cannot be the entry module.\",\n ),\n );\n return;\n }\n const requestedJson =\n referrer?.specifier.attributes?.some(\n (attribute) => attribute.key === \"type\" && attribute.value === \"json\",\n ) ?? false;\n if (requestedJson !== (loaded.source.kind === \"json\")) {\n diagnostics.push(\n withNotes(\n linkDiagnostic(\n referrer?.importerId ?? canonicalId,\n referrer?.specifier ?? {\n range: {\n start: { line: 1, column: 1 },\n end: { line: 1, column: 1 },\n },\n },\n \"The module kind does not match its import attributes.\",\n ),\n failingNotes,\n ),\n );\n return;\n }\n if (discovered.has(canonicalId)) return;\n discovered.add(canonicalId);\n if (request != null) {\n origins.set(canonicalId, request.origin);\n originSites.set(canonicalId, request.site);\n }\n const moduleNotes = importerChainNotes(origins, {\n id: canonicalId,\n kind: \"module\",\n });\n let parsed;\n if (loaded.source.kind === \"json\") {\n try {\n parsed = { diagnostics: [], module: jsonModuleSyntax(loaded.source) };\n } catch (error) {\n const diagnostic = withNotes(\n linkDiagnostic(\n referrer?.importerId ?? canonicalId,\n referrer?.specifier ?? {\n range: {\n start: { line: 1, column: 1 },\n end: { line: 1, column: 1 },\n },\n },\n error instanceof SyntaxError\n ? \"Invalid JSON module source.\"\n : \"JSON module construction exceeds compiler limits.\",\n ),\n failingNotes,\n );\n diagnostics.push(\n error instanceof SyntaxError\n ? diagnostic\n : { ...diagnostic, code: \"OSEO1001\" },\n );\n return;\n }\n } else {\n parsed = frontend.parseModule({\n source: loaded.source.source,\n sourceId: canonicalId,\n });\n }\n diagnostics.push(\n ...parsed.diagnostics.map((diagnostic) =>\n withNotes(diagnostic, moduleNotes),\n ),\n );\n if (parsed.module == null || parsed.diagnostics.length > 0) return;\n const moduleReferrer: ModuleRequestReferrer = {\n id: canonicalId,\n kind: \"module\",\n };\n const sites = resolveSites(\n moduleReferrer,\n requestSites(parsed.module, parsed.module.importCalls),\n );\n moduleSites.set(canonicalId, sites);\n const dependencies: ModuleDependency[] = [];\n const resolutions: ModuleResolution[] = [];\n const dependencyIds = new Set<string>();\n for (const site of sites) {\n if (site.edgeKind !== \"evaluation\") continue;\n resolutions.push({\n canonicalId: site.canonicalId,\n specifier: site.specifier,\n });\n if (!dependencyIds.has(site.canonicalId)) {\n dependencyIds.add(site.canonicalId);\n dependencies.push({\n canonicalId: site.canonicalId,\n specifier: site.specifier,\n });\n }\n }\n modules.push({\n canonicalId,\n dependencies,\n resolutions,\n sourceHash: loaded.source.sourceHash,\n syntax: parsed.module,\n moduleKind: loaded.source.kind ?? \"javascript\",\n });\n for (const site of sites) {\n const pending = pendingRequest(moduleReferrer, site);\n if (site.edgeKind === \"discovery\") {\n queue.push(pending);\n continue;\n }\n // eslint-disable-next-line no-await-in-loop -- Preserve source order.\n await visit(site.canonicalId, pending);\n }\n };\n\n // Script requests resolve first, and their targets are visited after\n // the entry's static closure and before any module's `import()` target.\n const scriptSites = scripts.map((script) => {\n const referrer: ModuleRequestReferrer = {\n id: script.canonicalId,\n kind: \"script\",\n };\n return {\n referrer,\n sites: resolveSites(\n referrer,\n requestSites(undefined, script.program.importCalls),\n ),\n };\n });\n if (entryId != null) await visit(entryId);\n queue.unshift(\n ...scriptSites.flatMap(({ referrer, sites }) =>\n sites.map((site) => pendingRequest(referrer, site)),\n ),\n );\n for (let index = 0; index < queue.length; index += 1) {\n const pending = queue[index]!;\n // eslint-disable-next-line no-await-in-loop -- Preserve discovery order.\n await visit(pending.site.canonicalId, pending);\n }\n\n const requests: ModuleRequestRecord[] = [];\n const siteIndices = new Map<ResolvedSite, number>();\n const record = (\n referrer: ModuleRequestReferrer,\n sites: readonly ResolvedSite[],\n ): void => {\n for (const site of sites) {\n siteIndices.set(site, requests.length);\n requests.push({\n byteRange: site.location.byteRange,\n edgeKind: site.edgeKind,\n index: requests.length,\n range: site.location.range,\n referrer,\n specifier: site.specifier,\n targetId: site.canonicalId,\n });\n }\n };\n for (const { referrer, sites } of scriptSites) record(referrer, sites);\n for (const module of modules) {\n record(\n { id: module.canonicalId, kind: \"module\" },\n moduleSites.get(module.canonicalId) ?? [],\n );\n }\n const discoveredModules: ModuleGraphNode[] = [];\n for (const module of modules) {\n const site = originSites.get(module.canonicalId);\n const discoveredBy = site == null ? undefined : siteIndices.get(site);\n discoveredModules.push(\n discoveredBy == null ? module : { ...module, discoveredBy },\n );\n }\n return { diagnostics, modules: discoveredModules, requests };\n}\n\n/**\n * Discover and parse one closed module graph without evaluating its modules.\n *\n * Literal `import()` sites, which a module frontend produces only when\n * static-specifier imports are enabled, add discovery edges: their\n * targets and those targets' closures join {@link ModuleGraph.modules},\n * but never a module's `dependencies`. A target that cannot be resolved,\n * loaded, or parsed fails discovery with its source location and its\n * importer chain in the diagnostic notes.\n */\nexport async function buildModuleGraph(\n frontend: ModuleSourceFrontend,\n loader: ModuleLoader,\n resolver: ModuleResolver,\n entryId: string,\n options: ModuleGraphOptions = {},\n): Promise<ModuleGraphResult> {\n const result = await discoverModules(\n frontend,\n loader,\n resolver,\n entryId,\n options.scripts ?? [],\n );\n return result.diagnostics.length > 0\n ? { diagnostics: result.diagnostics }\n : {\n diagnostics: result.diagnostics,\n graph: {\n entryId,\n kind: \"module-graph\",\n modules: result.modules,\n requests: result.requests,\n },\n };\n}\n\n/**\n * Discover the modules that Script referrers reach through `import()`,\n * for a Script program with no module entry. Each Script resolves its\n * requests against its own canonical identity, and a module with the same\n * identity is a separate record.\n */\nexport async function buildScriptRequests(\n frontend: ModuleSourceFrontend,\n loader: ModuleLoader,\n resolver: ModuleResolver,\n scripts: readonly ScriptRequestReferrer[],\n): Promise<ScriptRequestResult> {\n const result = await discoverModules(\n frontend,\n loader,\n resolver,\n undefined,\n scripts,\n );\n return result.diagnostics.length > 0\n ? { diagnostics: result.diagnostics }\n : {\n closure: {\n kind: \"script-request-closure\",\n modules: result.modules,\n requests: result.requests,\n },\n diagnostics: result.diagnostics,\n };\n}\n\n/** One runtime cell allocated during module instantiation. */\nexport interface LinkedModuleCell {\n readonly id: number;\n readonly localName: string;\n readonly moduleId: string;\n}\n\n/** One linked imported binding or namespace reference. */\nexport interface LinkedModuleImport {\n readonly cellId?: number;\n readonly importedName: string;\n readonly localName: string;\n readonly namespaceModuleId?: string;\n}\n\n/** One export resolved to the cell that provides its live value. */\nexport interface LinkedModuleExport {\n readonly cellId: number;\n readonly exportedName: string;\n readonly sourceModuleId: string;\n}\n\n/** One module after import and export name resolution. */\nexport interface LinkedModule {\n readonly canonicalId: string;\n readonly cellIds: readonly number[];\n readonly componentId: number;\n readonly exports: readonly LinkedModuleExport[];\n readonly imports: readonly LinkedModuleImport[];\n /**\n * The cell holding this module's namespace object, present when an\n * import or an `export * as` names that namespace. Every such reference\n * shares the one cell, so namespace identity is per module.\n */\n readonly namespaceCellId?: number;\n readonly namespaceNames: readonly string[];\n}\n\n/** One deterministic strongly connected module component. */\nexport interface ModuleComponent {\n readonly cyclic: boolean;\n readonly id: number;\n /** Module IDs in evaluation order, ending with the component root. */\n readonly moduleIds: readonly string[];\n}\n\n/** Closed graph with live-cell and evaluation identities fixed. */\nexport interface LinkedModuleGraph {\n readonly cells: readonly LinkedModuleCell[];\n readonly components: readonly ModuleComponent[];\n readonly entryId: string;\n /**\n * Startup evaluation order. A discovered graph lists only the entry's\n * static closure; modules that only `import()` reaches are linked but\n * not scheduled.\n */\n readonly evaluationOrder: readonly string[];\n readonly kind: \"linked-module-graph\";\n readonly modules: readonly LinkedModule[];\n}\n\n/** Result of static module linking and instantiation planning. */\nexport interface ModuleLinkResult {\n readonly diagnostics: readonly Diagnostic[];\n readonly graph?: LinkedModuleGraph;\n}\n\ninterface ExportCandidate {\n readonly cellId: number;\n readonly sourceModuleId: string;\n}\n\nfunction linkDiagnostic(\n sourceId: string,\n locationValue: LocatedSyntax,\n message: string,\n): Diagnostic {\n return {\n byteRange: locationValue.byteRange ?? { end: 0, start: 0 },\n code: \"OSEO2001\",\n message,\n range: locationValue.range,\n sourceId,\n };\n}\n\nfunction resolvedModuleId(\n module: ModuleGraphNode,\n specifier: SyntaxModuleSpecifier,\n): string | undefined {\n return module.resolutions.find(\n (resolution) =>\n resolution.specifier === specifier ||\n (resolution.specifier.value === specifier.value &&\n resolution.specifier.byteRange.start === specifier.byteRange.start &&\n resolution.specifier.byteRange.end === specifier.byteRange.end),\n )?.canonicalId;\n}\n\nexport function importedBinding(\n module: ModuleGraphNode,\n localName: string,\n): SyntaxImportEntry | undefined {\n return moduleNodeSyntax(module).imports.find(\n (entry) => entry.localName === localName && entry.importedName != null,\n );\n}\n\nfunction sameExport(left: ExportCandidate, right: ExportCandidate): boolean {\n return left.cellId === right.cellId;\n}\n\nfunction compareCodeUnits(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction moduleDepthFirstOrder(graph: ModuleGraph): readonly string[] {\n const nodes = new Map(\n graph.modules.map((module) => [module.canonicalId, module]),\n );\n const visited = new Set<string>();\n const order: string[] = [];\n const visit = (rootId: string): void => {\n if (visited.has(rootId)) return;\n visited.add(rootId);\n const frames: { dependencyIndex: number; moduleId: string }[] = [\n { dependencyIndex: 0, moduleId: rootId },\n ];\n while (frames.length > 0) {\n const frame = frames.at(-1)!;\n const dependencies = nodes.get(frame.moduleId)?.dependencies ?? [];\n const dependency = dependencies[frame.dependencyIndex];\n if (dependency != null) {\n frame.dependencyIndex += 1;\n if (visited.has(dependency.canonicalId)) continue;\n visited.add(dependency.canonicalId);\n frames.push({\n dependencyIndex: 0,\n moduleId: dependency.canonicalId,\n });\n continue;\n }\n order.push(frame.moduleId);\n frames.pop();\n }\n };\n // A Script's request closure has no entry module.\n if (nodes.has(graph.entryId)) visit(graph.entryId);\n // Graph discovery records its requests, and every module it finds\n // outside the entry's static closure is one that only `import()`\n // reaches. Such a module evaluates on request, never at startup. A\n // hand-built graph without request records keeps ordering every\n // module.\n if (graph.requests != null) return order;\n for (const moduleId of [...nodes.keys()].toSorted(compareCodeUnits)) {\n visit(moduleId);\n }\n return order;\n}\n\nfunction moduleComponents(graph: ModuleGraph): readonly ModuleComponent[] {\n const nodes = new Map(\n graph.modules.map((module) => [module.canonicalId, module]),\n );\n const indices = new Map<string, number>();\n const lowLinks = new Map<string, number>();\n const stack: string[] = [];\n const stacked = new Set<string>();\n const found: string[][] = [];\n let nextIndex = 0;\n\n const begin = (moduleId: string): void => {\n const index = nextIndex;\n nextIndex += 1;\n indices.set(moduleId, index);\n lowLinks.set(moduleId, index);\n stack.push(moduleId);\n stacked.add(moduleId);\n };\n\n const strongConnect = (root: string): void => {\n begin(root);\n const frames: { dependencyIndex: number; moduleId: string }[] = [\n { dependencyIndex: 0, moduleId: root },\n ];\n while (frames.length > 0) {\n const frame = frames.at(-1)!;\n const index = indices.get(frame.moduleId)!;\n const dependencies = nodes.get(frame.moduleId)?.dependencies ?? [];\n const dependency = dependencies[frame.dependencyIndex];\n if (dependency != null) {\n frame.dependencyIndex += 1;\n if (!indices.has(dependency.canonicalId)) {\n begin(dependency.canonicalId);\n frames.push({\n dependencyIndex: 0,\n moduleId: dependency.canonicalId,\n });\n } else if (stacked.has(dependency.canonicalId)) {\n lowLinks.set(\n frame.moduleId,\n Math.min(\n lowLinks.get(frame.moduleId) ?? index,\n indices.get(dependency.canonicalId) ?? index,\n ),\n );\n }\n continue;\n }\n if (lowLinks.get(frame.moduleId) === index) {\n const component: string[] = [];\n for (;;) {\n const member = stack.pop();\n if (member == null) {\n throw new Error(\"Module component stack underflow.\");\n }\n stacked.delete(member);\n component.push(member);\n if (member === frame.moduleId) break;\n }\n found.push(component);\n }\n frames.pop();\n const parent = frames.at(-1);\n if (parent != null) {\n lowLinks.set(\n parent.moduleId,\n Math.min(\n lowLinks.get(parent.moduleId) ?? index,\n lowLinks.get(frame.moduleId) ?? index,\n ),\n );\n }\n }\n };\n // The entry's static closure comes first. Modules that only `import()`\n // reaches are linked too, each from the first one not yet indexed, so\n // their components follow the entry's in graph order.\n const roots = [\n graph.entryId,\n ...graph.modules.map((module) => module.canonicalId),\n ];\n for (const root of roots) {\n if (indices.has(root)) continue;\n strongConnect(root);\n }\n const evaluationOrder = moduleDepthFirstOrder(graph);\n const evaluationIndex = new Map(\n evaluationOrder.map((moduleId, index) => [moduleId, index]),\n );\n return found\n .map((moduleIds) =>\n moduleIds.toSorted(\n (left, right) =>\n (evaluationIndex.get(left) ?? Number.MAX_SAFE_INTEGER) -\n (evaluationIndex.get(right) ?? Number.MAX_SAFE_INTEGER),\n ),\n )\n .toSorted(\n (left, right) =>\n (evaluationIndex.get(left[0] ?? \"\") ?? Number.MAX_SAFE_INTEGER) -\n (evaluationIndex.get(right[0] ?? \"\") ?? Number.MAX_SAFE_INTEGER),\n )\n .map((moduleIds, id) => {\n const first = nodes.get(moduleIds[0] ?? \"\");\n const selfCycle = first?.dependencies.some(\n (dependency) => dependency.canonicalId === first.canonicalId,\n );\n return {\n cyclic: moduleIds.length > 1 || selfCycle === true,\n id,\n moduleIds,\n };\n });\n}\n\n/** Resolve live imports, exports, namespace keys, and cyclic graph order. */\nexport function linkModuleGraph(graph: ModuleGraph): ModuleLinkResult {\n const diagnostics: Diagnostic[] = [];\n const nodes = new Map(\n graph.modules.map((module) => [module.canonicalId, module]),\n );\n const cells: LinkedModuleCell[] = [];\n const cellIds = new Map<string, number>();\n const exportsByModule = new Map<string, Map<string, ExportCandidate>>();\n const explicitNames = new Map<string, Set<string>>();\n const ambiguousNames = new Map<string, Set<string>>();\n const namespaceCells = new Map<string, number>();\n\n const cellFor = (moduleId: string, localName: string): number => {\n const key = `${moduleId}\\0${localName}`;\n const existing = cellIds.get(key);\n if (existing != null) return existing;\n const id = cells.length;\n cells.push({ id, localName, moduleId });\n cellIds.set(key, id);\n return id;\n };\n\n const namespaceCellFor = (moduleId: string): number => {\n const existing = namespaceCells.get(moduleId);\n if (existing != null) return existing;\n const cellId = cellFor(moduleId, `*namespace:${moduleId}*`);\n namespaceCells.set(moduleId, cellId);\n return cellId;\n };\n\n for (const module of graph.modules) {\n const moduleExports = new Map<string, ExportCandidate>();\n const names = new Set<string>();\n exportsByModule.set(module.canonicalId, moduleExports);\n explicitNames.set(module.canonicalId, names);\n ambiguousNames.set(module.canonicalId, new Set());\n for (const [index, entry] of moduleNodeSyntax(module).exports.entries()) {\n if (entry.kind === \"star\") continue;\n if (names.has(entry.exportedName)) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Duplicate export '${entry.exportedName}'.`,\n ),\n );\n continue;\n }\n names.add(entry.exportedName);\n if (entry.kind === \"local\") {\n if (importedBinding(module, entry.localName) == null) {\n moduleExports.set(entry.exportedName, {\n cellId: cellFor(module.canonicalId, entry.localName),\n sourceModuleId: module.canonicalId,\n });\n }\n } else if (entry.kind === \"default\") {\n moduleExports.set(\"default\", {\n cellId: cellFor(module.canonicalId, `*default:${index}*`),\n sourceModuleId: module.canonicalId,\n });\n } else if (entry.kind === \"namespace\") {\n // ResolveExport answers an `export * as` entry with the requested\n // module's namespace directly, so it never waits on star\n // resolution and no star export can shadow or make it ambiguous.\n const targetId = resolvedModuleId(module, entry.specifier);\n if (targetId == null || !nodes.has(targetId)) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Module '${entry.specifier.value}' was not resolved.`,\n ),\n );\n continue;\n }\n moduleExports.set(entry.exportedName, {\n cellId: namespaceCellFor(targetId),\n sourceModuleId: targetId,\n });\n }\n }\n }\n\n let changed = true;\n while (changed) {\n changed = false;\n for (const module of graph.modules) {\n const moduleExports = exportsByModule.get(module.canonicalId);\n const moduleAmbiguous = ambiguousNames.get(module.canonicalId);\n const moduleExplicit = explicitNames.get(module.canonicalId);\n if (\n moduleExports == null ||\n moduleAmbiguous == null ||\n moduleExplicit == null\n ) {\n throw new Error(\"Module link state is incomplete.\");\n }\n for (const entry of moduleNodeSyntax(module).exports) {\n if (entry.kind === \"local\") {\n const imported = importedBinding(module, entry.localName);\n if (imported == null) continue;\n const targetId = resolvedModuleId(module, imported.specifier);\n const candidate =\n targetId == null || imported.importedName == null\n ? undefined\n : imported.namespace === true\n ? {\n cellId: namespaceCellFor(targetId),\n sourceModuleId: targetId,\n }\n : exportsByModule.get(targetId)?.get(imported.importedName);\n const existing = moduleExports.get(entry.exportedName);\n if (\n candidate != null &&\n (existing == null || !sameExport(existing, candidate))\n ) {\n moduleExports.set(entry.exportedName, candidate);\n changed = true;\n }\n continue;\n }\n if (entry.kind === \"indirect\") {\n const targetId = resolvedModuleId(module, entry.specifier);\n const candidate =\n targetId == null\n ? undefined\n : exportsByModule.get(targetId)?.get(entry.importedName);\n if (\n candidate != null &&\n !moduleExports.has(entry.exportedName) &&\n !moduleAmbiguous.has(entry.exportedName)\n ) {\n moduleExports.set(entry.exportedName, candidate);\n changed = true;\n }\n continue;\n }\n if (entry.kind !== \"star\") continue;\n const targetId = resolvedModuleId(module, entry.specifier);\n if (targetId == null) continue;\n const targetExports = exportsByModule.get(targetId);\n const targetAmbiguous = ambiguousNames.get(targetId);\n if (targetExports == null || targetAmbiguous == null) continue;\n for (const name of targetAmbiguous) {\n if (name !== \"default\" && !moduleExplicit.has(name)) {\n if (!moduleAmbiguous.has(name)) changed = true;\n moduleAmbiguous.add(name);\n moduleExports.delete(name);\n }\n }\n for (const [name, candidate] of targetExports) {\n if (\n name === \"default\" ||\n moduleExplicit.has(name) ||\n moduleAmbiguous.has(name)\n ) {\n continue;\n }\n const existing = moduleExports.get(name);\n if (existing == null) {\n moduleExports.set(name, candidate);\n changed = true;\n } else if (!sameExport(existing, candidate)) {\n moduleExports.delete(name);\n moduleAmbiguous.add(name);\n changed = true;\n }\n }\n }\n }\n }\n\n const linkedImports = new Map<string, LinkedModuleImport[]>();\n for (const module of graph.modules) {\n const imports: LinkedModuleImport[] = [];\n linkedImports.set(module.canonicalId, imports);\n for (const entry of moduleNodeSyntax(module).exports) {\n if (entry.kind !== \"indirect\") continue;\n const targetId = resolvedModuleId(module, entry.specifier);\n const targetAmbiguous =\n targetId == null ? undefined : ambiguousNames.get(targetId);\n const candidate =\n targetId == null\n ? undefined\n : exportsByModule.get(targetId)?.get(entry.importedName);\n if (targetAmbiguous?.has(entry.importedName) === true) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Export '${entry.importedName}' is ambiguous.`,\n ),\n );\n } else if (candidate == null) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Module has no export '${entry.importedName}'.`,\n ),\n );\n }\n }\n for (const entry of moduleNodeSyntax(module).imports) {\n if (entry.localName == null || entry.importedName == null) continue;\n const targetId = resolvedModuleId(module, entry.specifier);\n if (targetId == null || !nodes.has(targetId)) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Module '${entry.specifier.value}' was not resolved.`,\n ),\n );\n continue;\n }\n if (entry.namespace === true) {\n imports.push({\n cellId: namespaceCellFor(targetId),\n importedName: \"*\",\n localName: entry.localName,\n namespaceModuleId: targetId,\n });\n continue;\n }\n const targetAmbiguous = ambiguousNames.get(targetId);\n const candidate = exportsByModule.get(targetId)?.get(entry.importedName);\n if (targetAmbiguous?.has(entry.importedName) === true) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Import '${entry.importedName}' is ambiguous.`,\n ),\n );\n } else if (candidate == null) {\n diagnostics.push(\n linkDiagnostic(\n module.canonicalId,\n entry,\n `Module has no export '${entry.importedName}'.`,\n ),\n );\n } else {\n imports.push({\n cellId: candidate.cellId,\n importedName: entry.importedName,\n localName: entry.localName,\n });\n }\n }\n }\n if (diagnostics.length > 0) {\n return { diagnostics: withImporterChains(graph, diagnostics) };\n }\n\n // Every `import()` target resolves with its one namespace object, so\n // the target gets the namespace cell an `import * as` would share.\n for (const request of graph.requests ?? []) {\n if (request.edgeKind === \"discovery\") namespaceCellFor(request.targetId);\n }\n const components = moduleComponents(graph);\n const componentByModule = new Map<string, number>();\n for (const component of components) {\n for (const moduleId of component.moduleIds) {\n componentByModule.set(moduleId, component.id);\n }\n }\n const linkedModules = graph.modules.map((module): LinkedModule => {\n const moduleExports = exportsByModule.get(module.canonicalId);\n const componentId = componentByModule.get(module.canonicalId);\n if (moduleExports == null || componentId == null) {\n throw new Error(\"Linked module state is incomplete.\");\n }\n const exports = [...moduleExports]\n .toSorted(([left], [right]) => compareCodeUnits(left, right))\n .map(([exportedName, candidate]) => ({\n cellId: candidate.cellId,\n exportedName,\n sourceModuleId: candidate.sourceModuleId,\n }));\n return {\n canonicalId: module.canonicalId,\n cellIds: cells\n .filter((cell) => cell.moduleId === module.canonicalId)\n .map((cell) => cell.id),\n componentId,\n exports,\n imports: linkedImports.get(module.canonicalId) ?? [],\n ...includePropertiesWhen(() => {\n const cellId = namespaceCells.get(module.canonicalId);\n return cellId == null ? undefined : { namespaceCellId: cellId };\n }),\n namespaceNames: exports.map((entry) => entry.exportedName),\n };\n });\n return {\n diagnostics,\n graph: {\n cells,\n components,\n entryId: graph.entryId,\n evaluationOrder: moduleDepthFirstOrder(graph),\n kind: \"linked-module-graph\",\n modules: linkedModules,\n },\n };\n}\n"],"mappings":";;;;AA4CA,SAAS,sBACP,YACoD;CACpD,OAAO,WAAW,KAAK,CAAC;AAC1B;;AAGA,SAAS,iBACP,QACkC;CAClC,MAAM,aAAsC,CAAC;CAC7C,KAAK,MAAM,SAAS,OAAO,SAAS,WAAW,K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UAAU,UAAU,EAAE;CAGhD,MAAM,gBAAgB,MAAM,QAAQ,KAAK,WAAyB;EAChE,MAAM,gBAAgB,gBAAgB,IAAI,OAAO,WAAW;EAC5D,MAAM,cAAc,kBAAkB,IAAI,OAAO,WAAW;EAC5D,IAAI,iBAAiB,QAAQ,eAAe,MAC1C,MAAM,IAAI,MAAM,oCAAoC;EAEtD,MAAM,UAAU,CAAC,GAAG,aAAa,CAAC,CAC/B,UAAU,CAAC,OAAO,CAAC,WAAW,iBAAiB,MAAM,KAAK,CAAC,CAAC,CAC5D,KAAK,CAAC,cAAc,gBAAgB;GACnC,QAAQ,UAAU;GAClB;GACA,gBAAgB,UAAU;EAC5B,EAAE;EACJ,OAAO;GACL,aAAa,OAAO;GACpB,SAAS,MACN,QAAQ,SAAS,KAAK,aAAa,OAAO,WAAW,CAAC,CACtD,KAAK,SAAS,KAAK,EAAE;GACxB;GACA;GACA,SAAS,cAAc,IAAI,OAAO,WAAW,KAAK,CAAC;GACnD,GAAG,4BAA4B;IAC7B,MAAM,SAAS,eAAe,IAAI,OAAO,WAAW;IACpD,OAAO,UAAU,OAAO,SAAY,EAAE,iBAAiB,OAAO;GAChE,CAAC;GACD,gBAAgB,QAAQ,KAAK,UAAU,MAAM,YAAY;EAC3D;CACF,CAAC;CACD,OAAO;EACL;EACA,OAAO;GACL;GACA;GACA,SAAS,MAAM;GACf,iBAAiB,sBAAsB,KAAK;GAC5C,MAAM;GACN,SAAS;EACX;CACF;AACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { CompilerHost, HarnessObjectKeyInput, NativeToolchain } from "./native.js";
|
|
2
|
+
//#region src/native-fragments.d.ts
|
|
3
|
+
/** Published object ownership belongs to the host cache, not the build dir. */
|
|
4
|
+
interface PreparedHarnessObject {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
readonly objectPath: string;
|
|
7
|
+
readonly cacheHit: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A composer's pinned compiler for one harness object build. `verify` is
|
|
11
|
+
* awaited after the key lock is acquired, before the compiler runs, and
|
|
12
|
+
* before the object is published, so a compiler that moves during the lock
|
|
13
|
+
* wait or the build cannot publish an object under this key. It raises to
|
|
14
|
+
* stop the build.
|
|
15
|
+
*/
|
|
16
|
+
interface HarnessObjectPin {
|
|
17
|
+
readonly compilerPath: string;
|
|
18
|
+
verify(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a normalized harness object once under the host's exclusive key lock.
|
|
22
|
+
* Without persistent storage the caller owns the returned temporary directory.
|
|
23
|
+
*/
|
|
24
|
+
declare function prepareHarnessObject(host: CompilerHost, toolchain: NativeToolchain, input: HarnessObjectKeyInput, pin?: HarnessObjectPin): Promise<PreparedHarnessObject>;
|
|
25
|
+
/** Exact normalized adapter invocations, independent of staging paths. */
|
|
26
|
+
interface HarnessToolchainPolicy {
|
|
27
|
+
readonly adapter: string;
|
|
28
|
+
readonly compileFlags: readonly string[];
|
|
29
|
+
readonly linkFlags: readonly string[];
|
|
30
|
+
readonly runtimeFlags: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
/** Canonical key encoding preserves ordered sources, assets, and flags. */
|
|
33
|
+
declare function createHarnessObjectKey(input: HarnessObjectKeyInput, policy: HarnessToolchainPolicy): Promise<string>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { HarnessObjectPin, HarnessToolchainPolicy, PreparedHarnessObject, createHarnessObjectKey, prepareHarnessObject };
|
|
36
|
+
//# sourceMappingURL=native-fragments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-fragments.d.ts","names":[],"sources":["../src/native-fragments.ts"],"mappings":";;;UA0BiB;WACN;WACA;WACA;;;;;;;;;UAUM;WACN;EACT,UAAU;;;;;;iBAOU,qBACpB,MAAM,cACN,WAAW,iBACX,OAAO,uBACP,MAAM,mBACL,QAAQ;;UAqEM;WACN;WACA;WACA;WACA;;;iBAIW,uBACpB,OAAO,uBACP,QAAQ,yBACP"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//#region src/native-fragments.ts
|
|
2
|
+
/**
|
|
3
|
+
* Build a normalized harness object once under the host's exclusive key lock.
|
|
4
|
+
* Without persistent storage the caller owns the returned temporary directory.
|
|
5
|
+
*/
|
|
6
|
+
async function prepareHarnessObject(host, toolchain, input, pin) {
|
|
7
|
+
const reuse = toolchain.harnessObjectReuse;
|
|
8
|
+
if (reuse == null) throw new Error("Toolchain lacks harness object support.");
|
|
9
|
+
const key = await reuse.createKey(input);
|
|
10
|
+
const cache = host.cache;
|
|
11
|
+
const directory = cache == null ? void 0 : await cache.getDirectory("harness-objects");
|
|
12
|
+
const objectPath = directory == null ? void 0 : `${directory}/${key}.o`;
|
|
13
|
+
const lock = objectPath == null ? void 0 : await cache.acquireFileLock(`${objectPath}.lock`);
|
|
14
|
+
let work;
|
|
15
|
+
try {
|
|
16
|
+
await pin?.verify();
|
|
17
|
+
if (objectPath != null && await cache.hasFile(objectPath)) return {
|
|
18
|
+
key,
|
|
19
|
+
objectPath,
|
|
20
|
+
cacheHit: true
|
|
21
|
+
};
|
|
22
|
+
work = await host.makeTemporaryDirectory("oseo-harness-");
|
|
23
|
+
await Promise.all(input.runtimeAssets.map(async (asset) => {
|
|
24
|
+
if (asset.kind !== "header") return;
|
|
25
|
+
if (!/^[A-Za-z0-9_.-]+$/u.test(asset.name) || asset.name === "..") throw new Error("Runtime header requires a flat staging name.");
|
|
26
|
+
await host.writeTextFile(`${work}/${asset.name}`, asset.contents);
|
|
27
|
+
}));
|
|
28
|
+
await host.writeTextFile(`${work}/harness.c`, input.generatedSource);
|
|
29
|
+
const buildInput = pin == null ? {
|
|
30
|
+
buildConfiguration: input.buildConfiguration ?? "checked",
|
|
31
|
+
workingDirectory: work,
|
|
32
|
+
target: input.target,
|
|
33
|
+
environment: input.toolchainEnvironment
|
|
34
|
+
} : {
|
|
35
|
+
compilerPath: pin.compilerPath,
|
|
36
|
+
buildConfiguration: input.buildConfiguration ?? "checked",
|
|
37
|
+
workingDirectory: work,
|
|
38
|
+
target: input.target,
|
|
39
|
+
environment: input.toolchainEnvironment
|
|
40
|
+
};
|
|
41
|
+
await pin?.verify();
|
|
42
|
+
const observed = await host.run(reuse.createBuildRequest(buildInput));
|
|
43
|
+
if (observed.exitStatus !== 0) throw new Error(`Harness object build failed: ${observed.stderr}`);
|
|
44
|
+
await pin?.verify();
|
|
45
|
+
const built = `${work}/harness.o`;
|
|
46
|
+
if (objectPath == null) {
|
|
47
|
+
work = void 0;
|
|
48
|
+
return {
|
|
49
|
+
key,
|
|
50
|
+
objectPath: built,
|
|
51
|
+
cacheHit: false
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
await cache.publishFile(built, objectPath);
|
|
55
|
+
return {
|
|
56
|
+
key,
|
|
57
|
+
objectPath,
|
|
58
|
+
cacheHit: false
|
|
59
|
+
};
|
|
60
|
+
} finally {
|
|
61
|
+
try {
|
|
62
|
+
if (work != null) await host.remove(work);
|
|
63
|
+
} finally {
|
|
64
|
+
await lock?.release();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Canonical key encoding preserves ordered sources, assets, and flags. */
|
|
69
|
+
async function createHarnessObjectKey(input, policy) {
|
|
70
|
+
const bytes = new TextEncoder().encode(JSON.stringify({
|
|
71
|
+
buildConfiguration: input.buildConfiguration ?? "checked",
|
|
72
|
+
fragmentAbiVersion: input.fragmentAbiVersion,
|
|
73
|
+
harnessSources: input.harnessSources.map((source) => [source.sourceId, source.source]),
|
|
74
|
+
strict: input.strict,
|
|
75
|
+
specialization: input.specialization,
|
|
76
|
+
observeSpecialization: input.observeSpecialization,
|
|
77
|
+
frontendIdentity: input.frontendIdentity,
|
|
78
|
+
compilerIdentity: input.compilerIdentity,
|
|
79
|
+
backendIdentity: input.backendIdentity,
|
|
80
|
+
generatedSource: input.generatedSource,
|
|
81
|
+
runtimeAbiVersion: input.runtimeAbiVersion,
|
|
82
|
+
runtimeAssets: input.runtimeAssets.map((asset) => [
|
|
83
|
+
asset.name,
|
|
84
|
+
asset.kind,
|
|
85
|
+
asset.contents
|
|
86
|
+
]),
|
|
87
|
+
target: [
|
|
88
|
+
input.target.name,
|
|
89
|
+
input.target.architecture,
|
|
90
|
+
input.target.operatingSystem,
|
|
91
|
+
input.target.abi ?? null,
|
|
92
|
+
input.target.atomicsPauseHint,
|
|
93
|
+
input.target.cStandard,
|
|
94
|
+
input.target.executableFormat,
|
|
95
|
+
input.target.sanitizers
|
|
96
|
+
],
|
|
97
|
+
toolchainIdentity: input.toolchainIdentity,
|
|
98
|
+
environment: Object.entries(input.toolchainEnvironment.variables).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0),
|
|
99
|
+
adapter: policy.adapter,
|
|
100
|
+
compileFlags: policy.compileFlags,
|
|
101
|
+
linkFlags: policy.linkFlags,
|
|
102
|
+
runtimeFlags: policy.runtimeFlags
|
|
103
|
+
}));
|
|
104
|
+
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
105
|
+
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { createHarnessObjectKey, prepareHarnessObject };
|
|
110
|
+
//# sourceMappingURL=native-fragments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-fragments.js","names":[],"sources":["../src/native-fragments.ts"],"sourcesContent":["/*\n * Oseo, an ahead-of-time compiler for JavaScript and TypeScript.\n * Copyright (C) 2026 Hong Minhee <https://hongminhee.org/>\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <https://www.gnu.org/licenses/>.\n */\n\nimport type {\n CompilerHost,\n HarnessObjectBuildInput,\n HarnessObjectKeyInput,\n NativeToolchain,\n} from \"./native.ts\";\n\n/** Published object ownership belongs to the host cache, not the build dir. */\nexport interface PreparedHarnessObject {\n readonly key: string;\n readonly objectPath: string;\n readonly cacheHit: boolean;\n}\n\n/**\n * A composer's pinned compiler for one harness object build. `verify` is\n * awaited after the key lock is acquired, before the compiler runs, and\n * before the object is published, so a compiler that moves during the lock\n * wait or the build cannot publish an object under this key. It raises to\n * stop the build.\n */\nexport interface HarnessObjectPin {\n readonly compilerPath: string;\n verify(): Promise<void>;\n}\n\n/**\n * Build a normalized harness object once under the host's exclusive key lock.\n * Without persistent storage the caller owns the returned temporary directory.\n */\nexport async function prepareHarnessObject(\n host: CompilerHost,\n toolchain: NativeToolchain,\n input: HarnessObjectKeyInput,\n pin?: HarnessObjectPin,\n): Promise<PreparedHarnessObject> {\n const reuse = toolchain.harnessObjectReuse;\n if (reuse == null) throw new Error(\"Toolchain lacks harness object support.\");\n const key = await reuse.createKey(input);\n const cache = host.cache;\n const directory =\n cache == null ? undefined : await cache.getDirectory(\"harness-objects\");\n const objectPath = directory == null ? undefined : `${directory}/${key}.o`;\n const lock =\n objectPath == null\n ? undefined\n : await cache!.acquireFileLock(`${objectPath}.lock`);\n let work: string | undefined;\n try {\n await pin?.verify();\n if (objectPath != null && (await cache!.hasFile(objectPath))) {\n return { key, objectPath, cacheHit: true };\n }\n work = await host.makeTemporaryDirectory(\"oseo-harness-\");\n await Promise.all(\n input.runtimeAssets.map(async (asset) => {\n if (asset.kind !== \"header\") return;\n if (!/^[A-Za-z0-9_.-]+$/u.test(asset.name) || asset.name === \"..\") {\n throw new Error(\"Runtime header requires a flat staging name.\");\n }\n await host.writeTextFile(`${work}/${asset.name}`, asset.contents);\n }),\n );\n await host.writeTextFile(`${work}/harness.c`, input.generatedSource);\n const buildInput: HarnessObjectBuildInput =\n pin == null\n ? {\n buildConfiguration: input.buildConfiguration ?? \"checked\",\n workingDirectory: work,\n target: input.target,\n environment: input.toolchainEnvironment,\n }\n : {\n compilerPath: pin.compilerPath,\n buildConfiguration: input.buildConfiguration ?? \"checked\",\n workingDirectory: work,\n target: input.target,\n environment: input.toolchainEnvironment,\n };\n await pin?.verify();\n const observed = await host.run(reuse.createBuildRequest(buildInput));\n if (observed.exitStatus !== 0) {\n throw new Error(`Harness object build failed: ${observed.stderr}`);\n }\n // The object is keyed by the pinned compiler whether it is published or\n // handed back directly, so it is verified before either.\n await pin?.verify();\n const built = `${work}/harness.o`;\n if (objectPath == null) {\n work = undefined;\n return { key, objectPath: built, cacheHit: false };\n }\n await cache!.publishFile(built, objectPath);\n return { key, objectPath, cacheHit: false };\n } finally {\n try {\n if (work != null) await host.remove(work);\n } finally {\n await lock?.release();\n }\n }\n}\n\n/** Exact normalized adapter invocations, independent of staging paths. */\nexport interface HarnessToolchainPolicy {\n readonly adapter: string;\n readonly compileFlags: readonly string[];\n readonly linkFlags: readonly string[];\n readonly runtimeFlags: readonly string[];\n}\n\n/** Canonical key encoding preserves ordered sources, assets, and flags. */\nexport async function createHarnessObjectKey(\n input: HarnessObjectKeyInput,\n policy: HarnessToolchainPolicy,\n): Promise<string> {\n const bytes = new TextEncoder().encode(\n JSON.stringify({\n buildConfiguration: input.buildConfiguration ?? \"checked\",\n fragmentAbiVersion: input.fragmentAbiVersion,\n harnessSources: input.harnessSources.map((source) => [\n source.sourceId,\n source.source,\n ]),\n strict: input.strict,\n specialization: input.specialization,\n observeSpecialization: input.observeSpecialization,\n frontendIdentity: input.frontendIdentity,\n compilerIdentity: input.compilerIdentity,\n backendIdentity: input.backendIdentity,\n generatedSource: input.generatedSource,\n runtimeAbiVersion: input.runtimeAbiVersion,\n runtimeAssets: input.runtimeAssets.map((asset) => [\n asset.name,\n asset.kind,\n asset.contents,\n ]),\n target: [\n input.target.name,\n input.target.architecture,\n input.target.operatingSystem,\n input.target.abi ?? null,\n input.target.atomicsPauseHint,\n input.target.cStandard,\n input.target.executableFormat,\n input.target.sanitizers,\n ],\n toolchainIdentity: input.toolchainIdentity,\n environment: Object.entries(\n input.toolchainEnvironment.variables,\n ).toSorted(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)),\n adapter: policy.adapter,\n compileFlags: policy.compileFlags,\n linkFlags: policy.linkFlags,\n runtimeFlags: policy.runtimeFlags,\n }),\n );\n const digest = await crypto.subtle.digest(\"SHA-256\", bytes);\n return [...new Uint8Array(digest)]\n .map((byte) => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n}\n"],"mappings":";;;;;AAgDA,eAAsB,qBACpB,MACA,WACA,OACA,KACgC;CAChC,MAAM,QAAQ,UAAU;CACxB,IAAI,SAAS,MAAM,MAAM,IAAI,MAAM,yCAAyC;CAC5E,MAAM,MAAM,MAAM,MAAM,UAAU,KAAK;CACvC,MAAM,QAAQ,KAAK;CACnB,MAAM,YACJ,SAAS,OAAO,SAAY,MAAM,MAAM,aAAa,iBAAiB;CACxE,MAAM,aAAa,aAAa,OAAO,SAAY,GAAG,UAAU,GAAG,IAAI;CACvE,MAAM,OACJ,cAAc,OACV,SACA,MAAM,MAAO,gBAAgB,GAAG,WAAW,MAAM;CACvD,IAAI;CACJ,IAAI;EACF,MAAM,KAAK,OAAO;EAClB,IAAI,cAAc,QAAS,MAAM,MAAO,QAAQ,UAAU,GACxD,OAAO;GAAE;GAAK;GAAY,UAAU;EAAK;EAE3C,OAAO,MAAM,KAAK,uBAAuB,eAAe;EACxD,MAAM,QAAQ,IACZ,MAAM,cAAc,IAAI,OAAO,UAAU;GACvC,IAAI,MAAM,SAAS,UAAU;GAC7B,IAAI,CAAC,qBAAqB,KAAK,MAAM,IAAI,KAAK,MAAM,SAAS,MAC3D,MAAM,IAAI,MAAM,8CAA8C;GAEhE,MAAM,KAAK,cAAc,GAAG,KAAK,GAAG,MAAM,QAAQ,MAAM,QAAQ;EAClE,CA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;EACR,CAAC;EACD,QAAQ;GACN,MAAM,OAAO;GACb,MAAM,OAAO;GACb,MAAM,OAAO;GACb,MAAM,OAAO,OAAO;GACpB,MAAM,OAAO;GACb,MAAM,OAAO;GACb,MAAM,OAAO;GACb,MAAM,OAAO;EACf;EACA,mBAAmB,MAAM;EACzB,aAAa,OAAO,QAClB,MAAM,qBAAqB,SAC7B,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAE;EACrD,SAAS,OAAO;EAChB,cAAc,OAAO;EACrB,WAAW,OAAO;EAClB,cAAc,OAAO;CACvB,CAAC,CACH;CACA,MAAM,SAAS,MAAM,OAAO,OAAO,OAAO,WAAW,KAAK;CAC1D,OAAO,CAAC,GAAG,IAAI,WAAW,MAAM,CAAC,CAAC,CAC/B,KAAK,SAAS,KAAK,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CACjD,KAAK,EAAE;AACZ"}
|
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { MirProgram } from "./mir.js";
|
|
2
|
+
//#region src/native.d.ts
|
|
3
|
+
/** Architecture facts admitted by Oseo native targets. */
|
|
4
|
+
type NativeArchitecture = "aarch64" | "x86_64";
|
|
5
|
+
/** Operating-system facts admitted by Oseo native targets. */
|
|
6
|
+
type NativeOperatingSystem = "linux" | "macos";
|
|
7
|
+
/** ABI environments distinguished by Oseo's native Linux targets. */
|
|
8
|
+
type NativeAbi = "gnu" | "musl";
|
|
9
|
+
/** Stable Oseo native target IDs in OS-architecture-ABI order. */
|
|
10
|
+
type TargetName = "linux-aarch64-musl" | "linux-x86_64-gnu" | "macos-aarch64";
|
|
11
|
+
/** Normalized host detection, including explicitly unknown reported facts. */
|
|
12
|
+
interface ExecutionHostDescription {
|
|
13
|
+
readonly architecture: NativeArchitecture | "unknown";
|
|
14
|
+
readonly operatingSystem: NativeOperatingSystem | "unknown";
|
|
15
|
+
}
|
|
16
|
+
/** Toolchain-neutral artifact facts for one explicit Oseo target ID. */
|
|
17
|
+
interface TargetDescription {
|
|
18
|
+
readonly abi?: NativeAbi;
|
|
19
|
+
readonly architecture: NativeArchitecture;
|
|
20
|
+
/**
|
|
21
|
+
* The processor hint the runtime's `Atomics.pause` executes once per
|
|
22
|
+
* call: the x86-64 PAUSE instruction or the AArch64 YIELD instruction.
|
|
23
|
+
*/
|
|
24
|
+
readonly atomicsPauseHint: "aarch64-yield" | "x86-pause";
|
|
25
|
+
readonly cStandard: "c11";
|
|
26
|
+
readonly executableFormat: "elf" | "mach-o";
|
|
27
|
+
readonly name: TargetName;
|
|
28
|
+
readonly operatingSystem: NativeOperatingSystem;
|
|
29
|
+
readonly sanitizers: readonly ("address" | "undefined")[];
|
|
30
|
+
}
|
|
31
|
+
/** Deterministic source emitted by a replaceable native backend. */
|
|
32
|
+
interface NativeSourceFile {
|
|
33
|
+
readonly source: string;
|
|
34
|
+
readonly sourceName: string;
|
|
35
|
+
}
|
|
36
|
+
/** Source display plus optional bounded units used for native compilation. */
|
|
37
|
+
interface EmittedNativeSource extends NativeSourceFile {
|
|
38
|
+
/**
|
|
39
|
+
* Compile these files instead of the standalone source when present.
|
|
40
|
+
* Stage the standalone source beside them under sourceName for includes.
|
|
41
|
+
*/
|
|
42
|
+
readonly compilationUnits?: readonly NativeSourceFile[];
|
|
43
|
+
}
|
|
44
|
+
/** Backend boundary that never performs process execution. */
|
|
45
|
+
interface NativeBackend {
|
|
46
|
+
emit(input: MirProgram): EmittedNativeSource;
|
|
47
|
+
}
|
|
48
|
+
/** One reviewed native asset supplied by a runtime package. */
|
|
49
|
+
interface RuntimeAsset {
|
|
50
|
+
readonly kind: "header" | "source";
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly url: URL;
|
|
53
|
+
}
|
|
54
|
+
/** A versioned set of native runtime inputs. */
|
|
55
|
+
interface RuntimeInput {
|
|
56
|
+
readonly abiVersion: string;
|
|
57
|
+
readonly assets: readonly RuntimeAsset[];
|
|
58
|
+
}
|
|
59
|
+
/** Provider boundary between runtime selection and backend emission. */
|
|
60
|
+
interface RuntimeInputProvider {
|
|
61
|
+
getRuntimeInput(): RuntimeInput;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Host-variable names a toolchain permits one of its subprocesses to inherit.
|
|
65
|
+
*/
|
|
66
|
+
interface ProcessEnvironmentPolicy {
|
|
67
|
+
readonly inherit: readonly string[];
|
|
68
|
+
}
|
|
69
|
+
/** Immutable host environment captured for one native workflow. */
|
|
70
|
+
interface ProcessEnvironment {
|
|
71
|
+
readonly variables: Readonly<Record<string, string>>;
|
|
72
|
+
}
|
|
73
|
+
/** One process request created by a native toolchain adapter. */
|
|
74
|
+
interface ProcessRequest {
|
|
75
|
+
readonly args: readonly string[];
|
|
76
|
+
readonly command: string;
|
|
77
|
+
readonly cwd: string;
|
|
78
|
+
readonly environment?: ProcessEnvironment;
|
|
79
|
+
/** Bytes or UTF-8 text written to stdin, then EOF; omission means EOF. */
|
|
80
|
+
readonly input?: string | Uint8Array;
|
|
81
|
+
/** Preserve output bytes as well as the legacy UTF-8 text observation. */
|
|
82
|
+
readonly captureBytes?: boolean;
|
|
83
|
+
/** Use the invoking terminal or pipe when no explicit input is supplied. */
|
|
84
|
+
readonly inheritStdin?: boolean;
|
|
85
|
+
/** Inherit stdout/stderr; observations then contain empty output strings. */
|
|
86
|
+
readonly inheritOutput?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/** Host-independent subprocess observation. */
|
|
89
|
+
interface ProcessObservation {
|
|
90
|
+
readonly exitStatus: number;
|
|
91
|
+
readonly stderr: string;
|
|
92
|
+
readonly stdout: string;
|
|
93
|
+
/** Present when the request asks for byte-exact output capture. */
|
|
94
|
+
readonly stdoutBytes?: Uint8Array;
|
|
95
|
+
readonly stderrBytes?: Uint8Array;
|
|
96
|
+
}
|
|
97
|
+
/** Compiler configuration for the same native target. */
|
|
98
|
+
type NativeBuildConfiguration = "checked" | "optimized";
|
|
99
|
+
/** Files and commands required for one native build. */
|
|
100
|
+
interface NativeBuildPlan {
|
|
101
|
+
/** Defaults to checked when omitted. */
|
|
102
|
+
readonly buildConfiguration?: NativeBuildConfiguration;
|
|
103
|
+
readonly executablePath: string;
|
|
104
|
+
readonly requests: readonly ProcessRequest[];
|
|
105
|
+
readonly runtimeArchivePath?: string;
|
|
106
|
+
readonly target: TargetDescription;
|
|
107
|
+
}
|
|
108
|
+
/** Runtime asset contents covered by one toolchain-owned archive key. */
|
|
109
|
+
interface RuntimeArchiveAsset {
|
|
110
|
+
readonly contents: string;
|
|
111
|
+
readonly kind: RuntimeAsset["kind"];
|
|
112
|
+
readonly name: string;
|
|
113
|
+
}
|
|
114
|
+
/** Complete semantic and tool inputs covered by one runtime archive key. */
|
|
115
|
+
interface RuntimeArchiveKeyInput {
|
|
116
|
+
/** Defaults to checked when omitted. */
|
|
117
|
+
readonly buildConfiguration?: NativeBuildConfiguration;
|
|
118
|
+
readonly runtimeAbiVersion: string;
|
|
119
|
+
readonly runtimeAssets: readonly RuntimeArchiveAsset[];
|
|
120
|
+
readonly target: TargetDescription;
|
|
121
|
+
readonly toolchainEnvironment: ProcessEnvironment;
|
|
122
|
+
readonly toolchainIdentity: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The executable a toolchain identity describes, and the paths whose
|
|
126
|
+
* fingerprints decide whether that identity is still current. A composer
|
|
127
|
+
* that reuses one identity across many builds pins the compiler by this
|
|
128
|
+
* absolute path and rechecks the fingerprints before every build, so an
|
|
129
|
+
* executable replaced or relinked mid-process cannot run under a key
|
|
130
|
+
* derived from the previous one.
|
|
131
|
+
*/
|
|
132
|
+
interface PinnedToolchain {
|
|
133
|
+
readonly compilerPath: string;
|
|
134
|
+
readonly watchedPaths: readonly string[];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Facts a host reports about one path without reading it. The identity
|
|
138
|
+
* fields describe the file the path resolves to, so replacing a file in
|
|
139
|
+
* place and repointing a symbolic link both change them. `realPath` is that
|
|
140
|
+
* resolved location, which a caller pins so later work runs the same file
|
|
141
|
+
* the fingerprint describes.
|
|
142
|
+
*/
|
|
143
|
+
interface FileFingerprint {
|
|
144
|
+
/**
|
|
145
|
+
* Inode change time. It moves on an in-place rewrite even when the writer
|
|
146
|
+
* restores the size and the modification time, which the other fields
|
|
147
|
+
* would then miss. A host that cannot report it leaves it absent, and a
|
|
148
|
+
* caller that depends on detecting such a rewrite must refuse that host
|
|
149
|
+
* rather than compare the remaining fields.
|
|
150
|
+
*/
|
|
151
|
+
readonly changedAtMilliseconds?: number;
|
|
152
|
+
readonly device: number;
|
|
153
|
+
readonly inode: number;
|
|
154
|
+
readonly modifiedAtMilliseconds: number;
|
|
155
|
+
readonly realPath: string;
|
|
156
|
+
readonly size: number;
|
|
157
|
+
}
|
|
158
|
+
/** Optional archive-reuse capability implemented by a native toolchain. */
|
|
159
|
+
interface RuntimeArchiveReuse {
|
|
160
|
+
createKey(input: RuntimeArchiveKeyInput): Promise<string>;
|
|
161
|
+
/**
|
|
162
|
+
* Ask the toolchain to report its identity. `compilerPath` repeats the
|
|
163
|
+
* probe through an already resolved executable, which lets a composer
|
|
164
|
+
* confirm that the identity it is about to record describes the file it
|
|
165
|
+
* pinned rather than whatever the search path resolved a moment earlier.
|
|
166
|
+
*/
|
|
167
|
+
createIdentityRequest(workingDirectory: string, environment: ProcessEnvironment, compilerPath?: string): ProcessRequest;
|
|
168
|
+
/**
|
|
169
|
+
* Read the adapter's own identity output and report which executable it
|
|
170
|
+
* describes. An adapter that cannot name one returns undefined, and a
|
|
171
|
+
* composer must then refuse to prepare rather than reuse an unpinned
|
|
172
|
+
* identity.
|
|
173
|
+
*/
|
|
174
|
+
pinToolchain?(identity: string): PinnedToolchain | undefined;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Explicit inputs used to construct a native build plan. Runtime source
|
|
178
|
+
* paths are an ordered collection: the toolchain compiles every listed
|
|
179
|
+
* translation unit and archives the objects in exactly this order, so
|
|
180
|
+
* filesystem enumeration never selects sources or archive layout.
|
|
181
|
+
*/
|
|
182
|
+
interface NativeBuildInput {
|
|
183
|
+
/** Defaults to checked when omitted. */
|
|
184
|
+
readonly buildConfiguration?: NativeBuildConfiguration;
|
|
185
|
+
/**
|
|
186
|
+
* Absolute path the toolchain must invoke instead of resolving its
|
|
187
|
+
* compiler through the host's search path. A composer that pinned the
|
|
188
|
+
* compiler for a prepared runtime supplies it so that every build of that
|
|
189
|
+
* preparation runs the executable the recorded identity describes.
|
|
190
|
+
*/
|
|
191
|
+
readonly compilerPath?: string;
|
|
192
|
+
readonly environment?: ProcessEnvironment;
|
|
193
|
+
readonly generatedSourcePath: string;
|
|
194
|
+
/** Opt-in additional units and already compiled objects, in link order. */
|
|
195
|
+
readonly additionalGeneratedSourcePaths?: readonly string[];
|
|
196
|
+
readonly prebuiltObjectPaths?: readonly string[];
|
|
197
|
+
readonly prebuiltRuntimeArchivePath?: string;
|
|
198
|
+
readonly runtimeDirectory: string;
|
|
199
|
+
readonly runtimeSourcePaths: readonly string[];
|
|
200
|
+
readonly target: TargetDescription;
|
|
201
|
+
readonly workingDirectory: string;
|
|
202
|
+
}
|
|
203
|
+
/** Toolchain boundary that constructs commands without executing them. */
|
|
204
|
+
interface NativeToolchain {
|
|
205
|
+
/** Configuration selected by a composing test or application. */
|
|
206
|
+
readonly buildConfiguration?: NativeBuildConfiguration;
|
|
207
|
+
/** Exact compiler identity retained in failure and replay metadata. */
|
|
208
|
+
readonly identity?: string;
|
|
209
|
+
createBuildPlan(input: NativeBuildInput): NativeBuildPlan;
|
|
210
|
+
readonly environment?: ProcessEnvironmentPolicy;
|
|
211
|
+
readonly runtimeArchiveReuse?: RuntimeArchiveReuse;
|
|
212
|
+
readonly harnessObjectReuse?: HarnessObjectReuse;
|
|
213
|
+
}
|
|
214
|
+
/** Exclusive lease over one host-owned compiler cache path. */
|
|
215
|
+
interface CompilerCacheLock {
|
|
216
|
+
release(): Promise<void>;
|
|
217
|
+
}
|
|
218
|
+
/** Persistent cache storage whose location and lifetime belong to one host. */
|
|
219
|
+
interface CompilerCache {
|
|
220
|
+
acquireFileLock(path: string): Promise<CompilerCacheLock>;
|
|
221
|
+
getDirectory(name: string): Promise<string>;
|
|
222
|
+
hasFile(path: string): Promise<boolean>;
|
|
223
|
+
publishFile(sourcePath: string, destinationPath: string): Promise<void>;
|
|
224
|
+
}
|
|
225
|
+
/** Narrow host boundary used by compiler adapters and test infrastructure. */
|
|
226
|
+
interface CompilerHost {
|
|
227
|
+
readonly cache?: CompilerCache;
|
|
228
|
+
canonicalizeFile?(path: string): Promise<string>;
|
|
229
|
+
/**
|
|
230
|
+
* Report one path's fingerprint without reading it, or undefined when the
|
|
231
|
+
* path does not exist. It is a stat, so a caller may repeat it per native
|
|
232
|
+
* execution.
|
|
233
|
+
*/
|
|
234
|
+
describeFile?(path: string): Promise<FileFingerprint | undefined>;
|
|
235
|
+
captureEnvironment?(policy: ProcessEnvironmentPolicy): Promise<ProcessEnvironment | undefined>;
|
|
236
|
+
readonly executionHost?: ExecutionHostDescription;
|
|
237
|
+
makeTemporaryDirectory(prefix: string): Promise<string>;
|
|
238
|
+
readTextFile(path: string | URL): Promise<string>;
|
|
239
|
+
remove(path: string): Promise<void>;
|
|
240
|
+
run(request: ProcessRequest): Promise<ProcessObservation>;
|
|
241
|
+
writeTextFile(path: string, contents: string): Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
/** Return the immutable artifact facts for an explicit native target. */
|
|
244
|
+
declare function describeTarget(name: TargetName): TargetDescription;
|
|
245
|
+
/** Whether one normalized host may execute an artifact for a target. */
|
|
246
|
+
declare function canExecuteTarget(host: ExecutionHostDescription, target: TargetDescription): boolean;
|
|
247
|
+
/** Select the supported native target matching one execution host. */
|
|
248
|
+
declare function targetForExecutionHost(host: ExecutionHostDescription): TargetDescription | undefined;
|
|
249
|
+
/** Normalized object staging contains harness.c and runtime headers. */
|
|
250
|
+
interface HarnessObjectBuildInput {
|
|
251
|
+
/** Defaults to checked when omitted. */
|
|
252
|
+
readonly buildConfiguration?: NativeBuildConfiguration;
|
|
253
|
+
/** Pinned compiler, with the same meaning as on `NativeBuildInput`. */
|
|
254
|
+
readonly compilerPath?: string;
|
|
255
|
+
readonly workingDirectory: string;
|
|
256
|
+
readonly target: TargetDescription;
|
|
257
|
+
readonly environment: ProcessEnvironment;
|
|
258
|
+
}
|
|
259
|
+
/** Complete bundle, compiler, runtime, and tool inputs for object reuse. */
|
|
260
|
+
interface HarnessObjectKeyInput extends RuntimeArchiveKeyInput {
|
|
261
|
+
readonly fragmentAbiVersion: string;
|
|
262
|
+
readonly harnessSources: readonly {
|
|
263
|
+
readonly sourceId: string;
|
|
264
|
+
readonly source: string;
|
|
265
|
+
}[];
|
|
266
|
+
readonly strict: boolean;
|
|
267
|
+
readonly specialization: "enabled" | "disabled";
|
|
268
|
+
readonly observeSpecialization: boolean;
|
|
269
|
+
/** Content identities must include uncommitted implementation changes. */
|
|
270
|
+
readonly frontendIdentity: string;
|
|
271
|
+
readonly compilerIdentity: string;
|
|
272
|
+
readonly backendIdentity: string;
|
|
273
|
+
readonly generatedSource: string;
|
|
274
|
+
}
|
|
275
|
+
/** Adapter-owned flags are included by createKey, never supplied ambiently. */
|
|
276
|
+
interface HarnessObjectReuse {
|
|
277
|
+
createKey(input: HarnessObjectKeyInput): Promise<string>;
|
|
278
|
+
createBuildRequest(input: HarnessObjectBuildInput): ProcessRequest;
|
|
279
|
+
}
|
|
280
|
+
//#endregion
|
|
281
|
+
export { CompilerCache, CompilerCacheLock, CompilerHost, EmittedNativeSource, ExecutionHostDescription, FileFingerprint, HarnessObjectBuildInput, HarnessObjectKeyInput, HarnessObjectReuse, NativeAbi, NativeArchitecture, NativeBackend, NativeBuildConfiguration, NativeBuildInput, NativeBuildPlan, NativeOperatingSystem, NativeSourceFile, NativeToolchain, PinnedToolchain, ProcessEnvironment, ProcessEnvironmentPolicy, ProcessObservation, ProcessRequest, RuntimeArchiveAsset, RuntimeArchiveKeyInput, RuntimeArchiveReuse, RuntimeAsset, RuntimeInput, RuntimeInputProvider, TargetDescription, TargetName, canExecuteTarget, describeTarget, targetForExecutionHost };
|
|
282
|
+
//# sourceMappingURL=native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.d.ts","names":[],"sources":["../src/native.ts"],"mappings":";;;KAoBY;;KAGA;;KAGA;;KAGA;;UAMK;WACN,cAAc;WACd,iBAAiB;;;UAIX;WACN,MAAM;WACN,cAAc;;;;;WAKd;WACA;WACA;WACA,MAAM;WACN,iBAAiB;WACjB;;;UAIM;WACN;WACA;;;UAIM,4BAA4B;;;;;WAKlC,4BAA4B;;;UAItB;EACf,KAAK,OAAO,aAAa;;;UAIV;WACN;WACA;WACA,KAAK;;;UAIC;WACN;WACA,iBAAiB;;;UAIX;EACf,mBAAmB;;;;;UAMJ;WACN;;;UAIM;WACN,WAAW,SAAS;;;UAId;WACN;WACA;WACA;WACA,cAAc;;WAEd,iBAAiB;;WAEjB;;WAEA;;WAEA;;;UAIM;WACN;WACA;WACA;;WAEA,cAAc;WACd,cAAc;;;KAIb;;UAGK;;WAEN,qBAAqB;WACrB;WACA,mBAAmB;WACnB;WACA,QAAQ;;;UAIF;WACN;WACA,MAAM;WACN;;;UAIM;;WAEN,qBAAqB;WACrB;WACA,wBAAwB;WACxB,QAAQ;WACR,sBAAsB;WACtB;;;;;;;;;;UAWM;WACN;WACA;;;;;;;;;UAUM;;;;;;;;WAQN;WACA;WACA;WACA;WACA;WACA;;;UAIM;EACf,UAAU,OAAO,yBAAyB;;;;;;;EAO1C,sBACE,0BACA,aAAa,oBACb,wBACC;;;;;;;EAOH,cAAc,mBAAmB;;;;;;;;UASlB;;WAEN,qBAAqB;;;;;;;WAOrB;WACA,cAAc;WACd;;WAEA;WACA;WACA;WACA;WACA;WACA,QAAQ;WACR;;;UAIM;;WAEN,qBAAqB;;WAErB;EACT,gBAAgB,OAAO,mBAAmB;WACjC,cAAc;WACd,sBAAsB;WACtB,qBAAqB;;;UAIf;EACf,WAAW;;;UAII;EACf,gBAAgB,eAAe,QAAQ;EACvC,aAAa,eAAe;EAC5B,QAAQ,eAAe;EACvB,YAAY,oBAAoB,0BAA0B;;;UAI3C;WACN,QAAQ;EACjB,kBAAkB,eAAe;;;;;;EAMjC,cAAc,eAAe,QAAQ;EACrC,oBACE,QAAQ,2BACP,QAAQ;WACF,gBAAgB;EACzB,uBAAuB,iBAAiB;EACxC,aAAa,eAAe,MAAM;EAClC,OAAO,eAAe;EACtB,IAAI,SAAS,iBAAiB,QAAQ;EACtC,cAAc,cAAc,mBAAmB;;;iBAIjC,eAAe,MAAM,aAAa;;iBAwClC,iBACd,MAAM,0BACN,QAAQ;;iBAMM,uBACd,MAAM,2BACL;;UAWc;;WAEN,qBAAqB;;WAErB;WACA;WACA,QAAQ;WACR,aAAa;;;UAIP,8BAA8B;WACpC;WACA;aACE;aACA;;WAEF;WACA;WACA;;WAEA;WACA;WACA;WACA;;;UAIM;EACf,UAAU,OAAO,wBAAwB;EACzC,mBAAmB,OAAO,0BAA0B"}
|
package/dist/native.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//#region src/native.ts
|
|
2
|
+
/** Return the immutable artifact facts for an explicit native target. */
|
|
3
|
+
function describeTarget(name) {
|
|
4
|
+
if (name === "linux-x86_64-gnu") return {
|
|
5
|
+
abi: "gnu",
|
|
6
|
+
architecture: "x86_64",
|
|
7
|
+
atomicsPauseHint: "x86-pause",
|
|
8
|
+
cStandard: "c11",
|
|
9
|
+
executableFormat: "elf",
|
|
10
|
+
name,
|
|
11
|
+
operatingSystem: "linux",
|
|
12
|
+
sanitizers: ["address", "undefined"]
|
|
13
|
+
};
|
|
14
|
+
if (name === "macos-aarch64") return {
|
|
15
|
+
architecture: "aarch64",
|
|
16
|
+
atomicsPauseHint: "aarch64-yield",
|
|
17
|
+
cStandard: "c11",
|
|
18
|
+
executableFormat: "mach-o",
|
|
19
|
+
name,
|
|
20
|
+
operatingSystem: "macos",
|
|
21
|
+
sanitizers: ["address", "undefined"]
|
|
22
|
+
};
|
|
23
|
+
if (name === "linux-aarch64-musl") return {
|
|
24
|
+
abi: "musl",
|
|
25
|
+
architecture: "aarch64",
|
|
26
|
+
atomicsPauseHint: "aarch64-yield",
|
|
27
|
+
cStandard: "c11",
|
|
28
|
+
executableFormat: "elf",
|
|
29
|
+
name,
|
|
30
|
+
operatingSystem: "linux",
|
|
31
|
+
sanitizers: []
|
|
32
|
+
};
|
|
33
|
+
throw new Error(`Unsupported native target '${String(name)}'.`);
|
|
34
|
+
}
|
|
35
|
+
/** Whether one normalized host may execute an artifact for a target. */
|
|
36
|
+
function canExecuteTarget(host, target) {
|
|
37
|
+
return targetForExecutionHost(host)?.name === target.name;
|
|
38
|
+
}
|
|
39
|
+
/** Select the supported native target matching one execution host. */
|
|
40
|
+
function targetForExecutionHost(host) {
|
|
41
|
+
if (host.architecture === "x86_64" && host.operatingSystem === "linux") return describeTarget("linux-x86_64-gnu");
|
|
42
|
+
if (host.architecture === "aarch64" && host.operatingSystem === "macos") return describeTarget("macos-aarch64");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
export { canExecuteTarget, describeTarget, targetForExecutionHost };
|
|
47
|
+
//# sourceMappingURL=native.js.map
|