eliscript 0.0.1 → 0.0.3

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.
Files changed (417) hide show
  1. package/README.md +61 -0
  2. package/bootstrap/README.md +26 -0
  3. package/bootstrap/backends/README.md +515 -0
  4. package/bootstrap/backends/async.eli +230 -0
  5. package/bootstrap/backends/binary.eli +173 -0
  6. package/bootstrap/backends/capabilities.eli +74 -0
  7. package/bootstrap/backends/elf.eli +246 -0
  8. package/bootstrap/backends/managed.eli +5976 -0
  9. package/bootstrap/backends/memory.eli +100 -0
  10. package/bootstrap/backends/native.eli +2000 -0
  11. package/bootstrap/backends/numeric.eli +1362 -0
  12. package/bootstrap/backends/optimize.eli +79 -0
  13. package/bootstrap/backends/regexp.eli +2263 -0
  14. package/bootstrap/backends/sha256.eli +138 -0
  15. package/bootstrap/backends/wasm.eli +1161 -0
  16. package/bootstrap/compiler/analyzer.eli +165 -77
  17. package/bootstrap/compiler/compiler.eli +43 -19
  18. package/bootstrap/compiler/emitter.eli +780 -170
  19. package/bootstrap/compiler/expander.eli +136 -45
  20. package/bootstrap/compiler/formatter.eli +8 -1
  21. package/bootstrap/compiler/ir.eli +148 -45
  22. package/bootstrap/compiler/lower.eli +29 -2
  23. package/bootstrap/compiler/project.eli +51 -21
  24. package/bootstrap/compiler/reader.eli +128 -36
  25. package/bootstrap/compiler/source-map.eli +46 -4
  26. package/bootstrap/compiler/symbol.eli +2 -1
  27. package/bootstrap/compiler/syntax.eli +47 -12
  28. package/bootstrap/compiler/transient-analysis.eli +40 -4
  29. package/bootstrap/host/check-cli-legacy.mjs +163 -0
  30. package/bootstrap/host/check-cli.mjs +59 -158
  31. package/bootstrap/host/check-cli.mjs.map +1 -0
  32. package/bootstrap/host/compiler-session.eli +1579 -0
  33. package/bootstrap/host/compiler-tools.eli +513 -0
  34. package/bootstrap/host/eliscript-cli.mjs +53 -33
  35. package/bootstrap/host/eliscript-cli.mjs.map +1 -0
  36. package/bootstrap/host/project-cli-legacy.mjs +295 -0
  37. package/bootstrap/host/project-cli.mjs +74 -289
  38. package/bootstrap/host/project-cli.mjs.map +1 -0
  39. package/bootstrap/host/project-legacy.mjs +1080 -0
  40. package/bootstrap/host/project.mjs +210 -1060
  41. package/bootstrap/host/project.mjs.map +1 -0
  42. package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
  43. package/bootstrap/runtime/memory.eli +30379 -0
  44. package/browser/host.mjs +732 -11
  45. package/browser/worker.mjs +6 -3
  46. package/compiler/eliscript-analyzer.el +371 -4
  47. package/compiler/eliscript-cli.el +84 -1
  48. package/compiler/eliscript-emitter.el +1189 -256
  49. package/compiler/eliscript-expander.el +147 -10
  50. package/compiler/eliscript-ir-emitter.el +725 -208
  51. package/compiler/eliscript-lower.el +127 -1
  52. package/compiler/eliscript-portable.el +177 -51
  53. package/compiler/eliscript-project.el +20 -2
  54. package/compiler/eliscript-reader.el +141 -57
  55. package/compiler/eliscript-source-map.el +26 -12
  56. package/compiler/eliscript-transient-analysis.el +382 -19
  57. package/dist/backends/async.mjs +561 -0
  58. package/dist/backends/async.mjs.macro-origins.json +1 -0
  59. package/dist/backends/async.mjs.map +1 -0
  60. package/dist/backends/binary.mjs +381 -0
  61. package/dist/backends/binary.mjs.macro-origins.json +1 -0
  62. package/dist/backends/binary.mjs.map +1 -0
  63. package/dist/backends/capabilities.mjs +237 -0
  64. package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
  65. package/dist/backends/capabilities.mjs.map +1 -0
  66. package/dist/backends/elf.mjs +540 -0
  67. package/dist/backends/elf.mjs.macro-origins.json +1 -0
  68. package/dist/backends/elf.mjs.map +1 -0
  69. package/dist/backends/managed.mjs +10616 -0
  70. package/dist/backends/managed.mjs.macro-origins.json +1 -0
  71. package/dist/backends/managed.mjs.map +1 -0
  72. package/dist/backends/memory.mjs +278 -0
  73. package/dist/backends/memory.mjs.macro-origins.json +1 -0
  74. package/dist/backends/memory.mjs.map +1 -0
  75. package/dist/backends/native.mjs +4099 -0
  76. package/dist/backends/native.mjs.macro-origins.json +1 -0
  77. package/dist/backends/native.mjs.map +1 -0
  78. package/dist/backends/numeric.mjs +2458 -0
  79. package/dist/backends/numeric.mjs.macro-origins.json +1 -0
  80. package/dist/backends/numeric.mjs.map +1 -0
  81. package/dist/backends/optimize.mjs +204 -0
  82. package/dist/backends/optimize.mjs.macro-origins.json +1 -0
  83. package/dist/backends/optimize.mjs.map +1 -0
  84. package/dist/backends/regexp.mjs +2033 -0
  85. package/dist/backends/regexp.mjs.macro-origins.json +1 -0
  86. package/dist/backends/regexp.mjs.map +1 -0
  87. package/dist/backends/sha256.mjs +310 -0
  88. package/dist/backends/sha256.mjs.macro-origins.json +1 -0
  89. package/dist/backends/sha256.mjs.map +1 -0
  90. package/dist/backends/wasm.mjs +2258 -0
  91. package/dist/backends/wasm.mjs.macro-origins.json +1 -0
  92. package/dist/backends/wasm.mjs.map +1 -0
  93. package/dist/bootstrap/analyzer.mjs +1908 -776
  94. package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
  95. package/dist/bootstrap/analyzer.mjs.map +1 -1
  96. package/dist/bootstrap/compiler.mjs +450 -142
  97. package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
  98. package/dist/bootstrap/compiler.mjs.map +1 -1
  99. package/dist/bootstrap/emitter.mjs +3083 -909
  100. package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
  101. package/dist/bootstrap/emitter.mjs.map +1 -1
  102. package/dist/bootstrap/expander.mjs +2887 -1233
  103. package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
  104. package/dist/bootstrap/expander.mjs.map +1 -1
  105. package/dist/bootstrap/formatter.mjs +582 -218
  106. package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
  107. package/dist/bootstrap/formatter.mjs.map +1 -1
  108. package/dist/bootstrap/ir.mjs +670 -116
  109. package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
  110. package/dist/bootstrap/ir.mjs.map +1 -1
  111. package/dist/bootstrap/lower.mjs +866 -257
  112. package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
  113. package/dist/bootstrap/lower.mjs.map +1 -1
  114. package/dist/bootstrap/package.json +1 -0
  115. package/dist/bootstrap/project.mjs +1168 -498
  116. package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
  117. package/dist/bootstrap/project.mjs.map +1 -1
  118. package/dist/bootstrap/reader.mjs +674 -175
  119. package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
  120. package/dist/bootstrap/reader.mjs.map +1 -1
  121. package/dist/bootstrap/runtime/math.mjs +1117 -0
  122. package/dist/bootstrap/runtime/math.mjs.map +1 -0
  123. package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
  124. package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
  125. package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
  126. package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
  127. package/dist/bootstrap/source-map.mjs +430 -119
  128. package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
  129. package/dist/bootstrap/source-map.mjs.map +1 -1
  130. package/dist/bootstrap/symbol.mjs +229 -53
  131. package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
  132. package/dist/bootstrap/symbol.mjs.map +1 -1
  133. package/dist/bootstrap/syntax.mjs +205 -7
  134. package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
  135. package/dist/bootstrap/syntax.mjs.map +1 -1
  136. package/dist/bootstrap/transient-analysis.mjs +1185 -489
  137. package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
  138. package/dist/bootstrap/transient-analysis.mjs.map +1 -1
  139. package/dist/browser/compiler.js +199 -6478
  140. package/dist/browser/host.mjs +1078 -0
  141. package/dist/browser/loader.js +1 -0
  142. package/dist/browser/loader.mjs +231 -0
  143. package/dist/browser/worker.mjs +63 -0
  144. package/dist/compiler-artifact.json +1 -0
  145. package/dist/host/compiler-session.mjs +2980 -0
  146. package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
  147. package/dist/host/compiler-session.mjs.map +1 -0
  148. package/dist/host/compiler-tools.mjs +1084 -0
  149. package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
  150. package/dist/host/compiler-tools.mjs.map +1 -0
  151. package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
  152. package/dist/literal-sources/runtime/core/collection.eli +639 -0
  153. package/dist/literal-sources/runtime/core/data-text.eli +290 -0
  154. package/dist/literal-sources/runtime/core/data.eli +22 -0
  155. package/dist/literal-sources/runtime/core/identifier.eli +44 -0
  156. package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
  157. package/dist/literal-sources/runtime/core/list.eli +19 -0
  158. package/dist/literal-sources/runtime/core/map.eli +9 -0
  159. package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
  160. package/dist/literal-sources/runtime/core/metadata.eli +40 -0
  161. package/dist/literal-sources/runtime/core/object.eli +8 -0
  162. package/dist/literal-sources/runtime/core/order.eli +123 -0
  163. package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
  164. package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
  165. package/dist/literal-sources/runtime/core/protocol.eli +28 -0
  166. package/dist/literal-sources/runtime/core/queue.eli +9 -0
  167. package/dist/literal-sources/runtime/core/record.eli +191 -0
  168. package/dist/literal-sources/runtime/core/regex.eli +158 -0
  169. package/dist/literal-sources/runtime/core/sequence.eli +305 -0
  170. package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
  171. package/dist/literal-sources/runtime/core/set.eli +9 -0
  172. package/dist/literal-sources/runtime/core/sorted.eli +408 -0
  173. package/dist/literal-sources/runtime/core/text.eli +14 -0
  174. package/dist/literal-sources/runtime/core/transducer.eli +268 -0
  175. package/dist/literal-sources/runtime/core/transient.eli +17 -0
  176. package/dist/literal-sources/runtime/core/truth.eli +4 -0
  177. package/dist/literal-sources/runtime/core/type.eli +232 -0
  178. package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
  179. package/dist/literal-sources/runtime/core/value.eli +19 -0
  180. package/dist/literal-sources/runtime/core/vector.eli +25 -0
  181. package/dist/literal-sources/runtime/literals.eli +23 -0
  182. package/dist/literal-sources/runtime/testing/value.eli +6 -0
  183. package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
  184. package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
  185. package/dist/literal-sources/runtime/wire/schema.eli +193 -0
  186. package/dist/literal-sources/stdlib/bit.eli +36 -0
  187. package/dist/literal-sources/stdlib/core/data.eli +306 -0
  188. package/dist/literal-sources/stdlib/core/object.eli +89 -0
  189. package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
  190. package/dist/literal-sources/stdlib/core/set.eli +312 -0
  191. package/dist/literal-sources/stdlib/core/text.eli +103 -0
  192. package/dist/literal-sources/stdlib/managed-literal-protocols.eli +494 -0
  193. package/dist/literal-sources/stdlib/managed-literals.eli +1469 -0
  194. package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
  195. package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
  196. package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
  197. package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
  198. package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
  199. package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
  200. package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
  201. package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
  202. package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
  203. package/dist/literal-sources/stdlib/value.eli +325 -0
  204. package/dist/package.json +10 -0
  205. package/dist/runtime/math.mjs +1116 -0
  206. package/dist/runtime/math.mjs.macro-origins.json +1 -0
  207. package/dist/runtime/math.mjs.map +1 -0
  208. package/dist/runtime/unicode-case-data.mjs +10124 -0
  209. package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
  210. package/dist/runtime/unicode-case-data.mjs.map +1 -0
  211. package/dist/runtime/unicode-case.mjs +280 -0
  212. package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
  213. package/dist/runtime/unicode-case.mjs.map +1 -0
  214. package/dist/runtime.eli +30379 -0
  215. package/dist/stage3-release.json +1 -0
  216. package/editor/README.md +1 -1
  217. package/editor/eliscript-mode.el +1 -1
  218. package/editor/eliscript-repl.el +1 -1
  219. package/package.json +106 -11
  220. package/platform/http.mjs +20 -0
  221. package/runtime/array-text.mjs +159 -0
  222. package/runtime/core/map-internals.mjs +27 -9
  223. package/runtime/core/object-impl.mjs +26 -17
  224. package/runtime/core/object-impl.mjs.map +1 -1
  225. package/runtime/core/protocol-impl.mjs +682 -255
  226. package/runtime/core/protocol-impl.mjs.map +1 -1
  227. package/runtime/core/protocol.mjs +4 -0
  228. package/runtime/core/record.mjs +23 -2
  229. package/runtime/core/regex.mjs +4 -0
  230. package/runtime/core/sorted.mjs +53 -0
  231. package/runtime/core/text-impl.mjs +167 -48
  232. package/runtime/core/text-impl.mjs.map +1 -1
  233. package/runtime/core/type.mjs +75 -3
  234. package/runtime/core/vector.mjs +6 -0
  235. package/runtime/math.eli +429 -0
  236. package/runtime/math.mjs +1116 -0
  237. package/runtime/math.mjs.map +1 -0
  238. package/runtime/number-radix.mjs +105 -0
  239. package/runtime/unicode-case-data.eli +29 -0
  240. package/runtime/unicode-case-data.mjs +10124 -0
  241. package/runtime/unicode-case-data.mjs.map +1 -0
  242. package/runtime/unicode-case.eli +100 -0
  243. package/runtime/unicode-case.mjs +280 -0
  244. package/runtime/unicode-case.mjs.map +1 -0
  245. package/runtime/wire/http-rpc.mjs +168 -0
  246. package/runtime/wire/markdown.mjs +196 -0
  247. package/runtime/wire/schema.mjs +109 -0
  248. package/stdlib/README.md +54 -0
  249. package/stdlib/core/protocol.eli +81 -17
  250. package/stdlib/core/seq.eli +1 -1
  251. package/stdlib/core/zipper.eli +172 -72
  252. package/stdlib/gepo.eli +12 -0
  253. package/stdlib/interop/js.eli +56 -15
  254. package/stdlib/managed-literal-protocols.eli +494 -0
  255. package/stdlib/managed-literals.eli +1469 -0
  256. package/stdlib/managed-protocol-error.eli +32 -0
  257. package/stdlib/managed-queue-state.eli +65 -0
  258. package/stdlib/managed-runtime-collection-internals.eli +60 -0
  259. package/stdlib/managed-runtime-collection.eli +639 -0
  260. package/stdlib/managed-runtime-data-text.eli +290 -0
  261. package/stdlib/managed-runtime-data.eli +22 -0
  262. package/stdlib/managed-runtime-identifier.eli +44 -0
  263. package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
  264. package/stdlib/managed-runtime-list.eli +19 -0
  265. package/stdlib/managed-runtime-literals.eli +23 -0
  266. package/stdlib/managed-runtime-map.eli +9 -0
  267. package/stdlib/managed-runtime-metadata-internals.eli +6 -0
  268. package/stdlib/managed-runtime-metadata.eli +40 -0
  269. package/stdlib/managed-runtime-object.eli +8 -0
  270. package/stdlib/managed-runtime-order.eli +123 -0
  271. package/stdlib/managed-runtime-persistent-kind.eli +28 -0
  272. package/stdlib/managed-runtime-protocol.eli +28 -0
  273. package/stdlib/managed-runtime-queue.eli +9 -0
  274. package/stdlib/managed-runtime-record.eli +191 -0
  275. package/stdlib/managed-runtime-regex.eli +158 -0
  276. package/stdlib/managed-runtime-sequence.eli +305 -0
  277. package/stdlib/managed-runtime-set-algebra.eli +28 -0
  278. package/stdlib/managed-runtime-set.eli +9 -0
  279. package/stdlib/managed-runtime-sorted.eli +408 -0
  280. package/stdlib/managed-runtime-text.eli +14 -0
  281. package/stdlib/managed-runtime-transducer.eli +268 -0
  282. package/stdlib/managed-runtime-transient.eli +17 -0
  283. package/stdlib/managed-runtime-truth.eli +4 -0
  284. package/stdlib/managed-runtime-type.eli +232 -0
  285. package/stdlib/managed-runtime-value-internals.eli +13 -0
  286. package/stdlib/managed-runtime-value.eli +19 -0
  287. package/stdlib/managed-runtime-vector.eli +25 -0
  288. package/stdlib/managed-sorted-state.eli +233 -0
  289. package/stdlib/managed-testing-value.eli +6 -0
  290. package/stdlib/managed-transient-state.eli +348 -0
  291. package/stdlib/managed-value-state.eli +153 -0
  292. package/stdlib/managed-vector-view-state.eli +102 -0
  293. package/stdlib/managed-wire-http-rpc.eli +362 -0
  294. package/stdlib/managed-wire-markdown.eli +275 -0
  295. package/stdlib/managed-wire-schema.eli +193 -0
  296. package/stdlib/mdp.eli +7 -0
  297. package/stdlib/mds.eli +4 -0
  298. package/stdlib/persistent-vector.eli +23 -6
  299. package/tools/acceptance/check-legacy.mjs +687 -0
  300. package/tools/acceptance/check.eli +431 -0
  301. package/tools/acceptance/compile-evidence.el +49 -0
  302. package/tools/acceptance/finalize-legacy.mjs +498 -0
  303. package/tools/acceptance/finalize.eli +270 -0
  304. package/tools/backends/benchmark.mjs +175 -0
  305. package/tools/backends/build.mjs +135 -0
  306. package/tools/backends/compile.mjs +94 -0
  307. package/tools/backends/compiler-bootstrap.mjs +1001 -0
  308. package/tools/backends/compiler-browser.mjs +361 -0
  309. package/tools/backends/compiler-build.mjs +1628 -0
  310. package/tools/backends/compiler-cli-legacy.mjs +334 -0
  311. package/tools/backends/compiler-cli.mjs +29 -0
  312. package/tools/backends/compiler-corpus-bit.mjs +234 -0
  313. package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
  314. package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
  315. package/tools/backends/compiler-corpus-debugging.mjs +221 -0
  316. package/tools/backends/compiler-corpus-emitter.mjs +324 -0
  317. package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
  318. package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
  319. package/tools/backends/compiler-corpus-execution.mjs +3324 -0
  320. package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
  321. package/tools/backends/compiler-corpus-generations.mjs +208 -0
  322. package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
  323. package/tools/backends/compiler-corpus-host-context.mjs +550 -0
  324. package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
  325. package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
  326. package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
  327. package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
  328. package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
  329. package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
  330. package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
  331. package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
  332. package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
  333. package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
  334. package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
  335. package/tools/backends/compiler-corpus-matchers.mjs +173 -0
  336. package/tools/backends/compiler-corpus-original-program.mjs +612 -0
  337. package/tools/backends/compiler-corpus-process.mjs +765 -0
  338. package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
  339. package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
  340. package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
  341. package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
  342. package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
  343. package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
  344. package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
  345. package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
  346. package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
  347. package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
  348. package/tools/backends/compiler-corpus-reference.mjs +241 -0
  349. package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
  350. package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
  351. package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
  352. package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
  353. package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
  354. package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
  355. package/tools/backends/compiler-corpus.mjs +2054 -0
  356. package/tools/backends/compiler-debug.mjs +142 -0
  357. package/tools/backends/compiler-matrix.mjs +1955 -0
  358. package/tools/backends/compiler-metadata.mjs +203 -0
  359. package/tools/backends/compiler-package-browser.mjs +120 -0
  360. package/tools/backends/compiler-package-legacy.mjs +654 -0
  361. package/tools/backends/compiler-package.mjs +464 -0
  362. package/tools/backends/compiler-project.mjs +126 -0
  363. package/tools/backends/compiler-session.mjs +843 -0
  364. package/tools/backends/compiler-sha256.mjs +152 -0
  365. package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
  366. package/tools/backends/compiler-worker.mjs +573 -0
  367. package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
  368. package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
  369. package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
  370. package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
  371. package/tools/backends/dist/record-grid.mjs +1256 -0
  372. package/tools/backends/dist/record-grid.mjs.map +1 -0
  373. package/tools/backends/dist/release-cli.mjs +462 -0
  374. package/tools/backends/dist/release-cli.mjs.map +1 -0
  375. package/tools/backends/dist/run-artifact.mjs +517 -0
  376. package/tools/backends/dist/run-artifact.mjs.map +1 -0
  377. package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
  378. package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
  379. package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
  380. package/tools/backends/managed-foreign-binding.mjs +497 -0
  381. package/tools/backends/managed-host-legacy.mjs +1181 -0
  382. package/tools/backends/managed-host-lifecycle.mjs +310 -0
  383. package/tools/backends/managed-host-object-provider.mjs +155 -0
  384. package/tools/backends/managed-host-object-realm.mjs +797 -0
  385. package/tools/backends/managed-host-proxy.mjs +71 -0
  386. package/tools/backends/managed-host-runtime.mjs +5868 -0
  387. package/tools/backends/managed-host.mjs +716 -0
  388. package/tools/backends/managed-module-graph-legacy.mjs +308 -0
  389. package/tools/backends/managed-module-graph.mjs +694 -0
  390. package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
  391. package/tools/backends/managed-runtime.mjs +939 -0
  392. package/tools/backends/managed-source-view-legacy.mjs +332 -0
  393. package/tools/backends/managed-source-view.mjs +959 -0
  394. package/tools/backends/memory-runtime.mjs +100 -0
  395. package/tools/backends/native-benchmark.mjs +88 -0
  396. package/tools/backends/native-managed-runtime.mjs +677 -0
  397. package/tools/backends/native-memory.mjs +768 -0
  398. package/tools/backends/native-node-memory.mjs +142 -0
  399. package/tools/backends/native-node-runner.mjs +99 -0
  400. package/tools/backends/native-node-watchdog.mjs +19 -0
  401. package/tools/backends/native-node-worker.mjs +75 -0
  402. package/tools/backends/stage3-targets.mjs +493 -0
  403. package/tools/bootstrap-command.el +13 -0
  404. package/tools/bootstrap-runtime.el +101 -0
  405. package/tools/bootstrap-seed.el +55 -0
  406. package/tools/project/check-cli.eli +31 -0
  407. package/tools/project/project-cli.eli +42 -0
  408. package/tools/project/project.eli +122 -0
  409. package/tools/runtime/unicode-case-profiles.mjs +13 -0
  410. package/tools/runtime/unicode-case-runtime.el +57 -0
  411. package/tools/testing/source-debugging-corpus-host.eli +16 -0
  412. package/tools/testing/source-debugging.eli +139 -0
  413. package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
  414. package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
  415. package/tools/testing/stdlib-bit.eli +104 -0
  416. package/tools/testing/stdlib-bit.mjs +255 -0
  417. package/bin/eliscript-bootstrap +0 -15
@@ -0,0 +1,1628 @@
1
+ // Generated by Eliscript. Do not edit.
2
+ import { tdz as __eliscript_tdz_error, immutable as __eliscript_const_error } from "data:text/javascript;base64,Y29uc3QgRSA9IFJlZmVyZW5jZUVycm9yOyBjb25zdCBUID0gVHlwZUVycm9yOyBleHBvcnQgZnVuY3Rpb24gdGR6KG5hbWUpIHsgdGhyb3cgbmV3IEUoIkNhbm5vdCBhY2Nlc3MgJyIgKyBuYW1lICsgIicgYmVmb3JlIGluaXRpYWxpemF0aW9uIik7IH0gZXhwb3J0IGZ1bmN0aW9uIGltbXV0YWJsZSgpIHsgdGhyb3cgbmV3IFQoIkFzc2lnbm1lbnQgdG8gY29uc3RhbnQgdmFyaWFibGUuIik7IH0K";
3
+ var __eliscript_tdz_ready_0;
4
+ function __eliscript_tdz_read_0() { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("independentCompilerProfiles"); return independentCompilerProfiles; }
5
+ function __eliscript_tdz_write_0(__eliscript_tdz_value_0) { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("independentCompilerProfiles"); return __eliscript_const_error(); }
6
+ import "eliscript/runtime/unicode-case.mjs";
7
+ import "eliscript/runtime/math.mjs";
8
+ import { c as __eliscript_at, d as __eliscript_at_direct } from "data:text/javascript;base64,dmFyIG09UmVmbGVjdC5hcHBseSx0dD1OdW1iZXIucHJvdG90eXBlLnZhbHVlT2Ysaj1OdW1iZXIucHJvdG90eXBlLnRvU3RyaW5nLFU9TnVtYmVyLG50PU9iamVjdC5jcmVhdGUsaD1CaWdJbnQsZXQ9RGF0YVZpZXcsb3Q9QXJyYXlCdWZmZXIsaXQ9RGF0YVZpZXcucHJvdG90eXBlLnNldEZsb2F0NjQsSj1EYXRhVmlldy5wcm90b3R5cGUuZ2V0VWludDMyLHJ0PVJhbmdlRXJyb3I7ZnVuY3Rpb24gY3QodCxuKXtsZXQgZT1oKG4pLG89aCh0KSxpPSIiO2lmKG88MG4pbz0tbztkb3tsZXQgZj1vJWU7aT0iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltVKGYpXStpLG8vPWV9d2hpbGUobyE9PTBuKTtyZXR1cm4gdDwwPyItIitpOml9ZnVuY3Rpb24gc3QodCxuKXtsZXQgZT1uZXcgZXQobmV3IG90KDgpKTttKGl0LGUsWzAsdCwhMV0pO2xldCBvPW0oSixlLFswLCExXSksaT1tKEosZSxbNCwhMV0pLGY9bz4+PjIwJjIwNDcsYj1vJjEwNDg1NzUscD1vPj4+MzEscj1oKGIpPDwzMm58aChpKTtpZihmIT09MClyKz0xbjw8NTJuO3I8PD0ybjtsZXQgbD00bix1PWY+MSYmYj09PTAmJmk9PT0wPzFuOjJuLGs9Mm47aWYoZj49MTA3NSl7bGV0IGM9aChmLTEwNzUpO3I8PD1jLHU8PD1jLGs8PD1jfWVsc2UgbDw8PWgoZj09PTA/MTA3NDoxMDc1LWYpO2xldCBkPWgobiksZz1udChudWxsKSxhPTAsUz0wLEQ9MDtpZihyPGwpd2hpbGUocjxsKXtpZihyKjJuPmwmJnIraz5sKWJyZWFrO3IqPWQsdSo9ZCxrKj1kLFMtLX1lbHNlIHdoaWxlKHI+PWwqZClsKj1kLFMrKztmb3IoOzspe2xldCBjPVUoci9sKTtyJT1sO2xldCBJPXI8dSx4PXIraz5sO2dbYSsrXT1jLEQ9RCoobiYxKStjJjE7bGV0IHE9cioybixQPXE+bHx8cT09PWwmJkQ9PT0xO2lmKFAmJnh8fCFQJiZJKXtpZihQKXtsZXQgUj1hLEI9ITA7d2hpbGUoUj4wJiZCKXtSLS07bGV0IEg9Z1tSXSsxO2lmKEg9PT1uKWdbUl09MDtlbHNlIGdbUl09SCxCPSExfWlmKEIpZ1swXT0xLFMrK31icmVha31pZihhPj02NCl0aHJvdyBuZXcgcnQoIm51bWJlciByYWRpeCBmb3JtYXR0aW5nIGRpZCBub3QgY29udmVyZ2UiKTtyKj1kLHUqPWQsayo9ZH13aGlsZShhPjEmJmdbYS0xXT09PTApYS0tO2xldCB3PSIiO2lmKFM8MCl7dz0iMC4iO2ZvcihsZXQgYz0wO2M8LTEtUztjKyspdys9IjAiO2ZvcihsZXQgYz0wO2M8YTtjKyspdys9IjAxMjM0NTY3ODlhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5eiJbZ1tjXV19ZWxzZXtsZXQgYz1TKzEsST1jPmE/YzphO2ZvcihsZXQgeD0wO3g8STt4Kyspe2lmKHg9PT1jJiZjPGEpdys9Ii4iO3crPXg8YT8iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltnW3hdXToiMCJ9fXJldHVybiBwPyItIit3Ond9ZnVuY3Rpb24gRyh0LG4pe2xldCBlO3RyeXtlPW0odHQsdCxbXSl9Y2F0Y2h7cmV0dXJuIG0oaix0LFtuXSl9bGV0IG89MTA7aWYobiE9PXZvaWQgMCl7bGV0IGk9K247aWYobz1pIT09aT8wOmktaSUxLG88Mnx8bz4zNnx8byE9PW8pcmV0dXJuIG0oaixlLFtvXSl9aWYobz09PTEwfHxlPT09MHx8ZSE9PWV8fGU9PT0xLzB8fGU9PT0tMS8wKXJldHVybiBtKGosZSxbMTBdKTtyZXR1cm4gZSUxPT09MD9jdChlLG8pOnN0KGUsbyl9dmFyIHM9UmVmbGVjdC5hcHBseSxNPUZ1bmN0aW9uLnByb3RvdHlwZS5jYWxsLE49RnVuY3Rpb24ucHJvdG90eXBlLmFwcGx5LEU9RnVuY3Rpb24ucHJvdG90eXBlLmJpbmQsVD1PYmplY3QuZGVmaW5lUHJvcGVydHksbHQ9T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcixmdD1PYmplY3QuZ2V0UHJvdG90eXBlT2YsdXQ9T2JqZWN0LnNldFByb3RvdHlwZU9mLGF0PVJlZmxlY3Qub3duS2V5cyxwdD1TeW1ib2wuaGFzSW5zdGFuY2UsVj1BcnJheS5pc0FycmF5LEs9QXJyYXkucHJvdG90eXBlLmpvaW4sej1BcnJheS5wcm90b3R5cGUudG9TdHJpbmcseXQ9T2JqZWN0LnByb3RvdHlwZS50b1N0cmluZyxidD1TdHJpbmcsQz1UeXBlRXJyb3IsZHQ9U3ltYm9sLnRvUHJpbWl0aXZlLGd0PVdlYWtTZXQucHJvdG90eXBlLmhhcyx3dD1XZWFrU2V0LnByb3RvdHlwZS5hZGQseHQ9V2Vha1NldC5wcm90b3R5cGUuZGVsZXRlLEY9bmV3IFdlYWtTZXQsTz1udWxsLFc9KHQpPT50IT09bnVsbCYmKHR5cGVvZiB0PT09Im9iamVjdCJ8fHR5cGVvZiB0PT09ImZ1bmN0aW9uInx8dHlwZW9mIHQ+InUiJiZ0IT09dm9pZCAwKSxBPSh0KT0+dHlwZW9mIHQ9PT0iZnVuY3Rpb24ifHx0eXBlb2YgdD4idSImJnQhPT12b2lkIDA7ZnVuY3Rpb24gaHQoKXtsZXQgbj1uZXcgQygiY3ljbGljIGFycmF5IHRleHQgY29udmVyc2lvbiIpO3Rocm93IG4uZWxpc2NyaXB0RGlhZ25vc3RpYz17Zm9ybWF0OiJlbGlzY3JpcHQtZGlhZ25vc3RpYyIsdmVyc2lvbjoxLGNvZGU6IkVMSS1SVDAwMDkiLHNldmVyaXR5OiJlcnJvciIscGhhc2U6InJ1bnRpbWUiLG1lc3NhZ2U6ImN5Y2xpYyBhcnJheSB0ZXh0IGNvbnZlcnNpb24ifSxufWZ1bmN0aW9uIG10KHQpe2lmKCFXKHQpKXJldHVybiB0O2xldCBuPXRbZHRdO2lmKG4hPT12b2lkIDAmJm4hPT1udWxsKXtsZXQgZT1zKG4sdCxbInN0cmluZyJdKTtpZighVyhlKSlyZXR1cm4gZTt0aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZSIpfWZvcihsZXQgZT0wO2U8MjtlKyspe2xldCBvPXRbZT09PTA/InRvU3RyaW5nIjoidmFsdWVPZiJdO2lmKEEobykpe2xldCBpPW89PT16JiZWKHQpP3YodCk6cyhvLHQsW10pO2lmKCFXKGkpKXJldHVybiBpfX10aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZSIpfWZ1bmN0aW9uIFEodCl7bGV0IG49bXQodCk7aWYodHlwZW9mIG49PT0ic3ltYm9sIil0aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgYSBTeW1ib2wgdmFsdWUgdG8gYSBzdHJpbmciKTtyZXR1cm4gYnQobil9ZnVuY3Rpb24gXyh0LG4pe2xldCBlPSt0Lmxlbmd0aCxvPWUhPT1lfHxlPD0wPzA6ZT49OTAwNzE5OTI1NDc0MDk5MT85MDA3MTk5MjU0NzQwOTkxOmUtZSUxLGk9bj09PXZvaWQgMD8iLCI6UShuKSxmPU89PT1udWxsO2lmKGYpTz10O2Vsc2V7aWYodD09PU98fHMoZ3QsRixbdF0pKWh0KCk7cyh3dCxGLFt0XSl9dHJ5e2xldCBiPSIiO2ZvcihsZXQgcD0wO3A8bztwKyspe2lmKHApYis9aTtsZXQgcj10W3BdO2lmKHIhPT1udWxsJiZyIT09dm9pZCAwKWIrPVEocil9cmV0dXJuIGJ9ZmluYWxseXtpZihmKU89bnVsbDtlbHNlIHMoeHQsRixbdF0pfX1mdW5jdGlvbiB2KHQpe2xldCBuPXQuam9pbjtyZXR1cm4gQShuKT9uPT09Sz9fKHQsdm9pZCAwKTpzKG4sdCxbXSk6cyh5dCx0LFtdKX1mdW5jdGlvbiB5KHQsbil7cmV0dXJuIG48dC5sZW5ndGg/dFtuXTp2b2lkIDB9ZnVuY3Rpb24gWCh0LG4pe2xldCBlPVtdO2ZvcihsZXQgbz1uO288dC5sZW5ndGg7bysrKVQoZSxlLmxlbmd0aCx7dmFsdWU6dFtvXSx3cml0YWJsZTohMCxlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMH0pO3JldHVybiBlfWZ1bmN0aW9uIFN0KHQsbil7bGV0IGU9W107Zm9yKGxldCBvPTA7bzx0Lmxlbmd0aCtuLmxlbmd0aDtvKyspVChlLG8se3ZhbHVlOm88dC5sZW5ndGg/dFtvXTpuW28tdC5sZW5ndGhdLHdyaXRhYmxlOiEwLGVudW1lcmFibGU6ITAsY29uZmlndXJhYmxlOiEwfSk7cmV0dXJuIGV9ZnVuY3Rpb24gWSguLi50KXtyZXR1cm4gdH1mdW5jdGlvbiBaKHQsbil7cmV0dXJuIG4/cyhOLFksW3ZvaWQgMCx0XSk6cyhZLHZvaWQgMCx0KX1mdW5jdGlvbiBMKHQsbixlKXtmb3IoOzspe2lmKHQ9PT1qKXJldHVybiBHKG4seShlLDApKTtpZih0PT09SyYmVihuKSlyZXR1cm4gXyhuLHkoZSwwKSk7aWYodD09PXomJlYobikpcmV0dXJuIHYobik7aWYodD09PU0pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9WChlLDEpLHQ9byxuPWk7Y29udGludWV9aWYodD09PU4pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9Wih5KGUsMSksITApLHQ9byxuPWk7Y29udGludWV9aWYodD09PXMpe2xldCBvPXkoZSwwKSxpPXkoZSwxKTtpZighQShvKSlyZXR1cm4gcyh0LG4sZSk7ZT1aKHkoZSwyKSwhMSksdD1vLG49aTtjb250aW51ZX1pZih0PT09RSl7bGV0IG89cyh0LG4sZSk7aWYobiE9PWomJm4hPT1LJiZuIT09eiYmbiE9PU0mJm4hPT1OJiZuIT09cyYmbiE9PUUpcmV0dXJuIG87bGV0IGk9bixmPXkoZSwwKSxiPVgoZSwxKSxwPSguLi51KT0+TChpLGYsU3QoYix1KSk7VChwLHB0LHt2YWx1ZToodSk9PnUgaW5zdGFuY2VvZiBpLGNvbmZpZ3VyYWJsZTohMH0pO2xldCByPXMoRSxwLFt2b2lkIDBdKTt1dChyLGZ0KG8pKTtsZXQgbD1hdChvKTtmb3IobGV0IHU9MDt1PGwubGVuZ3RoO3UrKylUKHIsbFt1XSxsdChvLGxbdV0pKTtyZXR1cm4gcn1yZXR1cm4gcyh0LG4sZSl9fWZ1bmN0aW9uIFJ0KHQsbil7bGV0IGU9dFtuXTtyZXR1cm4oLi4ubyk9PkwoZSx0LG8pfWZ1bmN0aW9uIEF0KHQsbiwuLi5lKXtsZXQgbz10W25dO3JldHVybiBMKG8sdCxlKX1leHBvcnR7UnQgYXMgYyxBdCBhcyBkfTs=";
9
+ const __eliscript_truthy = (value) => value !== false && value != null;
10
+ const __eliscript_number_intrinsic = globalThis.Number;
11
+ const __eliscript_bigint_intrinsic = globalThis.BigInt;
12
+ const __eliscript_numeric_apply = globalThis.Reflect.apply;
13
+ const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
14
+ const __eliscript_numeric_error = globalThis.TypeError;
15
+ const __eliscript_numeric_trim = globalThis.String.prototype.trim;
16
+ const __eliscript_numeric_slice = globalThis.String.prototype.slice;
17
+ const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
18
+ const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
19
+ const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
20
+ const __eliscript_numeric_primitive = (value) => {
21
+ if (!__eliscript_numeric_object(value)) return value;
22
+ const exotic = value[__eliscript_numeric_symbol];
23
+ if (exotic !== void 0 && exotic !== null) {
24
+ const result = __eliscript_numeric_apply(exotic, value, ["number"]);
25
+ if (!__eliscript_numeric_object(result)) return result;
26
+ throw new __eliscript_numeric_error("Cannot convert object to primitive value");
27
+ }
28
+ for (let index = 0; index < 2; index++) {
29
+ const method = value[index === 0 ? "valueOf" : "toString"];
30
+ if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
31
+ const result = __eliscript_numeric_apply(method, value, []);
32
+ if (!__eliscript_numeric_object(result)) return result;
33
+ }
34
+ }
35
+ throw new __eliscript_numeric_error("Cannot convert object to primitive value");
36
+ };
37
+ const __eliscript_to_number = (value) => {
38
+ const primitive = __eliscript_numeric_primitive(value);
39
+ if (typeof primitive === "string") {
40
+ const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
41
+ if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
42
+ let first = 2;
43
+ while (first < text.length && text[first] === "0") first++;
44
+ if (first === text.length) return 0;
45
+ const prefix = text[1];
46
+ const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
47
+ if (text.length - first > limit) return 1 / 0;
48
+ const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
49
+ return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
50
+ }
51
+ }
52
+ return __eliscript_number_intrinsic(primitive);
53
+ };
54
+ const __eliscript_numeric = (value) => {
55
+ if (typeof value === "number" || typeof value === "bigint") return value;
56
+ const primitive = __eliscript_numeric_primitive(value);
57
+ if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
58
+ return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
59
+ };
60
+ const __eliscript_implicit_number = (value) => {
61
+ if (typeof value === "number") return value;
62
+ const primitive = __eliscript_numeric_primitive(value);
63
+ if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
64
+ return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
65
+ };
66
+ const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
67
+ const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
68
+ const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
69
+ const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
70
+ const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
71
+ const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
72
+ const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
73
+ const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
74
+ const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
75
+ const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
76
+ const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
77
+ const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
78
+ const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
79
+ const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
80
+ const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
81
+ const __eliscript_numeric_relation = (operator, left, right) => {
82
+ if (typeof left === "number" && typeof right === "number") {
83
+ if (operator === "<") return left < right;
84
+ if (operator === "<=") return left <= right;
85
+ if (operator === ">") return left > right;
86
+ return left >= right;
87
+ }
88
+ let a = __eliscript_numeric_primitive(left);
89
+ let b = __eliscript_numeric_primitive(right);
90
+ const x = typeof a, y = typeof b;
91
+ if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
92
+ a = __eliscript_numeric(a);
93
+ b = __eliscript_numeric(b);
94
+ }
95
+ if (operator === "<") return a < b;
96
+ if (operator === "<=") return a <= b;
97
+ if (operator === ">") return a > b;
98
+ return a >= b;
99
+ };
100
+
101
+ import {mkdir, readFile, readdir, writeFile, open} from "node:fs/promises";
102
+ import {writeSync} from "node:fs";
103
+ import {resolve, dirname, relative, sep} from "node:path";
104
+ import {createHash} from "node:crypto";
105
+ import {pathToFileURL} from "node:url";
106
+ import {createRequire} from "node:module";
107
+ import {buildBackends, root, loadLiteralSources} from "./build.mjs";
108
+ import {encodeCompilerIR, encodeCompilerSourceAsset, forEachCompilerMetadataChunk, requestCompilerBuildConsumption} from "./compiler-session.mjs";
109
+ import {createManagedProjectFacades} from "./managed-module-graph.mjs";
110
+ const independentCompilerProfiles = Object.freeze(({"small": Object.freeze(({"budget": Object.freeze(({"maxSlots": 131072, "initialBytes": 8388608, "maxBytes": 67108864})), "memory": Object.freeze(({"initialPages": 128, "maximumPages": 4096})), "auto": 65536})), "full-runtime": Object.freeze(({"budget": Object.freeze(({"maxSlots": 1048575, "initialBytes": 67108864, "maxBytes": 268435456})), "memory": Object.freeze(({"initialPages": 2048, "maximumPages": 16384})), "auto": 4194304})), "full-compiler": Object.freeze(({"budget": Object.freeze(({"maxSlots": 8388607, "initialBytes": 268435456, "maxBytes": 1073741824, "extendedHeap": true})), "memory": Object.freeze(({"initialPages": 4096, "maximumPages": 65535})), "auto": 16777216}))}));
111
+ __eliscript_tdz_ready_0 = true;
112
+ function build_truth(value) {
113
+ return globalThis.Boolean(value);
114
+ }
115
+ function build_default(value, fallback) {
116
+ if ((value === undefined)) {
117
+ return fallback;
118
+ } else {
119
+ return value;
120
+ }
121
+ }
122
+ function build_nullish(value, fallback) {
123
+ if ((value == null)) {
124
+ return fallback;
125
+ } else {
126
+ return value;
127
+ }
128
+ }
129
+ function build_optional_get(value, key) {
130
+ if ((value == null)) {
131
+ return undefined;
132
+ } else {
133
+ return (value)[key];
134
+ }
135
+ }
136
+ function build_options(value) {
137
+ if ((value === null)) {
138
+ ((__eliscript_value_1) => { throw __eliscript_value_1; })(new (globalThis.TypeError)("compiler options must not be null"));
139
+ }
140
+ return build_default(value, ({}));
141
+ }
142
+ function build_call_options(arguments$) {
143
+ return build_options((__eliscript_numeric_relation(">", ((arguments$) ?? []).length, 0) ? (arguments$)[0] : undefined));
144
+ }
145
+ function build_trace(enabled, phase, context) {
146
+ if (__eliscript_truthy(enabled)) {
147
+ return (() => {
148
+ try {
149
+ return ((globalThis.process)["stderr"])["write"](("compiler-build trace " + JSON.stringify(build_copy_properties(({"phase": phase}), context)) + "\n"));
150
+ } catch (ignored) {
151
+ return null;
152
+ }
153
+ })();
154
+ } else {
155
+ return null;
156
+ }
157
+ }
158
+ function build_observed_request(enabled, request, action) {
159
+ if ((!__eliscript_truthy(enabled))) {
160
+ return action();
161
+ } else {
162
+ {
163
+ const __eliscript_value_2 = ({"operation": (request)["operation"]});
164
+ {
165
+ let context = __eliscript_value_2;
166
+ (["kind", "id", "revision"])["forEach"](((key) => {
167
+ if (__eliscript_truthy(Object.hasOwn(request, key))) {
168
+ {
169
+ const __eliscript_value_3 = (request)[key];
170
+ {
171
+ let value = __eliscript_value_3;
172
+ if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value) === "string")) {
173
+ return ((context)[key] = (value)["slice"](0, 256));
174
+ } else {
175
+ if (__eliscript_truthy(((__eliscript_value_4) => (__eliscript_truthy(__eliscript_value_4) ? Number.isFinite(value) : __eliscript_value_4))((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value) === "number")))) {
176
+ return ((context)[key] = value);
177
+ } else {
178
+ return null;
179
+ }
180
+ }
181
+ }
182
+ }
183
+ } else {
184
+ return null;
185
+ }
186
+ }));
187
+ build_trace(true, "request-start", context);
188
+ return (() => {
189
+ try {
190
+ {
191
+ const __eliscript_value_5 = action();
192
+ {
193
+ let pending = __eliscript_value_5;
194
+ return (Promise.resolve(pending))["then"](((value) => {
195
+ build_trace(true, "request-complete", context);
196
+ return value;
197
+ }), ((error) => {
198
+ build_trace(true, "request-failure", context);
199
+ return ((__eliscript_value_6) => { throw __eliscript_value_6; })(error);
200
+ }));
201
+ }
202
+ }
203
+ } catch (error) {
204
+ build_trace(true, "request-failure", context);
205
+ return ((__eliscript_value_7) => { throw __eliscript_value_7; })(error);
206
+ }
207
+ })();
208
+ }
209
+ }
210
+ }
211
+ }
212
+ function build_copy_properties(target, source, excluded = null) {
213
+ if ((!(source == null))) {
214
+ {
215
+ let object = globalThis.Object(source);
216
+ let keys = Reflect.ownKeys(object);
217
+ let index = 0;
218
+ while (__eliscript_numeric_relation("<", index, ((keys) ?? []).length)) {
219
+ {
220
+ const __eliscript_value_8 = (keys)[index];
221
+ {
222
+ let key = __eliscript_value_8;
223
+ if ((!__eliscript_truthy(((__eliscript_value_9) => (__eliscript_truthy(__eliscript_value_9) ? (excluded)["includes"](key) : __eliscript_value_9))(excluded)))) {
224
+ {
225
+ const __eliscript_value_10 = Object.getOwnPropertyDescriptor(object, key);
226
+ {
227
+ let descriptor = __eliscript_value_10;
228
+ if (__eliscript_truthy(((__eliscript_value_11) => (__eliscript_truthy(__eliscript_value_11) ? (descriptor)["enumerable"] : __eliscript_value_11))(descriptor))) {
229
+ Object.defineProperty(target, key, ({"value": (object)[key], "writable": true, "enumerable": true, "configurable": true}));
230
+ }
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ ((index = (index + 1)));
237
+ }
238
+ }
239
+ }
240
+ return target;
241
+ }
242
+ function independentCompilerResources(...arguments$) {
243
+ {
244
+ let input = build_call_options(arguments$);
245
+ let profile = build_default((input)["profile"], "small");
246
+ let budget = (input)["budget"];
247
+ let memory = (input)["memory"];
248
+ let auto = (input)["auto"];
249
+ let defaults = ((__eliscript_tdz_read_0()))[profile];
250
+ if ((!__eliscript_truthy(build_truth(defaults)))) {
251
+ ((__eliscript_value_12) => { throw __eliscript_value_12; })(new (globalThis.TypeError)(("unknown independent compiler profile: " + profile)));
252
+ }
253
+ return ({"profile": profile, "budget": build_copy_properties(build_copy_properties(({}), (defaults)["budget"]), budget), "memory": build_copy_properties(build_copy_properties(({}), (defaults)["memory"]), memory), "auto": build_nullish(auto, (defaults)["auto"])});
254
+ }
255
+ }
256
+ async function read_compiler_source(path) {
257
+ return (new (globalThis.TextDecoder)("utf-8", ({"fatal": true, "ignoreBOM": true})))["decode"](await (readFile(path)));
258
+ }
259
+ async function compiler_source_names(source_root, directory) {
260
+ return ((await (readdir(resolve(source_root, directory))))["filter"](((name) => {
261
+ return (new (globalThis.RegExp)("^[a-z][a-z0-9-]*[.]eli$"))["test"](name);
262
+ })))["sort"]();
263
+ }
264
+ async function loadCompilerSources(...arguments$) {
265
+ return (await (async (input) => {
266
+ return (await (async (source_root) => {
267
+ return (await (async (names) => {
268
+ return (await (async (hosts) => {
269
+ return (await (async (backends) => {
270
+ return (await (async (records) => {
271
+ return (await (async (modules) => {
272
+ return (await (async (groups) => {
273
+ return (await (async (group_index) => {
274
+ return (await (async (index) => {
275
+ return (await (async () => {
276
+ while (__eliscript_numeric_relation("<", group_index, ((groups) ?? []).length)) {
277
+ {
278
+ let group = (groups)[group_index];
279
+ let entries = (group)[0];
280
+ ((index = 0));
281
+ while (__eliscript_numeric_relation("<", index, ((entries) ?? []).length)) {
282
+ {
283
+ const __eliscript_value_13 = (entries)[index];
284
+ {
285
+ let name = __eliscript_value_13;
286
+ (records)["push"](({"id": ((group)[1] + (name)["slice"](0, -4) + ".mjs"), "filename": ((group)[2] + name)}));
287
+ }
288
+ }
289
+ ((index = (index + 1)));
290
+ }
291
+ }
292
+ ((group_index = (group_index + 1)));
293
+ }
294
+ (records)["push"](({"id": "runtime/math.mjs", "filename": "runtime/math.eli"}));
295
+ (records)["push"](({"id": "runtime/unicode-case.mjs", "filename": "runtime/unicode-case.eli"}));
296
+ (records)["push"](({"id": "runtime/unicode-case-data.mjs", "filename": "runtime/unicode-case-data.eli"}));
297
+ ((index = 0));
298
+ (await (async () => {
299
+ while (__eliscript_numeric_relation("<", index, ((records) ?? []).length)) {
300
+ (await (async (record) => {
301
+ return (modules)["push"](({"id": (record)["id"], "filename": (record)["filename"], "source": await (read_compiler_source(resolve(source_root, (record)["filename"])))}));
302
+ })((records)[index]));
303
+ ((index = (index + 1)));
304
+ }
305
+ return null;
306
+ })());
307
+ return (await (async (filename) => {
308
+ return ({"entry": "host/compiler-session.mjs", "modules": modules, "literalSources": await (loadLiteralSources(({"sourceRoot": source_root}))), "runtime": ({"filename": filename, "source": await (read_compiler_source(resolve(source_root, filename)))})});
309
+ })("bootstrap/runtime/memory.eli"));
310
+ })());
311
+ })(0));
312
+ })(0));
313
+ })([[names, "bootstrap/", "bootstrap/compiler/"], [backends, "backends/", "bootstrap/backends/"], [hosts, "host/", "bootstrap/host/"]]));
314
+ })([]));
315
+ })([]));
316
+ })(await (compiler_source_names(source_root, "bootstrap/backends"))));
317
+ })(await (compiler_source_names(source_root, "bootstrap/host"))));
318
+ })(await (compiler_source_names(source_root, "bootstrap/compiler"))));
319
+ })(build_default((input)["sourceRoot"], root)));
320
+ })(build_call_options(arguments$)));
321
+ }
322
+ function decodeCompilerBinary(value) {
323
+ if (__eliscript_truthy(__eliscript_at(globalThis.Uint8Array, (globalThis.Symbol)["hasInstance"])(value))) {
324
+ return new (globalThis.Uint8Array)(value);
325
+ } else {
326
+ if (__eliscript_truthy(Array.isArray(value))) {
327
+ {
328
+ const __eliscript_value_14 = 0;
329
+ {
330
+ let index = __eliscript_value_14;
331
+ while (__eliscript_numeric_relation("<", index, ((value) ?? []).length)) {
332
+ {
333
+ const __eliscript_value_15 = (value)[index];
334
+ {
335
+ let byte = __eliscript_value_15;
336
+ if ((!__eliscript_truthy(((__eliscript_value_16) => (__eliscript_truthy(__eliscript_value_16) ? (__eliscript_numeric_relation(">=", byte, 0) && __eliscript_numeric_relation("<=", byte, 255)) : __eliscript_value_16))(Number.isInteger(byte))))) {
337
+ ((__eliscript_value_17) => { throw __eliscript_value_17; })(new (globalThis.TypeError)("compiler binary contains an invalid byte"));
338
+ }
339
+ }
340
+ }
341
+ ((index = (index + 1)));
342
+ }
343
+ }
344
+ }
345
+ return (globalThis.Uint8Array)["from"](value);
346
+ } else {
347
+ if ((!((!(value === null)) && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value) === "object") && ((value)["encoding"] === "u16le-chunks")))) {
348
+ ((__eliscript_value_18) => { throw __eliscript_value_18; })(new (globalThis.TypeError)("compiler binary has an unsupported encoding"));
349
+ }
350
+ {
351
+ const __eliscript_value_19 = (value)["byteLength"];
352
+ const __eliscript_value_20 = (value)["chunks"];
353
+ const __eliscript_value_21 = 0;
354
+ {
355
+ let byte_length = __eliscript_value_19;
356
+ let chunks = __eliscript_value_20;
357
+ let index = __eliscript_value_21;
358
+ if ((!__eliscript_truthy(((__eliscript_value_22) => (__eliscript_truthy(__eliscript_value_22) ? ((__eliscript_value_23) => (__eliscript_truthy(__eliscript_value_23) ? ((__eliscript_value_24) => (__eliscript_truthy(__eliscript_value_24) ? ((__eliscript_value_25) => (__eliscript_truthy(__eliscript_value_25) ? (((chunks) ?? []).length === Math.ceil(__eliscript_numeric_div(byte_length, 4096))) : __eliscript_value_25))(Array.isArray(chunks)) : __eliscript_value_24))(__eliscript_numeric_relation("<=", byte_length, 4294967295)) : __eliscript_value_23))(__eliscript_numeric_relation(">=", byte_length, 0)) : __eliscript_value_22))(Number.isSafeInteger(byte_length))))) {
359
+ ((__eliscript_value_26) => { throw __eliscript_value_26; })(new (globalThis.TypeError)("compiler binary has an invalid chunk layout"));
360
+ }
361
+ while (__eliscript_numeric_relation("<", index, ((chunks) ?? []).length)) {
362
+ {
363
+ const __eliscript_value_27 = (chunks)[index];
364
+ const __eliscript_value_28 = Math.min(4096, __eliscript_numeric_sub(byte_length, __eliscript_numeric_mul(index, 4096)));
365
+ {
366
+ let chunk = __eliscript_value_27;
367
+ let size = __eliscript_value_28;
368
+ if ((!((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(chunk) === "string") && (((chunk) ?? []).length === Math.ceil(__eliscript_numeric_div(size, 2))) && ((__eliscript_numeric_rem(size, 2) === 0) || __eliscript_numeric_relation("<=", (chunk)["charCodeAt"](__eliscript_numeric_decrement(((chunk) ?? []).length)), 255))))) {
369
+ ((__eliscript_value_29) => { throw __eliscript_value_29; })(new (globalThis.TypeError)("compiler binary has a noncanonical chunk"));
370
+ }
371
+ }
372
+ }
373
+ ((index = (index + 1)));
374
+ }
375
+ {
376
+ const __eliscript_value_30 = new (globalThis.Uint8Array)(byte_length);
377
+ {
378
+ let bytes = __eliscript_value_30;
379
+ ((index = 0));
380
+ while (__eliscript_numeric_relation("<", index, ((chunks) ?? []).length)) {
381
+ {
382
+ const __eliscript_value_31 = (chunks)[index];
383
+ const __eliscript_value_32 = 0;
384
+ {
385
+ let chunk = __eliscript_value_31;
386
+ let unit = __eliscript_value_32;
387
+ while (__eliscript_numeric_relation("<", unit, ((chunk) ?? []).length)) {
388
+ {
389
+ const __eliscript_value_33 = (chunk)["charCodeAt"](unit);
390
+ const __eliscript_value_34 = (__eliscript_numeric_mul(index, 4096) + __eliscript_numeric_mul(unit, 2));
391
+ {
392
+ let word = __eliscript_value_33;
393
+ let at = __eliscript_value_34;
394
+ ((bytes)[at] = __eliscript_numeric_and(word, 255));
395
+ if (__eliscript_numeric_relation("<", (at + 1), byte_length)) {
396
+ ((bytes)[(at + 1)] = __eliscript_numeric_ushr(word, 8));
397
+ }
398
+ }
399
+ }
400
+ ((unit = (unit + 1)));
401
+ }
402
+ }
403
+ }
404
+ ((index = (index + 1)));
405
+ }
406
+ return bytes;
407
+ }
408
+ }
409
+ }
410
+ }
411
+ }
412
+ }
413
+ }
414
+ async function write_module(directory, id, javascript) {
415
+ return (await (async (path) => {
416
+ if ((!__eliscript_truthy((path)["startsWith"]((resolve(directory) + sep))))) {
417
+ ((__eliscript_value_35) => { throw __eliscript_value_35; })(new (globalThis.TypeError)("compiler module escapes output directory"));
418
+ }
419
+ await (mkdir(dirname(path), ({"recursive": true})));
420
+ await (writeFile(path, javascript));
421
+ return path;
422
+ })(resolve(directory, id)));
423
+ }
424
+ async function write_compiler_math_scope(directory) {
425
+ return (await (async (path) => {
426
+ return (await (async (text) => {
427
+ return (await (async () => {
428
+ (await (async () => {
429
+ try {
430
+ return await (writeFile(path, text, ({"flag": "wx"})));
431
+ } catch (error) {
432
+ return ((!(await (async (__eliscript_value_36) => (__eliscript_truthy(__eliscript_value_36) ? (await (readFile(path, "utf8")) === text) : __eliscript_value_36))(((error)["code"] === "EEXIST")))) ? ((__eliscript_value_37) => { throw __eliscript_value_37; })(error) : null);
433
+ }
434
+ })());
435
+ return path;
436
+ })());
437
+ })((String(JSON.stringify(({"name": "eliscript", "type": "module", "private": true, "exports": ({"./runtime/math.mjs": "./runtime/math.mjs", "./runtime/unicode-case.mjs": "./runtime/unicode-case.mjs", "./runtime/unicode-case-data.mjs": "./runtime/unicode-case-data.mjs"})}), null, 2)) + String("\n"))));
438
+ })(resolve(directory, "package.json")));
439
+ }
440
+ async function write_compiler_seed_scope(directory) {
441
+ await (mkdir(directory, ({"recursive": true})));
442
+ return (await (async (path) => {
443
+ return (await (async (text) => {
444
+ return (await (async () => {
445
+ (await (async () => {
446
+ try {
447
+ return await (writeFile(path, text, ({"flag": "wx"})));
448
+ } catch (error) {
449
+ return ((!(await (async (__eliscript_value_38) => (__eliscript_truthy(__eliscript_value_38) ? (await (readFile(path, "utf8")) === text) : __eliscript_value_38))(((error)["code"] === "EEXIST")))) ? ((__eliscript_value_39) => { throw __eliscript_value_39; })(error) : null);
450
+ }
451
+ })());
452
+ return path;
453
+ })());
454
+ })((String(JSON.stringify(({"type": "module", "private": true}), null, 2)) + String("\n"))));
455
+ })(resolve(directory, "package.json")));
456
+ }
457
+ function target_for_host(host) {
458
+ if (((host === "js") || (host === "javascript"))) {
459
+ return "javascript";
460
+ } else {
461
+ if (((host === "wasm") || (host === "native"))) {
462
+ return host;
463
+ } else {
464
+ return ((__eliscript_value_40) => { throw __eliscript_value_40; })(new (globalThis.TypeError)(("unknown compiler host: " + host)));
465
+ }
466
+ }
467
+ }
468
+ function compiler_metadata_utf8_block(encoder, bytes, text, start) {
469
+ {
470
+ const __eliscript_value_41 = Math.min((start + 65536), ((text) ?? []).length);
471
+ {
472
+ let end = __eliscript_value_41;
473
+ if ((__eliscript_numeric_relation("<", end, ((text) ?? []).length) && __eliscript_numeric_relation(">=", (text)["charCodeAt"](__eliscript_numeric_decrement(end)), 55296) && __eliscript_numeric_relation("<=", (text)["charCodeAt"](__eliscript_numeric_decrement(end)), 56319) && __eliscript_numeric_relation(">=", (text)["charCodeAt"](end), 56320) && __eliscript_numeric_relation("<=", (text)["charCodeAt"](end), 57343))) {
474
+ ((end = __eliscript_numeric_decrement(end)));
475
+ }
476
+ if ((end === start)) {
477
+ return ({"read": 0, "written": 0});
478
+ } else {
479
+ {
480
+ const __eliscript_value_42 = (encoder)["encodeInto"]((text)["slice"](start, end), bytes);
481
+ {
482
+ let result = __eliscript_value_42;
483
+ if ((!__eliscript_truthy(((__eliscript_value_43) => (__eliscript_truthy(__eliscript_value_43) ? ((__eliscript_value_44) => (__eliscript_truthy(__eliscript_value_44) ? ((__eliscript_value_45) => (__eliscript_truthy(__eliscript_value_45) ? ((__eliscript_value_46) => (__eliscript_truthy(__eliscript_value_46) ? (__eliscript_numeric_relation(">=", (result)["written"], 1) && __eliscript_numeric_relation("<=", (result)["written"], ((bytes) ?? []).length)) : __eliscript_value_46))(Number.isInteger((result)["written"])) : __eliscript_value_45))(__eliscript_numeric_relation("<=", (result)["read"], __eliscript_numeric_sub(end, start))) : __eliscript_value_44))(__eliscript_numeric_relation(">=", (result)["read"], 1)) : __eliscript_value_43))(Number.isInteger((result)["read"]))))) {
484
+ ((__eliscript_value_47) => { throw __eliscript_value_47; })(new (globalThis.Error)("compiler metadata UTF8 encoding did not advance"));
485
+ }
486
+ return result;
487
+ }
488
+ }
489
+ }
490
+ }
491
+ }
492
+ }
493
+ function compilerMetadataDigest(value) {
494
+ {
495
+ const __eliscript_value_48 = createHash("sha256");
496
+ const __eliscript_value_49 = new (globalThis.TextEncoder)();
497
+ const __eliscript_value_50 = new (globalThis.Uint8Array)(65536);
498
+ {
499
+ let hash = __eliscript_value_48;
500
+ let encoder = __eliscript_value_49;
501
+ let bytes = __eliscript_value_50;
502
+ forEachCompilerMetadataChunk(value, ((chunk) => {
503
+ {
504
+ const __eliscript_value_51 = 0;
505
+ {
506
+ let start = __eliscript_value_51;
507
+ while (__eliscript_numeric_relation("<", start, ((chunk) ?? []).length)) {
508
+ {
509
+ const __eliscript_value_52 = compiler_metadata_utf8_block(encoder, bytes, chunk, start);
510
+ {
511
+ let result = __eliscript_value_52;
512
+ (hash)["update"]((bytes)["subarray"](0, (result)["written"]));
513
+ ((start = (start + (result)["read"])));
514
+ }
515
+ }
516
+ }
517
+ return null;
518
+ }
519
+ }
520
+ }));
521
+ return (hash)["digest"]("hex");
522
+ }
523
+ }
524
+ }
525
+ async function compiler_file_identity(path, buffer) {
526
+ return (await (async (hash) => {
527
+ return (await (async (file) => {
528
+ return (await (async (bytes) => {
529
+ return (await (async (failed) => {
530
+ return (await (async (done) => {
531
+ return (await (async () => {
532
+ try {
533
+ return (await (async () => {
534
+ (await (async () => {
535
+ while ((!__eliscript_truthy(done))) {
536
+ ((count) => {
537
+ if ((!__eliscript_truthy(((__eliscript_value_53) => (__eliscript_truthy(__eliscript_value_53) ? (__eliscript_numeric_relation(">=", count, 0) && __eliscript_numeric_relation("<=", count, ((buffer) ?? []).length)) : __eliscript_value_53))(Number.isInteger(count))))) {
538
+ ((__eliscript_value_54) => { throw __eliscript_value_54; })(new (globalThis.Error)("compiler artifact read returned an invalid byte count"));
539
+ }
540
+ if ((count === 0)) {
541
+ return ((done = true));
542
+ } else {
543
+ (hash)["update"]((buffer)["subarray"](0, count));
544
+ return ((bytes = (bytes + count)));
545
+ }
546
+ })((await ((file)["read"](buffer, 0, ((buffer) ?? []).length, null)))["bytesRead"]);
547
+ }
548
+ return null;
549
+ })());
550
+ return ({"bytes": bytes, "sha256": (hash)["digest"]("hex")});
551
+ })());
552
+ } catch (error) {
553
+ ((failed = true));
554
+ return ((__eliscript_value_55) => { throw __eliscript_value_55; })(error);
555
+ } finally {
556
+ (await (async () => {
557
+ try {
558
+ return await ((file)["close"]());
559
+ } catch (error) {
560
+ if ((!__eliscript_truthy(failed))) {
561
+ return ((__eliscript_value_56) => { throw __eliscript_value_56; })(error);
562
+ } else {
563
+ return null;
564
+ }
565
+ }
566
+ })());
567
+ }
568
+ })());
569
+ })(false));
570
+ })(false));
571
+ })(0));
572
+ })(await (open(path, "r"))));
573
+ })(createHash("sha256")));
574
+ }
575
+ async function writeCompilerMetadata(path, value, options = null) {
576
+ return (await (async (chunks) => {
577
+ forEachCompilerMetadataChunk(value, ((chunk) => {
578
+ return (chunks)["push"](chunk);
579
+ }));
580
+ (chunks)["push"]("\n");
581
+ return (await (async (file, failed) => {
582
+ return (await (async () => {
583
+ try {
584
+ return (await (async (encoder, bytes, index) => {
585
+ (await (async () => {
586
+ while (__eliscript_numeric_relation("<", index, ((chunks) ?? []).length)) {
587
+ (await (async (chunk, start) => {
588
+ return (await (async () => {
589
+ while (__eliscript_numeric_relation("<", start, ((chunk) ?? []).length)) {
590
+ (await (async (result) => {
591
+ return (await (async (written) => {
592
+ return (await (async (offset) => {
593
+ return (await (async () => {
594
+ (await (async () => {
595
+ while (__eliscript_numeric_relation("<", offset, written)) {
596
+ ((count) => {
597
+ if ((!__eliscript_truthy(((__eliscript_value_57) => (__eliscript_truthy(__eliscript_value_57) ? (__eliscript_numeric_relation(">=", count, 1) && __eliscript_numeric_relation("<=", count, __eliscript_numeric_sub(written, offset))) : __eliscript_value_57))(Number.isInteger(count))))) {
598
+ ((__eliscript_value_58) => { throw __eliscript_value_58; })(new (globalThis.Error)("compiler metadata write did not advance"));
599
+ }
600
+ return ((offset = (offset + count)));
601
+ })((await ((file)["write"](bytes, offset, __eliscript_numeric_sub(written, offset), null)))["bytesWritten"]);
602
+ }
603
+ return null;
604
+ })());
605
+ return ((start = (start + (result)["read"])));
606
+ })());
607
+ })(0));
608
+ })((result)["written"]));
609
+ })(compiler_metadata_utf8_block(encoder, bytes, chunk, start)));
610
+ }
611
+ return null;
612
+ })());
613
+ })((chunks)[index], 0));
614
+ ((chunks)[index] = undefined);
615
+ ((index = (index + 1)));
616
+ }
617
+ return null;
618
+ })());
619
+ return undefined;
620
+ })(new (globalThis.TextEncoder)(), new (globalThis.Uint8Array)(65536), 0));
621
+ } catch (error) {
622
+ ((failed = true));
623
+ return ((__eliscript_value_59) => { throw __eliscript_value_59; })(error);
624
+ } finally {
625
+ (await (async () => {
626
+ try {
627
+ return await ((file)["close"]());
628
+ } catch (error) {
629
+ if ((!__eliscript_truthy(failed))) {
630
+ return ((__eliscript_value_60) => { throw __eliscript_value_60; })(error);
631
+ } else {
632
+ return null;
633
+ }
634
+ }
635
+ })());
636
+ }
637
+ })());
638
+ })(await (open(path, build_nullish(build_optional_get(options, "flag"), "w"), build_optional_get(options, "mode"))), false));
639
+ })([]));
640
+ }
641
+ async function write_owned_compiler_metadata(path, value) {
642
+ return (await (async (file, failed) => {
643
+ return (await (async () => {
644
+ try {
645
+ {
646
+ let encoder = new (globalThis.TextEncoder)();
647
+ let bytes = new (globalThis.Uint8Array)(65536);
648
+ let consume = ((chunk) => {
649
+ {
650
+ const __eliscript_value_61 = 0;
651
+ {
652
+ let start = __eliscript_value_61;
653
+ while (__eliscript_numeric_relation("<", start, ((chunk) ?? []).length)) {
654
+ {
655
+ let result = compiler_metadata_utf8_block(encoder, bytes, chunk, start);
656
+ let written = (result)["written"];
657
+ let offset = 0;
658
+ while (__eliscript_numeric_relation("<", offset, written)) {
659
+ {
660
+ const __eliscript_value_62 = writeSync((file)["fd"], bytes, offset, __eliscript_numeric_sub(written, offset));
661
+ {
662
+ let count = __eliscript_value_62;
663
+ if ((!__eliscript_truthy(((__eliscript_value_63) => (__eliscript_truthy(__eliscript_value_63) ? (__eliscript_numeric_relation(">=", count, 1) && __eliscript_numeric_relation("<=", count, __eliscript_numeric_sub(written, offset))) : __eliscript_value_63))(Number.isInteger(count))))) {
664
+ ((__eliscript_value_64) => { throw __eliscript_value_64; })(new (globalThis.Error)("compiler metadata write did not advance"));
665
+ }
666
+ ((offset = (offset + count)));
667
+ }
668
+ }
669
+ }
670
+ ((start = (start + (result)["read"])));
671
+ }
672
+ }
673
+ return null;
674
+ }
675
+ }
676
+ });
677
+ forEachCompilerMetadataChunk(value, consume);
678
+ consume("\n");
679
+ return undefined;
680
+ }
681
+ } catch (error) {
682
+ ((failed = true));
683
+ return ((__eliscript_value_65) => { throw __eliscript_value_65; })(error);
684
+ } finally {
685
+ (await (async () => {
686
+ try {
687
+ return await ((file)["close"]());
688
+ } catch (error) {
689
+ if ((!__eliscript_truthy(failed))) {
690
+ return ((__eliscript_value_66) => { throw __eliscript_value_66; })(error);
691
+ } else {
692
+ return null;
693
+ }
694
+ }
695
+ })());
696
+ }
697
+ })());
698
+ })(await (open(path, "w")), false));
699
+ }
700
+ function independentCompilerProductIdentity(input) {
701
+ {
702
+ let host = (input)["host"];
703
+ let native_target = (input)["nativeTarget"];
704
+ let files = (input)["files"];
705
+ let descriptor = (input)["descriptor"];
706
+ let typed = (input)["typed"];
707
+ let identity = ({"host": host});
708
+ if ((host === "native")) {
709
+ ((identity)["nativeTarget"] = native_target);
710
+ ((identity)["nativeFormat"] = "library");
711
+ }
712
+ ((identity)["files"] = (Array.from(files))["sort"](((a, b) => {
713
+ if (__eliscript_numeric_relation("<", (a)["path"], (b)["path"])) {
714
+ return -1;
715
+ } else {
716
+ if (__eliscript_numeric_relation(">", (a)["path"], (b)["path"])) {
717
+ return 1;
718
+ } else {
719
+ return 0;
720
+ }
721
+ }
722
+ })));
723
+ if (__eliscript_truthy(build_truth(descriptor))) {
724
+ ((identity)["descriptor"] = compilerMetadataDigest(descriptor));
725
+ }
726
+ if (__eliscript_truthy(build_truth(typed))) {
727
+ ((identity)["typed"] = compilerMetadataDigest(typed));
728
+ }
729
+ return build_copy_properties(({"algorithm": "sha256", "sha256": ((createHash("sha256"))["update"](JSON.stringify(identity)))["digest"]("hex")}), identity);
730
+ }
731
+ }
732
+ function seed_javascript_product(sources, compiler, debug) {
733
+ {
734
+ const __eliscript_value_67 = [];
735
+ const __eliscript_value_68 = false;
736
+ const __eliscript_value_69 = undefined;
737
+ const __eliscript_value_70 = 0;
738
+ const __eliscript_value_71 = (sources)["modules"];
739
+ {
740
+ let modules = __eliscript_value_67;
741
+ let failed = __eliscript_value_68;
742
+ let failure = __eliscript_value_69;
743
+ let index = __eliscript_value_70;
744
+ let records = __eliscript_value_71;
745
+ while (__eliscript_numeric_relation("<", index, ((records) ?? []).length)) {
746
+ {
747
+ let record = (records)[index];
748
+ let program = undefined;
749
+ let origins = undefined;
750
+ if (__eliscript_truthy(build_truth(debug))) {
751
+ {
752
+ const __eliscript_value_72 = (compiler)["compile_ir_string_with_origins"]((record)["source"], build_nullish((record)["filename"], (record)["id"]));
753
+ {
754
+ let expansion = __eliscript_value_72;
755
+ ((program = (expansion)["program"]));
756
+ ((origins = (expansion)["macroOrigins"]));
757
+ }
758
+ }
759
+ } else {
760
+ ((program = (compiler)["compile_ir_string"]((record)["source"], build_nullish((record)["filename"], (record)["id"]))));
761
+ }
762
+ if ((!__eliscript_truthy(failed))) {
763
+ (() => {
764
+ try {
765
+ {
766
+ let emission = (__eliscript_truthy(build_truth(debug)) ? (compiler)["emit_ir_string_with_source_map"](program, (record)["source"], (record)["id"], (record)["filename"]) : ({"javascript": (compiler)["emit_ir_string"](program)}));
767
+ let output = build_copy_properties(({"id": (record)["id"]}), emission);
768
+ if (__eliscript_truthy(build_truth(debug))) {
769
+ ((output)["macroOrigins"] = origins);
770
+ }
771
+ return (modules)["push"](output);
772
+ }
773
+ } catch (error) {
774
+ ((failed = true));
775
+ return ((failure = error));
776
+ }
777
+ })();
778
+ }
779
+ }
780
+ ((index = (index + 1)));
781
+ }
782
+ {
783
+ const __eliscript_value_73 = (sources)["runtime"];
784
+ {
785
+ let runtime = __eliscript_value_73;
786
+ if (__eliscript_truthy(build_truth(debug))) {
787
+ (compiler)["compile_ir_string_with_origins"]((runtime)["source"], (runtime)["filename"]);
788
+ } else {
789
+ (compiler)["compile_ir_string"]((runtime)["source"], (runtime)["filename"]);
790
+ }
791
+ }
792
+ }
793
+ if (__eliscript_truthy(failed)) {
794
+ ((__eliscript_value_74) => { throw __eliscript_value_74; })(failure);
795
+ }
796
+ return ({"target": "javascript", "modules": modules});
797
+ }
798
+ }
799
+ }
800
+ function compiler_ir_record(compiler, record) {
801
+ return ({"id": (record)["id"], "ir": encodeCompilerIR((record)["program"]), "canonicalIR": (compiler)["serialize_ir_program"]((record)["program"])});
802
+ }
803
+ function compiler_retain_ir(product, compiler, modules, runtime, literal_ir) {
804
+ ((product)["frontendIR"] = (modules)["map"](((record) => {
805
+ return compiler_ir_record(compiler, record);
806
+ })));
807
+ ((product)["runtimeIR"] = compiler_ir_record(compiler, ({"id": "runtime", "program": runtime})));
808
+ ((product)["literalIR"] = literal_ir);
809
+ return product;
810
+ }
811
+ async function seed_product(sources, host, directory, frontend, memory, native_target, retain_ir, debug, phase) {
812
+ await (write_compiler_seed_scope(resolve(directory, "seed")));
813
+ phase("seed-backends-start");
814
+ return ((backend) => {
815
+ return ((compiler) => {
816
+ return (() => {
817
+ phase("seed-backends-complete");
818
+ if (((frontend === undefined) && (host === "javascript") && (!__eliscript_truthy(build_truth(retain_ir))))) {
819
+ phase("seed-javascript-start");
820
+ {
821
+ const __eliscript_value_75 = seed_javascript_product(sources, compiler, debug);
822
+ {
823
+ let product = __eliscript_value_75;
824
+ phase("seed-javascript-complete");
825
+ return product;
826
+ }
827
+ }
828
+ } else {
829
+ phase("seed-frontend-start");
830
+ {
831
+ let origins = new (globalThis.Map)();
832
+ let modules = ((sources)["modules"])["map"](((record) => {
833
+ return ({"id": (record)["id"], "program": (__eliscript_truthy(build_truth(debug)) ? ((result) => {
834
+ (origins)["set"]((record)["id"], (result)["macroOrigins"]);
835
+ return (result)["program"];
836
+ })((compiler)["compile_ir_string_with_origins"]((record)["source"], build_nullish((record)["filename"], (record)["id"]))) : (compiler)["compile_ir_string"]((record)["source"], build_nullish((record)["filename"], (record)["id"])))});
837
+ }));
838
+ let runtime_source = (sources)["runtime"];
839
+ let runtime_emission = (__eliscript_truthy(build_truth(debug)) ? (compiler)["compile_ir_string_with_origins"]((runtime_source)["source"], (runtime_source)["filename"]) : undefined);
840
+ let runtime = ((build_optional_get(runtime_emission, "program") == null) ? (compiler)["compile_ir_string"]((runtime_source)["source"], (runtime_source)["filename"]) : (runtime_emission)["program"]);
841
+ let literal_modules = (__eliscript_truthy(((__eliscript_value_76) => (__eliscript_truthy(__eliscript_value_76) ? __eliscript_value_76 : build_truth(retain_ir)))((!(host === "javascript")))) ? (build_nullish((sources)["literalSources"], []))["map"](((record) => {
842
+ if ((!__eliscript_truthy(build_truth(debug)))) {
843
+ return ({"id": (record)["id"], "program": (compiler)["compile_ir_string"]((record)["source"], (record)["filename"])});
844
+ } else {
845
+ {
846
+ const __eliscript_value_77 = (compiler)["compile_ir_string_with_origins"]((record)["source"], (record)["filename"]);
847
+ {
848
+ let emission = __eliscript_value_77;
849
+ (origins)["set"]((record)["id"], (emission)["macroOrigins"]);
850
+ return ({"id": (record)["id"], "program": (emission)["program"]});
851
+ }
852
+ }
853
+ }
854
+ })) : []);
855
+ let literal_ir = (__eliscript_truthy(build_truth(retain_ir)) ? (literal_modules)["map"](((record) => {
856
+ return compiler_ir_record(compiler, record);
857
+ })) : undefined);
858
+ phase("seed-frontend-complete");
859
+ if ((host === "javascript")) {
860
+ if ((!__eliscript_truthy(build_truth(retain_ir)))) {
861
+ ((runtime = null));
862
+ ((runtime_emission = null));
863
+ }
864
+ {
865
+ const __eliscript_value_78 = ({"target": "javascript", "modules": (modules)["map"](((record, index) => {
866
+ {
867
+ let source = ((sources)["modules"])[index];
868
+ let emission = (__eliscript_truthy(build_truth(debug)) ? (compiler)["emit_ir_string_with_source_map"]((record)["program"], (source)["source"], (record)["id"], (source)["filename"]) : ({"javascript": (compiler)["emit_ir_string"]((record)["program"])}));
869
+ let output = build_copy_properties(({"id": (record)["id"]}), emission);
870
+ if (__eliscript_truthy(build_truth(debug))) {
871
+ ((output)["macroOrigins"] = (origins)["get"]((record)["id"]));
872
+ }
873
+ if ((!__eliscript_truthy(build_truth(retain_ir)))) {
874
+ ((record)["program"] = null);
875
+ }
876
+ return output;
877
+ }
878
+ }))});
879
+ {
880
+ let product = __eliscript_value_78;
881
+ if (__eliscript_truthy(build_truth(retain_ir))) {
882
+ compiler_retain_ir(product, compiler, modules, runtime, literal_ir);
883
+ }
884
+ return product;
885
+ }
886
+ }
887
+ } else {
888
+ {
889
+ let lower_options = ({"hostModules": build_nullish((sources)["hostModules"], []), "phased": ((sources)["phased"] === true), "literalModules": literal_modules});
890
+ let release_programs = (() => {
891
+ (modules)["forEach"](((record) => {
892
+ return ((record)["program"] = null);
893
+ }));
894
+ (literal_modules)["forEach"](((record) => {
895
+ return ((record)["program"] = null);
896
+ }));
897
+ return ((runtime = null));
898
+ });
899
+ phase("seed-managed-lower-start");
900
+ {
901
+ const __eliscript_value_79 = ((host === "wasm") ? ((backend)["wasm"])["emit_managed_project_wasm_product"](modules, (sources)["entry"], runtime, lower_options, (() => {
902
+ if ((!__eliscript_truthy(build_truth(retain_ir)))) {
903
+ release_programs();
904
+ }
905
+ phase("seed-managed-lower-complete");
906
+ phase("seed-wasm-emit-start");
907
+ return ({"memory": ({...((memory) ?? {}), ["binaryEncoding"]: "u16le-chunks"}), "debug": debug});
908
+ })) : ((backend)["managed"])["lower_managed_project"](modules, (sources)["entry"], runtime, lower_options));
909
+ {
910
+ let lowered = __eliscript_value_79;
911
+ if ((!__eliscript_truthy(build_truth(retain_ir)))) {
912
+ release_programs();
913
+ }
914
+ phase(((host === "wasm") ? "seed-wasm-emit-complete" : "seed-managed-lower-complete"));
915
+ {
916
+ let emission = (__eliscript_truthy(build_truth(debug)) ? ((host === "wasm") ? lowered : ((backend)["native"])["emit_fresh_observed_typed_native_memory_artifact"]((lowered)["typed"], native_target, ({"format": "library", "binaryEncoding": "u16le-chunks"}), phase)) : null);
917
+ let bytes = ((host === "wasm") ? (lowered)["bytes"] : (__eliscript_truthy(build_truth(emission)) ? (emission)["bytes"] : ((backend)["native"])["emit_fresh_observed_typed_native_memory_library"]((lowered)["typed"], native_target, ({"binaryEncoding": "u16le-chunks"}), phase)));
918
+ let debug_map = undefined;
919
+ if (__eliscript_truthy(build_truth(emission))) {
920
+ ((debug_map = build_copy_properties(({}), (emission)["debug"])));
921
+ if ((host === "wasm")) {
922
+ ((debug_map)["moduleByteLength"] = (__eliscript_truthy(Array.isArray(bytes)) ? ((bytes) ?? []).length : (bytes)["byteLength"]));
923
+ }
924
+ {
925
+ let source_record = ((record) => {
926
+ return ({"id": (record)["id"], "filename": (record)["filename"], "macroOrigins": (origins)["get"]((record)["id"])});
927
+ });
928
+ let debug_sources = ((sources)["modules"])["map"](source_record);
929
+ (build_nullish((sources)["literalSources"], []))["forEach"](((record) => {
930
+ return (debug_sources)["push"](source_record(record));
931
+ }));
932
+ (debug_sources)["push"](({"id": "runtime", "filename": (runtime_source)["filename"], "macroOrigins": build_nullish(build_optional_get(runtime_emission, "macroOrigins"), [])}));
933
+ ((debug_map)["sources"] = debug_sources);
934
+ }
935
+ }
936
+ {
937
+ const __eliscript_value_80 = ({"target": target_for_host(host), "bytes": bytes, "descriptor": (lowered)["descriptor"]});
938
+ {
939
+ let product = __eliscript_value_80;
940
+ if ((host === "native")) {
941
+ ((product)["typed"] = (lowered)["typed"]);
942
+ }
943
+ ((product)["debug"] = debug_map);
944
+ if (__eliscript_truthy(build_truth(retain_ir))) {
945
+ compiler_retain_ir(product, compiler, modules, runtime, literal_ir);
946
+ }
947
+ release_programs();
948
+ ((runtime_emission = null));
949
+ return product;
950
+ }
951
+ }
952
+ }
953
+ }
954
+ }
955
+ }
956
+ }
957
+ }
958
+ }
959
+ })();
960
+ })((backend)["compiler"]);
961
+ })(await (buildBackends(({"outputRoot": resolve(directory, "seed"), "frontend": frontend}))));
962
+ }
963
+ function compiler_source_identity_record(record) {
964
+ return ({"id": (record)["id"], "filename": (record)["filename"], "sha256": ((createHash("sha256"))["update"]((record)["source"], "utf16le"))["digest"]("hex")});
965
+ }
966
+ function compiler_source_identity(graph) {
967
+ {
968
+ let runtime = (graph)["runtime"];
969
+ let identity = ({"algorithm": "sha256", "encoding": "utf16le", "modules": ((graph)["modules"])["map"](compiler_source_identity_record), "runtime": ({"filename": (runtime)["filename"], "sha256": ((createHash("sha256"))["update"]((runtime)["source"], "utf16le"))["digest"]("hex")})});
970
+ if (__eliscript_truthy(build_truth((graph)["literalSources"]))) {
971
+ ((identity)["literalSources"] = ((graph)["literalSources"])["map"](compiler_source_identity_record));
972
+ }
973
+ if (__eliscript_truthy(build_truth((graph)["hostSources"]))) {
974
+ ((identity)["hostSources"] = ((graph)["hostSources"])["map"](compiler_source_identity_record));
975
+ }
976
+ return identity;
977
+ }
978
+ }
979
+ function compiler_portable_path(directory, path) {
980
+ return __eliscript_at_direct((relative(directory, path))["split"](sep), "join", "/");
981
+ }
982
+ function compiler_portable_ir_record(directory, record) {
983
+ {
984
+ const __eliscript_value_81 = build_copy_properties(({}), record);
985
+ {
986
+ let output = __eliscript_value_81;
987
+ ((output)["path"] = compiler_portable_path(directory, (record)["path"]));
988
+ ((output)["canonicalPath"] = compiler_portable_path(directory, (record)["canonicalPath"]));
989
+ return output;
990
+ }
991
+ }
992
+ }
993
+ function compiler_artifact_metadata(artifact, directory) {
994
+ {
995
+ const __eliscript_value_82 = build_copy_properties(({}), artifact, ["bytes", "lowered", "load", "directory", "url", "metadataPath"]);
996
+ {
997
+ let metadata = __eliscript_value_82;
998
+ ((metadata)["path"] = compiler_portable_path(directory, (artifact)["path"]));
999
+ ((metadata)["runtimePath"] = compiler_portable_path(directory, (artifact)["runtimePath"]));
1000
+ if (__eliscript_truthy(build_truth((artifact)["debugPath"]))) {
1001
+ ((metadata)["debugPath"] = compiler_portable_path(directory, (artifact)["debugPath"]));
1002
+ }
1003
+ if (__eliscript_truthy(build_truth((artifact)["frontendIR"]))) {
1004
+ ((metadata)["frontendIR"] = ((artifact)["frontendIR"])["map"](((record) => {
1005
+ return compiler_portable_ir_record(directory, record);
1006
+ })));
1007
+ }
1008
+ if (__eliscript_truthy(build_truth((artifact)["literalIR"]))) {
1009
+ ((metadata)["literalIR"] = ((artifact)["literalIR"])["map"](((record) => {
1010
+ return compiler_portable_ir_record(directory, record);
1011
+ })));
1012
+ }
1013
+ if (__eliscript_truthy(build_truth((artifact)["modules"]))) {
1014
+ ((metadata)["modules"] = ((artifact)["modules"])["map"](((record) => {
1015
+ {
1016
+ const __eliscript_value_83 = ({"id": (record)["id"], "path": compiler_portable_path(directory, (record)["path"])});
1017
+ {
1018
+ let output = __eliscript_value_83;
1019
+ if (__eliscript_truthy(build_truth((record)["sourceMapPath"]))) {
1020
+ ((output)["sourceMapPath"] = compiler_portable_path(directory, (record)["sourceMapPath"]));
1021
+ }
1022
+ if (__eliscript_truthy(build_truth((record)["macroOriginsPath"]))) {
1023
+ ((output)["macroOriginsPath"] = compiler_portable_path(directory, (record)["macroOriginsPath"]));
1024
+ }
1025
+ return output;
1026
+ }
1027
+ }
1028
+ })));
1029
+ }
1030
+ if (__eliscript_truthy(build_truth((artifact)["hostSources"]))) {
1031
+ ((metadata)["hostSources"] = ((artifact)["hostSources"])["map"](((record) => {
1032
+ return ({"id": (record)["id"], "path": compiler_portable_path(directory, (record)["path"])});
1033
+ })));
1034
+ }
1035
+ if (__eliscript_truthy(build_truth((artifact)["literalSources"]))) {
1036
+ ((metadata)["literalSources"] = ((artifact)["literalSources"])["map"](((record) => {
1037
+ return ({...((record) ?? {}), ["path"]: compiler_portable_path(directory, (record)["path"])});
1038
+ })));
1039
+ }
1040
+ return metadata;
1041
+ }
1042
+ }
1043
+ }
1044
+ async function compiler_save_ir(directory, record, index, literal) {
1045
+ return (await (async (name) => {
1046
+ return (await (async (path) => {
1047
+ return (await (async (canonical_path) => {
1048
+ return (await (async () => {
1049
+ await (mkdir(dirname(path), ({"recursive": true})));
1050
+ await (writeFile(path, (record)["ir"]));
1051
+ await (writeFile(canonical_path, (record)["canonicalIR"]));
1052
+ return ({"id": (record)["id"], "stage": "frontend", "path": path, "canonicalPath": canonical_path});
1053
+ })());
1054
+ })((path + ".canonical")));
1055
+ })((__eliscript_truthy(literal) ? resolve(directory, "ir", "literal", name) : resolve(directory, "ir", name))));
1056
+ })(((globalThis.String(index))["padStart"](4, "0") + ".json")));
1057
+ }
1058
+ async function compiler_runtime_ir_checkpoint(producer, graph, ready, directory, signal, trace, phase) {
1059
+ phase("runtime-retained-ir-start");
1060
+ return (await (async (literals) => {
1061
+ return (await (async (identity) => {
1062
+ return (await (async (checkpoint) => {
1063
+ return (await (async (receipt) => {
1064
+ return (await (async (request) => {
1065
+ return (await (async () => {
1066
+ Reflect.deleteProperty(identity, "modules");
1067
+ (await (async (record) => {
1068
+ if ((!((build_optional_get(record, "id") === "runtime") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["ir"]) === "string") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["canonicalIR"]) === "string")))) {
1069
+ ((__eliscript_value_84) => { throw __eliscript_value_84; })(new (globalThis.TypeError)("compiler omitted its original frontend IR"));
1070
+ }
1071
+ return ((checkpoint)["runtime"] = await (compiler_save_ir(directory, record, (((graph)["modules"]) ?? []).length, false)));
1072
+ })(await (build_observed_request(trace, request, (() => {
1073
+ return (producer)["request"](request, ({"signal": signal}));
1074
+ })))));
1075
+ (await (async (save_receipt) => {
1076
+ await (save_receipt());
1077
+ return (await (async (index) => {
1078
+ return (await (async () => {
1079
+ while (__eliscript_numeric_relation("<", index, ((literals) ?? []).length)) {
1080
+ (await (async (expected) => {
1081
+ return (await (async (literal_request) => {
1082
+ return (await (async (record) => {
1083
+ return (await (async () => {
1084
+ if ((!((build_optional_get(record, "id") === (expected)["id"]) && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["ir"]) === "string") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["canonicalIR"]) === "string")))) {
1085
+ ((__eliscript_value_85) => { throw __eliscript_value_85; })(new (globalThis.TypeError)("compiler changed its persistent literal frontend IR identity"));
1086
+ }
1087
+ return ((checkpoint)["literals"])["push"](await (compiler_save_ir(directory, record, index, true)));
1088
+ })());
1089
+ })(await (build_observed_request(trace, literal_request, (() => {
1090
+ return (producer)["request"](literal_request, ({"signal": signal}));
1091
+ })))));
1092
+ })(({"operation": "cached-ir", "kind": "literal", "id": (expected)["id"], "revision": (ready)["literalRevision"]})));
1093
+ })((literals)[index]));
1094
+ await (save_receipt());
1095
+ ((index = (index + 1)));
1096
+ }
1097
+ return null;
1098
+ })());
1099
+ })(0));
1100
+ })((async () => {
1101
+ return (await (async (output) => {
1102
+ ((output)["runtime"] = compiler_portable_ir_record(directory, (checkpoint)["runtime"]));
1103
+ ((output)["literals"] = ((checkpoint)["literals"])["map"](((record) => {
1104
+ return compiler_portable_ir_record(directory, record);
1105
+ })));
1106
+ return await (writeCompilerMetadata(receipt, output));
1107
+ })(build_copy_properties(({}), checkpoint)));
1108
+ })));
1109
+ phase("runtime-retained-ir-complete");
1110
+ return checkpoint;
1111
+ })());
1112
+ })(({"operation": "cached-ir", "kind": "runtime", "revision": (ready)["revision"]})));
1113
+ })(resolve(directory, "ir/runtime-checkpoint.json")));
1114
+ })(({"format": "eliscript-compiler-runtime-ir-checkpoint", "version": 1, "producerHost": (((producer)["host"] === "js") ? "javascript" : (producer)["host"]), "revision": (ready)["revision"], "literalRevision": (ready)["literalRevision"], "sourceIdentity": identity, "literals": []})));
1115
+ })(compiler_source_identity(({"modules": [], "runtime": (graph)["runtime"], "literalSources": literals}))));
1116
+ })(build_nullish((graph)["literalSources"], [])));
1117
+ }
1118
+ async function buildIndependentCompiler(...arguments$) {
1119
+ return (await (async (input) => {
1120
+ return (await (async (host) => {
1121
+ return (await (async (output_root) => {
1122
+ return (await (async (source_root) => {
1123
+ return (await (async (sources) => {
1124
+ return (await (async (frontend) => {
1125
+ return (await (async (session) => {
1126
+ return (await (async (profile) => {
1127
+ return (await (async (budget) => {
1128
+ return (await (async (memory) => {
1129
+ return (await (async (auto) => {
1130
+ return (await (async (native_target) => {
1131
+ return (await (async (retain_ir) => {
1132
+ return (await (async (debug) => {
1133
+ return (await (async (signal) => {
1134
+ return (await (async (on_phase) => {
1135
+ return (await (async (target) => {
1136
+ return (await (async () => {
1137
+ ((host = target));
1138
+ if ((!__eliscript_truthy((["arm64-macos", "arm64-linux"])["includes"](native_target)))) {
1139
+ ((__eliscript_value_86) => { throw __eliscript_value_86; })(new (globalThis.TypeError)("unsupported native compiler target"));
1140
+ }
1141
+ return (await (async (resources) => {
1142
+ if ((!((on_phase === undefined) || (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(on_phase) === "function")))) {
1143
+ ((__eliscript_value_87) => { throw __eliscript_value_87; })(new (globalThis.TypeError)("compiler phase observer must be a function"));
1144
+ }
1145
+ return (await (async (trace) => {
1146
+ return (await (async (phase) => {
1147
+ return (await (async (directory) => {
1148
+ return (await (async () => {
1149
+ phase("sources-start");
1150
+ return (await (async (graph) => {
1151
+ phase("sources-complete");
1152
+ return (await (async (producer) => {
1153
+ if (((!(session === undefined)) && (!(((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(build_optional_get(session, "request")) === "function")))) {
1154
+ ((__eliscript_value_88) => { throw __eliscript_value_88; })(new (globalThis.TypeError)("independent compiler producer requires session.request"));
1155
+ }
1156
+ await (mkdir(directory, ({"recursive": true})));
1157
+ (__eliscript_truthy(((__eliscript_value_89) => (__eliscript_truthy(__eliscript_value_89) ? ((graph)["modules"])["some"](((record) => {
1158
+ return ((record)["id"] === "runtime/math.mjs");
1159
+ })) : __eliscript_value_89))((host === "javascript"))) ? await (write_compiler_math_scope(directory)) : null);
1160
+ return (await (async (product, owned_product, runtime_checkpoint) => {
1161
+ (__eliscript_truthy(build_truth(producer)) ? (await (async () => {
1162
+ phase("runtime-start");
1163
+ return (await (async (runtime_request) => {
1164
+ if (__eliscript_truthy(build_truth((graph)["literalSources"]))) {
1165
+ ((runtime_request)["literalSources"] = (graph)["literalSources"]);
1166
+ }
1167
+ return (await (async (runtime_response, response_options) => {
1168
+ phase("runtime-complete");
1169
+ (__eliscript_truthy(build_truth(retain_ir)) ? ((runtime_checkpoint = await (compiler_runtime_ir_checkpoint(producer, graph, runtime_response, directory, signal, trace, phase)))) : null);
1170
+ (((host === "native") || (host === "wasm")) ? (await (async (capability_request) => {
1171
+ return ((capabilities) => {
1172
+ return ((modes) => {
1173
+ return (__eliscript_truthy(((__eliscript_value_90) => (__eliscript_truthy(__eliscript_value_90) ? ((__eliscript_value_91) => (__eliscript_truthy(__eliscript_value_91) ? (modes)["includes"]("graph-events-v1") : __eliscript_value_91))((!(modes == null))) : __eliscript_value_90))(((host === "native") || (debug === true)))) ? ((response_options = ({"signal": signal, "responseMode": "graph-events-v1"}))) : (__eliscript_truthy(((__eliscript_value_92) => (__eliscript_truthy(__eliscript_value_92) ? (modes)["includes"]("events-v1") : __eliscript_value_92))((!(modes == null)))) ? ((response_options = ({"signal": signal, "responseMode": "events-v1"}))) : (__eliscript_truthy(((__eliscript_value_93) => (__eliscript_truthy(__eliscript_value_93) ? (modes)["includes"]("graph-events-v1") : __eliscript_value_93))((!(modes == null)))) ? ((response_options = ({"signal": signal, "responseMode": "graph-events-v1"}))) : null)));
1174
+ })(build_optional_get(capabilities, "responseModes"));
1175
+ })(await (build_observed_request(trace, capability_request, (() => {
1176
+ return (producer)["request"](capability_request, ({"signal": signal}));
1177
+ }))));
1178
+ })(({"operation": "capabilities"}))) : null);
1179
+ phase("project-start");
1180
+ (await (async (request) => {
1181
+ if (__eliscript_truthy(build_truth((graph)["hostModules"]))) {
1182
+ ((request)["hostModules"] = (graph)["hostModules"]);
1183
+ }
1184
+ if (__eliscript_truthy(build_truth((graph)["hostSources"]))) {
1185
+ ((request)["hostSources"] = (graph)["hostSources"]);
1186
+ }
1187
+ if (((graph)["phased"] === true)) {
1188
+ ((request)["phased"] = true);
1189
+ }
1190
+ ((request)["entry"] = (graph)["entry"]);
1191
+ ((request)["target"] = target);
1192
+ ((request)["memory"] = (resources)["memory"]);
1193
+ ((request)["nativeTarget"] = native_target);
1194
+ ((request)["nativeFormat"] = "library");
1195
+ if (((host === "native") || (host === "wasm"))) {
1196
+ ((request)["binaryEncoding"] = "u16le-chunks");
1197
+ }
1198
+ if (((host === "javascript") && (debug === true))) {
1199
+ ((request)["sourceMap"] = true);
1200
+ }
1201
+ ((request)["debug"] = debug);
1202
+ return ((consumption) => {
1203
+ ((product = (consumption)["product"]));
1204
+ return ((owned_product = (consumption)["owned"]));
1205
+ })(((host === "wasm") ? ({"product": await (build_observed_request(trace, request, (() => {
1206
+ return (producer)["request"](request, response_options);
1207
+ }))), "owned": false}) : await (build_observed_request(trace, request, (() => {
1208
+ return requestCompilerBuildConsumption(producer, request, response_options);
1209
+ })))));
1210
+ })(({"operation": "project", "modules": (graph)["modules"]})));
1211
+ phase("project-complete");
1212
+ return (__eliscript_truthy(build_truth(retain_ir)) ? (await (async () => {
1213
+ phase("retained-ir-start");
1214
+ ((product)["frontendIR"] = []);
1215
+ (await (async (index, modules) => {
1216
+ return (await (async () => {
1217
+ while (__eliscript_numeric_relation("<", index, ((modules) ?? []).length)) {
1218
+ (await (async (request) => {
1219
+ return ((product)["frontendIR"])["push"](await (build_observed_request(trace, request, (() => {
1220
+ return (producer)["request"](request, ({"signal": signal}));
1221
+ }))));
1222
+ })(({"operation": "cached-ir", "kind": "module", "id": ((modules)[index])["id"], "revision": (product)["revision"]})));
1223
+ ((index = (index + 1)));
1224
+ }
1225
+ return null;
1226
+ })());
1227
+ })(0, (graph)["modules"]));
1228
+ return phase("retained-ir-complete");
1229
+ })()) : null);
1230
+ })(await (build_observed_request(trace, runtime_request, (() => {
1231
+ return (producer)["request"](runtime_request, ({"signal": signal}));
1232
+ }))), ({"signal": signal})));
1233
+ })(({"operation": "runtime", "source": ((graph)["runtime"])["source"], "filename": ((graph)["runtime"])["filename"]})));
1234
+ })()) : (await (async () => {
1235
+ if (__eliscript_truthy(build_truth(build_optional_get(signal, "aborted")))) {
1236
+ {
1237
+ const __eliscript_value_94 = (signal)["reason"];
1238
+ {
1239
+ let reason = __eliscript_value_94;
1240
+ ((__eliscript_value_95) => { throw __eliscript_value_95; })(((reason == null) ? new (globalThis.Error)("compiler build aborted") : reason));
1241
+ }
1242
+ }
1243
+ }
1244
+ ((product = await (seed_product(graph, host, directory, frontend, (resources)["memory"], native_target, retain_ir, debug, phase))));
1245
+ return ((owned_product = true));
1246
+ })()));
1247
+ if ((!(build_optional_get(product, "target") === target))) {
1248
+ ((__eliscript_value_96) => { throw __eliscript_value_96; })(new (globalThis.TypeError)("compiler producer returned a different target"));
1249
+ }
1250
+ return (await (async (artifact) => {
1251
+ return (await (async (files) => {
1252
+ return (await (async (reserved) => {
1253
+ return (await (async () => {
1254
+ ((artifact)["nativeTarget"] = native_target);
1255
+ ((artifact)["debugEnabled"] = debug);
1256
+ ((artifact)["capabilities"] = ({"productTargets": ["javascript", "wasm", "native"], "nativeProductTargets": (__eliscript_truthy(((graph)["modules"])["some"](((record) => {
1257
+ return ((record)["id"] === "backends/elf.mjs");
1258
+ }))) ? ["arm64-macos", "arm64-linux"] : ["arm64-macos"])}));
1259
+ ((artifact)["sourceIdentity"] = compiler_source_identity(graph));
1260
+ ((artifact)["provenance"] = ({"mode": (__eliscript_truthy(build_truth(producer)) ? "session" : "seed"), "producerHost": (__eliscript_truthy(build_truth(producer)) ? (((producer)["host"] === "js") ? "javascript" : (producer)["host"]) : "javascript"), "compiledModuleIds": ((graph)["modules"])["map"](((record) => {
1261
+ return (record)["id"];
1262
+ })), "runtimeCompiled": true}));
1263
+ ((host === "javascript") ? (await (async () => {
1264
+ phase("javascript-files-start");
1265
+ if ((!__eliscript_truthy(Array.isArray((product)["modules"])))) {
1266
+ ((__eliscript_value_97) => { throw __eliscript_value_97; })(new (globalThis.TypeError)("JavaScript compiler product has no modules"));
1267
+ }
1268
+ (await (async (expected, index) => {
1269
+ ((artifact)["modules"] = []);
1270
+ (await (async () => {
1271
+ while (__eliscript_numeric_relation("<", index, (((product)["modules"]) ?? []).length)) {
1272
+ (await (async (record) => {
1273
+ if ((!__eliscript_truthy(((__eliscript_value_98) => (__eliscript_truthy(__eliscript_value_98) ? (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["javascript"]) === "string") : __eliscript_value_98))((expected)["delete"]((record)["id"]))))) {
1274
+ ((__eliscript_value_99) => { throw __eliscript_value_99; })(new (globalThis.TypeError)("JavaScript compiler product contains an unexpected module"));
1275
+ }
1276
+ (await (async (path) => {
1277
+ return (await (async (output) => {
1278
+ return (await (async () => {
1279
+ ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["sourceMap"]) === "string") ? await (writeFile((path + ".map"), (record)["sourceMap"])) : null);
1280
+ (__eliscript_truthy(Array.isArray((record)["macroOrigins"])) ? await (writeFile((path + ".macro-origins.json"), (JSON.stringify((record)["macroOrigins"], null, 2) + "\n"))) : null);
1281
+ if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["sourceMap"]) === "string")) {
1282
+ ((output)["sourceMapPath"] = (path + ".map"));
1283
+ }
1284
+ if (__eliscript_truthy(Array.isArray((record)["macroOrigins"]))) {
1285
+ ((output)["macroOriginsPath"] = (path + ".macro-origins.json"));
1286
+ }
1287
+ return ((artifact)["modules"])["push"](output);
1288
+ })());
1289
+ })(({"id": (record)["id"], "path": path})));
1290
+ })(await (write_module(directory, (record)["id"], (record)["javascript"]))));
1291
+ if (__eliscript_truthy(owned_product)) {
1292
+ return (((product)["modules"])[index] = undefined);
1293
+ } else {
1294
+ return null;
1295
+ }
1296
+ })(((product)["modules"])[index]));
1297
+ ((index = (index + 1)));
1298
+ }
1299
+ return null;
1300
+ })());
1301
+ if ((!((expected)["size"] === 0))) {
1302
+ return ((__eliscript_value_100) => { throw __eliscript_value_100; })(new (globalThis.TypeError)("JavaScript compiler product omitted modules"));
1303
+ } else {
1304
+ return null;
1305
+ }
1306
+ })(new (globalThis.Set)(((graph)["modules"])["map"](((record) => {
1307
+ return (record)["id"];
1308
+ }))), 0));
1309
+ ((artifact)["path"] = resolve(directory, (graph)["entry"]));
1310
+ ((artifact)["url"] = (pathToFileURL((artifact)["path"]))["href"]);
1311
+ {
1312
+ const __eliscript_value_101 = createRequire(resolve(root, "tools/backends/compiler-build.mjs"));
1313
+ const __eliscript_value_102 = (artifact)["path"];
1314
+ {
1315
+ let require_module = __eliscript_value_101;
1316
+ let module_path = __eliscript_value_102;
1317
+ ((artifact)["load"] = (async () => {
1318
+ return require_module(module_path);
1319
+ }));
1320
+ }
1321
+ }
1322
+ return phase("javascript-files-complete");
1323
+ })()) : (await (async () => {
1324
+ if ((!__eliscript_truthy(((__eliscript_value_103) => (__eliscript_truthy(__eliscript_value_103) ? ((__eliscript_value_104) => (__eliscript_truthy(__eliscript_value_104) ? ((__eliscript_value_105) => (__eliscript_truthy(__eliscript_value_105) ? __eliscript_value_105 : build_truth((product)["typed"])))((!(host === "native"))) : __eliscript_value_104))(build_truth((product)["bytes"])) : __eliscript_value_103))(build_truth((product)["descriptor"]))))) {
1325
+ ((__eliscript_value_106) => { throw __eliscript_value_106; })(new (globalThis.TypeError)("binary compiler product omitted its bytes or lowering record"));
1326
+ }
1327
+ phase("binary-decode-start");
1328
+ ((artifact)["bytes"] = decodeCompilerBinary((product)["bytes"]));
1329
+ if (__eliscript_truthy(owned_product)) {
1330
+ ((product)["bytes"] = undefined);
1331
+ }
1332
+ phase("binary-decode-complete", ({"byteLength": ((artifact)["bytes"])["byteLength"]}));
1333
+ ((artifact)["descriptor"] = (product)["descriptor"]);
1334
+ ((artifact)["typed"] = (product)["typed"]);
1335
+ if (__eliscript_truthy(build_truth((product)["typed"]))) {
1336
+ ((artifact)["lowered"] = ({"typed": (product)["typed"], "descriptor": (product)["descriptor"]}));
1337
+ }
1338
+ ((artifact)["path"] = resolve(directory, ((host === "wasm") ? "compiler.wasm" : ((native_target === "arm64-linux") ? "compiler.so" : "compiler.dylib"))));
1339
+ await (writeFile((artifact)["path"], (artifact)["bytes"]));
1340
+ return phase("binary-file-complete");
1341
+ })()));
1342
+ (await (async (runtime_asset) => {
1343
+ ((artifact)["runtimePath"] = resolve(directory, (((runtime_asset)["encoding"] === "utf8") ? "runtime.eli" : "runtime.eli.json")));
1344
+ if ((!((runtime_asset)["encoding"] === "utf8"))) {
1345
+ ((artifact)["runtimeEncoding"] = (runtime_asset)["encoding"]);
1346
+ }
1347
+ return await (writeFile((artifact)["runtimePath"], (runtime_asset)["text"]));
1348
+ })(encodeCompilerSourceAsset(((graph)["runtime"])["source"])));
1349
+ ((files = ((host === "javascript") ? ((artifact)["modules"])["flatMap"](((record) => {
1350
+ {
1351
+ const __eliscript_value_107 = [(record)["path"]];
1352
+ {
1353
+ let paths = __eliscript_value_107;
1354
+ if (__eliscript_truthy(build_truth((record)["sourceMapPath"]))) {
1355
+ (paths)["push"]((record)["sourceMapPath"]);
1356
+ }
1357
+ if (__eliscript_truthy(build_truth((record)["macroOriginsPath"]))) {
1358
+ (paths)["push"]((record)["macroOriginsPath"]);
1359
+ }
1360
+ return paths;
1361
+ }
1362
+ }
1363
+ })) : [(artifact)["path"]])));
1364
+ (__eliscript_truthy(((__eliscript_value_108) => (__eliscript_truthy(__eliscript_value_108) ? ((artifact)["modules"])["some"](((record) => {
1365
+ return ((record)["id"] === "runtime/math.mjs");
1366
+ })) : __eliscript_value_108))((host === "javascript"))) ? (files)["push"](await (write_compiler_math_scope(directory))) : null);
1367
+ ((reserved = new (globalThis.Set)(((host === "javascript") ? ((artifact)["modules"])["map"](((record) => {
1368
+ return (record)["id"];
1369
+ })) : [compiler_portable_path(directory, (artifact)["path"])]))));
1370
+ (__eliscript_truthy(build_truth(build_optional_get((product)["descriptor"], "project"))) ? (await (async (facades, index) => {
1371
+ ((artifact)["project"] = ({"entry": (facades)["entry"], "registry": (facades)["registry"], "loadEntry": (facades)["loadEntry"], "files": []}));
1372
+ return (await (async () => {
1373
+ while (__eliscript_numeric_relation("<", index, (((facades)["files"]) ?? []).length)) {
1374
+ (await (async (record) => {
1375
+ if (__eliscript_truthy((reserved)["has"]((record)["id"]))) {
1376
+ ((__eliscript_value_109) => { throw __eliscript_value_109; })(new (globalThis.TypeError)("managed facade collides with a compiler artifact"));
1377
+ }
1378
+ (reserved)["add"]((record)["id"]);
1379
+ return ((path) => {
1380
+ (((artifact)["project"])["files"])["push"]((record)["id"]);
1381
+ return (files)["push"](path);
1382
+ })(await (write_module(directory, (record)["id"], (record)["source"])));
1383
+ })(((facades)["files"])[index]));
1384
+ ((index = (index + 1)));
1385
+ }
1386
+ return null;
1387
+ })());
1388
+ })(createManagedProjectFacades((product)["descriptor"], ({"entry": (graph)["entry"]})), 0)) : null);
1389
+ (__eliscript_truthy(build_truth((graph)["hostSources"])) ? (await (async () => {
1390
+ ((artifact)["hostSources"] = []);
1391
+ return (await (async (index, records) => {
1392
+ return (await (async () => {
1393
+ while (__eliscript_numeric_relation("<", index, ((records) ?? []).length)) {
1394
+ (await (async (record) => {
1395
+ if ((!__eliscript_truthy(((__eliscript_value_110) => (__eliscript_truthy(__eliscript_value_110) ? ((__eliscript_value_111) => (__eliscript_truthy(__eliscript_value_111) ? ((!__eliscript_truthy((((record)["id"])["split"]("/"))["some"](((part) => {
1396
+ return ((!__eliscript_truthy(build_truth(part))) || (part === ".") || (part === ".."));
1397
+ })))) && (!__eliscript_truthy((reserved)["has"]((record)["id"]))) && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["source"]) === "string")) : __eliscript_value_111))(((record)["id"])["endsWith"](".mjs")) : __eliscript_value_110))((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(build_optional_get(record, "id")) === "string"))))) {
1398
+ ((__eliscript_value_112) => { throw __eliscript_value_112; })(new (globalThis.TypeError)("invalid or colliding host source artifact"));
1399
+ }
1400
+ (reserved)["add"]((record)["id"]);
1401
+ return ((path) => {
1402
+ (files)["push"](path);
1403
+ return ((artifact)["hostSources"])["push"](({"id": (record)["id"], "path": path}));
1404
+ })(await (write_module(directory, (record)["id"], (record)["source"])));
1405
+ })((records)[index]));
1406
+ ((index = (index + 1)));
1407
+ }
1408
+ return null;
1409
+ })());
1410
+ })(0, (graph)["hostSources"]));
1411
+ })()) : null);
1412
+ (files)["push"]((artifact)["runtimePath"]);
1413
+ (__eliscript_truthy(build_truth((graph)["literalSources"])) ? (await (async () => {
1414
+ ((artifact)["literalSources"] = []);
1415
+ return (await (async (records, index) => {
1416
+ return (await (async () => {
1417
+ while (__eliscript_numeric_relation("<", index, ((records) ?? []).length)) {
1418
+ (await (async (record) => {
1419
+ if ((!__eliscript_truthy(((__eliscript_value_113) => (__eliscript_truthy(__eliscript_value_113) ? ((__eliscript_value_114) => (__eliscript_truthy(__eliscript_value_114) ? ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["filename"]) === "string") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["source"]) === "string")) : __eliscript_value_114))((new (globalThis.RegExp)("^(?:stdlib|runtime)/(?:[a-z][a-z0-9-]*/)*[a-z][a-z0-9-]*[.]mjs$"))["test"]((record)["id"])) : __eliscript_value_113))((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(build_optional_get(record, "id")) === "string"))))) {
1420
+ ((__eliscript_value_115) => { throw __eliscript_value_115; })(new (globalThis.TypeError)("invalid persistent literal source"));
1421
+ }
1422
+ return (await (async (encoded) => {
1423
+ return (await (async (asset) => {
1424
+ return (await (async () => {
1425
+ if (__eliscript_truthy((reserved)["has"](asset))) {
1426
+ ((__eliscript_value_116) => { throw __eliscript_value_116; })(new (globalThis.TypeError)("persistent literal source collides with a compiler artifact"));
1427
+ }
1428
+ (reserved)["add"](asset);
1429
+ return (await (async (path) => {
1430
+ return (await (async (output) => {
1431
+ return (await (async () => {
1432
+ await (mkdir(dirname(path), ({"recursive": true})));
1433
+ await (writeFile(path, (encoded)["text"]));
1434
+ (files)["push"](path);
1435
+ if ((!((encoded)["encoding"] === "utf8"))) {
1436
+ ((output)["encoding"] = (encoded)["encoding"]);
1437
+ }
1438
+ return ((artifact)["literalSources"])["push"](output);
1439
+ })());
1440
+ })(({"id": (record)["id"], "filename": (record)["filename"], "path": path})));
1441
+ })(resolve(directory, asset)));
1442
+ })());
1443
+ })(("literal-sources/" + ((record)["id"])["slice"](0, -4) + (((encoded)["encoding"] === "utf8") ? ".eli" : ".eli.json"))));
1444
+ })(encodeCompilerSourceAsset((record)["source"])));
1445
+ })((records)[index]));
1446
+ ((index = (index + 1)));
1447
+ }
1448
+ return null;
1449
+ })());
1450
+ })((graph)["literalSources"], 0));
1451
+ })()) : null);
1452
+ ((!((product)["debug"] === undefined)) ? (await (async () => {
1453
+ ((artifact)["debugPath"] = ((artifact)["path"] + ".debug.json"));
1454
+ phase("debug-file-start");
1455
+ (__eliscript_truthy(owned_product) ? await (write_owned_compiler_metadata((artifact)["debugPath"], (product)["debug"])) : await (writeCompilerMetadata((artifact)["debugPath"], (product)["debug"])));
1456
+ phase("debug-file-complete");
1457
+ (files)["push"]((artifact)["debugPath"]);
1458
+ if (__eliscript_truthy(owned_product)) {
1459
+ return ((product)["debug"] = undefined);
1460
+ } else {
1461
+ return null;
1462
+ }
1463
+ })()) : null);
1464
+ (__eliscript_truthy(build_truth(retain_ir)) ? (await (async () => {
1465
+ (await (async (records, index) => {
1466
+ if ((!__eliscript_truthy(runtime_checkpoint))) {
1467
+ (records)["push"]((product)["runtimeIR"]);
1468
+ }
1469
+ ((artifact)["frontendIR"] = []);
1470
+ return (await (async () => {
1471
+ while (__eliscript_numeric_relation("<", index, ((records) ?? []).length)) {
1472
+ (await (async (record) => {
1473
+ if ((!((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(build_optional_get(record, "id")) === "string") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["ir"]) === "string") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["canonicalIR"]) === "string")))) {
1474
+ ((__eliscript_value_117) => { throw __eliscript_value_117; })(new (globalThis.TypeError)("compiler omitted its original frontend IR"));
1475
+ }
1476
+ ((saved) => {
1477
+ ((artifact)["frontendIR"])["push"](saved);
1478
+ return (files)["push"]((saved)["path"], (saved)["canonicalPath"]);
1479
+ })(await (compiler_save_ir(directory, record, index, false)));
1480
+ if (__eliscript_truthy(owned_product)) {
1481
+ ((records)[index] = undefined);
1482
+ if (__eliscript_numeric_relation("<", index, (((product)["frontendIR"]) ?? []).length)) {
1483
+ return (((product)["frontendIR"])[index] = undefined);
1484
+ } else {
1485
+ return ((product)["runtimeIR"] = undefined);
1486
+ }
1487
+ } else {
1488
+ return null;
1489
+ }
1490
+ })((records)[index]));
1491
+ ((index = (index + 1)));
1492
+ }
1493
+ return null;
1494
+ })());
1495
+ })(Array.from((product)["frontendIR"]), 0));
1496
+ if (__eliscript_truthy(runtime_checkpoint)) {
1497
+ {
1498
+ const __eliscript_value_118 = (runtime_checkpoint)["runtime"];
1499
+ {
1500
+ let saved = __eliscript_value_118;
1501
+ ((artifact)["frontendIR"])["push"](saved);
1502
+ (files)["push"]((saved)["path"], (saved)["canonicalPath"]);
1503
+ }
1504
+ }
1505
+ }
1506
+ return (__eliscript_truthy(Object.hasOwn(graph, "literalSources")) ? (await (async () => {
1507
+ if ((!__eliscript_truthy(((__eliscript_value_119) => (__eliscript_truthy(__eliscript_value_119) ? __eliscript_value_119 : ((__eliscript_value_120) => (__eliscript_truthy(__eliscript_value_120) ? ((((product)["literalIR"]) ?? []).length === (((graph)["literalSources"]) ?? []).length) : __eliscript_value_120))(Array.isArray((product)["literalIR"]))))(runtime_checkpoint)))) {
1508
+ ((__eliscript_value_121) => { throw __eliscript_value_121; })(new (globalThis.TypeError)("compiler omitted its persistent literal frontend IR"));
1509
+ }
1510
+ ((artifact)["literalIR"] = []);
1511
+ return (__eliscript_truthy(runtime_checkpoint) ? ((runtime_checkpoint)["literals"])["forEach"](((saved) => {
1512
+ ((artifact)["literalIR"])["push"](saved);
1513
+ return (files)["push"]((saved)["path"], (saved)["canonicalPath"]);
1514
+ })) : (await (async (index) => {
1515
+ return (await (async () => {
1516
+ while (__eliscript_numeric_relation("<", index, (((product)["literalIR"]) ?? []).length)) {
1517
+ (await (async (record) => {
1518
+ if ((!((build_optional_get(record, "id") === (((graph)["literalSources"])[index])["id"]) && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["ir"]) === "string") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })((record)["canonicalIR"]) === "string")))) {
1519
+ ((__eliscript_value_122) => { throw __eliscript_value_122; })(new (globalThis.TypeError)("compiler changed its persistent literal frontend IR identity"));
1520
+ }
1521
+ ((saved) => {
1522
+ ((artifact)["literalIR"])["push"](saved);
1523
+ return (files)["push"]((saved)["path"], (saved)["canonicalPath"]);
1524
+ })(await (compiler_save_ir(directory, record, index, true)));
1525
+ if (__eliscript_truthy(owned_product)) {
1526
+ return (((product)["literalIR"])[index] = undefined);
1527
+ } else {
1528
+ return null;
1529
+ }
1530
+ })(((product)["literalIR"])[index]));
1531
+ ((index = (index + 1)));
1532
+ }
1533
+ return null;
1534
+ })());
1535
+ })(0)));
1536
+ })()) : null);
1537
+ })()) : null);
1538
+ ((product = undefined));
1539
+ ((artifact)["artifactIdentity"] = ({"algorithm": "sha256", "files": []}));
1540
+ phase("file-identities-start");
1541
+ (await (async (buffer, index) => {
1542
+ return (await (async () => {
1543
+ while (__eliscript_numeric_relation("<", index, ((files) ?? []).length)) {
1544
+ (await (async (path) => {
1545
+ return ((identity) => {
1546
+ return (((artifact)["artifactIdentity"])["files"])["push"](build_copy_properties(({"path": compiler_portable_path(directory, path)}), identity));
1547
+ })(await (compiler_file_identity(path, buffer)));
1548
+ })((files)[index]));
1549
+ ((index = (index + 1)));
1550
+ }
1551
+ return null;
1552
+ })());
1553
+ })(new (globalThis.Uint8Array)(65536), 0));
1554
+ phase("file-identities-complete", ({"fileCount": ((((artifact)["artifactIdentity"])["files"]) ?? []).length}));
1555
+ phase("product-identity-start");
1556
+ ((artifact)["productIdentity"] = independentCompilerProductIdentity(({"host": host, "nativeTarget": native_target, "files": ((artifact)["artifactIdentity"])["files"], "descriptor": (artifact)["descriptor"], "typed": (artifact)["typed"]})));
1557
+ phase("product-identity-complete");
1558
+ (await (async (metadata_path) => {
1559
+ ((artifact)["metadataPath"] = metadata_path);
1560
+ return (await (async (metadata) => {
1561
+ phase("artifact-metadata-start");
1562
+ (__eliscript_truthy(owned_product) ? await (write_owned_compiler_metadata(metadata_path, metadata)) : await (writeCompilerMetadata(metadata_path, metadata)));
1563
+ return phase("artifact-metadata-complete");
1564
+ })(compiler_artifact_metadata(artifact, directory)));
1565
+ })(resolve(directory, "compiler-artifact.json")));
1566
+ return artifact;
1567
+ })());
1568
+ })(undefined));
1569
+ })(undefined));
1570
+ })(build_copy_properties(({"host": host, "target": target, "directory": directory, "entry": (graph)["entry"]}), resources)));
1571
+ })(undefined, false, undefined));
1572
+ })(((session == null) ? ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(build_optional_get(frontend, "request")) === "function") ? frontend : undefined) : session)));
1573
+ })(((sources == null) ? await (loadCompilerSources(({"sourceRoot": source_root}))) : globalThis.structuredClone(sources))));
1574
+ })());
1575
+ })(resolve(output_root)));
1576
+ })(((name, counts = null) => {
1577
+ build_trace(trace, name, null);
1578
+ if ((!(on_phase === undefined))) {
1579
+ return (() => {
1580
+ try {
1581
+ return on_phase(name, Object.freeze(build_copy_properties(({"host": host}), counts)));
1582
+ } catch (ignored) {
1583
+ return undefined;
1584
+ }
1585
+ })();
1586
+ } else {
1587
+ return null;
1588
+ }
1589
+ })));
1590
+ })((((globalThis.process)["env"])["ELISCRIPT_COMPILER_BUILD_TRACE"] === "1")));
1591
+ })(independentCompilerResources(({"profile": profile, "budget": budget, "memory": memory, "auto": auto}))));
1592
+ })());
1593
+ })(target_for_host(host)));
1594
+ })((input)["onPhase"]));
1595
+ })((input)["signal"]));
1596
+ })(build_default((input)["debug"], false)));
1597
+ })(build_default((input)["retainIR"], false)));
1598
+ })(((value) => {
1599
+ if ((value === undefined)) {
1600
+ if (((globalThis.process)["platform"] === "linux")) {
1601
+ return "arm64-linux";
1602
+ } else {
1603
+ return "arm64-macos";
1604
+ }
1605
+ } else {
1606
+ return value;
1607
+ }
1608
+ })((input)["nativeTarget"])));
1609
+ })((input)["auto"]));
1610
+ })((input)["memory"]));
1611
+ })((input)["budget"]));
1612
+ })(build_default((input)["profile"], "small")));
1613
+ })((input)["session"]));
1614
+ })((input)["frontend"]));
1615
+ })((input)["sources"]));
1616
+ })(build_default((input)["sourceRoot"], root)));
1617
+ })(((value) => {
1618
+ if ((value === undefined)) {
1619
+ return resolve(root, "dist/independent-compiler", host);
1620
+ } else {
1621
+ return value;
1622
+ }
1623
+ })((input)["outputRoot"])));
1624
+ })(build_default((input)["host"], "wasm")));
1625
+ })(build_call_options(arguments$)));
1626
+ }
1627
+ export {independentCompilerProfiles, loadCompilerSources, independentCompilerResources, decodeCompilerBinary, compilerMetadataDigest, writeCompilerMetadata, independentCompilerProductIdentity, buildIndependentCompiler};
1628
+ //# sourceMappingURL=compiler-build.mjs.map