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,2258 @@
|
|
|
1
|
+
// Generated by Eliscript. Do not edit.
|
|
2
|
+
import "eliscript/runtime/unicode-case.mjs";
|
|
3
|
+
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
4
|
+
const __eliscript_number_intrinsic = globalThis.Number;
|
|
5
|
+
const __eliscript_bigint_intrinsic = globalThis.BigInt;
|
|
6
|
+
const __eliscript_numeric_apply = globalThis.Reflect.apply;
|
|
7
|
+
const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
|
|
8
|
+
const __eliscript_numeric_error = globalThis.TypeError;
|
|
9
|
+
const __eliscript_numeric_trim = globalThis.String.prototype.trim;
|
|
10
|
+
const __eliscript_numeric_slice = globalThis.String.prototype.slice;
|
|
11
|
+
const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
|
|
12
|
+
const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
|
|
13
|
+
const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
|
|
14
|
+
const __eliscript_numeric_primitive = (value) => {
|
|
15
|
+
if (!__eliscript_numeric_object(value)) return value;
|
|
16
|
+
const exotic = value[__eliscript_numeric_symbol];
|
|
17
|
+
if (exotic !== void 0 && exotic !== null) {
|
|
18
|
+
const result = __eliscript_numeric_apply(exotic, value, ["number"]);
|
|
19
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
20
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
21
|
+
}
|
|
22
|
+
for (let index = 0; index < 2; index++) {
|
|
23
|
+
const method = value[index === 0 ? "valueOf" : "toString"];
|
|
24
|
+
if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
|
|
25
|
+
const result = __eliscript_numeric_apply(method, value, []);
|
|
26
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
30
|
+
};
|
|
31
|
+
const __eliscript_to_number = (value) => {
|
|
32
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
33
|
+
if (typeof primitive === "string") {
|
|
34
|
+
const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
|
|
35
|
+
if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
|
|
36
|
+
let first = 2;
|
|
37
|
+
while (first < text.length && text[first] === "0") first++;
|
|
38
|
+
if (first === text.length) return 0;
|
|
39
|
+
const prefix = text[1];
|
|
40
|
+
const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
|
|
41
|
+
if (text.length - first > limit) return 1 / 0;
|
|
42
|
+
const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
|
|
43
|
+
return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return __eliscript_number_intrinsic(primitive);
|
|
47
|
+
};
|
|
48
|
+
const __eliscript_numeric = (value) => {
|
|
49
|
+
if (typeof value === "number" || typeof value === "bigint") return value;
|
|
50
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
51
|
+
if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
|
|
52
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
53
|
+
};
|
|
54
|
+
const __eliscript_implicit_number = (value) => {
|
|
55
|
+
if (typeof value === "number") return value;
|
|
56
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
57
|
+
if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
|
|
58
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
59
|
+
};
|
|
60
|
+
const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
|
|
61
|
+
const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
|
|
62
|
+
const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
|
|
63
|
+
const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
|
|
64
|
+
const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
|
|
65
|
+
const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
|
|
66
|
+
const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
|
|
67
|
+
const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
|
|
68
|
+
const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
|
|
69
|
+
const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
|
|
70
|
+
const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
|
|
71
|
+
const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
|
|
72
|
+
const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
|
|
73
|
+
const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
|
|
74
|
+
const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
|
|
75
|
+
const __eliscript_numeric_relation = (operator, left, right) => {
|
|
76
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
77
|
+
if (operator === "<") return left < right;
|
|
78
|
+
if (operator === "<=") return left <= right;
|
|
79
|
+
if (operator === ">") return left > right;
|
|
80
|
+
return left >= right;
|
|
81
|
+
}
|
|
82
|
+
let a = __eliscript_numeric_primitive(left);
|
|
83
|
+
let b = __eliscript_numeric_primitive(right);
|
|
84
|
+
const x = typeof a, y = typeof b;
|
|
85
|
+
if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
|
|
86
|
+
a = __eliscript_numeric(a);
|
|
87
|
+
b = __eliscript_numeric(b);
|
|
88
|
+
}
|
|
89
|
+
if (operator === "<") return a < b;
|
|
90
|
+
if (operator === "<=") return a <= b;
|
|
91
|
+
if (operator === ">") return a > b;
|
|
92
|
+
return a >= b;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
import {optimize_program} from "./optimize.mjs";
|
|
96
|
+
import {lower_numeric_program, optimize_numeric_program, numeric_pure, tree_size, backend_fail, find_function} from "./numeric.mjs";
|
|
97
|
+
import {lower_memory_program} from "./memory.mjs";
|
|
98
|
+
import {prepare_host_capabilities, host_capability_index} from "./capabilities.mjs";
|
|
99
|
+
import {lower_managed_program, lower_managed_project} from "./managed.mjs";
|
|
100
|
+
import {binary_output, binary_byte, binary_push, binary_child, binary_length, binary_resume, binary_append, binary_append_owned, binary_finish} from "./binary.mjs";
|
|
101
|
+
function append_bytes(output, bytes) {
|
|
102
|
+
return binary_append(output, bytes);
|
|
103
|
+
}
|
|
104
|
+
function unsigned_leb(output, value) {
|
|
105
|
+
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) === "number") && __eliscript_numeric_relation(">=", value, 0) && __eliscript_numeric_relation("<=", value, 4294967295) && (value === __eliscript_numeric_uint32(value))))) {
|
|
106
|
+
backend_fail(null, "WASM index or section length is outside u32");
|
|
107
|
+
}
|
|
108
|
+
while (__eliscript_numeric_relation(">=", value, 128)) {
|
|
109
|
+
binary_push(output, __eliscript_numeric_or(__eliscript_numeric_and(value, 127), 128));
|
|
110
|
+
((value = __eliscript_numeric_ushr(value, 7)));
|
|
111
|
+
}
|
|
112
|
+
binary_push(output, value);
|
|
113
|
+
return output;
|
|
114
|
+
}
|
|
115
|
+
function float64_bytes(output, value) {
|
|
116
|
+
{
|
|
117
|
+
let words = ((__eliscript_number) => { const __eliscript_bytes = new DataView(new ArrayBuffer(8)); __eliscript_bytes.setFloat64(0, __eliscript_number === 0 ? 0 : __eliscript_number, true); return [__eliscript_bytes.getUint32(0, true), __eliscript_bytes.getUint32(4, true)]; })(value);
|
|
118
|
+
let low = ((((words) ?? [])[0]) ?? null);
|
|
119
|
+
let high = ((((words) ?? [])[1]) ?? null);
|
|
120
|
+
let index = 0;
|
|
121
|
+
if (((value === 0) && __eliscript_numeric_relation("<", __eliscript_numeric_div(1, value), 0))) {
|
|
122
|
+
((high = 2147483648));
|
|
123
|
+
}
|
|
124
|
+
while (__eliscript_numeric_relation("<", index, 4)) {
|
|
125
|
+
binary_push(output, __eliscript_numeric_and(low, 255));
|
|
126
|
+
((low = __eliscript_numeric_ushr(low, 8)));
|
|
127
|
+
((index = (index + 1)));
|
|
128
|
+
}
|
|
129
|
+
((index = 0));
|
|
130
|
+
while (__eliscript_numeric_relation("<", index, 4)) {
|
|
131
|
+
binary_push(output, __eliscript_numeric_and(high, 255));
|
|
132
|
+
((high = __eliscript_numeric_ushr(high, 8)));
|
|
133
|
+
((index = (index + 1)));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return output;
|
|
137
|
+
}
|
|
138
|
+
function positive_signed_leb(output, value) {
|
|
139
|
+
while (__eliscript_numeric_relation(">=", value, 128)) {
|
|
140
|
+
binary_push(output, __eliscript_numeric_or(__eliscript_numeric_and(value, 127), 128));
|
|
141
|
+
((value = __eliscript_numeric_ushr(value, 7)));
|
|
142
|
+
}
|
|
143
|
+
if (__eliscript_numeric_relation(">=", value, 64)) {
|
|
144
|
+
return binary_push(output, __eliscript_numeric_or(value, 128), 0);
|
|
145
|
+
} else {
|
|
146
|
+
return binary_push(output, value);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function signed_word_leb(output, value) {
|
|
150
|
+
((value = __eliscript_numeric_or(value, 0)));
|
|
151
|
+
{
|
|
152
|
+
const __eliscript_value_1 = null;
|
|
153
|
+
{
|
|
154
|
+
let done = __eliscript_value_1;
|
|
155
|
+
while ((!__eliscript_truthy(done))) {
|
|
156
|
+
{
|
|
157
|
+
const __eliscript_value_2 = __eliscript_numeric_and(value, 127);
|
|
158
|
+
{
|
|
159
|
+
let byte = __eliscript_value_2;
|
|
160
|
+
((value = __eliscript_numeric_shr(value, 7)));
|
|
161
|
+
((done = (((value === 0) && __eliscript_numeric_relation("<", byte, 64)) || ((value === -1) && __eliscript_numeric_relation(">=", byte, 64)))));
|
|
162
|
+
binary_push(output, (__eliscript_truthy(done) ? byte : __eliscript_numeric_or(byte, 128)));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return output;
|
|
169
|
+
}
|
|
170
|
+
function number_type(expression) {
|
|
171
|
+
return (((expression)["type"] === "f64") || ((expression)["type"] === "u32"));
|
|
172
|
+
}
|
|
173
|
+
function utf8_name(output, name) {
|
|
174
|
+
{
|
|
175
|
+
const __eliscript_value_3 = binary_child(output);
|
|
176
|
+
const __eliscript_value_4 = 0;
|
|
177
|
+
{
|
|
178
|
+
let bytes = __eliscript_value_3;
|
|
179
|
+
let index = __eliscript_value_4;
|
|
180
|
+
while (__eliscript_numeric_relation("<", index, ((name) ?? []).length)) {
|
|
181
|
+
{
|
|
182
|
+
const __eliscript_value_5 = (name).charCodeAt(index);
|
|
183
|
+
{
|
|
184
|
+
let code = __eliscript_value_5;
|
|
185
|
+
if ((__eliscript_numeric_relation(">=", code, 55296) && __eliscript_numeric_relation("<=", code, 56319))) {
|
|
186
|
+
if (__eliscript_numeric_relation(">=", (index + 1), ((name) ?? []).length)) {
|
|
187
|
+
backend_fail(null, "WASM export name contains an unpaired surrogate");
|
|
188
|
+
}
|
|
189
|
+
{
|
|
190
|
+
const __eliscript_value_6 = (name).charCodeAt((index + 1));
|
|
191
|
+
{
|
|
192
|
+
let next = __eliscript_value_6;
|
|
193
|
+
if ((!(__eliscript_numeric_relation(">=", next, 56320) && __eliscript_numeric_relation("<=", next, 57343)))) {
|
|
194
|
+
backend_fail(null, "WASM export name contains an unpaired surrogate");
|
|
195
|
+
}
|
|
196
|
+
((code = (65536 + __eliscript_numeric_mul(__eliscript_numeric_sub(code, 55296), 1024) + __eliscript_numeric_sub(next, 56320))));
|
|
197
|
+
((index = (index + 1)));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if ((__eliscript_numeric_relation(">=", code, 56320) && __eliscript_numeric_relation("<=", code, 57343))) {
|
|
202
|
+
backend_fail(null, "WASM export name contains an unpaired surrogate");
|
|
203
|
+
}
|
|
204
|
+
if (__eliscript_numeric_relation("<", code, 128)) {
|
|
205
|
+
binary_push(bytes, code);
|
|
206
|
+
} else {
|
|
207
|
+
if (__eliscript_numeric_relation("<", code, 2048)) {
|
|
208
|
+
binary_push(bytes, __eliscript_numeric_or(192, __eliscript_numeric_ushr(code, 6)));
|
|
209
|
+
binary_push(bytes, __eliscript_numeric_or(128, __eliscript_numeric_and(code, 63)));
|
|
210
|
+
} else {
|
|
211
|
+
if (__eliscript_numeric_relation("<", code, 65536)) {
|
|
212
|
+
binary_push(bytes, __eliscript_numeric_or(224, __eliscript_numeric_ushr(code, 12)));
|
|
213
|
+
binary_push(bytes, __eliscript_numeric_or(128, __eliscript_numeric_and(__eliscript_numeric_ushr(code, 6), 63)));
|
|
214
|
+
binary_push(bytes, __eliscript_numeric_or(128, __eliscript_numeric_and(code, 63)));
|
|
215
|
+
} else {
|
|
216
|
+
binary_push(bytes, __eliscript_numeric_or(240, __eliscript_numeric_ushr(code, 18)));
|
|
217
|
+
binary_push(bytes, __eliscript_numeric_or(128, __eliscript_numeric_and(__eliscript_numeric_ushr(code, 12), 63)));
|
|
218
|
+
binary_push(bytes, __eliscript_numeric_or(128, __eliscript_numeric_and(__eliscript_numeric_ushr(code, 6), 63)));
|
|
219
|
+
binary_push(bytes, __eliscript_numeric_or(128, __eliscript_numeric_and(code, 63)));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
((index = (index + 1)));
|
|
226
|
+
}
|
|
227
|
+
unsigned_leb(output, ((bytes) ?? []).length);
|
|
228
|
+
return append_bytes(output, bytes);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function section(output, id, payload) {
|
|
233
|
+
binary_push(output, id);
|
|
234
|
+
unsigned_leb(output, ((payload) ?? []).length);
|
|
235
|
+
return append_bytes(output, payload);
|
|
236
|
+
}
|
|
237
|
+
function result_byte(type) {
|
|
238
|
+
if ((type === "f64")) {
|
|
239
|
+
return 124;
|
|
240
|
+
} else {
|
|
241
|
+
return 127;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function debug_range_start(output, expression, emission) {
|
|
245
|
+
{
|
|
246
|
+
const __eliscript_value_7 = ((output)["wasmDebug"] ?? null);
|
|
247
|
+
{
|
|
248
|
+
let state = __eliscript_value_7;
|
|
249
|
+
if (__eliscript_truthy(state)) {
|
|
250
|
+
{
|
|
251
|
+
let depth = ((state)["depth"] ?? 0);
|
|
252
|
+
let range = ({"kind": (expression)["kind"], "emission": emission, "function": (state)["function"], "functionIndex": (state)["functionIndex"], "depth": depth, "start": ((output) ?? []).length, "end": 0, "span": ((expression)["span"] ?? null)});
|
|
253
|
+
((state)["ranges"])["push"](range);
|
|
254
|
+
((state)["depth"] = (depth + 1));
|
|
255
|
+
return range;
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
return null;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function debug_range_end(output, range) {
|
|
264
|
+
if (__eliscript_truthy(range)) {
|
|
265
|
+
((range)["end"] = ((output) ?? []).length);
|
|
266
|
+
return (((output)["wasmDebug"])["depth"] = (range)["depth"]);
|
|
267
|
+
} else {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function emit_trapping_bytes(output, expression, bytes, terminal = null) {
|
|
272
|
+
{
|
|
273
|
+
const __eliscript_value_8 = ((output)["wasmDebug"] ?? null);
|
|
274
|
+
const __eliscript_value_9 = null;
|
|
275
|
+
{
|
|
276
|
+
let state = __eliscript_value_8;
|
|
277
|
+
let range = __eliscript_value_9;
|
|
278
|
+
if (__eliscript_truthy(state)) {
|
|
279
|
+
{
|
|
280
|
+
const __eliscript_value_10 = (state)["trapSites"];
|
|
281
|
+
{
|
|
282
|
+
let sites = __eliscript_value_10;
|
|
283
|
+
binary_push(output, 65);
|
|
284
|
+
positive_signed_leb(output, (((sites) ?? []).length + 1));
|
|
285
|
+
binary_push(output, 36, 0);
|
|
286
|
+
((range = ({"kind": "trap-site", "function": (state)["function"], "functionIndex": (state)["functionIndex"], "depth": (state)["depth"], "start": ((output) ?? []).length, "end": 0, "span": ((expression)["span"] ?? null), "site": (((sites) ?? []).length + 1)})));
|
|
287
|
+
(sites)["push"](range);
|
|
288
|
+
((state)["ranges"])["push"](range);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
append_bytes(output, bytes);
|
|
293
|
+
if (__eliscript_truthy(range)) {
|
|
294
|
+
((range)["end"] = ((output) ?? []).length);
|
|
295
|
+
if ((!__eliscript_truthy(terminal))) {
|
|
296
|
+
return binary_push(output, 65, 0, 36, 0);
|
|
297
|
+
} else {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
function emit_condition(output, expression) {
|
|
307
|
+
{
|
|
308
|
+
const __eliscript_value_11 = debug_range_start(output, expression, "condition");
|
|
309
|
+
{
|
|
310
|
+
let range = __eliscript_value_11;
|
|
311
|
+
{
|
|
312
|
+
const __eliscript_value_12 = emit_condition_body(output, expression);
|
|
313
|
+
{
|
|
314
|
+
let result = __eliscript_value_12;
|
|
315
|
+
debug_range_end(output, range);
|
|
316
|
+
return result;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function emit_condition_body(output, expression) {
|
|
323
|
+
if (__eliscript_truthy(number_type(expression))) {
|
|
324
|
+
emit_discarded(output, expression);
|
|
325
|
+
return binary_push(output, 65, 1);
|
|
326
|
+
} else {
|
|
327
|
+
return emit_expression(output, expression);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
function emit_while(output, children) {
|
|
331
|
+
binary_push(output, 2, 64);
|
|
332
|
+
emit_branch_false(output, ((((children) ?? [])[0]) ?? null), 0);
|
|
333
|
+
binary_push(output, 3, 64);
|
|
334
|
+
emit_discarded(output, ((((children) ?? [])[1]) ?? null));
|
|
335
|
+
emit_branch_true(output, ((((children) ?? [])[0]) ?? null), 0);
|
|
336
|
+
return binary_push(output, 11, 11);
|
|
337
|
+
}
|
|
338
|
+
function emit_guarded_while(output, children) {
|
|
339
|
+
binary_push(output, 2, 64);
|
|
340
|
+
emit_branch_false(output, ((((children) ?? [])[0]) ?? null), 0);
|
|
341
|
+
binary_push(output, 3, 64);
|
|
342
|
+
{
|
|
343
|
+
const __eliscript_value_13 = 0;
|
|
344
|
+
{
|
|
345
|
+
let index = __eliscript_value_13;
|
|
346
|
+
while (__eliscript_numeric_relation("<", index, 4)) {
|
|
347
|
+
emit_discarded(output, ((((children) ?? [])[1]) ?? null));
|
|
348
|
+
emit_branch_false(output, ((((children) ?? [])[0]) ?? null), 1);
|
|
349
|
+
if ((index === 3)) {
|
|
350
|
+
binary_push(output, 12, 0);
|
|
351
|
+
}
|
|
352
|
+
((index = (index + 1)));
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return binary_push(output, 11, 11);
|
|
357
|
+
}
|
|
358
|
+
function emit_counter_guarded_while(output, children) {
|
|
359
|
+
binary_push(output, 2, 64, 2, 64, 3, 64);
|
|
360
|
+
emit_branch_false(output, ((((children) ?? [])[2]) ?? null), 1);
|
|
361
|
+
{
|
|
362
|
+
const __eliscript_value_14 = 0;
|
|
363
|
+
{
|
|
364
|
+
let index = __eliscript_value_14;
|
|
365
|
+
while (__eliscript_numeric_relation("<", index, 4)) {
|
|
366
|
+
emit_branch_false(output, ((((children) ?? [])[3]) ?? null), 2);
|
|
367
|
+
emit_discarded(output, ((((children) ?? [])[1]) ?? null));
|
|
368
|
+
((index = (index + 1)));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
binary_push(output, 12, 0, 11, 11);
|
|
373
|
+
emit_while(output, children);
|
|
374
|
+
return binary_push(output, 11);
|
|
375
|
+
}
|
|
376
|
+
function emit_branch_true(output, expression, depth) {
|
|
377
|
+
{
|
|
378
|
+
const __eliscript_value_15 = debug_range_start(output, expression, "branch-true");
|
|
379
|
+
{
|
|
380
|
+
let range = __eliscript_value_15;
|
|
381
|
+
{
|
|
382
|
+
const __eliscript_value_16 = emit_branch_true_body(output, expression, depth);
|
|
383
|
+
{
|
|
384
|
+
let result = __eliscript_value_16;
|
|
385
|
+
debug_range_end(output, range);
|
|
386
|
+
return result;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function emit_branch_true_body(output, expression, depth) {
|
|
393
|
+
{
|
|
394
|
+
const __eliscript_value_17 = (expression)["kind"];
|
|
395
|
+
const __eliscript_value_18 = (expression)["children"];
|
|
396
|
+
{
|
|
397
|
+
let kind = __eliscript_value_17;
|
|
398
|
+
let children = __eliscript_value_18;
|
|
399
|
+
if (__eliscript_truthy(number_type(expression))) {
|
|
400
|
+
emit_discarded(output, expression);
|
|
401
|
+
binary_push(output, 12);
|
|
402
|
+
return unsigned_leb(output, depth);
|
|
403
|
+
} else {
|
|
404
|
+
if ((kind === "not")) {
|
|
405
|
+
return emit_branch_false(output, ((((children) ?? [])[0]) ?? null), depth);
|
|
406
|
+
} else {
|
|
407
|
+
if ((kind === "or")) {
|
|
408
|
+
{
|
|
409
|
+
const __eliscript_value_19 = 0;
|
|
410
|
+
{
|
|
411
|
+
let index = __eliscript_value_19;
|
|
412
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
413
|
+
emit_branch_true(output, ((((children) ?? [])[index]) ?? null), depth);
|
|
414
|
+
((index = (index + 1)));
|
|
415
|
+
}
|
|
416
|
+
return null;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
if ((kind === "and")) {
|
|
421
|
+
binary_push(output, 2, 64);
|
|
422
|
+
{
|
|
423
|
+
const __eliscript_value_20 = 0;
|
|
424
|
+
{
|
|
425
|
+
let index = __eliscript_value_20;
|
|
426
|
+
while (__eliscript_numeric_relation("<", index, __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
427
|
+
emit_branch_false(output, ((((children) ?? [])[index]) ?? null), 0);
|
|
428
|
+
((index = (index + 1)));
|
|
429
|
+
}
|
|
430
|
+
emit_branch_true(output, ((((children) ?? [])[index]) ?? null), (depth + 1));
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
return binary_push(output, 11);
|
|
434
|
+
} else {
|
|
435
|
+
emit_condition(output, expression);
|
|
436
|
+
binary_push(output, 13);
|
|
437
|
+
return unsigned_leb(output, depth);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
function emit_branch_false(output, expression, depth) {
|
|
446
|
+
{
|
|
447
|
+
const __eliscript_value_21 = debug_range_start(output, expression, "branch-false");
|
|
448
|
+
{
|
|
449
|
+
let range = __eliscript_value_21;
|
|
450
|
+
{
|
|
451
|
+
const __eliscript_value_22 = emit_branch_false_body(output, expression, depth);
|
|
452
|
+
{
|
|
453
|
+
let result = __eliscript_value_22;
|
|
454
|
+
debug_range_end(output, range);
|
|
455
|
+
return result;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function emit_branch_false_body(output, expression, depth) {
|
|
462
|
+
{
|
|
463
|
+
const __eliscript_value_23 = (expression)["kind"];
|
|
464
|
+
const __eliscript_value_24 = (expression)["children"];
|
|
465
|
+
{
|
|
466
|
+
let kind = __eliscript_value_23;
|
|
467
|
+
let children = __eliscript_value_24;
|
|
468
|
+
if (__eliscript_truthy(number_type(expression))) {
|
|
469
|
+
return emit_discarded(output, expression);
|
|
470
|
+
} else {
|
|
471
|
+
if ((kind === "not")) {
|
|
472
|
+
return emit_branch_true(output, ((((children) ?? [])[0]) ?? null), depth);
|
|
473
|
+
} else {
|
|
474
|
+
if (((kind === "int-compare") || (kind === "word-compare"))) {
|
|
475
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
476
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
477
|
+
binary_push(output, ((kind === "int-compare") ? 78 : ((operator) => {
|
|
478
|
+
if ((operator === "=")) {
|
|
479
|
+
return 71;
|
|
480
|
+
} else {
|
|
481
|
+
if ((operator === "/=")) {
|
|
482
|
+
return 70;
|
|
483
|
+
} else {
|
|
484
|
+
if ((operator === "<")) {
|
|
485
|
+
return 79;
|
|
486
|
+
} else {
|
|
487
|
+
if ((operator === ">")) {
|
|
488
|
+
return 77;
|
|
489
|
+
} else {
|
|
490
|
+
if ((operator === "<=")) {
|
|
491
|
+
return 75;
|
|
492
|
+
} else {
|
|
493
|
+
return 73;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
})((expression)["value"])), 13);
|
|
500
|
+
return unsigned_leb(output, depth);
|
|
501
|
+
} else {
|
|
502
|
+
if ((kind === "and")) {
|
|
503
|
+
{
|
|
504
|
+
const __eliscript_value_25 = 0;
|
|
505
|
+
{
|
|
506
|
+
let index = __eliscript_value_25;
|
|
507
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
508
|
+
emit_branch_false(output, ((((children) ?? [])[index]) ?? null), depth);
|
|
509
|
+
((index = (index + 1)));
|
|
510
|
+
}
|
|
511
|
+
return null;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
} else {
|
|
515
|
+
if ((kind === "or")) {
|
|
516
|
+
binary_push(output, 2, 64);
|
|
517
|
+
{
|
|
518
|
+
const __eliscript_value_26 = 0;
|
|
519
|
+
{
|
|
520
|
+
let index = __eliscript_value_26;
|
|
521
|
+
while (__eliscript_numeric_relation("<", index, __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
522
|
+
emit_condition(output, ((((children) ?? [])[index]) ?? null));
|
|
523
|
+
binary_push(output, 13, 0);
|
|
524
|
+
((index = (index + 1)));
|
|
525
|
+
}
|
|
526
|
+
emit_branch_false(output, ((((children) ?? [])[index]) ?? null), (depth + 1));
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return binary_push(output, 11);
|
|
530
|
+
} else {
|
|
531
|
+
emit_condition(output, expression);
|
|
532
|
+
binary_push(output, 69);
|
|
533
|
+
binary_push(output, 13);
|
|
534
|
+
return unsigned_leb(output, depth);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function emit_discarded_short_circuit(output, expression, index) {
|
|
544
|
+
{
|
|
545
|
+
let children = (expression)["children"];
|
|
546
|
+
let operand = ((((children) ?? [])[index]) ?? null);
|
|
547
|
+
let operator = (expression)["kind"];
|
|
548
|
+
if ((index === __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
549
|
+
return emit_discarded(output, operand);
|
|
550
|
+
} else {
|
|
551
|
+
if (__eliscript_truthy(number_type(expression))) {
|
|
552
|
+
emit_discarded(output, operand);
|
|
553
|
+
if ((operator === "and")) {
|
|
554
|
+
return emit_discarded_short_circuit(output, expression, (index + 1));
|
|
555
|
+
} else {
|
|
556
|
+
return null;
|
|
557
|
+
}
|
|
558
|
+
} else {
|
|
559
|
+
emit_condition(output, operand);
|
|
560
|
+
if ((operator === "or")) {
|
|
561
|
+
binary_push(output, 69);
|
|
562
|
+
}
|
|
563
|
+
binary_push(output, 4, 64);
|
|
564
|
+
emit_discarded_short_circuit(output, expression, (index + 1));
|
|
565
|
+
return binary_push(output, 11);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
function emit_discarded(output, expression) {
|
|
571
|
+
{
|
|
572
|
+
const __eliscript_value_27 = debug_range_start(output, expression, "discarded");
|
|
573
|
+
{
|
|
574
|
+
let range = __eliscript_value_27;
|
|
575
|
+
{
|
|
576
|
+
const __eliscript_value_28 = emit_discarded_body(output, expression);
|
|
577
|
+
{
|
|
578
|
+
let result = __eliscript_value_28;
|
|
579
|
+
debug_range_end(output, range);
|
|
580
|
+
return result;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function emit_discarded_body(output, expression) {
|
|
587
|
+
{
|
|
588
|
+
const __eliscript_value_29 = (expression)["kind"];
|
|
589
|
+
const __eliscript_value_30 = (expression)["children"];
|
|
590
|
+
{
|
|
591
|
+
let kind = __eliscript_value_29;
|
|
592
|
+
let children = __eliscript_value_30;
|
|
593
|
+
if (((kind === "literal") || (kind === "local"))) {
|
|
594
|
+
return null;
|
|
595
|
+
} else {
|
|
596
|
+
if ((kind === "int-number")) {
|
|
597
|
+
return emit_discarded(output, ((((children) ?? [])[0]) ?? null));
|
|
598
|
+
} else {
|
|
599
|
+
if (((kind === "set") || (kind === "initialize"))) {
|
|
600
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
601
|
+
binary_push(output, 33);
|
|
602
|
+
return unsigned_leb(output, (expression)["value"]);
|
|
603
|
+
} else {
|
|
604
|
+
if (((kind === "sequence") || (kind === "arithmetic") || (kind === "compare") || (kind === "not"))) {
|
|
605
|
+
{
|
|
606
|
+
const __eliscript_value_31 = 0;
|
|
607
|
+
{
|
|
608
|
+
let index = __eliscript_value_31;
|
|
609
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
610
|
+
emit_discarded(output, ((((children) ?? [])[index]) ?? null));
|
|
611
|
+
((index = (index + 1)));
|
|
612
|
+
}
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
} else {
|
|
617
|
+
if ((kind === "if")) {
|
|
618
|
+
emit_condition(output, ((((children) ?? [])[0]) ?? null));
|
|
619
|
+
binary_push(output, 4, 64);
|
|
620
|
+
emit_discarded(output, ((((children) ?? [])[1]) ?? null));
|
|
621
|
+
binary_push(output, 5);
|
|
622
|
+
emit_discarded(output, ((((children) ?? [])[2]) ?? null));
|
|
623
|
+
return binary_push(output, 11);
|
|
624
|
+
} else {
|
|
625
|
+
if (((kind === "while") || (kind === "remainder-while"))) {
|
|
626
|
+
return emit_while(output, children);
|
|
627
|
+
} else {
|
|
628
|
+
if ((kind === "guarded-while")) {
|
|
629
|
+
return emit_guarded_while(output, children);
|
|
630
|
+
} else {
|
|
631
|
+
if ((kind === "guarded-counter-while")) {
|
|
632
|
+
return emit_counter_guarded_while(output, children);
|
|
633
|
+
} else {
|
|
634
|
+
if (((kind === "and") || (kind === "or"))) {
|
|
635
|
+
return emit_discarded_short_circuit(output, expression, 0);
|
|
636
|
+
} else {
|
|
637
|
+
emit_expression(output, expression);
|
|
638
|
+
return binary_push(output, 26);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
function emit_sequence(output, children) {
|
|
652
|
+
if ((((children) ?? []).length === 0)) {
|
|
653
|
+
return binary_push(output, 65, 0);
|
|
654
|
+
} else {
|
|
655
|
+
{
|
|
656
|
+
const __eliscript_value_32 = 0;
|
|
657
|
+
{
|
|
658
|
+
let index = __eliscript_value_32;
|
|
659
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
660
|
+
if (__eliscript_numeric_relation("<", index, __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
661
|
+
emit_discarded(output, ((((children) ?? [])[index]) ?? null));
|
|
662
|
+
} else {
|
|
663
|
+
emit_expression(output, ((((children) ?? [])[index]) ?? null));
|
|
664
|
+
}
|
|
665
|
+
((index = (index + 1)));
|
|
666
|
+
}
|
|
667
|
+
return null;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
function emit_short_circuit(output, expression, index) {
|
|
673
|
+
{
|
|
674
|
+
let children = (expression)["children"];
|
|
675
|
+
let operand = ((((children) ?? [])[index]) ?? null);
|
|
676
|
+
let operator = (expression)["kind"];
|
|
677
|
+
if ((index === __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
678
|
+
return emit_expression(output, operand);
|
|
679
|
+
} else {
|
|
680
|
+
if (__eliscript_truthy(number_type(expression))) {
|
|
681
|
+
emit_expression(output, operand);
|
|
682
|
+
if ((operator === "and")) {
|
|
683
|
+
binary_push(output, 26);
|
|
684
|
+
return emit_short_circuit(output, expression, (index + 1));
|
|
685
|
+
} else {
|
|
686
|
+
return null;
|
|
687
|
+
}
|
|
688
|
+
} else {
|
|
689
|
+
emit_condition(output, operand);
|
|
690
|
+
binary_push(output, 4, 127);
|
|
691
|
+
if ((operator === "and")) {
|
|
692
|
+
emit_short_circuit(output, expression, (index + 1));
|
|
693
|
+
} else {
|
|
694
|
+
binary_push(output, 65, 1);
|
|
695
|
+
}
|
|
696
|
+
binary_push(output, 5);
|
|
697
|
+
if ((operator === "and")) {
|
|
698
|
+
binary_push(output, 65, 0);
|
|
699
|
+
} else {
|
|
700
|
+
emit_short_circuit(output, expression, (index + 1));
|
|
701
|
+
}
|
|
702
|
+
return binary_push(output, 11);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
function arithmetic_opcode(operator) {
|
|
708
|
+
if (((operator === "+") || (operator === "1+"))) {
|
|
709
|
+
return 160;
|
|
710
|
+
} else {
|
|
711
|
+
if (((operator === "-") || (operator === "1-"))) {
|
|
712
|
+
return 161;
|
|
713
|
+
} else {
|
|
714
|
+
if ((operator === "*")) {
|
|
715
|
+
return 162;
|
|
716
|
+
} else {
|
|
717
|
+
return 163;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
function emit_arithmetic(output, expression) {
|
|
723
|
+
{
|
|
724
|
+
let operator = (expression)["value"];
|
|
725
|
+
let children = (expression)["children"];
|
|
726
|
+
let count = ((children) ?? []).length;
|
|
727
|
+
if ((count === 0)) {
|
|
728
|
+
binary_push(output, 68);
|
|
729
|
+
return float64_bytes(output, ((operator === "*") ? 1 : 0));
|
|
730
|
+
} else {
|
|
731
|
+
if (((count === 1) && (operator === "-"))) {
|
|
732
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
733
|
+
return binary_push(output, 154);
|
|
734
|
+
} else {
|
|
735
|
+
if (((count === 1) && (operator === "/"))) {
|
|
736
|
+
binary_push(output, 68);
|
|
737
|
+
float64_bytes(output, 1);
|
|
738
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
739
|
+
return binary_push(output, 163);
|
|
740
|
+
} else {
|
|
741
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
742
|
+
if ((count === 2)) {
|
|
743
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
744
|
+
return binary_push(output, arithmetic_opcode(operator));
|
|
745
|
+
} else {
|
|
746
|
+
if (((operator === "1+") || (operator === "1-"))) {
|
|
747
|
+
binary_push(output, 68);
|
|
748
|
+
float64_bytes(output, 1);
|
|
749
|
+
return binary_push(output, arithmetic_opcode(operator));
|
|
750
|
+
} else {
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function emit_word_arithmetic(output, expression) {
|
|
760
|
+
{
|
|
761
|
+
let children = (expression)["children"];
|
|
762
|
+
let count = ((children) ?? []).length;
|
|
763
|
+
let operator = (expression)["value"];
|
|
764
|
+
if ((count === 0)) {
|
|
765
|
+
return binary_push(output, 65, ((operator === "*") ? 1 : 0));
|
|
766
|
+
} else {
|
|
767
|
+
if (((count === 1) && (operator === "-"))) {
|
|
768
|
+
binary_push(output, 65, 0);
|
|
769
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
770
|
+
return binary_push(output, 107);
|
|
771
|
+
} else {
|
|
772
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
773
|
+
if (((count === 2) || (operator === "1+") || (operator === "1-"))) {
|
|
774
|
+
if ((count === 2)) {
|
|
775
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
776
|
+
} else {
|
|
777
|
+
binary_push(output, 65, 1);
|
|
778
|
+
}
|
|
779
|
+
return binary_push(output, (((operator === "+") || (operator === "1+")) ? 106 : (((operator === "-") || (operator === "1-")) ? 107 : 108)));
|
|
780
|
+
} else {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function memory_access_width(name) {
|
|
788
|
+
if (((name === "load-u8") || (name === "store-u8"))) {
|
|
789
|
+
return 1;
|
|
790
|
+
} else {
|
|
791
|
+
if (((name === "load-u16") || (name === "store-u16"))) {
|
|
792
|
+
return 2;
|
|
793
|
+
} else {
|
|
794
|
+
if (((name === "load-u32") || (name === "store-u32"))) {
|
|
795
|
+
return 4;
|
|
796
|
+
} else {
|
|
797
|
+
if (((name === "load-f64") || (name === "store-f64"))) {
|
|
798
|
+
return 8;
|
|
799
|
+
} else {
|
|
800
|
+
return 0;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
function memory_f64_unary_opcode(name) {
|
|
807
|
+
if ((name === "f64-abs")) {
|
|
808
|
+
return 153;
|
|
809
|
+
} else {
|
|
810
|
+
if ((name === "f64-neg")) {
|
|
811
|
+
return 154;
|
|
812
|
+
} else {
|
|
813
|
+
if ((name === "f64-ceil")) {
|
|
814
|
+
return 155;
|
|
815
|
+
} else {
|
|
816
|
+
if ((name === "f64-floor")) {
|
|
817
|
+
return 156;
|
|
818
|
+
} else {
|
|
819
|
+
if ((name === "f64-trunc")) {
|
|
820
|
+
return 157;
|
|
821
|
+
} else {
|
|
822
|
+
if ((name === "f64-nearest")) {
|
|
823
|
+
return 158;
|
|
824
|
+
} else {
|
|
825
|
+
if ((name === "f64-sqrt")) {
|
|
826
|
+
return 159;
|
|
827
|
+
} else {
|
|
828
|
+
return null;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
function require_memory_f64_unary(expression, memory) {
|
|
838
|
+
{
|
|
839
|
+
const __eliscript_value_33 = (expression)["children"];
|
|
840
|
+
{
|
|
841
|
+
let children = __eliscript_value_33;
|
|
842
|
+
if ((!__eliscript_truthy(((__eliscript_value_34) => (__eliscript_truthy(__eliscript_value_34) ? ((__eliscript_value_35) => (__eliscript_truthy(__eliscript_value_35) ? ((__eliscript_value_36) => (__eliscript_truthy(__eliscript_value_36) ? ((__eliscript_value_37) => (__eliscript_truthy(__eliscript_value_37) ? ((__eliscript_value_38) => (__eliscript_truthy(__eliscript_value_38) ? ((__eliscript_value_39) => (__eliscript_truthy(__eliscript_value_39) ? ((__eliscript_value_40) => (__eliscript_truthy(__eliscript_value_40) ? ((__eliscript_value_41) => (__eliscript_truthy(__eliscript_value_41) ? ((((((children) ?? [])[0]) ?? null))["type"] === "f64") : __eliscript_value_41))(Array.isArray((((((children) ?? [])[0]) ?? null))["children"])) : __eliscript_value_40))((!__eliscript_truthy(Array.isArray(((((children) ?? [])[0]) ?? null))))) : __eliscript_value_39))((((__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; } })(((((children) ?? [])[0]) ?? null)) === "object")) : __eliscript_value_38))((!(((((children) ?? [])[0]) ?? null) === null))) : __eliscript_value_37))((((children) ?? []).length === 1)) : __eliscript_value_36))(Array.isArray(children)) : __eliscript_value_35))(((expression)["type"] === "f64")) : __eliscript_value_34))(memory)))) {
|
|
843
|
+
backend_fail(expression, "f64 unary memory opcode requires one f64 operand and result");
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return expression;
|
|
848
|
+
}
|
|
849
|
+
function require_memory_data_copy(expression, memory) {
|
|
850
|
+
{
|
|
851
|
+
const __eliscript_value_42 = (expression)["value"];
|
|
852
|
+
const __eliscript_value_43 = (expression)["children"];
|
|
853
|
+
{
|
|
854
|
+
let text = __eliscript_value_42;
|
|
855
|
+
let children = __eliscript_value_43;
|
|
856
|
+
if ((!__eliscript_truthy(((__eliscript_value_44) => (__eliscript_truthy(__eliscript_value_44) ? ((__eliscript_value_45) => (__eliscript_truthy(__eliscript_value_45) ? ((__eliscript_value_46) => (__eliscript_truthy(__eliscript_value_46) ? ((__eliscript_value_47) => (__eliscript_truthy(__eliscript_value_47) ? ((__eliscript_value_48) => (__eliscript_truthy(__eliscript_value_48) ? ((__eliscript_value_49) => (__eliscript_truthy(__eliscript_value_49) ? ((__eliscript_value_50) => (__eliscript_truthy(__eliscript_value_50) ? ((__eliscript_value_51) => (__eliscript_truthy(__eliscript_value_51) ? ((__eliscript_value_52) => (__eliscript_truthy(__eliscript_value_52) ? ((__eliscript_value_53) => (__eliscript_truthy(__eliscript_value_53) ? ((((((children) ?? [])[0]) ?? null))["type"] === "u32") : __eliscript_value_53))(Array.isArray((((((children) ?? [])[0]) ?? null))["children"])) : __eliscript_value_52))((!__eliscript_truthy(Array.isArray(((((children) ?? [])[0]) ?? null))))) : __eliscript_value_51))((((__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; } })(((((children) ?? [])[0]) ?? null)) === "object")) : __eliscript_value_50))((!(((((children) ?? [])[0]) ?? null) === null))) : __eliscript_value_49))((((children) ?? []).length === 1)) : __eliscript_value_48))(Array.isArray(children)) : __eliscript_value_47))(__eliscript_numeric_relation("<=", ((text) ?? []).length, 2147483647)) : __eliscript_value_46))((((__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; } })(text) === "string")) : __eliscript_value_45))(((expression)["type"] === "u32")) : __eliscript_value_44))(memory)))) {
|
|
857
|
+
backend_fail(expression, "static UTF16 copy requires memory-u32, one word address and string data");
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
return expression;
|
|
862
|
+
}
|
|
863
|
+
function require_wasm_expression_node(expression, parent, memory) {
|
|
864
|
+
if ((!((!(expression === 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; } })(expression) === "object") && (!__eliscript_truthy(Array.isArray(expression)))))) {
|
|
865
|
+
backend_fail(parent, "typed WASM expression requires a node object");
|
|
866
|
+
}
|
|
867
|
+
if (((expression)["kind"] === "memory-data-copy")) {
|
|
868
|
+
require_memory_data_copy(expression, memory);
|
|
869
|
+
}
|
|
870
|
+
if (__eliscript_truthy(((__eliscript_value_54) => (__eliscript_truthy(__eliscript_value_54) ? memory_f64_unary_opcode((expression)["value"]) : __eliscript_value_54))(((expression)["kind"] === "memory-op")))) {
|
|
871
|
+
require_memory_f64_unary(expression, memory);
|
|
872
|
+
}
|
|
873
|
+
if ((!__eliscript_truthy(Array.isArray((expression)["children"])))) {
|
|
874
|
+
backend_fail(expression, "typed WASM expression requires a children array");
|
|
875
|
+
}
|
|
876
|
+
return expression;
|
|
877
|
+
}
|
|
878
|
+
function copy_wasm_expression_node(expression, parent, memory) {
|
|
879
|
+
require_wasm_expression_node(expression, parent, memory);
|
|
880
|
+
{
|
|
881
|
+
const __eliscript_value_55 = Object.assign(({}), expression);
|
|
882
|
+
{
|
|
883
|
+
let copy = __eliscript_value_55;
|
|
884
|
+
((copy)["children"] = []);
|
|
885
|
+
return copy;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
function same_wasm_expression_snapshot(left, right) {
|
|
890
|
+
if ((!__eliscript_truthy(Object.is(Object.getPrototypeOf(left), Object.getPrototypeOf(right))))) {
|
|
891
|
+
return false;
|
|
892
|
+
} else {
|
|
893
|
+
{
|
|
894
|
+
const __eliscript_value_56 = (Object.getOwnPropertyNames(left))["concat"](Object.getOwnPropertySymbols(left));
|
|
895
|
+
const __eliscript_value_57 = (Object.getOwnPropertyNames(right))["concat"](Object.getOwnPropertySymbols(right));
|
|
896
|
+
const __eliscript_value_58 = 0;
|
|
897
|
+
const __eliscript_value_59 = true;
|
|
898
|
+
{
|
|
899
|
+
let keys = __eliscript_value_56;
|
|
900
|
+
let other = __eliscript_value_57;
|
|
901
|
+
let index = __eliscript_value_58;
|
|
902
|
+
let same = __eliscript_value_59;
|
|
903
|
+
if ((!(((keys) ?? []).length === ((other) ?? []).length))) {
|
|
904
|
+
((same = false));
|
|
905
|
+
}
|
|
906
|
+
while (__eliscript_truthy(((__eliscript_value_60) => (__eliscript_truthy(__eliscript_value_60) ? __eliscript_numeric_relation("<", index, ((keys) ?? []).length) : __eliscript_value_60))(same))) {
|
|
907
|
+
{
|
|
908
|
+
const __eliscript_value_61 = ((((keys) ?? [])[index]) ?? null);
|
|
909
|
+
{
|
|
910
|
+
let key = __eliscript_value_61;
|
|
911
|
+
if ((!__eliscript_truthy(Object.is(key, ((((other) ?? [])[index]) ?? null))))) {
|
|
912
|
+
((same = false));
|
|
913
|
+
}
|
|
914
|
+
if (__eliscript_truthy(same)) {
|
|
915
|
+
if (__eliscript_truthy(Object.is(key, "children"))) {
|
|
916
|
+
{
|
|
917
|
+
const __eliscript_value_62 = (left)["children"];
|
|
918
|
+
const __eliscript_value_63 = (right)["children"];
|
|
919
|
+
const __eliscript_value_64 = 0;
|
|
920
|
+
{
|
|
921
|
+
let children = __eliscript_value_62;
|
|
922
|
+
let others = __eliscript_value_63;
|
|
923
|
+
let position = __eliscript_value_64;
|
|
924
|
+
if ((!(((children) ?? []).length === ((others) ?? []).length))) {
|
|
925
|
+
((same = false));
|
|
926
|
+
}
|
|
927
|
+
while (__eliscript_truthy(((__eliscript_value_65) => (__eliscript_truthy(__eliscript_value_65) ? __eliscript_numeric_relation("<", position, ((children) ?? []).length) : __eliscript_value_65))(same))) {
|
|
928
|
+
if ((!__eliscript_truthy(Object.is(((((children) ?? [])[position]) ?? null), ((((others) ?? [])[position]) ?? null))))) {
|
|
929
|
+
((same = false));
|
|
930
|
+
}
|
|
931
|
+
((position = (position + 1)));
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
} else {
|
|
936
|
+
if ((!__eliscript_truthy(Object.is((left)[key], (right)[key])))) {
|
|
937
|
+
((same = false));
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
((index = (index + 1)));
|
|
944
|
+
}
|
|
945
|
+
return same;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
function intern_wasm_expression(source, copy, first_copies, alternatives) {
|
|
951
|
+
if ((!__eliscript_truthy((first_copies)["has"](source)))) {
|
|
952
|
+
(first_copies)["set"](source, copy);
|
|
953
|
+
return copy;
|
|
954
|
+
} else {
|
|
955
|
+
{
|
|
956
|
+
const __eliscript_value_66 = (first_copies)["get"](source);
|
|
957
|
+
{
|
|
958
|
+
let first = __eliscript_value_66;
|
|
959
|
+
if (__eliscript_truthy(same_wasm_expression_snapshot(copy, first))) {
|
|
960
|
+
return first;
|
|
961
|
+
} else {
|
|
962
|
+
{
|
|
963
|
+
const __eliscript_value_67 = (alternatives)["get"](source);
|
|
964
|
+
const __eliscript_value_68 = 0;
|
|
965
|
+
const __eliscript_value_69 = null;
|
|
966
|
+
{
|
|
967
|
+
let others = __eliscript_value_67;
|
|
968
|
+
let index = __eliscript_value_68;
|
|
969
|
+
let found = __eliscript_value_69;
|
|
970
|
+
if (__eliscript_truthy(others)) {
|
|
971
|
+
while (((!__eliscript_truthy(found)) && __eliscript_numeric_relation("<", index, ((others) ?? []).length))) {
|
|
972
|
+
{
|
|
973
|
+
const __eliscript_value_70 = ((((others) ?? [])[index]) ?? null);
|
|
974
|
+
{
|
|
975
|
+
let candidate = __eliscript_value_70;
|
|
976
|
+
if (__eliscript_truthy(same_wasm_expression_snapshot(copy, candidate))) {
|
|
977
|
+
((found = candidate));
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
((index = (index + 1)));
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
if (__eliscript_truthy(found)) {
|
|
985
|
+
return found;
|
|
986
|
+
} else {
|
|
987
|
+
if ((!__eliscript_truthy(others))) {
|
|
988
|
+
((others = []));
|
|
989
|
+
(alternatives)["set"](source, others);
|
|
990
|
+
}
|
|
991
|
+
(others)["push"](copy);
|
|
992
|
+
return copy;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
function copy_wasm_expression(expression, parent, memory) {
|
|
1002
|
+
{
|
|
1003
|
+
let copy = copy_wasm_expression_node(expression, parent, memory);
|
|
1004
|
+
let first_copies = new (globalThis.Map)();
|
|
1005
|
+
let alternatives = new (globalThis.Map)();
|
|
1006
|
+
let pending = [({"source": expression, "copy": copy, "position": 0})];
|
|
1007
|
+
while (__eliscript_numeric_relation(">", ((pending) ?? []).length, 0)) {
|
|
1008
|
+
{
|
|
1009
|
+
let frame = ((((pending) ?? [])[__eliscript_numeric_decrement(((pending) ?? []).length)]) ?? null);
|
|
1010
|
+
let source = (frame)["source"];
|
|
1011
|
+
let children = (source)["children"];
|
|
1012
|
+
let position = (frame)["position"];
|
|
1013
|
+
if ((position === ((children) ?? []).length)) {
|
|
1014
|
+
{
|
|
1015
|
+
const __eliscript_value_71 = intern_wasm_expression(source, (frame)["copy"], first_copies, alternatives);
|
|
1016
|
+
{
|
|
1017
|
+
let completed = __eliscript_value_71;
|
|
1018
|
+
(pending)["pop"]();
|
|
1019
|
+
if ((((pending) ?? []).length === 0)) {
|
|
1020
|
+
((copy = completed));
|
|
1021
|
+
} else {
|
|
1022
|
+
{
|
|
1023
|
+
let previous = ((((pending) ?? [])[__eliscript_numeric_decrement(((pending) ?? []).length)]) ?? null);
|
|
1024
|
+
let output = ((previous)["copy"])["children"];
|
|
1025
|
+
((output)[__eliscript_numeric_decrement((previous)["position"])] = completed);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
} else {
|
|
1031
|
+
{
|
|
1032
|
+
let child = ((((children) ?? [])[position]) ?? null);
|
|
1033
|
+
let child_copy = copy_wasm_expression_node(child, source, memory);
|
|
1034
|
+
((frame)["position"] = (position + 1));
|
|
1035
|
+
(((frame)["copy"])["children"])["push"](child_copy);
|
|
1036
|
+
(pending)["push"](({"source": child, "copy": child_copy, "position": 0}));
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
return copy;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
function copy_typed_wasm_program(program) {
|
|
1045
|
+
if ((!((!(program === 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; } })(program) === "object") && (!__eliscript_truthy(Array.isArray(program)))))) {
|
|
1046
|
+
backend_fail(null, "typed WASM emitter requires a program object");
|
|
1047
|
+
}
|
|
1048
|
+
{
|
|
1049
|
+
let functions = (program)["functions"];
|
|
1050
|
+
let copies = [];
|
|
1051
|
+
let memory = ((program)["abi"] === "memory-u32");
|
|
1052
|
+
let copy = Object.assign(({}), program);
|
|
1053
|
+
let index = 0;
|
|
1054
|
+
if ((!__eliscript_truthy(Array.isArray(functions)))) {
|
|
1055
|
+
backend_fail(program, "typed WASM emitter requires declared functions");
|
|
1056
|
+
}
|
|
1057
|
+
while (__eliscript_numeric_relation("<", index, ((functions) ?? []).length)) {
|
|
1058
|
+
{
|
|
1059
|
+
const __eliscript_value_72 = ((((functions) ?? [])[index]) ?? null);
|
|
1060
|
+
{
|
|
1061
|
+
let function$ = __eliscript_value_72;
|
|
1062
|
+
if ((!__eliscript_truthy(((__eliscript_value_73) => (__eliscript_truthy(__eliscript_value_73) ? ((__eliscript_value_74) => (__eliscript_truthy(__eliscript_value_74) ? ((__eliscript_value_75) => (__eliscript_truthy(__eliscript_value_75) ? Array.isArray((function$)["locals"]) : __eliscript_value_75))((!__eliscript_truthy(Array.isArray(function$)))) : __eliscript_value_74))((((__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; } })(function$) === "object")) : __eliscript_value_73))((!(function$ === null)))))) {
|
|
1063
|
+
backend_fail(program, "typed WASM function requires a locals array");
|
|
1064
|
+
}
|
|
1065
|
+
{
|
|
1066
|
+
const __eliscript_value_76 = Object.assign(({}), function$);
|
|
1067
|
+
{
|
|
1068
|
+
let function_copy = __eliscript_value_76;
|
|
1069
|
+
((function_copy)["locals"] = ((function$)["locals"])["slice"]());
|
|
1070
|
+
((function_copy)["body"] = copy_wasm_expression((function$)["body"], function$, memory));
|
|
1071
|
+
(copies)["push"](function_copy);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
((index = (index + 1)));
|
|
1077
|
+
}
|
|
1078
|
+
((copy)["functions"] = copies);
|
|
1079
|
+
return copy;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
function has_memory_access_p(expression) {
|
|
1083
|
+
return ((__eliscript_value_77) => (__eliscript_truthy(__eliscript_value_77) ? __eliscript_value_77 : ((expression)["children"])["some"](has_memory_access_p)))((((expression)["kind"] === "memory-op") && __eliscript_numeric_relation(">", memory_access_width((expression)["value"]), 0)));
|
|
1084
|
+
}
|
|
1085
|
+
function prepare_memory_scratch(function$) {
|
|
1086
|
+
if (__eliscript_truthy(has_memory_access_p((function$)["body"]))) {
|
|
1087
|
+
{
|
|
1088
|
+
let locals = (function$)["locals"];
|
|
1089
|
+
let base = ((locals) ?? []).length;
|
|
1090
|
+
(locals)["push"](({"name": "memory-address", "index": base, "type": "u32"}), ({"name": "memory-word", "index": (base + 1), "type": "u32"}), ({"name": "memory-float", "index": (base + 2), "type": "f64"}));
|
|
1091
|
+
return ({"word": ({"addressLocal": base, "valueLocal": (base + 1)}), "floating": ({"addressLocal": base, "valueLocal": (base + 2)})});
|
|
1092
|
+
}
|
|
1093
|
+
} else {
|
|
1094
|
+
return null;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
function memory_scratch_entry(output, expression) {
|
|
1098
|
+
{
|
|
1099
|
+
const __eliscript_value_78 = ((output)["wasmMemoryScratch"] ?? null);
|
|
1100
|
+
{
|
|
1101
|
+
let scratch = __eliscript_value_78;
|
|
1102
|
+
if (__eliscript_truthy(scratch)) {
|
|
1103
|
+
return (scratch)[(((expression)["value"] === "store-f64") ? "floating" : "word")];
|
|
1104
|
+
} else {
|
|
1105
|
+
return expression;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function emit_memory_guard(output, expression, width) {
|
|
1111
|
+
{
|
|
1112
|
+
const __eliscript_value_79 = memory_scratch_entry(output, expression);
|
|
1113
|
+
{
|
|
1114
|
+
let scratch = __eliscript_value_79;
|
|
1115
|
+
binary_push(output, 34);
|
|
1116
|
+
unsigned_leb(output, (scratch)["addressLocal"]);
|
|
1117
|
+
binary_push(output, 32);
|
|
1118
|
+
unsigned_leb(output, (scratch)["addressLocal"]);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
binary_push(output, 173, 66, width, 124, 63, 0, 173, 66, 16, 134, 86, 4, 64);
|
|
1122
|
+
emit_trapping_bytes(output, expression, [0], true);
|
|
1123
|
+
return binary_push(output, 11);
|
|
1124
|
+
}
|
|
1125
|
+
function emit_memory_op(output, expression) {
|
|
1126
|
+
{
|
|
1127
|
+
const __eliscript_value_80 = (expression)["children"];
|
|
1128
|
+
const __eliscript_value_81 = (expression)["value"];
|
|
1129
|
+
const __eliscript_value_82 = 0;
|
|
1130
|
+
{
|
|
1131
|
+
let children = __eliscript_value_80;
|
|
1132
|
+
let name = __eliscript_value_81;
|
|
1133
|
+
let i = __eliscript_value_82;
|
|
1134
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
1135
|
+
emit_expression(output, ((((children) ?? [])[i]) ?? null));
|
|
1136
|
+
((i = (i + 1)));
|
|
1137
|
+
}
|
|
1138
|
+
{
|
|
1139
|
+
const __eliscript_value_83 = memory_access_width(name);
|
|
1140
|
+
const __eliscript_value_84 = (((children) ?? []).length === 2);
|
|
1141
|
+
{
|
|
1142
|
+
let width = __eliscript_value_83;
|
|
1143
|
+
let store = __eliscript_value_84;
|
|
1144
|
+
if (__eliscript_numeric_relation(">", width, 0)) {
|
|
1145
|
+
if (__eliscript_truthy(store)) {
|
|
1146
|
+
binary_push(output, 33);
|
|
1147
|
+
unsigned_leb(output, (memory_scratch_entry(output, expression))["valueLocal"]);
|
|
1148
|
+
}
|
|
1149
|
+
emit_memory_guard(output, expression, width);
|
|
1150
|
+
if (__eliscript_truthy(store)) {
|
|
1151
|
+
binary_push(output, 32);
|
|
1152
|
+
unsigned_leb(output, (memory_scratch_entry(output, expression))["valueLocal"]);
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
if ((name === "load-u8")) {
|
|
1158
|
+
return binary_push(output, 45, 0, 0);
|
|
1159
|
+
} else {
|
|
1160
|
+
if ((name === "load-u16")) {
|
|
1161
|
+
return binary_push(output, 47, 1, 0);
|
|
1162
|
+
} else {
|
|
1163
|
+
if ((name === "load-u32")) {
|
|
1164
|
+
return binary_push(output, 40, 2, 0);
|
|
1165
|
+
} else {
|
|
1166
|
+
if ((name === "load-f64")) {
|
|
1167
|
+
return binary_push(output, 43, 3, 0);
|
|
1168
|
+
} else {
|
|
1169
|
+
if (__eliscript_truthy(memory_f64_unary_opcode(name))) {
|
|
1170
|
+
return binary_push(output, memory_f64_unary_opcode(name));
|
|
1171
|
+
} else {
|
|
1172
|
+
if ((name === "store-f64")) {
|
|
1173
|
+
return binary_push(output, 57, 3, 0, 65, 0);
|
|
1174
|
+
} else {
|
|
1175
|
+
if ((name === "store-u8")) {
|
|
1176
|
+
return binary_push(output, 58, 0, 0, 65, 0);
|
|
1177
|
+
} else {
|
|
1178
|
+
if ((name === "store-u16")) {
|
|
1179
|
+
return binary_push(output, 59, 1, 0, 65, 0);
|
|
1180
|
+
} else {
|
|
1181
|
+
if ((name === "store-u32")) {
|
|
1182
|
+
return binary_push(output, 54, 2, 0, 65, 0);
|
|
1183
|
+
} else {
|
|
1184
|
+
if ((name === "memory-size")) {
|
|
1185
|
+
return binary_push(output, 63, 0);
|
|
1186
|
+
} else {
|
|
1187
|
+
if ((name === "memory-grow")) {
|
|
1188
|
+
return binary_push(output, 64, 0);
|
|
1189
|
+
} else {
|
|
1190
|
+
if ((name === "word-div")) {
|
|
1191
|
+
return emit_trapping_bytes(output, expression, [110]);
|
|
1192
|
+
} else {
|
|
1193
|
+
if ((name === "word-shr")) {
|
|
1194
|
+
return binary_push(output, 118);
|
|
1195
|
+
} else {
|
|
1196
|
+
if ((name === "word-shl")) {
|
|
1197
|
+
return binary_push(output, 116);
|
|
1198
|
+
} else {
|
|
1199
|
+
if ((name === "word-and")) {
|
|
1200
|
+
return binary_push(output, 113);
|
|
1201
|
+
} else {
|
|
1202
|
+
if ((name === "word-or")) {
|
|
1203
|
+
return binary_push(output, 114);
|
|
1204
|
+
} else {
|
|
1205
|
+
if ((name === "word-xor")) {
|
|
1206
|
+
return binary_push(output, 115);
|
|
1207
|
+
} else {
|
|
1208
|
+
return backend_fail(expression, "unknown memory32 opcode");
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
function emit_memory_data_copy(output, expression) {
|
|
1230
|
+
{
|
|
1231
|
+
const __eliscript_value_85 = (expression)["value"];
|
|
1232
|
+
const __eliscript_value_86 = (expression)["children"];
|
|
1233
|
+
{
|
|
1234
|
+
let text = __eliscript_value_85;
|
|
1235
|
+
let children = __eliscript_value_86;
|
|
1236
|
+
require_memory_data_copy(expression, ((output)["wasmMemory"] ?? false));
|
|
1237
|
+
{
|
|
1238
|
+
let texts = (output)["wasmDataTexts"];
|
|
1239
|
+
let indices = (output)["wasmDataIndices"];
|
|
1240
|
+
let index = (indices)["get"](text);
|
|
1241
|
+
let instruction = [252, 8];
|
|
1242
|
+
if ((!__eliscript_truthy((indices)["has"](text)))) {
|
|
1243
|
+
((index = ((texts) ?? []).length));
|
|
1244
|
+
(texts)["push"](text);
|
|
1245
|
+
(indices)["set"](text, index);
|
|
1246
|
+
}
|
|
1247
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1248
|
+
binary_push(output, 65, 0, 65);
|
|
1249
|
+
signed_word_leb(output, __eliscript_numeric_mul(2, ((text) ?? []).length));
|
|
1250
|
+
unsigned_leb(instruction, index);
|
|
1251
|
+
(instruction)["push"](0);
|
|
1252
|
+
emit_trapping_bytes(output, expression, instruction);
|
|
1253
|
+
return binary_push(output, 65, 0);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
function data_uleb_size(value) {
|
|
1259
|
+
{
|
|
1260
|
+
const __eliscript_value_87 = 1;
|
|
1261
|
+
{
|
|
1262
|
+
let size = __eliscript_value_87;
|
|
1263
|
+
while (__eliscript_numeric_relation(">=", value, 128)) {
|
|
1264
|
+
((value = __eliscript_numeric_ushr(value, 7)), (size = (size + 1)));
|
|
1265
|
+
}
|
|
1266
|
+
return size;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
function append_passive_data(output, texts) {
|
|
1271
|
+
if (__eliscript_numeric_relation(">", ((texts) ?? []).length, 0)) {
|
|
1272
|
+
{
|
|
1273
|
+
const __eliscript_value_88 = data_uleb_size(((texts) ?? []).length);
|
|
1274
|
+
const __eliscript_value_89 = 0;
|
|
1275
|
+
{
|
|
1276
|
+
let size = __eliscript_value_88;
|
|
1277
|
+
let index = __eliscript_value_89;
|
|
1278
|
+
while (__eliscript_numeric_relation("<", index, ((texts) ?? []).length)) {
|
|
1279
|
+
{
|
|
1280
|
+
const __eliscript_value_90 = __eliscript_numeric_mul(2, ((((((texts) ?? [])[index]) ?? null)) ?? []).length);
|
|
1281
|
+
{
|
|
1282
|
+
let length = __eliscript_value_90;
|
|
1283
|
+
((size = (size + 1 + data_uleb_size(length) + length)));
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
((index = (index + 1)));
|
|
1287
|
+
}
|
|
1288
|
+
binary_push(output, 11);
|
|
1289
|
+
unsigned_leb(output, size);
|
|
1290
|
+
unsigned_leb(output, ((texts) ?? []).length);
|
|
1291
|
+
((index = 0));
|
|
1292
|
+
while (__eliscript_numeric_relation("<", index, ((texts) ?? []).length)) {
|
|
1293
|
+
{
|
|
1294
|
+
const __eliscript_value_91 = ((((texts) ?? [])[index]) ?? null);
|
|
1295
|
+
const __eliscript_value_92 = 0;
|
|
1296
|
+
{
|
|
1297
|
+
let text = __eliscript_value_91;
|
|
1298
|
+
let position = __eliscript_value_92;
|
|
1299
|
+
binary_push(output, 1);
|
|
1300
|
+
unsigned_leb(output, __eliscript_numeric_mul(2, ((text) ?? []).length));
|
|
1301
|
+
while (__eliscript_numeric_relation("<", position, ((text) ?? []).length)) {
|
|
1302
|
+
{
|
|
1303
|
+
const __eliscript_value_93 = (text).charCodeAt(position);
|
|
1304
|
+
{
|
|
1305
|
+
let unit = __eliscript_value_93;
|
|
1306
|
+
binary_push(output, __eliscript_numeric_and(unit, 255), __eliscript_numeric_ushr(unit, 8));
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
((position = (position + 1)));
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
((index = (index + 1)));
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return output;
|
|
1319
|
+
}
|
|
1320
|
+
function append_trap_site_section(output, sites) {
|
|
1321
|
+
{
|
|
1322
|
+
const __eliscript_value_94 = "eliscript-trap-sites";
|
|
1323
|
+
const __eliscript_value_95 = 2;
|
|
1324
|
+
const __eliscript_value_96 = 0;
|
|
1325
|
+
{
|
|
1326
|
+
let name = __eliscript_value_94;
|
|
1327
|
+
let length = __eliscript_value_95;
|
|
1328
|
+
let index = __eliscript_value_96;
|
|
1329
|
+
while (__eliscript_numeric_relation("<", index, ((sites) ?? []).length)) {
|
|
1330
|
+
((length = (length + ((JSON.stringify(((((sites) ?? [])[index]) ?? null))) ?? []).length + (__eliscript_numeric_relation(">", index, 0) ? 1 : 0))));
|
|
1331
|
+
((index = (index + 1)));
|
|
1332
|
+
}
|
|
1333
|
+
binary_byte(output, 0);
|
|
1334
|
+
unsigned_leb(output, (data_uleb_size(((name) ?? []).length) + ((name) ?? []).length + data_uleb_size(length) + length));
|
|
1335
|
+
utf8_name(output, name);
|
|
1336
|
+
unsigned_leb(output, length);
|
|
1337
|
+
binary_byte(output, 91);
|
|
1338
|
+
((index = 0));
|
|
1339
|
+
while (__eliscript_numeric_relation("<", index, ((sites) ?? []).length)) {
|
|
1340
|
+
if (__eliscript_numeric_relation(">", index, 0)) {
|
|
1341
|
+
binary_byte(output, 44);
|
|
1342
|
+
}
|
|
1343
|
+
{
|
|
1344
|
+
const __eliscript_value_97 = JSON.stringify(((((sites) ?? [])[index]) ?? null));
|
|
1345
|
+
const __eliscript_value_98 = 0;
|
|
1346
|
+
{
|
|
1347
|
+
let text = __eliscript_value_97;
|
|
1348
|
+
let position = __eliscript_value_98;
|
|
1349
|
+
while (__eliscript_numeric_relation("<", position, ((text) ?? []).length)) {
|
|
1350
|
+
binary_byte(output, (text).charCodeAt(position));
|
|
1351
|
+
((position = (position + 1)));
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
((index = (index + 1)));
|
|
1356
|
+
}
|
|
1357
|
+
binary_byte(output, 93);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
return output;
|
|
1361
|
+
}
|
|
1362
|
+
function emit_expression(output, expression) {
|
|
1363
|
+
{
|
|
1364
|
+
const __eliscript_value_99 = debug_range_start(output, expression, "expression");
|
|
1365
|
+
{
|
|
1366
|
+
let range = __eliscript_value_99;
|
|
1367
|
+
{
|
|
1368
|
+
const __eliscript_value_100 = emit_expression_body(output, expression);
|
|
1369
|
+
{
|
|
1370
|
+
let result = __eliscript_value_100;
|
|
1371
|
+
debug_range_end(output, range);
|
|
1372
|
+
return result;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
function emit_expression_body(output, expression) {
|
|
1379
|
+
{
|
|
1380
|
+
const __eliscript_value_101 = (expression)["kind"];
|
|
1381
|
+
const __eliscript_value_102 = (expression)["children"];
|
|
1382
|
+
const __eliscript_value_103 = (expression)["value"];
|
|
1383
|
+
{
|
|
1384
|
+
let kind = __eliscript_value_101;
|
|
1385
|
+
let children = __eliscript_value_102;
|
|
1386
|
+
let value = __eliscript_value_103;
|
|
1387
|
+
if ((kind === "memory-op")) {
|
|
1388
|
+
return emit_memory_op(output, expression);
|
|
1389
|
+
} else {
|
|
1390
|
+
if ((kind === "memory-data-copy")) {
|
|
1391
|
+
return emit_memory_data_copy(output, expression);
|
|
1392
|
+
} else {
|
|
1393
|
+
if ((kind === "word-arithmetic")) {
|
|
1394
|
+
return emit_word_arithmetic(output, expression);
|
|
1395
|
+
} else {
|
|
1396
|
+
if ((kind === "word-compare")) {
|
|
1397
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1398
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
1399
|
+
return binary_push(output, ((value === "=") ? 70 : ((value === "/=") ? 71 : ((value === "<") ? 73 : ((value === ">") ? 75 : ((value === "<=") ? 77 : 79))))));
|
|
1400
|
+
} else {
|
|
1401
|
+
if ((kind === "int-number")) {
|
|
1402
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1403
|
+
return binary_push(output, 183);
|
|
1404
|
+
} else {
|
|
1405
|
+
if ((kind === "int-literal")) {
|
|
1406
|
+
binary_push(output, 65);
|
|
1407
|
+
return signed_word_leb(output, value);
|
|
1408
|
+
} else {
|
|
1409
|
+
if (((kind === "int-add") || (kind === "int-sub") || (kind === "int-and"))) {
|
|
1410
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1411
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
1412
|
+
return binary_push(output, ((kind === "int-add") ? 106 : ((kind === "int-sub") ? 107 : 113)));
|
|
1413
|
+
} else {
|
|
1414
|
+
if ((kind === "int-compare")) {
|
|
1415
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1416
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
1417
|
+
return binary_push(output, 72);
|
|
1418
|
+
} else {
|
|
1419
|
+
if ((kind === "ceil-int")) {
|
|
1420
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1421
|
+
binary_push(output, 155);
|
|
1422
|
+
return emit_trapping_bytes(output, expression, [170]);
|
|
1423
|
+
} else {
|
|
1424
|
+
if ((kind === "literal")) {
|
|
1425
|
+
if (((expression)["type"] === "f64")) {
|
|
1426
|
+
binary_push(output, 68);
|
|
1427
|
+
return float64_bytes(output, value);
|
|
1428
|
+
} else {
|
|
1429
|
+
if ((((expression)["type"] === "u32") || ((expression)["type"] === "i32"))) {
|
|
1430
|
+
binary_push(output, 65);
|
|
1431
|
+
return signed_word_leb(output, value);
|
|
1432
|
+
} else {
|
|
1433
|
+
return binary_push(output, 65, value);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
} else {
|
|
1437
|
+
if ((kind === "local")) {
|
|
1438
|
+
binary_push(output, 32);
|
|
1439
|
+
return unsigned_leb(output, value);
|
|
1440
|
+
} else {
|
|
1441
|
+
if (((kind === "set") || (kind === "initialize"))) {
|
|
1442
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1443
|
+
binary_push(output, 34);
|
|
1444
|
+
return unsigned_leb(output, value);
|
|
1445
|
+
} else {
|
|
1446
|
+
if ((kind === "sequence")) {
|
|
1447
|
+
return emit_sequence(output, children);
|
|
1448
|
+
} else {
|
|
1449
|
+
if ((kind === "arithmetic")) {
|
|
1450
|
+
return emit_arithmetic(output, expression);
|
|
1451
|
+
} else {
|
|
1452
|
+
if ((kind === "compare")) {
|
|
1453
|
+
emit_expression(output, ((((children) ?? [])[0]) ?? null));
|
|
1454
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
1455
|
+
return binary_push(output, ((value === "=") ? 97 : ((value === "/=") ? 98 : ((value === "<") ? 99 : ((value === ">") ? 100 : ((value === "<=") ? 101 : 102))))));
|
|
1456
|
+
} else {
|
|
1457
|
+
if ((kind === "not")) {
|
|
1458
|
+
emit_condition(output, ((((children) ?? [])[0]) ?? null));
|
|
1459
|
+
return binary_push(output, 69);
|
|
1460
|
+
} else {
|
|
1461
|
+
if ((kind === "if")) {
|
|
1462
|
+
if (__eliscript_truthy(((__eliscript_value_104) => (__eliscript_truthy(__eliscript_value_104) ? ((__eliscript_value_105) => (__eliscript_truthy(__eliscript_value_105) ? ((__eliscript_value_106) => (__eliscript_truthy(__eliscript_value_106) ? __eliscript_numeric_relation("<=", (tree_size(((((children) ?? [])[1]) ?? null)) + tree_size(((((children) ?? [])[2]) ?? null))), 8) : __eliscript_value_106))(numeric_pure(((((children) ?? [])[2]) ?? null))) : __eliscript_value_105))(numeric_pure(((((children) ?? [])[1]) ?? null))) : __eliscript_value_104))(numeric_pure(((((children) ?? [])[0]) ?? null))))) {
|
|
1463
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
1464
|
+
emit_expression(output, ((((children) ?? [])[2]) ?? null));
|
|
1465
|
+
emit_condition(output, ((((children) ?? [])[0]) ?? null));
|
|
1466
|
+
return binary_push(output, 27);
|
|
1467
|
+
} else {
|
|
1468
|
+
emit_condition(output, ((((children) ?? [])[0]) ?? null));
|
|
1469
|
+
binary_push(output, 4, result_byte((expression)["type"]));
|
|
1470
|
+
emit_expression(output, ((((children) ?? [])[1]) ?? null));
|
|
1471
|
+
binary_push(output, 5);
|
|
1472
|
+
emit_expression(output, ((((children) ?? [])[2]) ?? null));
|
|
1473
|
+
return binary_push(output, 11);
|
|
1474
|
+
}
|
|
1475
|
+
} else {
|
|
1476
|
+
if (((kind === "while") || (kind === "remainder-while"))) {
|
|
1477
|
+
emit_while(output, children);
|
|
1478
|
+
return binary_push(output, 65, 0);
|
|
1479
|
+
} else {
|
|
1480
|
+
if ((kind === "guarded-while")) {
|
|
1481
|
+
emit_guarded_while(output, children);
|
|
1482
|
+
return binary_push(output, 65, 0);
|
|
1483
|
+
} else {
|
|
1484
|
+
if ((kind === "guarded-counter-while")) {
|
|
1485
|
+
emit_counter_guarded_while(output, children);
|
|
1486
|
+
return binary_push(output, 65, 0);
|
|
1487
|
+
} else {
|
|
1488
|
+
if (((kind === "and") || (kind === "or"))) {
|
|
1489
|
+
return emit_short_circuit(output, expression, 0);
|
|
1490
|
+
} else {
|
|
1491
|
+
if ((kind === "call")) {
|
|
1492
|
+
{
|
|
1493
|
+
const __eliscript_value_107 = 0;
|
|
1494
|
+
{
|
|
1495
|
+
let index = __eliscript_value_107;
|
|
1496
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
1497
|
+
emit_expression(output, ((((children) ?? [])[index]) ?? null));
|
|
1498
|
+
((index = (index + 1)));
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
{
|
|
1503
|
+
const __eliscript_value_108 = [16];
|
|
1504
|
+
{
|
|
1505
|
+
let instruction = __eliscript_value_108;
|
|
1506
|
+
unsigned_leb(instruction, (value + ((output)["wasmFunctionBase"] ?? 0)));
|
|
1507
|
+
return emit_trapping_bytes(output, expression, instruction);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
} else {
|
|
1511
|
+
if ((kind === "host-call")) {
|
|
1512
|
+
{
|
|
1513
|
+
const __eliscript_value_109 = 0;
|
|
1514
|
+
{
|
|
1515
|
+
let index = __eliscript_value_109;
|
|
1516
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
1517
|
+
emit_expression(output, ((((children) ?? [])[index]) ?? null));
|
|
1518
|
+
((index = (index + 1)));
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
{
|
|
1523
|
+
const __eliscript_value_110 = [16];
|
|
1524
|
+
{
|
|
1525
|
+
let instruction = __eliscript_value_110;
|
|
1526
|
+
unsigned_leb(instruction, host_capability_index((output)["wasmHostCapabilities"], expression));
|
|
1527
|
+
return emit_trapping_bytes(output, expression, instruction);
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
} else {
|
|
1531
|
+
if ((kind === "call-indirect")) {
|
|
1532
|
+
{
|
|
1533
|
+
const __eliscript_value_111 = 0;
|
|
1534
|
+
{
|
|
1535
|
+
let index = __eliscript_value_111;
|
|
1536
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
1537
|
+
emit_expression(output, ((((children) ?? [])[index]) ?? null));
|
|
1538
|
+
((index = (index + 1)));
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
{
|
|
1543
|
+
const __eliscript_value_112 = [17];
|
|
1544
|
+
{
|
|
1545
|
+
let instruction = __eliscript_value_112;
|
|
1546
|
+
unsigned_leb(instruction, (expression)["signatureIndex"]);
|
|
1547
|
+
(instruction)["push"](0);
|
|
1548
|
+
return emit_trapping_bytes(output, expression, instruction);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
} else {
|
|
1552
|
+
return backend_fail(expression, (String("unknown typed WASM expression: ") + String(kind)));
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}
|
|
1580
|
+
function prepare_indirect_calls(expression, arities, enabled) {
|
|
1581
|
+
{
|
|
1582
|
+
const __eliscript_value_113 = (expression)["children"];
|
|
1583
|
+
const __eliscript_value_114 = 0;
|
|
1584
|
+
{
|
|
1585
|
+
let children = __eliscript_value_113;
|
|
1586
|
+
let index = __eliscript_value_114;
|
|
1587
|
+
if (((expression)["kind"] === "call-indirect")) {
|
|
1588
|
+
{
|
|
1589
|
+
const __eliscript_value_115 = (expression)["value"];
|
|
1590
|
+
const __eliscript_value_116 = 0;
|
|
1591
|
+
{
|
|
1592
|
+
let arity = __eliscript_value_115;
|
|
1593
|
+
let signature = __eliscript_value_116;
|
|
1594
|
+
if ((!__eliscript_truthy(((__eliscript_value_117) => (__eliscript_truthy(__eliscript_value_117) ? ((((__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; } })(arity) === "number") && (arity === __eliscript_numeric_uint32(arity)) && (((children) ?? []).length === (arity + 1))) : __eliscript_value_117))(enabled)))) {
|
|
1595
|
+
backend_fail(expression, "indirect calls require a memory-u32 table and an exact signature");
|
|
1596
|
+
}
|
|
1597
|
+
while ((__eliscript_numeric_relation("<", signature, ((arities) ?? []).length) && ((__eliscript_value_118, __eliscript_value_119) => (__eliscript_value_118 !== __eliscript_value_119))(((((arities) ?? [])[signature]) ?? null), arity))) {
|
|
1598
|
+
((signature = (signature + 1)));
|
|
1599
|
+
}
|
|
1600
|
+
if ((signature === ((arities) ?? []).length)) {
|
|
1601
|
+
backend_fail(expression, "unknown indirect call signature");
|
|
1602
|
+
}
|
|
1603
|
+
((expression)["signatureIndex"] = signature);
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
while (__eliscript_numeric_relation("<", index, ((children) ?? []).length)) {
|
|
1608
|
+
prepare_indirect_calls(((((children) ?? [])[index]) ?? null), arities, enabled);
|
|
1609
|
+
((index = (index + 1)));
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
return expression;
|
|
1614
|
+
}
|
|
1615
|
+
function emit_typed_scalar_wasm(program, options, debug = null, consume_owned_bodies = null) {
|
|
1616
|
+
{
|
|
1617
|
+
let memory = ((program)["abi"] === "memory-u32");
|
|
1618
|
+
let scalar_byte = (__eliscript_truthy(memory) ? 127 : 124);
|
|
1619
|
+
let initial = ((options)["initialPages"] ?? 1);
|
|
1620
|
+
let maximum = ((options)["maximumPages"] ?? 256);
|
|
1621
|
+
let functions = (program)["functions"];
|
|
1622
|
+
let table = ((program)["table"] ?? null);
|
|
1623
|
+
let capabilities = prepare_host_capabilities(program);
|
|
1624
|
+
let host_count = ((capabilities) ?? []).length;
|
|
1625
|
+
let arities = [];
|
|
1626
|
+
let type_indices = [];
|
|
1627
|
+
let types = null;
|
|
1628
|
+
let declarations = null;
|
|
1629
|
+
let imports = null;
|
|
1630
|
+
let exports = null;
|
|
1631
|
+
let bodies = null;
|
|
1632
|
+
let memory_scratch = [];
|
|
1633
|
+
let data_texts = [];
|
|
1634
|
+
let data_indices = new (globalThis.Map)();
|
|
1635
|
+
let output = null;
|
|
1636
|
+
let index = 0;
|
|
1637
|
+
if (__eliscript_truthy(memory)) {
|
|
1638
|
+
if ((!((initial === __eliscript_numeric_uint32(initial)) && (maximum === __eliscript_numeric_uint32(maximum)) && __eliscript_numeric_relation(">=", initial, 1) && __eliscript_numeric_relation("<=", initial, maximum) && __eliscript_numeric_relation("<=", maximum, 65535)))) {
|
|
1639
|
+
backend_fail(program, "memory32 requires 1 <= initialPages <= maximumPages <= 65535");
|
|
1640
|
+
}
|
|
1641
|
+
if (__eliscript_truthy(find_function(functions, "memory"))) {
|
|
1642
|
+
backend_fail(program, "memory32 reserves the memory export name");
|
|
1643
|
+
}
|
|
1644
|
+
{
|
|
1645
|
+
const __eliscript_value_120 = 0;
|
|
1646
|
+
{
|
|
1647
|
+
let position = __eliscript_value_120;
|
|
1648
|
+
while (__eliscript_numeric_relation("<", position, ((functions) ?? []).length)) {
|
|
1649
|
+
(memory_scratch)["push"](prepare_memory_scratch(((((functions) ?? [])[position]) ?? null)));
|
|
1650
|
+
((position = (position + 1)));
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
if (__eliscript_truthy(debug)) {
|
|
1656
|
+
if (__eliscript_truthy(((__eliscript_value_121) => (__eliscript_truthy(__eliscript_value_121) ? __eliscript_value_121 : (((program)["aliases"] ?? []))["some"](((item) => {
|
|
1657
|
+
return ((item)["name"] === "__eliscript_trap_site");
|
|
1658
|
+
}))))(((program)["exports"])["includes"]("__eliscript_trap_site")))) {
|
|
1659
|
+
backend_fail(program, "debug WASM reserves the trap site export name");
|
|
1660
|
+
}
|
|
1661
|
+
((debug)["trapSites"] = []);
|
|
1662
|
+
}
|
|
1663
|
+
while (__eliscript_numeric_relation("<", index, ((functions) ?? []).length)) {
|
|
1664
|
+
{
|
|
1665
|
+
let arity = (((((functions) ?? [])[index]) ?? null))["arity"];
|
|
1666
|
+
let position = 0;
|
|
1667
|
+
while ((__eliscript_numeric_relation("<", position, ((arities) ?? []).length) && ((__eliscript_value_122, __eliscript_value_123) => (__eliscript_value_122 !== __eliscript_value_123))(((((arities) ?? [])[position]) ?? null), arity))) {
|
|
1668
|
+
((position = (position + 1)));
|
|
1669
|
+
}
|
|
1670
|
+
if ((position === ((arities) ?? []).length)) {
|
|
1671
|
+
(arities)["push"](arity);
|
|
1672
|
+
}
|
|
1673
|
+
(type_indices)["push"](position);
|
|
1674
|
+
}
|
|
1675
|
+
((index = (index + 1)));
|
|
1676
|
+
}
|
|
1677
|
+
if (__eliscript_truthy(table)) {
|
|
1678
|
+
if ((!__eliscript_truthy(((__eliscript_value_124) => (__eliscript_truthy(__eliscript_value_124) ? Array.isArray(table) : __eliscript_value_124))(memory)))) {
|
|
1679
|
+
backend_fail(program, "WASM function tables require memory-u32 input");
|
|
1680
|
+
}
|
|
1681
|
+
{
|
|
1682
|
+
const __eliscript_value_125 = 0;
|
|
1683
|
+
{
|
|
1684
|
+
let position = __eliscript_value_125;
|
|
1685
|
+
while (__eliscript_numeric_relation("<", position, ((table) ?? []).length)) {
|
|
1686
|
+
{
|
|
1687
|
+
const __eliscript_value_126 = ((((table) ?? [])[position]) ?? null);
|
|
1688
|
+
{
|
|
1689
|
+
let target = __eliscript_value_126;
|
|
1690
|
+
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; } })(target) === "number") && (target === __eliscript_numeric_uint32(target)) && __eliscript_numeric_relation("<", target, ((functions) ?? []).length)))) {
|
|
1691
|
+
backend_fail(program, "WASM table entry is not a declared function index");
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
((position = (position + 1)));
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
{
|
|
1701
|
+
const __eliscript_value_127 = (__eliscript_truthy(Object.prototype.hasOwnProperty.call((program) ?? {}, "indirectArities")) ? ((program)["indirectArities"] ?? null) : []);
|
|
1702
|
+
const __eliscript_value_128 = 0;
|
|
1703
|
+
{
|
|
1704
|
+
let declared = __eliscript_value_127;
|
|
1705
|
+
let position = __eliscript_value_128;
|
|
1706
|
+
if ((!__eliscript_truthy(((__eliscript_value_129) => (__eliscript_truthy(__eliscript_value_129) ? ((__eliscript_value_130) => (__eliscript_truthy(__eliscript_value_130) ? __eliscript_value_130 : ((__eliscript_value_131) => (__eliscript_truthy(__eliscript_value_131) ? table : __eliscript_value_131))(memory)))((((declared) ?? []).length === 0)) : __eliscript_value_129))(Array.isArray(declared))))) {
|
|
1707
|
+
backend_fail(program, "indirect signature declarations require a memory-u32 table");
|
|
1708
|
+
}
|
|
1709
|
+
while (__eliscript_numeric_relation("<", position, ((declared) ?? []).length)) {
|
|
1710
|
+
{
|
|
1711
|
+
const __eliscript_value_132 = ((((declared) ?? [])[position]) ?? null);
|
|
1712
|
+
const __eliscript_value_133 = 0;
|
|
1713
|
+
{
|
|
1714
|
+
let arity = __eliscript_value_132;
|
|
1715
|
+
let signature = __eliscript_value_133;
|
|
1716
|
+
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; } })(arity) === "number") && (arity === __eliscript_numeric_uint32(arity)) && __eliscript_numeric_relation("<=", arity, 65535)))) {
|
|
1717
|
+
backend_fail(program, "invalid indirect signature arity");
|
|
1718
|
+
}
|
|
1719
|
+
while ((__eliscript_numeric_relation("<", signature, ((arities) ?? []).length) && ((__eliscript_value_134, __eliscript_value_135) => (__eliscript_value_134 !== __eliscript_value_135))(((((arities) ?? [])[signature]) ?? null), arity))) {
|
|
1720
|
+
((signature = (signature + 1)));
|
|
1721
|
+
}
|
|
1722
|
+
if ((signature === ((arities) ?? []).length)) {
|
|
1723
|
+
(arities)["push"](arity);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
((position = (position + 1)));
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
((output = binary_output(options)));
|
|
1732
|
+
((types = binary_child(output)), (declarations = binary_child(output)), (imports = binary_child(output)), (exports = binary_child(output)), (bodies = binary_child(output)));
|
|
1733
|
+
append_bytes(output, [0, 97, 115, 109, 1, 0, 0, 0]);
|
|
1734
|
+
if (__eliscript_numeric_relation(">", host_count, 0)) {
|
|
1735
|
+
{
|
|
1736
|
+
const __eliscript_value_136 = 0;
|
|
1737
|
+
{
|
|
1738
|
+
let signature = __eliscript_value_136;
|
|
1739
|
+
while ((__eliscript_numeric_relation("<", signature, ((arities) ?? []).length) && ((__eliscript_value_137, __eliscript_value_138) => (__eliscript_value_137 !== __eliscript_value_138))(((((arities) ?? [])[signature]) ?? null), 2))) {
|
|
1740
|
+
((signature = (signature + 1)));
|
|
1741
|
+
}
|
|
1742
|
+
if ((signature === ((arities) ?? []).length)) {
|
|
1743
|
+
(arities)["push"](2);
|
|
1744
|
+
}
|
|
1745
|
+
unsigned_leb(imports, host_count);
|
|
1746
|
+
{
|
|
1747
|
+
const __eliscript_value_139 = 0;
|
|
1748
|
+
{
|
|
1749
|
+
let position = __eliscript_value_139;
|
|
1750
|
+
while (__eliscript_numeric_relation("<", position, host_count)) {
|
|
1751
|
+
{
|
|
1752
|
+
const __eliscript_value_140 = ((((capabilities) ?? [])[position]) ?? null);
|
|
1753
|
+
{
|
|
1754
|
+
let capability = __eliscript_value_140;
|
|
1755
|
+
utf8_name(imports, (capability)["module"]);
|
|
1756
|
+
utf8_name(imports, (capability)["name"]);
|
|
1757
|
+
binary_push(imports, 0);
|
|
1758
|
+
unsigned_leb(imports, signature);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
((position = (position + 1)));
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
((index = 0));
|
|
1769
|
+
while (__eliscript_numeric_relation("<", index, ((functions) ?? []).length)) {
|
|
1770
|
+
prepare_indirect_calls((((((functions) ?? [])[index]) ?? null))["body"], arities, ((__eliscript_value_141) => (__eliscript_truthy(__eliscript_value_141) ? table : __eliscript_value_141))(memory));
|
|
1771
|
+
((index = (index + 1)));
|
|
1772
|
+
}
|
|
1773
|
+
unsigned_leb(types, ((arities) ?? []).length);
|
|
1774
|
+
((index = 0));
|
|
1775
|
+
while (__eliscript_numeric_relation("<", index, ((arities) ?? []).length)) {
|
|
1776
|
+
binary_push(types, 96);
|
|
1777
|
+
unsigned_leb(types, ((((arities) ?? [])[index]) ?? null));
|
|
1778
|
+
{
|
|
1779
|
+
const __eliscript_value_142 = 0;
|
|
1780
|
+
{
|
|
1781
|
+
let parameter = __eliscript_value_142;
|
|
1782
|
+
while (__eliscript_numeric_relation("<", parameter, ((((arities) ?? [])[index]) ?? null))) {
|
|
1783
|
+
binary_push(types, scalar_byte);
|
|
1784
|
+
((parameter = (parameter + 1)));
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
binary_push(types, 1, scalar_byte);
|
|
1789
|
+
((index = (index + 1)));
|
|
1790
|
+
}
|
|
1791
|
+
unsigned_leb(declarations, ((functions) ?? []).length);
|
|
1792
|
+
((index = 0));
|
|
1793
|
+
while (__eliscript_numeric_relation("<", index, ((functions) ?? []).length)) {
|
|
1794
|
+
unsigned_leb(declarations, ((((type_indices) ?? [])[index]) ?? null));
|
|
1795
|
+
((index = (index + 1)));
|
|
1796
|
+
}
|
|
1797
|
+
unsigned_leb(exports, ((((program)["exports"]) ?? []).length + ((((program)["aliases"] ?? [])) ?? []).length + (__eliscript_truthy(memory) ? 1 : 0) + (__eliscript_truthy(debug) ? 1 : 0)));
|
|
1798
|
+
if (__eliscript_truthy(memory)) {
|
|
1799
|
+
utf8_name(exports, "memory");
|
|
1800
|
+
binary_push(exports, 2, 0);
|
|
1801
|
+
}
|
|
1802
|
+
if (__eliscript_truthy(debug)) {
|
|
1803
|
+
utf8_name(exports, "__eliscript_trap_site");
|
|
1804
|
+
binary_push(exports, 3, 0);
|
|
1805
|
+
}
|
|
1806
|
+
((index = 0));
|
|
1807
|
+
while (__eliscript_numeric_relation("<", index, (((program)["exports"]) ?? []).length)) {
|
|
1808
|
+
{
|
|
1809
|
+
const __eliscript_value_143 = (((((program)["exports"]) ?? [])[index]) ?? null);
|
|
1810
|
+
{
|
|
1811
|
+
let name = __eliscript_value_143;
|
|
1812
|
+
utf8_name(exports, name);
|
|
1813
|
+
binary_push(exports, 0);
|
|
1814
|
+
unsigned_leb(exports, (host_count + (find_function(functions, name))["index"]));
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
((index = (index + 1)));
|
|
1818
|
+
}
|
|
1819
|
+
((index = 0));
|
|
1820
|
+
while (__eliscript_numeric_relation("<", index, ((((program)["aliases"] ?? [])) ?? []).length)) {
|
|
1821
|
+
{
|
|
1822
|
+
let alias = (((((program)["aliases"]) ?? [])[index]) ?? null);
|
|
1823
|
+
let function$ = find_function(functions, (alias)["function"]);
|
|
1824
|
+
if ((!__eliscript_truthy(function$))) {
|
|
1825
|
+
backend_fail(program, "unknown WASM export alias target");
|
|
1826
|
+
}
|
|
1827
|
+
utf8_name(exports, (alias)["name"]);
|
|
1828
|
+
binary_push(exports, 0);
|
|
1829
|
+
unsigned_leb(exports, (host_count + (function$)["index"]));
|
|
1830
|
+
}
|
|
1831
|
+
((index = (index + 1)));
|
|
1832
|
+
}
|
|
1833
|
+
unsigned_leb(bodies, ((functions) ?? []).length);
|
|
1834
|
+
((index = 0));
|
|
1835
|
+
while (__eliscript_numeric_relation("<", index, ((functions) ?? []).length)) {
|
|
1836
|
+
{
|
|
1837
|
+
let function$ = ((((functions) ?? [])[index]) ?? null);
|
|
1838
|
+
let body = binary_child(output);
|
|
1839
|
+
let locals = (function$)["locals"];
|
|
1840
|
+
let count = __eliscript_numeric_sub(((locals) ?? []).length, (function$)["arity"]);
|
|
1841
|
+
let position = (function$)["arity"];
|
|
1842
|
+
let range_start = (__eliscript_truthy(debug) ? (((debug)["ranges"]) ?? []).length : 0);
|
|
1843
|
+
let local_entries_start = 0;
|
|
1844
|
+
let instructions_start = 0;
|
|
1845
|
+
((body)["wasmFunctionBase"] = host_count);
|
|
1846
|
+
((body)["wasmHostCapabilities"] = capabilities);
|
|
1847
|
+
((body)["wasmMemory"] = memory);
|
|
1848
|
+
((body)["wasmDataTexts"] = data_texts);
|
|
1849
|
+
if (__eliscript_truthy(memory)) {
|
|
1850
|
+
((body)["wasmMemoryScratch"] = ((((memory_scratch) ?? [])[index]) ?? null));
|
|
1851
|
+
}
|
|
1852
|
+
((body)["wasmDataIndices"] = data_indices);
|
|
1853
|
+
if (__eliscript_truthy(debug)) {
|
|
1854
|
+
((body)["wasmDebug"] = ({"ranges": (debug)["ranges"], "depth": 0, "trapSites": (debug)["trapSites"], "function": (function$)["name"], "functionIndex": (host_count + index)}));
|
|
1855
|
+
}
|
|
1856
|
+
unsigned_leb(body, count);
|
|
1857
|
+
((local_entries_start = ((body) ?? []).length));
|
|
1858
|
+
while (__eliscript_numeric_relation("<", position, ((locals) ?? []).length)) {
|
|
1859
|
+
binary_push(body, 1, result_byte((((((locals) ?? [])[position]) ?? null))["type"]));
|
|
1860
|
+
((position = (position + 1)));
|
|
1861
|
+
}
|
|
1862
|
+
((instructions_start = ((body) ?? []).length));
|
|
1863
|
+
emit_expression(body, (function$)["body"]);
|
|
1864
|
+
binary_push(body, 11);
|
|
1865
|
+
{
|
|
1866
|
+
const __eliscript_value_144 = ((bodies) ?? []).length;
|
|
1867
|
+
{
|
|
1868
|
+
let size_start = __eliscript_value_144;
|
|
1869
|
+
unsigned_leb(bodies, ((body) ?? []).length);
|
|
1870
|
+
if (__eliscript_truthy(debug)) {
|
|
1871
|
+
{
|
|
1872
|
+
let body_start = ((bodies) ?? []).length;
|
|
1873
|
+
let body_end = (body_start + ((body) ?? []).length);
|
|
1874
|
+
let source = ((function$)["source"] ?? null);
|
|
1875
|
+
let ranges = (debug)["ranges"];
|
|
1876
|
+
let i = range_start;
|
|
1877
|
+
while (__eliscript_numeric_relation("<", i, ((ranges) ?? []).length)) {
|
|
1878
|
+
{
|
|
1879
|
+
const __eliscript_value_145 = ((((ranges) ?? [])[i]) ?? null);
|
|
1880
|
+
{
|
|
1881
|
+
let range = __eliscript_value_145;
|
|
1882
|
+
((range)["start"] = (body_start + (range)["start"]));
|
|
1883
|
+
((range)["end"] = (body_start + (range)["end"]));
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
((i = (i + 1)));
|
|
1887
|
+
}
|
|
1888
|
+
((debug)["functions"])["push"](({"name": (function$)["name"], "index": (host_count + index), "span": ((function$)["span"] ?? (__eliscript_truthy(source) ? ((source)["span"] ?? null) : null)), "sizeField": ({"start": size_start, "end": body_start}), "body": ({"start": body_start, "end": body_end}), "locals": ({"start": body_start, "entriesStart": (body_start + local_entries_start), "end": (body_start + instructions_start), "count": count}), "instructions": ({"start": (body_start + instructions_start), "end": body_end})}));
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
binary_append_owned(bodies, body);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
if (__eliscript_truthy(consume_owned_bodies)) {
|
|
1895
|
+
((function$)["body"] = null);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
((index = (index + 1)));
|
|
1899
|
+
}
|
|
1900
|
+
section(output, 1, types);
|
|
1901
|
+
if (__eliscript_numeric_relation(">", host_count, 0)) {
|
|
1902
|
+
section(output, 2, imports);
|
|
1903
|
+
}
|
|
1904
|
+
section(output, 3, declarations);
|
|
1905
|
+
if (__eliscript_truthy(table)) {
|
|
1906
|
+
{
|
|
1907
|
+
const __eliscript_value_146 = [1, 112, 0];
|
|
1908
|
+
{
|
|
1909
|
+
let declaration = __eliscript_value_146;
|
|
1910
|
+
unsigned_leb(declaration, ((table) ?? []).length);
|
|
1911
|
+
section(output, 4, declaration);
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
if (__eliscript_truthy(memory)) {
|
|
1916
|
+
{
|
|
1917
|
+
const __eliscript_value_147 = [1, 1];
|
|
1918
|
+
{
|
|
1919
|
+
let limits = __eliscript_value_147;
|
|
1920
|
+
unsigned_leb(limits, initial);
|
|
1921
|
+
unsigned_leb(limits, maximum);
|
|
1922
|
+
section(output, 5, limits);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
if (__eliscript_truthy(debug)) {
|
|
1927
|
+
section(output, 6, [1, 127, 1, 65, 0, 11]);
|
|
1928
|
+
}
|
|
1929
|
+
section(output, 7, exports);
|
|
1930
|
+
if (__eliscript_truthy(table)) {
|
|
1931
|
+
{
|
|
1932
|
+
const __eliscript_value_148 = binary_child(output);
|
|
1933
|
+
const __eliscript_value_149 = 0;
|
|
1934
|
+
{
|
|
1935
|
+
let elements = __eliscript_value_148;
|
|
1936
|
+
let position = __eliscript_value_149;
|
|
1937
|
+
append_bytes(elements, [1, 0, 65, 0, 11]);
|
|
1938
|
+
unsigned_leb(elements, ((table) ?? []).length);
|
|
1939
|
+
while (__eliscript_numeric_relation("<", position, ((table) ?? []).length)) {
|
|
1940
|
+
unsigned_leb(elements, (host_count + ((((table) ?? [])[position]) ?? null)));
|
|
1941
|
+
((position = (position + 1)));
|
|
1942
|
+
}
|
|
1943
|
+
section(output, 9, elements);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
if (__eliscript_numeric_relation(">", ((data_texts) ?? []).length, 0)) {
|
|
1948
|
+
{
|
|
1949
|
+
const __eliscript_value_150 = [];
|
|
1950
|
+
{
|
|
1951
|
+
let count = __eliscript_value_150;
|
|
1952
|
+
unsigned_leb(count, ((data_texts) ?? []).length);
|
|
1953
|
+
section(output, 12, count);
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
if (__eliscript_truthy(debug)) {
|
|
1958
|
+
{
|
|
1959
|
+
const __eliscript_value_151 = ((output) ?? []).length;
|
|
1960
|
+
{
|
|
1961
|
+
let section_start = __eliscript_value_151;
|
|
1962
|
+
binary_push(output, 10);
|
|
1963
|
+
unsigned_leb(output, ((bodies) ?? []).length);
|
|
1964
|
+
{
|
|
1965
|
+
const __eliscript_value_152 = ((output) ?? []).length;
|
|
1966
|
+
const __eliscript_value_153 = (debug)["ranges"];
|
|
1967
|
+
const __eliscript_value_154 = (debug)["functions"];
|
|
1968
|
+
const __eliscript_value_155 = 0;
|
|
1969
|
+
{
|
|
1970
|
+
let payload_start = __eliscript_value_152;
|
|
1971
|
+
let ranges = __eliscript_value_153;
|
|
1972
|
+
let mapped_functions = __eliscript_value_154;
|
|
1973
|
+
let i = __eliscript_value_155;
|
|
1974
|
+
((debug)["codeSection"] = ({"id": 10, "start": section_start, "payloadStart": payload_start, "payloadSize": ((bodies) ?? []).length, "end": (payload_start + ((bodies) ?? []).length)}));
|
|
1975
|
+
while (__eliscript_numeric_relation("<", i, ((ranges) ?? []).length)) {
|
|
1976
|
+
{
|
|
1977
|
+
const __eliscript_value_156 = ((((ranges) ?? [])[i]) ?? null);
|
|
1978
|
+
{
|
|
1979
|
+
let range = __eliscript_value_156;
|
|
1980
|
+
((range)["start"] = (payload_start + (range)["start"]));
|
|
1981
|
+
((range)["end"] = (payload_start + (range)["end"]));
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
((i = (i + 1)));
|
|
1985
|
+
}
|
|
1986
|
+
((i = 0));
|
|
1987
|
+
while (__eliscript_numeric_relation("<", i, ((mapped_functions) ?? []).length)) {
|
|
1988
|
+
{
|
|
1989
|
+
let function$ = ((((mapped_functions) ?? [])[i]) ?? null);
|
|
1990
|
+
let fields = ["sizeField", "body", "locals", "instructions"];
|
|
1991
|
+
let j = 0;
|
|
1992
|
+
while (__eliscript_numeric_relation("<", j, ((fields) ?? []).length)) {
|
|
1993
|
+
{
|
|
1994
|
+
const __eliscript_value_157 = (function$)[((((fields) ?? [])[j]) ?? null)];
|
|
1995
|
+
{
|
|
1996
|
+
let range = __eliscript_value_157;
|
|
1997
|
+
((range)["start"] = (payload_start + (range)["start"]));
|
|
1998
|
+
((range)["end"] = (payload_start + (range)["end"]));
|
|
1999
|
+
if ((((((fields) ?? [])[j]) ?? null) === "locals")) {
|
|
2000
|
+
((range)["entriesStart"] = (payload_start + (range)["entriesStart"]));
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
}
|
|
2004
|
+
((j = (j + 1)));
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
((i = (i + 1)));
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
binary_append_owned(output, bodies);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
} else {
|
|
2015
|
+
binary_push(output, 10);
|
|
2016
|
+
unsigned_leb(output, ((bodies) ?? []).length);
|
|
2017
|
+
binary_append_owned(output, bodies);
|
|
2018
|
+
}
|
|
2019
|
+
((bodies = null));
|
|
2020
|
+
append_passive_data(output, data_texts);
|
|
2021
|
+
if (__eliscript_truthy(debug)) {
|
|
2022
|
+
{
|
|
2023
|
+
const __eliscript_value_158 = (debug)["trapSites"];
|
|
2024
|
+
const __eliscript_value_159 = 0;
|
|
2025
|
+
{
|
|
2026
|
+
let sites = __eliscript_value_158;
|
|
2027
|
+
let index = __eliscript_value_159;
|
|
2028
|
+
while (__eliscript_numeric_relation("<", index, ((sites) ?? []).length)) {
|
|
2029
|
+
{
|
|
2030
|
+
const __eliscript_value_160 = ((((sites) ?? [])[index]) ?? null);
|
|
2031
|
+
{
|
|
2032
|
+
let site = __eliscript_value_160;
|
|
2033
|
+
((sites)[index] = ({"site": (site)["site"], "address": (site)["start"], "offsetBase": "module", "functionIndex": (site)["functionIndex"], "returnAddress": false}));
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
((index = (index + 1)));
|
|
2037
|
+
}
|
|
2038
|
+
append_trap_site_section(output, sites);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
return output;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
function make_wasm_validation_workspace() {
|
|
2046
|
+
return ({"nodes": [], "positions": [], "seen": new (globalThis.Set)(), "active": new (globalThis.Set)()});
|
|
2047
|
+
}
|
|
2048
|
+
function validate_fresh_wasm_expression(expression, parent, memory, workspace = null) {
|
|
2049
|
+
require_wasm_expression_node(expression, parent, memory);
|
|
2050
|
+
{
|
|
2051
|
+
let work = ((__eliscript_value_161) => (__eliscript_truthy(__eliscript_value_161) ? __eliscript_value_161 : make_wasm_validation_workspace()))(workspace);
|
|
2052
|
+
let nodes = (work)["nodes"];
|
|
2053
|
+
let positions = (work)["positions"];
|
|
2054
|
+
let seen = (work)["seen"];
|
|
2055
|
+
let active = (work)["active"];
|
|
2056
|
+
let depth = 1;
|
|
2057
|
+
let seen_count = 0;
|
|
2058
|
+
let active_changes = 0;
|
|
2059
|
+
let clear_index = 0;
|
|
2060
|
+
while (__eliscript_numeric_relation("<", clear_index, ((nodes) ?? []).length)) {
|
|
2061
|
+
((nodes)[clear_index] = null);
|
|
2062
|
+
((clear_index = (clear_index + 1)));
|
|
2063
|
+
}
|
|
2064
|
+
(seen)["clear"]();
|
|
2065
|
+
(active)["clear"]();
|
|
2066
|
+
((nodes)[0] = expression);
|
|
2067
|
+
((positions)[0] = 0);
|
|
2068
|
+
(active)["add"](expression);
|
|
2069
|
+
while (__eliscript_numeric_relation(">", depth, 0)) {
|
|
2070
|
+
{
|
|
2071
|
+
let frame = __eliscript_numeric_decrement(depth);
|
|
2072
|
+
let node = ((((nodes) ?? [])[frame]) ?? null);
|
|
2073
|
+
let children = (node)["children"];
|
|
2074
|
+
let position = ((((positions) ?? [])[frame]) ?? null);
|
|
2075
|
+
if ((position === ((children) ?? []).length)) {
|
|
2076
|
+
(active)["delete"](node);
|
|
2077
|
+
((active_changes = (active_changes + 1)));
|
|
2078
|
+
if (__eliscript_numeric_relation(">=", seen_count, 65536)) {
|
|
2079
|
+
(seen)["clear"]();
|
|
2080
|
+
((seen_count = 0));
|
|
2081
|
+
}
|
|
2082
|
+
(seen)["add"](node);
|
|
2083
|
+
((seen_count = (seen_count + 1)));
|
|
2084
|
+
((nodes)[frame] = null);
|
|
2085
|
+
((depth = frame));
|
|
2086
|
+
} else {
|
|
2087
|
+
{
|
|
2088
|
+
const __eliscript_value_162 = ((((children) ?? [])[position]) ?? null);
|
|
2089
|
+
{
|
|
2090
|
+
let child = __eliscript_value_162;
|
|
2091
|
+
require_wasm_expression_node(child, node, memory);
|
|
2092
|
+
((positions)[frame] = (position + 1));
|
|
2093
|
+
if (__eliscript_truthy((active)["has"](child))) {
|
|
2094
|
+
backend_fail(child, "typed WASM expression contains a cyclic child graph");
|
|
2095
|
+
}
|
|
2096
|
+
if ((!__eliscript_truthy((seen)["has"](child)))) {
|
|
2097
|
+
(active)["add"](child);
|
|
2098
|
+
((active_changes = (active_changes + 1)));
|
|
2099
|
+
((nodes)[depth] = child);
|
|
2100
|
+
((positions)[depth] = 0);
|
|
2101
|
+
((depth = (depth + 1)));
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
if (__eliscript_numeric_relation(">=", active_changes, 4096)) {
|
|
2107
|
+
(active)["clear"]();
|
|
2108
|
+
{
|
|
2109
|
+
const __eliscript_value_163 = 0;
|
|
2110
|
+
{
|
|
2111
|
+
let index = __eliscript_value_163;
|
|
2112
|
+
while (__eliscript_numeric_relation("<", index, depth)) {
|
|
2113
|
+
(active)["add"](((((nodes) ?? [])[index]) ?? null));
|
|
2114
|
+
((index = (index + 1)));
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
((active_changes = 0));
|
|
2119
|
+
}
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
return expression;
|
|
2124
|
+
}
|
|
2125
|
+
function validate_fresh_typed_wasm_program(program) {
|
|
2126
|
+
if ((!((!(program === 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; } })(program) === "object") && (!__eliscript_truthy(Array.isArray(program)))))) {
|
|
2127
|
+
backend_fail(null, "typed WASM emitter requires a program object");
|
|
2128
|
+
}
|
|
2129
|
+
{
|
|
2130
|
+
const __eliscript_value_164 = (program)["functions"];
|
|
2131
|
+
const __eliscript_value_165 = ((program)["abi"] === "memory-u32");
|
|
2132
|
+
const __eliscript_value_166 = make_wasm_validation_workspace();
|
|
2133
|
+
const __eliscript_value_167 = 0;
|
|
2134
|
+
{
|
|
2135
|
+
let functions = __eliscript_value_164;
|
|
2136
|
+
let memory = __eliscript_value_165;
|
|
2137
|
+
let workspace = __eliscript_value_166;
|
|
2138
|
+
let index = __eliscript_value_167;
|
|
2139
|
+
if ((!__eliscript_truthy(Array.isArray(functions)))) {
|
|
2140
|
+
backend_fail(program, "typed WASM emitter requires declared functions");
|
|
2141
|
+
}
|
|
2142
|
+
while (__eliscript_numeric_relation("<", index, ((functions) ?? []).length)) {
|
|
2143
|
+
{
|
|
2144
|
+
const __eliscript_value_168 = ((((functions) ?? [])[index]) ?? null);
|
|
2145
|
+
{
|
|
2146
|
+
let function$ = __eliscript_value_168;
|
|
2147
|
+
if ((!__eliscript_truthy(((__eliscript_value_169) => (__eliscript_truthy(__eliscript_value_169) ? ((__eliscript_value_170) => (__eliscript_truthy(__eliscript_value_170) ? ((__eliscript_value_171) => (__eliscript_truthy(__eliscript_value_171) ? Array.isArray((function$)["locals"]) : __eliscript_value_171))((!__eliscript_truthy(Array.isArray(function$)))) : __eliscript_value_170))((((__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; } })(function$) === "object")) : __eliscript_value_169))((!(function$ === null)))))) {
|
|
2148
|
+
backend_fail(program, "typed WASM function requires a locals array");
|
|
2149
|
+
}
|
|
2150
|
+
validate_fresh_wasm_expression((function$)["body"], function$, memory, workspace);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
((index = (index + 1)));
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
return program;
|
|
2158
|
+
}
|
|
2159
|
+
function emit_fresh_managed_wasm_product(lowered, configure) {
|
|
2160
|
+
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; } })(configure) === "function"))) {
|
|
2161
|
+
backend_fail(null, "managed WASM product requires an output configuration callback");
|
|
2162
|
+
}
|
|
2163
|
+
{
|
|
2164
|
+
let configuration = configure();
|
|
2165
|
+
let typed = validate_fresh_typed_wasm_program((lowered)["typed"]);
|
|
2166
|
+
let memory = ((__eliscript_value_172) => (__eliscript_truthy(__eliscript_value_172) ? __eliscript_value_172 : ({})))(((configuration)["memory"] ?? null));
|
|
2167
|
+
let debug = ((((configuration)["debug"] ?? false) === true) ? ({"format": "eliscript-wasm-source-map", "version": 1, "target": "wasm32", "abi": "memory-u32", "offsetUnit": "byte", "offsetBase": "module", "functions": [], "ranges": []}) : null);
|
|
2168
|
+
let descriptor = (lowered)["descriptor"];
|
|
2169
|
+
let output = append_metadata_section(emit_typed_scalar_wasm(typed, memory, debug, true), "eliscript-managed-control", JSON.stringify(descriptor));
|
|
2170
|
+
let bytes = binary_finish(output);
|
|
2171
|
+
let product = ({"bytes": bytes, "descriptor": descriptor});
|
|
2172
|
+
if (__eliscript_truthy(debug)) {
|
|
2173
|
+
((debug)["moduleByteLength"] = binary_length(bytes));
|
|
2174
|
+
((product)["debug"] = debug);
|
|
2175
|
+
}
|
|
2176
|
+
return product;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
function managed_wasm_product_fail(node, message, phase = null) {
|
|
2180
|
+
return (() => {
|
|
2181
|
+
try {
|
|
2182
|
+
return backend_fail(node, message);
|
|
2183
|
+
} catch (error) {
|
|
2184
|
+
(((error)["eliscriptDiagnostic"])["phase"] = ((__eliscript_value_173) => (__eliscript_truthy(__eliscript_value_173) ? __eliscript_value_173 : "managed-backend"))(phase));
|
|
2185
|
+
return ((__eliscript_value_174) => { throw __eliscript_value_174; })(error);
|
|
2186
|
+
}
|
|
2187
|
+
})();
|
|
2188
|
+
}
|
|
2189
|
+
function emit_managed_ir_wasm_product(program, runtime_program, lower_options, configure) {
|
|
2190
|
+
{
|
|
2191
|
+
let options = ((__eliscript_value_175) => (__eliscript_truthy(__eliscript_value_175) ? __eliscript_value_175 : ({})))(lower_options);
|
|
2192
|
+
let requested = ((options)["abi"] ?? null);
|
|
2193
|
+
let lowered = lower_managed_program(program, runtime_program, (requested === "managed-module-v1"), null, null, null, null, null, null, ((options)["literalModules"] ?? null));
|
|
2194
|
+
if (((!(requested === null)) && (!((requested === "managed-control-v1") || (requested === "managed-module-v1"))))) {
|
|
2195
|
+
managed_wasm_product_fail(program, "unknown managed ABI");
|
|
2196
|
+
}
|
|
2197
|
+
if (((!(requested === null)) && (!(requested === ((lowered)["descriptor"])["abi"])))) {
|
|
2198
|
+
managed_wasm_product_fail(program, "top-level bindings require managed-module-v1");
|
|
2199
|
+
}
|
|
2200
|
+
return emit_fresh_managed_wasm_product(lowered, configure);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function emit_managed_project_wasm_product(modules, entry, runtime_program, lower_options, configure) {
|
|
2204
|
+
{
|
|
2205
|
+
let requested = ((((__eliscript_value_176) => (__eliscript_truthy(__eliscript_value_176) ? __eliscript_value_176 : ({})))(lower_options))["abi"] ?? null);
|
|
2206
|
+
let lowered = lower_managed_project(modules, entry, runtime_program, lower_options);
|
|
2207
|
+
if (((!(requested === null)) && (!(requested === "managed-module-v1")))) {
|
|
2208
|
+
managed_wasm_product_fail(null, "managed projects require managed-module-v1", "managed-link");
|
|
2209
|
+
}
|
|
2210
|
+
return emit_fresh_managed_wasm_product(lowered, configure);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
function emit_typed_numeric_wasm(program, options = null) {
|
|
2214
|
+
if ((!((program)["abi"] === "numeric-f64"))) {
|
|
2215
|
+
backend_fail(program, "WASM emitter requires numeric-f64 typed input");
|
|
2216
|
+
}
|
|
2217
|
+
return binary_finish(emit_typed_scalar_wasm(copy_typed_wasm_program(program), ((__eliscript_value_177) => (__eliscript_truthy(__eliscript_value_177) ? __eliscript_value_177 : ({})))(options)));
|
|
2218
|
+
}
|
|
2219
|
+
function emit_memory_wasm(program, options = null) {
|
|
2220
|
+
return binary_finish(emit_typed_scalar_wasm(lower_memory_program(program), ((__eliscript_value_178) => (__eliscript_truthy(__eliscript_value_178) ? __eliscript_value_178 : ({})))(options)));
|
|
2221
|
+
}
|
|
2222
|
+
function emit_typed_memory_wasm(program, options = null) {
|
|
2223
|
+
if ((!((program)["abi"] === "memory-u32"))) {
|
|
2224
|
+
backend_fail(program, "typed memory emitter requires memory-u32");
|
|
2225
|
+
}
|
|
2226
|
+
return binary_finish(emit_typed_scalar_wasm(copy_typed_wasm_program(program), ((__eliscript_value_179) => (__eliscript_truthy(__eliscript_value_179) ? __eliscript_value_179 : ({})))(options)));
|
|
2227
|
+
}
|
|
2228
|
+
function emit_typed_memory_wasm_artifact(program, options = null) {
|
|
2229
|
+
if ((!((program)["abi"] === "memory-u32"))) {
|
|
2230
|
+
backend_fail(program, "typed memory emitter requires memory-u32");
|
|
2231
|
+
}
|
|
2232
|
+
{
|
|
2233
|
+
let debug = ({"format": "eliscript-wasm-source-map", "version": 1, "target": "wasm32", "abi": "memory-u32", "offsetUnit": "byte", "offsetBase": "module", "functions": [], "ranges": []});
|
|
2234
|
+
let bytes = emit_typed_scalar_wasm(copy_typed_wasm_program(program), ((__eliscript_value_180) => (__eliscript_truthy(__eliscript_value_180) ? __eliscript_value_180 : ({})))(options), debug);
|
|
2235
|
+
((debug)["moduleByteLength"] = ((bytes) ?? []).length);
|
|
2236
|
+
return ({"bytes": binary_finish(bytes), "debug": debug});
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
function append_metadata_section(bytes, name, value) {
|
|
2240
|
+
{
|
|
2241
|
+
let finished = (((bytes)["encoding"] ?? null) === "u16le-chunks");
|
|
2242
|
+
let output = binary_resume(bytes);
|
|
2243
|
+
let payload = binary_child(output);
|
|
2244
|
+
utf8_name(payload, name);
|
|
2245
|
+
utf8_name(payload, value);
|
|
2246
|
+
section(output, 0, payload);
|
|
2247
|
+
if (__eliscript_truthy(finished)) {
|
|
2248
|
+
return binary_finish(output);
|
|
2249
|
+
} else {
|
|
2250
|
+
return output;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
function emit_numeric_wasm(program, options = null) {
|
|
2255
|
+
lower_numeric_program(program);
|
|
2256
|
+
return emit_typed_numeric_wasm(optimize_numeric_program(lower_numeric_program(optimize_program(program)), ({"constantFlow": true, "unswitch": true, "countedGuards": true})), options);
|
|
2257
|
+
}
|
|
2258
|
+
export {emit_numeric_wasm, emit_typed_numeric_wasm, emit_memory_wasm, emit_typed_memory_wasm, emit_typed_memory_wasm_artifact, emit_managed_ir_wasm_product, emit_managed_project_wasm_product, append_metadata_section};
|