eliscript 0.0.1 → 0.0.2

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 +59 -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-legacy.mjs +37 -0
  35. package/bootstrap/host/eliscript-cli.mjs +53 -33
  36. package/bootstrap/host/eliscript-cli.mjs.map +1 -0
  37. package/bootstrap/host/project-cli-legacy.mjs +295 -0
  38. package/bootstrap/host/project-cli.mjs +74 -289
  39. package/bootstrap/host/project-cli.mjs.map +1 -0
  40. package/bootstrap/host/project-legacy.mjs +1080 -0
  41. package/bootstrap/host/project.mjs +210 -1060
  42. package/bootstrap/host/project.mjs.map +1 -0
  43. package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
  44. package/bootstrap/runtime/memory.eli +30379 -0
  45. package/browser/host.mjs +89 -0
  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 +446 -0
  141. package/dist/browser/loader.js +1 -0
  142. package/dist/browser/loader.mjs +231 -0
  143. package/dist/browser/worker.mjs +60 -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 +579 -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 +23 -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 +20 -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 +483 -0
  193. package/dist/literal-sources/stdlib/managed-literals.eli +1414 -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 +97 -10
  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 +114 -47
  252. package/stdlib/gepo.eli +12 -0
  253. package/stdlib/interop/js.eli +56 -15
  254. package/stdlib/managed-literal-protocols.eli +483 -0
  255. package/stdlib/managed-literals.eli +1414 -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 +579 -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 +23 -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 +20 -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 +460 -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 +486 -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,446 @@
1
+ // In-memory compile host for browsers and workers.
2
+ //
3
+ // The command-line host in `bootstrap/host/project.mjs` answers the project
4
+ // planner from the filesystem. This host answers the same questions from a map
5
+ // of sources, so a project compiles without a server process, and it rewrites
6
+ // every specifier the emitted modules carry so they can run from blob URLs.
7
+ //
8
+ // Every import in this file is relative. A worker has no document and therefore
9
+ // no import map, so this module and the compiler bundle it loads must never
10
+ // depend on one.
11
+
12
+ import {
13
+ compile_ir_string,
14
+ emit_ir_string_with_source_map,
15
+ project_plan,
16
+ } from "./compiler.js";
17
+
18
+ const SOURCE_EXTENSION = ".eli";
19
+ const OUTPUT_EXTENSION = ".mjs";
20
+
21
+ /* ------------------------------------------------------------------ paths */
22
+
23
+ function splitPath(path) {
24
+ return path.split("/").filter((part) => part !== "" && part !== ".");
25
+ }
26
+
27
+ export function normalizePath(path) {
28
+ const parts = [];
29
+ for (const part of splitPath(path)) {
30
+ if (part === "..") {
31
+ if (parts.length === 0) {
32
+ throw new Error(`path escapes the project root: ${path}`);
33
+ }
34
+ parts.pop();
35
+ } else {
36
+ parts.push(part);
37
+ }
38
+ }
39
+ return parts.join("/");
40
+ }
41
+
42
+ export function dirname(path) {
43
+ const parts = splitPath(path);
44
+ parts.pop();
45
+ return parts.join("/");
46
+ }
47
+
48
+ export function resolvePath(importer, specifier) {
49
+ const base = dirname(importer);
50
+ return normalizePath(base === "" ? specifier : `${base}/${specifier}`);
51
+ }
52
+
53
+ export function outputPathFor(source) {
54
+ if (!source.endsWith(SOURCE_EXTENSION)) {
55
+ throw new Error(`source module must end with ${SOURCE_EXTENSION}: ${source}`);
56
+ }
57
+ return `${source.slice(0, -SOURCE_EXTENSION.length)}${OUTPUT_EXTENSION}`;
58
+ }
59
+
60
+ export function relativePath(from, to) {
61
+ const fromParts = splitPath(dirname(from));
62
+ const toParts = splitPath(to);
63
+ let common = 0;
64
+ while (common < fromParts.length && common < toParts.length &&
65
+ fromParts[common] === toParts[common]) {
66
+ common += 1;
67
+ }
68
+ const parts = [
69
+ ...fromParts.slice(common).map(() => ".."),
70
+ ...toParts.slice(common),
71
+ ];
72
+ const joined = parts.join("/");
73
+ return joined.startsWith(".") ? joined : `./${joined}`;
74
+ }
75
+
76
+ /* ------------------------------------------------------------------ graph */
77
+
78
+ // The planner hands back discovery order, but a module's imports must exist
79
+ // before it does, so execution needs a dependency-first order.
80
+ export function dependencyOrder(modules) {
81
+ const byId = new Map(modules.map((module) => [module.id, module]));
82
+ const order = [];
83
+ const state = new Map();
84
+ for (const module of modules) visit(module.id);
85
+ return order;
86
+
87
+ function visit(id) {
88
+ const seen = state.get(id);
89
+ if (seen === "done") return;
90
+ if (seen === "visiting") throw new Error(`import cycle through ${id}`);
91
+ state.set(id, "visiting");
92
+ for (const dependency of byId.get(id)?.dependencies ?? []) visit(dependency);
93
+ state.set(id, "done");
94
+ order.push(id);
95
+ }
96
+ }
97
+
98
+ function walkProgram(program, visit) {
99
+ const pending = [...program.body];
100
+ while (pending.length > 0) {
101
+ const node = pending.pop();
102
+ visit(node);
103
+ const children = node.children;
104
+ if (children === undefined || children === null) continue;
105
+ for (let index = children.length - 1; index >= 0; index -= 1) {
106
+ pending.push(children[index]);
107
+ }
108
+ }
109
+ }
110
+
111
+ function localSourceSpecifier(specifier) {
112
+ return specifier.startsWith(".") && specifier.endsWith(SOURCE_EXTENSION);
113
+ }
114
+
115
+ function importSpecifiers(program) {
116
+ const specifiers = [];
117
+ walkProgram(program, (node) => {
118
+ if (node.kind === "import-declaration") specifiers.push(node);
119
+ });
120
+ return specifiers;
121
+ }
122
+
123
+ // A source map names its source relative to the map beside it, which is a bare
124
+ // relative path rather than an import specifier.
125
+ function mapSourcePath(output, source) {
126
+ const path = relativePath(`${output}.map`, source);
127
+ return path.startsWith("./") ? path.slice(2) : path;
128
+ }
129
+
130
+ // The emitter injects runtime imports of its own for literals, collection
131
+ // helpers, list operations, and value equality. Those are not import nodes in
132
+ // the program, so they survive the IR rewrite above and must be resolved in the
133
+ // emitted text or every module that uses a vector keeps a bare specifier.
134
+ function rewriteEmittedExternals(code, source, resolveExternal) {
135
+ if (resolveExternal === undefined) return code;
136
+ const rewrite = (whole, prefix, quoted) => {
137
+ const specifier = quoted.slice(1, -1);
138
+ if (specifier.startsWith(".") || specifier.startsWith("/") ||
139
+ specifier.includes("://")) {
140
+ return whole;
141
+ }
142
+ const external = resolveExternal(specifier, source);
143
+ return typeof external === "string" && external.length > 0
144
+ ? `${prefix}"${external}"`
145
+ : whole;
146
+ };
147
+ return code
148
+ .replace(/(\bfrom\s+)("[^"]+")/gu, rewrite)
149
+ .replace(/(\bimport\s+)("[^"]+")/gu, rewrite);
150
+ }
151
+
152
+ function diagnosticOf(error, filename) {
153
+ return error?.eliscriptDiagnostic ?? {
154
+ format: "eliscript-diagnostic",
155
+ version: 1,
156
+ code: "ELI-BROWSER-0001",
157
+ severity: "error",
158
+ phase: "browser-host",
159
+ message: error?.message ?? String(error),
160
+ location: { file: filename },
161
+ };
162
+ }
163
+
164
+ export class BrowserCompileError extends Error {
165
+ constructor(diagnostics) {
166
+ super(diagnostics.map((diagnostic) => diagnostic.message).join("; "));
167
+ this.name = "BrowserCompileError";
168
+ this.diagnostics = diagnostics;
169
+ }
170
+ }
171
+
172
+ function failure(code, message, filename) {
173
+ return new BrowserCompileError([{
174
+ format: "eliscript-diagnostic",
175
+ version: 1,
176
+ code,
177
+ severity: "error",
178
+ phase: "browser-host",
179
+ message,
180
+ location: { file: filename },
181
+ }]);
182
+ }
183
+
184
+ /* ---------------------------------------------------------------- compile */
185
+
186
+ // Rewrites every specifier an emitted module carries:
187
+ // - a local `.eli` import becomes the relative path of its emitted module;
188
+ // - a bare specifier is offered to `resolveExternal`, so an application can
189
+ // point the runtime at a served directory without an import map;
190
+ // - anything `resolveExternal` declines stays as written, which is what a
191
+ // third-party package import needs.
192
+ function rewriteSpecifiers(program, source, resolveExternal) {
193
+ for (const node of importSpecifiers(program)) {
194
+ const specifier = node.value;
195
+ if (localSourceSpecifier(specifier)) {
196
+ node.value = relativePath(
197
+ outputPathFor(source),
198
+ outputPathFor(resolvePath(source, specifier)),
199
+ );
200
+ continue;
201
+ }
202
+ if (specifier.startsWith(".") || specifier.startsWith("/")) continue;
203
+ const external = resolveExternal?.(specifier, source);
204
+ if (typeof external === "string" && external.length > 0) node.value = external;
205
+ }
206
+ }
207
+
208
+ /**
209
+ * Compiles one module.
210
+ *
211
+ * @returns {{ javascript: string, sourceMap: object }}
212
+ */
213
+ export function compileSource(
214
+ source,
215
+ filename = `module${SOURCE_EXTENSION}`,
216
+ options = {},
217
+ ) {
218
+ const program = compile_ir_string(source, filename, options.macroContext ?? null);
219
+ rewriteSpecifiers(program, filename, options.resolveExternal);
220
+ const output = outputPathFor(filename);
221
+ const emission = emit_ir_string_with_source_map(
222
+ program,
223
+ source,
224
+ output,
225
+ mapSourcePath(output, filename),
226
+ );
227
+ return {
228
+ javascript: rewriteEmittedExternals(
229
+ emission.javascript,
230
+ filename,
231
+ options.resolveExternal,
232
+ ),
233
+ sourceMap: emission.sourceMap,
234
+ };
235
+ }
236
+
237
+ /**
238
+ * Compiles a whole project from a map of sources.
239
+ *
240
+ * @param {object} request
241
+ * @param {Record<string, string>} request.files relative `.eli` path to source
242
+ * @param {string} request.entry relative `.eli` path to compile from
243
+ * @returns {{ plan: object, modules: Record<string, object> }}
244
+ */
245
+ export function compileProject({
246
+ files,
247
+ entry,
248
+ macroContext = null,
249
+ resolveExternal,
250
+ }) {
251
+ for (const path of Object.keys(files)) outputPathFor(path);
252
+ if (files[entry] === undefined) {
253
+ throw failure("ELI-BROWSER-0002", `entry is not in the project: ${entry}`, entry);
254
+ }
255
+
256
+ const programs = new Map();
257
+ const programFor = (id) => {
258
+ if (programs.has(id)) return programs.get(id);
259
+ if (files[id] === undefined) {
260
+ throw failure("ELI-BROWSER-0003", `missing source for import: ${id}`, id);
261
+ }
262
+ let program;
263
+ try {
264
+ program = compile_ir_string(files[id], id, macroContext);
265
+ } catch (error) {
266
+ throw new BrowserCompileError([diagnosticOf(error, id)]);
267
+ }
268
+ programs.set(id, program);
269
+ return program;
270
+ };
271
+
272
+ const plan = project_plan([entry], (id) => importSpecifiers(programFor(id))
273
+ .filter((node) => localSourceSpecifier(node.value))
274
+ .map((node) => resolvePath(id, node.value)));
275
+
276
+ const modules = {};
277
+ for (const id of dependencyOrder(plan.modules)) {
278
+ const output = outputPathFor(id);
279
+ const program = programFor(id);
280
+ rewriteSpecifiers(program, id, resolveExternal);
281
+ const emission = emit_ir_string_with_source_map(
282
+ program,
283
+ files[id],
284
+ output,
285
+ mapSourcePath(output, id),
286
+ );
287
+ modules[output] = {
288
+ id,
289
+ source: files[id],
290
+ javascript: rewriteEmittedExternals(emission.javascript, id, resolveExternal),
291
+ sourceMap: emission.sourceMap,
292
+ };
293
+ }
294
+ return { plan, modules };
295
+ }
296
+
297
+ /* ---------------------------------------------------------------- execute */
298
+
299
+ /**
300
+ * Turns compiled modules into importable blob URLs, dependencies first.
301
+ *
302
+ * A blob module has no directory, so its relative imports cannot resolve. Each
303
+ * local specifier was therefore rewritten to a relative path during compilation
304
+ * and is replaced here by the blob URL of the module it names. Only import
305
+ * specifiers are touched, never a string literal that resembles one.
306
+ *
307
+ * @returns {{ entryUrl: string, urls: Record<string, string>, release: () => void }}
308
+ */
309
+ export function moduleGraphUrls(modules, entry) {
310
+ const urls = {};
311
+ const created = [];
312
+ const outputs = Object.keys(modules);
313
+
314
+ const targetOf = (from, specifier) => {
315
+ const parts = splitPath(dirname(from));
316
+ for (const part of specifier.split("/")) {
317
+ if (part === "" || part === ".") continue;
318
+ if (part === "..") parts.pop();
319
+ else parts.push(part);
320
+ }
321
+ return parts.join("/");
322
+ };
323
+ const rewritePattern = (code, from, pattern) => code.replace(
324
+ pattern,
325
+ (whole, prefix, quoted) => {
326
+ const specifier = quoted.slice(1, -1);
327
+ if (!specifier.startsWith(".")) return whole;
328
+ const url = urls[targetOf(from, specifier)];
329
+ return url === undefined ? whole : `${prefix}"${url}"`;
330
+ },
331
+ );
332
+
333
+ for (const outputPath of outputs) {
334
+ let code = modules[outputPath].javascript;
335
+ code = rewritePattern(code, outputPath, /(\bfrom\s+)("[^"]+")/gu);
336
+ code = rewritePattern(code, outputPath, /(\bimport\s+)("[^"]+")/gu);
337
+ urls[outputPath] = URL.createObjectURL(
338
+ new Blob([code], { type: "text/javascript" }),
339
+ );
340
+ created.push(urls[outputPath]);
341
+ }
342
+
343
+ const entryUrl = urls[outputPathFor(entry)];
344
+ if (entryUrl === undefined) {
345
+ for (const url of created) URL.revokeObjectURL(url);
346
+ throw failure("ELI-BROWSER-0004", `compiled entry is missing: ${entry}`, entry);
347
+ }
348
+ const release = () => {
349
+ for (const url of created) URL.revokeObjectURL(url);
350
+ };
351
+ return { entryUrl, urls, release };
352
+ }
353
+
354
+ /**
355
+ * Compiles one Eliscript module in memory and executes it immediately via a
356
+ * temporary Blob URL.
357
+ *
358
+ * @param {string} source Eliscript source text
359
+ * @param {string} [filename="module.eli"] virtual filename for diagnostics/maps
360
+ * @param {object} [options={}] compilation options (e.g., resolveExternal)
361
+ * @returns {Promise<{ module: object, javascript: string, sourceMap: string }>}
362
+ */
363
+ export async function runSource(
364
+ source,
365
+ filename = `module${SOURCE_EXTENSION}`,
366
+ options = {},
367
+ ) {
368
+ const compiled = compileSource(source, filename, options);
369
+ const url = URL.createObjectURL(
370
+ new Blob([compiled.javascript], { type: "text/javascript" }),
371
+ );
372
+ try {
373
+ const module = await import(url);
374
+ return {
375
+ module,
376
+ javascript: compiled.javascript,
377
+ sourceMap: compiled.sourceMap,
378
+ };
379
+ } finally {
380
+ URL.revokeObjectURL(url);
381
+ }
382
+ }
383
+
384
+ function scriptFilename(script, index) {
385
+ const explicit = script?.getAttribute?.("data-filename") || script?.dataset?.filename;
386
+ if (typeof explicit === "string" && explicit.trim().length > 0) {
387
+ const name = explicit.trim();
388
+ return name.endsWith(SOURCE_EXTENSION) ? name : `${name}${SOURCE_EXTENSION}`;
389
+ }
390
+ if (typeof script?.src === "string" && script.src.length > 0) {
391
+ try {
392
+ const url = new URL(script.src, globalThis.location?.href ?? "http://localhost/");
393
+ const tail = url.pathname.split("/").filter(Boolean).pop();
394
+ if (tail && tail.endsWith(SOURCE_EXTENSION)) return tail;
395
+ } catch {}
396
+ }
397
+ return `inline-${index + 1}${SOURCE_EXTENSION}`;
398
+ }
399
+
400
+ /**
401
+ * Scans a DOM root for `<script type="text/eliscript">` elements (both inline
402
+ * and external `src="..."`) and compiles + executes each one in document order.
403
+ *
404
+ * @param {ParentNode} [root=globalThis.document]
405
+ * @param {object} [options={}]
406
+ * @returns {Promise<Array<{ script: Element, filename: string, module: object, javascript: string, sourceMap: string }>>}
407
+ */
408
+ export async function mountEliscriptScripts(
409
+ root = globalThis.document,
410
+ options = {},
411
+ ) {
412
+ if (!root || typeof root.querySelectorAll !== "function") return [];
413
+ const fetchImpl = options.fetch ?? globalThis.fetch;
414
+ const scripts = Array.from(root.querySelectorAll('script[type="text/eliscript"]'));
415
+ const mounted = [];
416
+ for (let index = 0; index < scripts.length; index += 1) {
417
+ const script = scripts[index];
418
+ if (script.dataset?.eliscriptMounted === "true") continue;
419
+ if (script.dataset) script.dataset.eliscriptMounted = "true";
420
+ const filename = scriptFilename(script, index);
421
+ let source = script.textContent ?? "";
422
+ if (typeof script.src === "string" && script.src.length > 0) {
423
+ const response = await fetchImpl(script.src);
424
+ if (!response.ok) {
425
+ throw failure(
426
+ "ELI-BROWSER-0005",
427
+ `failed to fetch ${script.src}: ${response.status}`,
428
+ filename,
429
+ );
430
+ }
431
+ source = await response.text();
432
+ }
433
+ const executed = await runSource(source, filename, options);
434
+ mounted.push({
435
+ script,
436
+ filename,
437
+ ...executed,
438
+ });
439
+ }
440
+ return mounted;
441
+ }
442
+
443
+ export const browserHostSurface = Object.freeze({
444
+ sourceExtension: SOURCE_EXTENSION,
445
+ outputExtension: OUTPUT_EXTENSION,
446
+ });