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
package/README.md CHANGED
@@ -49,6 +49,28 @@ evaluation, `./bin/eliscript-watch` for rebuilds, and `./bin/eliscript-org` for
49
49
  Org sources. Each has a documented page in the
50
50
  [documentation](docs/getting-started.md).
51
51
 
52
+ ### Pure Browser Live Hot-Reload Compiler
53
+
54
+ Any website can compile and hot-reload `.eli` source directly in the browser
55
+ without a build server or repository files. Include `dist/browser/loader.js`
56
+ and use either `data-eliscript` or `<script type="text/eliscript">` tags:
57
+
58
+ ```html
59
+ <script defer src="https://unpkg.com/eliscript@0.0.3/dist/browser/loader.js"></script>
60
+ <script type="text/eliscript">
61
+ (module app.live
62
+ (print "Hello from in-browser Eliscript!"))
63
+ </script>
64
+ ```
65
+
66
+ Or import the programmatic browser SDK (`eliscript/browser`) to compile single
67
+ modules (`compileSource`, `runSource`), multi-file projects (`compileProject`,
68
+ `moduleGraphUrls`), or DOM script tags (`mountEliscriptScripts`) in memory, with
69
+ built-in IR constant-folding/dead-branch optimization (`optimizeProgramIr`),
70
+ optional JavaScript compaction (`optimizeJavaScript` / `{ minify: true }`), and
71
+ extensionless package subpath imports (`(import "eliscript/runtime/core/order" sort)`
72
+ alongside explicit `.mjs`).
73
+
52
74
  ## What Works Today
53
75
 
54
76
  | Area | State |
@@ -61,6 +83,13 @@ Org sources. Each has a documented page in the
61
83
  | Editor | [`eliscript-mode`](editor/README.md) and an evaluation REPL |
62
84
  | Applications | The [proving-ground site](https://liuchong.org/eliscript/examples/dogfood/_site/) and the packaged Action built from it, plus React, Org, and Vite probes as replaceable application evidence |
63
85
 
86
+ Experimental direct backends and the zero-import managed WASM heap are described
87
+ in the [backend runtime reference](tools/backends/README.md). The current delivery
88
+ uses a JavaScript-hosted stage0–stage3 compiler chain that emits JavaScript,
89
+ WASM and native programs, with 12,000-depth persistent zipper traversal and
90
+ edited ascent verified across all three output targets:
91
+ [active plan](docs/bootstrap-0.0.3-plan.md).
92
+
64
93
  ## Project Status
65
94
 
66
95
  The retained core acceptance audit records **35 of 35 mandatory criteria
@@ -115,6 +144,38 @@ baseline in
115
144
 
116
145
  ## Development
117
146
 
147
+ Build the JavaScript stage0 → stage1 → stage2 → stage3 chain, then independently
148
+ verify its fixed point:
149
+
150
+ ```sh
151
+ make bootstrap-release
152
+ make verify-bootstrap
153
+ ```
154
+
155
+ The second command only reads the existing artifacts. It rechecks the complete
156
+ declared products, source and IR identities, maps and other assets, compares every
157
+ stage2/stage3 product byte, and authenticates the stored comparison receipt. It
158
+ does not compile, rebuild, prepare a package, or update that receipt. Success is
159
+ exit code 0 and one JSON report with `scope: "stage2-stage3-complete-products"`,
160
+ `verification: "identical"`, the actual `fileCount`, matching stage2/stage3 product
161
+ SHA-256 summaries, and the source identity summary. The count follows the complete
162
+ product inventory rather than a fixed expected number.
163
+
164
+ Use the same output directory for both commands when choosing another layout:
165
+
166
+ ```sh
167
+ make bootstrap-release BOOTSTRAP_RELEASE_OUT=dist/bootstrap-local
168
+ make verify-bootstrap BOOTSTRAP_RELEASE_OUT=dist/bootstrap-local
169
+ ```
170
+
171
+ For a manifest elsewhere, run
172
+ `node tools/backends/dist/release-cli.mjs verify-bootstrap --bootstrap-manifest PATH/bootstrap.json`.
173
+ A missing file, a one-byte change, an extra product file, or a changed receipt
174
+ must produce a nonzero exit. Product control metadata can legitimately contain
175
+ different producer names and paths, so `diff -r` over entire stage directories is
176
+ not the comparison rule. This fixed-point check does not substitute for the final
177
+ stage3 JavaScript/WASM/native program acceptance.
178
+
118
179
  ```sh
119
180
  make byte-compile # Emacs Lisp with warnings as errors
120
181
  make test-core # contracts and the framework-neutral suite
@@ -98,3 +98,29 @@ All thirteen ESM modules and Source Maps are byte-identical across those
98
98
  generations. Formatter corpus tests additionally require canonical source to
99
99
  be byte-idempotent and original/formatted core sources to emit identical ESM.
100
100
  The Emacs Lisp seed remains the readable bootstrap and reference implementation.
101
+
102
+ ## Independent backends and runtime
103
+
104
+ `backends/wasm.eli` and `backends/native.eli` directly emit the experimental
105
+ numeric artifacts. `backends/memory.eli` validates the separate memory-u32 ABI,
106
+ including explicit `word-xor` without narrowing ordinary f64 values.
107
+ `runtime/memory.eli` supplies owned linear memory, managed values, root frames,
108
+ collection, UTF-16/UTF-8 operations, Map/Set key comparison/hashing, mutable tables
109
+ and live iterators.
110
+ It has no host imports. The [runtime guide](../tools/backends/README.md) defines
111
+ the checked APIs, rooting obligations and remaining capability limits.
112
+
113
+ These runtime slices do not yet implement general Map/Set JS interop, persistent
114
+ collection protocols, automatic root insertion or complete dynamic lowering. The complete
115
+ compiler still runs in JS; WASM/native compiler hosts and the complete nine-cell
116
+ self-bootstrap remain open in the [backend plan](../docs/native-wasm-feasibility.md).
117
+
118
+ `backends/managed.eli` starts ordinary-value lowering through the explicit
119
+ `managed-control-v1` profile: primitive values, lexical/control forms and direct
120
+ calls link the runtime with automatic root frames and a versioned entry
121
+ descriptor. Its zero-import WASM outputs execute through the bulk checked host
122
+ entry. It also lowers Number arithmetic, strict equality, Number/String pair
123
+ relations and variadic comparison order. Number remainder, 32-bit conversions,
124
+ bitwise/shift operators and imul32 also run inside the managed runtime. Mixed coercion,
125
+ persistent literals, closures, interop and complete compiler lowering remain
126
+ open; this is not a full WASM compiler host.
@@ -0,0 +1,515 @@
1
+ # Independent backend foundation
2
+
3
+ `optimize.eli`, `numeric.eli`, `memory.eli`, `wasm.eli`, `native.eli` and `sha256.eli` implement
4
+ the optimizer, typed numeric lowering, WASM/ARM64 emission and deterministic
5
+ SHA-256 in Eliscript. No C, LLVM IR, WAT,
6
+ external assembler or external optimizer participates in direct emission.
7
+ `tools/backends/` supplies filesystem/bootstrap and bulk-memory boundary adapters.
8
+
9
+ This is the first executable slice of the
10
+ [independent 3×3 roadmap](../../docs/native-wasm-feasibility.md#后续计划与决策门槛).
11
+ The compiler currently **runs as JavaScript**, including in the browser test;
12
+ emitting WASM does not mean the compiler itself runs as WASM. Full dynamic
13
+ runtime support and WASM/native compiler execution remain open acceptance units.
14
+
15
+ ## Explicit numeric ABI
16
+
17
+ Every function has distinct required f64 parameters and an f64 result. Callers
18
+ must supply the declared arity and Number arguments. The compiler must validate
19
+ this subset before optimization; unsupported constructs fail with located
20
+ `ELI-B0001` diagnostics, including constructs in an unselected branch.
21
+
22
+ Supported operations:
23
+
24
+ - finite numeric constants, negative zero, local Number values and boolean
25
+ conditions; runtime Number values include NaN and infinities;
26
+ - binary `+`, `-`, `*`, `/`, unary `+`, `-`, `*`, `/`, `1+`, `1-`, and binary
27
+ numeric `=`, `<`, `<=`, `>`, `>=`;
28
+ - simple initialized `let`/`let*`, fixed-type local assignment and assignment
29
+ return values, sequences, `while`, typed `if`, and homogeneous `and`/`or`;
30
+ - synchronous direct function calls, forward references, ordinary recursion,
31
+ and named function exports, including Unicode names.
32
+
33
+ Numbers use Lisp truth: zero and NaN are true. Numeric `and`/`or` return an
34
+ operand and preserve short circuit; boolean conditions remain distinct from
35
+ Numbers. Parameters and results are deliberately not inferred to be i32.
36
+ This slice does not accept objects, strings, persistent collections, closures,
37
+ dynamic arity, host imports, raw JS, async/await, or exceptions in source
38
+ programs. It does not claim general tail-call elimination or full-language
39
+ semantic coverage.
40
+
41
+ All observable float arithmetic uses individual f64 instructions in source
42
+ order. There is no fast-math, FMA substitution, reassociation, or approximate equality.
43
+ The shared optimizer folds proven numeric constants and literal conditions;
44
+ non-finite fold results retain their original expression so canonical IR stays
45
+ lossless. Original IR is not mutated and surviving source spans are retained.
46
+
47
+ The WASM emitter distinguishes used and discarded results. Discarded
48
+ assignments use `local.set`; discarded sequences and loops do not manufacture
49
+ values only to drop them. Unused nontrapping numeric operations disappear,
50
+ while their operand effects stay in source order. Numeric truth conditions
51
+ retain evaluation effects and yield true, including for zero and NaN.
52
+ Short-circuit effects and possible nontermination remain. Eligible leaf calls
53
+ expand with isolated local slots and arguments evaluated once; recursive or
54
+ oversized calls stay intact. Assignment values remain available when used.
55
+
56
+ `numeric.eli` also owns the shared typed optimization stage. It performs:
57
+
58
+ - leaf inlining with ordered argument capture and immutable-parameter aliases;
59
+ - nonnegative integer counter specialization behind finite bounds through
60
+ `2^31 - 1`, with f64 fallback; fractional limits use `ceil` once;
61
+ - proven cyclic integer locals, power-of-two wrap masks, zero/one-iteration
62
+ loop versions and four-iteration unrolling with an untouched remainder;
63
+ - WASM-only counted compound guards: a proven nonnegative integer range admits
64
+ four complete steps with one counter check, while every floating escape test
65
+ stays at its original position; the final zero to three steps retain the
66
+ complete original condition;
67
+ - pure lexical-initializer hoisting and loop-square reuse with dependency
68
+ invalidation; writes, branches and calls conservatively end availability;
69
+ - two-lane scheduling of independent scalar call loops. Arguments and caller
70
+ updates must be independent of the reduction result, and the callee bound
71
+ must be invariant. Private lanes may interleave, while each lane's arithmetic
72
+ and the final additions keep their original order. Dependent inputs, mutable
73
+ limits, nonfinite or large bounds and unsupported shapes use the normal path.
74
+
75
+ The WASM emitter rotates loops, branches directly on boolean `and`/`or`, and
76
+ selects cheap pure numeric arms without executing unselected effects. Numeric
77
+ counter values still use Lisp truth; they are not exposed as boolean i32s.
78
+ No transform recognizes benchmark function names or fixed argument values.
79
+ The typed optimizer consumes validated `numeric-f64` IR and does not mutate it.
80
+
81
+ Core byte arrays, records, string code units, float64 words and array operations
82
+ are currently represented by the existing JS bootstrap runtime. Porting these
83
+ primitives is an explicit prerequisite for WASM/native compiler execution;
84
+ Eliscript algorithm ownership does not prove that host migration is finished.
85
+
86
+ ## Build and compile
87
+
88
+ ```sh
89
+ bun tools/backends/build.mjs
90
+ bun tools/backends/compile.mjs --abi numeric-f64 --target wasm \
91
+ -o dist/experiments/kernels.wasm tools/experiments/native-wasm/kernels.eli
92
+ bun tools/backends/compile.mjs --abi numeric-f64 --target js \
93
+ -o dist/experiments/kernels.mjs tools/experiments/native-wasm/kernels.eli
94
+ bun test tests/direct-wasm-backend.test.mjs
95
+ ```
96
+
97
+ The explicit build creates `dist/backends/` next to `dist/bootstrap/`; it leaves
98
+ the existing bootstrap artifact inventory and public package exports intact.
99
+ The emitter returns an ordinary array of byte values, and the host converts it
100
+ to `Uint8Array` for writing or instantiation. All emitted WASM modules in this
101
+ slice are import-free. Toolchain version and release metadata are unchanged.
102
+
103
+ The tests build the core and backend modules through Seed, Generation 2 and
104
+ Generation 3, compare JS and Source Maps byte-for-byte, then compare emitted
105
+ WASM bytes. They execute semantic differential cases under Bun/Node, generated
106
+ numeric programs, multi-byte indices, and real browser compilation/execution.
107
+ Those are mandatory semantic checks; performance is evaluated separately.
108
+ Regression cases cover every inlining/loop/integer option combination, counter
109
+ range boundaries, signed zero and nonfinite values, fractional loop and grid
110
+ bounds, cyclic wraparound, ordered reductions, and rejected dependent/mutable
111
+ call-loop pipelines. Node, Bun and Chromium execute the optimized results.
112
+
113
+ ## Performance decisions
114
+
115
+ ```sh
116
+ bun tools/backends/benchmark.mjs
117
+ bun tools/backends/benchmark.mjs --verify
118
+ bun tools/backends/benchmark.mjs --require-production
119
+ ```
120
+
121
+ The report compares the same Eliscript workload and same shared optimization
122
+ layer under Node, Bun and Chromium. Loops are inside each generated program;
123
+ host-to-module scalar call costs are not substituted for whole-program costs.
124
+ Every measured checksum must match exactly. Three fresh process sessions, five
125
+ warmups and nine samples per implementation are retained, with alternating
126
+ measurement order. Before measurement, the promotion budget is fixed at no
127
+ regression against optimized JS for **every** workload and engine.
128
+
129
+ An observed failure remains a failure: `--require-production` exits nonzero,
130
+ the experimental backend is not promoted, and existing semantic/performance
131
+ budgets remain in force. Local production may eventually select an explicitly
132
+ identified external optimizing backend after its own semantic and performance
133
+ acceptance; the browser independent path and full self-hosting roadmap remain
134
+ required. External optimization is not automatically invoked by this slice.
135
+
136
+ The retained 2026-10-14 report passes all nine frozen numeric hot-execution
137
+ pairs. Confirmation used identical JS/WASM artifact hashes. The generated JS
138
+ control is unchanged from the previous failed report. The WASM module grows
139
+ from 789 to 5517 bytes because guarded versions and unrolled code retain their
140
+ fallbacks. Subsequent counted-guard emission retains each floating guard and
141
+ uses the original loop for the remainder. The retained report records the actual
142
+ current artifact size and hash. This closes this numeric performance gate only; download, cold
143
+ startup, compiler throughput, memory and full-language/backend acceptance stay
144
+ open. The full backend remains experimental.
145
+
146
+
147
+ ## Independent ARM64 native slice
148
+
149
+ The explicit `arm64-macos` target emits baseline ARM64 instructions and Mach-O
150
+ objects, dynamic libraries or standalone executables, with macOS 15 as the
151
+ minimum deployment target. Compilation requires no C compiler, assembler,
152
+ linker, host crypto or signing executable. The library/export table, symbol
153
+ layout, PC-relative branches/calls/literals, content-derived UUID and SHA-256
154
+ ad-hoc page signature are emitted by `.eli` algorithms. Ad-hoc signing supports
155
+ local execution; it does not establish release identity or notarization.
156
+
157
+ ```sh
158
+ bun tools/backends/compile.mjs --abi numeric-f64 --target native \
159
+ --platform arm64-macos --native-format object -o dist/experiments/kernels.o \
160
+ tools/experiments/native-wasm/kernels.eli
161
+ bun tools/backends/compile.mjs --abi numeric-f64 --target native \
162
+ --platform arm64-macos --native-format library -o dist/experiments/kernels.dylib \
163
+ tools/experiments/native-wasm/kernels.eli
164
+ # INPUT must export a zero-argument numeric function named entry.
165
+ bun tools/backends/compile.mjs --abi numeric-f64 --target native \
166
+ --platform arm64-macos --native-format executable --entry entry \
167
+ -o dist/experiments/program INPUT.eli
168
+ bun test tests/native-backend.test.mjs
169
+ ```
170
+
171
+ `emit_native_numeric_object`, `emit_native_numeric_library` and
172
+ `emit_native_numeric_executable` return ordinary byte arrays. Native functions
173
+ follow the ARM64 f64 calling convention, including stack parameters after the
174
+ first eight and ordinary recursive calls. The standalone numeric executable
175
+ writes exactly eight little-endian f64 bytes to stdout, preserving signed zero,
176
+ infinities and NaN; a failed/short write exits nonzero. This small output
177
+ protocol does not provide a general-language I/O runtime.
178
+
179
+ Default native optimization uses control-flow liveness and interference,
180
+ f64/i32 register classes, reuse of nonoverlapping local lifetimes, expression
181
+ scratch registers and preservation only of used/live registers. Arguments
182
+ execute before call snapshots so their assignments remain visible. Constants
183
+ use exact ARM64 immediates or deduplicated PC-relative f64 pools. Discarded nontrapping arithmetic retains operand effects, and floating
184
+ expressions compute directly into registers without redundant result copies.
185
+ Comparisons branch directly with ordered NaN behavior, and loops rotate without losing
186
+ initial/final condition effects. The shared optional `unswitch` pass moves only
187
+ pure guards whose reads cannot be written in the loop, with bounded code growth.
188
+ Native additionally enables the shared optional `constantFlow`, `parallelSingle`
189
+ and `cyclicMultiple` passes. Constant flow invalidates loop/short-circuit writes
190
+ and joins exact IEEE constants, preserving signed zero. Single-trip lane dispatch
191
+ runs outside batch loops; each cyclic initialization and update needs a range
192
+ proof. Unread storage is removed while retaining RHS effects and result values.
193
+ Loop constants occupy only unused registers and survive actual calls, and integer
194
+ updates/comparisons use proven ARM64 immediates. WASM defaults are unchanged.
195
+ The explicit `{registerAllocation:false}` native API option retains the initial
196
+ stack emitter for independent before/after measurements and semantic regression.
197
+ Neither path permits FMA, float reordering or approximate comparisons.
198
+
199
+ Tests independently check SHA vectors and page hashes, verify actual macOS
200
+ signatures, compare independently emitted and system-linked reference objects,
201
+ and execute recursion, Unicode exports, deep expressions, more than eight
202
+ arguments, nested argument effects, float immediates and IEEE boundaries. The
203
+ system linker/signer in the reference test participates in verification only.
204
+ Linux runners inspect emitted images; ARM64 macOS runners execute them. Browser
205
+ JS compilers and three bootstrap generations emit identical native images;
206
+ this does not prove native or WASM compiler execution.
207
+
208
+ ```sh
209
+ bun tools/backends/native-benchmark.mjs --baseline
210
+ bun tools/backends/native-benchmark.mjs
211
+ bun tools/backends/native-benchmark.mjs --verify
212
+ bun tools/backends/native-benchmark.mjs --require-production
213
+ ```
214
+
215
+ The native report freezes the same workloads, optimized JS control, three fresh
216
+ sessions, five warmups, nine samples and per-workload 1.0× minimum used by the
217
+ numeric WASM gate. Measurement includes one Bun FFI call per entire batch.
218
+ Baseline and optimized native evidence are retained separately and bound to
219
+ compiler/backend sources. A failed report blocks promotion. Numeric native
220
+ emission remains experimental; full dynamic runtime, compiler execution, native
221
+ debug information, cold startup, memory and the full 3×3 matrix remain open.
222
+
223
+ The retained native before/after reports use the identical optimized JS artifact
224
+ hash and preserve the initial stack image hash. Speedups versus JS change from
225
+ 0.58×/0.22×/0.11× to 1.97×/1.11×/1.27× for recurrence/grid/tiny batches.
226
+ All three pass the unchanged numeric gate. These
227
+ measurements concern numeric kernels, not compiler throughput or full self-hosting.
228
+
229
+ The numeric WASM entry also enables strict constant data flow, unread-store
230
+ removal and invariant loop-condition hoisting. These retain exact IEEE operation
231
+ order, signed-zero identity, effects and the original fallback paths. Retained
232
+ failed/confirmation measurements distinguish unchanged-artifact variation from
233
+ actual emission changes; low-margin stability remains open in the roadmap.
234
+
235
+ ## Internal memory ABI
236
+
237
+ `emit_memory_wasm(program, {initialPages: 1, maximumPages: 256})` compiles the
238
+ explicit `memory-u32` runtime subset to owned, exported memory without WASM
239
+ imports. `bootstrap/runtime/memory.eli` supplies allocation, growable bytes,
240
+ fixed word records, sealed UTF16 builders and UTF8 encoding/decoding. All
241
+ algorithms are Eliscript; `tools/backends/memory-runtime.mjs` marshals bulk data
242
+ and brands handles per instance. No character decoding or allocation is delegated
243
+ to host callbacks. This is an internal experimental runtime slice; the complete
244
+ dynamic runtime and WASM/native compiler hosts remain open.
245
+
246
+ Every required parameter/result is a word with an unsigned 32-bit bit pattern;
247
+ boolean temporaries are separate. `+`, `-`, `*`, `1+`, `1-` wrap modulo 2^32,
248
+ comparisons are unsigned, and every word is true including zero. General language
249
+ Numbers retain their existing f64 semantics. Fractional/out-of-range literals,
250
+ negative zero, heterogeneous branches, value-position `when`/`unless`, arbitrary imports and shadowed capability
251
+ calls are rejected before emission. Division uses explicit unsigned `word-div`
252
+ with a zero-divisor trap; discarded loads/divisions retain their traps.
253
+
254
+ Only `eliscript:memory32` named imports resolve to instructions: `load-u8/u16/u32`,
255
+ `store-u8/u16/u32`, `load-f64`, `store-f64`, `memory-size`, `memory-grow`, `word-div`, `word-shr`,
256
+ `word-shl`, `word-and`, `word-or`. Stores return word zero. Raw exports use the
257
+ WASM i32 ABI (normalize returned bits with `>>> 0`); the bulk bridge rejects JS
258
+ coercion, invalid words, foreign handles and retired handles. These capabilities
259
+ are restricted to internal runtime source by repository integrity checks.
260
+
261
+ Memory uses little-endian words and 8-byte alignment. Control words at 0/4/8/12
262
+ store cursor/epoch/error/live-object head; allocation begins at 256. Each 32-byte
263
+ header holds kind/epoch/length/capacity/data/sealed/next/reserved. Byte arrays,
264
+ UTF16 strings and word records have kinds 1/2/3. Membership must come from the
265
+ live allocation list, rather than a tag in arbitrary byte data. Growth preserves
266
+ handles and contents and reacquires host views after `memory.grow`. Failed object
267
+ allocation rolls back unpublished storage; failed reserve preserves the buffer.
268
+ Pages must satisfy `1 <= initialPages <= maximumPages <= 65535`.
269
+
270
+ Public raw operations clear the last error; zero may be a valid read, so always
271
+ check `last-error`. Codes 1..7 mean invalid handle, capacity, bounds, invalid UTF8,
272
+ unpaired UTF16, sealed-state violation and exhausted epoch. The bulk bridge
273
+ throws structured `ELI-RT0001`..`ELI-RT0007` diagnostics. UTF8 replacement follows
274
+ maximal-subpart decoding, strict mode rejects malformed input, and a leading BOM
275
+ is stripped unless preservation is requested. UTF16 code units, including lone
276
+ surrogates, survive builder/readback; replacement encoding matches TextEncoder.
277
+
278
+ `retire` invalidates all live handles and advances the epoch. Addresses are never
279
+ reused, so stale pointers cannot alias later objects. This arena does **not**
280
+ reclaim memory or implement GC, cyclic dynamic records, ownership transfer or
281
+ untrusted raw-memory sandboxing. Records contain words; tagged dynamic values
282
+ are supplied by the managed heap below. The raw memory ABI is trusted internal storage;
283
+ the bridge supplies the instance/lifetime boundary for host handles.
284
+
285
+ Run `bun test tests/wasm-memory-runtime.test.mjs tests/direct-wasm-backend.test.mjs`.
286
+ The latter also verifies seed/second/third-generation emission identity and runs
287
+ the memory runtime in the selected real browser. Use `ELISCRIPT_TEST_BROWSER`
288
+ with chromium, firefox or webkit. Encoding semantics follow the
289
+ [Encoding Standard](https://encoding.spec.whatwg.org/#utf-8-decoder), and byte
290
+ emission follows the [WASM binary specification](https://webassembly.github.io/spec/core/binary/instructions.html).
291
+
292
+
293
+ ## Managed value heap
294
+
295
+ Compile `bootstrap/runtime/memory.eli` with `emit_memory_wasm`. All exported parameters/results are words; restricted
296
+ `load-f64` and `store-f64` additionally allow typed f64 locals and ordered Number
297
+ operations inside the runtime. Implicit Word/f64 conversion is refused.
298
+ `instantiateManagedRuntime(bytes, {maxSlots, initialBytes, maxBytes})` supplies a
299
+ bulk host bridge. `number`, `string`, `bytes`, `array` and `record` return branded
300
+ handles; `binary` (0 add, 1 subtract, 2 multiply, 3 divide), `negate` and `compare`
301
+ (0 equal, 1 unequal, 2 less, 3 less-or-equal, 4 greater, 5 greater-or-equal) run
302
+ inside WASM. NaN and signed-zero identity follow Number semantics. Strings keep
303
+ UTF16 code units, including lone surrogates. These APIs remain internal.
304
+
305
+ `readNumber`, `readString`, `readBytes`, `get`, `set`, `length`, `resize` and `truth`
306
+ check lifetime and kind. Byte results are copied. Arrays and fixed mutable records
307
+ hold handles or immediate null/false/true/undefined; ordinary Number input must
308
+ first be boxed with `number`. Arrays and bytes can resize; records stay fixed.
309
+ The internal reference record is not the language persistent Record type.
310
+
311
+ Each returned handle owns one explicit root; `get` owns a new root for the
312
+ returned child. `pin` adds a root and `release` drops one. `collect` marks rooted
313
+ objects and their reference graphs iteratively, then frees unreachable blocks
314
+ and recycles slots. Cyclic and shared graphs are supported. Pool-relative offsets
315
+ survive growth; sorted free blocks coalesce, while resize failure leaves the old
316
+ value intact. `stats` reports pool used/capacity bytes and live values, not full
317
+ process peak memory. Values use 12-bit generations and 20-bit slots; slots stop
318
+ recycling at generation 4095 to prevent stale identity reuse. Exhaustion returns
319
+ the existing capacity diagnostic. A released handle remains usable until actual
320
+ collection; using it after collection fails with ELI-RT0001.
321
+
322
+ Collection defaults to explicit. `auto(thresholdBytes)` enables allocation
323
+ safepoints at a nonzero byte threshold; `auto(0)` disables them. Successful
324
+ allocations accumulate byte debt, checked before the next allocation. With this
325
+ mode enabled, exhausted slots or blocks trigger collection and one complete
326
+ retry. Resize temporarily roots its operand and preserves its identity and data
327
+ on failure. Number operations capture their f64 operands before allocation.
328
+ `array`/`record` construction temporarily roots each borrowed argument before
329
+ subsequent getters or allocation and releases those roots on success or failure.
330
+
331
+ `frame(count)` creates a private root frame; `frameSet`/`frameGet` access its
332
+ locals, including locals of an active ancestor. `frameGet` returns an owned root.
333
+ `leaveFrame` requires the current top frame. `frameReturn(frame, value)` roots the
334
+ result before popping and returns a handle with exactly one transferred root;
335
+ place it in a caller frame and release that root when ownership is transferred.
336
+ Existing roots remain independent. Popped or unwound frames expire immediately,
337
+ and frame tokens cannot appear as ordinary values or cross runtime instances.
338
+ `unwindFrames(target)` discards frames above an active ancestor; omission unwinds
339
+ all frames. Invalid targets leave the stack unchanged. Pop/unwind clear references
340
+ without allocation or GC. Use unwind in trap/exception cleanup before the next
341
+ allocation. `stats` also reports `frameDepth` and a saturating collection counter.
342
+
343
+ The raw WASM exports are `heap-auto`, `heap-collections` and
344
+ `frame-new/set/get/pop/return/unwind/depth`, with word arguments/results.
345
+ `frame-return` adds one explicit result root; immediate nil returns word zero on
346
+ success, so raw callers must inspect `last-error` to distinguish failure.
347
+ Collection traces the active frame chain and all its locals. Before enabling
348
+ automatic collection, raw callers must keep every live reference in a frame or
349
+ explicit root. Complete compiler insertion of these calls remains open; the
350
+ internal loop/recursive fixtures insert them explicitly.
351
+
352
+ Managed text now includes sealed UTF-16 concat, checked slice, lexical compare,
353
+ constant-space linear find and code points, plus exact-allocation UTF-8 codecs.
354
+ Strict errors allocate no result; allocating operations protect inputs across
355
+ collection and refresh addresses after growth. The bridge APIs and internal word
356
+ contracts are documented in the [runtime reference](../../tools/backends/README.md).
357
+ Raw accesses explicitly check the complete access width before executing a load
358
+ or store, preserving operand effects and growth before a catchable WASM trap.
359
+
360
+ The backing arena still retains previous regions on pool growth and does not yet
361
+ destroy multiple heaps. Complete dynamic lowering, persistent collections and
362
+ full compiler hosts remain open. No full compiler memory or performance
363
+ acceptance is claimed by these runtime slices.
364
+
365
+ ## Primitive Number and text conversion
366
+
367
+ The experimental managed profile now lowers `string-to-number` and variadic
368
+ `str`, and reuses those primitive conversions for String positions, concat and
369
+ Number-valued named-object keys. Decimal and binary/octal/hexadecimal strings
370
+ retain all significant digits before exact nearest-even binary64 rounding.
371
+ Empty text, ECMAScript whitespace, signed zero, subnormals, NaN and infinities
372
+ keep their separate semantics. Number text uses exact rounding intervals to
373
+ produce the shortest roundtripping ECMAScript spelling; it does not format a
374
+ fixed count of decimal digits or discard rounding information.
375
+
376
+ Private base-2^16 integers live in GC-rooted scratch bytes inside the same WASM
377
+ heap. No host parser, formatter or per-character imports are used. Scratch
378
+ addresses are used only between allocation safepoints, and all addresses are
379
+ reloaded after result allocation. Borrowed inputs, capacity failures and real
380
+ WASM traps retain the caller's roots and exact input values.
381
+
382
+ Generated JS uses a shared primitive helper for nondecimal Number conversion:
383
+ it parses valid radix integers exactly before converting to binary64, avoiding
384
+ host differences in direct Number(string) conversion. Modules with neither
385
+ numeric conversion nor dynamic numeric operators receive no helper. Seed and self-hosted emitters retain the
386
+ same bytes and source marks. Represented ordinary-object conversion hooks run
387
+ through the source call ABI. Symbol/BigInt coercion, complete JS interoperability
388
+ and full compiler hosts remain open; these slices do not close them.
389
+
390
+ ## Primitive source operators and typed JS
391
+
392
+ Ordinary managed arithmetic, remainder, word operations and relations now accept
393
+ nil, booleans, undefined, Number and String inputs. Addition concatenates if
394
+ either primitive is a String; two Strings compare by UTF-16 units. Other
395
+ relational inputs use exact Number conversion. Strict equality stays distinct
396
+ from table-key equality, and single-operand `+` and `*` retain the original value.
397
+ Both operands and intermediate conversions are rooted across allocation;
398
+ conversion failure suppresses later effects and retains caller frames. The raw
399
+ Number-only API keeps its original strict argument checks.
400
+
401
+ Dynamic JS operators use shared helpers for exact radix parsing and observable
402
+ ToPrimitive/ToNumeric ordering. They retain BigInt and object-hook semantics,
403
+ snapshot built-in conversion operations before user callbacks can replace them,
404
+ and bound integer parsing only after validating the complete radix grammar.
405
+ Modules emit these helpers conditionally. Ordinary Number pairs avoid extra
406
+ primitive conversion; no per-call closure is introduced.
407
+
408
+ Closed scalar loops also receive a Number entry version: required parameters
409
+ are checked once, then the loop uses direct operators. A lexical proof excludes
410
+ free reads/writes, strings, objects, calls, host access and destructuring. Other
411
+ inputs execute the complete coercion path, with identical operand and exception
412
+ order. This keeps numerical loop intermediates unboxed without trusting an IR
413
+ annotation or relaxing the dynamic language.
414
+
415
+ The numeric backend's `emit-numeric-javascript` validates the complete original
416
+ numeric-f64 IR before shared optimization and Number-only JS emission. The
417
+ explicit numeric CLI and benchmark generators use that checked entry. It rejects
418
+ unsupported dead code, leaves input IR unchanged, restores emission state after
419
+ failure and preserves the accepted optimized JS control bytes. It is not a
420
+ user-supplied unchecked annotation or a full dynamic backend.
421
+
422
+ Backend fixture preparation compiles all frontend modules in one Emacs seed
423
+ process with the same normal file compiler. Independent CLI comparisons verify
424
+ all JS and source-map bytes; no compiler module, generation or test is omitted.
425
+ This reduces repeated startup work within the original CI budget. Complete
426
+ compiler hosts, managed Symbol/BigInt coercion, production acceptance and
427
+ the full nine-cell bootstrap matrix remain open.
428
+
429
+ ## Source-array properties and sparse slots
430
+
431
+ Source arrays distinguish absent indexed slots from own slots containing
432
+ undefined. Length growth creates holes; shrink removes truncated slots; slice
433
+ preserves holes, converts primitive positions and excludes named properties.
434
+ Primitive property keys use exact Number/text conversion. Indices enumerate in
435
+ ascending order, followed by named properties in insertion order; length is an
436
+ own nonenumerable property. `object-has?`, `object-keys` and `object-assoc` accept
437
+ arrays, with assoc producing an ordinary shallow object containing enumerable
438
+ own properties. The raw reference-array layout and nil-filled ABI are unchanged.
439
+
440
+ Named-property tables are owned by the source array, traced by GC and preserved
441
+ across indexed storage growth. Private hole words never become handles or roots.
442
+ Allocating setters protect receiver, key and child; failed property allocation
443
+ does not publish a partial entry. Indexed reads and existing string-key queries
444
+ need no temporary frames, conversion strings or collection.
445
+
446
+ Static push/pop/slice calls capture lookup before evaluating arguments. A
447
+ shadowing data property causes noncallable failure after argument evaluation;
448
+ an argument replacing a builtin does not change the already captured call.
449
+ Bulk source-array bridging snapshots enumerable own string-keyed properties,
450
+ retains holes at other indices, protects earlier getter values and ignores the
451
+ input's iterator override.
452
+ Own proto data is copied as data; changing Array prototypes, general descriptors,
453
+ Symbol/BigInt keys and arbitrary host-object coercion remain explicitly unsupported.
454
+
455
+ ## Source Map, Set and live iterators
456
+
457
+ The managed profile accepts unshadowed builtin Map/Set constructors, their
458
+ get/set/add/has/delete/clear calls, size, and entries/keys/values/next. Constructors
459
+ consume arrays, source collections, live source iterators and String code points;
460
+ Map entries must be objects and are read at properties 0 and 1. Null and undefined
461
+ initializers create empty collections. Ignored arguments still evaluate in order.
462
+
463
+ Source wrappers use heap kinds 15/16/17 while raw Map/Set/iterator kinds 10/11/12
464
+ retain their existing ABI. Collection entries are separate from named own data;
465
+ size is inherited and read-only, and own enumeration/copy includes only named
466
+ own data. Method lookup is captured before arguments. Noncallable shadows fail
467
+ after argument evaluation, and replacing a method during argument evaluation
468
+ does not change the captured builtin. Simple parameter-only get/has leaves use
469
+ no private frame, allocation or GC.
470
+
471
+ Table iteration stays live across insertion, deletion, clear and storage growth.
472
+ Map and Set `forEach` use those same live tickets, with `(value, key, map)` and
473
+ `(value, value, set)` callback arguments. They validate the callback even for an
474
+ empty table, preserve captured own methods and argument effects, and unwind
475
+ private roots on capacity failures or real WASM traps. Mutation does not create
476
+ a snapshot or substitute a host-side loop.
477
+ Array iterators observe current length and return undefined for holes; String
478
+ iteration consumes code points and preserves lone surrogates. Each next call
479
+ returns a fresh value/done object. Completion is sticky and releases its source.
480
+ GC traces wrappers, named data, active iterators and their current values.
481
+
482
+ Arbitrary constructors, other builtin method values, Symbol protocols, descriptors,
483
+ prototype changes and other collection APIs remain unsupported. Missing members
484
+ return undefined; known unsupported builtin function values are refused. These
485
+ zero-import WASM slices do not complete either compiler host or the full matrix.
486
+
487
+ ## Exact integer rounding
488
+
489
+ Unshadowed `Math.round`, `floor`, `ceil` and `trunc` are first-class managed
490
+ builtins. They evaluate all arguments before ordinary Number conversion, retain
491
+ lexical shadows and conversion callback order, and handle missing arguments.
492
+ Their binary64 implementation preserves NaN, infinities, signed zero and
493
+ subnormals. `round` resolves negative half ties toward positive infinity without
494
+ adding 0.5 before rounding. Neither these functions nor source Number `1+`/`1-`
495
+ call a host math service. Number steps allocate the result directly and retain
496
+ the original mixed-value conversion path.
497
+
498
+ ## Source sequence concatenation
499
+
500
+ Array and String `concat` capture their selected method before evaluating every
501
+ argument. Array results are fresh shallow copies: arrays spread one level,
502
+ other values remain single entries, and holes stay distinct from own undefined.
503
+ Array constructor validation follows argument effects and precedes copying.
504
+ String arguments use ordinary text conversion in order, including source
505
+ conversion callbacks and lone UTF-16 surrogates. Own methods retain their
506
+ original callable and extra argument effects. Private roots protect arguments,
507
+ partial results and caller frames through collection, capacity failure and
508
+ actual WASM traps; no host copying or conversion implementation is required.
509
+
510
+ `Object.is` is a first-class builtin with SameValue semantics: NaN equals NaN,
511
+ positive and negative zero differ, and objects retain reference identity.
512
+ The existing `Array.isArray` continues to recognize source arrays only, keeping
513
+ private reference arrays and records separate. Aliases, missing arguments,
514
+ ignored extra arguments and lexical namespace shadows preserve normal call
515
+ semantics; neither predicate performs coercion.