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,2980 @@
|
|
|
1
|
+
// Generated by Eliscript. Do not edit.
|
|
2
|
+
import { tdz as __eliscript_tdz_error, immutable as __eliscript_const_error } from "data:text/javascript;base64,Y29uc3QgRSA9IFJlZmVyZW5jZUVycm9yOyBjb25zdCBUID0gVHlwZUVycm9yOyBleHBvcnQgZnVuY3Rpb24gdGR6KG5hbWUpIHsgdGhyb3cgbmV3IEUoIkNhbm5vdCBhY2Nlc3MgJyIgKyBuYW1lICsgIicgYmVmb3JlIGluaXRpYWxpemF0aW9uIik7IH0gZXhwb3J0IGZ1bmN0aW9uIGltbXV0YWJsZSgpIHsgdGhyb3cgbmV3IFQoIkFzc2lnbm1lbnQgdG8gY29uc3RhbnQgdmFyaWFibGUuIik7IH0K";
|
|
3
|
+
var __eliscript_tdz_ready_0;
|
|
4
|
+
function __eliscript_tdz_read_0() { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("session_json_parts_join"); return session_json_parts_join; }
|
|
5
|
+
function __eliscript_tdz_write_0(__eliscript_tdz_value_0) { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("session_json_parts_join"); return __eliscript_const_error(); }
|
|
6
|
+
var __eliscript_tdz_ready_1;
|
|
7
|
+
function __eliscript_tdz_read_1() { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("session_response_identity_segment_size"); return session_response_identity_segment_size; }
|
|
8
|
+
function __eliscript_tdz_write_1(__eliscript_tdz_value_1) { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("session_response_identity_segment_size"); return __eliscript_const_error(); }
|
|
9
|
+
import "eliscript/runtime/unicode-case.mjs";
|
|
10
|
+
import { c as __eliscript_at, d as __eliscript_at_direct } from "data:text/javascript;base64,dmFyIG09UmVmbGVjdC5hcHBseSx0dD1OdW1iZXIucHJvdG90eXBlLnZhbHVlT2Ysaj1OdW1iZXIucHJvdG90eXBlLnRvU3RyaW5nLFU9TnVtYmVyLG50PU9iamVjdC5jcmVhdGUsaD1CaWdJbnQsZXQ9RGF0YVZpZXcsb3Q9QXJyYXlCdWZmZXIsaXQ9RGF0YVZpZXcucHJvdG90eXBlLnNldEZsb2F0NjQsSj1EYXRhVmlldy5wcm90b3R5cGUuZ2V0VWludDMyLHJ0PVJhbmdlRXJyb3I7ZnVuY3Rpb24gY3QodCxuKXtsZXQgZT1oKG4pLG89aCh0KSxpPSIiO2lmKG88MG4pbz0tbztkb3tsZXQgZj1vJWU7aT0iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltVKGYpXStpLG8vPWV9d2hpbGUobyE9PTBuKTtyZXR1cm4gdDwwPyItIitpOml9ZnVuY3Rpb24gc3QodCxuKXtsZXQgZT1uZXcgZXQobmV3IG90KDgpKTttKGl0LGUsWzAsdCwhMV0pO2xldCBvPW0oSixlLFswLCExXSksaT1tKEosZSxbNCwhMV0pLGY9bz4+PjIwJjIwNDcsYj1vJjEwNDg1NzUscD1vPj4+MzEscj1oKGIpPDwzMm58aChpKTtpZihmIT09MClyKz0xbjw8NTJuO3I8PD0ybjtsZXQgbD00bix1PWY+MSYmYj09PTAmJmk9PT0wPzFuOjJuLGs9Mm47aWYoZj49MTA3NSl7bGV0IGM9aChmLTEwNzUpO3I8PD1jLHU8PD1jLGs8PD1jfWVsc2UgbDw8PWgoZj09PTA/MTA3NDoxMDc1LWYpO2xldCBkPWgobiksZz1udChudWxsKSxhPTAsUz0wLEQ9MDtpZihyPGwpd2hpbGUocjxsKXtpZihyKjJuPmwmJnIraz5sKWJyZWFrO3IqPWQsdSo9ZCxrKj1kLFMtLX1lbHNlIHdoaWxlKHI+PWwqZClsKj1kLFMrKztmb3IoOzspe2xldCBjPVUoci9sKTtyJT1sO2xldCBJPXI8dSx4PXIraz5sO2dbYSsrXT1jLEQ9RCoobiYxKStjJjE7bGV0IHE9cioybixQPXE+bHx8cT09PWwmJkQ9PT0xO2lmKFAmJnh8fCFQJiZJKXtpZihQKXtsZXQgUj1hLEI9ITA7d2hpbGUoUj4wJiZCKXtSLS07bGV0IEg9Z1tSXSsxO2lmKEg9PT1uKWdbUl09MDtlbHNlIGdbUl09SCxCPSExfWlmKEIpZ1swXT0xLFMrK31icmVha31pZihhPj02NCl0aHJvdyBuZXcgcnQoIm51bWJlciByYWRpeCBmb3JtYXR0aW5nIGRpZCBub3QgY29udmVyZ2UiKTtyKj1kLHUqPWQsayo9ZH13aGlsZShhPjEmJmdbYS0xXT09PTApYS0tO2xldCB3PSIiO2lmKFM8MCl7dz0iMC4iO2ZvcihsZXQgYz0wO2M8LTEtUztjKyspdys9IjAiO2ZvcihsZXQgYz0wO2M8YTtjKyspdys9IjAxMjM0NTY3ODlhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5eiJbZ1tjXV19ZWxzZXtsZXQgYz1TKzEsST1jPmE/YzphO2ZvcihsZXQgeD0wO3g8STt4Kyspe2lmKHg9PT1jJiZjPGEpdys9Ii4iO3crPXg8YT8iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltnW3hdXToiMCJ9fXJldHVybiBwPyItIit3Ond9ZnVuY3Rpb24gRyh0LG4pe2xldCBlO3RyeXtlPW0odHQsdCxbXSl9Y2F0Y2h7cmV0dXJuIG0oaix0LFtuXSl9bGV0IG89MTA7aWYobiE9PXZvaWQgMCl7bGV0IGk9K247aWYobz1pIT09aT8wOmktaSUxLG88Mnx8bz4zNnx8byE9PW8pcmV0dXJuIG0oaixlLFtvXSl9aWYobz09PTEwfHxlPT09MHx8ZSE9PWV8fGU9PT0xLzB8fGU9PT0tMS8wKXJldHVybiBtKGosZSxbMTBdKTtyZXR1cm4gZSUxPT09MD9jdChlLG8pOnN0KGUsbyl9dmFyIHM9UmVmbGVjdC5hcHBseSxNPUZ1bmN0aW9uLnByb3RvdHlwZS5jYWxsLE49RnVuY3Rpb24ucHJvdG90eXBlLmFwcGx5LEU9RnVuY3Rpb24ucHJvdG90eXBlLmJpbmQsVD1PYmplY3QuZGVmaW5lUHJvcGVydHksbHQ9T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcixmdD1PYmplY3QuZ2V0UHJvdG90eXBlT2YsdXQ9T2JqZWN0LnNldFByb3RvdHlwZU9mLGF0PVJlZmxlY3Qub3duS2V5cyxwdD1TeW1ib2wuaGFzSW5zdGFuY2UsVj1BcnJheS5pc0FycmF5LEs9QXJyYXkucHJvdG90eXBlLmpvaW4sej1BcnJheS5wcm90b3R5cGUudG9TdHJpbmcseXQ9T2JqZWN0LnByb3RvdHlwZS50b1N0cmluZyxidD1TdHJpbmcsQz1UeXBlRXJyb3IsZHQ9U3ltYm9sLnRvUHJpbWl0aXZlLGd0PVdlYWtTZXQucHJvdG90eXBlLmhhcyx3dD1XZWFrU2V0LnByb3RvdHlwZS5hZGQseHQ9V2Vha1NldC5wcm90b3R5cGUuZGVsZXRlLEY9bmV3IFdlYWtTZXQsTz1udWxsLFc9KHQpPT50IT09bnVsbCYmKHR5cGVvZiB0PT09Im9iamVjdCJ8fHR5cGVvZiB0PT09ImZ1bmN0aW9uInx8dHlwZW9mIHQ+InUiJiZ0IT09dm9pZCAwKSxBPSh0KT0+dHlwZW9mIHQ9PT0iZnVuY3Rpb24ifHx0eXBlb2YgdD4idSImJnQhPT12b2lkIDA7ZnVuY3Rpb24gaHQoKXtsZXQgbj1uZXcgQygiY3ljbGljIGFycmF5IHRleHQgY29udmVyc2lvbiIpO3Rocm93IG4uZWxpc2NyaXB0RGlhZ25vc3RpYz17Zm9ybWF0OiJlbGlzY3JpcHQtZGlhZ25vc3RpYyIsdmVyc2lvbjoxLGNvZGU6IkVMSS1SVDAwMDkiLHNldmVyaXR5OiJlcnJvciIscGhhc2U6InJ1bnRpbWUiLG1lc3NhZ2U6ImN5Y2xpYyBhcnJheSB0ZXh0IGNvbnZlcnNpb24ifSxufWZ1bmN0aW9uIG10KHQpe2lmKCFXKHQpKXJldHVybiB0O2xldCBuPXRbZHRdO2lmKG4hPT12b2lkIDAmJm4hPT1udWxsKXtsZXQgZT1zKG4sdCxbInN0cmluZyJdKTtpZighVyhlKSlyZXR1cm4gZTt0aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZSIpfWZvcihsZXQgZT0wO2U8MjtlKyspe2xldCBvPXRbZT09PTA/InRvU3RyaW5nIjoidmFsdWVPZiJdO2lmKEEobykpe2xldCBpPW89PT16JiZWKHQpP3YodCk6cyhvLHQsW10pO2lmKCFXKGkpKXJldHVybiBpfX10aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZSIpfWZ1bmN0aW9uIFEodCl7bGV0IG49bXQodCk7aWYodHlwZW9mIG49PT0ic3ltYm9sIil0aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgYSBTeW1ib2wgdmFsdWUgdG8gYSBzdHJpbmciKTtyZXR1cm4gYnQobil9ZnVuY3Rpb24gXyh0LG4pe2xldCBlPSt0Lmxlbmd0aCxvPWUhPT1lfHxlPD0wPzA6ZT49OTAwNzE5OTI1NDc0MDk5MT85MDA3MTk5MjU0NzQwOTkxOmUtZSUxLGk9bj09PXZvaWQgMD8iLCI6UShuKSxmPU89PT1udWxsO2lmKGYpTz10O2Vsc2V7aWYodD09PU98fHMoZ3QsRixbdF0pKWh0KCk7cyh3dCxGLFt0XSl9dHJ5e2xldCBiPSIiO2ZvcihsZXQgcD0wO3A8bztwKyspe2lmKHApYis9aTtsZXQgcj10W3BdO2lmKHIhPT1udWxsJiZyIT09dm9pZCAwKWIrPVEocil9cmV0dXJuIGJ9ZmluYWxseXtpZihmKU89bnVsbDtlbHNlIHMoeHQsRixbdF0pfX1mdW5jdGlvbiB2KHQpe2xldCBuPXQuam9pbjtyZXR1cm4gQShuKT9uPT09Sz9fKHQsdm9pZCAwKTpzKG4sdCxbXSk6cyh5dCx0LFtdKX1mdW5jdGlvbiB5KHQsbil7cmV0dXJuIG48dC5sZW5ndGg/dFtuXTp2b2lkIDB9ZnVuY3Rpb24gWCh0LG4pe2xldCBlPVtdO2ZvcihsZXQgbz1uO288dC5sZW5ndGg7bysrKVQoZSxlLmxlbmd0aCx7dmFsdWU6dFtvXSx3cml0YWJsZTohMCxlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMH0pO3JldHVybiBlfWZ1bmN0aW9uIFN0KHQsbil7bGV0IGU9W107Zm9yKGxldCBvPTA7bzx0Lmxlbmd0aCtuLmxlbmd0aDtvKyspVChlLG8se3ZhbHVlOm88dC5sZW5ndGg/dFtvXTpuW28tdC5sZW5ndGhdLHdyaXRhYmxlOiEwLGVudW1lcmFibGU6ITAsY29uZmlndXJhYmxlOiEwfSk7cmV0dXJuIGV9ZnVuY3Rpb24gWSguLi50KXtyZXR1cm4gdH1mdW5jdGlvbiBaKHQsbil7cmV0dXJuIG4/cyhOLFksW3ZvaWQgMCx0XSk6cyhZLHZvaWQgMCx0KX1mdW5jdGlvbiBMKHQsbixlKXtmb3IoOzspe2lmKHQ9PT1qKXJldHVybiBHKG4seShlLDApKTtpZih0PT09SyYmVihuKSlyZXR1cm4gXyhuLHkoZSwwKSk7aWYodD09PXomJlYobikpcmV0dXJuIHYobik7aWYodD09PU0pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9WChlLDEpLHQ9byxuPWk7Y29udGludWV9aWYodD09PU4pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9Wih5KGUsMSksITApLHQ9byxuPWk7Y29udGludWV9aWYodD09PXMpe2xldCBvPXkoZSwwKSxpPXkoZSwxKTtpZighQShvKSlyZXR1cm4gcyh0LG4sZSk7ZT1aKHkoZSwyKSwhMSksdD1vLG49aTtjb250aW51ZX1pZih0PT09RSl7bGV0IG89cyh0LG4sZSk7aWYobiE9PWomJm4hPT1LJiZuIT09eiYmbiE9PU0mJm4hPT1OJiZuIT09cyYmbiE9PUUpcmV0dXJuIG87bGV0IGk9bixmPXkoZSwwKSxiPVgoZSwxKSxwPSguLi51KT0+TChpLGYsU3QoYix1KSk7VChwLHB0LHt2YWx1ZToodSk9PnUgaW5zdGFuY2VvZiBpLGNvbmZpZ3VyYWJsZTohMH0pO2xldCByPXMoRSxwLFt2b2lkIDBdKTt1dChyLGZ0KG8pKTtsZXQgbD1hdChvKTtmb3IobGV0IHU9MDt1PGwubGVuZ3RoO3UrKylUKHIsbFt1XSxsdChvLGxbdV0pKTtyZXR1cm4gcn1yZXR1cm4gcyh0LG4sZSl9fWZ1bmN0aW9uIFJ0KHQsbil7bGV0IGU9dFtuXTtyZXR1cm4oLi4ubyk9PkwoZSx0LG8pfWZ1bmN0aW9uIEF0KHQsbiwuLi5lKXtsZXQgbz10W25dO3JldHVybiBMKG8sdCxlKX1leHBvcnR7UnQgYXMgYyxBdCBhcyBkfTs=";
|
|
11
|
+
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
12
|
+
const __eliscript_number_intrinsic = globalThis.Number;
|
|
13
|
+
const __eliscript_bigint_intrinsic = globalThis.BigInt;
|
|
14
|
+
const __eliscript_numeric_apply = globalThis.Reflect.apply;
|
|
15
|
+
const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
|
|
16
|
+
const __eliscript_numeric_error = globalThis.TypeError;
|
|
17
|
+
const __eliscript_numeric_trim = globalThis.String.prototype.trim;
|
|
18
|
+
const __eliscript_numeric_slice = globalThis.String.prototype.slice;
|
|
19
|
+
const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
|
|
20
|
+
const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
|
|
21
|
+
const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
|
|
22
|
+
const __eliscript_numeric_primitive = (value) => {
|
|
23
|
+
if (!__eliscript_numeric_object(value)) return value;
|
|
24
|
+
const exotic = value[__eliscript_numeric_symbol];
|
|
25
|
+
if (exotic !== void 0 && exotic !== null) {
|
|
26
|
+
const result = __eliscript_numeric_apply(exotic, value, ["number"]);
|
|
27
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
28
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
29
|
+
}
|
|
30
|
+
for (let index = 0; index < 2; index++) {
|
|
31
|
+
const method = value[index === 0 ? "valueOf" : "toString"];
|
|
32
|
+
if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
|
|
33
|
+
const result = __eliscript_numeric_apply(method, value, []);
|
|
34
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
38
|
+
};
|
|
39
|
+
const __eliscript_to_number = (value) => {
|
|
40
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
41
|
+
if (typeof primitive === "string") {
|
|
42
|
+
const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
|
|
43
|
+
if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
|
|
44
|
+
let first = 2;
|
|
45
|
+
while (first < text.length && text[first] === "0") first++;
|
|
46
|
+
if (first === text.length) return 0;
|
|
47
|
+
const prefix = text[1];
|
|
48
|
+
const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
|
|
49
|
+
if (text.length - first > limit) return 1 / 0;
|
|
50
|
+
const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
|
|
51
|
+
return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return __eliscript_number_intrinsic(primitive);
|
|
55
|
+
};
|
|
56
|
+
const __eliscript_numeric = (value) => {
|
|
57
|
+
if (typeof value === "number" || typeof value === "bigint") return value;
|
|
58
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
59
|
+
if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
|
|
60
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
61
|
+
};
|
|
62
|
+
const __eliscript_implicit_number = (value) => {
|
|
63
|
+
if (typeof value === "number") return value;
|
|
64
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
65
|
+
if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
|
|
66
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
67
|
+
};
|
|
68
|
+
const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
|
|
69
|
+
const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
|
|
70
|
+
const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
|
|
71
|
+
const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
|
|
72
|
+
const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
|
|
73
|
+
const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
|
|
74
|
+
const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
|
|
75
|
+
const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
|
|
76
|
+
const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
|
|
77
|
+
const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
|
|
78
|
+
const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
|
|
79
|
+
const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
|
|
80
|
+
const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
|
|
81
|
+
const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
|
|
82
|
+
const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
|
|
83
|
+
const __eliscript_numeric_relation = (operator, left, right) => {
|
|
84
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
85
|
+
if (operator === "<") return left < right;
|
|
86
|
+
if (operator === "<=") return left <= right;
|
|
87
|
+
if (operator === ">") return left > right;
|
|
88
|
+
return left >= right;
|
|
89
|
+
}
|
|
90
|
+
let a = __eliscript_numeric_primitive(left);
|
|
91
|
+
let b = __eliscript_numeric_primitive(right);
|
|
92
|
+
const x = typeof a, y = typeof b;
|
|
93
|
+
if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
|
|
94
|
+
a = __eliscript_numeric(a);
|
|
95
|
+
b = __eliscript_numeric(b);
|
|
96
|
+
}
|
|
97
|
+
if (operator === "<") return a < b;
|
|
98
|
+
if (operator === "<=") return a <= b;
|
|
99
|
+
if (operator === ">") return a > b;
|
|
100
|
+
return a >= b;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
import {compile_ir_string, compile_project_portable_ir_string, emit_ir_string, emit_ir_string_with_source_map, serialize_ir_program, deserialize_ir_program, format_source, project_plan, portable_project_plan, project_request, project_configuration, build_operation_request, check_operation_request, project_build_report, project_check_report, project_cache_lookup, project_cache_decision, evaluation_operation_request, evaluation_input_description, evaluation_form_description, evaluation_module_description} from "../bootstrap/compiler.mjs";
|
|
104
|
+
import {lower_managed_program, lower_managed_project} from "../backends/managed.mjs";
|
|
105
|
+
import {lower_memory_program} from "../backends/memory.mjs";
|
|
106
|
+
import {emit_typed_memory_wasm, emit_typed_memory_wasm_artifact, append_metadata_section, emit_managed_ir_wasm_product, emit_managed_project_wasm_product} from "../backends/wasm.mjs";
|
|
107
|
+
import {emit_typed_native_memory_library, emit_typed_native_memory_object, emit_typed_native_memory_artifact, emit_fresh_observed_typed_native_memory_object, emit_fresh_observed_typed_native_memory_library, emit_fresh_observed_typed_native_memory_artifact} from "../backends/native.mjs";
|
|
108
|
+
import {tools_request} from "./compiler-tools.mjs";
|
|
109
|
+
import {read_string} from "../bootstrap/reader.mjs";
|
|
110
|
+
import {expand_module, expand_module_with_origins, expand_owned_module, expand_owned_module_with_origins} from "../bootstrap/expander.mjs";
|
|
111
|
+
import {analyze_module, select_portable_module} from "../bootstrap/analyzer.mjs";
|
|
112
|
+
import {lower_module, lower_owned_module} from "../bootstrap/lower.mjs";
|
|
113
|
+
import {validate_serializable_program} from "../bootstrap/ir.mjs";
|
|
114
|
+
import {binding_name} from "../bootstrap/symbol.mjs";
|
|
115
|
+
const session_json_parts_join = (Array.prototype)["join"];
|
|
116
|
+
__eliscript_tdz_ready_0 = true;
|
|
117
|
+
function session_fail(message, filename = null) {
|
|
118
|
+
{
|
|
119
|
+
const __eliscript_value_1 = new (Error)(message);
|
|
120
|
+
{
|
|
121
|
+
let error = __eliscript_value_1;
|
|
122
|
+
{
|
|
123
|
+
const __eliscript_value_2 = ({"format": "eliscript-diagnostic", "version": 1, "code": "ELI-H0001", "severity": "error", "phase": "compiler-session", "message": message});
|
|
124
|
+
{
|
|
125
|
+
let diagnostic = __eliscript_value_2;
|
|
126
|
+
if (__eliscript_truthy(filename)) {
|
|
127
|
+
((diagnostic)["location"] = ({"file": filename}));
|
|
128
|
+
}
|
|
129
|
+
((error)["eliscriptDiagnostic"] = diagnostic);
|
|
130
|
+
return ((__eliscript_value_3) => { throw __eliscript_value_3; })(error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function session_object_p(value) {
|
|
137
|
+
return ((!(value === null)) && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value) === "object") && (!__eliscript_truthy(Array.isArray(value))));
|
|
138
|
+
}
|
|
139
|
+
function session_string(record, key, fallback) {
|
|
140
|
+
{
|
|
141
|
+
const __eliscript_value_4 = ((record)[key] ?? fallback);
|
|
142
|
+
{
|
|
143
|
+
let value = __eliscript_value_4;
|
|
144
|
+
if ((!(((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value) === "string"))) {
|
|
145
|
+
session_fail(("compiler request requires string " + key));
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function session_live(state) {
|
|
152
|
+
if ((!__eliscript_truthy(((__eliscript_value_5) => (__eliscript_truthy(__eliscript_value_5) ? ((((state)["format"] ?? null) === "eliscript-compiler-session") && (((state)["version"] ?? null) === 1) && (((state)["closed"] ?? null) === false)) : __eliscript_value_5))(session_object_p(state))))) {
|
|
153
|
+
session_fail("compiler session is closed or invalid");
|
|
154
|
+
}
|
|
155
|
+
return state;
|
|
156
|
+
}
|
|
157
|
+
function session_phase(state, phase, count) {
|
|
158
|
+
return (() => {
|
|
159
|
+
try {
|
|
160
|
+
{
|
|
161
|
+
const __eliscript_value_6 = ((state)["phaseObserver"] ?? null);
|
|
162
|
+
{
|
|
163
|
+
let observer = __eliscript_value_6;
|
|
164
|
+
if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(observer) === "function")) {
|
|
165
|
+
return observer(phase, ({"count": count}));
|
|
166
|
+
} else {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} catch (ignored) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
})();
|
|
175
|
+
}
|
|
176
|
+
function compiler_session_new() {
|
|
177
|
+
return ({"format": "eliscript-compiler-session", "version": 1, "closed": false, "runtime": null, "runtimeSource": null, "runtimeFilename": null, "revision": 0, "literalSources": null, "literalModules": null, "literalKey": null, "literalRevision": 0, "literalCache": new (globalThis.Map)(), "projectKey": null, "projectModules": null, "projectPortablePlan": null, "projectRevision": 0, "moduleCache": new (globalThis.Map)(), "responseCursor": null, "responseToken": 0, "phaseObserver": null, "lastPhase": null});
|
|
178
|
+
}
|
|
179
|
+
function compiler_session_close(state) {
|
|
180
|
+
session_live(state);
|
|
181
|
+
session_response_clear(state);
|
|
182
|
+
((state)["runtime"] = null);
|
|
183
|
+
((state)["runtimeSource"] = null);
|
|
184
|
+
((state)["runtimeFilename"] = null);
|
|
185
|
+
((state)["literalSources"] = null);
|
|
186
|
+
((state)["literalModules"] = null);
|
|
187
|
+
((state)["literalKey"] = null);
|
|
188
|
+
((state)["literalCache"] = null);
|
|
189
|
+
((state)["projectKey"] = null);
|
|
190
|
+
((state)["projectModules"] = null);
|
|
191
|
+
((state)["projectPortablePlan"] = null);
|
|
192
|
+
((state)["moduleCache"] = null);
|
|
193
|
+
((state)["phaseObserver"] = null);
|
|
194
|
+
((state)["lastPhase"] = null);
|
|
195
|
+
((state)["closed"] = true);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
function session_macro_context(input) {
|
|
199
|
+
if ((!(input === null))) {
|
|
200
|
+
if ((!__eliscript_truthy(session_object_p(input)))) {
|
|
201
|
+
session_fail("macroContext must be an object");
|
|
202
|
+
}
|
|
203
|
+
{
|
|
204
|
+
const __eliscript_value_7 = ((input)["capabilities"] ?? []);
|
|
205
|
+
const __eliscript_value_8 = ((input)["files"] ?? []);
|
|
206
|
+
const __eliscript_value_9 = new (globalThis.Set)();
|
|
207
|
+
const __eliscript_value_10 = new (globalThis.Map)();
|
|
208
|
+
const __eliscript_value_11 = 0;
|
|
209
|
+
{
|
|
210
|
+
let capabilities = __eliscript_value_7;
|
|
211
|
+
let files = __eliscript_value_8;
|
|
212
|
+
let allowed = __eliscript_value_9;
|
|
213
|
+
let contents = __eliscript_value_10;
|
|
214
|
+
let index = __eliscript_value_11;
|
|
215
|
+
if ((!__eliscript_truthy(((__eliscript_value_12) => (__eliscript_truthy(__eliscript_value_12) ? Array.isArray(files) : __eliscript_value_12))(Array.isArray(capabilities))))) {
|
|
216
|
+
session_fail("macroContext requires capability and file arrays");
|
|
217
|
+
}
|
|
218
|
+
while (__eliscript_numeric_relation("<", index, ((capabilities) ?? []).length)) {
|
|
219
|
+
{
|
|
220
|
+
const __eliscript_value_13 = ((((capabilities) ?? [])[index]) ?? null);
|
|
221
|
+
{
|
|
222
|
+
let name = __eliscript_value_13;
|
|
223
|
+
if ((!(name === "read-file"))) {
|
|
224
|
+
session_fail("unsupported macro capability");
|
|
225
|
+
}
|
|
226
|
+
(allowed)["add"](name);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
((index = (index + 1)));
|
|
230
|
+
}
|
|
231
|
+
((index = 0));
|
|
232
|
+
while (__eliscript_numeric_relation("<", index, ((files) ?? []).length)) {
|
|
233
|
+
{
|
|
234
|
+
const __eliscript_value_14 = ((((files) ?? [])[index]) ?? null);
|
|
235
|
+
{
|
|
236
|
+
let item = __eliscript_value_14;
|
|
237
|
+
if ((!__eliscript_truthy(session_object_p(item)))) {
|
|
238
|
+
session_fail("macro file must be an object");
|
|
239
|
+
}
|
|
240
|
+
{
|
|
241
|
+
const __eliscript_value_15 = session_string(item, "specifier", undefined);
|
|
242
|
+
const __eliscript_value_16 = session_string(item, "content", undefined);
|
|
243
|
+
{
|
|
244
|
+
let specifier = __eliscript_value_15;
|
|
245
|
+
let content = __eliscript_value_16;
|
|
246
|
+
if (__eliscript_truthy((contents)["has"](specifier))) {
|
|
247
|
+
session_fail("duplicate macro file");
|
|
248
|
+
}
|
|
249
|
+
(contents)["set"](specifier, content);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
((index = (index + 1)));
|
|
255
|
+
}
|
|
256
|
+
return ({"capabilities": allowed, "files": contents});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function session_runtime_ir(state, source, filename, prefix, index) {
|
|
264
|
+
((state)["lastPhase"] = ({"phase": (prefix + "-read"), "filename": filename, "index": index}));
|
|
265
|
+
{
|
|
266
|
+
const __eliscript_value_17 = read_string(source, filename);
|
|
267
|
+
{
|
|
268
|
+
let forms = __eliscript_value_17;
|
|
269
|
+
(((state)["lastPhase"])["phase"] = (prefix + "-expand"));
|
|
270
|
+
{
|
|
271
|
+
const __eliscript_value_18 = expand_owned_module(forms, filename);
|
|
272
|
+
{
|
|
273
|
+
let expanded = __eliscript_value_18;
|
|
274
|
+
((forms = null));
|
|
275
|
+
(((state)["lastPhase"])["phase"] = (prefix + "-analyze"));
|
|
276
|
+
analyze_module(expanded, filename);
|
|
277
|
+
(((state)["lastPhase"])["phase"] = (prefix + "-lower"));
|
|
278
|
+
return lower_owned_module(expanded, filename);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function session_packed_literal_ir(state, source, filename, index) {
|
|
285
|
+
{
|
|
286
|
+
const __eliscript_value_19 = session_runtime_ir(state, source, filename, "literal", index);
|
|
287
|
+
{
|
|
288
|
+
let program = __eliscript_value_19;
|
|
289
|
+
(((state)["lastPhase"])["phase"] = "literal-snapshot");
|
|
290
|
+
validate_serializable_program(program);
|
|
291
|
+
return session_ir_wire(program, new (globalThis.Set)());
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function session_shared_ir_primitive(value, pool) {
|
|
296
|
+
if (__eliscript_truthy((pool)["has"](value))) {
|
|
297
|
+
return (pool)["get"](value);
|
|
298
|
+
} else {
|
|
299
|
+
(pool)["set"](value, value);
|
|
300
|
+
return value;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function session_restore_ir_value(value, strings, numbers) {
|
|
304
|
+
{
|
|
305
|
+
const __eliscript_value_20 = ((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value);
|
|
306
|
+
{
|
|
307
|
+
let kind = __eliscript_value_20;
|
|
308
|
+
if ((kind === "string")) {
|
|
309
|
+
return session_shared_ir_primitive(value, strings);
|
|
310
|
+
} else {
|
|
311
|
+
if ((kind === "number")) {
|
|
312
|
+
if (__eliscript_truthy(Object.is(value, -0.0))) {
|
|
313
|
+
return value;
|
|
314
|
+
} else {
|
|
315
|
+
return session_shared_ir_primitive(value, numbers);
|
|
316
|
+
}
|
|
317
|
+
} else {
|
|
318
|
+
if (((value === null) || (!(kind === "object")))) {
|
|
319
|
+
return value;
|
|
320
|
+
} else {
|
|
321
|
+
if (__eliscript_truthy(Array.isArray(value))) {
|
|
322
|
+
{
|
|
323
|
+
const __eliscript_value_21 = [];
|
|
324
|
+
const __eliscript_value_22 = 0;
|
|
325
|
+
const __eliscript_value_23 = ((value) ?? []).length;
|
|
326
|
+
{
|
|
327
|
+
let result = __eliscript_value_21;
|
|
328
|
+
let index = __eliscript_value_22;
|
|
329
|
+
let count = __eliscript_value_23;
|
|
330
|
+
while (__eliscript_numeric_relation("<", index, count)) {
|
|
331
|
+
{
|
|
332
|
+
const __eliscript_value_24 = session_restore_ir_value(((((value) ?? [])[index]) ?? null), strings, numbers);
|
|
333
|
+
{
|
|
334
|
+
let child = __eliscript_value_24;
|
|
335
|
+
((value)[index] = null);
|
|
336
|
+
(result)["push"](child);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
((index = (index + 1)));
|
|
340
|
+
}
|
|
341
|
+
return result;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
{
|
|
346
|
+
const __eliscript_value_25 = ({});
|
|
347
|
+
const __eliscript_value_26 = Object.keys(value);
|
|
348
|
+
const __eliscript_value_27 = 0;
|
|
349
|
+
{
|
|
350
|
+
let result = __eliscript_value_25;
|
|
351
|
+
let keys = __eliscript_value_26;
|
|
352
|
+
let index = __eliscript_value_27;
|
|
353
|
+
while (__eliscript_numeric_relation("<", index, ((keys) ?? []).length)) {
|
|
354
|
+
{
|
|
355
|
+
let original_key = ((((keys) ?? [])[index]) ?? null);
|
|
356
|
+
let key = session_shared_ir_primitive(original_key, strings);
|
|
357
|
+
let child = session_restore_ir_value((value)[original_key], strings, numbers);
|
|
358
|
+
Reflect.deleteProperty(value, original_key);
|
|
359
|
+
((keys)[index] = null);
|
|
360
|
+
Object.defineProperty(result, key, ({"value": child, "writable": true, "enumerable": true, "configurable": true}));
|
|
361
|
+
}
|
|
362
|
+
((index = (index + 1)));
|
|
363
|
+
}
|
|
364
|
+
return result;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function session_restore_literals(state, literals) {
|
|
375
|
+
{
|
|
376
|
+
const __eliscript_value_28 = new (globalThis.Map)();
|
|
377
|
+
const __eliscript_value_29 = new (globalThis.Map)();
|
|
378
|
+
const __eliscript_value_30 = (literals)["modules"];
|
|
379
|
+
const __eliscript_value_31 = (literals)["sources"];
|
|
380
|
+
const __eliscript_value_32 = (literals)["cache"];
|
|
381
|
+
const __eliscript_value_33 = 0;
|
|
382
|
+
{
|
|
383
|
+
let strings = __eliscript_value_28;
|
|
384
|
+
let numbers = __eliscript_value_29;
|
|
385
|
+
let modules = __eliscript_value_30;
|
|
386
|
+
let sources = __eliscript_value_31;
|
|
387
|
+
let cache = __eliscript_value_32;
|
|
388
|
+
let index = __eliscript_value_33;
|
|
389
|
+
while (__eliscript_numeric_relation("<", index, ((modules) ?? []).length)) {
|
|
390
|
+
{
|
|
391
|
+
let module = ((((modules) ?? [])[index]) ?? null);
|
|
392
|
+
let source = ((((sources) ?? [])[index]) ?? null);
|
|
393
|
+
let cached = (cache)["get"]((module)["id"]);
|
|
394
|
+
if (__eliscript_truthy(Object.hasOwn(module, "packedIR"))) {
|
|
395
|
+
((state)["lastPhase"] = ({"phase": "literal-restore", "filename": (source)["filename"], "index": index}));
|
|
396
|
+
{
|
|
397
|
+
const __eliscript_value_34 = session_restore_ir_value(JSON.parse((module)["packedIR"]), strings, numbers);
|
|
398
|
+
{
|
|
399
|
+
let program = __eliscript_value_34;
|
|
400
|
+
((module)["program"] = program);
|
|
401
|
+
((cached)["program"] = program);
|
|
402
|
+
Reflect.deleteProperty(module, "packedIR");
|
|
403
|
+
Reflect.deleteProperty(cached, "packedIR");
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
((index = (index + 1)));
|
|
409
|
+
}
|
|
410
|
+
(strings)["clear"]();
|
|
411
|
+
(numbers)["clear"]();
|
|
412
|
+
return literals;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function session_literal_modules(state, request, pack = null) {
|
|
417
|
+
{
|
|
418
|
+
let inputs = ((request)["literalSources"] ?? ((__eliscript_value_35) => (__eliscript_truthy(__eliscript_value_35) ? __eliscript_value_35 : []))((state)["literalSources"]));
|
|
419
|
+
let key = JSON.stringify(inputs);
|
|
420
|
+
let previous = ((__eliscript_value_36) => (__eliscript_truthy(__eliscript_value_36) ? __eliscript_value_36 : new (globalThis.Map)()))((state)["literalCache"]);
|
|
421
|
+
if ((!__eliscript_truthy(Array.isArray(inputs)))) {
|
|
422
|
+
session_fail("literalSources must be an array");
|
|
423
|
+
}
|
|
424
|
+
if (__eliscript_truthy(((__eliscript_value_37) => (__eliscript_truthy(__eliscript_value_37) ? (state)["literalModules"] : __eliscript_value_37))((key === (state)["literalKey"])))) {
|
|
425
|
+
return ({"key": key, "sources": inputs, "modules": (state)["literalModules"], "cache": previous});
|
|
426
|
+
} else {
|
|
427
|
+
{
|
|
428
|
+
const __eliscript_value_38 = [];
|
|
429
|
+
const __eliscript_value_39 = [];
|
|
430
|
+
const __eliscript_value_40 = new (globalThis.Map)();
|
|
431
|
+
const __eliscript_value_41 = new (globalThis.Set)();
|
|
432
|
+
const __eliscript_value_42 = 0;
|
|
433
|
+
{
|
|
434
|
+
let modules = __eliscript_value_38;
|
|
435
|
+
let sources = __eliscript_value_39;
|
|
436
|
+
let next = __eliscript_value_40;
|
|
437
|
+
let ids = __eliscript_value_41;
|
|
438
|
+
let index = __eliscript_value_42;
|
|
439
|
+
while (__eliscript_numeric_relation("<", index, ((inputs) ?? []).length)) {
|
|
440
|
+
{
|
|
441
|
+
const __eliscript_value_43 = ((((inputs) ?? [])[index]) ?? null);
|
|
442
|
+
{
|
|
443
|
+
let input = __eliscript_value_43;
|
|
444
|
+
if ((!__eliscript_truthy(session_object_p(input)))) {
|
|
445
|
+
session_fail("literal source must be an object");
|
|
446
|
+
}
|
|
447
|
+
{
|
|
448
|
+
let id = session_string(input, "id", undefined);
|
|
449
|
+
let source = session_string(input, "source", undefined);
|
|
450
|
+
let filename = session_string(input, "filename", id);
|
|
451
|
+
let cached = (previous)["get"](id);
|
|
452
|
+
if (__eliscript_truthy(((__eliscript_value_44) => (__eliscript_truthy(__eliscript_value_44) ? __eliscript_value_44 : (ids)["has"](id)))((((id) ?? []).length === 0)))) {
|
|
453
|
+
session_fail("literal source ids must be non-empty and unique", filename);
|
|
454
|
+
}
|
|
455
|
+
(ids)["add"](id);
|
|
456
|
+
{
|
|
457
|
+
let reusable = ((__eliscript_value_45) => (__eliscript_truthy(__eliscript_value_45) ? (((cached)["source"] === source) && ((cached)["filename"] === filename)) : __eliscript_value_45))(cached);
|
|
458
|
+
let program = (__eliscript_truthy(reusable) ? (cached)["program"] : (__eliscript_truthy(pack) ? session_packed_literal_ir(state, source, filename, index) : session_runtime_ir(state, source, filename, "literal", index)));
|
|
459
|
+
if ((!__eliscript_truthy(reusable))) {
|
|
460
|
+
(((state)["lastPhase"])["phase"] = "literal-complete");
|
|
461
|
+
}
|
|
462
|
+
(modules)["push"]((__eliscript_truthy(((__eliscript_value_46) => (__eliscript_truthy(__eliscript_value_46) ? (!__eliscript_truthy(reusable)) : __eliscript_value_46))(pack)) ? ({"id": id, "packedIR": program}) : ({"id": id, "program": program})));
|
|
463
|
+
(sources)["push"](({"id": id, "filename": filename, "source": source}));
|
|
464
|
+
(next)["set"](id, (__eliscript_truthy(reusable) ? cached : (__eliscript_truthy(pack) ? ({"source": source, "filename": filename, "packedIR": program}) : ({"source": source, "filename": filename, "program": program}))));
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
((index = (index + 1)));
|
|
470
|
+
}
|
|
471
|
+
return ({"key": key, "sources": sources, "modules": modules, "cache": next});
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function session_publish_literals(state, literals) {
|
|
478
|
+
if ((!((state)["literalKey"] === (literals)["key"]))) {
|
|
479
|
+
((state)["literalRevision"] = ((state)["literalRevision"] + 1));
|
|
480
|
+
}
|
|
481
|
+
((state)["literalSources"] = (literals)["sources"]);
|
|
482
|
+
((state)["literalModules"] = (literals)["modules"]);
|
|
483
|
+
((state)["literalKey"] = (literals)["key"]);
|
|
484
|
+
return ((state)["literalCache"] = (literals)["cache"]);
|
|
485
|
+
}
|
|
486
|
+
function session_runtime(state, request) {
|
|
487
|
+
session_phase(state, "runtime-literals-start", 0);
|
|
488
|
+
{
|
|
489
|
+
let source = session_string(request, "source", undefined);
|
|
490
|
+
let filename = session_string(request, "filename", "bootstrap/runtime/memory.eli");
|
|
491
|
+
let cold = (((state)["runtime"] === null) && (((state)["literalCache"])["size"] === 0));
|
|
492
|
+
let literals = session_literal_modules(state, request, cold);
|
|
493
|
+
session_phase(state, "runtime-literals-complete", (((literals)["modules"]) ?? []).length);
|
|
494
|
+
if ((!((source === (state)["runtimeSource"]) && (filename === (state)["runtimeFilename"]) && ((literals)["key"] === (state)["literalKey"]) && (!((state)["runtime"] === null))))) {
|
|
495
|
+
session_phase(state, "runtime-program-start", 0);
|
|
496
|
+
{
|
|
497
|
+
const __eliscript_value_47 = (__eliscript_truthy(((__eliscript_value_48) => (__eliscript_truthy(__eliscript_value_48) ? ((__eliscript_value_49) => (__eliscript_truthy(__eliscript_value_49) ? (state)["runtime"] : __eliscript_value_49))((filename === (state)["runtimeFilename"])) : __eliscript_value_48))((source === (state)["runtimeSource"]))) ? (state)["runtime"] : session_runtime_ir(state, source, filename, "runtime-program", -1));
|
|
498
|
+
{
|
|
499
|
+
let program = __eliscript_value_47;
|
|
500
|
+
session_phase(state, "runtime-program-complete", 0);
|
|
501
|
+
if (__eliscript_truthy(cold)) {
|
|
502
|
+
session_restore_literals(state, literals);
|
|
503
|
+
}
|
|
504
|
+
((state)["runtime"] = program);
|
|
505
|
+
((state)["runtimeSource"] = source);
|
|
506
|
+
((state)["runtimeFilename"] = filename);
|
|
507
|
+
session_publish_literals(state, literals);
|
|
508
|
+
((state)["revision"] = ((state)["revision"] + 1));
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
((state)["lastPhase"] = ({"phase": "runtime-ready", "filename": filename, "index": -1}));
|
|
513
|
+
{
|
|
514
|
+
const __eliscript_value_50 = ({"ready": true, "filename": filename, "revision": (state)["revision"]});
|
|
515
|
+
{
|
|
516
|
+
let result = __eliscript_value_50;
|
|
517
|
+
if (__eliscript_numeric_relation(">", ((((state)["literalModules"] ?? [])) ?? []).length, 0)) {
|
|
518
|
+
((result)["literalRevision"] = (state)["literalRevision"]);
|
|
519
|
+
}
|
|
520
|
+
return result;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function session_ir_wire_flush(sink) {
|
|
526
|
+
{
|
|
527
|
+
const __eliscript_value_51 = (sink)["pending"];
|
|
528
|
+
{
|
|
529
|
+
let pending = __eliscript_value_51;
|
|
530
|
+
if (__eliscript_numeric_relation(">", ((pending) ?? []).length, 0)) {
|
|
531
|
+
((sink)["complete"])["push"](__eliscript_at(Reflect, "apply")((__eliscript_tdz_read_0()), pending, [""]));
|
|
532
|
+
((sink)["pending"] = []);
|
|
533
|
+
return ((sink)["units"] = 0);
|
|
534
|
+
} else {
|
|
535
|
+
return null;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function session_ir_wire_push(sink, text) {
|
|
541
|
+
{
|
|
542
|
+
const __eliscript_value_52 = (sink)["pending"];
|
|
543
|
+
{
|
|
544
|
+
let pending = __eliscript_value_52;
|
|
545
|
+
(pending)["push"](text);
|
|
546
|
+
((sink)["units"] = ((sink)["units"] + ((text) ?? []).length));
|
|
547
|
+
if ((__eliscript_numeric_relation(">=", ((pending) ?? []).length, 2048) || __eliscript_numeric_relation(">=", (sink)["units"], 32768))) {
|
|
548
|
+
return session_ir_wire_flush(sink);
|
|
549
|
+
} else {
|
|
550
|
+
return null;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function session_ir_wire_append(value, ancestors, frames, chunks, array_element) {
|
|
556
|
+
{
|
|
557
|
+
const __eliscript_value_53 = ((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value);
|
|
558
|
+
{
|
|
559
|
+
let kind = __eliscript_value_53;
|
|
560
|
+
if ((value === null)) {
|
|
561
|
+
session_ir_wire_push(chunks, "null");
|
|
562
|
+
return true;
|
|
563
|
+
} else {
|
|
564
|
+
if ((kind === "bigint")) {
|
|
565
|
+
return ((__eliscript_value_54) => { throw __eliscript_value_54; })(new (globalThis.TypeError)("compiler IR cannot contain BigInt values"));
|
|
566
|
+
} else {
|
|
567
|
+
if ((kind === "number")) {
|
|
568
|
+
session_ir_wire_push(chunks, (((value === 0) && __eliscript_numeric_relation("<", __eliscript_numeric_div(1, value), 0)) ? "-0" : JSON.stringify(value)));
|
|
569
|
+
return true;
|
|
570
|
+
} else {
|
|
571
|
+
if (((kind === "string") || (kind === "boolean"))) {
|
|
572
|
+
session_ir_wire_push(chunks, JSON.stringify(value));
|
|
573
|
+
return true;
|
|
574
|
+
} else {
|
|
575
|
+
if ((!(kind === "object"))) {
|
|
576
|
+
if (__eliscript_truthy(array_element)) {
|
|
577
|
+
session_ir_wire_push(chunks, "null");
|
|
578
|
+
}
|
|
579
|
+
return false;
|
|
580
|
+
} else {
|
|
581
|
+
if (__eliscript_truthy((ancestors)["has"](value))) {
|
|
582
|
+
((__eliscript_value_55) => { throw __eliscript_value_55; })(new (globalThis.TypeError)("compiler IR cannot contain cycles"));
|
|
583
|
+
}
|
|
584
|
+
{
|
|
585
|
+
const __eliscript_value_56 = ({"value": value, "array": Array.isArray(value), "keys": null, "index": 0, "first": true, "active": false});
|
|
586
|
+
{
|
|
587
|
+
let frame = __eliscript_value_56;
|
|
588
|
+
(frames)["push"](frame);
|
|
589
|
+
(ancestors)["add"](value);
|
|
590
|
+
((frame)["active"] = true);
|
|
591
|
+
if (__eliscript_truthy((frame)["array"])) {
|
|
592
|
+
session_ir_wire_push(chunks, "[");
|
|
593
|
+
} else {
|
|
594
|
+
session_ir_wire_push(chunks, "{");
|
|
595
|
+
((frame)["keys"] = Object.keys(value));
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
function session_ir_wire(value, ancestors) {
|
|
609
|
+
{
|
|
610
|
+
const __eliscript_value_57 = [];
|
|
611
|
+
const __eliscript_value_58 = ({"pending": [], "units": 0, "complete": []});
|
|
612
|
+
{
|
|
613
|
+
let frames = __eliscript_value_57;
|
|
614
|
+
let chunks = __eliscript_value_58;
|
|
615
|
+
return (() => {
|
|
616
|
+
try {
|
|
617
|
+
if ((!__eliscript_truthy(session_ir_wire_append(value, ancestors, frames, chunks, false)))) {
|
|
618
|
+
((__eliscript_value_59) => { throw __eliscript_value_59; })(new (globalThis.TypeError)("compiler IR must be JSON data"));
|
|
619
|
+
}
|
|
620
|
+
while (__eliscript_numeric_relation(">", ((frames) ?? []).length, 0)) {
|
|
621
|
+
{
|
|
622
|
+
let frame = ((((frames) ?? [])[__eliscript_numeric_decrement(((frames) ?? []).length)]) ?? null);
|
|
623
|
+
let container = (frame)["value"];
|
|
624
|
+
let index = (frame)["index"];
|
|
625
|
+
let advance = false;
|
|
626
|
+
if (__eliscript_truthy((frame)["array"])) {
|
|
627
|
+
if (__eliscript_numeric_relation("<", index, ((container) ?? []).length)) {
|
|
628
|
+
((frame)["index"] = (index + 1));
|
|
629
|
+
if (__eliscript_numeric_relation(">", index, 0)) {
|
|
630
|
+
session_ir_wire_push(chunks, ",");
|
|
631
|
+
}
|
|
632
|
+
session_ir_wire_append(((((container) ?? [])[index]) ?? null), ancestors, frames, chunks, true);
|
|
633
|
+
((advance = true));
|
|
634
|
+
}
|
|
635
|
+
} else {
|
|
636
|
+
{
|
|
637
|
+
const __eliscript_value_60 = (frame)["keys"];
|
|
638
|
+
{
|
|
639
|
+
let keys = __eliscript_value_60;
|
|
640
|
+
if (__eliscript_numeric_relation("<", index, ((keys) ?? []).length)) {
|
|
641
|
+
((frame)["index"] = (index + 1));
|
|
642
|
+
{
|
|
643
|
+
let key = ((((keys) ?? [])[index]) ?? null);
|
|
644
|
+
let item = (container)[key];
|
|
645
|
+
let kind = ((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(item);
|
|
646
|
+
if ((!((item === undefined) || (kind === "function") || (kind === "symbol")))) {
|
|
647
|
+
if ((!__eliscript_truthy((frame)["first"]))) {
|
|
648
|
+
session_ir_wire_push(chunks, ",");
|
|
649
|
+
}
|
|
650
|
+
((frame)["first"] = false);
|
|
651
|
+
session_ir_wire_push(chunks, JSON.stringify(key));
|
|
652
|
+
session_ir_wire_push(chunks, ":");
|
|
653
|
+
session_ir_wire_append(item, ancestors, frames, chunks, false);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
((advance = true));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if ((!__eliscript_truthy(advance))) {
|
|
662
|
+
session_ir_wire_push(chunks, (__eliscript_truthy((frame)["array"]) ? "]" : "}"));
|
|
663
|
+
(ancestors)["delete"](container);
|
|
664
|
+
((frame)["active"] = false);
|
|
665
|
+
(frames)["pop"]();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
session_ir_wire_flush(chunks);
|
|
670
|
+
return __eliscript_at(Reflect, "apply")((__eliscript_tdz_read_0()), (chunks)["complete"], [""]);
|
|
671
|
+
} finally {
|
|
672
|
+
while (__eliscript_numeric_relation(">", ((frames) ?? []).length, 0)) {
|
|
673
|
+
{
|
|
674
|
+
const __eliscript_value_61 = (frames)["pop"]();
|
|
675
|
+
{
|
|
676
|
+
let frame = __eliscript_value_61;
|
|
677
|
+
if (__eliscript_truthy((frame)["active"])) {
|
|
678
|
+
(ancestors)["delete"]((frame)["value"]);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
})();
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function session_response_clear(state) {
|
|
689
|
+
{
|
|
690
|
+
const __eliscript_value_62 = ((state)["responseCursor"] ?? null);
|
|
691
|
+
{
|
|
692
|
+
let cursor = __eliscript_value_62;
|
|
693
|
+
((state)["responseCursor"] = null);
|
|
694
|
+
if (__eliscript_truthy(cursor)) {
|
|
695
|
+
((cursor)["root"] = null);
|
|
696
|
+
((cursor)["frames"] = null);
|
|
697
|
+
((cursor)["ancestors"] = null);
|
|
698
|
+
((cursor)["pendingEvent"] = null);
|
|
699
|
+
if (__eliscript_truthy(((cursor)["identities"] ?? null))) {
|
|
700
|
+
(((cursor)["identities"])["segments"] = null);
|
|
701
|
+
}
|
|
702
|
+
((cursor)["identities"] = null);
|
|
703
|
+
return ((cursor)["nextIdentity"] = 0);
|
|
704
|
+
} else {
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
const session_response_identity_segment_size = 1048576;
|
|
711
|
+
__eliscript_tdz_ready_1 = true;
|
|
712
|
+
function session_response_identities(segment_size) {
|
|
713
|
+
{
|
|
714
|
+
const __eliscript_value_63 = segment_size;
|
|
715
|
+
{
|
|
716
|
+
let limit = __eliscript_value_63;
|
|
717
|
+
if ((!__eliscript_truthy(((__eliscript_value_64) => (__eliscript_truthy(__eliscript_value_64) ? (__eliscript_numeric_relation(">", limit, 0) && __eliscript_numeric_relation("<=", limit, (__eliscript_tdz_read_1()))) : __eliscript_value_64))(Number.isSafeInteger(limit))))) {
|
|
718
|
+
session_fail("invalid compiler response identity segment size");
|
|
719
|
+
}
|
|
720
|
+
return ({"limit": limit, "segments": [new (globalThis.Map)()]});
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function session_response_find_identity(identities, value) {
|
|
725
|
+
{
|
|
726
|
+
const __eliscript_value_65 = (identities)["segments"];
|
|
727
|
+
const __eliscript_value_66 = 0;
|
|
728
|
+
const __eliscript_value_67 = null;
|
|
729
|
+
{
|
|
730
|
+
let segments = __eliscript_value_65;
|
|
731
|
+
let index = __eliscript_value_66;
|
|
732
|
+
let id = __eliscript_value_67;
|
|
733
|
+
while (((id === null) && __eliscript_numeric_relation("<", index, ((segments) ?? []).length))) {
|
|
734
|
+
{
|
|
735
|
+
const __eliscript_value_68 = ((((segments) ?? [])[index]) ?? null);
|
|
736
|
+
{
|
|
737
|
+
let segment = __eliscript_value_68;
|
|
738
|
+
if (__eliscript_truthy((segment)["has"](value))) {
|
|
739
|
+
((id = (segment)["get"](value)));
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
((index = (index + 1)));
|
|
744
|
+
}
|
|
745
|
+
return id;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
function session_response_add_identity(identities, value, id) {
|
|
750
|
+
{
|
|
751
|
+
let segments = (identities)["segments"];
|
|
752
|
+
let segment = ((((segments) ?? [])[__eliscript_numeric_decrement(((segments) ?? []).length)]) ?? null);
|
|
753
|
+
if (__eliscript_numeric_relation(">=", (segment)["size"], (identities)["limit"])) {
|
|
754
|
+
((segment = new (globalThis.Map)()));
|
|
755
|
+
(segments)["push"](segment);
|
|
756
|
+
}
|
|
757
|
+
return (segment)["set"](value, id);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function session_response_value_event(cursor, value, array_element) {
|
|
761
|
+
{
|
|
762
|
+
const __eliscript_value_69 = ((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value);
|
|
763
|
+
{
|
|
764
|
+
let kind = __eliscript_value_69;
|
|
765
|
+
if ((value === undefined)) {
|
|
766
|
+
if (__eliscript_truthy(array_element)) {
|
|
767
|
+
return ["value", null];
|
|
768
|
+
} else {
|
|
769
|
+
return ((__eliscript_value_70) => { throw __eliscript_value_70; })(new (globalThis.TypeError)("compiler IR must be JSON data"));
|
|
770
|
+
}
|
|
771
|
+
} else {
|
|
772
|
+
if ((value === null)) {
|
|
773
|
+
return ["value", null];
|
|
774
|
+
} else {
|
|
775
|
+
if ((kind === "bigint")) {
|
|
776
|
+
return ((__eliscript_value_71) => { throw __eliscript_value_71; })(new (globalThis.TypeError)("compiler IR cannot contain BigInt values"));
|
|
777
|
+
} else {
|
|
778
|
+
if ((kind === "number")) {
|
|
779
|
+
return ["value", (__eliscript_truthy(Number.isFinite(value)) ? value : null)];
|
|
780
|
+
} else {
|
|
781
|
+
if ((kind === "string")) {
|
|
782
|
+
if (__eliscript_truthy(((__eliscript_value_72) => (__eliscript_truthy(__eliscript_value_72) ? __eliscript_numeric_relation(">", ((value) ?? []).length, 8192) : __eliscript_value_72))(((cursor)["stringChunks"] ?? false)))) {
|
|
783
|
+
((cursor)["frames"])["push"](({"string": true, "value": value, "index": 0}));
|
|
784
|
+
return ["string", ((value) ?? []).length];
|
|
785
|
+
} else {
|
|
786
|
+
return ["value", value];
|
|
787
|
+
}
|
|
788
|
+
} else {
|
|
789
|
+
if ((kind === "boolean")) {
|
|
790
|
+
return ["value", value];
|
|
791
|
+
} else {
|
|
792
|
+
if ((!(kind === "object"))) {
|
|
793
|
+
if (__eliscript_truthy(array_element)) {
|
|
794
|
+
return ["value", null];
|
|
795
|
+
} else {
|
|
796
|
+
return ((__eliscript_value_73) => { throw __eliscript_value_73; })(new (globalThis.TypeError)("compiler IR must be JSON data"));
|
|
797
|
+
}
|
|
798
|
+
} else {
|
|
799
|
+
{
|
|
800
|
+
const __eliscript_value_74 = (cursor)["ancestors"];
|
|
801
|
+
const __eliscript_value_75 = (cursor)["frames"];
|
|
802
|
+
const __eliscript_value_76 = ((cursor)["identities"] ?? null);
|
|
803
|
+
{
|
|
804
|
+
let ancestors = __eliscript_value_74;
|
|
805
|
+
let frames = __eliscript_value_75;
|
|
806
|
+
let identities = __eliscript_value_76;
|
|
807
|
+
if (__eliscript_truthy((ancestors)["has"](value))) {
|
|
808
|
+
((__eliscript_value_77) => { throw __eliscript_value_77; })(new (globalThis.TypeError)("compiler IR cannot contain cycles"));
|
|
809
|
+
}
|
|
810
|
+
{
|
|
811
|
+
const __eliscript_value_78 = (__eliscript_truthy(identities) ? session_response_find_identity(identities, value) : null);
|
|
812
|
+
{
|
|
813
|
+
let existing = __eliscript_value_78;
|
|
814
|
+
if (__eliscript_truthy(existing)) {
|
|
815
|
+
return ["reference", existing];
|
|
816
|
+
} else {
|
|
817
|
+
{
|
|
818
|
+
const __eliscript_value_79 = ({"value": value, "array": Array.isArray(value), "keys": null, "index": 0, "pendingValue": false, "item": null});
|
|
819
|
+
const __eliscript_value_80 = null;
|
|
820
|
+
{
|
|
821
|
+
let frame = __eliscript_value_79;
|
|
822
|
+
let id = __eliscript_value_80;
|
|
823
|
+
if (__eliscript_truthy(identities)) {
|
|
824
|
+
((id = (cursor)["nextIdentity"]));
|
|
825
|
+
if ((!__eliscript_truthy(((__eliscript_value_81) => (__eliscript_truthy(__eliscript_value_81) ? __eliscript_numeric_relation(">", id, 0) : __eliscript_value_81))(Number.isSafeInteger(id))))) {
|
|
826
|
+
session_fail("compiler response identity space is exhausted");
|
|
827
|
+
}
|
|
828
|
+
session_response_add_identity(identities, value, id);
|
|
829
|
+
((cursor)["nextIdentity"] = (id + 1));
|
|
830
|
+
}
|
|
831
|
+
(frames)["push"](frame);
|
|
832
|
+
(ancestors)["add"](value);
|
|
833
|
+
{
|
|
834
|
+
const __eliscript_value_82 = (__eliscript_truthy((frame)["array"]) ? "array" : "object");
|
|
835
|
+
{
|
|
836
|
+
let kind = __eliscript_value_82;
|
|
837
|
+
if ((!__eliscript_truthy((frame)["array"]))) {
|
|
838
|
+
((frame)["keys"] = Object.keys(value));
|
|
839
|
+
}
|
|
840
|
+
if (__eliscript_truthy(identities)) {
|
|
841
|
+
return [kind, id];
|
|
842
|
+
} else {
|
|
843
|
+
return [kind];
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function session_response_array_event(cursor, frame) {
|
|
865
|
+
{
|
|
866
|
+
const __eliscript_value_83 = (frame)["value"];
|
|
867
|
+
const __eliscript_value_84 = [];
|
|
868
|
+
const __eliscript_value_85 = null;
|
|
869
|
+
const __eliscript_value_86 = false;
|
|
870
|
+
{
|
|
871
|
+
let container = __eliscript_value_83;
|
|
872
|
+
let values = __eliscript_value_84;
|
|
873
|
+
let event = __eliscript_value_85;
|
|
874
|
+
let stop = __eliscript_value_86;
|
|
875
|
+
while (((!__eliscript_truthy(stop)) && __eliscript_numeric_relation("<", ((values) ?? []).length, 256) && __eliscript_numeric_relation("<", (frame)["index"], ((container) ?? []).length))) {
|
|
876
|
+
{
|
|
877
|
+
const __eliscript_value_87 = (frame)["index"];
|
|
878
|
+
{
|
|
879
|
+
let index = __eliscript_value_87;
|
|
880
|
+
((frame)["index"] = (index + 1));
|
|
881
|
+
{
|
|
882
|
+
const __eliscript_value_88 = ((((container) ?? [])[index]) ?? null);
|
|
883
|
+
{
|
|
884
|
+
let item = __eliscript_value_88;
|
|
885
|
+
if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(item) === "number")) {
|
|
886
|
+
(values)["push"]((__eliscript_truthy(Number.isFinite(item)) ? item : null));
|
|
887
|
+
} else {
|
|
888
|
+
((stop = true));
|
|
889
|
+
if (__eliscript_numeric_relation(">", ((values) ?? []).length, 0)) {
|
|
890
|
+
((frame)["item"] = item);
|
|
891
|
+
((frame)["pendingValue"] = true);
|
|
892
|
+
} else {
|
|
893
|
+
((event = session_response_value_event(cursor, item, true)));
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
if (__eliscript_numeric_relation(">", ((values) ?? []).length, 0)) {
|
|
902
|
+
return ["array-values", values];
|
|
903
|
+
} else {
|
|
904
|
+
return event;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
function session_response_string_event(cursor, frame) {
|
|
910
|
+
{
|
|
911
|
+
const __eliscript_value_89 = (frame)["value"];
|
|
912
|
+
const __eliscript_value_90 = (frame)["index"];
|
|
913
|
+
{
|
|
914
|
+
let text = __eliscript_value_89;
|
|
915
|
+
let index = __eliscript_value_90;
|
|
916
|
+
if (__eliscript_numeric_relation("<", index, ((text) ?? []).length)) {
|
|
917
|
+
{
|
|
918
|
+
const __eliscript_value_91 = (index + 8192);
|
|
919
|
+
{
|
|
920
|
+
let end = __eliscript_value_91;
|
|
921
|
+
if (__eliscript_numeric_relation(">", end, ((text) ?? []).length)) {
|
|
922
|
+
((end = ((text) ?? []).length));
|
|
923
|
+
}
|
|
924
|
+
((frame)["index"] = end);
|
|
925
|
+
return ["string-chunk", (text)["slice"](index, end)];
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
} else {
|
|
929
|
+
((frame)["value"] = null);
|
|
930
|
+
((cursor)["frames"])["pop"]();
|
|
931
|
+
return ["end"];
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
function session_response_event(cursor) {
|
|
937
|
+
if ((!__eliscript_truthy((cursor)["started"]))) {
|
|
938
|
+
((cursor)["started"] = true);
|
|
939
|
+
return session_response_value_event(cursor, (cursor)["root"], false);
|
|
940
|
+
} else {
|
|
941
|
+
{
|
|
942
|
+
const __eliscript_value_92 = null;
|
|
943
|
+
const __eliscript_value_93 = (cursor)["frames"];
|
|
944
|
+
{
|
|
945
|
+
let event = __eliscript_value_92;
|
|
946
|
+
let frames = __eliscript_value_93;
|
|
947
|
+
while (((event === null) && __eliscript_numeric_relation(">", ((frames) ?? []).length, 0))) {
|
|
948
|
+
{
|
|
949
|
+
let frame = ((((frames) ?? [])[__eliscript_numeric_decrement(((frames) ?? []).length)]) ?? null);
|
|
950
|
+
let container = (frame)["value"];
|
|
951
|
+
let index = (frame)["index"];
|
|
952
|
+
let advance = false;
|
|
953
|
+
if (__eliscript_truthy(((frame)["string"] ?? false))) {
|
|
954
|
+
((event = session_response_string_event(cursor, frame)));
|
|
955
|
+
((advance = true));
|
|
956
|
+
} else {
|
|
957
|
+
if (__eliscript_truthy((frame)["pendingValue"])) {
|
|
958
|
+
{
|
|
959
|
+
const __eliscript_value_94 = (frame)["item"];
|
|
960
|
+
{
|
|
961
|
+
let item = __eliscript_value_94;
|
|
962
|
+
((frame)["pendingValue"] = false);
|
|
963
|
+
((frame)["item"] = null);
|
|
964
|
+
((event = session_response_value_event(cursor, item, (frame)["array"])));
|
|
965
|
+
((advance = true));
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
} else {
|
|
969
|
+
if (__eliscript_truthy((frame)["array"])) {
|
|
970
|
+
if (__eliscript_numeric_relation("<", index, ((container) ?? []).length)) {
|
|
971
|
+
((event = session_response_array_event(cursor, frame)));
|
|
972
|
+
((advance = true));
|
|
973
|
+
}
|
|
974
|
+
} else {
|
|
975
|
+
{
|
|
976
|
+
const __eliscript_value_95 = (frame)["keys"];
|
|
977
|
+
{
|
|
978
|
+
let keys = __eliscript_value_95;
|
|
979
|
+
if (__eliscript_numeric_relation("<", index, ((keys) ?? []).length)) {
|
|
980
|
+
((frame)["index"] = (index + 1));
|
|
981
|
+
{
|
|
982
|
+
let key = ((((keys) ?? [])[index]) ?? null);
|
|
983
|
+
let item = (container)[key];
|
|
984
|
+
let kind = ((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(item);
|
|
985
|
+
if ((!((item === undefined) || (kind === "function") || (kind === "symbol")))) {
|
|
986
|
+
((frame)["item"] = item);
|
|
987
|
+
((frame)["pendingValue"] = true);
|
|
988
|
+
((event = ["key", key]));
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
((advance = true));
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
if ((!__eliscript_truthy(advance))) {
|
|
999
|
+
((cursor)["ancestors"])["delete"](container);
|
|
1000
|
+
(frames)["pop"]();
|
|
1001
|
+
((event = ["end"]));
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return event;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
function session_response_event_units(event) {
|
|
1011
|
+
if (((((event) ?? []).length === 2) && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(((((event) ?? [])[1]) ?? null)) === "string"))) {
|
|
1012
|
+
return ((((((event) ?? [])[1]) ?? null)) ?? []).length;
|
|
1013
|
+
} else {
|
|
1014
|
+
return 0;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
function session_response_batch(state, cursor) {
|
|
1018
|
+
{
|
|
1019
|
+
const __eliscript_value_96 = [];
|
|
1020
|
+
const __eliscript_value_97 = 0;
|
|
1021
|
+
const __eliscript_value_98 = false;
|
|
1022
|
+
{
|
|
1023
|
+
let events = __eliscript_value_96;
|
|
1024
|
+
let units = __eliscript_value_97;
|
|
1025
|
+
let stop = __eliscript_value_98;
|
|
1026
|
+
while (((!__eliscript_truthy(stop)) && __eliscript_numeric_relation("<", ((events) ?? []).length, 256) && __eliscript_numeric_relation("<", units, 32768))) {
|
|
1027
|
+
{
|
|
1028
|
+
const __eliscript_value_99 = ((cursor)["pendingEvent"] ?? null);
|
|
1029
|
+
{
|
|
1030
|
+
let event = __eliscript_value_99;
|
|
1031
|
+
((cursor)["pendingEvent"] = null);
|
|
1032
|
+
if ((event === null)) {
|
|
1033
|
+
((event = session_response_event(cursor)));
|
|
1034
|
+
}
|
|
1035
|
+
if ((event === null)) {
|
|
1036
|
+
((stop = true));
|
|
1037
|
+
} else {
|
|
1038
|
+
{
|
|
1039
|
+
const __eliscript_value_100 = session_response_event_units(event);
|
|
1040
|
+
{
|
|
1041
|
+
let next_units = __eliscript_value_100;
|
|
1042
|
+
if ((__eliscript_numeric_relation(">", ((events) ?? []).length, 0) && __eliscript_numeric_relation(">", (units + next_units), 32768))) {
|
|
1043
|
+
((cursor)["pendingEvent"] = event);
|
|
1044
|
+
((stop = true));
|
|
1045
|
+
} else {
|
|
1046
|
+
(events)["push"](event);
|
|
1047
|
+
((units = (units + next_units)));
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
{
|
|
1056
|
+
let done = ((__eliscript_value_101) => (__eliscript_truthy(__eliscript_value_101) ? (((((cursor)["frames"]) ?? []).length === 0) && (((cursor)["pendingEvent"] ?? null) === null)) : __eliscript_value_101))((cursor)["started"]);
|
|
1057
|
+
let result = ({"format": "eliscript-compiler-response-events", "version": (cursor)["version"], "token": (cursor)["token"], "events": events, "done": done});
|
|
1058
|
+
if (__eliscript_truthy(done)) {
|
|
1059
|
+
session_phase(state, "response-events-complete", 0);
|
|
1060
|
+
session_response_clear(state);
|
|
1061
|
+
}
|
|
1062
|
+
return result;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function session_response_start(state, value, mode = null, identity_size = null, string_chunks = null) {
|
|
1068
|
+
{
|
|
1069
|
+
const __eliscript_value_102 = (((state)["responseToken"] ?? 0) + 1);
|
|
1070
|
+
const __eliscript_value_103 = (mode === "graph-events-v1");
|
|
1071
|
+
{
|
|
1072
|
+
let token = __eliscript_value_102;
|
|
1073
|
+
let graph = __eliscript_value_103;
|
|
1074
|
+
if ((!__eliscript_truthy(((__eliscript_value_104) => (__eliscript_truthy(__eliscript_value_104) ? __eliscript_numeric_relation(">", token, 0) : __eliscript_value_104))(Number.isSafeInteger(token))))) {
|
|
1075
|
+
session_fail("compiler response token space is exhausted");
|
|
1076
|
+
}
|
|
1077
|
+
{
|
|
1078
|
+
const __eliscript_value_105 = ({"token": token, "root": value, "frames": [], "ancestors": new (globalThis.Set)(), "started": false, "pendingEvent": null, "stringChunks": (string_chunks === true), "version": (__eliscript_truthy(graph) ? 2 : 1), "identities": (__eliscript_truthy(graph) ? session_response_identities(((identity_size === null) ? (__eliscript_tdz_read_1()) : identity_size)) : null), "nextIdentity": 1});
|
|
1079
|
+
{
|
|
1080
|
+
let cursor = __eliscript_value_105;
|
|
1081
|
+
((state)["responseToken"] = token);
|
|
1082
|
+
((state)["responseCursor"] = cursor);
|
|
1083
|
+
session_phase(state, "response-events-start", 0);
|
|
1084
|
+
return session_response_batch(state, cursor);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
function session_response_control(state, request, operation) {
|
|
1091
|
+
{
|
|
1092
|
+
const __eliscript_value_106 = ((state)["responseCursor"] ?? null);
|
|
1093
|
+
const __eliscript_value_107 = ((request)["token"] ?? undefined);
|
|
1094
|
+
{
|
|
1095
|
+
let cursor = __eliscript_value_106;
|
|
1096
|
+
let token = __eliscript_value_107;
|
|
1097
|
+
if ((!__eliscript_truthy(((__eliscript_value_108) => (__eliscript_truthy(__eliscript_value_108) ? ((__eliscript_value_109) => (__eliscript_truthy(__eliscript_value_109) ? (__eliscript_numeric_relation(">", token, 0) && (token === (cursor)["token"])) : __eliscript_value_109))(Number.isSafeInteger(token)) : __eliscript_value_108))(cursor)))) {
|
|
1098
|
+
session_fail("compiler response token is absent, stale or invalid");
|
|
1099
|
+
}
|
|
1100
|
+
if ((operation === "response-next")) {
|
|
1101
|
+
return session_response_batch(state, cursor);
|
|
1102
|
+
} else {
|
|
1103
|
+
{
|
|
1104
|
+
const __eliscript_value_110 = ({"format": "eliscript-compiler-response-events", "version": (cursor)["version"], "token": token, "events": [], "done": true});
|
|
1105
|
+
{
|
|
1106
|
+
let result = __eliscript_value_110;
|
|
1107
|
+
session_response_clear(state);
|
|
1108
|
+
return result;
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
function session_compile_program(request, source, filename) {
|
|
1116
|
+
{
|
|
1117
|
+
const __eliscript_value_111 = ((request)["portableEntries"] ?? null);
|
|
1118
|
+
const __eliscript_value_112 = session_macro_context(((request)["macroContext"] ?? null));
|
|
1119
|
+
{
|
|
1120
|
+
let entries = __eliscript_value_111;
|
|
1121
|
+
let context = __eliscript_value_112;
|
|
1122
|
+
if ((entries === null)) {
|
|
1123
|
+
return compile_ir_string(source, filename, context);
|
|
1124
|
+
} else {
|
|
1125
|
+
if ((!__eliscript_truthy(((__eliscript_value_113) => (__eliscript_truthy(__eliscript_value_113) ? __eliscript_numeric_relation(">", ((entries) ?? []).length, 0) : __eliscript_value_113))(Array.isArray(entries))))) {
|
|
1126
|
+
session_fail("portableEntries requires non-empty entry names", filename);
|
|
1127
|
+
}
|
|
1128
|
+
{
|
|
1129
|
+
const __eliscript_value_114 = expand_owned_module(read_string(source, filename), filename, context);
|
|
1130
|
+
{
|
|
1131
|
+
let forms = __eliscript_value_114;
|
|
1132
|
+
analyze_module(forms, filename);
|
|
1133
|
+
{
|
|
1134
|
+
const __eliscript_value_115 = select_portable_module(forms, entries, filename, ((request)["allowProjectImports"] ?? false));
|
|
1135
|
+
{
|
|
1136
|
+
let selected = __eliscript_value_115;
|
|
1137
|
+
((forms = null));
|
|
1138
|
+
return lower_owned_module(selected, filename);
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
function session_compile(request, ir_only) {
|
|
1148
|
+
{
|
|
1149
|
+
let source = session_string(request, "source", undefined);
|
|
1150
|
+
let filename = session_string(request, "filename", "<input>");
|
|
1151
|
+
let program = session_compile_program(request, source, filename);
|
|
1152
|
+
if (__eliscript_truthy(ir_only)) {
|
|
1153
|
+
{
|
|
1154
|
+
const __eliscript_value_116 = ({"ir": session_ir_wire(program, new (globalThis.Set)()), "filename": filename});
|
|
1155
|
+
{
|
|
1156
|
+
let result = __eliscript_value_116;
|
|
1157
|
+
if ((((request)["canonicalIR"] ?? false) === true)) {
|
|
1158
|
+
((result)["canonicalIR"] = serialize_ir_program(program));
|
|
1159
|
+
}
|
|
1160
|
+
return result;
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
} else {
|
|
1164
|
+
{
|
|
1165
|
+
const __eliscript_value_117 = ((request)["sourceMap"] ?? null);
|
|
1166
|
+
{
|
|
1167
|
+
let mapping = __eliscript_value_117;
|
|
1168
|
+
if ((mapping === null)) {
|
|
1169
|
+
return ({"javascript": emit_ir_string(program), "filename": filename});
|
|
1170
|
+
} else {
|
|
1171
|
+
if ((!__eliscript_truthy(session_object_p(mapping)))) {
|
|
1172
|
+
session_fail("sourceMap must be an object", filename);
|
|
1173
|
+
}
|
|
1174
|
+
{
|
|
1175
|
+
const __eliscript_value_118 = emit_ir_string_with_source_map(program, source, session_string(mapping, "generatedFile", "output.mjs"), session_string(mapping, "sourceName", filename));
|
|
1176
|
+
{
|
|
1177
|
+
let artifact = __eliscript_value_118;
|
|
1178
|
+
((artifact)["filename"] = filename);
|
|
1179
|
+
return artifact;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function session_stage(request) {
|
|
1189
|
+
{
|
|
1190
|
+
let stage = session_string(request, "stage", undefined);
|
|
1191
|
+
let source = session_string(request, "source", undefined);
|
|
1192
|
+
let filename = session_string(request, "filename", "<input>");
|
|
1193
|
+
let forms = read_string(source, filename);
|
|
1194
|
+
let result = null;
|
|
1195
|
+
if ((!((stage === "reader") || (stage === "expander") || (stage === "analyzer") || (stage === "portable") || (stage === "ir") || (stage === "emitter")))) {
|
|
1196
|
+
session_fail("unknown compiler stage", filename);
|
|
1197
|
+
}
|
|
1198
|
+
if (((!(stage === "reader")) && (!(((request)["expand"] ?? true) === false)))) {
|
|
1199
|
+
((forms = expand_module(forms, filename, session_macro_context(((request)["macroContext"] ?? null)))));
|
|
1200
|
+
}
|
|
1201
|
+
if (((stage === "reader") || (stage === "expander"))) {
|
|
1202
|
+
((result = forms));
|
|
1203
|
+
} else {
|
|
1204
|
+
analyze_module(forms, filename);
|
|
1205
|
+
((result = ((stage === "analyzer") ? forms : ((stage === "portable") ? ((entries) => {
|
|
1206
|
+
if ((!__eliscript_truthy(Array.isArray(entries)))) {
|
|
1207
|
+
session_fail("portable stage requires entry names", filename);
|
|
1208
|
+
}
|
|
1209
|
+
return select_portable_module(forms, entries, filename, ((request)["allowProjectImports"] ?? false));
|
|
1210
|
+
})(((request)["entries"] ?? null)) : ((stage === "ir") ? lower_module(forms, filename) : ((program, mapping) => {
|
|
1211
|
+
if ((mapping === null)) {
|
|
1212
|
+
return emit_ir_string(program);
|
|
1213
|
+
} else {
|
|
1214
|
+
if ((!__eliscript_truthy(session_object_p(mapping)))) {
|
|
1215
|
+
session_fail("sourceMap must be an object", filename);
|
|
1216
|
+
}
|
|
1217
|
+
{
|
|
1218
|
+
const __eliscript_value_119 = emit_ir_string_with_source_map(program, source, session_string(mapping, "generatedFile", "fixture.mjs"), session_string(mapping, "sourceName", filename));
|
|
1219
|
+
{
|
|
1220
|
+
let emission = __eliscript_value_119;
|
|
1221
|
+
return ({"javascript": (emission)["javascript"], "sourceMap": JSON.parse((emission)["sourceMap"])});
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
})(lower_module(forms, filename), ((request)["sourceMap"] ?? null)))))));
|
|
1226
|
+
}
|
|
1227
|
+
return ({"stage": stage, "filename": filename, "data": session_ir_wire(result, new (globalThis.Set)())});
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
function session_protocol(request) {
|
|
1231
|
+
{
|
|
1232
|
+
const __eliscript_value_120 = session_string(request, "name", undefined);
|
|
1233
|
+
const __eliscript_value_121 = ((request)["input"] ?? undefined);
|
|
1234
|
+
{
|
|
1235
|
+
let name = __eliscript_value_120;
|
|
1236
|
+
let input = __eliscript_value_121;
|
|
1237
|
+
if ((name === "project-plan")) {
|
|
1238
|
+
return project_plan(((input)["entries"] ?? undefined), ((id) => {
|
|
1239
|
+
{
|
|
1240
|
+
const __eliscript_value_122 = ((input)["dependencies"] ?? ({}));
|
|
1241
|
+
{
|
|
1242
|
+
let dependencies = __eliscript_value_122;
|
|
1243
|
+
if (__eliscript_truthy((globalThis.Object)["hasOwn"](dependencies, id))) {
|
|
1244
|
+
return (dependencies)[id];
|
|
1245
|
+
} else {
|
|
1246
|
+
return [];
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
}));
|
|
1251
|
+
} else {
|
|
1252
|
+
if ((name === "portable-project-plan")) {
|
|
1253
|
+
{
|
|
1254
|
+
let calls = [];
|
|
1255
|
+
let resolutions = ((input)["resolutions"] ?? []);
|
|
1256
|
+
let plan = portable_project_plan(((input)["entries"] ?? undefined), ((id, entries) => {
|
|
1257
|
+
(calls)["push"](({"id": id, "entries": Array.from(entries)}));
|
|
1258
|
+
{
|
|
1259
|
+
const __eliscript_value_123 = 0;
|
|
1260
|
+
const __eliscript_value_124 = null;
|
|
1261
|
+
const __eliscript_value_125 = false;
|
|
1262
|
+
{
|
|
1263
|
+
let index = __eliscript_value_123;
|
|
1264
|
+
let selected = __eliscript_value_124;
|
|
1265
|
+
let found = __eliscript_value_125;
|
|
1266
|
+
while ((__eliscript_numeric_relation("<", index, ((resolutions) ?? []).length) && (!__eliscript_truthy(found)))) {
|
|
1267
|
+
{
|
|
1268
|
+
const __eliscript_value_126 = ((((resolutions) ?? [])[index]) ?? null);
|
|
1269
|
+
{
|
|
1270
|
+
let item = __eliscript_value_126;
|
|
1271
|
+
if (__eliscript_truthy(((__eliscript_value_127) => (__eliscript_truthy(__eliscript_value_127) ? ((__eliscript_value_128) => (__eliscript_truthy(__eliscript_value_128) ? __eliscript_value_128 : (entries)["includes"]((item)["includes"])))((((item)["includes"] ?? null) === null)) : __eliscript_value_127))(((item)["id"] === id)))) {
|
|
1272
|
+
((selected = ((item)["dependencies"] ?? undefined)), (found = true));
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
((index = (index + 1)));
|
|
1277
|
+
}
|
|
1278
|
+
if (__eliscript_truthy(found)) {
|
|
1279
|
+
return selected;
|
|
1280
|
+
} else {
|
|
1281
|
+
return [];
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}));
|
|
1286
|
+
return ({"plan": plan, "calls": calls});
|
|
1287
|
+
}
|
|
1288
|
+
} else {
|
|
1289
|
+
if ((name === "project-request")) {
|
|
1290
|
+
return project_request(input);
|
|
1291
|
+
} else {
|
|
1292
|
+
if ((name === "project-configuration")) {
|
|
1293
|
+
return project_configuration(input, session_string(request, "filename", "eliscript.json"));
|
|
1294
|
+
} else {
|
|
1295
|
+
if ((name === "build-operation-request")) {
|
|
1296
|
+
return build_operation_request(input);
|
|
1297
|
+
} else {
|
|
1298
|
+
if ((name === "check-operation-request")) {
|
|
1299
|
+
return check_operation_request(input);
|
|
1300
|
+
} else {
|
|
1301
|
+
if ((name === "project-build-report")) {
|
|
1302
|
+
return project_build_report(input);
|
|
1303
|
+
} else {
|
|
1304
|
+
if ((name === "project-check-report")) {
|
|
1305
|
+
return project_check_report(input);
|
|
1306
|
+
} else {
|
|
1307
|
+
if ((name === "project-cache-lookup")) {
|
|
1308
|
+
return project_cache_lookup(input);
|
|
1309
|
+
} else {
|
|
1310
|
+
if ((name === "project-cache-decision")) {
|
|
1311
|
+
return project_cache_decision(input);
|
|
1312
|
+
} else {
|
|
1313
|
+
if ((name === "evaluation-operation-request")) {
|
|
1314
|
+
return evaluation_operation_request(input);
|
|
1315
|
+
} else {
|
|
1316
|
+
if ((name === "deserialize-ir")) {
|
|
1317
|
+
return ({"ir": session_ir_wire(deserialize_ir_program(((input)["text"] ?? undefined)), new (globalThis.Set)())});
|
|
1318
|
+
} else {
|
|
1319
|
+
if ((name === "serialize-ir")) {
|
|
1320
|
+
return ({"canonicalIR": serialize_ir_program(((input)["program"] ?? undefined))});
|
|
1321
|
+
} else {
|
|
1322
|
+
if ((name === "evaluation-input-description")) {
|
|
1323
|
+
return evaluation_input_description(session_string(request, "source", undefined), session_string(request, "filename", "<input>"));
|
|
1324
|
+
} else {
|
|
1325
|
+
if ((name === "evaluation-form-description")) {
|
|
1326
|
+
return evaluation_form_description(session_string(request, "source", undefined), session_string(request, "filename", "<input>"));
|
|
1327
|
+
} else {
|
|
1328
|
+
if ((name === "evaluation-module-description")) {
|
|
1329
|
+
return evaluation_module_description(session_string(request, "source", undefined), session_string(request, "filename", "<input>"));
|
|
1330
|
+
} else {
|
|
1331
|
+
return session_fail(("unknown compiler protocol: " + name));
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
function session_ir_operation(state, request, operation) {
|
|
1352
|
+
if ((operation === "deserialize-ir")) {
|
|
1353
|
+
{
|
|
1354
|
+
let canonical = session_string(request, "canonicalIR", undefined);
|
|
1355
|
+
let program = deserialize_ir_program(canonical);
|
|
1356
|
+
return ({"ir": session_ir_wire(program, new (globalThis.Set)()), "canonicalIR": canonical});
|
|
1357
|
+
}
|
|
1358
|
+
} else {
|
|
1359
|
+
{
|
|
1360
|
+
let program = JSON.parse(session_string(request, "ir", undefined));
|
|
1361
|
+
let canonical = serialize_ir_program(program);
|
|
1362
|
+
if ((operation === "serialize-ir")) {
|
|
1363
|
+
return ({"canonicalIR": canonical});
|
|
1364
|
+
} else {
|
|
1365
|
+
if ((!(((request)["target"] ?? "javascript") === "javascript"))) {
|
|
1366
|
+
return session_binary_ir(state, request, program);
|
|
1367
|
+
} else {
|
|
1368
|
+
{
|
|
1369
|
+
const __eliscript_value_129 = ((request)["sourceMap"] ?? null);
|
|
1370
|
+
{
|
|
1371
|
+
let mapping = __eliscript_value_129;
|
|
1372
|
+
if ((mapping === null)) {
|
|
1373
|
+
return ({"javascript": emit_ir_string(program)});
|
|
1374
|
+
} else {
|
|
1375
|
+
if ((!__eliscript_truthy(session_object_p(mapping)))) {
|
|
1376
|
+
session_fail("sourceMap must be an object");
|
|
1377
|
+
}
|
|
1378
|
+
return emit_ir_string_with_source_map(program, session_string(request, "source", undefined), session_string(mapping, "generatedFile", "output.mjs"), session_string(mapping, "sourceName", (program)["filename"]));
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
function session_backend_emission(filename, action) {
|
|
1388
|
+
return (() => {
|
|
1389
|
+
try {
|
|
1390
|
+
return action();
|
|
1391
|
+
} catch (error) {
|
|
1392
|
+
if (__eliscript_truthy(((__eliscript_value_130) => (__eliscript_truthy(__eliscript_value_130) ? ((__eliscript_value_131) => (__eliscript_truthy(__eliscript_value_131) ? (globalThis.Object)["hasOwn"](error, "eliscriptIRSpan") : __eliscript_value_131))((((error)["eliscriptDiagnostic"] ?? null) === null)) : __eliscript_value_130))(session_object_p(error)))) {
|
|
1393
|
+
{
|
|
1394
|
+
let span = ((error)["eliscriptIRSpan"] ?? null);
|
|
1395
|
+
let location = ({"file": (__eliscript_truthy(session_object_p(span)) ? ((span)["filename"] ?? filename) : filename)});
|
|
1396
|
+
let message = ((error)["message"] ?? "backend emission failed");
|
|
1397
|
+
if (__eliscript_truthy(session_object_p(span))) {
|
|
1398
|
+
((location)["start"] = ({"offset": (span)["start"], "line": (span)["line"], "column": (span)["column"]}));
|
|
1399
|
+
((location)["end"] = ({"offset": (span)["end"], "line": (span)["endLine"], "column": (span)["endColumn"]}));
|
|
1400
|
+
}
|
|
1401
|
+
((error)["eliscriptDiagnostic"] = ({"format": "eliscript-diagnostic", "version": 1, "code": "ELI-B0001", "severity": "error", "phase": "managed-backend", "message": message, "location": location}));
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
return ((__eliscript_value_132) => { throw __eliscript_value_132; })(error);
|
|
1405
|
+
}
|
|
1406
|
+
})();
|
|
1407
|
+
}
|
|
1408
|
+
function session_binary_ir(state, request, program) {
|
|
1409
|
+
return session_project_transaction(state, (() => {
|
|
1410
|
+
{
|
|
1411
|
+
const __eliscript_value_133 = session_string(request, "target", undefined);
|
|
1412
|
+
const __eliscript_value_134 = (state)["runtime"];
|
|
1413
|
+
{
|
|
1414
|
+
let target = __eliscript_value_133;
|
|
1415
|
+
let runtime = __eliscript_value_134;
|
|
1416
|
+
if ((!((target === "wasm") || (target === "native")))) {
|
|
1417
|
+
session_fail("IR target must be javascript, wasm or native");
|
|
1418
|
+
}
|
|
1419
|
+
if ((runtime === null)) {
|
|
1420
|
+
session_fail("binary emission requires an initialized runtime");
|
|
1421
|
+
}
|
|
1422
|
+
if (__eliscript_truthy((globalThis.Object)["hasOwn"](request, "literalSources"))) {
|
|
1423
|
+
session_publish_literals(state, session_literal_modules(state, request));
|
|
1424
|
+
}
|
|
1425
|
+
{
|
|
1426
|
+
let lowered = session_backend_emission((program)["filename"], (() => {
|
|
1427
|
+
if ((target === "wasm")) {
|
|
1428
|
+
return emit_managed_ir_wasm_product(program, runtime, ({"literalModules": ((state)["literalModules"] ?? null)}), (() => {
|
|
1429
|
+
return session_wasm_configuration(request);
|
|
1430
|
+
}));
|
|
1431
|
+
} else {
|
|
1432
|
+
return lower_managed_program(program, runtime, null, null, null, null, null, null, null, ((state)["literalModules"] ?? null));
|
|
1433
|
+
}
|
|
1434
|
+
}));
|
|
1435
|
+
let modules = [({"id": "__eliscript_input__.mjs", "filename": (program)["filename"], "program": program, "source": ((request)["source"] ?? "")})];
|
|
1436
|
+
if ((target === "native")) {
|
|
1437
|
+
((lowered = ({"typed": (lowered)["typed"], "descriptor": (lowered)["descriptor"]})));
|
|
1438
|
+
}
|
|
1439
|
+
return session_lowered_output(state, modules, request, target, lowered);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}));
|
|
1444
|
+
}
|
|
1445
|
+
function session_project_ir(state, request) {
|
|
1446
|
+
return session_project_transaction(state, (() => {
|
|
1447
|
+
{
|
|
1448
|
+
const __eliscript_value_135 = ((request)["modules"] ?? undefined);
|
|
1449
|
+
const __eliscript_value_136 = [];
|
|
1450
|
+
const __eliscript_value_137 = new (globalThis.Set)();
|
|
1451
|
+
const __eliscript_value_138 = session_string(request, "target", undefined);
|
|
1452
|
+
const __eliscript_value_139 = session_string(request, "entry", undefined);
|
|
1453
|
+
{
|
|
1454
|
+
let inputs = __eliscript_value_135;
|
|
1455
|
+
let modules = __eliscript_value_136;
|
|
1456
|
+
let ids = __eliscript_value_137;
|
|
1457
|
+
let target = __eliscript_value_138;
|
|
1458
|
+
let entry = __eliscript_value_139;
|
|
1459
|
+
if ((!((target === "javascript") || (target === "wasm") || (target === "native")))) {
|
|
1460
|
+
session_fail("target must be javascript, wasm or native");
|
|
1461
|
+
}
|
|
1462
|
+
if ((!__eliscript_truthy(((__eliscript_value_140) => (__eliscript_truthy(__eliscript_value_140) ? __eliscript_numeric_relation(">", ((inputs) ?? []).length, 0) : __eliscript_value_140))(Array.isArray(inputs))))) {
|
|
1463
|
+
session_fail("project IR requires a non-empty modules array");
|
|
1464
|
+
}
|
|
1465
|
+
(inputs)["forEach"](((input) => {
|
|
1466
|
+
if ((!__eliscript_truthy(session_object_p(input)))) {
|
|
1467
|
+
session_fail("project IR module must be an object");
|
|
1468
|
+
}
|
|
1469
|
+
{
|
|
1470
|
+
let id = session_string(input, "id", undefined);
|
|
1471
|
+
let program = JSON.parse(session_string(input, "ir", undefined));
|
|
1472
|
+
let _canonical = serialize_ir_program(program);
|
|
1473
|
+
let filename = session_string(input, "filename", (program)["filename"]);
|
|
1474
|
+
let source = session_string(input, "source", "");
|
|
1475
|
+
if (__eliscript_truthy(((__eliscript_value_141) => (__eliscript_truthy(__eliscript_value_141) ? __eliscript_value_141 : (ids)["has"](id)))((((id) ?? []).length === 0)))) {
|
|
1476
|
+
session_fail("project IR module ids must be non-empty and unique", filename);
|
|
1477
|
+
}
|
|
1478
|
+
if ((!(filename === (program)["filename"]))) {
|
|
1479
|
+
session_fail("project IR filename must match its original IR filename", filename);
|
|
1480
|
+
}
|
|
1481
|
+
if ((!__eliscript_truthy(Array.isArray(((input)["macroOrigins"] ?? []))))) {
|
|
1482
|
+
session_fail("project IR macroOrigins must be an array", filename);
|
|
1483
|
+
}
|
|
1484
|
+
if (__eliscript_truthy(((__eliscript_value_142) => (__eliscript_truthy(__eliscript_value_142) ? ((__eliscript_value_143) => (__eliscript_truthy(__eliscript_value_143) ? (!__eliscript_truthy((globalThis.Object)["hasOwn"](input, "source"))) : __eliscript_value_143))(((request)["sourceMap"] ?? false)) : __eliscript_value_142))((target === "javascript")))) {
|
|
1485
|
+
session_fail("IR Source Maps require the original module source", filename);
|
|
1486
|
+
}
|
|
1487
|
+
(ids)["add"](id);
|
|
1488
|
+
return (modules)["push"](({"id": id, "filename": filename, "program": program, "source": source, "macroOrigins": ((input)["macroOrigins"] ?? [])}));
|
|
1489
|
+
}
|
|
1490
|
+
}));
|
|
1491
|
+
if ((!__eliscript_truthy((ids)["has"](entry)))) {
|
|
1492
|
+
session_fail("project entry is absent from modules", entry);
|
|
1493
|
+
}
|
|
1494
|
+
if ((((request)["resolveImports"] ?? false) === true)) {
|
|
1495
|
+
{
|
|
1496
|
+
const __eliscript_value_144 = new (globalThis.Map)();
|
|
1497
|
+
{
|
|
1498
|
+
let aliases = __eliscript_value_144;
|
|
1499
|
+
(modules)["forEach"](((item) => {
|
|
1500
|
+
return ([(item)["id"], (item)["filename"]])["forEach"](((path) => {
|
|
1501
|
+
{
|
|
1502
|
+
let key = session_normalize_path(path);
|
|
1503
|
+
let previous = (aliases)["get"](key);
|
|
1504
|
+
if (__eliscript_truthy(((__eliscript_value_145) => (__eliscript_truthy(__eliscript_value_145) ? (!(previous === (item)["id"])) : __eliscript_value_145))(previous))) {
|
|
1505
|
+
session_fail("ambiguous project source identity", path);
|
|
1506
|
+
}
|
|
1507
|
+
return (aliases)["set"](key, (item)["id"]);
|
|
1508
|
+
}
|
|
1509
|
+
}));
|
|
1510
|
+
}));
|
|
1511
|
+
(((request)["hostSources"] ?? []))["forEach"](((input) => {
|
|
1512
|
+
{
|
|
1513
|
+
const __eliscript_value_146 = session_normalize_path(session_string(input, "id", undefined));
|
|
1514
|
+
{
|
|
1515
|
+
let id = __eliscript_value_146;
|
|
1516
|
+
if (__eliscript_truthy((aliases)["has"](id))) {
|
|
1517
|
+
session_fail("host source collides with a compiled module", id);
|
|
1518
|
+
}
|
|
1519
|
+
(aliases)["set"](id, id);
|
|
1520
|
+
return (aliases)["set"](session_normalize_path(session_string(input, "filename", id)), id);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
}));
|
|
1524
|
+
((modules = (modules)["map"](((item) => {
|
|
1525
|
+
return (globalThis.Object)["assign"](({}), item, ({"program": (globalThis.Object)["assign"](({}), (item)["program"], ({"body": session_rewrite_imports(((item)["program"])["body"], item, aliases, ((request)["hostModules"] ?? []))}))}));
|
|
1526
|
+
}))));
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
if (__eliscript_truthy((globalThis.Object)["hasOwn"](request, "literalSources"))) {
|
|
1531
|
+
session_publish_literals(state, session_literal_modules(state, request));
|
|
1532
|
+
}
|
|
1533
|
+
{
|
|
1534
|
+
const __eliscript_value_147 = ((target === "javascript") ? session_javascript_project(modules, request) : session_binary_project(state, modules, request, target));
|
|
1535
|
+
{
|
|
1536
|
+
let result = __eliscript_value_147;
|
|
1537
|
+
((result)["revision"] = (state)["projectRevision"]);
|
|
1538
|
+
if (__eliscript_numeric_relation(">", ((((state)["literalModules"] ?? [])) ?? []).length, 0)) {
|
|
1539
|
+
((result)["literalRevision"] = (state)["literalRevision"]);
|
|
1540
|
+
}
|
|
1541
|
+
return result;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
}));
|
|
1547
|
+
}
|
|
1548
|
+
function session_binary_options(request, kind) {
|
|
1549
|
+
{
|
|
1550
|
+
const __eliscript_value_148 = ({"format": kind});
|
|
1551
|
+
{
|
|
1552
|
+
let options = __eliscript_value_148;
|
|
1553
|
+
if (__eliscript_truthy(Object.hasOwn(request, "binaryEncoding"))) {
|
|
1554
|
+
((options)["binaryEncoding"] = (request)["binaryEncoding"]);
|
|
1555
|
+
}
|
|
1556
|
+
return options;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
function session_native_observer(state) {
|
|
1561
|
+
return (() => {
|
|
1562
|
+
try {
|
|
1563
|
+
{
|
|
1564
|
+
const __eliscript_value_149 = ((state)["phaseObserver"] ?? null);
|
|
1565
|
+
{
|
|
1566
|
+
let observer = __eliscript_value_149;
|
|
1567
|
+
if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(observer) === "function")) {
|
|
1568
|
+
return observer;
|
|
1569
|
+
} else {
|
|
1570
|
+
return null;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
} catch (ignored) {
|
|
1575
|
+
return null;
|
|
1576
|
+
}
|
|
1577
|
+
})();
|
|
1578
|
+
}
|
|
1579
|
+
function session_memory_ir(request, operation) {
|
|
1580
|
+
{
|
|
1581
|
+
let input = JSON.parse(session_string(request, "ir", undefined));
|
|
1582
|
+
let target = session_string(request, "target", undefined);
|
|
1583
|
+
let typed = ((operation === "emit-memory-ir") ? (() => {
|
|
1584
|
+
serialize_ir_program(input);
|
|
1585
|
+
return lower_memory_program(input);
|
|
1586
|
+
})() : input);
|
|
1587
|
+
let emission = JSON.parse(session_ir_wire(typed, new (globalThis.Set)()));
|
|
1588
|
+
let memory = ((request)["memory"] ?? ({}));
|
|
1589
|
+
let debug = (((request)["debug"] ?? false) === true);
|
|
1590
|
+
if ((!((target === "wasm") || (target === "native")))) {
|
|
1591
|
+
session_fail("raw memory IR targets must be wasm or native");
|
|
1592
|
+
}
|
|
1593
|
+
if ((!__eliscript_truthy(session_object_p(memory)))) {
|
|
1594
|
+
session_fail("memory must be an object");
|
|
1595
|
+
}
|
|
1596
|
+
if ((target === "wasm")) {
|
|
1597
|
+
{
|
|
1598
|
+
let configuration = session_wasm_configuration(request);
|
|
1599
|
+
let memory = (configuration)["memory"];
|
|
1600
|
+
let artifact = (__eliscript_truthy(debug) ? emit_typed_memory_wasm_artifact(emission, memory) : null);
|
|
1601
|
+
return ({"target": target, "abi": "memory-u32", "typed": typed, "bytes": (__eliscript_truthy(artifact) ? (artifact)["bytes"] : emit_typed_memory_wasm(emission, memory)), "debug": (__eliscript_truthy(artifact) ? (artifact)["debug"] : null)});
|
|
1602
|
+
}
|
|
1603
|
+
} else {
|
|
1604
|
+
{
|
|
1605
|
+
const __eliscript_value_150 = session_string(request, "nativeTarget", undefined);
|
|
1606
|
+
const __eliscript_value_151 = session_string(request, "nativeFormat", "library");
|
|
1607
|
+
{
|
|
1608
|
+
let platform = __eliscript_value_150;
|
|
1609
|
+
let kind = __eliscript_value_151;
|
|
1610
|
+
if ((!((kind === "library") || (kind === "object")))) {
|
|
1611
|
+
session_fail("nativeFormat must be library or object");
|
|
1612
|
+
}
|
|
1613
|
+
{
|
|
1614
|
+
const __eliscript_value_152 = (__eliscript_truthy(debug) ? emit_typed_native_memory_artifact(emission, platform, session_binary_options(request, kind)) : null);
|
|
1615
|
+
{
|
|
1616
|
+
let artifact = __eliscript_value_152;
|
|
1617
|
+
return ({"target": target, "abi": "memory-u32", "typed": typed, "nativeTarget": platform, "nativeFormat": kind, "bytes": (__eliscript_truthy(artifact) ? (artifact)["bytes"] : ((kind === "object") ? emit_typed_native_memory_object(emission, platform, session_binary_options(request, kind)) : emit_typed_native_memory_library(emission, platform, session_binary_options(request, kind)))), "debug": (__eliscript_truthy(artifact) ? (artifact)["debug"] : null)});
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
function session_input_index(inputs) {
|
|
1626
|
+
{
|
|
1627
|
+
const __eliscript_value_153 = new (globalThis.Map)();
|
|
1628
|
+
const __eliscript_value_154 = new (globalThis.Map)();
|
|
1629
|
+
{
|
|
1630
|
+
let records = __eliscript_value_153;
|
|
1631
|
+
let aliases = __eliscript_value_154;
|
|
1632
|
+
(inputs)["forEach"](((input) => {
|
|
1633
|
+
if ((!__eliscript_truthy(session_object_p(input)))) {
|
|
1634
|
+
session_fail("project module must be an object");
|
|
1635
|
+
}
|
|
1636
|
+
{
|
|
1637
|
+
let id = session_string(input, "id", undefined);
|
|
1638
|
+
let filename = session_string(input, "filename", id);
|
|
1639
|
+
if (__eliscript_truthy(((__eliscript_value_155) => (__eliscript_truthy(__eliscript_value_155) ? __eliscript_value_155 : (records)["has"](id)))((((id) ?? []).length === 0)))) {
|
|
1640
|
+
session_fail("project module ids must be non-empty and unique", filename);
|
|
1641
|
+
}
|
|
1642
|
+
(records)["set"](id, input);
|
|
1643
|
+
return ([id, filename])["forEach"](((path) => {
|
|
1644
|
+
{
|
|
1645
|
+
let key = session_normalize_path(path);
|
|
1646
|
+
let existing = (aliases)["get"](key);
|
|
1647
|
+
if (__eliscript_truthy(((__eliscript_value_156) => (__eliscript_truthy(__eliscript_value_156) ? (!(existing === id)) : __eliscript_value_156))(existing))) {
|
|
1648
|
+
session_fail("ambiguous project source identity", path);
|
|
1649
|
+
}
|
|
1650
|
+
return (aliases)["set"](key, id);
|
|
1651
|
+
}
|
|
1652
|
+
}));
|
|
1653
|
+
}
|
|
1654
|
+
}));
|
|
1655
|
+
return ({"records": records, "aliases": aliases});
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
function session_enqueue_dependencies(nodes, item, graph, queued, pending) {
|
|
1660
|
+
return (nodes)["forEach"](((node) => {
|
|
1661
|
+
if (((node)["kind"] === "module-declaration")) {
|
|
1662
|
+
return session_enqueue_dependencies((node)["children"], item, graph, queued, pending);
|
|
1663
|
+
} else {
|
|
1664
|
+
if (((node)["kind"] === "import-declaration")) {
|
|
1665
|
+
{
|
|
1666
|
+
const __eliscript_value_157 = (node)["value"];
|
|
1667
|
+
const __eliscript_value_158 = null;
|
|
1668
|
+
{
|
|
1669
|
+
let specifier = __eliscript_value_157;
|
|
1670
|
+
let target = __eliscript_value_158;
|
|
1671
|
+
if (__eliscript_truthy((specifier)["startsWith"]("."))) {
|
|
1672
|
+
{
|
|
1673
|
+
const __eliscript_value_159 = ((item)["filename"])["split"]("/");
|
|
1674
|
+
{
|
|
1675
|
+
let parts = __eliscript_value_159;
|
|
1676
|
+
(parts)["pop"]();
|
|
1677
|
+
((target = ((graph)["aliases"])["get"](session_normalize_path(((__eliscript_numeric_relation(">", ((parts) ?? []).length, 0) ? (__eliscript_at_direct(parts, "join", "/") + "/") : "") + specifier)))));
|
|
1678
|
+
if ((!__eliscript_truthy(((__eliscript_value_160) => (__eliscript_truthy(__eliscript_value_160) ? __eliscript_value_160 : ((__eliscript_value_161) => (__eliscript_truthy(__eliscript_value_161) ? __eliscript_value_161 : ((graph)["hostModules"])["some"](((declaration) => {
|
|
1679
|
+
return (((declaration)["referrer"] === (item)["id"]) && ((declaration)["specifier"] === specifier));
|
|
1680
|
+
}))))(((graph)["hostAliases"])["has"](session_normalize_path(((__eliscript_numeric_relation(">", ((parts) ?? []).length, 0) ? (__eliscript_at_direct(parts, "join", "/") + "/") : "") + specifier))))))(target)))) {
|
|
1681
|
+
session_fail(("missing project source: " + specifier), (item)["filename"]);
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
} else {
|
|
1686
|
+
((target = ((graph)["aliases"])["get"](specifier)));
|
|
1687
|
+
}
|
|
1688
|
+
if (__eliscript_truthy(((__eliscript_value_162) => (__eliscript_truthy(__eliscript_value_162) ? (!__eliscript_truthy((queued)["has"](target))) : __eliscript_value_162))(target))) {
|
|
1689
|
+
(queued)["add"](target);
|
|
1690
|
+
return (pending)["push"](((graph)["records"])["get"](target));
|
|
1691
|
+
} else {
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
} else {
|
|
1697
|
+
return null;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}));
|
|
1701
|
+
}
|
|
1702
|
+
function session_source_record(id, source, filename, macro_input, trace, entries = null) {
|
|
1703
|
+
{
|
|
1704
|
+
const __eliscript_value_163 = session_macro_context(macro_input);
|
|
1705
|
+
{
|
|
1706
|
+
let context = __eliscript_value_163;
|
|
1707
|
+
if ((!__eliscript_truthy(trace))) {
|
|
1708
|
+
return ({"id": id, "source": source, "filename": filename, "portableEntries": ((__eliscript_value_164) => (__eliscript_truthy(__eliscript_value_164) ? __eliscript_value_164 : []))(entries), "program": (__eliscript_truthy(entries) ? compile_project_portable_ir_string(source, entries, filename, context) : compile_ir_string(source, filename, context))});
|
|
1709
|
+
} else {
|
|
1710
|
+
{
|
|
1711
|
+
let expansion = expand_owned_module_with_origins(read_string(source, filename), filename, context);
|
|
1712
|
+
let forms = (expansion)["forms"];
|
|
1713
|
+
analyze_module(forms, filename);
|
|
1714
|
+
{
|
|
1715
|
+
const __eliscript_value_165 = (__eliscript_truthy(entries) ? select_portable_module(forms, entries, filename, true) : forms);
|
|
1716
|
+
const __eliscript_value_166 = (expansion)["macroOrigins"];
|
|
1717
|
+
{
|
|
1718
|
+
let selected = __eliscript_value_165;
|
|
1719
|
+
let origins = __eliscript_value_166;
|
|
1720
|
+
((expansion)["forms"] = null);
|
|
1721
|
+
((expansion = null));
|
|
1722
|
+
((forms = null));
|
|
1723
|
+
return ({"id": id, "source": source, "filename": filename, "portableEntries": ((__eliscript_value_167) => (__eliscript_truthy(__eliscript_value_167) ? __eliscript_value_167 : []))(entries), "program": lower_owned_module(selected, filename), "macroOrigins": origins});
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
function session_portable_requests(request) {
|
|
1732
|
+
{
|
|
1733
|
+
const __eliscript_value_168 = [];
|
|
1734
|
+
const __eliscript_value_169 = ((request)["portableEntries"] ?? []);
|
|
1735
|
+
const __eliscript_value_170 = ((request)["modules"] ?? null);
|
|
1736
|
+
{
|
|
1737
|
+
let initial = __eliscript_value_168;
|
|
1738
|
+
let entries = __eliscript_value_169;
|
|
1739
|
+
let inputs = __eliscript_value_170;
|
|
1740
|
+
if ((!__eliscript_truthy(Array.isArray(entries)))) {
|
|
1741
|
+
session_fail("portableEntries must be an array");
|
|
1742
|
+
}
|
|
1743
|
+
if (__eliscript_numeric_relation(">", ((entries) ?? []).length, 0)) {
|
|
1744
|
+
(initial)["push"](({"id": session_string(request, "entry", undefined), "entries": entries}));
|
|
1745
|
+
}
|
|
1746
|
+
if (__eliscript_truthy(Array.isArray(inputs))) {
|
|
1747
|
+
(inputs)["forEach"](((input) => {
|
|
1748
|
+
if (__eliscript_truthy(session_object_p(input))) {
|
|
1749
|
+
{
|
|
1750
|
+
const __eliscript_value_171 = ((input)["portableEntries"] ?? []);
|
|
1751
|
+
{
|
|
1752
|
+
let selected = __eliscript_value_171;
|
|
1753
|
+
if ((!__eliscript_truthy(Array.isArray(selected)))) {
|
|
1754
|
+
session_fail("module portableEntries must be an array");
|
|
1755
|
+
}
|
|
1756
|
+
if (__eliscript_numeric_relation(">", ((selected) ?? []).length, 0)) {
|
|
1757
|
+
return (initial)["push"](({"id": session_string(input, "id", undefined), "entries": selected}));
|
|
1758
|
+
} else {
|
|
1759
|
+
return null;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
} else {
|
|
1764
|
+
return null;
|
|
1765
|
+
}
|
|
1766
|
+
}));
|
|
1767
|
+
}
|
|
1768
|
+
return initial;
|
|
1769
|
+
}
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
function session_portable_import_fail(message, filename) {
|
|
1773
|
+
{
|
|
1774
|
+
const __eliscript_value_172 = new (Error)(message);
|
|
1775
|
+
{
|
|
1776
|
+
let error = __eliscript_value_172;
|
|
1777
|
+
((error)["eliscriptDiagnostic"] = ({"format": "eliscript-diagnostic", "version": 1, "code": "ELI-B0001", "severity": "error", "phase": "project-build", "message": message, "location": ({"file": filename})}));
|
|
1778
|
+
return ((__eliscript_value_173) => { throw __eliscript_value_173; })(error);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function session_portable_dependencies(nodes, item, graph) {
|
|
1783
|
+
{
|
|
1784
|
+
const __eliscript_value_174 = [];
|
|
1785
|
+
{
|
|
1786
|
+
let dependencies = __eliscript_value_174;
|
|
1787
|
+
(nodes)["forEach"](((node) => {
|
|
1788
|
+
if (((node)["kind"] === "module-declaration")) {
|
|
1789
|
+
return (session_portable_dependencies((node)["children"], item, graph))["forEach"](((dependency) => {
|
|
1790
|
+
return (dependencies)["push"](dependency);
|
|
1791
|
+
}));
|
|
1792
|
+
} else {
|
|
1793
|
+
if (((node)["kind"] === "import-declaration")) {
|
|
1794
|
+
if ((!(((((node)["properties"] ?? ({})))["portable"] ?? false) === true))) {
|
|
1795
|
+
session_portable_import_fail("portable project contains a non-portable import", (item)["filename"]);
|
|
1796
|
+
}
|
|
1797
|
+
{
|
|
1798
|
+
const __eliscript_value_175 = (node)["value"];
|
|
1799
|
+
{
|
|
1800
|
+
let specifier = __eliscript_value_175;
|
|
1801
|
+
if ((!__eliscript_truthy(((__eliscript_value_176) => (__eliscript_truthy(__eliscript_value_176) ? (specifier)["endsWith"](".eli") : __eliscript_value_176))((specifier)["startsWith"]("."))))) {
|
|
1802
|
+
session_portable_import_fail(("portable import must be a relative .eli module: " + specifier), (item)["filename"]);
|
|
1803
|
+
}
|
|
1804
|
+
{
|
|
1805
|
+
const __eliscript_value_177 = ((item)["filename"])["split"]("/");
|
|
1806
|
+
{
|
|
1807
|
+
let parts = __eliscript_value_177;
|
|
1808
|
+
(parts)["pop"]();
|
|
1809
|
+
{
|
|
1810
|
+
let path = session_normalize_path(((__eliscript_numeric_relation(">", ((parts) ?? []).length, 0) ? (__eliscript_at_direct(parts, "join", "/") + "/") : "") + specifier));
|
|
1811
|
+
let target = ((graph)["aliases"])["get"](path);
|
|
1812
|
+
if ((!__eliscript_truthy(target))) {
|
|
1813
|
+
session_fail(("missing project source: " + specifier), (item)["filename"]);
|
|
1814
|
+
}
|
|
1815
|
+
return (dependencies)["push"](({"id": target, "entries": (((node)["children"])["filter"](((binding) => {
|
|
1816
|
+
return ((binding)["kind"] === "import-named");
|
|
1817
|
+
})))["map"](((binding) => {
|
|
1818
|
+
return (binding)["value"];
|
|
1819
|
+
}))}));
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
} else {
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}));
|
|
1830
|
+
return dependencies;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
function session_compile_portable_modules(state, request, initial) {
|
|
1835
|
+
{
|
|
1836
|
+
let inputs = ((request)["modules"] ?? null);
|
|
1837
|
+
let graph = session_input_index(inputs);
|
|
1838
|
+
let previous = ((((request)["cache"] ?? true) === false) ? new (globalThis.Map)() : (state)["moduleCache"]);
|
|
1839
|
+
let next = new (globalThis.Map)();
|
|
1840
|
+
let modules = [];
|
|
1841
|
+
let plan = portable_project_plan(initial, ((id, entries) => {
|
|
1842
|
+
{
|
|
1843
|
+
const __eliscript_value_178 = ((graph)["records"])["get"](id);
|
|
1844
|
+
{
|
|
1845
|
+
let input = __eliscript_value_178;
|
|
1846
|
+
if ((!__eliscript_truthy(input))) {
|
|
1847
|
+
session_fail("project entry is absent from modules", id);
|
|
1848
|
+
}
|
|
1849
|
+
{
|
|
1850
|
+
let source = session_string(input, "source", undefined);
|
|
1851
|
+
let filename = session_string(input, "filename", id);
|
|
1852
|
+
let macro_input = ((input)["macroContext"] ?? ((request)["macroContext"] ?? null));
|
|
1853
|
+
let trace = (((request)["debug"] ?? false) === true);
|
|
1854
|
+
let key = JSON.stringify([source, filename, macro_input, trace, entries]);
|
|
1855
|
+
let cached = ((__eliscript_value_179) => (__eliscript_truthy(__eliscript_value_179) ? __eliscript_value_179 : (previous)["get"](id)))((next)["get"](id));
|
|
1856
|
+
let item = (__eliscript_truthy(((__eliscript_value_180) => (__eliscript_truthy(__eliscript_value_180) ? ((cached)["key"] === key) : __eliscript_value_180))(cached)) ? (cached)["module"] : session_source_record(id, source, filename, macro_input, trace, entries));
|
|
1857
|
+
(next)["set"](id, ({"key": key, "module": item}));
|
|
1858
|
+
return session_portable_dependencies(((item)["program"])["body"], item, graph);
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}));
|
|
1863
|
+
((plan)["modules"])["forEach"](((record) => {
|
|
1864
|
+
return (modules)["push"](((next)["get"]((record)["id"]))["module"]);
|
|
1865
|
+
}));
|
|
1866
|
+
return ({"modules": modules, "cache": next, "portablePlan": plan});
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
function session_compile_standard_modules(state, request) {
|
|
1870
|
+
{
|
|
1871
|
+
const __eliscript_value_181 = ((request)["modules"] ?? null);
|
|
1872
|
+
const __eliscript_value_182 = [];
|
|
1873
|
+
const __eliscript_value_183 = new (globalThis.Set)();
|
|
1874
|
+
const __eliscript_value_184 = 0;
|
|
1875
|
+
const __eliscript_value_185 = ((((request)["cache"] ?? true) === false) ? new (globalThis.Map)() : (state)["moduleCache"]);
|
|
1876
|
+
const __eliscript_value_186 = new (globalThis.Map)();
|
|
1877
|
+
const __eliscript_value_187 = null;
|
|
1878
|
+
const __eliscript_value_188 = new (globalThis.Set)();
|
|
1879
|
+
{
|
|
1880
|
+
let inputs = __eliscript_value_181;
|
|
1881
|
+
let modules = __eliscript_value_182;
|
|
1882
|
+
let ids = __eliscript_value_183;
|
|
1883
|
+
let index = __eliscript_value_184;
|
|
1884
|
+
let previous = __eliscript_value_185;
|
|
1885
|
+
let next = __eliscript_value_186;
|
|
1886
|
+
let graph = __eliscript_value_187;
|
|
1887
|
+
let queued = __eliscript_value_188;
|
|
1888
|
+
if ((!__eliscript_truthy(((__eliscript_value_189) => (__eliscript_truthy(__eliscript_value_189) ? __eliscript_numeric_relation(">", ((inputs) ?? []).length, 0) : __eliscript_value_189))(Array.isArray(inputs))))) {
|
|
1889
|
+
session_fail("project requires a non-empty modules array");
|
|
1890
|
+
}
|
|
1891
|
+
if ((((request)["resolveImports"] ?? false) === true)) {
|
|
1892
|
+
((graph = session_input_index(inputs)));
|
|
1893
|
+
{
|
|
1894
|
+
const __eliscript_value_190 = new (globalThis.Map)();
|
|
1895
|
+
{
|
|
1896
|
+
let hosts = __eliscript_value_190;
|
|
1897
|
+
(((request)["hostSources"] ?? []))["forEach"](((item) => {
|
|
1898
|
+
{
|
|
1899
|
+
const __eliscript_value_191 = session_string(item, "id", undefined);
|
|
1900
|
+
{
|
|
1901
|
+
let id = __eliscript_value_191;
|
|
1902
|
+
(hosts)["set"](session_normalize_path(id), id);
|
|
1903
|
+
return (hosts)["set"](session_normalize_path(session_string(item, "filename", id)), id);
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}));
|
|
1907
|
+
((graph)["hostAliases"] = hosts);
|
|
1908
|
+
((graph)["hostModules"] = ((request)["hostModules"] ?? []));
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
{
|
|
1912
|
+
const __eliscript_value_192 = ((request)["entries"] ?? [(request)["entry"]]);
|
|
1913
|
+
{
|
|
1914
|
+
let entries = __eliscript_value_192;
|
|
1915
|
+
if ((!__eliscript_truthy(((__eliscript_value_193) => (__eliscript_truthy(__eliscript_value_193) ? __eliscript_numeric_relation(">", ((entries) ?? []).length, 0) : __eliscript_value_193))(Array.isArray(entries))))) {
|
|
1916
|
+
session_fail("project requires entry identities");
|
|
1917
|
+
}
|
|
1918
|
+
if (__eliscript_numeric_relation(">", ((((request)["hostSources"] ?? [])) ?? []).length, 0)) {
|
|
1919
|
+
((entries = Array.from(((graph)["records"])["keys"]())));
|
|
1920
|
+
}
|
|
1921
|
+
((inputs = []));
|
|
1922
|
+
(entries)["forEach"](((entry) => {
|
|
1923
|
+
if ((!__eliscript_truthy(((graph)["records"])["has"](entry)))) {
|
|
1924
|
+
session_fail("project entry is absent from modules", entry);
|
|
1925
|
+
}
|
|
1926
|
+
if ((!__eliscript_truthy((queued)["has"](entry)))) {
|
|
1927
|
+
(queued)["add"](entry);
|
|
1928
|
+
return (inputs)["push"](((graph)["records"])["get"](entry));
|
|
1929
|
+
} else {
|
|
1930
|
+
return null;
|
|
1931
|
+
}
|
|
1932
|
+
}));
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
while (__eliscript_numeric_relation("<", index, ((inputs) ?? []).length)) {
|
|
1937
|
+
{
|
|
1938
|
+
const __eliscript_value_194 = ((((inputs) ?? [])[index]) ?? null);
|
|
1939
|
+
{
|
|
1940
|
+
let input = __eliscript_value_194;
|
|
1941
|
+
if ((!__eliscript_truthy(session_object_p(input)))) {
|
|
1942
|
+
session_fail("project module must be an object");
|
|
1943
|
+
}
|
|
1944
|
+
{
|
|
1945
|
+
let id = session_string(input, "id", undefined);
|
|
1946
|
+
let source = session_string(input, "source", undefined);
|
|
1947
|
+
let filename = session_string(input, "filename", id);
|
|
1948
|
+
let macro_input = ((input)["macroContext"] ?? ((request)["macroContext"] ?? null));
|
|
1949
|
+
let trace = (((request)["debug"] ?? false) === true);
|
|
1950
|
+
let key = JSON.stringify([source, filename, macro_input, trace]);
|
|
1951
|
+
let cached = (previous)["get"](id);
|
|
1952
|
+
if (__eliscript_truthy(((__eliscript_value_195) => (__eliscript_truthy(__eliscript_value_195) ? __eliscript_value_195 : (ids)["has"](id)))((((id) ?? []).length === 0)))) {
|
|
1953
|
+
session_fail("project module ids must be non-empty and unique", filename);
|
|
1954
|
+
}
|
|
1955
|
+
(ids)["add"](id);
|
|
1956
|
+
{
|
|
1957
|
+
const __eliscript_value_196 = (__eliscript_truthy(((__eliscript_value_197) => (__eliscript_truthy(__eliscript_value_197) ? ((cached)["key"] === key) : __eliscript_value_197))(cached)) ? (cached)["module"] : session_source_record(id, source, filename, macro_input, trace));
|
|
1958
|
+
{
|
|
1959
|
+
let item = __eliscript_value_196;
|
|
1960
|
+
(modules)["push"](item);
|
|
1961
|
+
(next)["set"](id, ({"key": key, "module": item}));
|
|
1962
|
+
if (__eliscript_truthy(graph)) {
|
|
1963
|
+
session_enqueue_dependencies(((item)["program"])["body"], item, graph, queued, inputs);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
((index = (index + 1)));
|
|
1971
|
+
}
|
|
1972
|
+
return ({"modules": modules, "cache": next, "portablePlan": null});
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function session_compile_modules(state, request) {
|
|
1977
|
+
{
|
|
1978
|
+
const __eliscript_value_198 = ((request)["modules"] ?? null);
|
|
1979
|
+
const __eliscript_value_199 = session_portable_requests(request);
|
|
1980
|
+
{
|
|
1981
|
+
let inputs = __eliscript_value_198;
|
|
1982
|
+
let initial = __eliscript_value_199;
|
|
1983
|
+
if ((!__eliscript_truthy(((__eliscript_value_200) => (__eliscript_truthy(__eliscript_value_200) ? __eliscript_numeric_relation(">", ((inputs) ?? []).length, 0) : __eliscript_value_200))(Array.isArray(inputs))))) {
|
|
1984
|
+
session_fail("project requires a non-empty modules array");
|
|
1985
|
+
}
|
|
1986
|
+
if (__eliscript_numeric_relation(">", ((initial) ?? []).length, 0)) {
|
|
1987
|
+
return session_compile_portable_modules(state, request, initial);
|
|
1988
|
+
} else {
|
|
1989
|
+
return session_compile_standard_modules(state, request);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
function session_modules(state, request) {
|
|
1995
|
+
session_phase(state, "modules-start", 0);
|
|
1996
|
+
{
|
|
1997
|
+
const __eliscript_value_201 = JSON.stringify([((request)["modules"] ?? null), ((request)["macroContext"] ?? null), ((request)["resolveImports"] ?? false), ((request)["entry"] ?? null), ((request)["entries"] ?? null), ((request)["portableEntries"] ?? null), ((request)["debug"] ?? false), ((request)["hostSources"] ?? null), ((request)["hostModules"] ?? null), ((state)["literalRevision"] ?? 0)]);
|
|
1998
|
+
{
|
|
1999
|
+
let key = __eliscript_value_201;
|
|
2000
|
+
if (((!(((request)["cache"] ?? true) === false)) && (key === (state)["projectKey"]) && (!((state)["projectModules"] === null)))) {
|
|
2001
|
+
session_phase(state, "modules-cached", (((state)["projectModules"]) ?? []).length);
|
|
2002
|
+
return (state)["projectModules"];
|
|
2003
|
+
} else {
|
|
2004
|
+
{
|
|
2005
|
+
let compiled = session_compile_modules(state, request);
|
|
2006
|
+
let modules = (compiled)["modules"];
|
|
2007
|
+
((state)["moduleCache"] = (compiled)["cache"]);
|
|
2008
|
+
((state)["projectPortablePlan"] = (compiled)["portablePlan"]);
|
|
2009
|
+
((state)["projectKey"] = key);
|
|
2010
|
+
((state)["projectModules"] = modules);
|
|
2011
|
+
((state)["projectRevision"] = ((state)["projectRevision"] + 1));
|
|
2012
|
+
session_phase(state, "modules-complete", ((modules) ?? []).length);
|
|
2013
|
+
return modules;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
function session_cached_ir(state, request) {
|
|
2020
|
+
{
|
|
2021
|
+
const __eliscript_value_202 = session_string(request, "kind", "module");
|
|
2022
|
+
const __eliscript_value_203 = null;
|
|
2023
|
+
const __eliscript_value_204 = null;
|
|
2024
|
+
const __eliscript_value_205 = null;
|
|
2025
|
+
const __eliscript_value_206 = ((request)["revision"] ?? undefined);
|
|
2026
|
+
{
|
|
2027
|
+
let kind = __eliscript_value_202;
|
|
2028
|
+
let program = __eliscript_value_203;
|
|
2029
|
+
let filename = __eliscript_value_204;
|
|
2030
|
+
let id = __eliscript_value_205;
|
|
2031
|
+
let revision = __eliscript_value_206;
|
|
2032
|
+
if ((!__eliscript_truthy(((__eliscript_value_207) => (__eliscript_truthy(__eliscript_value_207) ? __eliscript_numeric_relation(">=", revision, 0) : __eliscript_value_207))(Number.isSafeInteger(revision))))) {
|
|
2033
|
+
session_fail("cached IR requires an exact source revision");
|
|
2034
|
+
}
|
|
2035
|
+
if ((kind === "runtime")) {
|
|
2036
|
+
if ((!(revision === (state)["revision"]))) {
|
|
2037
|
+
session_fail("runtime IR belongs to a different revision");
|
|
2038
|
+
}
|
|
2039
|
+
((program = (state)["runtime"]), (filename = (state)["runtimeFilename"]), (id = "runtime"));
|
|
2040
|
+
} else {
|
|
2041
|
+
if ((kind === "literal")) {
|
|
2042
|
+
if ((!(revision === (state)["literalRevision"]))) {
|
|
2043
|
+
session_fail("literal IR belongs to a different revision");
|
|
2044
|
+
}
|
|
2045
|
+
((id = session_string(request, "id", undefined)));
|
|
2046
|
+
{
|
|
2047
|
+
const __eliscript_value_208 = ((state)["literalCache"])["get"](id);
|
|
2048
|
+
{
|
|
2049
|
+
let cached = __eliscript_value_208;
|
|
2050
|
+
if (__eliscript_truthy(cached)) {
|
|
2051
|
+
((program = (cached)["program"]), (filename = (cached)["filename"]));
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
} else {
|
|
2056
|
+
if ((kind === "module")) {
|
|
2057
|
+
if ((!(revision === (state)["projectRevision"]))) {
|
|
2058
|
+
session_fail("project IR belongs to a different revision");
|
|
2059
|
+
}
|
|
2060
|
+
((id = session_string(request, "id", undefined)));
|
|
2061
|
+
{
|
|
2062
|
+
const __eliscript_value_209 = ((state)["projectModules"] ?? null);
|
|
2063
|
+
{
|
|
2064
|
+
let modules = __eliscript_value_209;
|
|
2065
|
+
if (__eliscript_truthy(modules)) {
|
|
2066
|
+
(modules)["forEach"](((item) => {
|
|
2067
|
+
if ((id === (item)["id"])) {
|
|
2068
|
+
return ((program = (item)["program"]), (filename = (item)["filename"]));
|
|
2069
|
+
} else {
|
|
2070
|
+
return null;
|
|
2071
|
+
}
|
|
2072
|
+
}));
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
} else {
|
|
2077
|
+
session_fail("cached IR kind must be module, runtime or literal");
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
if ((program === null)) {
|
|
2082
|
+
session_fail("cached IR is unavailable", filename);
|
|
2083
|
+
}
|
|
2084
|
+
{
|
|
2085
|
+
const __eliscript_value_210 = ({"id": id, "filename": filename, "revision": revision, "stage": "frontend"});
|
|
2086
|
+
{
|
|
2087
|
+
let result = __eliscript_value_210;
|
|
2088
|
+
if ((((request)["responseStringChunks"] ?? false) === true)) {
|
|
2089
|
+
Object.defineProperty(result, "ir", ({"enumerable": true, "configurable": true, "get": (() => {
|
|
2090
|
+
return session_ir_wire(program, new (globalThis.Set)());
|
|
2091
|
+
})}));
|
|
2092
|
+
Object.defineProperty(result, "canonicalIR", ({"enumerable": true, "configurable": true, "get": (() => {
|
|
2093
|
+
return serialize_ir_program(program);
|
|
2094
|
+
})}));
|
|
2095
|
+
} else {
|
|
2096
|
+
((result)["ir"] = session_ir_wire(program, new (globalThis.Set)()));
|
|
2097
|
+
((result)["canonicalIR"] = serialize_ir_program(program));
|
|
2098
|
+
}
|
|
2099
|
+
return result;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
function session_normalize_path(path) {
|
|
2106
|
+
if (__eliscript_truthy(((__eliscript_value_211) => (__eliscript_truthy(__eliscript_value_211) ? __eliscript_value_211 : (path)["includes"]("\\")))((path)["startsWith"]("/")))) {
|
|
2107
|
+
session_fail("project paths must be relative virtual paths", path);
|
|
2108
|
+
}
|
|
2109
|
+
{
|
|
2110
|
+
const __eliscript_value_212 = (path)["split"]("/");
|
|
2111
|
+
const __eliscript_value_213 = [];
|
|
2112
|
+
const __eliscript_value_214 = 0;
|
|
2113
|
+
{
|
|
2114
|
+
let parts = __eliscript_value_212;
|
|
2115
|
+
let result = __eliscript_value_213;
|
|
2116
|
+
let index = __eliscript_value_214;
|
|
2117
|
+
while (__eliscript_numeric_relation("<", index, ((parts) ?? []).length)) {
|
|
2118
|
+
{
|
|
2119
|
+
const __eliscript_value_215 = ((((parts) ?? [])[index]) ?? null);
|
|
2120
|
+
{
|
|
2121
|
+
let part = __eliscript_value_215;
|
|
2122
|
+
if (((part === "") || (part === "."))) {
|
|
2123
|
+
null;
|
|
2124
|
+
} else {
|
|
2125
|
+
if ((part === "..")) {
|
|
2126
|
+
if ((((result) ?? []).length === 0)) {
|
|
2127
|
+
session_fail("project path escapes its virtual root", path);
|
|
2128
|
+
}
|
|
2129
|
+
(result)["pop"]();
|
|
2130
|
+
} else {
|
|
2131
|
+
(result)["push"](part);
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
((index = (index + 1)));
|
|
2137
|
+
}
|
|
2138
|
+
return __eliscript_at_direct(result, "join", "/");
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function session_relative_import(importer, target) {
|
|
2143
|
+
{
|
|
2144
|
+
const __eliscript_value_216 = (importer)["split"]("/");
|
|
2145
|
+
const __eliscript_value_217 = (target)["split"]("/");
|
|
2146
|
+
const __eliscript_value_218 = 0;
|
|
2147
|
+
const __eliscript_value_219 = [];
|
|
2148
|
+
{
|
|
2149
|
+
let from = __eliscript_value_216;
|
|
2150
|
+
let to = __eliscript_value_217;
|
|
2151
|
+
let index = __eliscript_value_218;
|
|
2152
|
+
let parts = __eliscript_value_219;
|
|
2153
|
+
(from)["pop"]();
|
|
2154
|
+
while ((__eliscript_numeric_relation("<", index, ((from) ?? []).length) && __eliscript_numeric_relation("<", index, ((to) ?? []).length) && (((((from) ?? [])[index]) ?? null) === ((((to) ?? [])[index]) ?? null)))) {
|
|
2155
|
+
((index = (index + 1)));
|
|
2156
|
+
}
|
|
2157
|
+
{
|
|
2158
|
+
const __eliscript_value_220 = index;
|
|
2159
|
+
{
|
|
2160
|
+
let remaining = __eliscript_value_220;
|
|
2161
|
+
while (__eliscript_numeric_relation("<", remaining, ((from) ?? []).length)) {
|
|
2162
|
+
(parts)["push"]("..");
|
|
2163
|
+
((remaining = (remaining + 1)));
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
while (__eliscript_numeric_relation("<", index, ((to) ?? []).length)) {
|
|
2168
|
+
(parts)["push"](((((to) ?? [])[index]) ?? null));
|
|
2169
|
+
((index = (index + 1)));
|
|
2170
|
+
}
|
|
2171
|
+
{
|
|
2172
|
+
const __eliscript_value_221 = __eliscript_at_direct(parts, "join", "/");
|
|
2173
|
+
{
|
|
2174
|
+
let path = __eliscript_value_221;
|
|
2175
|
+
if (__eliscript_truthy((path)["startsWith"]("."))) {
|
|
2176
|
+
return path;
|
|
2177
|
+
} else {
|
|
2178
|
+
return ("./" + path);
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
function session_rewrite_imports(nodes, item, aliases, host_modules) {
|
|
2186
|
+
return (nodes)["map"](((node) => {
|
|
2187
|
+
{
|
|
2188
|
+
const __eliscript_value_222 = (node)["kind"];
|
|
2189
|
+
{
|
|
2190
|
+
let kind = __eliscript_value_222;
|
|
2191
|
+
if ((kind === "module-declaration")) {
|
|
2192
|
+
return (globalThis.Object)["assign"](({}), node, ({"children": session_rewrite_imports((node)["children"], item, aliases, host_modules)}));
|
|
2193
|
+
} else {
|
|
2194
|
+
if ((kind === "import-declaration")) {
|
|
2195
|
+
{
|
|
2196
|
+
let specifier = (node)["value"];
|
|
2197
|
+
let id = (item)["id"];
|
|
2198
|
+
let filename = (item)["filename"];
|
|
2199
|
+
let target = null;
|
|
2200
|
+
if (__eliscript_truthy((specifier)["startsWith"]("."))) {
|
|
2201
|
+
{
|
|
2202
|
+
let parts = (filename)["split"]("/");
|
|
2203
|
+
let _directory = (parts)["pop"]();
|
|
2204
|
+
let resolved = session_normalize_path(((__eliscript_numeric_relation(">", ((parts) ?? []).length, 0) ? (__eliscript_at_direct(parts, "join", "/") + "/") : "") + specifier));
|
|
2205
|
+
((target = (aliases)["get"](resolved)));
|
|
2206
|
+
if ((!__eliscript_truthy(((__eliscript_value_223) => (__eliscript_truthy(__eliscript_value_223) ? __eliscript_value_223 : (host_modules)["some"](((declaration) => {
|
|
2207
|
+
return (((declaration)["referrer"] === id) && ((declaration)["specifier"] === specifier));
|
|
2208
|
+
}))))(target)))) {
|
|
2209
|
+
session_fail(("missing project source: " + specifier), filename);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
} else {
|
|
2213
|
+
((target = (aliases)["get"](specifier)));
|
|
2214
|
+
}
|
|
2215
|
+
if (__eliscript_truthy(target)) {
|
|
2216
|
+
return (globalThis.Object)["assign"](({}), node, ({"value": session_relative_import(id, target)}));
|
|
2217
|
+
} else {
|
|
2218
|
+
return node;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
} else {
|
|
2222
|
+
return node;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
}));
|
|
2228
|
+
}
|
|
2229
|
+
function session_project_modules(state, request) {
|
|
2230
|
+
{
|
|
2231
|
+
const __eliscript_value_224 = session_modules(state, request);
|
|
2232
|
+
{
|
|
2233
|
+
let modules = __eliscript_value_224;
|
|
2234
|
+
if (((!(((request)["resolveImports"] ?? false) === true)) && ((state)["projectPortablePlan"] === null))) {
|
|
2235
|
+
return modules;
|
|
2236
|
+
} else {
|
|
2237
|
+
{
|
|
2238
|
+
const __eliscript_value_225 = new (globalThis.Map)();
|
|
2239
|
+
{
|
|
2240
|
+
let aliases = __eliscript_value_225;
|
|
2241
|
+
(modules)["forEach"](((item) => {
|
|
2242
|
+
return ([(item)["id"], (item)["filename"]])["forEach"](((path) => {
|
|
2243
|
+
{
|
|
2244
|
+
let key = session_normalize_path(path);
|
|
2245
|
+
let existing = (aliases)["get"](key);
|
|
2246
|
+
if (__eliscript_truthy(((__eliscript_value_226) => (__eliscript_truthy(__eliscript_value_226) ? (!(existing === (item)["id"])) : __eliscript_value_226))(existing))) {
|
|
2247
|
+
session_fail("ambiguous project source identity", path);
|
|
2248
|
+
}
|
|
2249
|
+
return (aliases)["set"](key, (item)["id"]);
|
|
2250
|
+
}
|
|
2251
|
+
}));
|
|
2252
|
+
}));
|
|
2253
|
+
{
|
|
2254
|
+
const __eliscript_value_227 = ((request)["hostSources"] ?? []);
|
|
2255
|
+
{
|
|
2256
|
+
let providers = __eliscript_value_227;
|
|
2257
|
+
if ((!__eliscript_truthy(Array.isArray(providers)))) {
|
|
2258
|
+
session_fail("hostSources must be an array");
|
|
2259
|
+
}
|
|
2260
|
+
(providers)["forEach"](((item) => {
|
|
2261
|
+
{
|
|
2262
|
+
let id = session_normalize_path(session_string(item, "id", undefined));
|
|
2263
|
+
let filename = session_normalize_path(session_string(item, "filename", id));
|
|
2264
|
+
if (__eliscript_truthy(((__eliscript_value_228) => (__eliscript_truthy(__eliscript_value_228) ? __eliscript_value_228 : (aliases)["has"](filename)))((aliases)["has"](id)))) {
|
|
2265
|
+
session_fail("host source collides with a project source", id);
|
|
2266
|
+
}
|
|
2267
|
+
(aliases)["set"](id, id);
|
|
2268
|
+
return (aliases)["set"](filename, id);
|
|
2269
|
+
}
|
|
2270
|
+
}));
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
return (modules)["map"](((item) => {
|
|
2274
|
+
return (globalThis.Object)["assign"](({}), item, ({"program": (globalThis.Object)["assign"](({}), (item)["program"], ({"body": session_rewrite_imports(((item)["program"])["body"], item, aliases, ((request)["hostModules"] ?? []))}))}));
|
|
2275
|
+
}));
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
}
|
|
2282
|
+
function session_project_host_modules(modules, request) {
|
|
2283
|
+
{
|
|
2284
|
+
const __eliscript_value_229 = (((request)["hostModules"] ?? []))["map"](((item) => {
|
|
2285
|
+
return (globalThis.Object)["assign"](({}), item, ({"allowedExports": (((item)["allowedExports"] ?? []))["slice"]()}));
|
|
2286
|
+
}));
|
|
2287
|
+
const __eliscript_value_230 = new (globalThis.Map)();
|
|
2288
|
+
{
|
|
2289
|
+
let declarations = __eliscript_value_229;
|
|
2290
|
+
let providers = __eliscript_value_230;
|
|
2291
|
+
(((request)["hostSources"] ?? []))["forEach"](((item) => {
|
|
2292
|
+
return (providers)["set"](session_normalize_path((item)["id"]), item);
|
|
2293
|
+
}));
|
|
2294
|
+
(modules)["forEach"](((item) => {
|
|
2295
|
+
{
|
|
2296
|
+
const __eliscript_value_231 = (((item)["program"])["body"])["slice"]();
|
|
2297
|
+
{
|
|
2298
|
+
let pending = __eliscript_value_231;
|
|
2299
|
+
while (__eliscript_numeric_relation(">", ((pending) ?? []).length, 0)) {
|
|
2300
|
+
{
|
|
2301
|
+
let node = (pending)["shift"]();
|
|
2302
|
+
let kind = (node)["kind"];
|
|
2303
|
+
if ((kind === "module-declaration")) {
|
|
2304
|
+
((node)["children"])["forEach"](((child) => {
|
|
2305
|
+
return (pending)["push"](child);
|
|
2306
|
+
}));
|
|
2307
|
+
} else {
|
|
2308
|
+
if ((kind === "import-declaration")) {
|
|
2309
|
+
{
|
|
2310
|
+
let specifier = (node)["value"];
|
|
2311
|
+
let parts = ((item)["id"])["split"]("/");
|
|
2312
|
+
let _directory = (parts)["pop"]();
|
|
2313
|
+
let path = (__eliscript_truthy((specifier)["startsWith"](".")) ? session_normalize_path(((__eliscript_numeric_relation(">", ((parts) ?? []).length, 0) ? (__eliscript_at_direct(parts, "join", "/") + "/") : "") + specifier)) : null);
|
|
2314
|
+
if (__eliscript_truthy(((__eliscript_value_232) => (__eliscript_truthy(__eliscript_value_232) ? (providers)["has"](path) : __eliscript_value_232))(path))) {
|
|
2315
|
+
{
|
|
2316
|
+
const __eliscript_value_233 = (declarations)["find"](((value) => {
|
|
2317
|
+
return (((value)["referrer"] === (item)["id"]) && ((value)["specifier"] === specifier));
|
|
2318
|
+
}));
|
|
2319
|
+
{
|
|
2320
|
+
let existing = __eliscript_value_233;
|
|
2321
|
+
if (__eliscript_truthy(((__eliscript_value_234) => (__eliscript_truthy(__eliscript_value_234) ? (!((existing)["id"] === path)) : __eliscript_value_234))(existing))) {
|
|
2322
|
+
session_fail("host declaration conflicts with its source identity", specifier);
|
|
2323
|
+
}
|
|
2324
|
+
if ((!__eliscript_truthy(existing))) {
|
|
2325
|
+
((existing = ({"id": path, "specifier": specifier, "referrer": (item)["id"], "allowedExports": [], "namespace": false})));
|
|
2326
|
+
(declarations)["push"](existing);
|
|
2327
|
+
}
|
|
2328
|
+
((node)["children"])["forEach"](((binding) => {
|
|
2329
|
+
{
|
|
2330
|
+
const __eliscript_value_235 = (binding)["kind"];
|
|
2331
|
+
{
|
|
2332
|
+
let mode = __eliscript_value_235;
|
|
2333
|
+
if ((mode === "import-namespace")) {
|
|
2334
|
+
return ((existing)["namespace"] = true);
|
|
2335
|
+
} else {
|
|
2336
|
+
{
|
|
2337
|
+
const __eliscript_value_236 = ((mode === "import-default") ? "default" : binding_name((binding)["value"]));
|
|
2338
|
+
{
|
|
2339
|
+
let name = __eliscript_value_236;
|
|
2340
|
+
if ((!__eliscript_truthy(((existing)["allowedExports"])["includes"](name)))) {
|
|
2341
|
+
return ((existing)["allowedExports"])["push"](name);
|
|
2342
|
+
} else {
|
|
2343
|
+
return null;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
}));
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
} else {
|
|
2356
|
+
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
return null;
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2364
|
+
}));
|
|
2365
|
+
return declarations;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
function session_ordered_modules(modules) {
|
|
2370
|
+
return ((modules)["slice"]())["sort"](((left, right) => {
|
|
2371
|
+
{
|
|
2372
|
+
const __eliscript_value_237 = (left)["id"];
|
|
2373
|
+
const __eliscript_value_238 = (right)["id"];
|
|
2374
|
+
{
|
|
2375
|
+
let a = __eliscript_value_237;
|
|
2376
|
+
let b = __eliscript_value_238;
|
|
2377
|
+
if (__eliscript_numeric_relation("<", a, b)) {
|
|
2378
|
+
return -1;
|
|
2379
|
+
} else {
|
|
2380
|
+
if (__eliscript_numeric_relation(">", a, b)) {
|
|
2381
|
+
return 1;
|
|
2382
|
+
} else {
|
|
2383
|
+
return 0;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
}));
|
|
2389
|
+
}
|
|
2390
|
+
function session_javascript_project(modules, request) {
|
|
2391
|
+
{
|
|
2392
|
+
const __eliscript_value_239 = session_ordered_modules(modules);
|
|
2393
|
+
const __eliscript_value_240 = [];
|
|
2394
|
+
const __eliscript_value_241 = 0;
|
|
2395
|
+
const __eliscript_value_242 = ((request)["sourceMap"] ?? false);
|
|
2396
|
+
{
|
|
2397
|
+
let modules = __eliscript_value_239;
|
|
2398
|
+
let outputs = __eliscript_value_240;
|
|
2399
|
+
let index = __eliscript_value_241;
|
|
2400
|
+
let mapping = __eliscript_value_242;
|
|
2401
|
+
while (__eliscript_numeric_relation("<", index, ((modules) ?? []).length)) {
|
|
2402
|
+
{
|
|
2403
|
+
let item = ((((modules) ?? [])[index]) ?? null);
|
|
2404
|
+
let id = (item)["id"];
|
|
2405
|
+
let filename = (item)["filename"];
|
|
2406
|
+
let artifact = (__eliscript_truthy(mapping) ? emit_ir_string_with_source_map((item)["program"], (item)["source"], id, filename) : ({"javascript": emit_ir_string((item)["program"])}));
|
|
2407
|
+
((artifact)["id"] = id);
|
|
2408
|
+
((artifact)["filename"] = filename);
|
|
2409
|
+
if (__eliscript_numeric_relation(">", ((((item)["portableEntries"] ?? [])) ?? []).length, 0)) {
|
|
2410
|
+
((artifact)["portableEntries"] = ((item)["portableEntries"])["slice"]());
|
|
2411
|
+
}
|
|
2412
|
+
if ((((request)["debug"] ?? false) === true)) {
|
|
2413
|
+
((artifact)["macroOrigins"] = ((item)["macroOrigins"] ?? []));
|
|
2414
|
+
}
|
|
2415
|
+
(outputs)["push"](artifact);
|
|
2416
|
+
}
|
|
2417
|
+
((index = (index + 1)));
|
|
2418
|
+
}
|
|
2419
|
+
return ({"target": "javascript", "entry": (request)["entry"], "modules": outputs});
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
function session_resolve_import(importer, specifier, ids) {
|
|
2424
|
+
if (__eliscript_truthy((ids)["has"](specifier))) {
|
|
2425
|
+
return specifier;
|
|
2426
|
+
} else {
|
|
2427
|
+
if (__eliscript_truthy((specifier)["startsWith"]("."))) {
|
|
2428
|
+
{
|
|
2429
|
+
let parts = (importer)["split"]("/");
|
|
2430
|
+
let pending = (specifier)["split"]("/");
|
|
2431
|
+
let index = 0;
|
|
2432
|
+
(parts)["pop"]();
|
|
2433
|
+
while (__eliscript_numeric_relation("<", index, ((pending) ?? []).length)) {
|
|
2434
|
+
{
|
|
2435
|
+
const __eliscript_value_243 = ((((pending) ?? [])[index]) ?? null);
|
|
2436
|
+
{
|
|
2437
|
+
let part = __eliscript_value_243;
|
|
2438
|
+
if (((part === "") || (part === "."))) {
|
|
2439
|
+
null;
|
|
2440
|
+
} else {
|
|
2441
|
+
if ((part === "..")) {
|
|
2442
|
+
if ((((parts) ?? []).length === 0)) {
|
|
2443
|
+
session_fail("relative project import escapes its virtual root", importer);
|
|
2444
|
+
}
|
|
2445
|
+
(parts)["pop"]();
|
|
2446
|
+
} else {
|
|
2447
|
+
(parts)["push"](part);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
}
|
|
2452
|
+
((index = (index + 1)));
|
|
2453
|
+
}
|
|
2454
|
+
{
|
|
2455
|
+
const __eliscript_value_244 = __eliscript_at_direct(parts, "join", "/");
|
|
2456
|
+
{
|
|
2457
|
+
let resolved = __eliscript_value_244;
|
|
2458
|
+
if ((!__eliscript_truthy((ids)["has"](resolved)))) {
|
|
2459
|
+
session_fail(("missing virtual project module: " + resolved), importer);
|
|
2460
|
+
}
|
|
2461
|
+
return resolved;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
} else {
|
|
2466
|
+
return null;
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
function session_module_imports(nodes, importer, ids, dependencies, external, host_modules) {
|
|
2471
|
+
{
|
|
2472
|
+
const __eliscript_value_245 = 0;
|
|
2473
|
+
{
|
|
2474
|
+
let index = __eliscript_value_245;
|
|
2475
|
+
while (__eliscript_numeric_relation("<", index, ((nodes) ?? []).length)) {
|
|
2476
|
+
{
|
|
2477
|
+
let node = ((((nodes) ?? [])[index]) ?? null);
|
|
2478
|
+
let kind = (node)["kind"];
|
|
2479
|
+
if ((kind === "import-declaration")) {
|
|
2480
|
+
{
|
|
2481
|
+
let specifier = (node)["value"];
|
|
2482
|
+
let provider = (host_modules)["find"](((item) => {
|
|
2483
|
+
return (((item)["referrer"] === importer) && ((item)["specifier"] === specifier));
|
|
2484
|
+
}));
|
|
2485
|
+
if (__eliscript_truthy(provider)) {
|
|
2486
|
+
if (__eliscript_truthy((specifier)["startsWith"]("."))) {
|
|
2487
|
+
{
|
|
2488
|
+
const __eliscript_value_246 = (importer)["split"]("/");
|
|
2489
|
+
{
|
|
2490
|
+
let parts = __eliscript_value_246;
|
|
2491
|
+
(parts)["pop"]();
|
|
2492
|
+
session_normalize_path(((__eliscript_numeric_relation(">", ((parts) ?? []).length, 0) ? (__eliscript_at_direct(parts, "join", "/") + "/") : "") + specifier));
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
(external)["add"]((provider)["id"]);
|
|
2497
|
+
} else {
|
|
2498
|
+
{
|
|
2499
|
+
const __eliscript_value_247 = session_resolve_import(importer, specifier, ids);
|
|
2500
|
+
{
|
|
2501
|
+
let resolved = __eliscript_value_247;
|
|
2502
|
+
if ((resolved === null)) {
|
|
2503
|
+
(external)["add"](specifier);
|
|
2504
|
+
} else {
|
|
2505
|
+
(dependencies)["add"](resolved);
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
} else {
|
|
2512
|
+
if ((kind === "module-declaration")) {
|
|
2513
|
+
session_module_imports((node)["children"], importer, ids, dependencies, external, host_modules);
|
|
2514
|
+
} else {
|
|
2515
|
+
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
((index = (index + 1)));
|
|
2520
|
+
}
|
|
2521
|
+
return null;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
function session_project_transaction(state, operation) {
|
|
2526
|
+
{
|
|
2527
|
+
const __eliscript_value_248 = (state)["projectKey"];
|
|
2528
|
+
const __eliscript_value_249 = (state)["projectModules"];
|
|
2529
|
+
const __eliscript_value_250 = (state)["projectPortablePlan"];
|
|
2530
|
+
const __eliscript_value_251 = (state)["projectRevision"];
|
|
2531
|
+
const __eliscript_value_252 = (state)["moduleCache"];
|
|
2532
|
+
const __eliscript_value_253 = (state)["literalSources"];
|
|
2533
|
+
const __eliscript_value_254 = (state)["literalModules"];
|
|
2534
|
+
const __eliscript_value_255 = (state)["literalKey"];
|
|
2535
|
+
const __eliscript_value_256 = (state)["literalCache"];
|
|
2536
|
+
const __eliscript_value_257 = (state)["literalRevision"];
|
|
2537
|
+
{
|
|
2538
|
+
let key = __eliscript_value_248;
|
|
2539
|
+
let modules = __eliscript_value_249;
|
|
2540
|
+
let portable = __eliscript_value_250;
|
|
2541
|
+
let revision = __eliscript_value_251;
|
|
2542
|
+
let cache = __eliscript_value_252;
|
|
2543
|
+
let literal_sources = __eliscript_value_253;
|
|
2544
|
+
let literal_modules = __eliscript_value_254;
|
|
2545
|
+
let literal_key = __eliscript_value_255;
|
|
2546
|
+
let literal_cache = __eliscript_value_256;
|
|
2547
|
+
let literal_revision = __eliscript_value_257;
|
|
2548
|
+
return (() => {
|
|
2549
|
+
try {
|
|
2550
|
+
return operation();
|
|
2551
|
+
} catch (error) {
|
|
2552
|
+
((state)["projectKey"] = key);
|
|
2553
|
+
((state)["projectModules"] = modules);
|
|
2554
|
+
((state)["projectPortablePlan"] = portable);
|
|
2555
|
+
((state)["projectRevision"] = revision);
|
|
2556
|
+
((state)["moduleCache"] = cache);
|
|
2557
|
+
((state)["literalSources"] = literal_sources);
|
|
2558
|
+
((state)["literalModules"] = literal_modules);
|
|
2559
|
+
((state)["literalKey"] = literal_key);
|
|
2560
|
+
((state)["literalCache"] = literal_cache);
|
|
2561
|
+
((state)["literalRevision"] = literal_revision);
|
|
2562
|
+
return ((__eliscript_value_258) => { throw __eliscript_value_258; })(error);
|
|
2563
|
+
}
|
|
2564
|
+
})();
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
function session_project_plan(state, request) {
|
|
2569
|
+
return session_project_transaction(state, (() => {
|
|
2570
|
+
return session_project_plan_body(state, request);
|
|
2571
|
+
}));
|
|
2572
|
+
}
|
|
2573
|
+
function session_project_plan_body(state, request) {
|
|
2574
|
+
{
|
|
2575
|
+
const __eliscript_value_259 = session_project_modules(state, request);
|
|
2576
|
+
const __eliscript_value_260 = new (globalThis.Map)();
|
|
2577
|
+
const __eliscript_value_261 = new (globalThis.Set)();
|
|
2578
|
+
{
|
|
2579
|
+
let modules = __eliscript_value_259;
|
|
2580
|
+
let ids = __eliscript_value_260;
|
|
2581
|
+
let external = __eliscript_value_261;
|
|
2582
|
+
(modules)["forEach"](((item) => {
|
|
2583
|
+
return (ids)["set"]((item)["id"], item);
|
|
2584
|
+
}));
|
|
2585
|
+
{
|
|
2586
|
+
let host_modules = session_project_host_modules(modules, request);
|
|
2587
|
+
let entries = ((request)["entries"] ?? [(request)["entry"]]);
|
|
2588
|
+
let plan = ((__eliscript_value_262) => (__eliscript_truthy(__eliscript_value_262) ? __eliscript_value_262 : project_plan(entries, ((id) => {
|
|
2589
|
+
if ((!__eliscript_truthy((ids)["has"](id)))) {
|
|
2590
|
+
session_fail("project entry is absent from modules", id);
|
|
2591
|
+
}
|
|
2592
|
+
{
|
|
2593
|
+
const __eliscript_value_263 = new (globalThis.Set)();
|
|
2594
|
+
{
|
|
2595
|
+
let dependencies = __eliscript_value_263;
|
|
2596
|
+
session_module_imports((((ids)["get"](id))["program"])["body"], id, ids, dependencies, external, host_modules);
|
|
2597
|
+
return (Array.from(dependencies))["sort"]();
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
}))))((state)["projectPortablePlan"]);
|
|
2601
|
+
let result = (globalThis.Object)["assign"](({}), plan);
|
|
2602
|
+
((result)["external"] = (Array.from(external))["sort"]());
|
|
2603
|
+
return result;
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
function session_debug_sources(state, modules) {
|
|
2609
|
+
{
|
|
2610
|
+
const __eliscript_value_264 = (modules)["map"](((item) => {
|
|
2611
|
+
return ({"id": (item)["id"], "filename": (item)["filename"], "macroOrigins": ((item)["macroOrigins"] ?? [])});
|
|
2612
|
+
}));
|
|
2613
|
+
{
|
|
2614
|
+
let sources = __eliscript_value_264;
|
|
2615
|
+
(sources)["push"](({"id": "runtime", "filename": (state)["runtimeFilename"], "macroOrigins": []}));
|
|
2616
|
+
return sources;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
function session_binary_project(state, modules, request, target) {
|
|
2621
|
+
{
|
|
2622
|
+
const __eliscript_value_265 = (state)["runtime"];
|
|
2623
|
+
const __eliscript_value_266 = session_ordered_modules(modules);
|
|
2624
|
+
{
|
|
2625
|
+
let runtime = __eliscript_value_265;
|
|
2626
|
+
let modules = __eliscript_value_266;
|
|
2627
|
+
if ((runtime === null)) {
|
|
2628
|
+
session_fail("binary emission requires an initialized runtime");
|
|
2629
|
+
}
|
|
2630
|
+
{
|
|
2631
|
+
let entry = session_string(request, "entry", undefined);
|
|
2632
|
+
let records = (modules)["map"](((item) => {
|
|
2633
|
+
return ({"id": (item)["id"], "program": (item)["program"]});
|
|
2634
|
+
}));
|
|
2635
|
+
let _observed = session_phase(state, "managed-lower-start", ((records) ?? []).length);
|
|
2636
|
+
let lowered = session_backend_emission(entry, (() => {
|
|
2637
|
+
{
|
|
2638
|
+
const __eliscript_value_267 = ({"hostModules": session_project_host_modules(modules, request), "literalModules": ((state)["literalModules"] ?? null), "phased": (((request)["phased"] ?? false) === true)});
|
|
2639
|
+
{
|
|
2640
|
+
let options = __eliscript_value_267;
|
|
2641
|
+
if (__eliscript_truthy((state)["projectPortablePlan"])) {
|
|
2642
|
+
{
|
|
2643
|
+
const __eliscript_value_268 = new (globalThis.Set)();
|
|
2644
|
+
{
|
|
2645
|
+
let roots = __eliscript_value_268;
|
|
2646
|
+
(((state)["projectPortablePlan"])["entries"])["forEach"](((item) => {
|
|
2647
|
+
return (roots)["add"]((item)["id"]);
|
|
2648
|
+
}));
|
|
2649
|
+
((options)["entries"] = Array.from(roots));
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
} else {
|
|
2653
|
+
if (__eliscript_truthy(Object.hasOwn(request, "entries"))) {
|
|
2654
|
+
((options)["entries"] = (request)["entries"]);
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
if (__eliscript_truthy(Object.hasOwn(request, "foreignEntry"))) {
|
|
2658
|
+
{
|
|
2659
|
+
const __eliscript_value_269 = (request)["foreignEntry"];
|
|
2660
|
+
{
|
|
2661
|
+
let foreign_entry = __eliscript_value_269;
|
|
2662
|
+
if ((!(((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(foreign_entry) === "boolean"))) {
|
|
2663
|
+
session_fail("foreignEntry must be a boolean");
|
|
2664
|
+
}
|
|
2665
|
+
((options)["foreignEntry"] = foreign_entry);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
}
|
|
2669
|
+
if ((target === "wasm")) {
|
|
2670
|
+
return emit_managed_project_wasm_product(records, entry, runtime, options, (() => {
|
|
2671
|
+
session_phase(state, "managed-lower-complete", ((records) ?? []).length);
|
|
2672
|
+
session_phase(state, "wasm-emit-start", 0);
|
|
2673
|
+
return session_wasm_configuration(request);
|
|
2674
|
+
}));
|
|
2675
|
+
} else {
|
|
2676
|
+
return lower_managed_project(records, entry, runtime, options);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
}));
|
|
2681
|
+
session_phase(state, ((target === "wasm") ? "wasm-emit-complete" : "managed-lower-complete"), 0);
|
|
2682
|
+
if ((target === "native")) {
|
|
2683
|
+
((lowered = ({"typed": (lowered)["typed"], "descriptor": (lowered)["descriptor"]})));
|
|
2684
|
+
}
|
|
2685
|
+
return session_lowered_output(state, modules, request, target, lowered);
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
function session_wasm_configuration(request) {
|
|
2691
|
+
{
|
|
2692
|
+
const __eliscript_value_270 = ((request)["memory"] ?? null);
|
|
2693
|
+
{
|
|
2694
|
+
let memory = __eliscript_value_270;
|
|
2695
|
+
if ((!__eliscript_truthy(((__eliscript_value_271) => (__eliscript_truthy(__eliscript_value_271) ? __eliscript_value_271 : session_object_p(memory)))((memory === null))))) {
|
|
2696
|
+
session_fail("memory must be an object");
|
|
2697
|
+
}
|
|
2698
|
+
((memory = ((__eliscript_value_272) => (__eliscript_truthy(__eliscript_value_272) ? __eliscript_value_272 : ({})))(memory)));
|
|
2699
|
+
if (__eliscript_truthy((globalThis.Object)["hasOwn"](request, "binaryEncoding"))) {
|
|
2700
|
+
((memory = (globalThis.Object)["assign"](({}), memory)));
|
|
2701
|
+
((memory)["binaryEncoding"] = (request)["binaryEncoding"]);
|
|
2702
|
+
}
|
|
2703
|
+
return ({"memory": memory, "debug": (((request)["debug"] ?? false) === true)});
|
|
2704
|
+
}
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
function session_lowered_output(state, modules, request, target, lowered) {
|
|
2708
|
+
{
|
|
2709
|
+
const __eliscript_value_273 = ((request)["entry"] ?? undefined);
|
|
2710
|
+
const __eliscript_value_274 = (lowered)["typed"];
|
|
2711
|
+
const __eliscript_value_275 = (lowered)["descriptor"];
|
|
2712
|
+
{
|
|
2713
|
+
let entry = __eliscript_value_273;
|
|
2714
|
+
let typed = __eliscript_value_274;
|
|
2715
|
+
let descriptor = __eliscript_value_275;
|
|
2716
|
+
if ((target === "wasm")) {
|
|
2717
|
+
{
|
|
2718
|
+
let bytes = (lowered)["bytes"];
|
|
2719
|
+
let mapping = ((lowered)["debug"] ?? null);
|
|
2720
|
+
let debug = (__eliscript_truthy(mapping) ? (globalThis.Object)["assign"](({}), mapping, ({"moduleByteLength": (__eliscript_truthy(Array.isArray(bytes)) ? ((bytes) ?? []).length : (bytes)["byteLength"]), "sources": session_debug_sources(state, modules)})) : null);
|
|
2721
|
+
return ({"target": target, "entry": entry, "descriptor": descriptor, "bytes": bytes, "debug": debug});
|
|
2722
|
+
}
|
|
2723
|
+
} else {
|
|
2724
|
+
{
|
|
2725
|
+
let platform = session_string(request, "nativeTarget", undefined);
|
|
2726
|
+
let kind = session_string(request, "nativeFormat", "library");
|
|
2727
|
+
if ((!((kind === "library") || (kind === "object")))) {
|
|
2728
|
+
session_fail("managed nativeFormat must be library or object");
|
|
2729
|
+
}
|
|
2730
|
+
{
|
|
2731
|
+
let observer = session_native_observer(state);
|
|
2732
|
+
let artifact = ((((request)["debug"] ?? false) === true) ? emit_fresh_observed_typed_native_memory_artifact(typed, platform, session_binary_options(request, kind), observer) : null);
|
|
2733
|
+
return ({"target": target, "nativeTarget": platform, "nativeFormat": kind, "entry": entry, "descriptor": descriptor, "typed": typed, "debug": (__eliscript_truthy(artifact) ? (globalThis.Object)["assign"](({}), (artifact)["debug"], ({"sources": session_debug_sources(state, modules)})) : null), "bytes": (__eliscript_truthy(artifact) ? (artifact)["bytes"] : ((kind === "object") ? emit_fresh_observed_typed_native_memory_object(typed, platform, session_binary_options(request, kind), observer) : emit_fresh_observed_typed_native_memory_library(typed, platform, session_binary_options(request, kind), observer)))});
|
|
2734
|
+
}
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
}
|
|
2740
|
+
function session_project(state, request) {
|
|
2741
|
+
return session_project_transaction(state, (() => {
|
|
2742
|
+
return session_project_body(state, request);
|
|
2743
|
+
}));
|
|
2744
|
+
}
|
|
2745
|
+
function session_project_body(state, request) {
|
|
2746
|
+
{
|
|
2747
|
+
const __eliscript_value_276 = session_string(request, "target", undefined);
|
|
2748
|
+
const __eliscript_value_277 = session_string(request, "entry", undefined);
|
|
2749
|
+
{
|
|
2750
|
+
let target = __eliscript_value_276;
|
|
2751
|
+
let entry = __eliscript_value_277;
|
|
2752
|
+
if ((!((target === "javascript") || (target === "wasm") || (target === "native")))) {
|
|
2753
|
+
session_fail("target must be javascript, wasm or native");
|
|
2754
|
+
}
|
|
2755
|
+
if (__eliscript_truthy((globalThis.Object)["hasOwn"](request, "literalSources"))) {
|
|
2756
|
+
session_publish_literals(state, session_literal_modules(state, request));
|
|
2757
|
+
}
|
|
2758
|
+
{
|
|
2759
|
+
const __eliscript_value_278 = session_project_modules(state, request);
|
|
2760
|
+
const __eliscript_value_279 = false;
|
|
2761
|
+
{
|
|
2762
|
+
let modules = __eliscript_value_278;
|
|
2763
|
+
let found = __eliscript_value_279;
|
|
2764
|
+
(modules)["forEach"](((item) => {
|
|
2765
|
+
if (((item)["id"] === entry)) {
|
|
2766
|
+
return ((found = true));
|
|
2767
|
+
} else {
|
|
2768
|
+
return null;
|
|
2769
|
+
}
|
|
2770
|
+
}));
|
|
2771
|
+
if ((!__eliscript_truthy(found))) {
|
|
2772
|
+
session_fail("project entry is absent from modules", entry);
|
|
2773
|
+
}
|
|
2774
|
+
{
|
|
2775
|
+
const __eliscript_value_280 = ((target === "javascript") ? session_javascript_project(modules, request) : session_binary_project(state, modules, request, target));
|
|
2776
|
+
{
|
|
2777
|
+
let result = __eliscript_value_280;
|
|
2778
|
+
((result)["revision"] = (state)["projectRevision"]);
|
|
2779
|
+
if (__eliscript_numeric_relation(">", ((((state)["literalModules"] ?? [])) ?? []).length, 0)) {
|
|
2780
|
+
((result)["literalRevision"] = (state)["literalRevision"]);
|
|
2781
|
+
}
|
|
2782
|
+
if (__eliscript_truthy((state)["projectPortablePlan"])) {
|
|
2783
|
+
((result)["plan"] = (state)["projectPortablePlan"]);
|
|
2784
|
+
}
|
|
2785
|
+
return result;
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
function session_request_result(state, request, operation) {
|
|
2794
|
+
if ((operation === "runtime")) {
|
|
2795
|
+
return session_runtime(state, request);
|
|
2796
|
+
} else {
|
|
2797
|
+
if ((operation === "compile")) {
|
|
2798
|
+
return session_compile(request, false);
|
|
2799
|
+
} else {
|
|
2800
|
+
if ((operation === "compile-ir")) {
|
|
2801
|
+
return session_compile(request, true);
|
|
2802
|
+
} else {
|
|
2803
|
+
if ((operation === "stage")) {
|
|
2804
|
+
return session_stage(request);
|
|
2805
|
+
} else {
|
|
2806
|
+
if ((operation === "cached-ir")) {
|
|
2807
|
+
return session_cached_ir(state, request);
|
|
2808
|
+
} else {
|
|
2809
|
+
if (((operation === "emit-ir") || (operation === "serialize-ir") || (operation === "deserialize-ir"))) {
|
|
2810
|
+
return session_ir_operation(state, request, operation);
|
|
2811
|
+
} else {
|
|
2812
|
+
if ((operation === "protocol")) {
|
|
2813
|
+
return session_protocol(request);
|
|
2814
|
+
} else {
|
|
2815
|
+
if ((operation === "project")) {
|
|
2816
|
+
return session_project(state, request);
|
|
2817
|
+
} else {
|
|
2818
|
+
if ((operation === "project-ir")) {
|
|
2819
|
+
return session_project_ir(state, request);
|
|
2820
|
+
} else {
|
|
2821
|
+
if (((operation === "emit-memory-ir") || (operation === "emit-typed-memory"))) {
|
|
2822
|
+
return session_memory_ir(request, operation);
|
|
2823
|
+
} else {
|
|
2824
|
+
if ((operation === "project-plan")) {
|
|
2825
|
+
return session_project_plan(state, request);
|
|
2826
|
+
} else {
|
|
2827
|
+
if (((operation === "analyze") || (operation === "query") || (operation === "edit-preview"))) {
|
|
2828
|
+
return tools_request((globalThis.Object)["assign"](({}), request, ({"macroContext": session_macro_context(((request)["macroContext"] ?? null))})));
|
|
2829
|
+
} else {
|
|
2830
|
+
if ((operation === "format")) {
|
|
2831
|
+
return ({"source": format_source(session_string(request, "source", undefined), session_string(request, "filename", "<input>"), ((request)["options"] ?? null))});
|
|
2832
|
+
} else {
|
|
2833
|
+
if ((operation === "capabilities")) {
|
|
2834
|
+
return ({"format": "eliscript-compiler-capabilities", "version": 1, "operations": ["runtime", "compile", "compile-ir", "stage", "cached-ir", "emit-ir", "serialize-ir", "deserialize-ir", "protocol", "project", "project-ir", "emit-memory-ir", "emit-typed-memory", "project-plan", "format", "analyze", "query", "edit-preview", "response-next", "response-close"], "responseModes": ["events-v1", "graph-events-v1"], "responseStringChunks": true, "targets": ["javascript", "wasm", "native"], "nativeTargets": ["arm64-macos", "arm64-linux"], "memoryIRTargets": ["wasm", "native"]});
|
|
2835
|
+
} else {
|
|
2836
|
+
return session_fail(("unknown compiler operation: " + operation));
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
}
|
|
2852
|
+
function compiler_session_request(state, request_json) {
|
|
2853
|
+
session_live(state);
|
|
2854
|
+
return (() => {
|
|
2855
|
+
try {
|
|
2856
|
+
if ((!(((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(request_json) === "string"))) {
|
|
2857
|
+
session_fail("compiler request must be a JSON string");
|
|
2858
|
+
}
|
|
2859
|
+
{
|
|
2860
|
+
const __eliscript_value_281 = JSON.parse(request_json);
|
|
2861
|
+
{
|
|
2862
|
+
let request = __eliscript_value_281;
|
|
2863
|
+
if ((!__eliscript_truthy(session_object_p(request)))) {
|
|
2864
|
+
session_fail("compiler request must be an object");
|
|
2865
|
+
}
|
|
2866
|
+
{
|
|
2867
|
+
let operation = session_string(request, "operation", undefined);
|
|
2868
|
+
let control = ((operation === "response-next") || (operation === "response-close"));
|
|
2869
|
+
let result = (__eliscript_truthy(control) ? session_response_control(state, request, operation) : (() => {
|
|
2870
|
+
if (__eliscript_truthy(((state)["responseCursor"] ?? null))) {
|
|
2871
|
+
session_fail("compiler response is pending; use response-next or response-close");
|
|
2872
|
+
}
|
|
2873
|
+
{
|
|
2874
|
+
const __eliscript_value_282 = (request)["responseMode"];
|
|
2875
|
+
{
|
|
2876
|
+
let mode = __eliscript_value_282;
|
|
2877
|
+
if ((!((mode === undefined) || (mode === "events-v1") || (mode === "graph-events-v1")))) {
|
|
2878
|
+
session_fail("unsupported compiler responseMode");
|
|
2879
|
+
}
|
|
2880
|
+
{
|
|
2881
|
+
const __eliscript_value_283 = (request)["responseStringChunks"];
|
|
2882
|
+
{
|
|
2883
|
+
let chunks = __eliscript_value_283;
|
|
2884
|
+
if ((!((chunks === undefined) || (chunks === true) || (chunks === false)))) {
|
|
2885
|
+
session_fail("responseStringChunks must be a boolean");
|
|
2886
|
+
}
|
|
2887
|
+
if (((chunks === true) && (mode === undefined))) {
|
|
2888
|
+
session_fail("responseStringChunks requires an event responseMode");
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
{
|
|
2893
|
+
const __eliscript_value_284 = session_request_result(state, request, operation);
|
|
2894
|
+
{
|
|
2895
|
+
let value = __eliscript_value_284;
|
|
2896
|
+
if (((mode === "events-v1") || (mode === "graph-events-v1"))) {
|
|
2897
|
+
return session_response_start(state, value, mode, undefined, ((request)["responseStringChunks"] ?? false));
|
|
2898
|
+
} else {
|
|
2899
|
+
return value;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
})());
|
|
2906
|
+
if ((!__eliscript_truthy(control))) {
|
|
2907
|
+
session_phase(state, "response-serialize-start", 0);
|
|
2908
|
+
}
|
|
2909
|
+
{
|
|
2910
|
+
const __eliscript_value_285 = session_ir_wire(result, new (globalThis.Set)());
|
|
2911
|
+
{
|
|
2912
|
+
let text = __eliscript_value_285;
|
|
2913
|
+
if ((!__eliscript_truthy(control))) {
|
|
2914
|
+
session_phase(state, "response-serialize-complete", ((text) ?? []).length);
|
|
2915
|
+
}
|
|
2916
|
+
return text;
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
} catch (error) {
|
|
2923
|
+
(() => {
|
|
2924
|
+
try {
|
|
2925
|
+
return session_response_clear(state);
|
|
2926
|
+
} catch (cleanup) {
|
|
2927
|
+
return null;
|
|
2928
|
+
}
|
|
2929
|
+
})();
|
|
2930
|
+
return ((__eliscript_value_286) => { throw __eliscript_value_286; })(error);
|
|
2931
|
+
}
|
|
2932
|
+
})();
|
|
2933
|
+
}
|
|
2934
|
+
function compiler_session_project_owned(wire_request, state, request_json) {
|
|
2935
|
+
if ((!(wire_request === compiler_session_request))) {
|
|
2936
|
+
return null;
|
|
2937
|
+
} else {
|
|
2938
|
+
session_live(state);
|
|
2939
|
+
return (() => {
|
|
2940
|
+
try {
|
|
2941
|
+
if ((!(((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(request_json) === "string"))) {
|
|
2942
|
+
session_fail("compiler request must be a JSON string");
|
|
2943
|
+
}
|
|
2944
|
+
{
|
|
2945
|
+
const __eliscript_value_287 = JSON.parse(request_json);
|
|
2946
|
+
{
|
|
2947
|
+
let request = __eliscript_value_287;
|
|
2948
|
+
if ((!__eliscript_truthy(session_object_p(request)))) {
|
|
2949
|
+
session_fail("compiler request must be an object");
|
|
2950
|
+
}
|
|
2951
|
+
{
|
|
2952
|
+
const __eliscript_value_288 = session_string(request, "operation", undefined);
|
|
2953
|
+
{
|
|
2954
|
+
let operation = __eliscript_value_288;
|
|
2955
|
+
if (((operation === "project") && (((request)["target"] === "wasm") || ((request)["target"] === "native")) && (!__eliscript_truthy(Object.hasOwn(request, "responseMode"))))) {
|
|
2956
|
+
if (__eliscript_truthy(((state)["responseCursor"] ?? null))) {
|
|
2957
|
+
session_fail("compiler response is pending; use response-next or response-close");
|
|
2958
|
+
}
|
|
2959
|
+
return ({"format": "eliscript-compiler-owned-project", "version": 1, "value": session_project(state, request)});
|
|
2960
|
+
} else {
|
|
2961
|
+
return null;
|
|
2962
|
+
}
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
} catch (error) {
|
|
2968
|
+
(() => {
|
|
2969
|
+
try {
|
|
2970
|
+
return session_response_clear(state);
|
|
2971
|
+
} catch (cleanup) {
|
|
2972
|
+
return null;
|
|
2973
|
+
}
|
|
2974
|
+
})();
|
|
2975
|
+
return ((__eliscript_value_289) => { throw __eliscript_value_289; })(error);
|
|
2976
|
+
}
|
|
2977
|
+
})();
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
export {compiler_session_new, compiler_session_request, compiler_session_close, compiler_session_project_owned};
|