eliscript 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (417) hide show
  1. package/README.md +61 -0
  2. package/bootstrap/README.md +26 -0
  3. package/bootstrap/backends/README.md +515 -0
  4. package/bootstrap/backends/async.eli +230 -0
  5. package/bootstrap/backends/binary.eli +173 -0
  6. package/bootstrap/backends/capabilities.eli +74 -0
  7. package/bootstrap/backends/elf.eli +246 -0
  8. package/bootstrap/backends/managed.eli +5976 -0
  9. package/bootstrap/backends/memory.eli +100 -0
  10. package/bootstrap/backends/native.eli +2000 -0
  11. package/bootstrap/backends/numeric.eli +1362 -0
  12. package/bootstrap/backends/optimize.eli +79 -0
  13. package/bootstrap/backends/regexp.eli +2263 -0
  14. package/bootstrap/backends/sha256.eli +138 -0
  15. package/bootstrap/backends/wasm.eli +1161 -0
  16. package/bootstrap/compiler/analyzer.eli +165 -77
  17. package/bootstrap/compiler/compiler.eli +43 -19
  18. package/bootstrap/compiler/emitter.eli +780 -170
  19. package/bootstrap/compiler/expander.eli +136 -45
  20. package/bootstrap/compiler/formatter.eli +8 -1
  21. package/bootstrap/compiler/ir.eli +148 -45
  22. package/bootstrap/compiler/lower.eli +29 -2
  23. package/bootstrap/compiler/project.eli +51 -21
  24. package/bootstrap/compiler/reader.eli +128 -36
  25. package/bootstrap/compiler/source-map.eli +46 -4
  26. package/bootstrap/compiler/symbol.eli +2 -1
  27. package/bootstrap/compiler/syntax.eli +47 -12
  28. package/bootstrap/compiler/transient-analysis.eli +40 -4
  29. package/bootstrap/host/check-cli-legacy.mjs +163 -0
  30. package/bootstrap/host/check-cli.mjs +59 -158
  31. package/bootstrap/host/check-cli.mjs.map +1 -0
  32. package/bootstrap/host/compiler-session.eli +1579 -0
  33. package/bootstrap/host/compiler-tools.eli +513 -0
  34. package/bootstrap/host/eliscript-cli.mjs +53 -33
  35. package/bootstrap/host/eliscript-cli.mjs.map +1 -0
  36. package/bootstrap/host/project-cli-legacy.mjs +295 -0
  37. package/bootstrap/host/project-cli.mjs +74 -289
  38. package/bootstrap/host/project-cli.mjs.map +1 -0
  39. package/bootstrap/host/project-legacy.mjs +1080 -0
  40. package/bootstrap/host/project.mjs +210 -1060
  41. package/bootstrap/host/project.mjs.map +1 -0
  42. package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
  43. package/bootstrap/runtime/memory.eli +30379 -0
  44. package/browser/host.mjs +732 -11
  45. package/browser/worker.mjs +6 -3
  46. package/compiler/eliscript-analyzer.el +371 -4
  47. package/compiler/eliscript-cli.el +84 -1
  48. package/compiler/eliscript-emitter.el +1189 -256
  49. package/compiler/eliscript-expander.el +147 -10
  50. package/compiler/eliscript-ir-emitter.el +725 -208
  51. package/compiler/eliscript-lower.el +127 -1
  52. package/compiler/eliscript-portable.el +177 -51
  53. package/compiler/eliscript-project.el +20 -2
  54. package/compiler/eliscript-reader.el +141 -57
  55. package/compiler/eliscript-source-map.el +26 -12
  56. package/compiler/eliscript-transient-analysis.el +382 -19
  57. package/dist/backends/async.mjs +561 -0
  58. package/dist/backends/async.mjs.macro-origins.json +1 -0
  59. package/dist/backends/async.mjs.map +1 -0
  60. package/dist/backends/binary.mjs +381 -0
  61. package/dist/backends/binary.mjs.macro-origins.json +1 -0
  62. package/dist/backends/binary.mjs.map +1 -0
  63. package/dist/backends/capabilities.mjs +237 -0
  64. package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
  65. package/dist/backends/capabilities.mjs.map +1 -0
  66. package/dist/backends/elf.mjs +540 -0
  67. package/dist/backends/elf.mjs.macro-origins.json +1 -0
  68. package/dist/backends/elf.mjs.map +1 -0
  69. package/dist/backends/managed.mjs +10616 -0
  70. package/dist/backends/managed.mjs.macro-origins.json +1 -0
  71. package/dist/backends/managed.mjs.map +1 -0
  72. package/dist/backends/memory.mjs +278 -0
  73. package/dist/backends/memory.mjs.macro-origins.json +1 -0
  74. package/dist/backends/memory.mjs.map +1 -0
  75. package/dist/backends/native.mjs +4099 -0
  76. package/dist/backends/native.mjs.macro-origins.json +1 -0
  77. package/dist/backends/native.mjs.map +1 -0
  78. package/dist/backends/numeric.mjs +2458 -0
  79. package/dist/backends/numeric.mjs.macro-origins.json +1 -0
  80. package/dist/backends/numeric.mjs.map +1 -0
  81. package/dist/backends/optimize.mjs +204 -0
  82. package/dist/backends/optimize.mjs.macro-origins.json +1 -0
  83. package/dist/backends/optimize.mjs.map +1 -0
  84. package/dist/backends/regexp.mjs +2033 -0
  85. package/dist/backends/regexp.mjs.macro-origins.json +1 -0
  86. package/dist/backends/regexp.mjs.map +1 -0
  87. package/dist/backends/sha256.mjs +310 -0
  88. package/dist/backends/sha256.mjs.macro-origins.json +1 -0
  89. package/dist/backends/sha256.mjs.map +1 -0
  90. package/dist/backends/wasm.mjs +2258 -0
  91. package/dist/backends/wasm.mjs.macro-origins.json +1 -0
  92. package/dist/backends/wasm.mjs.map +1 -0
  93. package/dist/bootstrap/analyzer.mjs +1908 -776
  94. package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
  95. package/dist/bootstrap/analyzer.mjs.map +1 -1
  96. package/dist/bootstrap/compiler.mjs +450 -142
  97. package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
  98. package/dist/bootstrap/compiler.mjs.map +1 -1
  99. package/dist/bootstrap/emitter.mjs +3083 -909
  100. package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
  101. package/dist/bootstrap/emitter.mjs.map +1 -1
  102. package/dist/bootstrap/expander.mjs +2887 -1233
  103. package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
  104. package/dist/bootstrap/expander.mjs.map +1 -1
  105. package/dist/bootstrap/formatter.mjs +582 -218
  106. package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
  107. package/dist/bootstrap/formatter.mjs.map +1 -1
  108. package/dist/bootstrap/ir.mjs +670 -116
  109. package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
  110. package/dist/bootstrap/ir.mjs.map +1 -1
  111. package/dist/bootstrap/lower.mjs +866 -257
  112. package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
  113. package/dist/bootstrap/lower.mjs.map +1 -1
  114. package/dist/bootstrap/package.json +1 -0
  115. package/dist/bootstrap/project.mjs +1168 -498
  116. package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
  117. package/dist/bootstrap/project.mjs.map +1 -1
  118. package/dist/bootstrap/reader.mjs +674 -175
  119. package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
  120. package/dist/bootstrap/reader.mjs.map +1 -1
  121. package/dist/bootstrap/runtime/math.mjs +1117 -0
  122. package/dist/bootstrap/runtime/math.mjs.map +1 -0
  123. package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
  124. package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
  125. package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
  126. package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
  127. package/dist/bootstrap/source-map.mjs +430 -119
  128. package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
  129. package/dist/bootstrap/source-map.mjs.map +1 -1
  130. package/dist/bootstrap/symbol.mjs +229 -53
  131. package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
  132. package/dist/bootstrap/symbol.mjs.map +1 -1
  133. package/dist/bootstrap/syntax.mjs +205 -7
  134. package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
  135. package/dist/bootstrap/syntax.mjs.map +1 -1
  136. package/dist/bootstrap/transient-analysis.mjs +1185 -489
  137. package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
  138. package/dist/bootstrap/transient-analysis.mjs.map +1 -1
  139. package/dist/browser/compiler.js +199 -6478
  140. package/dist/browser/host.mjs +1078 -0
  141. package/dist/browser/loader.js +1 -0
  142. package/dist/browser/loader.mjs +231 -0
  143. package/dist/browser/worker.mjs +63 -0
  144. package/dist/compiler-artifact.json +1 -0
  145. package/dist/host/compiler-session.mjs +2980 -0
  146. package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
  147. package/dist/host/compiler-session.mjs.map +1 -0
  148. package/dist/host/compiler-tools.mjs +1084 -0
  149. package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
  150. package/dist/host/compiler-tools.mjs.map +1 -0
  151. package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
  152. package/dist/literal-sources/runtime/core/collection.eli +639 -0
  153. package/dist/literal-sources/runtime/core/data-text.eli +290 -0
  154. package/dist/literal-sources/runtime/core/data.eli +22 -0
  155. package/dist/literal-sources/runtime/core/identifier.eli +44 -0
  156. package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
  157. package/dist/literal-sources/runtime/core/list.eli +19 -0
  158. package/dist/literal-sources/runtime/core/map.eli +9 -0
  159. package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
  160. package/dist/literal-sources/runtime/core/metadata.eli +40 -0
  161. package/dist/literal-sources/runtime/core/object.eli +8 -0
  162. package/dist/literal-sources/runtime/core/order.eli +123 -0
  163. package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
  164. package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
  165. package/dist/literal-sources/runtime/core/protocol.eli +28 -0
  166. package/dist/literal-sources/runtime/core/queue.eli +9 -0
  167. package/dist/literal-sources/runtime/core/record.eli +191 -0
  168. package/dist/literal-sources/runtime/core/regex.eli +158 -0
  169. package/dist/literal-sources/runtime/core/sequence.eli +305 -0
  170. package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
  171. package/dist/literal-sources/runtime/core/set.eli +9 -0
  172. package/dist/literal-sources/runtime/core/sorted.eli +408 -0
  173. package/dist/literal-sources/runtime/core/text.eli +14 -0
  174. package/dist/literal-sources/runtime/core/transducer.eli +268 -0
  175. package/dist/literal-sources/runtime/core/transient.eli +17 -0
  176. package/dist/literal-sources/runtime/core/truth.eli +4 -0
  177. package/dist/literal-sources/runtime/core/type.eli +232 -0
  178. package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
  179. package/dist/literal-sources/runtime/core/value.eli +19 -0
  180. package/dist/literal-sources/runtime/core/vector.eli +25 -0
  181. package/dist/literal-sources/runtime/literals.eli +23 -0
  182. package/dist/literal-sources/runtime/testing/value.eli +6 -0
  183. package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
  184. package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
  185. package/dist/literal-sources/runtime/wire/schema.eli +193 -0
  186. package/dist/literal-sources/stdlib/bit.eli +36 -0
  187. package/dist/literal-sources/stdlib/core/data.eli +306 -0
  188. package/dist/literal-sources/stdlib/core/object.eli +89 -0
  189. package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
  190. package/dist/literal-sources/stdlib/core/set.eli +312 -0
  191. package/dist/literal-sources/stdlib/core/text.eli +103 -0
  192. package/dist/literal-sources/stdlib/managed-literal-protocols.eli +494 -0
  193. package/dist/literal-sources/stdlib/managed-literals.eli +1469 -0
  194. package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
  195. package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
  196. package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
  197. package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
  198. package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
  199. package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
  200. package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
  201. package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
  202. package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
  203. package/dist/literal-sources/stdlib/value.eli +325 -0
  204. package/dist/package.json +10 -0
  205. package/dist/runtime/math.mjs +1116 -0
  206. package/dist/runtime/math.mjs.macro-origins.json +1 -0
  207. package/dist/runtime/math.mjs.map +1 -0
  208. package/dist/runtime/unicode-case-data.mjs +10124 -0
  209. package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
  210. package/dist/runtime/unicode-case-data.mjs.map +1 -0
  211. package/dist/runtime/unicode-case.mjs +280 -0
  212. package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
  213. package/dist/runtime/unicode-case.mjs.map +1 -0
  214. package/dist/runtime.eli +30379 -0
  215. package/dist/stage3-release.json +1 -0
  216. package/editor/README.md +1 -1
  217. package/editor/eliscript-mode.el +1 -1
  218. package/editor/eliscript-repl.el +1 -1
  219. package/package.json +106 -11
  220. package/platform/http.mjs +20 -0
  221. package/runtime/array-text.mjs +159 -0
  222. package/runtime/core/map-internals.mjs +27 -9
  223. package/runtime/core/object-impl.mjs +26 -17
  224. package/runtime/core/object-impl.mjs.map +1 -1
  225. package/runtime/core/protocol-impl.mjs +682 -255
  226. package/runtime/core/protocol-impl.mjs.map +1 -1
  227. package/runtime/core/protocol.mjs +4 -0
  228. package/runtime/core/record.mjs +23 -2
  229. package/runtime/core/regex.mjs +4 -0
  230. package/runtime/core/sorted.mjs +53 -0
  231. package/runtime/core/text-impl.mjs +167 -48
  232. package/runtime/core/text-impl.mjs.map +1 -1
  233. package/runtime/core/type.mjs +75 -3
  234. package/runtime/core/vector.mjs +6 -0
  235. package/runtime/math.eli +429 -0
  236. package/runtime/math.mjs +1116 -0
  237. package/runtime/math.mjs.map +1 -0
  238. package/runtime/number-radix.mjs +105 -0
  239. package/runtime/unicode-case-data.eli +29 -0
  240. package/runtime/unicode-case-data.mjs +10124 -0
  241. package/runtime/unicode-case-data.mjs.map +1 -0
  242. package/runtime/unicode-case.eli +100 -0
  243. package/runtime/unicode-case.mjs +280 -0
  244. package/runtime/unicode-case.mjs.map +1 -0
  245. package/runtime/wire/http-rpc.mjs +168 -0
  246. package/runtime/wire/markdown.mjs +196 -0
  247. package/runtime/wire/schema.mjs +109 -0
  248. package/stdlib/README.md +54 -0
  249. package/stdlib/core/protocol.eli +81 -17
  250. package/stdlib/core/seq.eli +1 -1
  251. package/stdlib/core/zipper.eli +172 -72
  252. package/stdlib/gepo.eli +12 -0
  253. package/stdlib/interop/js.eli +56 -15
  254. package/stdlib/managed-literal-protocols.eli +494 -0
  255. package/stdlib/managed-literals.eli +1469 -0
  256. package/stdlib/managed-protocol-error.eli +32 -0
  257. package/stdlib/managed-queue-state.eli +65 -0
  258. package/stdlib/managed-runtime-collection-internals.eli +60 -0
  259. package/stdlib/managed-runtime-collection.eli +639 -0
  260. package/stdlib/managed-runtime-data-text.eli +290 -0
  261. package/stdlib/managed-runtime-data.eli +22 -0
  262. package/stdlib/managed-runtime-identifier.eli +44 -0
  263. package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
  264. package/stdlib/managed-runtime-list.eli +19 -0
  265. package/stdlib/managed-runtime-literals.eli +23 -0
  266. package/stdlib/managed-runtime-map.eli +9 -0
  267. package/stdlib/managed-runtime-metadata-internals.eli +6 -0
  268. package/stdlib/managed-runtime-metadata.eli +40 -0
  269. package/stdlib/managed-runtime-object.eli +8 -0
  270. package/stdlib/managed-runtime-order.eli +123 -0
  271. package/stdlib/managed-runtime-persistent-kind.eli +28 -0
  272. package/stdlib/managed-runtime-protocol.eli +28 -0
  273. package/stdlib/managed-runtime-queue.eli +9 -0
  274. package/stdlib/managed-runtime-record.eli +191 -0
  275. package/stdlib/managed-runtime-regex.eli +158 -0
  276. package/stdlib/managed-runtime-sequence.eli +305 -0
  277. package/stdlib/managed-runtime-set-algebra.eli +28 -0
  278. package/stdlib/managed-runtime-set.eli +9 -0
  279. package/stdlib/managed-runtime-sorted.eli +408 -0
  280. package/stdlib/managed-runtime-text.eli +14 -0
  281. package/stdlib/managed-runtime-transducer.eli +268 -0
  282. package/stdlib/managed-runtime-transient.eli +17 -0
  283. package/stdlib/managed-runtime-truth.eli +4 -0
  284. package/stdlib/managed-runtime-type.eli +232 -0
  285. package/stdlib/managed-runtime-value-internals.eli +13 -0
  286. package/stdlib/managed-runtime-value.eli +19 -0
  287. package/stdlib/managed-runtime-vector.eli +25 -0
  288. package/stdlib/managed-sorted-state.eli +233 -0
  289. package/stdlib/managed-testing-value.eli +6 -0
  290. package/stdlib/managed-transient-state.eli +348 -0
  291. package/stdlib/managed-value-state.eli +153 -0
  292. package/stdlib/managed-vector-view-state.eli +102 -0
  293. package/stdlib/managed-wire-http-rpc.eli +362 -0
  294. package/stdlib/managed-wire-markdown.eli +275 -0
  295. package/stdlib/managed-wire-schema.eli +193 -0
  296. package/stdlib/mdp.eli +7 -0
  297. package/stdlib/mds.eli +4 -0
  298. package/stdlib/persistent-vector.eli +23 -6
  299. package/tools/acceptance/check-legacy.mjs +687 -0
  300. package/tools/acceptance/check.eli +431 -0
  301. package/tools/acceptance/compile-evidence.el +49 -0
  302. package/tools/acceptance/finalize-legacy.mjs +498 -0
  303. package/tools/acceptance/finalize.eli +270 -0
  304. package/tools/backends/benchmark.mjs +175 -0
  305. package/tools/backends/build.mjs +135 -0
  306. package/tools/backends/compile.mjs +94 -0
  307. package/tools/backends/compiler-bootstrap.mjs +1001 -0
  308. package/tools/backends/compiler-browser.mjs +361 -0
  309. package/tools/backends/compiler-build.mjs +1628 -0
  310. package/tools/backends/compiler-cli-legacy.mjs +334 -0
  311. package/tools/backends/compiler-cli.mjs +29 -0
  312. package/tools/backends/compiler-corpus-bit.mjs +234 -0
  313. package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
  314. package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
  315. package/tools/backends/compiler-corpus-debugging.mjs +221 -0
  316. package/tools/backends/compiler-corpus-emitter.mjs +324 -0
  317. package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
  318. package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
  319. package/tools/backends/compiler-corpus-execution.mjs +3324 -0
  320. package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
  321. package/tools/backends/compiler-corpus-generations.mjs +208 -0
  322. package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
  323. package/tools/backends/compiler-corpus-host-context.mjs +550 -0
  324. package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
  325. package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
  326. package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
  327. package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
  328. package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
  329. package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
  330. package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
  331. package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
  332. package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
  333. package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
  334. package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
  335. package/tools/backends/compiler-corpus-matchers.mjs +173 -0
  336. package/tools/backends/compiler-corpus-original-program.mjs +612 -0
  337. package/tools/backends/compiler-corpus-process.mjs +765 -0
  338. package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
  339. package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
  340. package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
  341. package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
  342. package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
  343. package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
  344. package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
  345. package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
  346. package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
  347. package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
  348. package/tools/backends/compiler-corpus-reference.mjs +241 -0
  349. package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
  350. package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
  351. package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
  352. package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
  353. package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
  354. package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
  355. package/tools/backends/compiler-corpus.mjs +2054 -0
  356. package/tools/backends/compiler-debug.mjs +142 -0
  357. package/tools/backends/compiler-matrix.mjs +1955 -0
  358. package/tools/backends/compiler-metadata.mjs +203 -0
  359. package/tools/backends/compiler-package-browser.mjs +120 -0
  360. package/tools/backends/compiler-package-legacy.mjs +654 -0
  361. package/tools/backends/compiler-package.mjs +464 -0
  362. package/tools/backends/compiler-project.mjs +126 -0
  363. package/tools/backends/compiler-session.mjs +843 -0
  364. package/tools/backends/compiler-sha256.mjs +152 -0
  365. package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
  366. package/tools/backends/compiler-worker.mjs +573 -0
  367. package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
  368. package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
  369. package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
  370. package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
  371. package/tools/backends/dist/record-grid.mjs +1256 -0
  372. package/tools/backends/dist/record-grid.mjs.map +1 -0
  373. package/tools/backends/dist/release-cli.mjs +462 -0
  374. package/tools/backends/dist/release-cli.mjs.map +1 -0
  375. package/tools/backends/dist/run-artifact.mjs +517 -0
  376. package/tools/backends/dist/run-artifact.mjs.map +1 -0
  377. package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
  378. package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
  379. package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
  380. package/tools/backends/managed-foreign-binding.mjs +497 -0
  381. package/tools/backends/managed-host-legacy.mjs +1181 -0
  382. package/tools/backends/managed-host-lifecycle.mjs +310 -0
  383. package/tools/backends/managed-host-object-provider.mjs +155 -0
  384. package/tools/backends/managed-host-object-realm.mjs +797 -0
  385. package/tools/backends/managed-host-proxy.mjs +71 -0
  386. package/tools/backends/managed-host-runtime.mjs +5868 -0
  387. package/tools/backends/managed-host.mjs +716 -0
  388. package/tools/backends/managed-module-graph-legacy.mjs +308 -0
  389. package/tools/backends/managed-module-graph.mjs +694 -0
  390. package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
  391. package/tools/backends/managed-runtime.mjs +939 -0
  392. package/tools/backends/managed-source-view-legacy.mjs +332 -0
  393. package/tools/backends/managed-source-view.mjs +959 -0
  394. package/tools/backends/memory-runtime.mjs +100 -0
  395. package/tools/backends/native-benchmark.mjs +88 -0
  396. package/tools/backends/native-managed-runtime.mjs +677 -0
  397. package/tools/backends/native-memory.mjs +768 -0
  398. package/tools/backends/native-node-memory.mjs +142 -0
  399. package/tools/backends/native-node-runner.mjs +99 -0
  400. package/tools/backends/native-node-watchdog.mjs +19 -0
  401. package/tools/backends/native-node-worker.mjs +75 -0
  402. package/tools/backends/stage3-targets.mjs +493 -0
  403. package/tools/bootstrap-command.el +13 -0
  404. package/tools/bootstrap-runtime.el +101 -0
  405. package/tools/bootstrap-seed.el +55 -0
  406. package/tools/project/check-cli.eli +31 -0
  407. package/tools/project/project-cli.eli +42 -0
  408. package/tools/project/project.eli +122 -0
  409. package/tools/runtime/unicode-case-profiles.mjs +13 -0
  410. package/tools/runtime/unicode-case-runtime.el +57 -0
  411. package/tools/testing/source-debugging-corpus-host.eli +16 -0
  412. package/tools/testing/source-debugging.eli +139 -0
  413. package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
  414. package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
  415. package/tools/testing/stdlib-bit.eli +104 -0
  416. package/tools/testing/stdlib-bit.mjs +255 -0
  417. package/bin/eliscript-bootstrap +0 -15
@@ -0,0 +1,196 @@
1
+ const own = (value, key) => Object.hasOwn(value, key);
2
+ const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
3
+ const put = (target, key, value) => Object.defineProperty(target, key, { value, writable: true, enumerable: true, configurable: true });
4
+ const number = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/u;
5
+
6
+ export class MarkdownError extends Error {
7
+ constructor(code, line, message) { super(`${code} at line ${line}: ${message}`); this.name = 'MarkdownError'; this.code = code; this.line = line; }
8
+ }
9
+ const fail = (code, line, message) => { throw new MarkdownError(code, line, message); };
10
+
11
+ function scalar(text) {
12
+ if (text.startsWith('"') && text.endsWith('"') && text.length >= 2)
13
+ return text.slice(1, -1).replace(/\\(["\\ntr])/gu, (_, c) => ({ n: '\n', t: '\t', r: '\r' }[c] ?? c));
14
+ if (number.test(text)) {
15
+ const value = Number(text);
16
+ if (!Number.isFinite(value)) throw new RangeError('Number exceeds finite IEEE 754 range');
17
+ return value;
18
+ }
19
+ if (text === 'true') return true;
20
+ if (text === 'false') return false;
21
+ if (text === 'null' || text === '') return null;
22
+ if (text === '{}') return {};
23
+ if (text === '[]') return [];
24
+ return text;
25
+ }
26
+
27
+ function cells(text) {
28
+ const result = []; let cell = '';
29
+ for (let i = 1; i < text.length - 1; i++) {
30
+ if (text[i] === '\\' && text[i + 1] === '|') { cell += '|'; i++; }
31
+ else if (text[i] === '|') { result.push(cell.trim()); cell = ''; }
32
+ else cell += text[i];
33
+ }
34
+ result.push(cell.trim()); return result;
35
+ }
36
+
37
+ function tokenize(source) {
38
+ const lines = source.replace(/^\uFEFF/u, '').split(/\r\n?|\n/u);
39
+ const tokens = []; let fence = null; let html = null;
40
+ for (let i = 0; i < lines.length; i++) {
41
+ const raw = lines[i], text = raw.trim(), line = i + 1;
42
+ if (fence) { if (new RegExp(`^ {0,3}${fence.char}{${fence.size},}\\s*$`, 'u').test(raw)) fence = null; continue; }
43
+ if (html) { if (html === 'blank' ? text === '' : html.test(raw)) html = null; continue; }
44
+ const fenced = raw.match(/^ {0,3}(`{3,}|~{3,})/u);
45
+ if (fenced) { fence = { char: fenced[1][0], size: fenced[1].length }; continue; }
46
+ if (/^ {0,3}<!--/u.test(raw)) { if (!raw.includes('-->')) html = /-->/u; continue; }
47
+ const special = raw.match(/^ {0,3}<(script|pre|style|textarea)(?:\s|>)/iu);
48
+ if (special) { const end = new RegExp(`</${special[1]}>`, 'iu'); if (!end.test(raw)) html = end; continue; }
49
+ if (/^ {0,3}<\?/u.test(raw)) { if (!raw.includes('?>')) html = /\?>/u; continue; }
50
+ if (/^ {0,3}<!\[CDATA\[/u.test(raw)) { if (!raw.includes(']]>')) html = /\]\]>/u; continue; }
51
+ if (/^ {0,3}<![A-Z]/u.test(raw)) { if (!raw.includes('>')) html = />/u; continue; }
52
+ const blockTag = /^ {0,3}<\/?(?:address|article|aside|base|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(?:\s|\/?>)/iu;
53
+ if (blockTag.test(raw) || /^ {0,3}<\/?[A-Za-z][\w-]*(?:\s[^>]*|\/?)>\s*$/u.test(raw)) { html = 'blank'; continue; }
54
+ const heading = raw.match(/^ {0,3}(#{1,2})(?:[ \t]+(.*)|$)/u);
55
+ if (heading) {
56
+ const title = (heading[2] ?? '').replace(/(?:^|\s+)#+\s*$/u, '').trim();
57
+ if (!title) fail('MDP-E007', line, 'Empty heading');
58
+ tokens.push({ kind: 'heading', level: heading[1].length, title, line }); continue;
59
+ }
60
+ const field = text.match(/^-\s+([^]*?):(?: (.*)|\s*)$/u);
61
+ const pipe = text.startsWith('|') && text.endsWith('|') && text.length > 1;
62
+ if (!field && !pipe) continue;
63
+ const leading = raw.match(/^\s*/u)[0];
64
+ if (leading.includes('\t')) fail('MDP-E009', line, 'Tab indentation');
65
+ const level = Math.floor(leading.length / 2);
66
+ if (field) { tokens.push({ kind: 'field', key: field[1].trim(), text: (field[2] ?? '').trim(), level, line }); continue; }
67
+ if (i + 1 >= lines.length || !lines[i + 1].trim().startsWith('|') || !lines[i + 1].trim().endsWith('|')) continue;
68
+ const separator = cells(lines[i + 1].trim());
69
+ if (!separator.every(c => /^:?-+:?$/u.test(c))) continue;
70
+ if (lines[i + 1].match(/^\s*/u)[0].includes('\t')) fail('MDP-E009', line + 1, 'Tab indentation');
71
+ const headers = cells(text);
72
+ if (headers.some(h => !h) || new Set(headers).size !== headers.length) fail('MDP-E005', line, 'Invalid table header');
73
+ if (separator.length !== headers.length) fail('MDP-E004', line + 1, 'Separator width');
74
+ const rows = []; i++;
75
+ while (i + 1 < lines.length && /^\s*\|.*\|\s*$/u.test(lines[i + 1])) {
76
+ if (lines[i + 1].match(/^\s*/u)[0].includes('\t')) fail('MDP-E009', i + 2, 'Tab indentation');
77
+ const row = cells(lines[++i].trim());
78
+ if (row.length !== headers.length) fail('MDP-E004', i + 1, 'Row width');
79
+ if (headers.length === 1) rows.push(scalar(row[0]));
80
+ else { const value = {}; row.forEach((c, j) => { if (c !== '') put(value, headers[j], scalar(c)); }); rows.push(value); }
81
+ }
82
+ tokens.push({ kind: 'table', value: rows, level, line });
83
+ }
84
+ return tokens;
85
+ }
86
+
87
+ export function parse(source, options = {}) {
88
+ const { maxLength = 16777216, maxDepth = 256 } = options;
89
+ if (typeof source !== 'string') throw new TypeError('Markdown source must be a string');
90
+ if (!Number.isSafeInteger(maxLength) || maxLength < 1 || !Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 512) throw new RangeError('Invalid parser limits');
91
+ if (source.length > maxLength) throw new RangeError('Markdown length limit');
92
+ const tokens = tokenize(source); let cursor = 0;
93
+ function block(level, root = false) {
94
+ if (level > maxDepth) throw new RangeError('Markdown depth limit');
95
+ let value = {}, mode = 'object', populated = false;
96
+ while (cursor < tokens.length) {
97
+ const token = tokens[cursor];
98
+ if (token.kind === 'heading' || token.level < level) break;
99
+ if (token.level > level && !(token.kind === 'table' && level === 0 && token.level <= 1))
100
+ fail(token.kind === 'table' || token.key === '' ? 'MDP-E006' : 'MDP-E009', token.line, 'Unattached indentation');
101
+ cursor++;
102
+ if (token.kind === 'table') {
103
+ if (root) fail('MDP-E006', token.line, 'Root table');
104
+ if (populated) fail('MDP-E002', token.line, 'Mixed contents');
105
+ value = token.value; mode = 'table'; populated = true; continue;
106
+ }
107
+ const element = token.key === '';
108
+ if (element && root) fail('MDP-E006', token.line, 'Root element');
109
+ if (mode === 'table' || (populated && element !== (mode === 'elements'))) fail('MDP-E002', token.line, 'Mixed contents');
110
+ if (element && !populated) { value = []; mode = 'elements'; }
111
+ if (!element && own(value, token.key)) fail('MDP-E003', token.line, 'Duplicate key');
112
+ let child = scalar(token.text);
113
+ const next = tokens[cursor];
114
+ if (next && next.kind !== 'heading' && next.level > level) {
115
+ if (next.level !== level + 1 || token.text !== '') fail(next.kind === 'table' ? 'MDP-E006' : 'MDP-E009', next.line, 'Child requires a container');
116
+ child = block(level + 1);
117
+ }
118
+ if (element) value.push(child); else put(value, token.key, child);
119
+ populated = true;
120
+ }
121
+ return value;
122
+ }
123
+ const result = block(0, true); let current = null;
124
+ while (cursor < tokens.length) {
125
+ const token = tokens[cursor++];
126
+ if (token.level === 1) {
127
+ if (own(result, token.title)) fail('MDP-E003', token.line, 'Duplicate section');
128
+ current = block(0); put(result, token.title, current);
129
+ } else {
130
+ if (current === null) fail('MDP-E001', token.line, 'Orphan heading');
131
+ if (Array.isArray(current)) fail('MDP-E002', token.line, 'Table with subsection');
132
+ if (own(current, token.title)) fail('MDP-E003', token.line, 'Duplicate subsection');
133
+ put(current, token.title, block(0));
134
+ }
135
+ }
136
+ return result;
137
+ }
138
+
139
+ function atom(value) {
140
+ if (value === null) return 'null';
141
+ if (typeof value === 'string') {
142
+ return value === '' || value.trim() !== value || /[\n\r\t]/u.test(value) || number.test(value) || ['true', 'false', 'null', '{}', '[]'].includes(value) || (value.startsWith('"') && value.endsWith('"'))
143
+ ? '"' + value.replace(/["\\\n\r\t]/gu, c => ({ '"': '\\"', '\\': '\\\\', '\n': '\\n', '\r': '\\r', '\t': '\\t' }[c])) + '"' : value;
144
+ }
145
+ if (typeof value === 'boolean' || (typeof value === 'number' && Number.isFinite(value))) return String(value);
146
+ if (Array.isArray(value) && value.length === 0) return '[]';
147
+ if (object(value) && [Object.prototype, null].includes(Object.getPrototypeOf(value)) && Object.keys(value).length === 0) return '{}';
148
+ throw new TypeError('Expected a finite JSON scalar');
149
+ }
150
+ const leaf = value => value === null || typeof value !== 'object' || (Array.isArray(value) ? value.length === 0 : Object.keys(value).length === 0);
151
+ function keyText(key, heading = false) {
152
+ if (!key || key.trim() !== key || /[\r\n\t]/u.test(key) || (heading ? /\s#+$/u.test(key) : /: /u.test(key))) throw new TypeError('Unrepresentable Markdown key');
153
+ return key;
154
+ }
155
+
156
+ export function encode(value, options = {}) {
157
+ const { maxDepth = 256, maxLength = 16777216 } = options;
158
+ if (!object(value) || ![Object.prototype, null].includes(Object.getPrototypeOf(value))) throw new TypeError('Markdown document must be a plain object');
159
+ if (!Number.isSafeInteger(maxDepth) || maxDepth < 0 || maxDepth > 512 || !Number.isSafeInteger(maxLength) || maxLength < 1) throw new RangeError('Invalid encoder limits');
160
+ const active = new Set();
161
+ function body(data, depth) {
162
+ if (depth > maxDepth) throw new RangeError('Markdown depth limit');
163
+ if (active.has(data)) throw new TypeError('Cyclic Markdown value');
164
+ active.add(data); const pad = ' '.repeat(depth); let lines = [];
165
+ if (Array.isArray(data)) {
166
+ for (let i = 0; i < data.length; i++) if (!own(data, i)) throw new TypeError('Sparse arrays are not JSON values');
167
+ if (data.every(v => leaf(v))) lines = [`${pad}| value |`, `${pad}| --- |`, ...data.map(v => `${pad}| ${atom(v).replaceAll('|', '\\|')} |`)];
168
+ else {
169
+ const keys = [...new Set(data.flatMap(v => object(v) ? Object.keys(v) : []))];
170
+ if (keys.length > 1 && data.every(v => object(v) && Object.values(v).every(leaf))) {
171
+ const row = values => `${pad}| ${values.join(' | ')} |`;
172
+ const cell = v => atom(v).replaceAll('|', '\\|');
173
+ lines = [row(keys.map(k => keyText(k).replaceAll('|', '\\|'))), row(keys.map(() => '---')), ...data.map(v => row(keys.map(k => own(v, k) ? cell(v[k]) : '')))];
174
+ } else for (const child of data) {
175
+ if (leaf(child)) lines.push(`${pad}- : ${atom(child)}`);
176
+ else lines.push(`${pad}- :`, ...body(child, depth + 1));
177
+ }
178
+ }
179
+ } else if (object(data)) {
180
+ if (Object.getPrototypeOf(data) !== Object.prototype && Object.getPrototypeOf(data) !== null) throw new TypeError('Expected plain JSON object');
181
+ for (const [key, child] of Object.entries(data)) {
182
+ if (leaf(child)) lines.push(`${pad}- ${keyText(key)}: ${atom(child)}`);
183
+ else lines.push(`${pad}- ${keyText(key)}:`, ...body(child, depth + 1));
184
+ }
185
+ } else throw new TypeError('Expected JSON container');
186
+ active.delete(data); return lines;
187
+ }
188
+ active.add(value); const preamble = [], sections = [];
189
+ for (const [key, child] of Object.entries(value)) {
190
+ if (leaf(child)) preamble.push(`- ${keyText(key)}: ${atom(child)}`);
191
+ else sections.push(`# ${keyText(key, true)}\n\n${body(child, 0).join('\n')}`);
192
+ }
193
+ const output = [...(preamble.length ? [preamble.join('\n')] : []), ...sections].join('\n\n') + '\n';
194
+ if (output.length > maxLength) throw new RangeError('Markdown length limit');
195
+ return output;
196
+ }
@@ -0,0 +1,109 @@
1
+ import { parse } from './markdown.mjs';
2
+
3
+ const own = (value, key) => Object.hasOwn(value, key);
4
+ const object = value => value !== null && typeof value === 'object' && !Array.isArray(value);
5
+ const types = new Set(['any', 'string', 'int', 'float', 'number', 'bool', 'null', 'date', 'datetime']);
6
+ const reserved = new Set(['Preamble', 'Sections']);
7
+ function at(document, path) {
8
+ let value = document;
9
+ for (const part of path.split('.')) {
10
+ if (!object(value) || !own(value, part)) return undefined;
11
+ value = value[part];
12
+ }
13
+ return value;
14
+ }
15
+ function date(value) {
16
+ if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/u.test(value)) return false;
17
+ const parsed = new Date(`${value}T00:00:00Z`);
18
+ return Number.isFinite(parsed.getTime()) && parsed.toISOString().slice(0, 10) === value;
19
+ }
20
+ function typed(value, type) {
21
+ switch (type) {
22
+ case 'any': return true;
23
+ case 'string': return typeof value === 'string';
24
+ case 'int': return Number.isFinite(value) && Number.isInteger(value);
25
+ case 'float': case 'number': return typeof value === 'number' && Number.isFinite(value);
26
+ case 'bool': return typeof value === 'boolean';
27
+ case 'null': return value === null;
28
+ case 'date': return date(value);
29
+ case 'datetime': return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/u.test(value) && date(value.slice(0, 10)) && Number.isFinite(Date.parse(value));
30
+ }
31
+ }
32
+
33
+ export function validate(data, schema) {
34
+ if (typeof data === 'string') data = parse(data);
35
+ if (typeof schema === 'string') schema = parse(schema);
36
+ if (!object(data) || !object(schema) || schema.mds !== '0.1') throw new TypeError('Expected object data and an MDS/0.1 schema');
37
+ for (const [name, value] of Object.entries(schema)) {
38
+ if (!reserved.has(name) && object(value)) throw new TypeError('Schema field definition must be a table');
39
+ }
40
+ const definitions = Object.keys(schema).filter(k => !reserved.has(k) && Array.isArray(schema[k]));
41
+ const fields = new Map();
42
+ for (const name of [...definitions, ...(own(schema, 'Preamble') ? ['Preamble'] : [])]) {
43
+ const rows = schema[name];
44
+ if (!Array.isArray(rows)) throw new TypeError('Schema field definition must be a table');
45
+ const seen = new Set();
46
+ fields.set(name, rows.map(row => {
47
+ if (!object(row) || typeof row.name !== 'string' || !row.name || !types.has(row.type) || seen.has(row.name)) throw new TypeError('Invalid schema field declaration');
48
+ seen.add(row.name);
49
+ if (own(row, 'required') && typeof row.required !== 'boolean') throw new TypeError('required must be boolean');
50
+ for (const key of ['min', 'max', 'min_len', 'max_len']) if (own(row, key) && (typeof row[key] !== 'number' || !Number.isFinite(row[key]) || (key.endsWith('_len') && (!Number.isInteger(row[key]) || row[key] < 0)))) throw new TypeError(`Invalid ${key} constraint`);
51
+ if ((row.min !== undefined && row.max !== undefined && row.min > row.max) || (row.min_len !== undefined && row.max_len !== undefined && row.min_len > row.max_len)) throw new TypeError('Inverted field bounds');
52
+ if (own(row, 'enum') && typeof row.enum !== 'string') throw new TypeError('enum must be text');
53
+ let pattern;
54
+ if (own(row, 'pattern')) {
55
+ if (typeof row.pattern !== 'string') throw new TypeError('pattern must be text');
56
+ pattern = new RegExp(row.pattern, 'u');
57
+ }
58
+ return { ...row, pattern };
59
+ }));
60
+ }
61
+ let declarations;
62
+ if (own(schema, 'Sections')) {
63
+ if (!Array.isArray(schema.Sections)) throw new TypeError('Sections must be a table');
64
+ declarations = schema.Sections;
65
+ } else declarations = definitions.map(name => ({ name, required: true }));
66
+ const declared = new Map();
67
+ for (const row of declarations) {
68
+ if (!object(row) || typeof row.name !== 'string' || !row.name || row.name.split('.').some(p => !p) || declared.has(row.name) || !['object', 'list', 'any'].includes(row.kind ?? 'any')) throw new TypeError('Invalid section declaration');
69
+ for (const key of ['required', 'additional']) if (own(row, key) && typeof row[key] !== 'boolean') throw new TypeError(`${key} must be boolean`);
70
+ for (const key of ['min_rows', 'max_rows']) if (own(row, key) && (!Number.isSafeInteger(row[key]) || row[key] < 0)) throw new TypeError(`Invalid ${key} constraint`);
71
+ if (row.min_rows !== undefined && row.max_rows !== undefined && row.min_rows > row.max_rows) throw new TypeError('Inverted row bounds');
72
+ declared.set(row.name, row);
73
+ }
74
+ const errors = [];
75
+ const error = (path, rule, expected, actual) => errors.push({ path, rule, expected, actual });
76
+ function checkRow(value, rows, path, additional = true) {
77
+ if (!object(value)) { error(path, 'kind', 'object', value); return; }
78
+ for (const row of rows) {
79
+ const fieldPath = `${path}.${row.name}`;
80
+ if (!own(value, row.name)) { if (row.required) error(fieldPath, 'required', true, 'missing'); continue; }
81
+ const actual = value[row.name];
82
+ if (!typed(actual, row.type)) { error(fieldPath, 'type', row.type, actual); continue; }
83
+ if (row.enum !== undefined && !row.enum.split(',').map(v => v.trim()).includes(String(actual))) error(fieldPath, 'enum', row.enum, actual);
84
+ for (const key of ['min', 'max']) if (typeof actual === 'number' && row[key] !== undefined && (key === 'min' ? actual < row[key] : actual > row[key])) error(fieldPath, key, row[key], actual);
85
+ if (typeof actual === 'string') {
86
+ const length = [...actual].length;
87
+ for (const key of ['min_len', 'max_len']) if (row[key] !== undefined && (key === 'min_len' ? length < row[key] : length > row[key])) error(fieldPath, key, row[key], length);
88
+ if (row.pattern && !row.pattern.test(actual)) error(fieldPath, 'pattern', row.pattern.source, actual);
89
+ }
90
+ }
91
+ if (!additional) {
92
+ const allowed = new Set(rows.map(r => r.name));
93
+ for (const key of Object.keys(value)) if (!allowed.has(key) && (value[key] === null || typeof value[key] !== 'object')) error(`${path}.${key}`, 'additional', false, value[key]);
94
+ }
95
+ }
96
+ if (fields.has('Preamble')) checkRow(data, fields.get('Preamble'), 'preamble');
97
+ for (const name of new Set([...definitions, ...declared.keys()])) {
98
+ const policy = declared.get(name) ?? {};
99
+ const value = at(data, name);
100
+ if (value === undefined) { if (policy.required) error(name, 'required', true, 'missing'); continue; }
101
+ const kind = Array.isArray(value) ? 'list' : object(value) ? 'object' : 'scalar';
102
+ if (policy.kind && policy.kind !== 'any' && policy.kind !== kind) { error(name, 'kind', policy.kind, kind); continue; }
103
+ if (Array.isArray(value)) {
104
+ for (const key of ['min_rows', 'max_rows']) if (policy[key] !== undefined && (key === 'min_rows' ? value.length < policy[key] : value.length > policy[key])) error(name, key, policy[key], value.length);
105
+ if (fields.has(name)) value.forEach((row, i) => checkRow(row, fields.get(name), `${name}[${i}]`, policy.additional));
106
+ } else if (fields.has(name)) checkRow(value, fields.get(name), name, policy.additional);
107
+ }
108
+ return { valid: errors.length === 0, errors };
109
+ }
package/stdlib/README.md CHANGED
@@ -772,3 +772,57 @@ The Emacs indexing workload imports `count-by` from this module. Its portable
772
772
  project build follows the dependency into `object.eli`, emits only `count-by`,
773
773
  `assoc`, and `has?`, and executes the resulting graph in the worker. See
774
774
  [specs/0029-portable-indexing-composition.md](../specs/0029-portable-indexing-composition.md).
775
+
776
+ ## Markdown wire data and HTTP RPC
777
+
778
+ Import the wire libraries directly from Eliscript:
779
+
780
+ ```elisp
781
+ (import "./stdlib/mdp.eli" mdp-parse mdp-encode)
782
+ (import "./stdlib/mds.eli" mds-validate)
783
+ (import "./stdlib/gepo.eli" gepo-client gepo-service gepo-operation)
784
+
785
+ (defconst data (mdp-parse "# User\n- name: Ada\n- age: 42\n"))
786
+ (defconst wire (mdp-encode data))
787
+ (defconst report
788
+ (mds-validate data
789
+ "- mds: \"0.1\"\n# User\n| name | type | required |\n| --- | --- | --- |\n| age | int | true |\n"))
790
+ ```
791
+
792
+ The MDP boundary uses native JSON objects and arrays. Parsing throws structural
793
+ errors with `code` and one-based `line`; encoding preserves nested and mixed
794
+ arrays and rejects unsupported values. Optional `maxLength` and `maxDepth`
795
+ bound document size and nesting. Numbers use finite IEEE 754 doubles.
796
+ MDS validation accepts objects or Markdown text and returns `{valid, errors}`;
797
+ error records include path, rule, expected and actual. Schema patterns use
798
+ ECMAScript Unicode regular expressions and should come from trusted schemas.
799
+
800
+ `gepo-service` accepts an options object with `operations` and returns a Fetch
801
+ request handler for GEPO 0.2. Each operation supplies `path` and an `execute`
802
+ callback that returns a Fetch Response. Its optional title, summary, request,
803
+ success, failures, effect, retry and contentType describe current usage.
804
+ `visible` filters discoverable operations, and `authorize` checks requests
805
+ independently. Both default to public access. The host provides the listener.
806
+
807
+ `gepo-client` returns async `discover(url)`, `index(url)`, `usage(url)`, and
808
+ `invoke(url, body, options)` methods. Invocation requires an explicit body and
809
+ `allowPost: true`, reads successful same-path usage first, then sends one POST.
810
+ For example, call the client from an async Eliscript function:
811
+
812
+ ```elisp
813
+ (defasync invoke-echo (url data)
814
+ (let* ((client (gepo-client))
815
+ (reply (await (js-call client :invoke url (mdp-encode data)
816
+ (js-object :allowPost t
817
+ :contentType "text/markdown; variant=mdp")))))
818
+ (mdp-parse (get reply "body"))))
819
+ ```
820
+
821
+ Options include custom fetch and classifier, headers, timeoutMs and maxBytes;
822
+ request options include signal, headers and contentType. Discovery distinguishes
823
+ found, empty and not-found. The default textual classifier handles Markdown and
824
+ plain-text indexes; other representations use the classifier callback. Clients
825
+ reject URL credentials and redirects and do not automatically retry POST.
826
+
827
+ See [the wire contract](../specs/0181-markdown-wire-and-http-rpc.md) for the
828
+ complete API and local verification scenarios.
@@ -1,8 +1,11 @@
1
1
  (module eliscript.core.protocol
2
2
  (import "../../runtime/core/protocol-error.mjs" ProtocolDispatchError)
3
3
 
4
- (defconst protocol-states (js* "new WeakMap()"))
5
- (defconst protocol-missing (js* "Symbol(\"eliscript.protocol.missing\")"))
4
+ (defconst protocol-states (new globalThis/WeakMap))
5
+ (defconst protocol-operation-owners (new globalThis/WeakMap))
6
+ (defconst protocol-method-owners (new globalThis/WeakMap))
7
+ (defconst protocol-missing
8
+ (funcall globalThis/Symbol "eliscript.protocol.missing"))
6
9
  (defconst protocol-host-categories
7
10
  (js-array "null" "undefined" "boolean" "number" "bigint" "string"
8
11
  "symbol" "function" "object"))
@@ -12,29 +15,48 @@
12
15
 
13
16
  ;; These capabilities isolate host reflection from dispatch policy. They are
14
17
  ;; deliberately private and contain no protocol-specific decisions.
15
- (defconst protocol-symbol (js* "(description) => Symbol(description)"))
18
+ (defconst protocol-symbol
19
+ (lambda (description) (funcall globalThis/Symbol description)))
16
20
  (defconst protocol-array? (js* "Array.isArray"))
17
- (defconst protocol-map (js* "() => new Map()"))
18
- (defconst protocol-null-object (js* "() => Object.create(null)"))
21
+ (defconst protocol-map (lambda () (new globalThis/Map)))
22
+ (defconst protocol-null-object
23
+ (lambda () (js-call globalThis/Object :create nil)))
19
24
  (defconst protocol-own-descriptors
20
25
  (js* "Object.getOwnPropertyDescriptors"))
21
26
  (defconst protocol-own-keys (js* "Reflect.ownKeys"))
22
27
  (defconst protocol-has-own
23
- (js* "(value, key) => Object.prototype.hasOwnProperty.call(value, key)"))
28
+ (lambda (value key)
29
+ (js-call (aref (aref globalThis/Object "prototype") "hasOwnProperty")
30
+ :call value key)))
24
31
  (defconst protocol-property-present
25
- (js* "(value, key) => { if (value === null || value === undefined) return false; return Reflect.has(Object(value), key); }"))
32
+ (lambda (value key)
33
+ (if (or (nil? value) (undefined? value))
34
+ false
35
+ (js-call globalThis/Reflect :has (funcall globalThis/Object value) key))))
26
36
  (defconst protocol-property-value
27
- (js* "(value, key) => Object(value)[key]"))
28
- (defconst protocol-host-type (js* "(value) => typeof value"))
37
+ (lambda (value key) (aref (funcall globalThis/Object value) key)))
38
+ (defconst protocol-host-type (lambda (value) (js* "typeof value")))
29
39
  (defconst protocol-exact-prototype
30
- (js* "(value, missing) => ((typeof value === \"object\" && value !== null) || typeof value === \"function\") ? Object.getPrototypeOf(value) : missing"))
40
+ (lambda (value missing)
41
+ (if (or (and (= (js* "typeof value") "object") (not (nil? value)))
42
+ (= (js* "typeof value") "function"))
43
+ (js-call globalThis/Object :getPrototypeOf value)
44
+ missing)))
31
45
  (defconst protocol-object-prototype (js* "Object.prototype"))
32
46
  (defconst protocol-get-prototype (js* "Object.getPrototypeOf"))
33
47
  (defconst protocol-freeze (js* "Object.freeze"))
34
48
  (defconst protocol-define-enumerable
35
- (js* "(target, key, value) => { Object.defineProperty(target, key, { value, enumerable: true }); return target; }"))
49
+ (lambda (target key value)
50
+ (js-call globalThis/Object :defineProperty target key
51
+ (js-object :value value :enumerable t))
52
+ target))
36
53
  (defconst protocol-define-metadata
37
- (js* "(target, protocol, operation, slot) => { Object.defineProperties(target, { protocol: { value: protocol }, operation: { value: operation }, slot: { value: slot } }); return target; }"))
54
+ (lambda (target protocol operation slot)
55
+ (js-call globalThis/Object :defineProperties target
56
+ (js-object :protocol (js-object :value protocol)
57
+ :operation (js-object :value operation)
58
+ :slot (js-object :value slot)))
59
+ target))
38
60
 
39
61
  (defun protocol-fail (message)
40
62
  (throw (new globalThis/TypeError message)))
@@ -236,7 +258,7 @@
236
258
  (new ProtocolDispatchError protocol (get record :name) receiver))
237
259
  (apply external (js-cons receiver arguments)))))))
238
260
 
239
- (defun define-protocol (name operations)
261
+ (defun make-protocol-with-slots (name operations slots)
240
262
  (let ((protocol-name (normalize-name name "protocol name"))
241
263
  (protocol-operations (normalize-protocol-operations operations)))
242
264
  (let ((records (funcall protocol-map))
@@ -251,9 +273,10 @@
251
273
  (str "protocol " protocol-name
252
274
  " declares duplicate operation " operation)))
253
275
  (let* ((slot
254
- (funcall protocol-symbol
255
- (str "eliscript.protocol."
256
- protocol-name "/" operation)))
276
+ (if (nil? slots)
277
+ (funcall protocol-symbol
278
+ (str "eliscript.protocol." protocol-name "/" operation))
279
+ (get slots index)))
257
280
  (method
258
281
  (lambda (&rest invocation)
259
282
  (when (= (js-length invocation) 0)
@@ -276,6 +299,7 @@
276
299
  (js-object :name protocol-name
277
300
  :operations
278
301
  (funcall protocol-freeze operation-table))))
302
+ (js-call protocol-operation-owners :set operation-table protocol)
279
303
  (setq index 0)
280
304
  (while (< index (js-length protocol-operations))
281
305
  (let* ((operation (js-nth index protocol-operations))
@@ -283,6 +307,9 @@
283
307
  (method (get record :method)))
284
308
  (funcall protocol-define-metadata
285
309
  method protocol operation (get record :slot))
310
+ (js-call protocol-method-owners :set method
311
+ (funcall protocol-freeze
312
+ (js-object :protocol protocol :operation operation)))
286
313
  (funcall protocol-freeze method)
287
314
  (funcall protocol-freeze record))
288
315
  (setq index (1+ index)))
@@ -296,6 +323,9 @@
296
323
  (funcall protocol-null-object))))
297
324
  protocol)))
298
325
 
326
+ (defun define-protocol (name operations)
327
+ (make-protocol-with-slots name operations nil))
328
+
299
329
  (defun protocol-definition (protocol)
300
330
  (protocol-state protocol)
301
331
  (let ((operations
@@ -312,6 +342,31 @@
312
342
  (define-protocol (get normalized :name)
313
343
  (get normalized :operations))))
314
344
 
345
+ ;; Bulk materialization reuses already transported Symbols, so observing a
346
+ ;; slot before its protocol does not create two identities for one slot.
347
+ (defun materialize-protocol-from-definition (definition slots)
348
+ (let* ((normalized (normalize-protocol-definition definition))
349
+ (operations (get normalized :operations)))
350
+ (unless (and (funcall protocol-array? slots) (= (js-length slots) (js-length operations)))
351
+ (protocol-fail "protocol slots must be a dense array matching its operations"))
352
+ (let* ((descriptors (funcall protocol-own-descriptors slots))
353
+ (keys (funcall protocol-own-keys descriptors))
354
+ (seen (new globalThis/Set)) (symbols (js-array)) (index 0))
355
+ (unless (= (js-length keys) (1+ (js-length slots)))
356
+ (protocol-fail "protocol slots must be a dense array with no extra properties"))
357
+ (while (< index (js-length slots))
358
+ (let* ((descriptor (get descriptors (str index) undefined))
359
+ (value (if (undefined? descriptor) undefined (get descriptor :value))))
360
+ (unless (and (not (undefined? descriptor))
361
+ (funcall protocol-has-own descriptor "value")
362
+ (get descriptor :enumerable false)
363
+ (= (funcall protocol-host-type value) "symbol"))
364
+ (protocol-fail "protocol slots must contain enumerable Symbol data values"))
365
+ (when (js-call seen :has value) (protocol-fail "protocol slots must be distinct Symbols"))
366
+ (js-call seen :add value) (js-call symbols :push value))
367
+ (setq index (1+ index)))
368
+ (make-protocol-with-slots (get normalized :name) operations symbols))))
369
+
315
370
  (defun protocol-method (protocol operation)
316
371
  (get (operation-record protocol operation) :method))
317
372
 
@@ -380,7 +435,16 @@
380
435
  (setq index (1+ index)))
381
436
  implemented))
382
437
 
383
- (export define-protocol define-protocol-from-definition
438
+ (defun protocol? (value) (js-call protocol-states :has value))
439
+
440
+ (defun read-protocol-operations-owner (value)
441
+ (js-call protocol-operation-owners :get value))
442
+
443
+ (defun read-protocol-method-owner (value)
444
+ (js-call protocol-method-owners :get value))
445
+
446
+ (export protocol? define-protocol define-protocol-from-definition materialize-protocol-from-definition
447
+ read-protocol-operations-owner read-protocol-method-owner
384
448
  extend-protocol-category extend-protocol-default
385
449
  extend-protocol-type implements-protocol-operation?
386
450
  implements-protocol? protocol-definition protocol-host-category
@@ -43,7 +43,7 @@
43
43
  persistentVector)
44
44
  (defconst not-found (js-object))
45
45
  (defconst sequence-no-partition-pad (js-object))
46
- (defconst sequence-ring (js* "() => new Map()"))
46
+ (defconst sequence-ring (lambda () (new globalThis/Map)))
47
47
  (defconst sequence-array? (js* "Array.isArray"))
48
48
  (defconst sequence-safe-integer? (js* "Number.isSafeInteger"))
49
49
  (defconst sequence-finite? (js* "Number.isFinite"))