eliscript 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/README.md +59 -0
  2. package/bootstrap/README.md +26 -0
  3. package/bootstrap/backends/README.md +515 -0
  4. package/bootstrap/backends/async.eli +230 -0
  5. package/bootstrap/backends/binary.eli +173 -0
  6. package/bootstrap/backends/capabilities.eli +74 -0
  7. package/bootstrap/backends/elf.eli +246 -0
  8. package/bootstrap/backends/managed.eli +5976 -0
  9. package/bootstrap/backends/memory.eli +100 -0
  10. package/bootstrap/backends/native.eli +2000 -0
  11. package/bootstrap/backends/numeric.eli +1362 -0
  12. package/bootstrap/backends/optimize.eli +79 -0
  13. package/bootstrap/backends/regexp.eli +2263 -0
  14. package/bootstrap/backends/sha256.eli +138 -0
  15. package/bootstrap/backends/wasm.eli +1161 -0
  16. package/bootstrap/compiler/analyzer.eli +165 -77
  17. package/bootstrap/compiler/compiler.eli +43 -19
  18. package/bootstrap/compiler/emitter.eli +780 -170
  19. package/bootstrap/compiler/expander.eli +136 -45
  20. package/bootstrap/compiler/formatter.eli +8 -1
  21. package/bootstrap/compiler/ir.eli +148 -45
  22. package/bootstrap/compiler/lower.eli +29 -2
  23. package/bootstrap/compiler/project.eli +51 -21
  24. package/bootstrap/compiler/reader.eli +128 -36
  25. package/bootstrap/compiler/source-map.eli +46 -4
  26. package/bootstrap/compiler/symbol.eli +2 -1
  27. package/bootstrap/compiler/syntax.eli +47 -12
  28. package/bootstrap/compiler/transient-analysis.eli +40 -4
  29. package/bootstrap/host/check-cli-legacy.mjs +163 -0
  30. package/bootstrap/host/check-cli.mjs +59 -158
  31. package/bootstrap/host/check-cli.mjs.map +1 -0
  32. package/bootstrap/host/compiler-session.eli +1579 -0
  33. package/bootstrap/host/compiler-tools.eli +513 -0
  34. package/bootstrap/host/eliscript-cli-legacy.mjs +37 -0
  35. package/bootstrap/host/eliscript-cli.mjs +53 -33
  36. package/bootstrap/host/eliscript-cli.mjs.map +1 -0
  37. package/bootstrap/host/project-cli-legacy.mjs +295 -0
  38. package/bootstrap/host/project-cli.mjs +74 -289
  39. package/bootstrap/host/project-cli.mjs.map +1 -0
  40. package/bootstrap/host/project-legacy.mjs +1080 -0
  41. package/bootstrap/host/project.mjs +210 -1060
  42. package/bootstrap/host/project.mjs.map +1 -0
  43. package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
  44. package/bootstrap/runtime/memory.eli +30379 -0
  45. package/browser/host.mjs +89 -0
  46. package/compiler/eliscript-analyzer.el +371 -4
  47. package/compiler/eliscript-cli.el +84 -1
  48. package/compiler/eliscript-emitter.el +1189 -256
  49. package/compiler/eliscript-expander.el +147 -10
  50. package/compiler/eliscript-ir-emitter.el +725 -208
  51. package/compiler/eliscript-lower.el +127 -1
  52. package/compiler/eliscript-portable.el +177 -51
  53. package/compiler/eliscript-project.el +20 -2
  54. package/compiler/eliscript-reader.el +141 -57
  55. package/compiler/eliscript-source-map.el +26 -12
  56. package/compiler/eliscript-transient-analysis.el +382 -19
  57. package/dist/backends/async.mjs +561 -0
  58. package/dist/backends/async.mjs.macro-origins.json +1 -0
  59. package/dist/backends/async.mjs.map +1 -0
  60. package/dist/backends/binary.mjs +381 -0
  61. package/dist/backends/binary.mjs.macro-origins.json +1 -0
  62. package/dist/backends/binary.mjs.map +1 -0
  63. package/dist/backends/capabilities.mjs +237 -0
  64. package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
  65. package/dist/backends/capabilities.mjs.map +1 -0
  66. package/dist/backends/elf.mjs +540 -0
  67. package/dist/backends/elf.mjs.macro-origins.json +1 -0
  68. package/dist/backends/elf.mjs.map +1 -0
  69. package/dist/backends/managed.mjs +10616 -0
  70. package/dist/backends/managed.mjs.macro-origins.json +1 -0
  71. package/dist/backends/managed.mjs.map +1 -0
  72. package/dist/backends/memory.mjs +278 -0
  73. package/dist/backends/memory.mjs.macro-origins.json +1 -0
  74. package/dist/backends/memory.mjs.map +1 -0
  75. package/dist/backends/native.mjs +4099 -0
  76. package/dist/backends/native.mjs.macro-origins.json +1 -0
  77. package/dist/backends/native.mjs.map +1 -0
  78. package/dist/backends/numeric.mjs +2458 -0
  79. package/dist/backends/numeric.mjs.macro-origins.json +1 -0
  80. package/dist/backends/numeric.mjs.map +1 -0
  81. package/dist/backends/optimize.mjs +204 -0
  82. package/dist/backends/optimize.mjs.macro-origins.json +1 -0
  83. package/dist/backends/optimize.mjs.map +1 -0
  84. package/dist/backends/regexp.mjs +2033 -0
  85. package/dist/backends/regexp.mjs.macro-origins.json +1 -0
  86. package/dist/backends/regexp.mjs.map +1 -0
  87. package/dist/backends/sha256.mjs +310 -0
  88. package/dist/backends/sha256.mjs.macro-origins.json +1 -0
  89. package/dist/backends/sha256.mjs.map +1 -0
  90. package/dist/backends/wasm.mjs +2258 -0
  91. package/dist/backends/wasm.mjs.macro-origins.json +1 -0
  92. package/dist/backends/wasm.mjs.map +1 -0
  93. package/dist/bootstrap/analyzer.mjs +1908 -776
  94. package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
  95. package/dist/bootstrap/analyzer.mjs.map +1 -1
  96. package/dist/bootstrap/compiler.mjs +450 -142
  97. package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
  98. package/dist/bootstrap/compiler.mjs.map +1 -1
  99. package/dist/bootstrap/emitter.mjs +3083 -909
  100. package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
  101. package/dist/bootstrap/emitter.mjs.map +1 -1
  102. package/dist/bootstrap/expander.mjs +2887 -1233
  103. package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
  104. package/dist/bootstrap/expander.mjs.map +1 -1
  105. package/dist/bootstrap/formatter.mjs +582 -218
  106. package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
  107. package/dist/bootstrap/formatter.mjs.map +1 -1
  108. package/dist/bootstrap/ir.mjs +670 -116
  109. package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
  110. package/dist/bootstrap/ir.mjs.map +1 -1
  111. package/dist/bootstrap/lower.mjs +866 -257
  112. package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
  113. package/dist/bootstrap/lower.mjs.map +1 -1
  114. package/dist/bootstrap/package.json +1 -0
  115. package/dist/bootstrap/project.mjs +1168 -498
  116. package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
  117. package/dist/bootstrap/project.mjs.map +1 -1
  118. package/dist/bootstrap/reader.mjs +674 -175
  119. package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
  120. package/dist/bootstrap/reader.mjs.map +1 -1
  121. package/dist/bootstrap/runtime/math.mjs +1117 -0
  122. package/dist/bootstrap/runtime/math.mjs.map +1 -0
  123. package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
  124. package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
  125. package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
  126. package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
  127. package/dist/bootstrap/source-map.mjs +430 -119
  128. package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
  129. package/dist/bootstrap/source-map.mjs.map +1 -1
  130. package/dist/bootstrap/symbol.mjs +229 -53
  131. package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
  132. package/dist/bootstrap/symbol.mjs.map +1 -1
  133. package/dist/bootstrap/syntax.mjs +205 -7
  134. package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
  135. package/dist/bootstrap/syntax.mjs.map +1 -1
  136. package/dist/bootstrap/transient-analysis.mjs +1185 -489
  137. package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
  138. package/dist/bootstrap/transient-analysis.mjs.map +1 -1
  139. package/dist/browser/compiler.js +199 -6478
  140. package/dist/browser/host.mjs +446 -0
  141. package/dist/browser/loader.js +1 -0
  142. package/dist/browser/loader.mjs +231 -0
  143. package/dist/browser/worker.mjs +60 -0
  144. package/dist/compiler-artifact.json +1 -0
  145. package/dist/host/compiler-session.mjs +2980 -0
  146. package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
  147. package/dist/host/compiler-session.mjs.map +1 -0
  148. package/dist/host/compiler-tools.mjs +1084 -0
  149. package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
  150. package/dist/host/compiler-tools.mjs.map +1 -0
  151. package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
  152. package/dist/literal-sources/runtime/core/collection.eli +579 -0
  153. package/dist/literal-sources/runtime/core/data-text.eli +290 -0
  154. package/dist/literal-sources/runtime/core/data.eli +22 -0
  155. package/dist/literal-sources/runtime/core/identifier.eli +44 -0
  156. package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
  157. package/dist/literal-sources/runtime/core/list.eli +19 -0
  158. package/dist/literal-sources/runtime/core/map.eli +9 -0
  159. package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
  160. package/dist/literal-sources/runtime/core/metadata.eli +23 -0
  161. package/dist/literal-sources/runtime/core/object.eli +8 -0
  162. package/dist/literal-sources/runtime/core/order.eli +123 -0
  163. package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
  164. package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
  165. package/dist/literal-sources/runtime/core/protocol.eli +28 -0
  166. package/dist/literal-sources/runtime/core/queue.eli +9 -0
  167. package/dist/literal-sources/runtime/core/record.eli +191 -0
  168. package/dist/literal-sources/runtime/core/regex.eli +158 -0
  169. package/dist/literal-sources/runtime/core/sequence.eli +305 -0
  170. package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
  171. package/dist/literal-sources/runtime/core/set.eli +9 -0
  172. package/dist/literal-sources/runtime/core/sorted.eli +408 -0
  173. package/dist/literal-sources/runtime/core/text.eli +14 -0
  174. package/dist/literal-sources/runtime/core/transducer.eli +268 -0
  175. package/dist/literal-sources/runtime/core/transient.eli +17 -0
  176. package/dist/literal-sources/runtime/core/truth.eli +4 -0
  177. package/dist/literal-sources/runtime/core/type.eli +232 -0
  178. package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
  179. package/dist/literal-sources/runtime/core/value.eli +19 -0
  180. package/dist/literal-sources/runtime/core/vector.eli +20 -0
  181. package/dist/literal-sources/runtime/literals.eli +23 -0
  182. package/dist/literal-sources/runtime/testing/value.eli +6 -0
  183. package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
  184. package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
  185. package/dist/literal-sources/runtime/wire/schema.eli +193 -0
  186. package/dist/literal-sources/stdlib/bit.eli +36 -0
  187. package/dist/literal-sources/stdlib/core/data.eli +306 -0
  188. package/dist/literal-sources/stdlib/core/object.eli +89 -0
  189. package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
  190. package/dist/literal-sources/stdlib/core/set.eli +312 -0
  191. package/dist/literal-sources/stdlib/core/text.eli +103 -0
  192. package/dist/literal-sources/stdlib/managed-literal-protocols.eli +483 -0
  193. package/dist/literal-sources/stdlib/managed-literals.eli +1414 -0
  194. package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
  195. package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
  196. package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
  197. package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
  198. package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
  199. package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
  200. package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
  201. package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
  202. package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
  203. package/dist/literal-sources/stdlib/value.eli +325 -0
  204. package/dist/package.json +10 -0
  205. package/dist/runtime/math.mjs +1116 -0
  206. package/dist/runtime/math.mjs.macro-origins.json +1 -0
  207. package/dist/runtime/math.mjs.map +1 -0
  208. package/dist/runtime/unicode-case-data.mjs +10124 -0
  209. package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
  210. package/dist/runtime/unicode-case-data.mjs.map +1 -0
  211. package/dist/runtime/unicode-case.mjs +280 -0
  212. package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
  213. package/dist/runtime/unicode-case.mjs.map +1 -0
  214. package/dist/runtime.eli +30379 -0
  215. package/dist/stage3-release.json +1 -0
  216. package/editor/README.md +1 -1
  217. package/editor/eliscript-mode.el +1 -1
  218. package/editor/eliscript-repl.el +1 -1
  219. package/package.json +97 -10
  220. package/platform/http.mjs +20 -0
  221. package/runtime/array-text.mjs +159 -0
  222. package/runtime/core/map-internals.mjs +27 -9
  223. package/runtime/core/object-impl.mjs +26 -17
  224. package/runtime/core/object-impl.mjs.map +1 -1
  225. package/runtime/core/protocol-impl.mjs +682 -255
  226. package/runtime/core/protocol-impl.mjs.map +1 -1
  227. package/runtime/core/protocol.mjs +4 -0
  228. package/runtime/core/record.mjs +23 -2
  229. package/runtime/core/regex.mjs +4 -0
  230. package/runtime/core/sorted.mjs +53 -0
  231. package/runtime/core/text-impl.mjs +167 -48
  232. package/runtime/core/text-impl.mjs.map +1 -1
  233. package/runtime/core/type.mjs +75 -3
  234. package/runtime/core/vector.mjs +6 -0
  235. package/runtime/math.eli +429 -0
  236. package/runtime/math.mjs +1116 -0
  237. package/runtime/math.mjs.map +1 -0
  238. package/runtime/number-radix.mjs +105 -0
  239. package/runtime/unicode-case-data.eli +29 -0
  240. package/runtime/unicode-case-data.mjs +10124 -0
  241. package/runtime/unicode-case-data.mjs.map +1 -0
  242. package/runtime/unicode-case.eli +100 -0
  243. package/runtime/unicode-case.mjs +280 -0
  244. package/runtime/unicode-case.mjs.map +1 -0
  245. package/runtime/wire/http-rpc.mjs +168 -0
  246. package/runtime/wire/markdown.mjs +196 -0
  247. package/runtime/wire/schema.mjs +109 -0
  248. package/stdlib/README.md +54 -0
  249. package/stdlib/core/protocol.eli +81 -17
  250. package/stdlib/core/seq.eli +1 -1
  251. package/stdlib/core/zipper.eli +114 -47
  252. package/stdlib/gepo.eli +12 -0
  253. package/stdlib/interop/js.eli +56 -15
  254. package/stdlib/managed-literal-protocols.eli +483 -0
  255. package/stdlib/managed-literals.eli +1414 -0
  256. package/stdlib/managed-protocol-error.eli +32 -0
  257. package/stdlib/managed-queue-state.eli +65 -0
  258. package/stdlib/managed-runtime-collection-internals.eli +60 -0
  259. package/stdlib/managed-runtime-collection.eli +579 -0
  260. package/stdlib/managed-runtime-data-text.eli +290 -0
  261. package/stdlib/managed-runtime-data.eli +22 -0
  262. package/stdlib/managed-runtime-identifier.eli +44 -0
  263. package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
  264. package/stdlib/managed-runtime-list.eli +19 -0
  265. package/stdlib/managed-runtime-literals.eli +23 -0
  266. package/stdlib/managed-runtime-map.eli +9 -0
  267. package/stdlib/managed-runtime-metadata-internals.eli +6 -0
  268. package/stdlib/managed-runtime-metadata.eli +23 -0
  269. package/stdlib/managed-runtime-object.eli +8 -0
  270. package/stdlib/managed-runtime-order.eli +123 -0
  271. package/stdlib/managed-runtime-persistent-kind.eli +28 -0
  272. package/stdlib/managed-runtime-protocol.eli +28 -0
  273. package/stdlib/managed-runtime-queue.eli +9 -0
  274. package/stdlib/managed-runtime-record.eli +191 -0
  275. package/stdlib/managed-runtime-regex.eli +158 -0
  276. package/stdlib/managed-runtime-sequence.eli +305 -0
  277. package/stdlib/managed-runtime-set-algebra.eli +28 -0
  278. package/stdlib/managed-runtime-set.eli +9 -0
  279. package/stdlib/managed-runtime-sorted.eli +408 -0
  280. package/stdlib/managed-runtime-text.eli +14 -0
  281. package/stdlib/managed-runtime-transducer.eli +268 -0
  282. package/stdlib/managed-runtime-transient.eli +17 -0
  283. package/stdlib/managed-runtime-truth.eli +4 -0
  284. package/stdlib/managed-runtime-type.eli +232 -0
  285. package/stdlib/managed-runtime-value-internals.eli +13 -0
  286. package/stdlib/managed-runtime-value.eli +19 -0
  287. package/stdlib/managed-runtime-vector.eli +20 -0
  288. package/stdlib/managed-sorted-state.eli +233 -0
  289. package/stdlib/managed-testing-value.eli +6 -0
  290. package/stdlib/managed-transient-state.eli +348 -0
  291. package/stdlib/managed-value-state.eli +153 -0
  292. package/stdlib/managed-vector-view-state.eli +102 -0
  293. package/stdlib/managed-wire-http-rpc.eli +362 -0
  294. package/stdlib/managed-wire-markdown.eli +275 -0
  295. package/stdlib/managed-wire-schema.eli +193 -0
  296. package/stdlib/mdp.eli +7 -0
  297. package/stdlib/mds.eli +4 -0
  298. package/stdlib/persistent-vector.eli +23 -6
  299. package/tools/acceptance/check-legacy.mjs +687 -0
  300. package/tools/acceptance/check.eli +431 -0
  301. package/tools/acceptance/compile-evidence.el +49 -0
  302. package/tools/acceptance/finalize-legacy.mjs +498 -0
  303. package/tools/acceptance/finalize.eli +270 -0
  304. package/tools/backends/benchmark.mjs +175 -0
  305. package/tools/backends/build.mjs +135 -0
  306. package/tools/backends/compile.mjs +94 -0
  307. package/tools/backends/compiler-bootstrap.mjs +1001 -0
  308. package/tools/backends/compiler-browser.mjs +361 -0
  309. package/tools/backends/compiler-build.mjs +1628 -0
  310. package/tools/backends/compiler-cli-legacy.mjs +334 -0
  311. package/tools/backends/compiler-cli.mjs +29 -0
  312. package/tools/backends/compiler-corpus-bit.mjs +234 -0
  313. package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
  314. package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
  315. package/tools/backends/compiler-corpus-debugging.mjs +221 -0
  316. package/tools/backends/compiler-corpus-emitter.mjs +324 -0
  317. package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
  318. package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
  319. package/tools/backends/compiler-corpus-execution.mjs +3324 -0
  320. package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
  321. package/tools/backends/compiler-corpus-generations.mjs +208 -0
  322. package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
  323. package/tools/backends/compiler-corpus-host-context.mjs +550 -0
  324. package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
  325. package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
  326. package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
  327. package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
  328. package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
  329. package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
  330. package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
  331. package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
  332. package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
  333. package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
  334. package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
  335. package/tools/backends/compiler-corpus-matchers.mjs +173 -0
  336. package/tools/backends/compiler-corpus-original-program.mjs +612 -0
  337. package/tools/backends/compiler-corpus-process.mjs +765 -0
  338. package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
  339. package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
  340. package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
  341. package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
  342. package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
  343. package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
  344. package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
  345. package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
  346. package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
  347. package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
  348. package/tools/backends/compiler-corpus-reference.mjs +241 -0
  349. package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
  350. package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
  351. package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
  352. package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
  353. package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
  354. package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
  355. package/tools/backends/compiler-corpus.mjs +2054 -0
  356. package/tools/backends/compiler-debug.mjs +142 -0
  357. package/tools/backends/compiler-matrix.mjs +1955 -0
  358. package/tools/backends/compiler-metadata.mjs +203 -0
  359. package/tools/backends/compiler-package-browser.mjs +120 -0
  360. package/tools/backends/compiler-package-legacy.mjs +654 -0
  361. package/tools/backends/compiler-package.mjs +464 -0
  362. package/tools/backends/compiler-project.mjs +126 -0
  363. package/tools/backends/compiler-session.mjs +843 -0
  364. package/tools/backends/compiler-sha256.mjs +152 -0
  365. package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
  366. package/tools/backends/compiler-worker.mjs +573 -0
  367. package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
  368. package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
  369. package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
  370. package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
  371. package/tools/backends/dist/record-grid.mjs +1256 -0
  372. package/tools/backends/dist/record-grid.mjs.map +1 -0
  373. package/tools/backends/dist/release-cli.mjs +460 -0
  374. package/tools/backends/dist/release-cli.mjs.map +1 -0
  375. package/tools/backends/dist/run-artifact.mjs +517 -0
  376. package/tools/backends/dist/run-artifact.mjs.map +1 -0
  377. package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
  378. package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
  379. package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
  380. package/tools/backends/managed-foreign-binding.mjs +497 -0
  381. package/tools/backends/managed-host-legacy.mjs +1181 -0
  382. package/tools/backends/managed-host-lifecycle.mjs +310 -0
  383. package/tools/backends/managed-host-object-provider.mjs +155 -0
  384. package/tools/backends/managed-host-object-realm.mjs +797 -0
  385. package/tools/backends/managed-host-proxy.mjs +71 -0
  386. package/tools/backends/managed-host-runtime.mjs +5868 -0
  387. package/tools/backends/managed-host.mjs +716 -0
  388. package/tools/backends/managed-module-graph-legacy.mjs +308 -0
  389. package/tools/backends/managed-module-graph.mjs +694 -0
  390. package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
  391. package/tools/backends/managed-runtime.mjs +939 -0
  392. package/tools/backends/managed-source-view-legacy.mjs +332 -0
  393. package/tools/backends/managed-source-view.mjs +959 -0
  394. package/tools/backends/memory-runtime.mjs +100 -0
  395. package/tools/backends/native-benchmark.mjs +88 -0
  396. package/tools/backends/native-managed-runtime.mjs +677 -0
  397. package/tools/backends/native-memory.mjs +768 -0
  398. package/tools/backends/native-node-memory.mjs +142 -0
  399. package/tools/backends/native-node-runner.mjs +99 -0
  400. package/tools/backends/native-node-watchdog.mjs +19 -0
  401. package/tools/backends/native-node-worker.mjs +75 -0
  402. package/tools/backends/stage3-targets.mjs +486 -0
  403. package/tools/bootstrap-command.el +13 -0
  404. package/tools/bootstrap-runtime.el +101 -0
  405. package/tools/bootstrap-seed.el +55 -0
  406. package/tools/project/check-cli.eli +31 -0
  407. package/tools/project/project-cli.eli +42 -0
  408. package/tools/project/project.eli +122 -0
  409. package/tools/runtime/unicode-case-profiles.mjs +13 -0
  410. package/tools/runtime/unicode-case-runtime.el +57 -0
  411. package/tools/testing/source-debugging-corpus-host.eli +16 -0
  412. package/tools/testing/source-debugging.eli +139 -0
  413. package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
  414. package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
  415. package/tools/testing/stdlib-bit.eli +104 -0
  416. package/tools/testing/stdlib-bit.mjs +255 -0
  417. package/bin/eliscript-bootstrap +0 -15
@@ -0,0 +1,513 @@
1
+ (module bootstrap.host.compiler-tools
2
+ (import "../bootstrap/reader.mjs" read-string)
3
+ (import "../bootstrap/expander.mjs" expand-module-with-origins)
4
+ (import "../bootstrap/analyzer.mjs" analyze-module)
5
+ (import "../bootstrap/lower.mjs" lower-module)
6
+ (import "../backends/sha256.mjs" sha256-string-utf16le)
7
+
8
+ (defun tools-fail (message filename &optional code)
9
+ (let ((error (new (js* "Error") message)))
10
+ (put error :eliscriptDiagnostic
11
+ (js-object :format "eliscript-diagnostic" :version 1 :code (or code "ELI-T0001")
12
+ :severity "error" :phase "compiler-tools" :message message
13
+ :location (js-object :file filename)))
14
+ (throw error)))
15
+
16
+ (defun tools-span-key (span)
17
+ (when span (str (get span :start) ":" (get span :end))))
18
+
19
+ (defun tools-syntax-index (node context)
20
+ (let ((span (get node :span nil)) (kind (get node :kind nil)))
21
+ (when span
22
+ (js-call (get context :syntax) :set (tools-span-key span) node))
23
+ (when (or (= kind "list") (= kind "vector"))
24
+ (js-call (get node :items) :forEach
25
+ (lambda (child) (tools-syntax-index child context))))))
26
+
27
+ (defun tools-symbol-span (node name context)
28
+ (let* ((span (get node :span nil))
29
+ (original (and span (js-call (get context :syntax) :get (tools-span-key span))))
30
+ (kind (get node :kind nil)))
31
+ (when original
32
+ (cond
33
+ ((and (= (get original :kind) "symbol") (= (get original :name) name))
34
+ (get original :span))
35
+ ((and (= kind "binding-name") (= (get original :kind) "symbol"))
36
+ ;; Qualified map shortcuts bind only their final local name. The
37
+ ;; reader span is the whole qualified symbol; retain its actual
38
+ ;; suffix rather than labelling this source binding as generated.
39
+ (let* ((qualified (get original :name)) (slash (js-call qualified :lastIndexOf "/")))
40
+ (when (and (>= slash 0) (= (js-call qualified :slice (1+ slash)) name))
41
+ (let* ((prefix (tools-scalar-length (js-call qualified :slice 0 (1+ slash))))
42
+ (original-span (get original :span)))
43
+ (js-call globalThis.Object :assign (js-object) original-span
44
+ (js-object :start (+ (get original-span :start) prefix)
45
+ :column (+ (get original-span :column) prefix)))))))
46
+ ((= (get original :kind) "list")
47
+ (let* ((items (get original :items))
48
+ (head (js-nth 0 items))
49
+ (operator (and head (get head :name nil)))
50
+ (declaration (or
51
+ (and (= kind "function-declaration")
52
+ (js-call (js-array "defun" "defn" "defportable" "defasync") :includes operator))
53
+ (and (= kind "variable-declaration")
54
+ (or (= operator "defconst") (= operator "defvar")))))
55
+ (candidate (if declaration (js-nth 1 items)
56
+ (if (= kind "lexical-binding") head nil))))
57
+ (when (and candidate (= (get candidate :kind) "symbol")
58
+ (= (get candidate :name) name))
59
+ (get candidate :span))))))))
60
+
61
+ (defun tools-origin (span context)
62
+ (let ((result nil))
63
+ (when span
64
+ (js-call (get context :macroOrigins) :forEach
65
+ (lambda (origin)
66
+ (when (= (tools-span-key span) (tools-span-key (get origin :span)))
67
+ (setq result origin)))))
68
+ (let ((trace (js-array)))
69
+ (when span
70
+ (js-call (get context :macroExpansions) :forEach
71
+ (lambda (event)
72
+ (when (= (tools-span-key span) (tools-span-key (get event :callSpan)))
73
+ (js-call trace :push event)))))
74
+ (when (> (js-length trace) 0)
75
+ (let ((event (js-nth (1- (js-length trace)) trace)))
76
+ (setq result (js-call globalThis.Object :assign (js-object)
77
+ (or result (js-object))
78
+ (js-object :macroName (get event :macroName) :span (get event :callSpan)
79
+ :definitionSpan (get event :definitionSpan) :trace trace)))))
80
+ result)))
81
+
82
+ (defun tools-scope (parent)
83
+ (js-object :parent parent :names (new globalThis.Map)))
84
+
85
+ (defun tools-find (scope name)
86
+ (let ((current scope) (binding nil))
87
+ (while (and current (nullish? binding))
88
+ (setq binding (js-call (get current :names) :get name))
89
+ (setq current (get current :parent))) binding))
90
+
91
+ (defun tools-declare (node scope kind context)
92
+ (let* ((name (get node :value))
93
+ (span (tools-symbol-span node name context))
94
+ (definition (js-object
95
+ :id (str "binding-" (js-length (get context :definitions)))
96
+ :name name :kind kind :span span :expandedSpan (get node :span nil)
97
+ :generated (nil? span) :macroOrigin (tools-origin (get node :span nil) context))))
98
+ (js-call (get scope :names) :set name definition)
99
+ (js-call (get context :definitions) :push definition)
100
+ definition))
101
+
102
+ (defun tools-reference (node scope role context)
103
+ (let* ((name (get node :value))
104
+ (binding (tools-find scope name))
105
+ (span (tools-symbol-span node name context)))
106
+ (js-call (get context :references) :push
107
+ (js-object :name name :role role :span span :expandedSpan (get node :span nil)
108
+ :generated (nil? span) :bindingId (if binding (get binding :id) nil)
109
+ :definitionSpan (if binding (get binding :span) nil)
110
+ :macroOrigin (tools-origin (get node :span nil) context)))))
111
+
112
+ (defun tools-pattern-defaults (node scope context)
113
+ (let ((kind (get node :kind)) (children (get node :children)))
114
+ (cond
115
+ ((= kind "map-binding-entry")
116
+ (when (> (js-length children) 2) (tools-walk (js-nth 2 children) scope context))
117
+ (tools-pattern-defaults (js-nth 0 children) scope context))
118
+ ((or (= kind "array-binding-pattern") (= kind "map-binding-pattern"))
119
+ (js-call children :forEach (lambda (child) (tools-pattern-defaults child scope context)))))))
120
+
121
+ (defun tools-pattern-declare (node scope kind context)
122
+ (let ((tag (get node :kind)) (children (get node :children)))
123
+ (cond
124
+ ((= tag "binding-name") (tools-declare node scope kind context))
125
+ ((= tag "map-binding-entry") (tools-pattern-declare (js-nth 0 children) scope kind context))
126
+ ((or (= tag "array-binding-pattern") (= tag "map-binding-pattern"))
127
+ (js-call children :forEach (lambda (child) (tools-pattern-declare child scope kind context)))))))
128
+
129
+ (defun tools-binding-defaults (node scope context)
130
+ ;; A parameter's expression children belong to the enclosing scope, just
131
+ ;; like defaults inside its binding pattern. Do not walk those children as
132
+ ;; function-body expressions after parameter names have been declared.
133
+ (when (= (get node :kind) "parameter-binding")
134
+ (tools-binding-initializer node scope context))
135
+ (when (get (get node :properties nil) :pattern false)
136
+ (tools-pattern-defaults (js-nth 0 (get node :children)) scope context)))
137
+
138
+ (defun tools-binding-declare (node scope kind context)
139
+ (if (get (get node :properties nil) :pattern false)
140
+ (tools-pattern-declare (js-nth 0 (get node :children)) scope kind context)
141
+ (tools-declare node scope kind context)))
142
+
143
+ (defun tools-binding-initializer (node scope context)
144
+ (let ((children (get node :children))
145
+ (start (if (get (get node :properties nil) :pattern false) 1 0)))
146
+ (while (< start (js-length children))
147
+ (tools-walk (js-nth start children) scope context)
148
+ (setq start (1+ start)))))
149
+
150
+ (defun tools-predeclare (nodes scope context)
151
+ (js-call nodes :forEach
152
+ (lambda (node)
153
+ (let ((kind (get node :kind)))
154
+ (cond
155
+ ((= kind "module-declaration") (tools-predeclare (get node :children) scope context))
156
+ ((= kind "function-declaration") (tools-declare node scope "function" context))
157
+ ((= kind "variable-declaration") (tools-declare node scope "variable" context))
158
+ ((= kind "import-declaration")
159
+ (js-call (get node :children) :forEach
160
+ (lambda (child) (tools-declare child scope "import" context)))))))))
161
+
162
+ (defun tools-function (node scope context)
163
+ (let* ((children (get node :children))
164
+ (count (get (get node :properties) :parameterCount))
165
+ (child (tools-scope scope)) (index 0))
166
+ ;; Analyzer defaults see the enclosing scope, before any parameter binds.
167
+ (while (< index count)
168
+ (tools-binding-defaults (js-nth index children) scope context)
169
+ (setq index (1+ index)))
170
+ (setq index 0)
171
+ (while (< index count)
172
+ (tools-binding-declare (js-nth index children) child "parameter" context)
173
+ (setq index (1+ index)))
174
+ (while (< index (js-length children))
175
+ (tools-walk (js-nth index children) child context)
176
+ (setq index (1+ index)))))
177
+
178
+ (defun tools-let (node scope context)
179
+ (let* ((children (get node :children)) (properties (get node :properties))
180
+ (count (get properties :bindingCount))
181
+ (sequential (get properties :sequential false))
182
+ (child (tools-scope scope)) (index 0))
183
+ (while (< index count)
184
+ (let* ((binding (js-nth index children)) (initializer-scope (if sequential child scope)))
185
+ (tools-binding-initializer binding initializer-scope context)
186
+ (tools-binding-defaults binding initializer-scope context)
187
+ (when sequential (tools-binding-declare binding child "local" context)))
188
+ (setq index (1+ index)))
189
+ (unless sequential
190
+ (setq index 0)
191
+ (while (< index count)
192
+ (tools-binding-declare (js-nth index children) child
193
+ (if (= (get node :kind) "binding-loop") "loop" "local") context)
194
+ (setq index (1+ index))))
195
+ (while (< index (js-length children))
196
+ (tools-walk (js-nth index children) child context)
197
+ (setq index (1+ index)))))
198
+
199
+ (defun tools-walk (node scope context)
200
+ (let ((kind (get node :kind)) (children (get node :children)))
201
+ (cond
202
+ ((= kind "reference") (tools-reference node scope "read" context))
203
+ ((= kind "assignment-pair")
204
+ (tools-reference node scope "write" context)
205
+ (js-call children :forEach (lambda (child) (tools-walk child scope context))))
206
+ ((or (= kind "function-declaration") (= kind "function-expression"))
207
+ (tools-function node scope context))
208
+ ((or (= kind "lexical-bindings") (= kind "binding-loop")) (tools-let node scope context))
209
+ ((= kind "catch-clause")
210
+ (let ((child (tools-scope scope)) (binding (js-nth 0 children)) (index 1))
211
+ (tools-binding-defaults binding scope context)
212
+ (tools-binding-declare binding child "catch" context)
213
+ (while (< index (js-length children))
214
+ (tools-walk (js-nth index children) child context)
215
+ (setq index (1+ index)))))
216
+ ;; Literal/raw contents and property names are data, never guessed refs.
217
+ ((or (= kind "quoted-literal") (= kind "raw-javascript")
218
+ (= kind "import-declaration")) nil)
219
+ (t (js-call children :forEach (lambda (child) (tools-walk child scope context)))))))
220
+
221
+ (defun tools-source-sequence (nodes context)
222
+ (js-call nodes :forEach (lambda (node) (tools-source-expression node context))))
223
+
224
+ (defun tools-source-binding-defaults (node context)
225
+ (let ((kind (get node :kind)))
226
+ (cond
227
+ ((= kind "vector")
228
+ (js-call (get node :items) :forEach
229
+ (lambda (item) (tools-source-binding-defaults item context))))
230
+ ((= kind "list")
231
+ (let* ((items (get node :items)) (head (js-nth 0 items)))
232
+ (when (and head (= (get head :kind) "symbol") (= (get head :name) "hash-map"))
233
+ (let ((index 1))
234
+ (while (< index (js-length items))
235
+ (let* ((target (js-nth index items)) (value (js-nth (1+ index) items))
236
+ (directive (if (= (get target :kind) "keyword") (get target :name) nil)))
237
+ (cond
238
+ ((= directive "or")
239
+ (let ((defaults (get value :items)) (position 2))
240
+ (while (< position (js-length defaults))
241
+ (tools-source-expression (js-nth position defaults) context)
242
+ (setq position (+ position 2)))))
243
+ ;; Shortcut keys and :as values only introduce names.
244
+ ((not (= (get target :kind) "keyword"))
245
+ (tools-source-binding-defaults target context))))
246
+ (setq index (+ index 2))))))))))
247
+
248
+ (defun tools-source-parameter-defaults (parameters context)
249
+ (js-call (get parameters :items (js-array)) :forEach
250
+ (lambda (parameter) (tools-source-binding-defaults parameter context))))
251
+
252
+ (defun tools-source-expression (node context)
253
+ (let ((kind (get node :kind)))
254
+ (cond
255
+ ((= kind "vector") (tools-source-sequence (get node :items) context))
256
+ ((= kind "list")
257
+ (let* ((items (get node :items)) (head (js-nth 0 items))
258
+ (operator (and head (= (get head :kind) "symbol") (get head :name)))
259
+ (macro (and operator (js-call (get context :macros) :get operator))))
260
+ (cond
261
+ (macro
262
+ ;; locate-generated preserves this source invocation span, not a
263
+ ;; complete nested expansion trace. Do not fabricate that trace.
264
+ (let ((origin (js-object :name operator :span (get node :span)
265
+ :definitionId (get macro :id) :definitionSpan (get macro :span)
266
+ :precision "source-invocation")))
267
+ (js-call (get context :macroOrigins) :push origin)
268
+ (js-call (get context :references) :push
269
+ (js-object :name operator :role "macro-expansion" :span (get head :span)
270
+ :expandedSpan (get node :span) :generated false
271
+ :bindingId (get macro :id) :definitionSpan (get macro :span) :macroOrigin origin))))
272
+ ((or (= operator "quote") (= operator "js*")) nil)
273
+ ((or (= operator "lambda") (= operator "fn") (= operator "async"))
274
+ (tools-source-parameter-defaults (js-nth 1 items) context)
275
+ (tools-source-sequence (js-call items :slice 2) context))
276
+ ((or (= operator "let") (= operator "let*") (= operator "loop"))
277
+ (let ((bindings (get (js-nth 1 items) :items (js-array))))
278
+ (js-call bindings :forEach
279
+ (lambda (binding)
280
+ (when (= (get binding :kind) "list")
281
+ (tools-source-sequence (js-call (get binding :items) :slice 1) context)))))
282
+ (tools-source-sequence (js-call items :slice 2) context))
283
+ ((= operator "cond")
284
+ (js-call (js-call items :slice 1) :forEach
285
+ (lambda (clause) (tools-source-sequence (get clause :items) context))))
286
+ ((= operator "try")
287
+ (js-call (js-call items :slice 1) :forEach
288
+ (lambda (clause)
289
+ (let* ((parts (get clause :items (js-array)))
290
+ (tag (and (> (js-length parts) 0) (get (js-nth 0 parts) :name nil))))
291
+ (cond
292
+ ((= tag "catch") (tools-source-sequence (js-call parts :slice 2) context))
293
+ ((= tag "finally") (tools-source-sequence (js-call parts :slice 1) context))
294
+ (t (tools-source-expression clause context)))))))
295
+ ((= operator "js-object")
296
+ (let ((index 1))
297
+ (while (< index (js-length items))
298
+ (let ((key (js-nth index items)))
299
+ (when (or (= (get key :kind) "list") (= (get key :kind) "vector"))
300
+ (tools-source-expression key context)))
301
+ (tools-source-expression (js-nth (1+ index) items) context)
302
+ (setq index (+ index 2)))))
303
+ (t
304
+ (unless (and head (= (get head :kind) "symbol"))
305
+ (when head (tools-source-expression head context)))
306
+ (tools-source-sequence (js-call items :slice 1) context))))))))
307
+
308
+ (defun tools-source-top (forms context)
309
+ (js-call forms :forEach
310
+ (lambda (node)
311
+ (let* ((items (get node :items (js-array)))
312
+ (head (js-nth 0 items))
313
+ (operator (and head (get head :name nil))))
314
+ (cond
315
+ ((= operator "module") (tools-source-top (js-call items :slice 2) context))
316
+ ((= operator "defmacro")
317
+ (let* ((name-node (js-nth 1 items)) (name (get name-node :name))
318
+ (definition (js-object :id (str "binding-" (js-length (get context :definitions)))
319
+ :name name :kind "macro" :span (get name-node :span)
320
+ :expandedSpan (get node :span) :generated false :macroOrigin nil)))
321
+ (js-call (get context :definitions) :push definition)
322
+ (js-call (get context :macros) :set name definition)))
323
+ ((or (= operator "import") (= operator "import-portable") (= operator "export")) nil)
324
+ ((or (= operator "defun") (= operator "defn")
325
+ (= operator "defportable") (= operator "defasync"))
326
+ (tools-source-parameter-defaults (js-nth 2 items) context)
327
+ (tools-source-sequence (js-call items :slice 3) context))
328
+ ((or (= operator "defvar") (= operator "defconst"))
329
+ (tools-source-sequence (js-call items :slice 2) context))
330
+ (t (tools-source-expression node context)))))))
331
+
332
+ (defun tools-scalar-length (source)
333
+ (let ((index 0) (count 0) (length (js-length source)))
334
+ (while (< index length)
335
+ (let ((first (string-code-unit-at source index)))
336
+ (when (and (>= first 55296) (<= first 56319) (< (1+ index) length))
337
+ (let ((second (string-code-unit-at source (1+ index))))
338
+ (when (and (>= second 56320) (<= second 57343)) (setq index (1+ index))))))
339
+ (setq index (1+ index)) (setq count (1+ count))) count))
340
+
341
+ (defun tools-contains (span offset)
342
+ (and span (<= (get span :start) offset) (< offset (get span :end))))
343
+
344
+ (defun tools-at (context offset)
345
+ (let ((selected nil) (width nil) (ambiguous false))
346
+ (js-call (get context :definitions) :forEach
347
+ (lambda (definition)
348
+ (let ((span (get definition :span)))
349
+ (when (tools-contains span offset)
350
+ (let ((size (- (get span :end) (get span :start))))
351
+ (cond
352
+ ((or (nil? width) (< size width))
353
+ (setq selected (js-object :kind "definition" :value definition
354
+ :bindingId (get definition :id)))
355
+ (setq width size) (setq ambiguous false))
356
+ ((= size width) (setq ambiguous t))))))))
357
+ (js-call (get context :references) :forEach
358
+ (lambda (reference)
359
+ (let ((span (get reference :span)))
360
+ (when (tools-contains span offset)
361
+ (let ((size (- (get span :end) (get span :start))))
362
+ (cond
363
+ ((or (nil? width) (< size width))
364
+ (setq selected (js-object :kind "reference" :value reference
365
+ :bindingId (get reference :bindingId)))
366
+ (setq width size) (setq ambiguous false))
367
+ ((= size width) (setq ambiguous t))))))))
368
+ (if ambiguous nil selected)))
369
+
370
+ (defun tools-query (context request source filename)
371
+ (let ((offset (get request :offset nil))
372
+ (unit (get request :offsetUnit nil))
373
+ (query (get request :query "symbol")))
374
+ (unless (= unit "unicode-scalar")
375
+ (tools-fail "query offsetUnit must be unicode-scalar" filename))
376
+ (unless (and (Number/isSafeInteger offset) (>= offset 0)
377
+ (<= offset (tools-scalar-length source)))
378
+ (tools-fail "query offset is outside the source Unicode scalar range" filename))
379
+ (unless (js-call (js-array "symbol" "definition" "references") :includes query)
380
+ (tools-fail "unsupported compiler query" filename))
381
+ (let* ((selected (tools-at context offset))
382
+ (binding-id (and selected (get selected :bindingId)))
383
+ (definition nil) (references (js-array)))
384
+ (unless (nil? binding-id)
385
+ (js-call (get context :definitions) :forEach
386
+ (lambda (item) (when (= (get item :id) binding-id) (setq definition item))))
387
+ (js-call (get context :references) :forEach
388
+ (lambda (item)
389
+ (when (= (get item :bindingId) binding-id) (js-call references :push item)))))
390
+ (js-object :query query :offset offset :offsetUnit unit :symbol selected
391
+ :definition definition :references references
392
+ :result (cond ((= query "definition") definition)
393
+ ((= query "references") references)
394
+ (t selected))))))
395
+
396
+ (defun tools-source-identity (source filename)
397
+ (let ((bytes (sha256-string-utf16le source)) (hex "")
398
+ (digits "0123456789abcdef") (index 0))
399
+ (while (< index (js-length bytes))
400
+ (let ((byte (js-nth index bytes)))
401
+ (setq hex (str hex (js-call digits :charAt (unsigned-bit-shift-right byte 4))
402
+ (js-call digits :charAt (bit-and byte 15)))))
403
+ (setq index (1+ index)))
404
+ (js-object :format "eliscript-source-identity" :version 1
405
+ :encoding "utf16le" :filename filename :units (js-length source) :sha256 hex)))
406
+
407
+ (defun tools-check-source-identity (request identity filename required)
408
+ (let ((expected (get request :expectedSourceIdentity)))
409
+ (when (and required (undefined? expected))
410
+ (tools-fail "edit-preview requires expectedSourceIdentity" filename))
411
+ (unless (undefined? expected)
412
+ (unless (and (not (nil? expected)) (= (value-type expected) "object")
413
+ (not (Array/isArray expected))
414
+ (= (get expected :format nil) "eliscript-source-identity")
415
+ (= (get expected :version nil) 1)
416
+ (= (get expected :encoding nil) "utf16le")
417
+ (= (get expected :filename nil) (get identity :filename))
418
+ (= (get expected :units nil) (get identity :units))
419
+ (= (get expected :sha256 nil) (get identity :sha256)))
420
+ (tools-fail "request belongs to a different source snapshot" filename "ELI-T0002")))))
421
+
422
+ (defun tools-next-scalar (source index)
423
+ (let ((first (string-code-unit-at source index)) (next (1+ index)))
424
+ (when (and (>= first 55296) (<= first 56319) (< next (js-length source)))
425
+ (let ((second (string-code-unit-at source next)))
426
+ (when (and (>= second 56320) (<= second 57343)) (setq next (1+ next)))))
427
+ next))
428
+
429
+ (defun tools-edit-preview (request source filename identity)
430
+ (let ((edits (get request :edits undefined)) (length (tools-scalar-length source))
431
+ (previous-start -1) (previous-end 0))
432
+ (unless (= (get request :offsetUnit nil) "unicode-scalar")
433
+ (tools-fail "edit offsetUnit must be unicode-scalar" filename))
434
+ (unless (Array/isArray edits) (tools-fail "edits must be an array" filename))
435
+ ;; Validate the complete original-coordinate batch before constructing a
436
+ ;; preview. Equal starts, even two insertions, are deliberately ambiguous.
437
+ (js-call edits :forEach
438
+ (lambda (edit)
439
+ (unless (and (not (nil? edit)) (= (value-type edit) "object")
440
+ (not (Array/isArray edit)))
441
+ (tools-fail "each edit must be an object" filename))
442
+ (let ((start (get edit :start nil)) (end (get edit :end nil))
443
+ (text (get edit :text undefined)))
444
+ (unless (and (Number/isSafeInteger start) (Number/isSafeInteger end)
445
+ (>= start 0) (>= end start) (<= end length)
446
+ (= (value-type text) "string"))
447
+ (tools-fail "edit requires a valid scalar range and replacement string" filename))
448
+ (unless (and (> start previous-start) (>= start previous-end))
449
+ (tools-fail "edits must have distinct starts in nonoverlapping source order" filename))
450
+ (setq previous-start start) (setq previous-end end))))
451
+ (let ((parts (js-array)) (unit 0) (scalar 0) (copied 0))
452
+ ;; Walk the original once. Preserve unmatched UTF-16 units and never
453
+ ;; allocate a whole-source scalar array just to address edit offsets.
454
+ (js-call edits :forEach
455
+ (lambda (edit)
456
+ (while (< scalar (get edit :start))
457
+ (setq unit (tools-next-scalar source unit)) (setq scalar (1+ scalar)))
458
+ (js-call parts :push (js-call source :slice copied unit) (get edit :text))
459
+ (while (< scalar (get edit :end))
460
+ (setq unit (tools-next-scalar source unit)) (setq scalar (1+ scalar)))
461
+ (setq copied unit)))
462
+ (js-call parts :push (js-call source :slice copied))
463
+ (let ((updated (js-call parts :join "")))
464
+ (js-object :ok t :operation "edit-preview" :filename filename
465
+ :offsetUnit "unicode-scalar" :readOnly t :diagnostics (js-array)
466
+ :previousSourceIdentity identity :sourceIdentity (tools-source-identity updated filename)
467
+ :source updated)))))
468
+
469
+ (defun tools-request (request)
470
+ (let ((filename (get request :filename "<input>")) (identity nil))
471
+ (unless (= (value-type filename) "string") (tools-fail "filename must be a string" "<input>"))
472
+ (try
473
+ (let ((source (get request :source undefined))
474
+ (operation (get request :operation nil)))
475
+ (unless (= (value-type source) "string") (tools-fail "source must be a string" filename))
476
+ (unless (or (= operation "analyze") (= operation "query") (= operation "edit-preview"))
477
+ (tools-fail "unsupported compiler tools operation" filename))
478
+ (progn
479
+ (setq identity (tools-source-identity source filename))
480
+ (tools-check-source-identity request identity filename (= operation "edit-preview"))
481
+ (if (= operation "edit-preview") (tools-edit-preview request source filename identity)
482
+ (let* ((forms (read-string source filename))
483
+ (expansion (expand-module-with-origins forms filename (get request :macroContext nil)))
484
+ (expanded (get expansion :forms))
485
+ (context (js-object :syntax (new globalThis.Map) :macros (new globalThis.Map)
486
+ :definitions (js-array) :references (js-array) :macroOrigins (js-array)
487
+ :macroExpansions (get expansion :macroOrigins)))
488
+ (scope (tools-scope nil)))
489
+ (analyze-module expanded filename)
490
+ (let ((program (lower-module expanded filename)))
491
+ (js-call forms :forEach (lambda (node) (tools-syntax-index node context)))
492
+ (tools-source-top forms context)
493
+ (tools-predeclare (get program :body) scope context)
494
+ (js-call (get program :body) :forEach (lambda (node) (tools-walk node scope context)))
495
+ (let ((result (js-object :ok t :operation operation :filename filename
496
+ :offsetUnit "unicode-scalar" :sourceIdentity identity :readOnly t :diagnostics (js-array)
497
+ :definitions (get context :definitions) :references (get context :references)
498
+ :macroOrigins (get context :macroOrigins)
499
+ :macroExpansions (get context :macroExpansions) :macroExpansionTraceAvailable t)))
500
+ (when (= operation "query")
501
+ (put result :query (tools-query context request source filename)))
502
+ result))))))
503
+ (catch error
504
+ (let ((diagnostic (get error :eliscriptDiagnostic nil)))
505
+ (if diagnostic
506
+ (js-object :ok false :operation (get request :operation nil) :filename filename
507
+ :offsetUnit "unicode-scalar" :sourceIdentity identity :readOnly t :diagnostics (js-array diagnostic)
508
+ :definitions (js-array) :references (js-array) :macroOrigins (js-array)
509
+ :macroExpansions (get error :macroOrigins (js-array))
510
+ :macroExpansionTraceAvailable t :query nil)
511
+ (throw error)))))))
512
+
513
+ (export tools-request))
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ //
3
+ // Node entry point for the packaged command line.
4
+ //
5
+ // The shell wrappers beside this file locate the checkout through their own
6
+ // path and default to Bun. An installed package has neither a checkout URL nor
7
+ // a guaranteed Bun, so this entry derives the package root from its own
8
+ // location, defaults to the Node runtime it is already running under, and
9
+ // dispatches on the name the command was invoked as. Every name in `bin` points
10
+ // here.
11
+
12
+ import { basename, dirname, resolve } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const here = dirname(fileURLToPath(import.meta.url));
16
+ const root = resolve(here, "../..");
17
+
18
+ // The generated compiler sits beside the package. The shell wrappers read the
19
+ // same variable, so both entry points agree on one location.
20
+ process.env.ELISCRIPT_BOOTSTRAP_MODULE_DIR ??= resolve(root, "dist/bootstrap");
21
+
22
+ const commands = {
23
+ "eliscript": ["bun.mjs", "eliscript"],
24
+ "eliscript-build": ["project-cli.mjs", "eliscript-build"],
25
+ "eliscript-check": ["check-cli.mjs", "eliscript-check"],
26
+ "eliscript-format": ["format-cli.mjs", "eliscript-format"],
27
+ "eliscript-eval": ["evaluation-cli.mjs", "eliscript-eval"],
28
+ "eliscript-watch": ["watch-cli.mjs", "eliscript-watch"],
29
+ "eliscript-compiler": ["../../tools/backends/compiler-cli.mjs", "eliscript-compiler"],
30
+ };
31
+
32
+ const invoked = basename(process.argv[1] ?? "");
33
+ const [entry, commandName] = commands[invoked] ?? commands.eliscript;
34
+ process.env.ELISCRIPT_COMMAND_NAME ??= commandName;
35
+
36
+ const { main } = await import(new URL(`./${entry}`, import.meta.url));
37
+ await main(process.argv.slice(2));
@@ -1,36 +1,56 @@
1
1
  #!/usr/bin/env node
2
- //
3
- // Node entry point for the packaged command line.
4
- //
5
- // The shell wrappers beside this file locate the checkout through their own
6
- // path and default to Bun. An installed package has neither a checkout URL nor
7
- // a guaranteed Bun, so this entry derives the package root from its own
8
- // location, defaults to the Node runtime it is already running under, and
9
- // dispatches on the name the command was invoked as. Every name in `bin` points
10
- // here.
11
-
12
- import { basename, dirname, resolve } from "node:path";
13
- import { fileURLToPath } from "node:url";
2
+ // Generated by Eliscript. Do not edit.
3
+ import { tdz as __eliscript_tdz_error, immutable as __eliscript_const_error } from "data:text/javascript;base64,Y29uc3QgRSA9IFJlZmVyZW5jZUVycm9yOyBjb25zdCBUID0gVHlwZUVycm9yOyBleHBvcnQgZnVuY3Rpb24gdGR6KG5hbWUpIHsgdGhyb3cgbmV3IEUoIkNhbm5vdCBhY2Nlc3MgJyIgKyBuYW1lICsgIicgYmVmb3JlIGluaXRpYWxpemF0aW9uIik7IH0gZXhwb3J0IGZ1bmN0aW9uIGltbXV0YWJsZSgpIHsgdGhyb3cgbmV3IFQoIkFzc2lnbm1lbnQgdG8gY29uc3RhbnQgdmFyaWFibGUuIik7IH0K";
4
+ var __eliscript_tdz_ready_0;
5
+ function __eliscript_tdz_read_0() { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("here"); return here; }
6
+ function __eliscript_tdz_write_0(__eliscript_tdz_value_0) { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("here"); return __eliscript_const_error(); }
7
+ var __eliscript_tdz_ready_1;
8
+ function __eliscript_tdz_read_1() { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("root"); return root; }
9
+ function __eliscript_tdz_write_1(__eliscript_tdz_value_1) { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("root"); return __eliscript_const_error(); }
10
+ var __eliscript_tdz_ready_2;
11
+ function __eliscript_tdz_read_2() { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("environment"); return environment; }
12
+ function __eliscript_tdz_write_2(__eliscript_tdz_value_2) { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("environment"); return __eliscript_const_error(); }
13
+ var __eliscript_tdz_ready_3;
14
+ function __eliscript_tdz_read_3() { if (__eliscript_tdz_ready_3 !== true) __eliscript_tdz_error("commands"); return commands; }
15
+ function __eliscript_tdz_write_3(__eliscript_tdz_value_3) { if (__eliscript_tdz_ready_3 !== true) __eliscript_tdz_error("commands"); return __eliscript_const_error(); }
16
+ import "eliscript/runtime/unicode-case.mjs";
17
+ const __eliscript_truthy = (value) => value !== false && value != null;
14
18
 
19
+ import {basename, dirname, resolve} from "node:path";
20
+ import {fileURLToPath} from "node:url";
21
+ import {createRequire} from "node:module";
22
+ import {runReleaseCLI} from "../../tools/backends/dist/release-cli.mjs";
15
23
  const here = dirname(fileURLToPath(import.meta.url));
16
- const root = resolve(here, "../..");
17
-
18
- // The generated compiler sits beside the package. The shell wrappers read the
19
- // same variable, so both entry points agree on one location.
20
- process.env.ELISCRIPT_BOOTSTRAP_MODULE_DIR ??= resolve(root, "dist/bootstrap");
21
-
22
- const commands = {
23
- "eliscript": ["bun.mjs", "eliscript"],
24
- "eliscript-build": ["project-cli.mjs", "eliscript-build"],
25
- "eliscript-check": ["check-cli.mjs", "eliscript-check"],
26
- "eliscript-format": ["format-cli.mjs", "eliscript-format"],
27
- "eliscript-eval": ["evaluation-cli.mjs", "eliscript-eval"],
28
- "eliscript-watch": ["watch-cli.mjs", "eliscript-watch"],
29
- };
30
-
31
- const invoked = basename(process.argv[1] ?? "");
32
- const [entry, commandName] = commands[invoked] ?? commands.eliscript;
33
- process.env.ELISCRIPT_COMMAND_NAME ??= commandName;
34
-
35
- const { main } = await import(new URL(`./${entry}`, import.meta.url));
36
- await main(process.argv.slice(2));
24
+ __eliscript_tdz_ready_0 = true;
25
+ const root = resolve((__eliscript_tdz_read_0()), "../..");
26
+ __eliscript_tdz_ready_1 = true;
27
+ const environment = (globalThis.process)["env"];
28
+ __eliscript_tdz_ready_2 = true;
29
+ ((((__eliscript_tdz_read_2()))["ELISCRIPT_BOOTSTRAP_MODULE_DIR"] == null) ? (((__eliscript_tdz_read_2()))["ELISCRIPT_BOOTSTRAP_MODULE_DIR"] = resolve((__eliscript_tdz_read_1()), "dist/bootstrap")) : null);
30
+ const commands = ({"eliscript": ["bun.mjs", "eliscript"], "eliscript-build": ["project-cli.mjs", "eliscript-build"], "eliscript-check": ["check-cli.mjs", "eliscript-check"], "eliscript-format": ["format-cli.mjs", "eliscript-format"], "eliscript-eval": ["evaluation-cli.mjs", "eliscript-eval"], "eliscript-watch": ["watch-cli.mjs", "eliscript-watch"], "eliscript-compiler": ["../../tools/backends/compiler-cli.mjs", "eliscript-compiler"]});
31
+ __eliscript_tdz_ready_3 = true;
32
+ async function main() {
33
+ return (await (async (arguments$) => {
34
+ return (await (async (invoked) => {
35
+ return (await (async (found) => {
36
+ return (await (async (selected) => {
37
+ return (await (async (entry) => {
38
+ return (await (async () => {
39
+ if ((((__eliscript_tdz_read_2()))["ELISCRIPT_COMMAND_NAME"] == null)) {
40
+ (((__eliscript_tdz_read_2()))["ELISCRIPT_COMMAND_NAME"] = (selected)[1]);
41
+ }
42
+ return ((invoked === "eliscript-compiler") ? await (runReleaseCLI((arguments$)["slice"](2))) : (await (async (namespace) => {
43
+ return await ((namespace)["main"]((arguments$)["slice"](2)));
44
+ })((createRequire(resolve((__eliscript_tdz_read_0()), "eliscript-cli.mjs")))(entry))));
45
+ })());
46
+ })(resolve((__eliscript_tdz_read_0()), (selected)[0])));
47
+ })(((found == null) ? ((__eliscript_tdz_read_3()))["eliscript"] : found)));
48
+ })(((__eliscript_tdz_read_3()))[invoked]));
49
+ })(basename((((arguments$)[1] == null) ? "" : (arguments$)[1]))));
50
+ })((globalThis.process)["argv"]));
51
+ }
52
+ (main())["catch"](((error) => {
53
+ (globalThis.console)["error"](error);
54
+ return ((globalThis.process)["exitCode"] = 1);
55
+ }));
56
+ //# sourceMappingURL=eliscript-cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eliscript-cli.mjs","sources":["../../tools/backends/eliscript/package-cli-entry.eli"],"sourcesContent":["(module tools.backends.package-cli-entry\n (import \"node:path\" basename dirname resolve)\n (import \"node:url\" fileURLToPath)\n (import \"node:module\" createRequire)\n (import \"../../tools/backends/dist/release-cli.mjs\" runReleaseCLI)\n\n ;; This file is emitted at bootstrap/host/eliscript-cli.mjs. Installed bin\n ;; symlinks may have another name; locate runtime assets beside this module.\n (defconst here (dirname (fileURLToPath (js* \"import.meta.url\"))))\n (defconst root (resolve here \"../..\"))\n (defconst environment (get globalThis.process :env))\n (when (nullish? (get environment :ELISCRIPT_BOOTSTRAP_MODULE_DIR))\n (put environment :ELISCRIPT_BOOTSTRAP_MODULE_DIR (resolve root \"dist/bootstrap\")))\n (defconst commands\n (js-object\n :eliscript (js-array \"bun.mjs\" \"eliscript\")\n :eliscript-build (js-array \"project-cli.mjs\" \"eliscript-build\")\n :eliscript-check (js-array \"check-cli.mjs\" \"eliscript-check\")\n :eliscript-format (js-array \"format-cli.mjs\" \"eliscript-format\")\n :eliscript-eval (js-array \"evaluation-cli.mjs\" \"eliscript-eval\")\n :eliscript-watch (js-array \"watch-cli.mjs\" \"eliscript-watch\")\n :eliscript-compiler (js-array \"../../tools/backends/compiler-cli.mjs\" \"eliscript-compiler\")))\n\n (defasync main ()\n (let* ((arguments (get globalThis.process :argv))\n (invoked (basename (if (nullish? (aref arguments 1)) \"\" (aref arguments 1))))\n (found (get commands invoked))\n (selected (if (nullish? found) (get commands :eliscript) found))\n (entry (resolve here (aref selected 0))))\n (when (nullish? (get environment :ELISCRIPT_COMMAND_NAME))\n (put environment :ELISCRIPT_COMMAND_NAME (aref selected 1)))\n ;; The compiler entry has asynchronous ESM dependencies. Its static\n ;; import completes before main; the six established handlers still\n ;; capture their command environment only when their namespace loads.\n (if (= invoked \"eliscript-compiler\")\n (await (runReleaseCLI (js-call arguments :slice 2)))\n (let ((namespace (funcall (createRequire (resolve here \"eliscript-cli.mjs\")) entry)))\n (await (js-call namespace :main (js-call arguments :slice 2)))))))\n\n (js-call (main) :catch (lambda (error)\n (js-call globalThis.console :error error)\n (put globalThis.process :exitCode 1))))\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACE,QAAoB,UAAS,SAAQ;AACrC,QAAmB;AACnB,QAAsB;AACtB,QAAoD;AAIpD,aAAgB,QAAS,cAAc;;AACvC,aAAgB,QAAQ,4BAAK;;AAC7B,oBAAsB,CAAK,oBAAmB;;AAC9C,CAAM,CAAU,CAAK,4BAAY,6CAC/B,EAAK,4BAAY,oCAAiC,QAAQ,4BAAK;AACjE,iBACE,EACE,aAAW,CAAU,WAAU,cAC/B,mBAAiB,CAAU,mBAAkB,oBAC7C,mBAAiB,CAAU,iBAAgB,oBAC3C,oBAAkB,CAAU,kBAAiB,qBAC7C,kBAAgB,CAAU,sBAAqB,mBAC/C,mBAAiB,CAAU,iBAAgB,oBAC3C,sBAAoB,CAAU,yCAAwC;;AAE1E;EACE,OAAA,eAAO;0BACA;4BACA;8BACA;gCACA;;cACL,IAAM,CAAU,CAAK,4BAAY;gBAC/B,EAAK,4BAAY,4BAAwB,CAAM,UAAS;;cAI1D,OAAA,CAAI,CAAG,YAAQ,wBACb,OAAQ,cAAc,CAAS,YAAU,SAAO,OAChD,eAAM;gBACJ,OAAA,OAAO,CAAS,WAAU,QAAM,CAAS,YAAU,SAAO;iBAD3C,CAAU,cAAe,QAAQ,4BAAK,uBAAsB;;aARlE,QAAQ,4BAAK,CAAM,UAAS;WAD1B,CAAI,CAAU,iBAAO,CAAK,4BAAS,eAAY;SADlD,CAAK,4BAAS;OADX,SAAS,CAAI,CAAU,CAAM,YAAU,cAAI,KAAG,CAAM,YAAU;KAD7D,CAAK,oBAAmB;;AAe5C,CAAU,QAAM,SAAO,EAAS;EAC9B,CAAS,oBAAmB,SAAO;EACnC,OAAA,EAAK,oBAAmB,cAAU"}