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
@@ -22,11 +22,25 @@
22
22
  (defconst portable-forbidden-operators
23
23
  (js-array "js*" "print" "put" "js-call" "new" "async" "await" "throw" "try"))
24
24
 
25
- (defconst fail
26
- (js* "(diagnostic) => { const p = diagnostic.location.start; const error = new Error(`${diagnostic.location.file}:${p.line}:${p.column}: ${diagnostic.message}`); error.eliscriptDiagnostic = diagnostic; throw error; }"))
27
- (defconst guard
28
- (js* "(operation, onError) => { try { return operation(); } catch (error) { return onError(error.message); } }"))
25
+ (defconst top-level-operators
26
+ (js-array "defun" "defn" "defportable" "defasync" "defvar" "defconst"
27
+ "export" "export-default" "import" "import-portable" "module"))
29
28
 
29
+ (defconst fail
30
+ (lambda (diagnostic)
31
+ (let* ((p (aref (aref diagnostic "location") "start"))
32
+ (error (new (js* "Error")
33
+ (let* ((file-value (aref (aref diagnostic "location") "file"))
34
+ (file (js* "`${file_value}`"))
35
+ (line-value (aref p "line"))
36
+ (line (js* "`${line_value}`"))
37
+ (column-value (aref p "column"))
38
+ (column (js* "`${column_value}`"))
39
+ (message-value (aref diagnostic "message"))
40
+ (message (js* "`${message_value}`")))
41
+ (+ file ":" line ":" column ": " message)))))
42
+ (put error :eliscriptDiagnostic diagnostic)
43
+ (throw error))))
30
44
  (defun compiler-fail (context span code phase message)
31
45
  (let ((file (or (get context :filename)
32
46
  (and span (get span :filename))
@@ -93,7 +107,7 @@
93
107
  (t undefined)))
94
108
 
95
109
  (defun binding-marker-p (name)
96
- (js-call (js-array "&optional" "&rest" "&body") :includes name))
110
+ (or (= name "&optional") (= name "&rest") (= name "&body")))
97
111
 
98
112
  (defun split-binding-name (name)
99
113
  (let ((slash (js-call name :lastIndexOf "/")))
@@ -107,7 +121,7 @@
107
121
  (when (keyword-node-p node)
108
122
  (let* ((parts (split-binding-name (node-name node)))
109
123
  (kind (get parts :local)))
110
- (when (js-call (js-array "keys" "strs" "syms") :includes kind)
124
+ (when (or (= kind "keys") (= kind "strs") (= kind "syms"))
111
125
  (js-object :kind kind :namespace (get parts :namespace))))))
112
126
 
113
127
  (defun shortcut-entry (shortcut name-node)
@@ -384,29 +398,43 @@
384
398
  (defun make-scope (parent &optional function-context)
385
399
  (js-object
386
400
  :parent parent
387
- :names (new (js* "Map"))
388
- :outputs (new (js* "Map"))
389
- :functionContext function-context))
401
+ :names nil
402
+ :outputs nil
403
+ :bindingEpoch (if parent (get parent :bindingEpoch) (js-object :value 0))
404
+ :lookupCache undefined
405
+ :lookupEpoch -1
406
+ :functionContext (or function-context (and parent (get parent :functionContext)))))
390
407
 
391
408
  (defun async-function-p (scope)
392
- (let ((current scope)
393
- (function-context nil))
394
- (while (and current (not function-context))
395
- (setq function-context (get current :functionContext))
396
- (setq current (get current :parent)))
397
- (= function-context "async")))
409
+ (= (get scope :functionContext) "async"))
398
410
 
399
411
  (defun guarded-binding-name (name context span)
400
- (funcall
401
- guard
402
- (lambda () (binding-name name))
403
- (lambda (message) (analyzer-fail context span message))))
412
+ (let* ((cache (get context :bindingNames))
413
+ (cached (and cache (js-call cache :get name))))
414
+ (if cached cached
415
+ (let ((result (try (binding-name name)
416
+ (catch error
417
+ (analyzer-fail context span (get error :message))))))
418
+ (when (= (js* "typeof name") "string")
419
+ (unless cache
420
+ (setq cache (new (js* "Map")))
421
+ (put context :bindingNames cache))
422
+ (js-call cache :set name result))
423
+ result))))
404
424
 
405
425
  (defun guarded-reference-name (name context span)
406
- (funcall
407
- guard
408
- (lambda () (reference-name name))
409
- (lambda (message) (analyzer-fail context span message))))
426
+ (let* ((cache (get context :referenceNames))
427
+ (cached (and cache (js-call cache :get name))))
428
+ (if cached cached
429
+ (let ((result (try (reference-name name)
430
+ (catch error
431
+ (analyzer-fail context span (get error :message))))))
432
+ (when (= (js* "typeof name") "string")
433
+ (unless cache
434
+ (setq cache (new (js* "Map")))
435
+ (put context :referenceNames cache))
436
+ (js-call cache :set name result))
437
+ result))))
410
438
 
411
439
  (defun declare-binding (scope name-node kind mutable context)
412
440
  (unless (symbol-node-p name-node)
@@ -418,8 +446,8 @@
418
446
  (names (get scope :names))
419
447
  (outputs (get scope :outputs))
420
448
  (output-name (guarded-binding-name name context span))
421
- (existing-name (js-call names :get name))
422
- (existing-output (js-call outputs :get output-name)))
449
+ (existing-name (and names (js-call names :get name)))
450
+ (existing-output (and outputs (js-call outputs :get output-name))))
423
451
  (when existing-name
424
452
  (analyzer-fail
425
453
  context span (str "duplicate " kind " binding: " name)))
@@ -434,22 +462,53 @@
434
462
  :outputName output-name
435
463
  :kind kind
436
464
  :mutable mutable)))
465
+ (unless names
466
+ (setq names (new (js* "Map")))
467
+ (put scope :names names)
468
+ (setq outputs (new (js* "Map")))
469
+ (put scope :outputs outputs))
437
470
  (js-call names :set name binding)
438
471
  (js-call outputs :set output-name binding)
472
+ ;; A later let* binding may shadow a previously resolved ancestor.
473
+ ;; One private epoch invalidates inherited resolutions throughout
474
+ ;; this module without retaining syntax nodes or completed contexts.
475
+ (let ((epoch (get scope :bindingEpoch)))
476
+ (put epoch :value (1+ (get epoch :value))))
439
477
  binding)))
440
478
 
441
479
  (defun declare-pattern (scope pattern kind mutable context)
442
- (js-call (binding-nodes pattern context) :forEach
443
- (lambda (binding)
444
- (declare-binding scope binding kind mutable context))))
480
+ (if (and (symbol-node-p pattern)
481
+ (not (binding-marker-p (node-name pattern))))
482
+ (declare-binding scope pattern kind mutable context)
483
+ (let ((bindings (binding-nodes pattern context))
484
+ (index 0))
485
+ (while (< index (get bindings :length))
486
+ (declare-binding scope (js-nth index bindings) kind mutable context)
487
+ (setq index (1+ index))))))
445
488
 
446
489
  (defun lookup-binding (scope name)
447
- (let ((current scope)
448
- (binding undefined))
449
- (while (and current (not binding))
450
- (setq binding (js-call (get current :names) :get name))
451
- (setq current (get current :parent)))
452
- binding))
490
+ (let* ((names (get scope :names))
491
+ (binding (and names (js-call names :get name)))
492
+ (current (get scope :parent)))
493
+ (if (or binding (not current)) binding
494
+ (let* ((epoch (get (get scope :bindingEpoch) :value))
495
+ (cache (get scope :lookupCache)))
496
+ (when (and cache (not (= epoch (get scope :lookupEpoch))))
497
+ (js-call cache :clear)
498
+ (put scope :lookupEpoch epoch))
499
+ (setq binding (and cache (js-call cache :get name)))
500
+ (unless binding
501
+ (while (and current (not binding))
502
+ (let ((parent-names (get current :names)))
503
+ (when parent-names (setq binding (js-call parent-names :get name))))
504
+ (setq current (get current :parent)))
505
+ (when binding
506
+ (unless cache
507
+ (setq cache (new (js* "Map")))
508
+ (put scope :lookupCache cache)
509
+ (put scope :lookupEpoch epoch))
510
+ (js-call cache :set name binding)))
511
+ binding))))
453
512
 
454
513
  (defun require-binding (scope node context)
455
514
  (let* ((name (node-name node))
@@ -465,18 +524,25 @@
465
524
  (defun analyze-sequence (forms scope context)
466
525
  (let ((tail-position (get context :tailPosition))
467
526
  (index 0))
527
+ ;; Non-tail sequences dominate ordinary calls. Their context already
528
+ ;; has the required value; repeatedly writing it builds needless
529
+ ;; managed property-update state for every operand.
530
+ (when (and tail-position (> (get forms :length) 1))
531
+ (put context :tailPosition false))
468
532
  (while (< index (get forms :length))
469
- (put context :tailPosition
470
- (and tail-position (= index (1- (get forms :length)))))
533
+ (when (and tail-position (= index (1- (get forms :length))))
534
+ (put context :tailPosition tail-position))
471
535
  (analyze-expression (js-nth index forms) scope context)
472
- (setq index (1+ index)))
473
- (put context :tailPosition tail-position)))
536
+ (setq index (1+ index)))))
474
537
 
475
538
  (defun analyze-non-tail (form scope context)
476
539
  (let ((tail-position (get context :tailPosition)))
477
- (put context :tailPosition false)
478
- (analyze-expression form scope context)
479
- (put context :tailPosition tail-position)))
540
+ (if tail-position
541
+ (progn
542
+ (put context :tailPosition false)
543
+ (analyze-expression form scope context)
544
+ (put context :tailPosition tail-position))
545
+ (analyze-expression form scope context))))
480
546
 
481
547
  (defun analyze-pattern-defaults (pattern scope context)
482
548
  (cond
@@ -498,14 +564,17 @@
498
564
 
499
565
  (defun analyze-non-tail-sequence (forms scope context)
500
566
  (let ((tail-position (get context :tailPosition)))
501
- (put context :tailPosition false)
502
- (analyze-sequence forms scope context)
503
- (put context :tailPosition tail-position)))
567
+ (if tail-position
568
+ (progn
569
+ (put context :tailPosition false)
570
+ (analyze-sequence forms scope context)
571
+ (put context :tailPosition tail-position))
572
+ (analyze-sequence forms scope context))))
504
573
 
505
574
  (defun binding-pair (binding context)
506
575
  (cond
507
576
  ((binding-pattern-p binding)
508
- (binding-nodes binding context)
577
+ (unless (symbol-node-p binding) (binding-nodes binding context))
509
578
  (js-array binding undefined))
510
579
  (t
511
580
  (let ((items (list-items binding)))
@@ -514,7 +583,8 @@
514
583
  (<= (get items :length) 2)
515
584
  (binding-pattern-p (js-nth 0 items)))
516
585
  (progn
517
- (binding-nodes (js-nth 0 items) context)
586
+ (unless (symbol-node-p (js-nth 0 items))
587
+ (binding-nodes (js-nth 0 items) context))
518
588
  (js-array (js-nth 0 items) (js-nth 1 items)))
519
589
  (analyzer-fail
520
590
  context (node-span binding)
@@ -528,45 +598,56 @@
528
598
  (let* ((bindings-form (js-nth 0 args))
529
599
  (bindings (list-items bindings-form))
530
600
  (body (js-call args :slice 1))
531
- (child (make-scope scope)))
601
+ (child (make-scope scope))
602
+ (index 0))
532
603
  (when (eq bindings undefined)
533
604
  (analyzer-fail
534
605
  context (node-span bindings-form) "let bindings must be a list"))
535
606
  (if sequential
536
- (js-call bindings :forEach
537
- (lambda (binding)
538
- (let ((pair (binding-pair binding context)))
607
+ (while (< index (get bindings :length))
608
+ (let ((pair (binding-pair (js-nth index bindings) context)))
539
609
  (analyze-non-tail (js-nth 1 pair) child context)
540
610
  (analyze-pattern-defaults (js-nth 0 pair) child context)
541
611
  (declare-pattern
542
- child (js-nth 0 pair) "local" t context))))
543
- (let ((parsed
544
- (js-call bindings :map
545
- (lambda (binding) (binding-pair binding context)))))
546
- (js-call parsed :forEach
547
- (lambda (pair)
612
+ child (js-nth 0 pair) "local" t context))
613
+ (setq index (1+ index)))
614
+ (let ((parsed (js-array)))
615
+ ;; Validate every parallel binding before analyzing any initializer.
616
+ (while (< index (get bindings :length))
617
+ (js-call parsed :push (binding-pair (js-nth index bindings) context))
618
+ (setq index (1+ index)))
619
+ (setq index 0)
620
+ (while (< index (get parsed :length))
621
+ (let ((pair (js-nth index parsed)))
548
622
  (analyze-non-tail (js-nth 1 pair) scope context)
549
- (analyze-pattern-defaults (js-nth 0 pair) scope context)))
550
- (js-call parsed :forEach
551
- (lambda (pair)
623
+ (analyze-pattern-defaults (js-nth 0 pair) scope context))
624
+ (setq index (1+ index)))
625
+ (setq index 0)
626
+ (while (< index (get parsed :length))
627
+ (let ((pair (js-nth index parsed)))
552
628
  (declare-pattern
553
- child (js-nth 0 pair) "local" t context)))))
629
+ child (js-nth 0 pair) "local" t context))
630
+ (setq index (1+ index)))))
554
631
  (analyze-sequence body child context)))
555
632
 
556
633
  (defun analyze-function
557
634
  (parameters body scope context &optional asynchronous)
558
- (let ((parameter-items (function-parameters parameters context)))
559
- (js-call parameter-items :forEach
560
- (lambda (parameter)
561
- (analyze-pattern-defaults (get parameter :node) scope context)))
635
+ (let ((parameter-items (function-parameters parameters context))
636
+ (index 0))
637
+ (while (< index (get parameter-items :length))
638
+ (analyze-pattern-defaults (get (js-nth index parameter-items) :node) scope context)
639
+ (setq index (1+ index)))
562
640
  (let ((child (make-scope
563
641
  scope (if asynchronous "async" "sync"))))
564
- (js-call parameter-items :forEach
565
- (lambda (parameter)
566
- (js-call (get parameter :bindings) :forEach
567
- (lambda (binding)
642
+ (setq index 0)
643
+ (while (< index (get parameter-items :length))
644
+ (let ((bindings (get (js-nth index parameter-items) :bindings))
645
+ (binding-index 0))
646
+ (while (< binding-index (get bindings :length))
568
647
  (declare-binding
569
- child binding "parameter" t context)))))
648
+ child (js-nth binding-index bindings) "parameter" t context)
649
+ (setq binding-index (1+ binding-index))))
650
+ (setq index (1+ index)))
570
651
  (let ((recur-targets (get context :recurTargets))
571
652
  (tail-position (get context :tailPosition))
572
653
  (recur-barrier (get context :recurBarrier)))
@@ -830,7 +911,12 @@
830
911
  (<= (get args :length) 3))
831
912
  (analyzer-fail context form-span "if expects 2..3 arguments"))
832
913
  (analyze-non-tail (js-nth 0 args) scope context)
833
- (analyze-sequence (js-call args :slice 1) scope context))
914
+ ;; These are alternatives, not successive body forms. Each branch
915
+ ;; inherits the conditional's tail position, including the first.
916
+ (let ((index 1))
917
+ (while (< index (get args :length))
918
+ (analyze-expression (js-nth index args) scope context)
919
+ (setq index (1+ index)))))
834
920
  ((or (= operator "when") (= operator "unless"))
835
921
  (when (= (get args :length) 0)
836
922
  (analyzer-fail
@@ -859,11 +945,7 @@
859
945
  ((= operator "js*") nil)
860
946
  ((js-call builtin-operators :includes operator)
861
947
  (analyze-non-tail-sequence args scope context))
862
- ((js-call
863
- (js-array "defun" "defn" "defportable" "defasync"
864
- "defvar" "defconst"
865
- "export" "export-default" "import" "import-portable" "module")
866
- :includes operator)
948
+ ((js-call top-level-operators :includes operator)
867
949
  (analyzer-fail
868
950
  context form-span
869
951
  (str operator " is only valid at module top level")))
@@ -1014,7 +1096,9 @@
1014
1096
  context (node-span form)
1015
1097
  (str operator " expects 2+ arguments")))
1016
1098
  (declare-binding
1017
- scope (js-nth 0 args) "function" false context))))))))
1099
+ scope (js-nth 0 args) "function" false context)
1100
+ (when (= operator "defportable")
1101
+ (put context :hasPortable t)))))))))
1018
1102
 
1019
1103
  (defun analyze-top-level (form scope context)
1020
1104
  (if (not (= (node-kind form) "list"))
@@ -1420,7 +1504,11 @@
1420
1504
  (js-call flattened :forEach
1421
1505
  (lambda (form) (analyze-top-level form scope context)))
1422
1506
  (analyze-transients forms filename)
1423
- (validate-portable-module flattened context)
1507
+ ;; With no portable entry the dependency worklist is empty. All normal
1508
+ ;; declarations/imports were already checked above; do not construct a
1509
+ ;; second Map and copy every function body just to visit no entry.
1510
+ (when (get context :hasPortable false)
1511
+ (validate-portable-module flattened context))
1424
1512
  forms))
1425
1513
 
1426
1514
  (export analyze-module select-portable-module))
@@ -6,9 +6,10 @@
6
6
  formatter-width
7
7
  formatter-indent
8
8
  format-source)
9
- (import "./expander.mjs" expand-module)
9
+ (import "./expander.mjs" expand-module expand-module-with-origins
10
+ expand-owned-module expand-owned-module-with-origins)
10
11
  (import "./analyzer.mjs" analyze-module select-portable-module)
11
- (import "./lower.mjs" lower-module)
12
+ (import "./lower.mjs" lower-module lower-owned-module)
12
13
  (import "./ir.mjs" ir-format ir-version serialize-program deserialize-program)
13
14
  (import "./emitter.mjs" emit-module emit-module-with-source-map)
14
15
  (import "./project.mjs"
@@ -53,23 +54,39 @@
53
54
  (defconst evaluation-module-heads
54
55
  (js-array "export" "export-default" "import" "import-portable" "module"))
55
56
  (defconst evaluation-fail
56
- (js*
57
- "(message, filename) => { const error = new Error(message); error.eliscriptDiagnostic = { format: 'eliscript-diagnostic', version: 1, code: 'ELI-E0001', severity: 'error', phase: 'evaluation-request', message, ...(filename ? { location: { file: filename } } : {}) }; throw error; }"))
57
+ (lambda (message filename)
58
+ (let* ((error (new (js* "Error") message))
59
+ (diagnostic (js-object :format "eliscript-diagnostic" :version 1
60
+ :code "ELI-E0001" :severity "error" :phase "evaluation-request" :message message)))
61
+ (when (js* "!!filename")
62
+ (put diagnostic :location (js-object :file filename)))
63
+ (put error :eliscriptDiagnostic diagnostic)
64
+ (throw error))))
58
65
  (defconst evaluation-object-p
59
- (js*
60
- "(value) => value !== null && typeof value === 'object' && !Array.isArray(value)"))
66
+ (lambda (value)
67
+ (and (not (nil? value)) (= (js* "typeof value") "object") (not (Array/isArray value)))))
61
68
  (defconst evaluation-id-p
62
- (js*
63
- "(value) => value === null || (typeof value === 'string' && value.length > 0) || (Number.isSafeInteger(value) && value >= 0)"))
69
+ (lambda (value)
70
+ (or (nil? value) (and (= (js* "typeof value") "string") (> (js-length value) 0))
71
+ (and (Number/isSafeInteger value) (>= value 0)))))
64
72
  (defconst evaluation-positive-integer-p
65
- (js* "(value) => Number.isSafeInteger(value) && value >= 1"))
73
+ (lambda (value)
74
+ (and (Number/isSafeInteger value) (>= value 1))))
66
75
  (defun compile-ir-string
67
76
  (source filename &optional macro-context)
68
77
  (let*
69
78
  ((read-forms (read-string source filename))
70
- (expanded-forms (expand-module read-forms filename macro-context)))
79
+ (expanded-forms (expand-owned-module read-forms filename macro-context)))
80
+ ;; Expansion keeps any shared leaves it needs. Release the separate
81
+ ;; reader tree before analysis and lowering allocate their output.
82
+ (setq read-forms nil)
71
83
  (analyze-module expanded-forms filename)
72
- (lower-module expanded-forms filename)))
84
+ (lower-owned-module expanded-forms filename)))
85
+ (defun compile-ir-string-with-origins (source filename &optional macro-context)
86
+ (let* ((expansion (expand-owned-module-with-origins (read-string source filename) filename macro-context))
87
+ (forms (get expansion :forms)))
88
+ (analyze-module forms filename)
89
+ (js-object :program (lower-owned-module forms filename) :macroOrigins (get expansion :macroOrigins))))
73
90
  (defun evaluation-object-field
74
91
  (value key fallback)
75
92
  (if (js-call globalThis.Object :hasOwn value key) (get value key) fallback))
@@ -132,7 +149,7 @@
132
149
  (unless (js-call evaluation-operation-keys :includes key)
133
150
  (funcall evaluation-fail (str "unknown evaluation operation key: " key) false))))
134
151
  (let*
135
- ((id (evaluation-object-field input "id" (js* "null")))
152
+ ((id (evaluation-object-field input "id" nil))
136
153
  (operation (get input :operation)))
137
154
  (unless (funcall evaluation-id-p id)
138
155
  (funcall
@@ -149,7 +166,7 @@
149
166
  (let*
150
167
  ((filename (evaluation-require-filename (get input :filename)))
151
168
  (source (evaluation-require-source (get input :source) filename))
152
- (root (evaluation-object-field input "root" (js* "null")))
169
+ (root (evaluation-object-field input "root" nil))
153
170
  (line (evaluation-object-field input "line" 1))
154
171
  (column (evaluation-object-field input "column" 1)))
155
172
  (unless
@@ -264,9 +281,9 @@
264
281
  :kind
265
282
  (cond (definition "definition") (module-form "module") (t "expression"))
266
283
  :head
267
- (or head (js* "null"))
284
+ (or head nil)
268
285
  :name
269
- (or name (js* "null"))
286
+ (or name nil)
270
287
  :runtimeBinding
271
288
  (and definition (not (= head "defmacro")))
272
289
  :filename
@@ -382,16 +399,22 @@
382
399
  (source entries filename &optional macro-context)
383
400
  (let*
384
401
  ((read-forms (read-string source filename))
385
- (expanded-forms (expand-module read-forms filename macro-context)))
402
+ (expanded-forms (expand-owned-module read-forms filename macro-context)))
403
+ (setq read-forms nil)
386
404
  (analyze-module expanded-forms filename)
387
- (lower-module (select-portable-module expanded-forms entries filename) filename)))
405
+ (let ((selected (select-portable-module expanded-forms entries filename)))
406
+ (setq expanded-forms nil)
407
+ (lower-owned-module selected filename))))
388
408
  (defun compile-project-portable-ir-string
389
409
  (source entries filename &optional macro-context)
390
410
  (let*
391
411
  ((read-forms (read-string source filename))
392
- (expanded-forms (expand-module read-forms filename macro-context)))
412
+ (expanded-forms (expand-owned-module read-forms filename macro-context)))
413
+ (setq read-forms nil)
393
414
  (analyze-module expanded-forms filename)
394
- (lower-module (select-portable-module expanded-forms entries filename t) filename)))
415
+ (let ((selected (select-portable-module expanded-forms entries filename t)))
416
+ (setq expanded-forms nil)
417
+ (lower-owned-module selected filename))))
395
418
  (defun emit-ir-string (program) (emit-module program))
396
419
  (defun serialize-ir-program (program) (serialize-program program))
397
420
  (defun deserialize-ir-program (source) (deserialize-program source))
@@ -417,6 +440,7 @@
417
440
  (or source-name filename "<string>")))
418
441
  (export
419
442
  compile-ir-string
443
+ compile-ir-string-with-origins
420
444
  compile-project-portable-ir-string
421
445
  compile-string
422
446
  compile-portable-ir-string