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,361 @@
|
|
|
1
|
+
import {createCompilerSession, encodeCompilerIR,decodeCompilerSourceAsset} from './compiler-session.mjs';
|
|
2
|
+
import {installCompilerWorker, createCompilerWorkerClient, compilerSourceIdentity} from './compiler-worker.mjs';
|
|
3
|
+
|
|
4
|
+
function abort(signal) {
|
|
5
|
+
if (!signal) return;
|
|
6
|
+
if (typeof signal.throwIfAborted === 'function') signal.throwIfAborted();
|
|
7
|
+
else if (signal.aborted) {
|
|
8
|
+
if (signal.reason !== undefined) throw signal.reason;
|
|
9
|
+
const error = new Error('browser compiler request aborted');error.name = 'AbortError';throw error;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function stale(message) {const error = new Error(message);error.code = 'stale-source';return error;}
|
|
13
|
+
function relativeURL(path, base, label) {
|
|
14
|
+
if (typeof path !== 'string' || !path || path.startsWith('/') || path.includes('\\') ||
|
|
15
|
+
/^[a-z][a-z0-9+.-]*:/i.test(path) || path.split('/').includes('..')) {
|
|
16
|
+
throw new TypeError(label + ' must be a relative artifact path');
|
|
17
|
+
}
|
|
18
|
+
return new URL(path, base);
|
|
19
|
+
}
|
|
20
|
+
const artifactResources = new WeakMap();
|
|
21
|
+
function resourceIdentity(manifest, path) {
|
|
22
|
+
if (!Object.hasOwn(manifest, 'artifactIdentity')) return undefined;
|
|
23
|
+
let files = artifactResources.get(manifest);
|
|
24
|
+
if (!files) {
|
|
25
|
+
const identity = manifest.artifactIdentity;
|
|
26
|
+
if (identity?.algorithm !== 'sha256' || !Array.isArray(identity.files)) {
|
|
27
|
+
throw new TypeError('invalid compiler artifact resource identities');
|
|
28
|
+
}
|
|
29
|
+
files = new Map();
|
|
30
|
+
for (const record of identity.files) {
|
|
31
|
+
if (typeof record?.path !== 'string' || !record.path || files.has(record.path) ||
|
|
32
|
+
!Number.isSafeInteger(record.bytes) || record.bytes < 0 ||
|
|
33
|
+
typeof record.sha256 !== 'string' || !/^[0-9a-f]{64}$/.test(record.sha256)) {
|
|
34
|
+
throw new TypeError('invalid or repeated compiler artifact resource identity');
|
|
35
|
+
}
|
|
36
|
+
files.set(record.path, {bytes: record.bytes, sha256: record.sha256});
|
|
37
|
+
}
|
|
38
|
+
artifactResources.set(manifest, files);
|
|
39
|
+
}
|
|
40
|
+
const expected = files.get(path);
|
|
41
|
+
if (!expected) throw new TypeError('compiler resource has no artifact identity: ' + path);
|
|
42
|
+
return expected;
|
|
43
|
+
}
|
|
44
|
+
async function response(url, signal) {
|
|
45
|
+
abort(signal);
|
|
46
|
+
const result = await fetch(url, {signal});
|
|
47
|
+
if (!result.ok) {
|
|
48
|
+
const error = new Error(`compiler resource request failed: ${result.status} ${result.statusText}`);
|
|
49
|
+
error.status = result.status;error.url = result.url || String(url);throw error;
|
|
50
|
+
}
|
|
51
|
+
abort(signal);return result;
|
|
52
|
+
}
|
|
53
|
+
async function resourceBytes(url, signal, identity) {
|
|
54
|
+
const resource = await response(url, signal);
|
|
55
|
+
const bytes = new Uint8Array(await resource.arrayBuffer());
|
|
56
|
+
abort(signal);
|
|
57
|
+
if (identity) {
|
|
58
|
+
if (bytes.byteLength !== identity.bytes) throw new Error('compiler resource byte count mismatch: ' + url);
|
|
59
|
+
if (!globalThis.crypto?.subtle) throw new Error('compiler resource SHA-256 verification is unavailable');
|
|
60
|
+
const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', bytes));
|
|
61
|
+
abort(signal);
|
|
62
|
+
const actual = Array.from(digest, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
63
|
+
if (actual !== identity.sha256) throw new Error('compiler resource SHA-256 mismatch: ' + url);
|
|
64
|
+
}
|
|
65
|
+
return bytes;
|
|
66
|
+
}
|
|
67
|
+
async function sourceText(url, signal, identity, encoding) {
|
|
68
|
+
const bytes = await resourceBytes(url, signal, identity);
|
|
69
|
+
// Source offsets and identities refer to the original input, including its
|
|
70
|
+
// BOM. Fetch's text decoder strips it and replaces malformed UTF-8.
|
|
71
|
+
return decodeCompilerSourceAsset(bytes, encoding);
|
|
72
|
+
}
|
|
73
|
+
async function sessionConfiguration({host, manifestURL, options = {}, signal}) {
|
|
74
|
+
if (!['javascript', 'wasm'].includes(host)) throw new TypeError('browser compiler host must be javascript or wasm');
|
|
75
|
+
if (!manifestURL) throw new TypeError('browser compiler requires an explicit artifact manifest URL');
|
|
76
|
+
const resolved = new URL(manifestURL, globalThis.location?.href ?? import.meta.url);
|
|
77
|
+
const fetched = await response(resolved, signal), manifest = await fetched.json();abort(signal);
|
|
78
|
+
if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest) || manifest.host !== host ||
|
|
79
|
+
manifest.target !== undefined && manifest.target !== host) {
|
|
80
|
+
throw new TypeError('compiler manifest does not match the requested browser host');
|
|
81
|
+
}
|
|
82
|
+
const base = new URL('./', fetched.url || resolved.href);
|
|
83
|
+
const artifactURL = relativeURL(manifest.path, base, 'compiler path');
|
|
84
|
+
const configuration = {host, memory: manifest.memory ?? {}, options: {...manifest.budget, auto: manifest.auto ?? 65536, ...options}};
|
|
85
|
+
if (options?.debug === undefined && manifest.debugPath !== undefined && manifest.debugPath !== null) {
|
|
86
|
+
const debugURL = relativeURL(manifest.debugPath, base, 'compiler debug path');
|
|
87
|
+
const bytes = await resourceBytes(debugURL, signal, resourceIdentity(manifest, manifest.debugPath));
|
|
88
|
+
configuration.options.debug = JSON.parse(new TextDecoder('utf-8', {fatal: true}).decode(bytes));
|
|
89
|
+
abort(signal);
|
|
90
|
+
}
|
|
91
|
+
if (host === 'javascript') {
|
|
92
|
+
if (!/\.(?:mjs|js)$/.test(artifactURL.pathname)) throw new TypeError('JavaScript compiler manifest must name a module');
|
|
93
|
+
configuration.compiler = await import(/* @vite-ignore */ artifactURL.href);abort(signal);
|
|
94
|
+
} else {
|
|
95
|
+
configuration.bytes = await resourceBytes(artifactURL, signal, resourceIdentity(manifest, manifest.path));
|
|
96
|
+
abort(signal);
|
|
97
|
+
}
|
|
98
|
+
return {configuration, manifest, manifestURL: fetched.url || resolved.href};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// This entry may be called by a deployment's own module Worker as well as the
|
|
102
|
+
// owned Worker below. No native module is imported by the browser loader.
|
|
103
|
+
export async function installBrowserCompilerWorker(scope, options) {
|
|
104
|
+
const {configuration} = await sessionConfiguration(options);
|
|
105
|
+
return installCompilerWorker(scope, configuration);
|
|
106
|
+
}
|
|
107
|
+
function keyFor(payload) {
|
|
108
|
+
if (Array.isArray(payload.modules)) return (payload.operation==='project-ir'?'project-ir:':'project:') + payload.entry;
|
|
109
|
+
if (typeof payload.ir === 'string') return 'ir:' + (payload.filename ?? '<input>');
|
|
110
|
+
if (typeof payload.source === 'string') return 'source:' + (payload.filename ?? '<input>');
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
function snapshotPayload(payload){
|
|
114
|
+
const text=typeof payload==='string'?payload:JSON.stringify(payload);
|
|
115
|
+
if(typeof text!=='string')throw new TypeError('compiler request requires a JSON object');
|
|
116
|
+
const value=JSON.parse(text);
|
|
117
|
+
if(value===null||typeof value!=='object'||Array.isArray(value))throw new TypeError('compiler request requires a JSON object');
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function createBrowserCompiler({
|
|
122
|
+
host = 'javascript', manifestURL, workerClient, ownsWorkerClient = false,
|
|
123
|
+
worker = true, signal, options = {}, runtimeURL, runtimeSource,
|
|
124
|
+
} = {}) {
|
|
125
|
+
if (!['javascript', 'wasm'].includes(host)) throw new TypeError('browser compiler host must be javascript or wasm');
|
|
126
|
+
abort(signal);
|
|
127
|
+
let session, client = workerClient, ownsClient = ownsWorkerClient, ownedWorker, blobURL, closed = false, removeLoadingAbort;
|
|
128
|
+
const snapshots = new Map();let sourceRevision = 0, artifactManifest, artifactManifestURL;
|
|
129
|
+
let runtimeReady = false, runtimeLoading, literalSourcesLoading;
|
|
130
|
+
async function dispose() {
|
|
131
|
+
if (closed) return;closed = true;snapshots.clear();
|
|
132
|
+
let failed = false, failure;
|
|
133
|
+
try {if (client && ownsClient) await client.close();else session?.close();}
|
|
134
|
+
catch (error) {failed = true;failure = error;}
|
|
135
|
+
finally {ownedWorker?.terminate();if (blobURL) URL.revokeObjectURL(blobURL);}
|
|
136
|
+
client = undefined;session = undefined;ownedWorker = undefined;blobURL = undefined;
|
|
137
|
+
if (failed) throw failure;
|
|
138
|
+
}
|
|
139
|
+
function active() {if (closed) throw new Error('browser compiler is disposed');}
|
|
140
|
+
try {
|
|
141
|
+
if (!client && worker) {
|
|
142
|
+
if (typeof Worker !== 'function') throw new Error('module Workers are unavailable; select worker:false explicitly to use the same artifact on this thread');
|
|
143
|
+
if (!manifestURL) throw new TypeError('browser compiler requires an explicit artifact manifest URL');
|
|
144
|
+
const configuration = {host, manifestURL: new URL(manifestURL, globalThis.location?.href ?? import.meta.url).href, options};
|
|
145
|
+
const entry = `const waiting=[],loading=new AbortController();const hold=event=>{if(event.data?.type==='abort-browser-compiler-loading')loading.abort();else waiting.push(event.data);};self.addEventListener('message',hold);\n` +
|
|
146
|
+
`const{installBrowserCompilerWorker}=await import(${JSON.stringify(import.meta.url)});\n` +
|
|
147
|
+
`await installBrowserCompilerWorker(self,{...${JSON.stringify(configuration)},signal:loading.signal});\n` +
|
|
148
|
+
`self.removeEventListener('message',hold);for(const data of waiting)self.dispatchEvent(new MessageEvent('message',{data}));\n`;
|
|
149
|
+
blobURL = URL.createObjectURL(new Blob([entry], {type: 'text/javascript'}));
|
|
150
|
+
ownedWorker = new Worker(blobURL, {type: 'module'});
|
|
151
|
+
if (signal) {
|
|
152
|
+
const cancelLoading = () => {
|
|
153
|
+
try {ownedWorker?.postMessage({type: 'abort-browser-compiler-loading'});} catch {}
|
|
154
|
+
};
|
|
155
|
+
signal.addEventListener('abort', cancelLoading, {once: true});
|
|
156
|
+
removeLoadingAbort = () => signal.removeEventListener('abort', cancelLoading);
|
|
157
|
+
if (signal.aborted) cancelLoading();
|
|
158
|
+
}
|
|
159
|
+
client = createCompilerWorkerClient(ownedWorker, {ownsWorker: true});ownsClient = true;
|
|
160
|
+
} else if (!client) {
|
|
161
|
+
const loaded = await sessionConfiguration({host, manifestURL, options, signal});
|
|
162
|
+
artifactManifest = loaded.manifest;artifactManifestURL = loaded.manifestURL;
|
|
163
|
+
session = await createCompilerSession(loaded.configuration);abort(signal);
|
|
164
|
+
}
|
|
165
|
+
if (client) {
|
|
166
|
+
if (typeof client.request !== 'function' || typeof client.setSource !== 'function' || typeof client.close !== 'function') {
|
|
167
|
+
throw new TypeError('browser compiler requires a compiler Worker client');
|
|
168
|
+
}
|
|
169
|
+
const capabilities = await client.request({operation: 'capabilities'}, {signal});
|
|
170
|
+
if (capabilities?.host !== host) throw new TypeError('compiler Worker is executing a different host artifact');
|
|
171
|
+
abort(signal);
|
|
172
|
+
}
|
|
173
|
+
} catch (error) {try {await dispose();} catch {}throw error;}
|
|
174
|
+
finally {removeLoadingAbort?.();removeLoadingAbort = undefined;}
|
|
175
|
+
|
|
176
|
+
async function dispatch(payload, requestOptions) {
|
|
177
|
+
active();abort(requestOptions?.signal);
|
|
178
|
+
if (!client) return session.request(payload, requestOptions);
|
|
179
|
+
const reply = await client.request(payload, requestOptions);active();
|
|
180
|
+
if (reply.host !== host) throw new TypeError('compiler Worker changed its host artifact');
|
|
181
|
+
return reply.result;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function runtimeRequest(payload, requestOptions = {}) {
|
|
185
|
+
if (Object.hasOwn(payload, 'literalSources')) return payload;
|
|
186
|
+
active();abort(requestOptions.signal);
|
|
187
|
+
if (!artifactManifest && manifestURL) {
|
|
188
|
+
const resolved = new URL(manifestURL, globalThis.location?.href ?? import.meta.url);
|
|
189
|
+
const fetched = await response(resolved, requestOptions.signal);
|
|
190
|
+
const manifest = await fetched.json();active();abort(requestOptions.signal);
|
|
191
|
+
if (!manifest || manifest.host !== host) throw new TypeError('compiler runtime manifest host mismatch');
|
|
192
|
+
artifactManifest = manifest;artifactManifestURL = fetched.url || resolved.href;
|
|
193
|
+
}
|
|
194
|
+
if (artifactManifest?.literalSources === undefined) return payload;
|
|
195
|
+
if (!literalSourcesLoading) literalSourcesLoading = (async () => {
|
|
196
|
+
if (!Array.isArray(artifactManifest.literalSources)) throw new TypeError('compiler literalSources must be an array');
|
|
197
|
+
return Promise.all(artifactManifest.literalSources.map(async item => {
|
|
198
|
+
if (typeof item?.id !== 'string' || typeof item.filename !== 'string') throw new TypeError('invalid compiler literal source asset');
|
|
199
|
+
const url = relativeURL(item.path, new URL('./', artifactManifestURL), 'compiler literal source path');
|
|
200
|
+
const source = await sourceText(url, requestOptions.signal, resourceIdentity(artifactManifest, item.path), item.encoding);active();abort(requestOptions.signal);
|
|
201
|
+
return {id: item.id, filename: item.filename, source};
|
|
202
|
+
}));
|
|
203
|
+
})().catch(error => {literalSourcesLoading = undefined;throw error;});
|
|
204
|
+
const literalSources = await literalSourcesLoading;active();abort(requestOptions.signal);
|
|
205
|
+
return {...payload, literalSources};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async function loadRuntime(requestOptions = {}) {
|
|
209
|
+
active();abort(requestOptions.signal);
|
|
210
|
+
if (runtimeReady) return;
|
|
211
|
+
if (!runtimeLoading) {
|
|
212
|
+
runtimeLoading = (async () => {
|
|
213
|
+
let source = runtimeSource;
|
|
214
|
+
if (source !== undefined && typeof source !== 'string') throw new TypeError('compiler runtime source must be a string');
|
|
215
|
+
if (source === undefined) {
|
|
216
|
+
let url, identity, encoding;
|
|
217
|
+
if (runtimeURL !== undefined) url = new URL(runtimeURL, globalThis.location?.href ?? import.meta.url);
|
|
218
|
+
else {
|
|
219
|
+
if (!artifactManifest) {
|
|
220
|
+
if (!manifestURL) throw new TypeError('binary output requires the compiler runtime source or an artifact manifest');
|
|
221
|
+
const resolved = new URL(manifestURL, globalThis.location?.href ?? import.meta.url);
|
|
222
|
+
const fetched = await response(resolved, requestOptions.signal);
|
|
223
|
+
const manifest = await fetched.json();abort(requestOptions.signal);
|
|
224
|
+
if (!manifest || manifest.host !== host) throw new TypeError('compiler runtime manifest host mismatch');
|
|
225
|
+
artifactManifest = manifest;artifactManifestURL = fetched.url || resolved.href;
|
|
226
|
+
}
|
|
227
|
+
url = relativeURL(artifactManifest.runtimePath, new URL('./', artifactManifestURL), 'compiler runtime path');
|
|
228
|
+
identity = resourceIdentity(artifactManifest, artifactManifest.runtimePath);
|
|
229
|
+
encoding = artifactManifest.runtimeEncoding;
|
|
230
|
+
}
|
|
231
|
+
source = await sourceText(url, requestOptions.signal, identity, encoding);
|
|
232
|
+
}
|
|
233
|
+
active();abort(requestOptions.signal);
|
|
234
|
+
// A caller can install an explicit runtime while the default asset is
|
|
235
|
+
// downloading. Keep that completed source revision as the owner.
|
|
236
|
+
if (runtimeReady) return;
|
|
237
|
+
const request = await runtimeRequest({operation: 'runtime', source, filename: 'bootstrap/runtime/memory.eli'}, requestOptions);
|
|
238
|
+
active();abort(requestOptions.signal);
|
|
239
|
+
if (runtimeReady) return;
|
|
240
|
+
if (client) await setSource(request, {signal: requestOptions.signal});
|
|
241
|
+
active();abort(requestOptions.signal);
|
|
242
|
+
if (runtimeReady) return;
|
|
243
|
+
await dispatch(request, {signal: requestOptions.signal});
|
|
244
|
+
runtimeReady = true;
|
|
245
|
+
})();
|
|
246
|
+
}
|
|
247
|
+
const pending = runtimeLoading;
|
|
248
|
+
try {await pending;active();abort(requestOptions.signal);}
|
|
249
|
+
finally {if (runtimeLoading === pending) runtimeLoading = undefined;}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
async function setSource(payload, {revision, signal: requestSignal} = {}) {
|
|
253
|
+
active();abort(requestSignal);
|
|
254
|
+
payload=snapshotPayload(payload);
|
|
255
|
+
const key = keyFor(payload);if (key === null) throw new TypeError('source snapshot requires source text or project modules');
|
|
256
|
+
const sourceIdentity = await compilerSourceIdentity(payload);active();abort(requestSignal);
|
|
257
|
+
const previous = snapshots.get(key);
|
|
258
|
+
const nextRevision = revision ?? (previous?.sourceIdentity === sourceIdentity ? previous.revision : sourceRevision + 1);
|
|
259
|
+
if (!Number.isSafeInteger(nextRevision) || nextRevision < 0 || previous &&
|
|
260
|
+
(nextRevision < previous.revision || nextRevision === previous.revision && previous.sourceIdentity !== sourceIdentity)) {
|
|
261
|
+
throw stale('source snapshot belongs to an older revision');
|
|
262
|
+
}
|
|
263
|
+
const next = {revision: nextRevision, sourceIdentity};sourceRevision = Math.max(sourceRevision, nextRevision);
|
|
264
|
+
snapshots.set(key, next);
|
|
265
|
+
try {
|
|
266
|
+
if (client) await client.setSource(payload, {revision: nextRevision, signal: requestSignal});
|
|
267
|
+
active();abort(requestSignal);return {...next};
|
|
268
|
+
} catch (error) {
|
|
269
|
+
if (!closed && snapshots.get(key) === next) {if (previous) snapshots.set(key, previous);else snapshots.delete(key);}
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async function request(payload, requestOptions = {}) {
|
|
274
|
+
active();abort(requestOptions.signal);
|
|
275
|
+
payload=snapshotPayload(payload);
|
|
276
|
+
if (payload.operation === 'runtime') payload = await runtimeRequest(payload, requestOptions);
|
|
277
|
+
if (['project','project-ir','emit-ir'].includes(payload.operation) && (payload.target === 'wasm' || payload.target === 'native')) {
|
|
278
|
+
await loadRuntime(requestOptions);
|
|
279
|
+
}
|
|
280
|
+
const key = keyFor(payload), readOnly = ['analyze', 'query', 'edit-preview'].includes(payload.operation);let selectedSnapshot;
|
|
281
|
+
if (key !== null) {
|
|
282
|
+
const sourceIdentity = await compilerSourceIdentity(payload);active();abort(requestOptions.signal);
|
|
283
|
+
const current = snapshots.get(key);
|
|
284
|
+
if (!current || current.sourceIdentity !== sourceIdentity) {
|
|
285
|
+
if (readOnly || requestOptions.expectedSourceIdentity !== undefined || requestOptions.expectedRevision !== undefined) {
|
|
286
|
+
throw stale('register the current source snapshot before requesting queries or applying older results');
|
|
287
|
+
}
|
|
288
|
+
await setSource(payload, {signal: requestOptions.signal});
|
|
289
|
+
}
|
|
290
|
+
const selected = snapshots.get(key);
|
|
291
|
+
selectedSnapshot=selected;
|
|
292
|
+
if (requestOptions.expectedSourceIdentity !== undefined && requestOptions.expectedSourceIdentity !== selected.sourceIdentity ||
|
|
293
|
+
requestOptions.expectedRevision !== undefined && requestOptions.expectedRevision !== selected.revision) {
|
|
294
|
+
throw stale('request belongs to an older source snapshot');
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
active();
|
|
298
|
+
const result = await dispatch(payload, requestOptions);
|
|
299
|
+
active();abort(requestOptions.signal);
|
|
300
|
+
if(key!==null){const current=snapshots.get(key);if(!current||current.revision!==selectedSnapshot.revision||current.sourceIdentity!==selectedSnapshot.sourceIdentity)throw stale('compiler response belongs to an older source snapshot');}
|
|
301
|
+
if (payload.operation === 'runtime') runtimeReady = true;
|
|
302
|
+
return result;
|
|
303
|
+
}
|
|
304
|
+
return Object.freeze({
|
|
305
|
+
host,
|
|
306
|
+
request,
|
|
307
|
+
setSource,
|
|
308
|
+
loadRuntime,
|
|
309
|
+
async compile_string(source, filename = '<input>', macroContext = null, requestOptions = {}) {
|
|
310
|
+
return (await request({operation: 'compile', source, filename, macroContext}, requestOptions)).javascript;
|
|
311
|
+
},
|
|
312
|
+
async compile_string_with_source_map(source, filename = '<input>', generatedFile = 'output.mjs', sourceName = filename, macroContext = null, requestOptions = {}) {
|
|
313
|
+
const result = await request({operation: 'compile', source, filename, macroContext, sourceMap: {generatedFile, sourceName}}, requestOptions);
|
|
314
|
+
return {javascript: result.javascript, sourceMap: result.sourceMap};
|
|
315
|
+
},
|
|
316
|
+
async compile_ir_string(source, filename = '<input>', macroContext = null, requestOptions = {}) {
|
|
317
|
+
const result = await request({operation: 'compile-ir', source, filename, macroContext}, requestOptions);
|
|
318
|
+
return JSON.parse(result.ir);
|
|
319
|
+
},
|
|
320
|
+
async serialize_ir_program(program, requestOptions = {}) {
|
|
321
|
+
return (await request({operation: 'serialize-ir', ir: encodeCompilerIR(program)}, requestOptions)).canonicalIR;
|
|
322
|
+
},
|
|
323
|
+
async deserialize_ir_program(canonicalIR, requestOptions = {}) {
|
|
324
|
+
return JSON.parse((await request({operation: 'deserialize-ir', canonicalIR}, requestOptions)).ir);
|
|
325
|
+
},
|
|
326
|
+
async emit_ir_string(program, requestOptions = {}) {
|
|
327
|
+
return (await request({operation: 'emit-ir', ir: encodeCompilerIR(program)}, requestOptions)).javascript;
|
|
328
|
+
},
|
|
329
|
+
async emit_ir_string_with_source_map(program, source, generatedFile = 'output.mjs', sourceName = program.filename, requestOptions = {}) {
|
|
330
|
+
return request({operation: 'emit-ir', ir: encodeCompilerIR(program), source,
|
|
331
|
+
sourceMap: {generatedFile, sourceName}}, requestOptions);
|
|
332
|
+
},
|
|
333
|
+
async compile_portable_ir_string(source, entries, filename = '<input>', macroContext = null, requestOptions = {}) {
|
|
334
|
+
const result = await request({operation: 'compile-ir', source, filename, macroContext, portableEntries: entries}, requestOptions);
|
|
335
|
+
return JSON.parse(result.ir);
|
|
336
|
+
},
|
|
337
|
+
async compile_project_portable_ir_string(source, entries, filename = '<input>', macroContext = null, requestOptions = {}) {
|
|
338
|
+
const result = await request({operation: 'compile-ir', source, filename, macroContext,
|
|
339
|
+
portableEntries: entries, allowProjectImports: true}, requestOptions);
|
|
340
|
+
return JSON.parse(result.ir);
|
|
341
|
+
},
|
|
342
|
+
async compile_portable_string(source, entries, filename = '<input>', macroContext = null, requestOptions = {}) {
|
|
343
|
+
return (await request({operation: 'compile', source, filename, macroContext, portableEntries: entries}, requestOptions)).javascript;
|
|
344
|
+
},
|
|
345
|
+
async compile_portable_string_with_source_map(source, entries, filename = '<input>', generatedFile = 'output.mjs', sourceName = filename, macroContext = null, requestOptions = {}) {
|
|
346
|
+
const result = await request({operation: 'compile', source, filename, macroContext, portableEntries: entries,
|
|
347
|
+
sourceMap: {generatedFile, sourceName}}, requestOptions);
|
|
348
|
+
return {javascript: result.javascript, sourceMap: result.sourceMap};
|
|
349
|
+
},
|
|
350
|
+
async format_source(source, filename = '<input>', formatOptions = null, requestOptions = {}) {
|
|
351
|
+
return (await request({operation: 'format', source, filename, options: formatOptions}, requestOptions)).source;
|
|
352
|
+
},
|
|
353
|
+
compile_project(project, requestOptions = {}) {return request({...project, operation: 'project'}, requestOptions);},
|
|
354
|
+
project_plan(project, requestOptions = {}) {return request({...project, operation: 'project-plan'}, requestOptions);},
|
|
355
|
+
protocol(name, input, requestOptions = {}) {return request({operation: 'protocol', name, input}, requestOptions);},
|
|
356
|
+
analyze(input, requestOptions = {}) {return request({...input, operation: 'analyze'}, requestOptions);},
|
|
357
|
+
query(input, requestOptions = {}) {return request({...input, operation: 'query'}, requestOptions);},
|
|
358
|
+
dispose,
|
|
359
|
+
close: dispose,
|
|
360
|
+
});
|
|
361
|
+
}
|