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.
- package/README.md +59 -0
- package/bootstrap/README.md +26 -0
- package/bootstrap/backends/README.md +515 -0
- package/bootstrap/backends/async.eli +230 -0
- package/bootstrap/backends/binary.eli +173 -0
- package/bootstrap/backends/capabilities.eli +74 -0
- package/bootstrap/backends/elf.eli +246 -0
- package/bootstrap/backends/managed.eli +5976 -0
- package/bootstrap/backends/memory.eli +100 -0
- package/bootstrap/backends/native.eli +2000 -0
- package/bootstrap/backends/numeric.eli +1362 -0
- package/bootstrap/backends/optimize.eli +79 -0
- package/bootstrap/backends/regexp.eli +2263 -0
- package/bootstrap/backends/sha256.eli +138 -0
- package/bootstrap/backends/wasm.eli +1161 -0
- package/bootstrap/compiler/analyzer.eli +165 -77
- package/bootstrap/compiler/compiler.eli +43 -19
- package/bootstrap/compiler/emitter.eli +780 -170
- package/bootstrap/compiler/expander.eli +136 -45
- package/bootstrap/compiler/formatter.eli +8 -1
- package/bootstrap/compiler/ir.eli +148 -45
- package/bootstrap/compiler/lower.eli +29 -2
- package/bootstrap/compiler/project.eli +51 -21
- package/bootstrap/compiler/reader.eli +128 -36
- package/bootstrap/compiler/source-map.eli +46 -4
- package/bootstrap/compiler/symbol.eli +2 -1
- package/bootstrap/compiler/syntax.eli +47 -12
- package/bootstrap/compiler/transient-analysis.eli +40 -4
- package/bootstrap/host/check-cli-legacy.mjs +163 -0
- package/bootstrap/host/check-cli.mjs +59 -158
- package/bootstrap/host/check-cli.mjs.map +1 -0
- package/bootstrap/host/compiler-session.eli +1579 -0
- package/bootstrap/host/compiler-tools.eli +513 -0
- package/bootstrap/host/eliscript-cli-legacy.mjs +37 -0
- package/bootstrap/host/eliscript-cli.mjs +53 -33
- package/bootstrap/host/eliscript-cli.mjs.map +1 -0
- package/bootstrap/host/project-cli-legacy.mjs +295 -0
- package/bootstrap/host/project-cli.mjs +74 -289
- package/bootstrap/host/project-cli.mjs.map +1 -0
- package/bootstrap/host/project-legacy.mjs +1080 -0
- package/bootstrap/host/project.mjs +210 -1060
- package/bootstrap/host/project.mjs.map +1 -0
- package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
- package/bootstrap/runtime/memory.eli +30379 -0
- package/browser/host.mjs +89 -0
- package/compiler/eliscript-analyzer.el +371 -4
- package/compiler/eliscript-cli.el +84 -1
- package/compiler/eliscript-emitter.el +1189 -256
- package/compiler/eliscript-expander.el +147 -10
- package/compiler/eliscript-ir-emitter.el +725 -208
- package/compiler/eliscript-lower.el +127 -1
- package/compiler/eliscript-portable.el +177 -51
- package/compiler/eliscript-project.el +20 -2
- package/compiler/eliscript-reader.el +141 -57
- package/compiler/eliscript-source-map.el +26 -12
- package/compiler/eliscript-transient-analysis.el +382 -19
- package/dist/backends/async.mjs +561 -0
- package/dist/backends/async.mjs.macro-origins.json +1 -0
- package/dist/backends/async.mjs.map +1 -0
- package/dist/backends/binary.mjs +381 -0
- package/dist/backends/binary.mjs.macro-origins.json +1 -0
- package/dist/backends/binary.mjs.map +1 -0
- package/dist/backends/capabilities.mjs +237 -0
- package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
- package/dist/backends/capabilities.mjs.map +1 -0
- package/dist/backends/elf.mjs +540 -0
- package/dist/backends/elf.mjs.macro-origins.json +1 -0
- package/dist/backends/elf.mjs.map +1 -0
- package/dist/backends/managed.mjs +10616 -0
- package/dist/backends/managed.mjs.macro-origins.json +1 -0
- package/dist/backends/managed.mjs.map +1 -0
- package/dist/backends/memory.mjs +278 -0
- package/dist/backends/memory.mjs.macro-origins.json +1 -0
- package/dist/backends/memory.mjs.map +1 -0
- package/dist/backends/native.mjs +4099 -0
- package/dist/backends/native.mjs.macro-origins.json +1 -0
- package/dist/backends/native.mjs.map +1 -0
- package/dist/backends/numeric.mjs +2458 -0
- package/dist/backends/numeric.mjs.macro-origins.json +1 -0
- package/dist/backends/numeric.mjs.map +1 -0
- package/dist/backends/optimize.mjs +204 -0
- package/dist/backends/optimize.mjs.macro-origins.json +1 -0
- package/dist/backends/optimize.mjs.map +1 -0
- package/dist/backends/regexp.mjs +2033 -0
- package/dist/backends/regexp.mjs.macro-origins.json +1 -0
- package/dist/backends/regexp.mjs.map +1 -0
- package/dist/backends/sha256.mjs +310 -0
- package/dist/backends/sha256.mjs.macro-origins.json +1 -0
- package/dist/backends/sha256.mjs.map +1 -0
- package/dist/backends/wasm.mjs +2258 -0
- package/dist/backends/wasm.mjs.macro-origins.json +1 -0
- package/dist/backends/wasm.mjs.map +1 -0
- package/dist/bootstrap/analyzer.mjs +1908 -776
- package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +450 -142
- package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +3083 -909
- package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +2887 -1233
- package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/formatter.mjs +582 -218
- package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/formatter.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +670 -116
- package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/lower.mjs +866 -257
- package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/lower.mjs.map +1 -1
- package/dist/bootstrap/package.json +1 -0
- package/dist/bootstrap/project.mjs +1168 -498
- package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +674 -175
- package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/runtime/math.mjs +1117 -0
- package/dist/bootstrap/runtime/math.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
- package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +430 -119
- package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/symbol.mjs +229 -53
- package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/symbol.mjs.map +1 -1
- package/dist/bootstrap/syntax.mjs +205 -7
- package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/syntax.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +1185 -489
- package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +199 -6478
- package/dist/browser/host.mjs +446 -0
- package/dist/browser/loader.js +1 -0
- package/dist/browser/loader.mjs +231 -0
- package/dist/browser/worker.mjs +60 -0
- package/dist/compiler-artifact.json +1 -0
- package/dist/host/compiler-session.mjs +2980 -0
- package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-session.mjs.map +1 -0
- package/dist/host/compiler-tools.mjs +1084 -0
- package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-tools.mjs.map +1 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
- package/dist/literal-sources/runtime/core/collection.eli +579 -0
- package/dist/literal-sources/runtime/core/data-text.eli +290 -0
- package/dist/literal-sources/runtime/core/data.eli +22 -0
- package/dist/literal-sources/runtime/core/identifier.eli +44 -0
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
- package/dist/literal-sources/runtime/core/list.eli +19 -0
- package/dist/literal-sources/runtime/core/map.eli +9 -0
- package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
- package/dist/literal-sources/runtime/core/metadata.eli +23 -0
- package/dist/literal-sources/runtime/core/object.eli +8 -0
- package/dist/literal-sources/runtime/core/order.eli +123 -0
- package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
- package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
- package/dist/literal-sources/runtime/core/protocol.eli +28 -0
- package/dist/literal-sources/runtime/core/queue.eli +9 -0
- package/dist/literal-sources/runtime/core/record.eli +191 -0
- package/dist/literal-sources/runtime/core/regex.eli +158 -0
- package/dist/literal-sources/runtime/core/sequence.eli +305 -0
- package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
- package/dist/literal-sources/runtime/core/set.eli +9 -0
- package/dist/literal-sources/runtime/core/sorted.eli +408 -0
- package/dist/literal-sources/runtime/core/text.eli +14 -0
- package/dist/literal-sources/runtime/core/transducer.eli +268 -0
- package/dist/literal-sources/runtime/core/transient.eli +17 -0
- package/dist/literal-sources/runtime/core/truth.eli +4 -0
- package/dist/literal-sources/runtime/core/type.eli +232 -0
- package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
- package/dist/literal-sources/runtime/core/value.eli +19 -0
- package/dist/literal-sources/runtime/core/vector.eli +20 -0
- package/dist/literal-sources/runtime/literals.eli +23 -0
- package/dist/literal-sources/runtime/testing/value.eli +6 -0
- package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
- package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
- package/dist/literal-sources/runtime/wire/schema.eli +193 -0
- package/dist/literal-sources/stdlib/bit.eli +36 -0
- package/dist/literal-sources/stdlib/core/data.eli +306 -0
- package/dist/literal-sources/stdlib/core/object.eli +89 -0
- package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
- package/dist/literal-sources/stdlib/core/set.eli +312 -0
- package/dist/literal-sources/stdlib/core/text.eli +103 -0
- package/dist/literal-sources/stdlib/managed-literal-protocols.eli +483 -0
- package/dist/literal-sources/stdlib/managed-literals.eli +1414 -0
- package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
- package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
- package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
- package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
- package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
- package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
- package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
- package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
- package/dist/literal-sources/stdlib/value.eli +325 -0
- package/dist/package.json +10 -0
- package/dist/runtime/math.mjs +1116 -0
- package/dist/runtime/math.mjs.macro-origins.json +1 -0
- package/dist/runtime/math.mjs.map +1 -0
- package/dist/runtime/unicode-case-data.mjs +10124 -0
- package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/runtime/unicode-case.mjs +280 -0
- package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case.mjs.map +1 -0
- package/dist/runtime.eli +30379 -0
- package/dist/stage3-release.json +1 -0
- package/editor/README.md +1 -1
- package/editor/eliscript-mode.el +1 -1
- package/editor/eliscript-repl.el +1 -1
- package/package.json +97 -10
- package/platform/http.mjs +20 -0
- package/runtime/array-text.mjs +159 -0
- package/runtime/core/map-internals.mjs +27 -9
- package/runtime/core/object-impl.mjs +26 -17
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/protocol-impl.mjs +682 -255
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/protocol.mjs +4 -0
- package/runtime/core/record.mjs +23 -2
- package/runtime/core/regex.mjs +4 -0
- package/runtime/core/sorted.mjs +53 -0
- package/runtime/core/text-impl.mjs +167 -48
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/type.mjs +75 -3
- package/runtime/core/vector.mjs +6 -0
- package/runtime/math.eli +429 -0
- package/runtime/math.mjs +1116 -0
- package/runtime/math.mjs.map +1 -0
- package/runtime/number-radix.mjs +105 -0
- package/runtime/unicode-case-data.eli +29 -0
- package/runtime/unicode-case-data.mjs +10124 -0
- package/runtime/unicode-case-data.mjs.map +1 -0
- package/runtime/unicode-case.eli +100 -0
- package/runtime/unicode-case.mjs +280 -0
- package/runtime/unicode-case.mjs.map +1 -0
- package/runtime/wire/http-rpc.mjs +168 -0
- package/runtime/wire/markdown.mjs +196 -0
- package/runtime/wire/schema.mjs +109 -0
- package/stdlib/README.md +54 -0
- package/stdlib/core/protocol.eli +81 -17
- package/stdlib/core/seq.eli +1 -1
- package/stdlib/core/zipper.eli +114 -47
- package/stdlib/gepo.eli +12 -0
- package/stdlib/interop/js.eli +56 -15
- package/stdlib/managed-literal-protocols.eli +483 -0
- package/stdlib/managed-literals.eli +1414 -0
- package/stdlib/managed-protocol-error.eli +32 -0
- package/stdlib/managed-queue-state.eli +65 -0
- package/stdlib/managed-runtime-collection-internals.eli +60 -0
- package/stdlib/managed-runtime-collection.eli +579 -0
- package/stdlib/managed-runtime-data-text.eli +290 -0
- package/stdlib/managed-runtime-data.eli +22 -0
- package/stdlib/managed-runtime-identifier.eli +44 -0
- package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
- package/stdlib/managed-runtime-list.eli +19 -0
- package/stdlib/managed-runtime-literals.eli +23 -0
- package/stdlib/managed-runtime-map.eli +9 -0
- package/stdlib/managed-runtime-metadata-internals.eli +6 -0
- package/stdlib/managed-runtime-metadata.eli +23 -0
- package/stdlib/managed-runtime-object.eli +8 -0
- package/stdlib/managed-runtime-order.eli +123 -0
- package/stdlib/managed-runtime-persistent-kind.eli +28 -0
- package/stdlib/managed-runtime-protocol.eli +28 -0
- package/stdlib/managed-runtime-queue.eli +9 -0
- package/stdlib/managed-runtime-record.eli +191 -0
- package/stdlib/managed-runtime-regex.eli +158 -0
- package/stdlib/managed-runtime-sequence.eli +305 -0
- package/stdlib/managed-runtime-set-algebra.eli +28 -0
- package/stdlib/managed-runtime-set.eli +9 -0
- package/stdlib/managed-runtime-sorted.eli +408 -0
- package/stdlib/managed-runtime-text.eli +14 -0
- package/stdlib/managed-runtime-transducer.eli +268 -0
- package/stdlib/managed-runtime-transient.eli +17 -0
- package/stdlib/managed-runtime-truth.eli +4 -0
- package/stdlib/managed-runtime-type.eli +232 -0
- package/stdlib/managed-runtime-value-internals.eli +13 -0
- package/stdlib/managed-runtime-value.eli +19 -0
- package/stdlib/managed-runtime-vector.eli +20 -0
- package/stdlib/managed-sorted-state.eli +233 -0
- package/stdlib/managed-testing-value.eli +6 -0
- package/stdlib/managed-transient-state.eli +348 -0
- package/stdlib/managed-value-state.eli +153 -0
- package/stdlib/managed-vector-view-state.eli +102 -0
- package/stdlib/managed-wire-http-rpc.eli +362 -0
- package/stdlib/managed-wire-markdown.eli +275 -0
- package/stdlib/managed-wire-schema.eli +193 -0
- package/stdlib/mdp.eli +7 -0
- package/stdlib/mds.eli +4 -0
- package/stdlib/persistent-vector.eli +23 -6
- package/tools/acceptance/check-legacy.mjs +687 -0
- package/tools/acceptance/check.eli +431 -0
- package/tools/acceptance/compile-evidence.el +49 -0
- package/tools/acceptance/finalize-legacy.mjs +498 -0
- package/tools/acceptance/finalize.eli +270 -0
- package/tools/backends/benchmark.mjs +175 -0
- package/tools/backends/build.mjs +135 -0
- package/tools/backends/compile.mjs +94 -0
- package/tools/backends/compiler-bootstrap.mjs +1001 -0
- package/tools/backends/compiler-browser.mjs +361 -0
- package/tools/backends/compiler-build.mjs +1628 -0
- package/tools/backends/compiler-cli-legacy.mjs +334 -0
- package/tools/backends/compiler-cli.mjs +29 -0
- package/tools/backends/compiler-corpus-bit.mjs +234 -0
- package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
- package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
- package/tools/backends/compiler-corpus-debugging.mjs +221 -0
- package/tools/backends/compiler-corpus-emitter.mjs +324 -0
- package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
- package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
- package/tools/backends/compiler-corpus-execution.mjs +3324 -0
- package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
- package/tools/backends/compiler-corpus-generations.mjs +208 -0
- package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
- package/tools/backends/compiler-corpus-host-context.mjs +550 -0
- package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
- package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
- package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
- package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
- package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
- package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
- package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
- package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
- package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
- package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
- package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
- package/tools/backends/compiler-corpus-matchers.mjs +173 -0
- package/tools/backends/compiler-corpus-original-program.mjs +612 -0
- package/tools/backends/compiler-corpus-process.mjs +765 -0
- package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
- package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
- package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
- package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
- package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
- package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
- package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
- package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
- package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
- package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
- package/tools/backends/compiler-corpus-reference.mjs +241 -0
- package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
- package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
- package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
- package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
- package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
- package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
- package/tools/backends/compiler-corpus.mjs +2054 -0
- package/tools/backends/compiler-debug.mjs +142 -0
- package/tools/backends/compiler-matrix.mjs +1955 -0
- package/tools/backends/compiler-metadata.mjs +203 -0
- package/tools/backends/compiler-package-browser.mjs +120 -0
- package/tools/backends/compiler-package-legacy.mjs +654 -0
- package/tools/backends/compiler-package.mjs +464 -0
- package/tools/backends/compiler-project.mjs +126 -0
- package/tools/backends/compiler-session.mjs +843 -0
- package/tools/backends/compiler-sha256.mjs +152 -0
- package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
- package/tools/backends/compiler-worker.mjs +573 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
- package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
- package/tools/backends/dist/record-grid.mjs +1256 -0
- package/tools/backends/dist/record-grid.mjs.map +1 -0
- package/tools/backends/dist/release-cli.mjs +460 -0
- package/tools/backends/dist/release-cli.mjs.map +1 -0
- package/tools/backends/dist/run-artifact.mjs +517 -0
- package/tools/backends/dist/run-artifact.mjs.map +1 -0
- package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
- package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
- package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
- package/tools/backends/managed-foreign-binding.mjs +497 -0
- package/tools/backends/managed-host-legacy.mjs +1181 -0
- package/tools/backends/managed-host-lifecycle.mjs +310 -0
- package/tools/backends/managed-host-object-provider.mjs +155 -0
- package/tools/backends/managed-host-object-realm.mjs +797 -0
- package/tools/backends/managed-host-proxy.mjs +71 -0
- package/tools/backends/managed-host-runtime.mjs +5868 -0
- package/tools/backends/managed-host.mjs +716 -0
- package/tools/backends/managed-module-graph-legacy.mjs +308 -0
- package/tools/backends/managed-module-graph.mjs +694 -0
- package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
- package/tools/backends/managed-runtime.mjs +939 -0
- package/tools/backends/managed-source-view-legacy.mjs +332 -0
- package/tools/backends/managed-source-view.mjs +959 -0
- package/tools/backends/memory-runtime.mjs +100 -0
- package/tools/backends/native-benchmark.mjs +88 -0
- package/tools/backends/native-managed-runtime.mjs +677 -0
- package/tools/backends/native-memory.mjs +768 -0
- package/tools/backends/native-node-memory.mjs +142 -0
- package/tools/backends/native-node-runner.mjs +99 -0
- package/tools/backends/native-node-watchdog.mjs +19 -0
- package/tools/backends/native-node-worker.mjs +75 -0
- package/tools/backends/stage3-targets.mjs +486 -0
- package/tools/bootstrap-command.el +13 -0
- package/tools/bootstrap-runtime.el +101 -0
- package/tools/bootstrap-seed.el +55 -0
- package/tools/project/check-cli.eli +31 -0
- package/tools/project/project-cli.eli +42 -0
- package/tools/project/project.eli +122 -0
- package/tools/runtime/unicode-case-profiles.mjs +13 -0
- package/tools/runtime/unicode-case-runtime.el +57 -0
- package/tools/testing/source-debugging-corpus-host.eli +16 -0
- package/tools/testing/source-debugging.eli +139 -0
- package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
- package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
- package/tools/testing/stdlib-bit.eli +104 -0
- package/tools/testing/stdlib-bit.mjs +255 -0
- package/bin/eliscript-bootstrap +0 -15
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
(module eliscript.backend.async
|
|
2
|
+
(import "../bootstrap/symbol.mjs" binding-name)
|
|
3
|
+
;; This pass produces ordinary closures. Suspension is represented solely by
|
|
4
|
+
;; runtime reactions; tail records trampoline synchronous continuation calls.
|
|
5
|
+
(defun async-node (kind value children &optional properties)
|
|
6
|
+
(js-object :kind kind :value value :children children :properties properties :span nil))
|
|
7
|
+
(defun async-intrinsic (name children) (async-node "intrinsic" name children))
|
|
8
|
+
(defun async-reference (name) (async-node "reference" name (js-array)))
|
|
9
|
+
(defun async-literal (value) (async-node "literal" value (js-array)))
|
|
10
|
+
(defun async-fresh (state)
|
|
11
|
+
(let ((name (str (get state :prefix) (get state :next))))
|
|
12
|
+
(put state :next (1+ (get state :next))) name))
|
|
13
|
+
(defun async-lambda (name body)
|
|
14
|
+
(async-node "function-expression" nil
|
|
15
|
+
(js-array (async-node "parameter-binding" name (js-array) (js-object :parameterKind "required")) body)
|
|
16
|
+
(js-object :parameterCount 1 :async false)))
|
|
17
|
+
(defun async-call (function value)
|
|
18
|
+
(async-intrinsic "managed-async-tail" (js-array function value)))
|
|
19
|
+
(defun async-bind (name value body)
|
|
20
|
+
(async-node "lexical-bindings" nil
|
|
21
|
+
(js-array (async-node "lexical-binding" name (js-array value)) body)
|
|
22
|
+
(js-object :bindingCount 1 :sequential t)))
|
|
23
|
+
(defun async-await-p (node)
|
|
24
|
+
(let ((found false))
|
|
25
|
+
(when node
|
|
26
|
+
(if (= (get node :kind) "await-expression") (setq found t)
|
|
27
|
+
(unless (or (= (get node :kind) "function-expression") (= (get node :kind) "function-declaration"))
|
|
28
|
+
(js-call (get node :children) :forEach (lambda (child) (when (async-await-p child) (setq found t))))))) found))
|
|
29
|
+
(defun async-guard (expression reject state)
|
|
30
|
+
(let ((error (async-fresh state)))
|
|
31
|
+
(async-node "try-expression" nil
|
|
32
|
+
(js-array expression (async-node "catch-clause" nil
|
|
33
|
+
(js-array (async-node "catch-binding" error (js-array)) (async-call reject (async-reference error)))))
|
|
34
|
+
(js-object :bodyCount 1))))
|
|
35
|
+
(defun async-copy (node children)
|
|
36
|
+
(js-call globalThis.Object :assign (js-object) node (js-object :children children :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node))))
|
|
37
|
+
(defun async-children (nodes index values done reject state)
|
|
38
|
+
(if (= index (js-length nodes)) (done values)
|
|
39
|
+
(let ((node (js-nth index nodes)))
|
|
40
|
+
(if (or (= (get node :kind) "object-property") (= (get node :kind) "assignment-pair"))
|
|
41
|
+
(async-children (get node :children) 0 (js-array)
|
|
42
|
+
(lambda (parts)
|
|
43
|
+
(let ((next (js-call values :slice)))
|
|
44
|
+
(js-call next :push (async-copy node parts))
|
|
45
|
+
(async-children nodes (1+ index) next done reject state))) reject state)
|
|
46
|
+
(let ((name (async-fresh state)))
|
|
47
|
+
(async-cps node
|
|
48
|
+
(async-lambda name
|
|
49
|
+
(let ((next (js-call values :slice)))
|
|
50
|
+
(js-call next :push (async-reference name))
|
|
51
|
+
(async-children nodes (1+ index) next done reject state))) reject state))))))
|
|
52
|
+
(defun async-sequence (nodes index next reject state)
|
|
53
|
+
(if (= index (js-length nodes)) (async-call next (async-literal nil))
|
|
54
|
+
(if (= (1+ index) (js-length nodes)) (async-cps (js-nth index nodes) next reject state)
|
|
55
|
+
(async-cps (js-nth index nodes)
|
|
56
|
+
(async-lambda (async-fresh state) (async-sequence nodes (1+ index) next reject state)) reject state))))
|
|
57
|
+
(defun async-short (node index next reject state)
|
|
58
|
+
(let ((nodes (get node :children)) (operator (get node :value)))
|
|
59
|
+
(if (= index (js-length nodes)) (async-call next (async-literal (= operator "and")))
|
|
60
|
+
(if (= (1+ index) (js-length nodes)) (async-cps (js-nth index nodes) next reject state)
|
|
61
|
+
(let ((name (async-fresh state)))
|
|
62
|
+
(async-cps (js-nth index nodes)
|
|
63
|
+
(async-lambda name
|
|
64
|
+
(let ((tail (async-short node (1+ index) next reject state))
|
|
65
|
+
(stop (async-call next (async-reference name))))
|
|
66
|
+
(async-node "conditional" nil
|
|
67
|
+
(if (= operator "and") (js-array (async-reference name) tail stop)
|
|
68
|
+
(js-array (async-reference name) stop tail))))) reject state))))))
|
|
69
|
+
(defun async-chain (clauses index next reject state)
|
|
70
|
+
(if (= index (js-length clauses)) (async-call next (async-literal nil))
|
|
71
|
+
(let* ((nodes (get (js-nth index clauses) :children)) (name (async-fresh state)))
|
|
72
|
+
(async-cps (js-nth 0 nodes)
|
|
73
|
+
(async-lambda name (async-node "conditional" nil
|
|
74
|
+
(js-array (async-reference name)
|
|
75
|
+
(if (= (js-length nodes) 1) (async-call next (async-reference name))
|
|
76
|
+
(async-sequence (js-call nodes :slice 1) 0 next reject state))
|
|
77
|
+
(async-chain clauses (1+ index) next reject state)))) reject state))))
|
|
78
|
+
(defun async-bindings (node next reject state)
|
|
79
|
+
(let* ((nodes (get node :children)) (count (get (get node :properties) :bindingCount))
|
|
80
|
+
(sequential (get (get node :properties) :sequential)) (bindings (js-call nodes :slice 0 count))
|
|
81
|
+
(body (js-call nodes :slice count)))
|
|
82
|
+
(if sequential
|
|
83
|
+
(async-bind-sequential bindings 0 body next reject state)
|
|
84
|
+
(let ((initializers (js-call bindings :map (lambda (binding)
|
|
85
|
+
(if (= (js-length (get binding :children)) 0) (async-literal nil) (js-nth 0 (get binding :children)))))))
|
|
86
|
+
(async-children initializers 0 (js-array)
|
|
87
|
+
(lambda (values)
|
|
88
|
+
(let ((output (js-call bindings :map (lambda (binding index) (async-copy binding (js-array (js-nth index values)))))))
|
|
89
|
+
(js-call output :push (async-sequence body 0 next reject state))
|
|
90
|
+
(async-copy node output))) reject state)))))
|
|
91
|
+
(defun async-bind-sequential (bindings index body next reject state)
|
|
92
|
+
(if (= index (js-length bindings)) (async-sequence body 0 next reject state)
|
|
93
|
+
(let* ((binding (js-nth index bindings)) (temporary (async-fresh state))
|
|
94
|
+
(initializer (if (= (js-length (get binding :children)) 0) (async-literal nil) (js-nth 0 (get binding :children)))))
|
|
95
|
+
(async-cps initializer
|
|
96
|
+
(async-lambda temporary
|
|
97
|
+
(async-node "lexical-bindings" nil
|
|
98
|
+
(js-array (async-copy binding (js-array (async-reference temporary)))
|
|
99
|
+
(async-bind-sequential bindings (1+ index) body next reject state))
|
|
100
|
+
(js-object :bindingCount 1 :sequential t))) reject state))))
|
|
101
|
+
(defun async-try (node next reject state)
|
|
102
|
+
(let* ((nodes (get node :children)) (count (get (get node :properties) :bodyCount))
|
|
103
|
+
(handler nil) (finalizer nil) (normal next) (abrupt reject))
|
|
104
|
+
(js-call (js-call nodes :slice count) :forEach (lambda (clause)
|
|
105
|
+
(if (= (get clause :kind) "catch-clause") (setq handler clause) (setq finalizer clause))))
|
|
106
|
+
(when finalizer
|
|
107
|
+
(let ((value (async-fresh state)) (error (async-fresh state)))
|
|
108
|
+
(setq normal (async-lambda value
|
|
109
|
+
(async-sequence (get finalizer :children) 0
|
|
110
|
+
(async-lambda (async-fresh state) (async-call next (async-reference value))) reject state)))
|
|
111
|
+
(setq abrupt (async-lambda error
|
|
112
|
+
(async-sequence (get finalizer :children) 0
|
|
113
|
+
(async-lambda (async-fresh state) (async-call reject (async-reference error))) reject state)))))
|
|
114
|
+
(let ((catcher abrupt))
|
|
115
|
+
(when handler
|
|
116
|
+
(let ((error (async-fresh state)) (parts (get handler :children)))
|
|
117
|
+
;; Use the existing catch-binding lowering for TDZ, defaults,
|
|
118
|
+
;; destructuring and iterator closing rather than rebinding by hand.
|
|
119
|
+
(setq catcher (async-lambda error
|
|
120
|
+
(async-guard
|
|
121
|
+
(async-node "try-expression" nil
|
|
122
|
+
(js-array (async-node "throw-expression" nil (js-array (async-reference error)))
|
|
123
|
+
(async-node "catch-clause" nil
|
|
124
|
+
(js-array (js-nth 0 parts)
|
|
125
|
+
(async-sequence (js-call parts :slice 1) 0 normal abrupt state))))
|
|
126
|
+
(js-object :bodyCount 1)) abrupt state)))))
|
|
127
|
+
(async-sequence (js-call nodes :slice 0 count) 0 normal catcher state))))
|
|
128
|
+
(defun async-while (node next reject state)
|
|
129
|
+
(let* ((loop-name (async-fresh state)) (test-name (async-fresh state)) (ignored (async-fresh state))
|
|
130
|
+
(nodes (get node :children))
|
|
131
|
+
(again (async-lambda ignored (async-call (async-reference loop-name) (async-literal nil))))
|
|
132
|
+
(step (async-lambda ignored
|
|
133
|
+
(async-cps (js-nth 0 nodes)
|
|
134
|
+
(async-lambda test-name (async-node "conditional" nil
|
|
135
|
+
(js-array (async-reference test-name)
|
|
136
|
+
(async-sequence (js-call nodes :slice 1) 0 again reject state)
|
|
137
|
+
(async-call next (async-literal nil))))) reject state))))
|
|
138
|
+
(async-bind loop-name (async-literal nil)
|
|
139
|
+
(async-node "sequence" nil
|
|
140
|
+
(js-array (async-node "assignment" "setq"
|
|
141
|
+
(js-array (async-node "assignment-pair" loop-name (js-array step))))
|
|
142
|
+
(async-call (async-reference loop-name) (async-literal nil)))))))
|
|
143
|
+
(defun async-assignment (node index next reject state)
|
|
144
|
+
(let ((pairs (get node :children)))
|
|
145
|
+
(if (= index (js-length pairs)) (async-call next (async-literal nil))
|
|
146
|
+
(let* ((pair (js-nth index pairs)) (name (async-fresh state))
|
|
147
|
+
(assignment (async-copy node (js-array (async-copy pair (js-array (async-reference name)))))))
|
|
148
|
+
(async-cps (js-nth 0 (get pair :children))
|
|
149
|
+
(async-lambda name
|
|
150
|
+
(if (= (1+ index) (js-length pairs)) (async-guard (async-call next assignment) reject state)
|
|
151
|
+
(async-guard (async-node "sequence" nil (js-array assignment (async-assignment node (1+ index) next reject state))) reject state))) reject state)))))
|
|
152
|
+
(defun async-cps (node next reject state)
|
|
153
|
+
(let ((kind (get node :kind)) (nodes (get node :children)))
|
|
154
|
+
(cond
|
|
155
|
+
((not (async-await-p node)) (async-guard (async-call next (async-transform-node node state)) reject state))
|
|
156
|
+
((and (= kind "intrinsic") (= (get node :value) "host-identity-token"))
|
|
157
|
+
(let ((capture (async-intrinsic "managed-host-identity-capture" (js-array))))
|
|
158
|
+
(put capture :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node))
|
|
159
|
+
(async-cps (async-intrinsic "managed-host-identity-apply" (js-array capture (js-nth 0 nodes))) next reject state)))
|
|
160
|
+
((= kind "await-expression")
|
|
161
|
+
(let ((name (async-fresh state)))
|
|
162
|
+
(async-cps (js-nth 0 nodes)
|
|
163
|
+
(async-lambda name (async-guard (async-intrinsic "managed-promise-await"
|
|
164
|
+
(js-array (async-reference name) next reject)) reject state)) reject state)))
|
|
165
|
+
((= kind "sequence") (async-sequence nodes 0 next reject state))
|
|
166
|
+
((= kind "lexical-bindings") (async-bindings node next reject state))
|
|
167
|
+
((= kind "try-expression") (async-try node next reject state))
|
|
168
|
+
((= kind "throw-expression") (async-cps (js-nth 0 nodes) reject reject state))
|
|
169
|
+
((= kind "short-circuit") (async-short node 0 next reject state))
|
|
170
|
+
((= kind "conditional-chain") (async-chain nodes 0 next reject state))
|
|
171
|
+
((= kind "conditional-sugar")
|
|
172
|
+
(async-cps (async-node "conditional" nil
|
|
173
|
+
(if (= (get node :value) "unless")
|
|
174
|
+
(js-array (js-nth 0 nodes) (async-literal nil) (async-node "sequence" nil (js-call nodes :slice 1)))
|
|
175
|
+
(js-array (js-nth 0 nodes) (async-node "sequence" nil (js-call nodes :slice 1)) (async-literal nil)))) next reject state))
|
|
176
|
+
((= kind "conditional")
|
|
177
|
+
(let ((name (async-fresh state)))
|
|
178
|
+
(async-cps (js-nth 0 nodes)
|
|
179
|
+
(async-lambda name (async-node "conditional" nil
|
|
180
|
+
(js-array (async-reference name) (async-cps (js-nth 1 nodes) next reject state)
|
|
181
|
+
(async-cps (js-nth 2 nodes) next reject state)))) reject state)))
|
|
182
|
+
((and (= kind "loop") (= (get node :value) "while")) (async-while node next reject state))
|
|
183
|
+
((= kind "assignment") (async-assignment node 0 next reject state))
|
|
184
|
+
((= kind "constructor-call")
|
|
185
|
+
(async-children (js-call nodes :slice 1) 0 (js-array)
|
|
186
|
+
(lambda (arguments)
|
|
187
|
+
(async-guard (async-call next (async-copy node
|
|
188
|
+
(js-call (js-array (js-nth 0 nodes)) :concat arguments))) reject state)) reject state))
|
|
189
|
+
((= kind "method-call")
|
|
190
|
+
(async-cps (async-node "call" nil
|
|
191
|
+
(js-call (js-array (async-intrinsic "managed-async-method-capture" (js-call nodes :slice 0 2)))
|
|
192
|
+
:concat (js-call nodes :slice 2))) next reject state))
|
|
193
|
+
(t
|
|
194
|
+
(async-children nodes 0 (js-array)
|
|
195
|
+
(lambda (values) (async-guard (async-call next (async-copy node values)) reject state)) reject state)))))
|
|
196
|
+
(defun async-function (node state)
|
|
197
|
+
(let* ((properties (get node :properties)) (count (get properties :parameterCount))
|
|
198
|
+
(nodes (get node :children)) (promise (async-fresh state)) (result (async-fresh state)) (error (async-fresh state))
|
|
199
|
+
(accept (async-lambda result (async-intrinsic "managed-promise-resolve" (js-array (async-reference promise) (async-reference result)))))
|
|
200
|
+
(reject (async-lambda error (async-intrinsic "managed-promise-reject" (js-array (async-reference promise) (async-reference error)))))
|
|
201
|
+
(start (async-lambda (async-fresh state) (async-guard (async-sequence (js-call nodes :slice count) 0 accept reject state) reject state)))
|
|
202
|
+
(body (async-bind promise (async-intrinsic "managed-promise-new" (js-array))
|
|
203
|
+
(async-node "sequence" nil
|
|
204
|
+
(js-array (async-guard (async-intrinsic "managed-async-run" (js-array start (async-literal nil))) reject state)
|
|
205
|
+
(async-reference promise)))))
|
|
206
|
+
(output (js-call nodes :slice 0 count)))
|
|
207
|
+
(js-call output :push body)
|
|
208
|
+
(js-call globalThis.Object :assign (js-object) node
|
|
209
|
+
(js-object :children output :managedAsyncOriginal (or (get node :managedAsyncOriginal nil) node) :properties (js-call globalThis.Object :assign (js-object) properties (js-object :async false :managedAsync t))))))
|
|
210
|
+
(defun async-transform-node (node state)
|
|
211
|
+
(if (and (or (= (get node :kind) "function-expression") (= (get node :kind) "function-declaration"))
|
|
212
|
+
(get (get node :properties) :async)) (async-function node state)
|
|
213
|
+
(let* ((changed false)
|
|
214
|
+
(children (js-call (get node :children) :map (lambda (child)
|
|
215
|
+
(let ((copy (async-transform-node child state)))
|
|
216
|
+
(unless (eq copy child) (setq changed t)) copy)))))
|
|
217
|
+
(if changed (async-copy node children) node))))
|
|
218
|
+
(defun lower-async-program (program)
|
|
219
|
+
(let ((names (new globalThis.Set)) (pending (js-call (get program :body) :slice)) (prefix "eliscript_async_"))
|
|
220
|
+
(while (> (js-length pending) 0)
|
|
221
|
+
(let ((node (js-call pending :pop)))
|
|
222
|
+
(when (= (value-type (get node :value)) "string")
|
|
223
|
+
(let ((name (get node :value)))
|
|
224
|
+
(js-call names :add (try (binding-name name) (catch error name)))))
|
|
225
|
+
(js-call (get node :children) :forEach (lambda (child) (js-call pending :push child)))))
|
|
226
|
+
(while (js-call (Array/from names) :some (lambda (name) (js-call name :startsWith prefix))) (setq prefix (str "_" prefix)))
|
|
227
|
+
(let ((state (js-object :prefix prefix :next 0)))
|
|
228
|
+
(js-call globalThis.Object :assign (js-object) program
|
|
229
|
+
(js-object :body (js-call (get program :body) :map (lambda (node) (async-transform-node node state))))))))
|
|
230
|
+
(export lower-async-program))
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
(module eliscript.backend.binary
|
|
2
|
+
(import "./numeric.mjs" backend-fail)
|
|
3
|
+
|
|
4
|
+
;; Packed output owns bounded word batches and exact UTF16 strings. Each
|
|
5
|
+
;; code unit stores two little-endian bytes, including unpaired surrogates.
|
|
6
|
+
;; The ordinary byte-array API keeps its original representation.
|
|
7
|
+
(defun binary-output (&optional options)
|
|
8
|
+
(let ((configuration (or options (js-object))))
|
|
9
|
+
(if (not (Object/hasOwn configuration "binaryEncoding")) (js-array)
|
|
10
|
+
(if (= (get configuration :binaryEncoding) "u16le-chunks")
|
|
11
|
+
(js-object :length 0 :chunks (js-array) :pending (js-array) :low -1)
|
|
12
|
+
(backend-fail nil "unsupported binary output encoding")))))
|
|
13
|
+
|
|
14
|
+
(defun binary-flush (output)
|
|
15
|
+
(let ((pending (get output :pending)))
|
|
16
|
+
(when (> (js-length pending) 0)
|
|
17
|
+
(js-call (get output :chunks) :push
|
|
18
|
+
(Reflect/apply (get globalThis.String :fromCharCode) nil pending))
|
|
19
|
+
(put output :pending (js-array)))))
|
|
20
|
+
|
|
21
|
+
(defun binary-unit (output value)
|
|
22
|
+
(js-call (get output :pending) :push value)
|
|
23
|
+
(when (= (js-length (get output :pending)) 2048) (binary-flush output)))
|
|
24
|
+
|
|
25
|
+
(defun binary-byte (output value)
|
|
26
|
+
(if (Array/isArray output) (js-call output :push (bit-and value 255))
|
|
27
|
+
(progn
|
|
28
|
+
(if (< (get output :low) 0) (put output :low (bit-and value 255))
|
|
29
|
+
(progn
|
|
30
|
+
(binary-unit output (+ (get output :low) (* (bit-and value 255) 256)))
|
|
31
|
+
(put output :low -1)))
|
|
32
|
+
(put output :length (1+ (get output :length)))))
|
|
33
|
+
output)
|
|
34
|
+
|
|
35
|
+
(defun binary-u32 (output value)
|
|
36
|
+
(if (and (not (Array/isArray output)) (< (get output :low) 0))
|
|
37
|
+
(progn
|
|
38
|
+
(binary-unit output (bit-and value 65535))
|
|
39
|
+
(binary-unit output (unsigned-bit-shift-right value 16))
|
|
40
|
+
(put output :length (+ (get output :length) 4)))
|
|
41
|
+
(let ((i 0))
|
|
42
|
+
(while (< i 4)
|
|
43
|
+
(binary-byte output (bit-and value 255))
|
|
44
|
+
(setq value (unsigned-bit-shift-right value 8)) (setq i (1+ i)))))
|
|
45
|
+
output)
|
|
46
|
+
|
|
47
|
+
(defun binary-push (output &rest values)
|
|
48
|
+
(let ((index 0))
|
|
49
|
+
(while (< index (js-length values))
|
|
50
|
+
(binary-byte output (js-nth index values)) (setq index (1+ index))))
|
|
51
|
+
(get output :length))
|
|
52
|
+
|
|
53
|
+
(defun binary-child (output)
|
|
54
|
+
(binary-output (if (Array/isArray output) (js-object)
|
|
55
|
+
(js-object :binaryEncoding "u16le-chunks"))))
|
|
56
|
+
|
|
57
|
+
(defun binary-length (input)
|
|
58
|
+
(if (Array/isArray input) (js-length input)
|
|
59
|
+
(if (= (get input :encoding nil) "u16le-chunks") (get input :byteLength) (get input :length))))
|
|
60
|
+
|
|
61
|
+
(defun binary-byte-at (input index)
|
|
62
|
+
(if (Array/isArray input) (js-nth index input)
|
|
63
|
+
(let* ((unit (js-call globalThis.Math :floor (/ index 2)))
|
|
64
|
+
(chunk (js-call globalThis.Math :floor (/ unit 2048))) (offset (% unit 2048))
|
|
65
|
+
(chunks (get input :chunks))
|
|
66
|
+
(value (if (< chunk (js-length chunks))
|
|
67
|
+
(string-code-unit-at (js-nth chunk chunks) offset)
|
|
68
|
+
(if (< offset (js-length (get input :pending)))
|
|
69
|
+
(js-nth offset (get input :pending)) (get input :low)))))
|
|
70
|
+
(bit-and (if (= (% index 2) 0) value (unsigned-bit-shift-right value 8)) 255))))
|
|
71
|
+
|
|
72
|
+
;; Reopening a finished public envelope retains its immutable chunk strings.
|
|
73
|
+
;; Only the final partial block is unpacked, never the complete byte stream.
|
|
74
|
+
(defun binary-resume (input)
|
|
75
|
+
(if (/= (get input :encoding nil) "u16le-chunks") input
|
|
76
|
+
(let* ((output (binary-output (js-object :binaryEncoding "u16le-chunks")))
|
|
77
|
+
(length (get input :byteLength)) (chunks (js-call (get input :chunks) :slice))
|
|
78
|
+
(tail (% length 4096)))
|
|
79
|
+
(put output :length length) (put output :chunks chunks)
|
|
80
|
+
(when (> tail 0)
|
|
81
|
+
(let ((last (js-call chunks :pop)) (index 0) (count (js-call globalThis.Math :floor (/ tail 2))))
|
|
82
|
+
(while (< index count)
|
|
83
|
+
(js-call (get output :pending) :push (string-code-unit-at last index))
|
|
84
|
+
(setq index (1+ index)))
|
|
85
|
+
(when (= (% tail 2) 1) (put output :low (bit-and (string-code-unit-at last count) 255)))))
|
|
86
|
+
output)))
|
|
87
|
+
|
|
88
|
+
(defun binary-append (output input)
|
|
89
|
+
(let ((i 0))
|
|
90
|
+
(while (< i (binary-length input)) (binary-byte output (binary-byte-at input i)) (setq i (1+ i))))
|
|
91
|
+
output)
|
|
92
|
+
|
|
93
|
+
(defun binary-append-owned-even (output input length)
|
|
94
|
+
(let ((units (js-call globalThis.Math :floor (/ length 2))))
|
|
95
|
+
(when (> units 0)
|
|
96
|
+
(let* ((chunks (get input :chunks)) (chunk-index 0) (position 0)
|
|
97
|
+
(pending (get output :pending))
|
|
98
|
+
(carry (if (> (js-length pending) 0)
|
|
99
|
+
(Reflect/apply (get globalThis.String :fromCharCode) nil pending) "")))
|
|
100
|
+
(put output :pending (js-array))
|
|
101
|
+
(while (< position units)
|
|
102
|
+
(let ((chunk (if (< chunk-index (js-length chunks)) (js-nth chunk-index chunks)
|
|
103
|
+
(Reflect/apply (get globalThis.String :fromCharCode) nil (get input :pending)))))
|
|
104
|
+
;; A finished odd source may include one padded high byte in
|
|
105
|
+
;; its last unit. Never transfer that unit as a complete pair.
|
|
106
|
+
(when (> (js-length chunk) (- units position))
|
|
107
|
+
(setq chunk (js-call chunk :slice 0 (- units position))))
|
|
108
|
+
(setq position (+ position (js-length chunk)))
|
|
109
|
+
(setq chunk-index (1+ chunk-index))
|
|
110
|
+
(if (and (= (js-length carry) 0) (= (js-length chunk) 2048))
|
|
111
|
+
(js-call (get output :chunks) :push chunk)
|
|
112
|
+
(progn
|
|
113
|
+
;; carry has <2048 units and chunk has <=2048: this
|
|
114
|
+
;; temporary has at most 4095, regardless of stream size.
|
|
115
|
+
(setq carry (str carry chunk))
|
|
116
|
+
(when (>= (js-length carry) 2048)
|
|
117
|
+
(js-call (get output :chunks) :push (js-call carry :slice 0 2048))
|
|
118
|
+
(setq carry (js-call carry :slice 2048)))))))
|
|
119
|
+
;; Only the final tail is unpacked into the normal pending batch.
|
|
120
|
+
;; Intermediate carries stay strings rather than numeric arrays.
|
|
121
|
+
(let ((index 0))
|
|
122
|
+
(while (< index (js-length carry))
|
|
123
|
+
(js-call (get output :pending) :push (string-code-unit-at carry index))
|
|
124
|
+
(setq index (1+ index))))
|
|
125
|
+
(put output :length (+ (get output :length) (* units 2)))))
|
|
126
|
+
(when (= (% length 2) 1) (binary-byte output (binary-byte-at input (1- length)))))
|
|
127
|
+
output)
|
|
128
|
+
|
|
129
|
+
;; Internal transfer for the WASM emitter's freshly allocated packed body
|
|
130
|
+
;; writers only. Public append and finished envelopes remain repeatable and
|
|
131
|
+
;; non-consuming. No caller option can select this path for typed input.
|
|
132
|
+
(defun binary-append-owned (output input)
|
|
133
|
+
(when (Object/is output input) (backend-fail nil "cannot consume a binary writer into itself"))
|
|
134
|
+
(if (or (Array/isArray output) (Array/isArray input)
|
|
135
|
+
(= (get input :encoding nil) "u16le-chunks"))
|
|
136
|
+
(binary-append output input)
|
|
137
|
+
(progn
|
|
138
|
+
(unless (and (not (nil? output)) (not (nil? input))
|
|
139
|
+
(Array/isArray (get output :chunks nil)) (Array/isArray (get output :pending nil))
|
|
140
|
+
(Array/isArray (get input :chunks nil)) (Array/isArray (get input :pending nil))
|
|
141
|
+
(not (Object/hasOwn output "encoding")) (not (Object/hasOwn input "encoding")))
|
|
142
|
+
(backend-fail nil "owned binary append requires fresh packed writers"))
|
|
143
|
+
(let ((length (get input :length)) (index 0))
|
|
144
|
+
(if (< (get output :low) 0) (binary-append-owned-even output input length)
|
|
145
|
+
;; An odd destination needs cross-unit byte pairing. Preserve the
|
|
146
|
+
;; original path, including the source's exact odd final byte.
|
|
147
|
+
(while (< index length)
|
|
148
|
+
(binary-byte output (binary-byte-at input index)) (setq index (1+ index)))))
|
|
149
|
+
;; Replace storage, rather than clearing shared arrays in place: a
|
|
150
|
+
;; previously finished snapshot may still own the old chunk list.
|
|
151
|
+
;; Preserve emitter debug/span/scratch properties on both writers.
|
|
152
|
+
(put input :length 0) (put input :chunks (js-array))
|
|
153
|
+
(put input :pending (js-array)) (put input :low -1)
|
|
154
|
+
output)))
|
|
155
|
+
|
|
156
|
+
(defun binary-slice (output start end)
|
|
157
|
+
(if (Array/isArray output) (js-call output :slice start end)
|
|
158
|
+
(let ((result (js-array)) (limit (binary-length output)))
|
|
159
|
+
(when (> end limit) (setq end limit))
|
|
160
|
+
(while (< start end)
|
|
161
|
+
(js-call result :push (binary-byte-at output start))
|
|
162
|
+
(setq start (1+ start))) result)))
|
|
163
|
+
|
|
164
|
+
(defun binary-finish (output)
|
|
165
|
+
(if (Array/isArray output) output
|
|
166
|
+
(progn
|
|
167
|
+
(when (>= (get output :low) 0)
|
|
168
|
+
(binary-unit output (get output :low)) (put output :low -1))
|
|
169
|
+
(binary-flush output)
|
|
170
|
+
(js-object :encoding "u16le-chunks" :byteLength (get output :length) :chunks (get output :chunks)))))
|
|
171
|
+
|
|
172
|
+
(export binary-output binary-byte binary-u32 binary-push binary-child binary-length binary-resume
|
|
173
|
+
binary-append binary-append-owned binary-slice binary-finish))
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
(module eliscript.backend.capabilities
|
|
2
|
+
(import "./numeric.mjs" backend-fail)
|
|
3
|
+
|
|
4
|
+
;; A capability is declared only when a typed operation actually needs it.
|
|
5
|
+
;; Scalar and pure managed programs keep the original import-free ABI.
|
|
6
|
+
(defun host-capability-definition (name node)
|
|
7
|
+
(cond
|
|
8
|
+
((or (= name "console-log") (= name "console-log-capture") (= name "source-operation"))
|
|
9
|
+
(js-object :name name :module "eliscript.host" :arity 2 :abi "managed-host-call-v1"))
|
|
10
|
+
(t (backend-fail node (str "unknown host capability: " name)))))
|
|
11
|
+
|
|
12
|
+
(defun collect-host-capabilities (node names &optional completed)
|
|
13
|
+
(unless (and completed (js-call completed :has node))
|
|
14
|
+
(when (= (get node :kind) "host-call")
|
|
15
|
+
(let ((name (get node :value)) (children (get node :children)))
|
|
16
|
+
(host-capability-definition name node)
|
|
17
|
+
(unless (and (= (get node :type) "u32") (Array/isArray children) (= (js-length children) 2))
|
|
18
|
+
(backend-fail node "host calls require exactly heap and argument-list word operands"))
|
|
19
|
+
(let ((index 0))
|
|
20
|
+
(while (< index 2)
|
|
21
|
+
(unless (or (= (get (js-nth index children) :type) "u32")
|
|
22
|
+
(= (get (js-nth index children) :type) "i32"))
|
|
23
|
+
(backend-fail node "host call operands must be memory32 words"))
|
|
24
|
+
(setq index (1+ index))))
|
|
25
|
+
(unless (js-call names :includes name) (js-call names :push name))))
|
|
26
|
+
(let ((children (get node :children)) (index 0))
|
|
27
|
+
(unless (Array/isArray children) (backend-fail node "typed capability scan requires a children array"))
|
|
28
|
+
(while (< index (js-length children))
|
|
29
|
+
(collect-host-capabilities (js-nth index children) names completed)
|
|
30
|
+
(setq index (1+ index))))
|
|
31
|
+
;; Only the source-lowering handoff supplies a memo. A completed subtree
|
|
32
|
+
;; has already declared its capabilities in their first DFS order.
|
|
33
|
+
(when completed (js-call completed :set node t))))
|
|
34
|
+
|
|
35
|
+
(defun prepare-host-capabilities-core (program fresh)
|
|
36
|
+
(let ((names (js-array)) (functions (get program :functions)) (index 0) (result (js-array)))
|
|
37
|
+
(unless (Array/isArray functions) (backend-fail program "typed capability scan requires declared functions"))
|
|
38
|
+
(while (< index (js-length functions))
|
|
39
|
+
(collect-host-capabilities (get (js-nth index functions) :body) names
|
|
40
|
+
(when fresh (new globalThis.WeakMap)))
|
|
41
|
+
(setq index (1+ index)))
|
|
42
|
+
(when (and (> (js-length names) 0) (/= (get program :abi) "memory-u32"))
|
|
43
|
+
(backend-fail program "host capabilities require memory-u32 input"))
|
|
44
|
+
(setq index 0)
|
|
45
|
+
(while (< index (js-length names))
|
|
46
|
+
(js-call result :push (host-capability-definition (js-nth index names) program))
|
|
47
|
+
(setq index (1+ index)))
|
|
48
|
+
(let ((declared (get program :hostCapabilities nil)))
|
|
49
|
+
(unless (nil? declared)
|
|
50
|
+
(unless (and (Array/isArray declared) (= (js-length declared) (js-length result)))
|
|
51
|
+
(backend-fail program "host capability declarations differ from actual typed calls"))
|
|
52
|
+
(setq index 0)
|
|
53
|
+
(while (< index (js-length result))
|
|
54
|
+
(let ((expected (js-nth index result)) (actual (js-nth index declared)))
|
|
55
|
+
(unless (and (= (get actual :name) (get expected :name))
|
|
56
|
+
(= (get actual :module) (get expected :module))
|
|
57
|
+
(= (get actual :arity) 2) (= (get actual :abi) "managed-host-call-v1"))
|
|
58
|
+
(backend-fail program "invalid host capability declaration")))
|
|
59
|
+
(setq index (1+ index)))))
|
|
60
|
+
result))
|
|
61
|
+
|
|
62
|
+
(defun prepare-host-capabilities (program)
|
|
63
|
+
(prepare-host-capabilities-core program nil))
|
|
64
|
+
(defun prepare-fresh-host-capabilities (program)
|
|
65
|
+
(prepare-host-capabilities-core program t))
|
|
66
|
+
|
|
67
|
+
(defun host-capability-index (capabilities node)
|
|
68
|
+
(let ((index 0) (name (get node :value)))
|
|
69
|
+
(while (and (< index (js-length capabilities)) (/= name (get (js-nth index capabilities) :name)))
|
|
70
|
+
(setq index (1+ index)))
|
|
71
|
+
(when (= index (js-length capabilities)) (backend-fail node "host capability was not declared"))
|
|
72
|
+
index))
|
|
73
|
+
|
|
74
|
+
(export prepare-host-capabilities host-capability-index prepare-fresh-host-capabilities))
|