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,4099 @@
|
|
|
1
|
+
// Generated by Eliscript. Do not edit.
|
|
2
|
+
import "eliscript/runtime/unicode-case.mjs";
|
|
3
|
+
import "eliscript/runtime/math.mjs";
|
|
4
|
+
import { c as __eliscript_at, d as __eliscript_at_direct } from "data:text/javascript;base64,dmFyIG09UmVmbGVjdC5hcHBseSx0dD1OdW1iZXIucHJvdG90eXBlLnZhbHVlT2Ysaj1OdW1iZXIucHJvdG90eXBlLnRvU3RyaW5nLFU9TnVtYmVyLG50PU9iamVjdC5jcmVhdGUsaD1CaWdJbnQsZXQ9RGF0YVZpZXcsb3Q9QXJyYXlCdWZmZXIsaXQ9RGF0YVZpZXcucHJvdG90eXBlLnNldEZsb2F0NjQsSj1EYXRhVmlldy5wcm90b3R5cGUuZ2V0VWludDMyLHJ0PVJhbmdlRXJyb3I7ZnVuY3Rpb24gY3QodCxuKXtsZXQgZT1oKG4pLG89aCh0KSxpPSIiO2lmKG88MG4pbz0tbztkb3tsZXQgZj1vJWU7aT0iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltVKGYpXStpLG8vPWV9d2hpbGUobyE9PTBuKTtyZXR1cm4gdDwwPyItIitpOml9ZnVuY3Rpb24gc3QodCxuKXtsZXQgZT1uZXcgZXQobmV3IG90KDgpKTttKGl0LGUsWzAsdCwhMV0pO2xldCBvPW0oSixlLFswLCExXSksaT1tKEosZSxbNCwhMV0pLGY9bz4+PjIwJjIwNDcsYj1vJjEwNDg1NzUscD1vPj4+MzEscj1oKGIpPDwzMm58aChpKTtpZihmIT09MClyKz0xbjw8NTJuO3I8PD0ybjtsZXQgbD00bix1PWY+MSYmYj09PTAmJmk9PT0wPzFuOjJuLGs9Mm47aWYoZj49MTA3NSl7bGV0IGM9aChmLTEwNzUpO3I8PD1jLHU8PD1jLGs8PD1jfWVsc2UgbDw8PWgoZj09PTA/MTA3NDoxMDc1LWYpO2xldCBkPWgobiksZz1udChudWxsKSxhPTAsUz0wLEQ9MDtpZihyPGwpd2hpbGUocjxsKXtpZihyKjJuPmwmJnIraz5sKWJyZWFrO3IqPWQsdSo9ZCxrKj1kLFMtLX1lbHNlIHdoaWxlKHI+PWwqZClsKj1kLFMrKztmb3IoOzspe2xldCBjPVUoci9sKTtyJT1sO2xldCBJPXI8dSx4PXIraz5sO2dbYSsrXT1jLEQ9RCoobiYxKStjJjE7bGV0IHE9cioybixQPXE+bHx8cT09PWwmJkQ9PT0xO2lmKFAmJnh8fCFQJiZJKXtpZihQKXtsZXQgUj1hLEI9ITA7d2hpbGUoUj4wJiZCKXtSLS07bGV0IEg9Z1tSXSsxO2lmKEg9PT1uKWdbUl09MDtlbHNlIGdbUl09SCxCPSExfWlmKEIpZ1swXT0xLFMrK31icmVha31pZihhPj02NCl0aHJvdyBuZXcgcnQoIm51bWJlciByYWRpeCBmb3JtYXR0aW5nIGRpZCBub3QgY29udmVyZ2UiKTtyKj1kLHUqPWQsayo9ZH13aGlsZShhPjEmJmdbYS0xXT09PTApYS0tO2xldCB3PSIiO2lmKFM8MCl7dz0iMC4iO2ZvcihsZXQgYz0wO2M8LTEtUztjKyspdys9IjAiO2ZvcihsZXQgYz0wO2M8YTtjKyspdys9IjAxMjM0NTY3ODlhYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5eiJbZ1tjXV19ZWxzZXtsZXQgYz1TKzEsST1jPmE/YzphO2ZvcihsZXQgeD0wO3g8STt4Kyspe2lmKHg9PT1jJiZjPGEpdys9Ii4iO3crPXg8YT8iMDEyMzQ1Njc4OWFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6IltnW3hdXToiMCJ9fXJldHVybiBwPyItIit3Ond9ZnVuY3Rpb24gRyh0LG4pe2xldCBlO3RyeXtlPW0odHQsdCxbXSl9Y2F0Y2h7cmV0dXJuIG0oaix0LFtuXSl9bGV0IG89MTA7aWYobiE9PXZvaWQgMCl7bGV0IGk9K247aWYobz1pIT09aT8wOmktaSUxLG88Mnx8bz4zNnx8byE9PW8pcmV0dXJuIG0oaixlLFtvXSl9aWYobz09PTEwfHxlPT09MHx8ZSE9PWV8fGU9PT0xLzB8fGU9PT0tMS8wKXJldHVybiBtKGosZSxbMTBdKTtyZXR1cm4gZSUxPT09MD9jdChlLG8pOnN0KGUsbyl9dmFyIHM9UmVmbGVjdC5hcHBseSxNPUZ1bmN0aW9uLnByb3RvdHlwZS5jYWxsLE49RnVuY3Rpb24ucHJvdG90eXBlLmFwcGx5LEU9RnVuY3Rpb24ucHJvdG90eXBlLmJpbmQsVD1PYmplY3QuZGVmaW5lUHJvcGVydHksbHQ9T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcixmdD1PYmplY3QuZ2V0UHJvdG90eXBlT2YsdXQ9T2JqZWN0LnNldFByb3RvdHlwZU9mLGF0PVJlZmxlY3Qub3duS2V5cyxwdD1TeW1ib2wuaGFzSW5zdGFuY2UsVj1BcnJheS5pc0FycmF5LEs9QXJyYXkucHJvdG90eXBlLmpvaW4sej1BcnJheS5wcm90b3R5cGUudG9TdHJpbmcseXQ9T2JqZWN0LnByb3RvdHlwZS50b1N0cmluZyxidD1TdHJpbmcsQz1UeXBlRXJyb3IsZHQ9U3ltYm9sLnRvUHJpbWl0aXZlLGd0PVdlYWtTZXQucHJvdG90eXBlLmhhcyx3dD1XZWFrU2V0LnByb3RvdHlwZS5hZGQseHQ9V2Vha1NldC5wcm90b3R5cGUuZGVsZXRlLEY9bmV3IFdlYWtTZXQsTz1udWxsLFc9KHQpPT50IT09bnVsbCYmKHR5cGVvZiB0PT09Im9iamVjdCJ8fHR5cGVvZiB0PT09ImZ1bmN0aW9uInx8dHlwZW9mIHQ+InUiJiZ0IT09dm9pZCAwKSxBPSh0KT0+dHlwZW9mIHQ9PT0iZnVuY3Rpb24ifHx0eXBlb2YgdD4idSImJnQhPT12b2lkIDA7ZnVuY3Rpb24gaHQoKXtsZXQgbj1uZXcgQygiY3ljbGljIGFycmF5IHRleHQgY29udmVyc2lvbiIpO3Rocm93IG4uZWxpc2NyaXB0RGlhZ25vc3RpYz17Zm9ybWF0OiJlbGlzY3JpcHQtZGlhZ25vc3RpYyIsdmVyc2lvbjoxLGNvZGU6IkVMSS1SVDAwMDkiLHNldmVyaXR5OiJlcnJvciIscGhhc2U6InJ1bnRpbWUiLG1lc3NhZ2U6ImN5Y2xpYyBhcnJheSB0ZXh0IGNvbnZlcnNpb24ifSxufWZ1bmN0aW9uIG10KHQpe2lmKCFXKHQpKXJldHVybiB0O2xldCBuPXRbZHRdO2lmKG4hPT12b2lkIDAmJm4hPT1udWxsKXtsZXQgZT1zKG4sdCxbInN0cmluZyJdKTtpZighVyhlKSlyZXR1cm4gZTt0aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZSIpfWZvcihsZXQgZT0wO2U8MjtlKyspe2xldCBvPXRbZT09PTA/InRvU3RyaW5nIjoidmFsdWVPZiJdO2lmKEEobykpe2xldCBpPW89PT16JiZWKHQpP3YodCk6cyhvLHQsW10pO2lmKCFXKGkpKXJldHVybiBpfX10aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgb2JqZWN0IHRvIHByaW1pdGl2ZSB2YWx1ZSIpfWZ1bmN0aW9uIFEodCl7bGV0IG49bXQodCk7aWYodHlwZW9mIG49PT0ic3ltYm9sIil0aHJvdyBuZXcgQygiQ2Fubm90IGNvbnZlcnQgYSBTeW1ib2wgdmFsdWUgdG8gYSBzdHJpbmciKTtyZXR1cm4gYnQobil9ZnVuY3Rpb24gXyh0LG4pe2xldCBlPSt0Lmxlbmd0aCxvPWUhPT1lfHxlPD0wPzA6ZT49OTAwNzE5OTI1NDc0MDk5MT85MDA3MTk5MjU0NzQwOTkxOmUtZSUxLGk9bj09PXZvaWQgMD8iLCI6UShuKSxmPU89PT1udWxsO2lmKGYpTz10O2Vsc2V7aWYodD09PU98fHMoZ3QsRixbdF0pKWh0KCk7cyh3dCxGLFt0XSl9dHJ5e2xldCBiPSIiO2ZvcihsZXQgcD0wO3A8bztwKyspe2lmKHApYis9aTtsZXQgcj10W3BdO2lmKHIhPT1udWxsJiZyIT09dm9pZCAwKWIrPVEocil9cmV0dXJuIGJ9ZmluYWxseXtpZihmKU89bnVsbDtlbHNlIHMoeHQsRixbdF0pfX1mdW5jdGlvbiB2KHQpe2xldCBuPXQuam9pbjtyZXR1cm4gQShuKT9uPT09Sz9fKHQsdm9pZCAwKTpzKG4sdCxbXSk6cyh5dCx0LFtdKX1mdW5jdGlvbiB5KHQsbil7cmV0dXJuIG48dC5sZW5ndGg/dFtuXTp2b2lkIDB9ZnVuY3Rpb24gWCh0LG4pe2xldCBlPVtdO2ZvcihsZXQgbz1uO288dC5sZW5ndGg7bysrKVQoZSxlLmxlbmd0aCx7dmFsdWU6dFtvXSx3cml0YWJsZTohMCxlbnVtZXJhYmxlOiEwLGNvbmZpZ3VyYWJsZTohMH0pO3JldHVybiBlfWZ1bmN0aW9uIFN0KHQsbil7bGV0IGU9W107Zm9yKGxldCBvPTA7bzx0Lmxlbmd0aCtuLmxlbmd0aDtvKyspVChlLG8se3ZhbHVlOm88dC5sZW5ndGg/dFtvXTpuW28tdC5sZW5ndGhdLHdyaXRhYmxlOiEwLGVudW1lcmFibGU6ITAsY29uZmlndXJhYmxlOiEwfSk7cmV0dXJuIGV9ZnVuY3Rpb24gWSguLi50KXtyZXR1cm4gdH1mdW5jdGlvbiBaKHQsbil7cmV0dXJuIG4/cyhOLFksW3ZvaWQgMCx0XSk6cyhZLHZvaWQgMCx0KX1mdW5jdGlvbiBMKHQsbixlKXtmb3IoOzspe2lmKHQ9PT1qKXJldHVybiBHKG4seShlLDApKTtpZih0PT09SyYmVihuKSlyZXR1cm4gXyhuLHkoZSwwKSk7aWYodD09PXomJlYobikpcmV0dXJuIHYobik7aWYodD09PU0pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9WChlLDEpLHQ9byxuPWk7Y29udGludWV9aWYodD09PU4pe2lmKCFBKG4pKXJldHVybiBzKHQsbixlKTtsZXQgbz1uLGk9eShlLDApO2U9Wih5KGUsMSksITApLHQ9byxuPWk7Y29udGludWV9aWYodD09PXMpe2xldCBvPXkoZSwwKSxpPXkoZSwxKTtpZighQShvKSlyZXR1cm4gcyh0LG4sZSk7ZT1aKHkoZSwyKSwhMSksdD1vLG49aTtjb250aW51ZX1pZih0PT09RSl7bGV0IG89cyh0LG4sZSk7aWYobiE9PWomJm4hPT1LJiZuIT09eiYmbiE9PU0mJm4hPT1OJiZuIT09cyYmbiE9PUUpcmV0dXJuIG87bGV0IGk9bixmPXkoZSwwKSxiPVgoZSwxKSxwPSguLi51KT0+TChpLGYsU3QoYix1KSk7VChwLHB0LHt2YWx1ZToodSk9PnUgaW5zdGFuY2VvZiBpLGNvbmZpZ3VyYWJsZTohMH0pO2xldCByPXMoRSxwLFt2b2lkIDBdKTt1dChyLGZ0KG8pKTtsZXQgbD1hdChvKTtmb3IobGV0IHU9MDt1PGwubGVuZ3RoO3UrKylUKHIsbFt1XSxsdChvLGxbdV0pKTtyZXR1cm4gcn1yZXR1cm4gcyh0LG4sZSl9fWZ1bmN0aW9uIFJ0KHQsbil7bGV0IGU9dFtuXTtyZXR1cm4oLi4ubyk9PkwoZSx0LG8pfWZ1bmN0aW9uIEF0KHQsbiwuLi5lKXtsZXQgbz10W25dO3JldHVybiBMKG8sdCxlKX1leHBvcnR7UnQgYXMgYyxBdCBhcyBkfTs=";
|
|
5
|
+
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
6
|
+
const __eliscript_number_intrinsic = globalThis.Number;
|
|
7
|
+
const __eliscript_bigint_intrinsic = globalThis.BigInt;
|
|
8
|
+
const __eliscript_numeric_apply = globalThis.Reflect.apply;
|
|
9
|
+
const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
|
|
10
|
+
const __eliscript_numeric_error = globalThis.TypeError;
|
|
11
|
+
const __eliscript_numeric_trim = globalThis.String.prototype.trim;
|
|
12
|
+
const __eliscript_numeric_slice = globalThis.String.prototype.slice;
|
|
13
|
+
const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
|
|
14
|
+
const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
|
|
15
|
+
const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
|
|
16
|
+
const __eliscript_numeric_primitive = (value) => {
|
|
17
|
+
if (!__eliscript_numeric_object(value)) return value;
|
|
18
|
+
const exotic = value[__eliscript_numeric_symbol];
|
|
19
|
+
if (exotic !== void 0 && exotic !== null) {
|
|
20
|
+
const result = __eliscript_numeric_apply(exotic, value, ["number"]);
|
|
21
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
22
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
23
|
+
}
|
|
24
|
+
for (let index = 0; index < 2; index++) {
|
|
25
|
+
const method = value[index === 0 ? "valueOf" : "toString"];
|
|
26
|
+
if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
|
|
27
|
+
const result = __eliscript_numeric_apply(method, value, []);
|
|
28
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
32
|
+
};
|
|
33
|
+
const __eliscript_to_number = (value) => {
|
|
34
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
35
|
+
if (typeof primitive === "string") {
|
|
36
|
+
const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
|
|
37
|
+
if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
|
|
38
|
+
let first = 2;
|
|
39
|
+
while (first < text.length && text[first] === "0") first++;
|
|
40
|
+
if (first === text.length) return 0;
|
|
41
|
+
const prefix = text[1];
|
|
42
|
+
const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
|
|
43
|
+
if (text.length - first > limit) return 1 / 0;
|
|
44
|
+
const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
|
|
45
|
+
return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return __eliscript_number_intrinsic(primitive);
|
|
49
|
+
};
|
|
50
|
+
const __eliscript_numeric = (value) => {
|
|
51
|
+
if (typeof value === "number" || typeof value === "bigint") return value;
|
|
52
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
53
|
+
if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
|
|
54
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
55
|
+
};
|
|
56
|
+
const __eliscript_implicit_number = (value) => {
|
|
57
|
+
if (typeof value === "number") return value;
|
|
58
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
59
|
+
if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
|
|
60
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
61
|
+
};
|
|
62
|
+
const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
|
|
63
|
+
const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
|
|
64
|
+
const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
|
|
65
|
+
const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
|
|
66
|
+
const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
|
|
67
|
+
const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
|
|
68
|
+
const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
|
|
69
|
+
const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
|
|
70
|
+
const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
|
|
71
|
+
const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
|
|
72
|
+
const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
|
|
73
|
+
const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
|
|
74
|
+
const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
|
|
75
|
+
const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
|
|
76
|
+
const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
|
|
77
|
+
const __eliscript_numeric_relation = (operator, left, right) => {
|
|
78
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
79
|
+
if (operator === "<") return left < right;
|
|
80
|
+
if (operator === "<=") return left <= right;
|
|
81
|
+
if (operator === ">") return left > right;
|
|
82
|
+
return left >= right;
|
|
83
|
+
}
|
|
84
|
+
let a = __eliscript_numeric_primitive(left);
|
|
85
|
+
let b = __eliscript_numeric_primitive(right);
|
|
86
|
+
const x = typeof a, y = typeof b;
|
|
87
|
+
if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
|
|
88
|
+
a = __eliscript_numeric(a);
|
|
89
|
+
b = __eliscript_numeric(b);
|
|
90
|
+
}
|
|
91
|
+
if (operator === "<") return a < b;
|
|
92
|
+
if (operator === "<=") return a <= b;
|
|
93
|
+
if (operator === ">") return a > b;
|
|
94
|
+
return a >= b;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
import {optimize_program} from "./optimize.mjs";
|
|
98
|
+
import {lower_numeric_program, optimize_numeric_program, numeric_pure, backend_fail, find_function} from "./numeric.mjs";
|
|
99
|
+
import {sha256_bytes, sha256_words_le} from "./sha256.mjs";
|
|
100
|
+
import {lower_memory_program} from "./memory.mjs";
|
|
101
|
+
import {emit_elf_object, emit_elf_library} from "./elf.mjs";
|
|
102
|
+
import {prepare_host_capabilities, prepare_fresh_host_capabilities, host_capability_index} from "./capabilities.mjs";
|
|
103
|
+
import {binary_output, binary_byte, binary_u32, binary_append, binary_append_owned, binary_slice, binary_finish} from "./binary.mjs";
|
|
104
|
+
function native_word_buffer() {
|
|
105
|
+
return ({"length": 0, "chunks": [], "cache": [], "units": [], "cacheIndex": -1, "dirty": false});
|
|
106
|
+
}
|
|
107
|
+
function native_word_flush(words) {
|
|
108
|
+
if (__eliscript_truthy((words)["dirty"])) {
|
|
109
|
+
{
|
|
110
|
+
const __eliscript_value_1 = (words)["cache"];
|
|
111
|
+
const __eliscript_value_2 = ((words)["units"] ?? null);
|
|
112
|
+
const __eliscript_value_3 = 0;
|
|
113
|
+
{
|
|
114
|
+
let cache = __eliscript_value_1;
|
|
115
|
+
let units = __eliscript_value_2;
|
|
116
|
+
let index = __eliscript_value_3;
|
|
117
|
+
if ((!__eliscript_truthy(units))) {
|
|
118
|
+
((units = []));
|
|
119
|
+
((words)["units"] = units);
|
|
120
|
+
}
|
|
121
|
+
((units)["length"] = 0);
|
|
122
|
+
while (__eliscript_numeric_relation("<", index, ((cache) ?? []).length)) {
|
|
123
|
+
if ((!__eliscript_truthy(Object.hasOwn(cache, index)))) {
|
|
124
|
+
backend_fail(null, "native word buffer contains an unwritten word");
|
|
125
|
+
}
|
|
126
|
+
{
|
|
127
|
+
const __eliscript_value_4 = ((((cache) ?? [])[index]) ?? null);
|
|
128
|
+
{
|
|
129
|
+
let value = __eliscript_value_4;
|
|
130
|
+
(units)["push"](__eliscript_numeric_and(value, 65535), __eliscript_numeric_ushr(value, 16));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
((index = (index + 1)));
|
|
134
|
+
}
|
|
135
|
+
(((words)["chunks"])[(words)["cacheIndex"]] = __eliscript_at(Reflect, "apply")((globalThis.String)["fromCharCode"], null, units));
|
|
136
|
+
((words)["dirty"] = false);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return words;
|
|
141
|
+
}
|
|
142
|
+
function native_word_cache(words, block) {
|
|
143
|
+
if ((!(block === (words)["cacheIndex"]))) {
|
|
144
|
+
native_word_flush(words);
|
|
145
|
+
{
|
|
146
|
+
const __eliscript_value_5 = (((((words)["chunks"]) ?? [])[block]) ?? null);
|
|
147
|
+
const __eliscript_value_6 = (words)["cache"];
|
|
148
|
+
const __eliscript_value_7 = 0;
|
|
149
|
+
{
|
|
150
|
+
let text = __eliscript_value_5;
|
|
151
|
+
let cache = __eliscript_value_6;
|
|
152
|
+
let index = __eliscript_value_7;
|
|
153
|
+
((cache)["length"] = 0);
|
|
154
|
+
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; } })(text) === "string")) {
|
|
155
|
+
while (__eliscript_numeric_relation("<", index, ((text) ?? []).length)) {
|
|
156
|
+
(cache)["push"](((text).charCodeAt(index) + __eliscript_numeric_mul((text).charCodeAt((index + 1)), 65536)));
|
|
157
|
+
((index = (index + 2)));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
((words)["cacheIndex"] = block);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return (words)["cache"];
|
|
165
|
+
}
|
|
166
|
+
function native_word_at(words, index) {
|
|
167
|
+
if (__eliscript_truthy(Array.isArray(words))) {
|
|
168
|
+
return ((((words) ?? [])[index]) ?? null);
|
|
169
|
+
} else {
|
|
170
|
+
if ((!__eliscript_truthy(((__eliscript_value_8) => (__eliscript_truthy(__eliscript_value_8) ? (__eliscript_numeric_relation(">=", index, 0) && __eliscript_numeric_relation("<", index, ((words) ?? []).length)) : __eliscript_value_8))(Number.isSafeInteger(index))))) {
|
|
171
|
+
backend_fail(null, "native word buffer index is out of range");
|
|
172
|
+
}
|
|
173
|
+
{
|
|
174
|
+
const __eliscript_value_9 = (globalThis.Math)["floor"](__eliscript_numeric_div(index, 1024));
|
|
175
|
+
const __eliscript_value_10 = __eliscript_numeric_rem(index, 1024);
|
|
176
|
+
{
|
|
177
|
+
let block = __eliscript_value_9;
|
|
178
|
+
let offset = __eliscript_value_10;
|
|
179
|
+
if ((block === (words)["cacheIndex"])) {
|
|
180
|
+
{
|
|
181
|
+
const __eliscript_value_11 = (words)["cache"];
|
|
182
|
+
{
|
|
183
|
+
let cache = __eliscript_value_11;
|
|
184
|
+
if ((!__eliscript_truthy(Object.hasOwn(cache, offset)))) {
|
|
185
|
+
backend_fail(null, "native word buffer contains an unwritten word");
|
|
186
|
+
}
|
|
187
|
+
return ((((cache) ?? [])[offset]) ?? null);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
{
|
|
192
|
+
const __eliscript_value_12 = (((((words)["chunks"]) ?? [])[block]) ?? null);
|
|
193
|
+
{
|
|
194
|
+
let text = __eliscript_value_12;
|
|
195
|
+
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; } })(text) === "string") && __eliscript_numeric_relation("<", (__eliscript_numeric_mul(offset, 2) + 1), ((text) ?? []).length)))) {
|
|
196
|
+
backend_fail(null, "native word buffer contains an unwritten word");
|
|
197
|
+
}
|
|
198
|
+
return ((text).charCodeAt(__eliscript_numeric_mul(offset, 2)) + __eliscript_numeric_mul((text).charCodeAt((__eliscript_numeric_mul(offset, 2) + 1)), 65536));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function native_word_set(words, index, value) {
|
|
207
|
+
if (__eliscript_truthy(Array.isArray(words))) {
|
|
208
|
+
((words)[index] = value);
|
|
209
|
+
} else {
|
|
210
|
+
if ((!__eliscript_truthy(((__eliscript_value_13) => (__eliscript_truthy(__eliscript_value_13) ? (__eliscript_numeric_relation(">=", index, 0) && __eliscript_numeric_relation("<", index, ((words) ?? []).length)) : __eliscript_value_13))(Number.isSafeInteger(index))))) {
|
|
211
|
+
backend_fail(null, "native word buffer index is out of range");
|
|
212
|
+
}
|
|
213
|
+
((native_word_cache(words, (globalThis.Math)["floor"](__eliscript_numeric_div(index, 1024))))[__eliscript_numeric_rem(index, 1024)] = __eliscript_numeric_uint32(value));
|
|
214
|
+
((words)["dirty"] = true);
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
function native_word_resize(words, length) {
|
|
219
|
+
if (__eliscript_truthy(Array.isArray(words))) {
|
|
220
|
+
((words)["length"] = length);
|
|
221
|
+
} else {
|
|
222
|
+
if ((!__eliscript_truthy(((__eliscript_value_14) => (__eliscript_truthy(__eliscript_value_14) ? __eliscript_numeric_relation(">=", length, 0) : __eliscript_value_14))(Number.isSafeInteger(length))))) {
|
|
223
|
+
backend_fail(null, "native word buffer length is invalid");
|
|
224
|
+
}
|
|
225
|
+
if (__eliscript_numeric_relation("<", length, ((words) ?? []).length)) {
|
|
226
|
+
{
|
|
227
|
+
const __eliscript_value_15 = (globalThis.Math)["floor"](__eliscript_numeric_div(length, 1024));
|
|
228
|
+
const __eliscript_value_16 = __eliscript_numeric_rem(length, 1024);
|
|
229
|
+
const __eliscript_value_17 = (words)["cacheIndex"];
|
|
230
|
+
const __eliscript_value_18 = (words)["chunks"];
|
|
231
|
+
{
|
|
232
|
+
let block = __eliscript_value_15;
|
|
233
|
+
let tail = __eliscript_value_16;
|
|
234
|
+
let cached = __eliscript_value_17;
|
|
235
|
+
let chunks = __eliscript_value_18;
|
|
236
|
+
if (__eliscript_numeric_relation("<", __eliscript_numeric_mul(cached, 1024), length)) {
|
|
237
|
+
if ((cached === block)) {
|
|
238
|
+
{
|
|
239
|
+
const __eliscript_value_19 = (words)["cache"];
|
|
240
|
+
{
|
|
241
|
+
let cache = __eliscript_value_19;
|
|
242
|
+
if (__eliscript_numeric_relation(">", ((cache) ?? []).length, tail)) {
|
|
243
|
+
((cache)["length"] = tail);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
native_word_flush(words);
|
|
249
|
+
}
|
|
250
|
+
(((words)["cache"])["length"] = 0);
|
|
251
|
+
((words)["cacheIndex"] = -1);
|
|
252
|
+
((words)["dirty"] = false);
|
|
253
|
+
((chunks)["length"] = (block + (__eliscript_numeric_relation(">", tail, 0) ? 1 : 0)));
|
|
254
|
+
if ((__eliscript_numeric_relation(">", tail, 0) && (((__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; } })(((((chunks) ?? [])[block]) ?? null)) === "string"))) {
|
|
255
|
+
((chunks)[block] = (((((chunks) ?? [])[block]) ?? null))["slice"](0, __eliscript_numeric_mul(tail, 2)));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
((words)["length"] = length);
|
|
261
|
+
}
|
|
262
|
+
return length;
|
|
263
|
+
}
|
|
264
|
+
function native_word_push(words, value) {
|
|
265
|
+
if (__eliscript_truthy(Array.isArray(words))) {
|
|
266
|
+
return (words)["push"](__eliscript_numeric_uint32(value));
|
|
267
|
+
} else {
|
|
268
|
+
{
|
|
269
|
+
const __eliscript_value_20 = ((words) ?? []).length;
|
|
270
|
+
{
|
|
271
|
+
let index = __eliscript_value_20;
|
|
272
|
+
native_word_resize(words, (index + 1));
|
|
273
|
+
native_word_set(words, index, value);
|
|
274
|
+
return ((words) ?? []).length;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function word(state, value) {
|
|
280
|
+
return native_word_push((state)["words"], value);
|
|
281
|
+
}
|
|
282
|
+
function native_append_words(output, words) {
|
|
283
|
+
if (__eliscript_truthy(((__eliscript_value_21) => (__eliscript_truthy(__eliscript_value_21) ? __eliscript_value_21 : Array.isArray(words)))(Array.isArray(output)))) {
|
|
284
|
+
{
|
|
285
|
+
const __eliscript_value_22 = 0;
|
|
286
|
+
{
|
|
287
|
+
let index = __eliscript_value_22;
|
|
288
|
+
while (__eliscript_numeric_relation("<", index, ((words) ?? []).length)) {
|
|
289
|
+
binary_u32(output, native_word_at(words, index));
|
|
290
|
+
((index = (index + 1)));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
} else {
|
|
295
|
+
native_word_flush(words);
|
|
296
|
+
binary_append_owned(output, ({"length": __eliscript_numeric_mul(((words) ?? []).length, 4), "chunks": (words)["chunks"], "pending": [], "low": -1}));
|
|
297
|
+
}
|
|
298
|
+
return output;
|
|
299
|
+
}
|
|
300
|
+
function u32(bytes, value) {
|
|
301
|
+
return binary_u32(bytes, value);
|
|
302
|
+
}
|
|
303
|
+
function u64(bytes, value) {
|
|
304
|
+
u32(bytes, __eliscript_numeric_uint32(value));
|
|
305
|
+
return u32(bytes, __eliscript_numeric_uint32(__eliscript_numeric_div(value, 4294967296)));
|
|
306
|
+
}
|
|
307
|
+
function zeros(bytes, count) {
|
|
308
|
+
{
|
|
309
|
+
const __eliscript_value_23 = 0;
|
|
310
|
+
{
|
|
311
|
+
let i = __eliscript_value_23;
|
|
312
|
+
while (__eliscript_numeric_relation("<", i, count)) {
|
|
313
|
+
binary_byte(bytes, 0);
|
|
314
|
+
((i = (i + 1)));
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function ascii_field(bytes, name, width) {
|
|
321
|
+
{
|
|
322
|
+
const __eliscript_value_24 = 0;
|
|
323
|
+
{
|
|
324
|
+
let i = __eliscript_value_24;
|
|
325
|
+
while (__eliscript_numeric_relation("<", i, width)) {
|
|
326
|
+
binary_byte(bytes, (__eliscript_numeric_relation("<", i, ((name) ?? []).length) ? (name).charCodeAt(i) : 0));
|
|
327
|
+
((i = (i + 1)));
|
|
328
|
+
}
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
function string_bytes(bytes, name) {
|
|
334
|
+
{
|
|
335
|
+
const __eliscript_value_25 = 0;
|
|
336
|
+
{
|
|
337
|
+
let i = __eliscript_value_25;
|
|
338
|
+
while (__eliscript_numeric_relation("<", i, ((name) ?? []).length)) {
|
|
339
|
+
{
|
|
340
|
+
const __eliscript_value_26 = (name).charCodeAt(i);
|
|
341
|
+
{
|
|
342
|
+
let code = __eliscript_value_26;
|
|
343
|
+
if ((code === 0)) {
|
|
344
|
+
backend_fail(null, "native symbol contains NUL");
|
|
345
|
+
}
|
|
346
|
+
if ((__eliscript_numeric_relation(">=", code, 55296) && __eliscript_numeric_relation("<=", code, 56319))) {
|
|
347
|
+
{
|
|
348
|
+
const __eliscript_value_27 = (__eliscript_numeric_relation("<", (i + 1), ((name) ?? []).length) ? (name).charCodeAt((i + 1)) : 0);
|
|
349
|
+
{
|
|
350
|
+
let next = __eliscript_value_27;
|
|
351
|
+
if ((!(__eliscript_numeric_relation(">=", next, 56320) && __eliscript_numeric_relation("<=", next, 57343)))) {
|
|
352
|
+
backend_fail(null, "native symbol contains an unpaired surrogate");
|
|
353
|
+
}
|
|
354
|
+
((code = (65536 + __eliscript_numeric_mul(__eliscript_numeric_sub(code, 55296), 1024) + __eliscript_numeric_sub(next, 56320))));
|
|
355
|
+
((i = (i + 1)));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
if ((__eliscript_numeric_relation(">=", code, 56320) && __eliscript_numeric_relation("<=", code, 57343))) {
|
|
360
|
+
backend_fail(null, "native symbol contains an unpaired surrogate");
|
|
361
|
+
}
|
|
362
|
+
if (__eliscript_numeric_relation("<", code, 128)) {
|
|
363
|
+
(bytes)["push"](code);
|
|
364
|
+
} else {
|
|
365
|
+
if (__eliscript_numeric_relation("<", code, 2048)) {
|
|
366
|
+
(bytes)["push"](__eliscript_numeric_or(192, __eliscript_numeric_ushr(code, 6)), __eliscript_numeric_or(128, __eliscript_numeric_and(code, 63)));
|
|
367
|
+
} else {
|
|
368
|
+
if (__eliscript_numeric_relation("<", code, 65536)) {
|
|
369
|
+
(bytes)["push"](__eliscript_numeric_or(224, __eliscript_numeric_ushr(code, 12)), __eliscript_numeric_or(128, __eliscript_numeric_and(__eliscript_numeric_ushr(code, 6), 63)), __eliscript_numeric_or(128, __eliscript_numeric_and(code, 63)));
|
|
370
|
+
} else {
|
|
371
|
+
(bytes)["push"](__eliscript_numeric_or(240, __eliscript_numeric_ushr(code, 18)), __eliscript_numeric_or(128, __eliscript_numeric_and(__eliscript_numeric_ushr(code, 12), 63)), __eliscript_numeric_or(128, __eliscript_numeric_and(__eliscript_numeric_ushr(code, 6), 63)), __eliscript_numeric_or(128, __eliscript_numeric_and(code, 63)));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
((i = (i + 1)));
|
|
378
|
+
}
|
|
379
|
+
return (bytes)["push"](0);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function integer_register(state, register, low, high) {
|
|
384
|
+
word(state, (3531603968 + __eliscript_numeric_mul(__eliscript_numeric_and(low, 65535), 32) + register));
|
|
385
|
+
if (((!__eliscript_truthy(((state)["compact"] ?? null))) || ((__eliscript_value_28, __eliscript_value_29) => (__eliscript_value_28 !== __eliscript_value_29))(__eliscript_numeric_ushr(low, 16), 0))) {
|
|
386
|
+
word(state, (4070572032 + __eliscript_numeric_mul(__eliscript_numeric_ushr(low, 16), 32) + register));
|
|
387
|
+
}
|
|
388
|
+
if (((!__eliscript_truthy(((state)["compact"] ?? null))) || ((__eliscript_value_30, __eliscript_value_31) => (__eliscript_value_30 !== __eliscript_value_31))(__eliscript_numeric_and(high, 65535), 0))) {
|
|
389
|
+
word(state, (4072669184 + __eliscript_numeric_mul(__eliscript_numeric_and(high, 65535), 32) + register));
|
|
390
|
+
}
|
|
391
|
+
if (((!__eliscript_truthy(((state)["compact"] ?? null))) || ((__eliscript_value_32, __eliscript_value_33) => (__eliscript_value_32 !== __eliscript_value_33))(__eliscript_numeric_ushr(high, 16), 0))) {
|
|
392
|
+
return word(state, (4074766336 + __eliscript_numeric_mul(__eliscript_numeric_ushr(high, 16), 32) + register));
|
|
393
|
+
} else {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function memory_integer_register(state, register, value) {
|
|
398
|
+
{
|
|
399
|
+
const __eliscript_value_34 = __eliscript_numeric_and(value, 65535);
|
|
400
|
+
const __eliscript_value_35 = __eliscript_numeric_ushr(value, 16);
|
|
401
|
+
{
|
|
402
|
+
let low = __eliscript_value_34;
|
|
403
|
+
let high = __eliscript_value_35;
|
|
404
|
+
if (((low === 0) && ((__eliscript_value_36, __eliscript_value_37) => (__eliscript_value_36 !== __eliscript_value_37))(high, 0))) {
|
|
405
|
+
return word(state, (1386217472 + __eliscript_numeric_mul(high, 32) + register));
|
|
406
|
+
} else {
|
|
407
|
+
word(state, (1384120320 + __eliscript_numeric_mul(low, 32) + register));
|
|
408
|
+
if (((__eliscript_value_38, __eliscript_value_39) => (__eliscript_value_38 !== __eliscript_value_39))(high, 0)) {
|
|
409
|
+
return word(state, (1923088384 + __eliscript_numeric_mul(high, 32) + register));
|
|
410
|
+
} else {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function float_literal(state, value) {
|
|
418
|
+
{
|
|
419
|
+
let bits = ((__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);
|
|
420
|
+
let low = ((((bits) ?? [])[0]) ?? null);
|
|
421
|
+
let high = ((((bits) ?? [])[1]) ?? null);
|
|
422
|
+
if (((value === 0) && __eliscript_numeric_relation("<", __eliscript_numeric_div(1, value), 0))) {
|
|
423
|
+
((high = 2147483648));
|
|
424
|
+
}
|
|
425
|
+
if (__eliscript_truthy(((__eliscript_value_40) => (__eliscript_truthy(__eliscript_value_40) ? ((low === 0) && (high === 0)) : __eliscript_value_40))(((state)["compact"] ?? null)))) {
|
|
426
|
+
return word(state, 2657551328);
|
|
427
|
+
} else {
|
|
428
|
+
if (__eliscript_truthy(((__eliscript_value_41) => (__eliscript_truthy(__eliscript_value_41) ? ((low === 0) && (__eliscript_numeric_and(high, 65535) === 0) && __eliscript_numeric_relation(">=", __eliscript_numeric_and(__eliscript_numeric_ushr(high, 20), 2047), 1020) && __eliscript_numeric_relation("<=", __eliscript_numeric_and(__eliscript_numeric_ushr(high, 20), 2047), 1027)) : __eliscript_value_41))(((state)["compact"] ?? null)))) {
|
|
429
|
+
{
|
|
430
|
+
let exponent = __eliscript_numeric_sub(__eliscript_numeric_and(__eliscript_numeric_ushr(high, 20), 2047), 1023);
|
|
431
|
+
let immediate = (__eliscript_numeric_mul(__eliscript_numeric_ushr(high, 31), 128) + (__eliscript_numeric_relation("<", exponent, 1) ? (64 + __eliscript_numeric_mul((exponent + 3), 16)) : __eliscript_numeric_mul(__eliscript_numeric_decrement(exponent), 16)) + __eliscript_numeric_and(__eliscript_numeric_ushr(high, 16), 15));
|
|
432
|
+
return word(state, (509612032 + __eliscript_numeric_mul(immediate, 8192)));
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
if (__eliscript_truthy(((state)["compact"] ?? null))) {
|
|
436
|
+
{
|
|
437
|
+
const __eliscript_value_42 = (state)["constants"];
|
|
438
|
+
const __eliscript_value_43 = 0;
|
|
439
|
+
const __eliscript_value_44 = null;
|
|
440
|
+
{
|
|
441
|
+
let constants = __eliscript_value_42;
|
|
442
|
+
let index = __eliscript_value_43;
|
|
443
|
+
let found = __eliscript_value_44;
|
|
444
|
+
while ((__eliscript_numeric_relation("<", index, ((constants) ?? []).length) && (!__eliscript_truthy(found)))) {
|
|
445
|
+
{
|
|
446
|
+
const __eliscript_value_45 = ((((constants) ?? [])[index]) ?? null);
|
|
447
|
+
{
|
|
448
|
+
let entry = __eliscript_value_45;
|
|
449
|
+
if (((low === (entry)["low"]) && (high === (entry)["high"]))) {
|
|
450
|
+
((found = entry));
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
((index = (index + 1)));
|
|
455
|
+
}
|
|
456
|
+
if ((!__eliscript_truthy(found))) {
|
|
457
|
+
((found = ({"low": low, "high": high, "uses": []})));
|
|
458
|
+
(constants)["push"](found);
|
|
459
|
+
}
|
|
460
|
+
((found)["uses"])["push"]((((state)["words"]) ?? []).length);
|
|
461
|
+
return word(state, 1543503872);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
integer_register(state, 9, low, high);
|
|
466
|
+
return word(state, 2657550624);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function literal_register(state, value) {
|
|
473
|
+
{
|
|
474
|
+
let bits = ((__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);
|
|
475
|
+
let entries = ((state)["literalRegisters"] ?? []);
|
|
476
|
+
let i = 0;
|
|
477
|
+
let register = -1;
|
|
478
|
+
while (__eliscript_numeric_relation("<", i, ((entries) ?? []).length)) {
|
|
479
|
+
{
|
|
480
|
+
const __eliscript_value_46 = ((((entries) ?? [])[i]) ?? null);
|
|
481
|
+
{
|
|
482
|
+
let entry = __eliscript_value_46;
|
|
483
|
+
if (((((((bits) ?? [])[0]) ?? null) === (entry)["low"]) && (((((bits) ?? [])[1]) ?? null) === (entry)["high"]))) {
|
|
484
|
+
((register = (entry)["register"]));
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
((i = (i + 1)));
|
|
489
|
+
}
|
|
490
|
+
return register;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
function collect_loop_literals(node, depth, entries) {
|
|
494
|
+
{
|
|
495
|
+
const __eliscript_value_47 = (node)["kind"];
|
|
496
|
+
const __eliscript_value_48 = (node)["children"];
|
|
497
|
+
const __eliscript_value_49 = 0;
|
|
498
|
+
{
|
|
499
|
+
let kind = __eliscript_value_47;
|
|
500
|
+
let children = __eliscript_value_48;
|
|
501
|
+
let i = __eliscript_value_49;
|
|
502
|
+
if ((__eliscript_numeric_relation(">", depth, 0) && (kind === "literal") && ((node)["type"] === "f64") && ((__eliscript_value_50, __eliscript_value_51) => (__eliscript_value_50 !== __eliscript_value_51))((node)["value"], 0))) {
|
|
503
|
+
{
|
|
504
|
+
let bits = ((__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)]; })((node)["value"]);
|
|
505
|
+
let found = null;
|
|
506
|
+
let j = 0;
|
|
507
|
+
while (__eliscript_numeric_relation("<", j, ((entries) ?? []).length)) {
|
|
508
|
+
{
|
|
509
|
+
const __eliscript_value_52 = ((((entries) ?? [])[j]) ?? null);
|
|
510
|
+
{
|
|
511
|
+
let entry = __eliscript_value_52;
|
|
512
|
+
if (((((((bits) ?? [])[0]) ?? null) === (entry)["low"]) && (((((bits) ?? [])[1]) ?? null) === (entry)["high"]))) {
|
|
513
|
+
((found = entry));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
((j = (j + 1)));
|
|
518
|
+
}
|
|
519
|
+
if (__eliscript_truthy(found)) {
|
|
520
|
+
((found)["weight"] = ((found)["weight"] + 1));
|
|
521
|
+
} else {
|
|
522
|
+
(entries)["push"](({"low": ((((bits) ?? [])[0]) ?? null), "high": ((((bits) ?? [])[1]) ?? null), "value": (node)["value"], "weight": 1}));
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
527
|
+
collect_loop_literals(((((children) ?? [])[i]) ?? null), (((kind === "while") || (kind === "remainder-while") || (kind === "guarded-while")) ? (depth + 1) : depth), entries);
|
|
528
|
+
((i = (i + 1)));
|
|
529
|
+
}
|
|
530
|
+
return null;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function allocate_literal_registers(state, body) {
|
|
535
|
+
{
|
|
536
|
+
const __eliscript_value_53 = [];
|
|
537
|
+
const __eliscript_value_54 = [];
|
|
538
|
+
const __eliscript_value_55 = (state)["registers"];
|
|
539
|
+
const __eliscript_value_56 = 31;
|
|
540
|
+
{
|
|
541
|
+
let entries = __eliscript_value_53;
|
|
542
|
+
let selected = __eliscript_value_54;
|
|
543
|
+
let registers = __eliscript_value_55;
|
|
544
|
+
let r = __eliscript_value_56;
|
|
545
|
+
collect_loop_literals(body, 0, entries);
|
|
546
|
+
while ((__eliscript_numeric_relation(">=", r, 2) && __eliscript_numeric_relation(">", ((entries) ?? []).length, 0))) {
|
|
547
|
+
if (((__eliscript_numeric_relation("<", r, 16) || __eliscript_numeric_relation(">=", r, 24)) && (!__eliscript_truthy((registers)["includes"](r))))) {
|
|
548
|
+
{
|
|
549
|
+
const __eliscript_value_57 = 0;
|
|
550
|
+
const __eliscript_value_58 = 1;
|
|
551
|
+
{
|
|
552
|
+
let best = __eliscript_value_57;
|
|
553
|
+
let j = __eliscript_value_58;
|
|
554
|
+
while (__eliscript_numeric_relation("<", j, ((entries) ?? []).length)) {
|
|
555
|
+
if (__eliscript_numeric_relation(">", (((((entries) ?? [])[j]) ?? null))["weight"], (((((entries) ?? [])[best]) ?? null))["weight"])) {
|
|
556
|
+
((best = j));
|
|
557
|
+
}
|
|
558
|
+
((j = (j + 1)));
|
|
559
|
+
}
|
|
560
|
+
{
|
|
561
|
+
const __eliscript_value_59 = ((((entries) ?? [])[best]) ?? null);
|
|
562
|
+
{
|
|
563
|
+
let entry = __eliscript_value_59;
|
|
564
|
+
((entry)["register"] = r);
|
|
565
|
+
(selected)["push"](entry);
|
|
566
|
+
(registers)["push"](r);
|
|
567
|
+
(entries)["splice"](best, 1);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
((r = __eliscript_numeric_decrement(r)));
|
|
574
|
+
}
|
|
575
|
+
return selected;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
function finish_literals(state) {
|
|
580
|
+
{
|
|
581
|
+
const __eliscript_value_60 = (state)["constants"];
|
|
582
|
+
const __eliscript_value_61 = (state)["words"];
|
|
583
|
+
const __eliscript_value_62 = 0;
|
|
584
|
+
{
|
|
585
|
+
let constants = __eliscript_value_60;
|
|
586
|
+
let words = __eliscript_value_61;
|
|
587
|
+
let i = __eliscript_value_62;
|
|
588
|
+
if ((__eliscript_numeric_relation(">", ((constants) ?? []).length, 0) && ((__eliscript_value_63, __eliscript_value_64) => (__eliscript_value_63 !== __eliscript_value_64))(__eliscript_numeric_and(((words) ?? []).length, 1), 0))) {
|
|
589
|
+
word(state, 3573751839);
|
|
590
|
+
}
|
|
591
|
+
while (__eliscript_numeric_relation("<", i, ((constants) ?? []).length)) {
|
|
592
|
+
{
|
|
593
|
+
let entry = ((((constants) ?? [])[i]) ?? null);
|
|
594
|
+
let target = ((words) ?? []).length;
|
|
595
|
+
let uses = (entry)["uses"];
|
|
596
|
+
let j = 0;
|
|
597
|
+
while (__eliscript_numeric_relation("<", j, ((uses) ?? []).length)) {
|
|
598
|
+
{
|
|
599
|
+
let at = ((((uses) ?? [])[j]) ?? null);
|
|
600
|
+
let distance = __eliscript_numeric_sub(target, at);
|
|
601
|
+
if ((!(__eliscript_numeric_relation(">=", distance, -262144) && __eliscript_numeric_relation("<", distance, 262144)))) {
|
|
602
|
+
backend_fail(null, "native literal exceeds ARM64 displacement range");
|
|
603
|
+
}
|
|
604
|
+
native_word_set(words, at, __eliscript_numeric_or((1543503872 + __eliscript_numeric_and(native_word_at(words, at), 31)), __eliscript_numeric_mul(__eliscript_numeric_and(distance, 524287), 32)));
|
|
605
|
+
}
|
|
606
|
+
((j = (j + 1)));
|
|
607
|
+
}
|
|
608
|
+
word(state, (entry)["low"]);
|
|
609
|
+
word(state, (entry)["high"]);
|
|
610
|
+
}
|
|
611
|
+
((i = (i + 1)));
|
|
612
|
+
}
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
function stack_adjust(state, amount, subtract) {
|
|
618
|
+
while (__eliscript_numeric_relation(">", amount, 0)) {
|
|
619
|
+
{
|
|
620
|
+
const __eliscript_value_65 = (__eliscript_numeric_relation("<", amount, 4080) ? amount : 4080);
|
|
621
|
+
{
|
|
622
|
+
let part = __eliscript_value_65;
|
|
623
|
+
word(state, ((__eliscript_truthy(subtract) ? 3506439167 : 2432697343) + __eliscript_numeric_mul(part, 1024)));
|
|
624
|
+
((amount = __eliscript_numeric_sub(amount, part)));
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
function push_value(state, type) {
|
|
631
|
+
{
|
|
632
|
+
const __eliscript_value_66 = ((state)["depth"] ?? 0);
|
|
633
|
+
{
|
|
634
|
+
let depth = __eliscript_value_66;
|
|
635
|
+
if (__eliscript_truthy(((__eliscript_value_67) => (__eliscript_truthy(__eliscript_value_67) ? __eliscript_numeric_relation("<", depth, 8) : __eliscript_value_67))(((state)["leaf"] ?? null)))) {
|
|
636
|
+
word(state, (((type === "f64") ? 509624320 : 505872384) + (16 + depth)));
|
|
637
|
+
} else {
|
|
638
|
+
stack_adjust(state, 16, true);
|
|
639
|
+
word(state, ((type === "f64") ? 4244636640 : 3103785952));
|
|
640
|
+
}
|
|
641
|
+
return ((state)["depth"] = (depth + 1));
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
function pop_value(state, type) {
|
|
646
|
+
{
|
|
647
|
+
const __eliscript_value_68 = __eliscript_numeric_decrement(((state)["depth"] ?? 1));
|
|
648
|
+
{
|
|
649
|
+
let depth = __eliscript_value_68;
|
|
650
|
+
((state)["depth"] = depth);
|
|
651
|
+
if (__eliscript_truthy(((__eliscript_value_69) => (__eliscript_truthy(__eliscript_value_69) ? __eliscript_numeric_relation("<", depth, 8) : __eliscript_value_69))(((state)["leaf"] ?? null)))) {
|
|
652
|
+
return word(state, (((type === "f64") ? 509624321 : 505806849) + __eliscript_numeric_mul((16 + depth), 32)));
|
|
653
|
+
} else {
|
|
654
|
+
word(state, ((type === "f64") ? 4248830945 : 3107980257));
|
|
655
|
+
return stack_adjust(state, 16, null);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function local_access(state, index, type, store) {
|
|
661
|
+
{
|
|
662
|
+
let registers = ((state)["registers"] ?? []);
|
|
663
|
+
let register = (__eliscript_numeric_relation("<", index, ((registers) ?? []).length) ? ((((registers) ?? [])[index]) ?? null) : -1);
|
|
664
|
+
if (__eliscript_numeric_relation("<=", register, -2)) {
|
|
665
|
+
{
|
|
666
|
+
const __eliscript_value_70 = __eliscript_numeric_sub(__eliscript_numeric_neg(register), 2);
|
|
667
|
+
{
|
|
668
|
+
let physical = __eliscript_value_70;
|
|
669
|
+
return word(state, (704644064 + (__eliscript_truthy(store) ? physical : __eliscript_numeric_mul(physical, 65536))));
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
} else {
|
|
673
|
+
if (__eliscript_numeric_relation(">=", register, 0)) {
|
|
674
|
+
return word(state, ((type === "f64") ? (509624320 + (__eliscript_truthy(store) ? register : __eliscript_numeric_mul(register, 32))) : (__eliscript_truthy(store) ? (505872384 + register) : (505806848 + __eliscript_numeric_mul(register, 32)))));
|
|
675
|
+
} else {
|
|
676
|
+
{
|
|
677
|
+
const __eliscript_value_71 = __eliscript_numeric_mul((index + 1), 8);
|
|
678
|
+
{
|
|
679
|
+
let offset = __eliscript_value_71;
|
|
680
|
+
if (__eliscript_truthy(((__eliscript_value_72) => (__eliscript_truthy(__eliscript_value_72) ? __eliscript_numeric_relation("<=", offset, 256) : __eliscript_value_72))(((state)["memory"] ?? null)))) {
|
|
681
|
+
return word(state, (((type === "f64") ? (__eliscript_truthy(store) ? 4227858432 : 4232052736) : (__eliscript_truthy(store) ? 3087007744 : 3091202048)) + __eliscript_numeric_mul(__eliscript_numeric_and(__eliscript_numeric_neg(offset), 511), 4096) + 928));
|
|
682
|
+
} else {
|
|
683
|
+
if (__eliscript_truthy(((__eliscript_value_73) => (__eliscript_truthy(__eliscript_value_73) ? __eliscript_numeric_relation("<=", offset, 4095) : __eliscript_value_73))(((state)["memory"] ?? null)))) {
|
|
684
|
+
word(state, (3506439081 + __eliscript_numeric_mul(offset, 1024)));
|
|
685
|
+
} else {
|
|
686
|
+
integer_register(state, 9, offset, 0);
|
|
687
|
+
word(state, 3406365609);
|
|
688
|
+
}
|
|
689
|
+
return word(state, ((type === "f64") ? (__eliscript_truthy(store) ? 4244635936 : 4248830240) : (__eliscript_truthy(store) ? 3103785248 : 3107979552)));
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
function register_weights(node, counts) {
|
|
698
|
+
{
|
|
699
|
+
const __eliscript_value_74 = (node)["kind"];
|
|
700
|
+
const __eliscript_value_75 = (node)["children"];
|
|
701
|
+
const __eliscript_value_76 = 0;
|
|
702
|
+
const __eliscript_value_77 = ((node)["kind"] === "call");
|
|
703
|
+
{
|
|
704
|
+
let kind = __eliscript_value_74;
|
|
705
|
+
let children = __eliscript_value_75;
|
|
706
|
+
let i = __eliscript_value_76;
|
|
707
|
+
let call = __eliscript_value_77;
|
|
708
|
+
if (((kind === "local") || (kind === "set") || (kind === "initialize"))) {
|
|
709
|
+
{
|
|
710
|
+
const __eliscript_value_78 = (node)["value"];
|
|
711
|
+
{
|
|
712
|
+
let index = __eliscript_value_78;
|
|
713
|
+
(counts)["splice"](index, 1, (((((counts) ?? [])[index]) ?? null) + 1));
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
718
|
+
if (__eliscript_truthy(register_weights(((((children) ?? [])[i]) ?? null), counts))) {
|
|
719
|
+
((call = true));
|
|
720
|
+
}
|
|
721
|
+
((i = (i + 1)));
|
|
722
|
+
}
|
|
723
|
+
return call;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
function live_union(left, right) {
|
|
728
|
+
{
|
|
729
|
+
const __eliscript_value_79 = (left)["slice"]();
|
|
730
|
+
const __eliscript_value_80 = 0;
|
|
731
|
+
{
|
|
732
|
+
let result = __eliscript_value_79;
|
|
733
|
+
let i = __eliscript_value_80;
|
|
734
|
+
while (__eliscript_numeric_relation("<", i, ((right) ?? []).length)) {
|
|
735
|
+
if ((!__eliscript_truthy((result)["includes"](((((right) ?? [])[i]) ?? null))))) {
|
|
736
|
+
(result)["push"](((((right) ?? [])[i]) ?? null));
|
|
737
|
+
}
|
|
738
|
+
((i = (i + 1)));
|
|
739
|
+
}
|
|
740
|
+
return result;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
function interference(graph, index, live) {
|
|
745
|
+
{
|
|
746
|
+
const __eliscript_value_81 = 0;
|
|
747
|
+
{
|
|
748
|
+
let i = __eliscript_value_81;
|
|
749
|
+
while (__eliscript_numeric_relation("<", i, ((live) ?? []).length)) {
|
|
750
|
+
{
|
|
751
|
+
const __eliscript_value_82 = ((((live) ?? [])[i]) ?? null);
|
|
752
|
+
{
|
|
753
|
+
let other = __eliscript_value_82;
|
|
754
|
+
if ((!(index === other))) {
|
|
755
|
+
if ((!__eliscript_truthy((((((graph) ?? [])[index]) ?? null))["includes"](other)))) {
|
|
756
|
+
(((((graph) ?? [])[index]) ?? null))["push"](other);
|
|
757
|
+
}
|
|
758
|
+
if ((!__eliscript_truthy((((((graph) ?? [])[other]) ?? null))["includes"](index)))) {
|
|
759
|
+
(((((graph) ?? [])[other]) ?? null))["push"](index);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
((i = (i + 1)));
|
|
765
|
+
}
|
|
766
|
+
return null;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
function live_before(node, after, graph) {
|
|
771
|
+
{
|
|
772
|
+
const __eliscript_value_83 = (node)["kind"];
|
|
773
|
+
const __eliscript_value_84 = (node)["children"];
|
|
774
|
+
const __eliscript_value_85 = (node)["value"];
|
|
775
|
+
const __eliscript_value_86 = (after)["slice"]();
|
|
776
|
+
{
|
|
777
|
+
let kind = __eliscript_value_83;
|
|
778
|
+
let children = __eliscript_value_84;
|
|
779
|
+
let value = __eliscript_value_85;
|
|
780
|
+
let live = __eliscript_value_86;
|
|
781
|
+
if ((kind === "call")) {
|
|
782
|
+
((node)["callLive"] = live_union(((node)["callLive"] ?? []), after));
|
|
783
|
+
}
|
|
784
|
+
if ((kind === "local")) {
|
|
785
|
+
interference(graph, value, live);
|
|
786
|
+
if ((!__eliscript_truthy((live)["includes"](value)))) {
|
|
787
|
+
(live)["push"](value);
|
|
788
|
+
}
|
|
789
|
+
} else {
|
|
790
|
+
if (((kind === "set") || (kind === "initialize"))) {
|
|
791
|
+
((node)["storeLive"] = ((__eliscript_value_87) => (__eliscript_truthy(__eliscript_value_87) ? __eliscript_value_87 : (live)["includes"](value)))(((node)["storeLive"] ?? null)));
|
|
792
|
+
interference(graph, value, live);
|
|
793
|
+
{
|
|
794
|
+
const __eliscript_value_88 = (live)["indexOf"](value);
|
|
795
|
+
{
|
|
796
|
+
let at = __eliscript_value_88;
|
|
797
|
+
if (__eliscript_numeric_relation(">=", at, 0)) {
|
|
798
|
+
(live)["splice"](at, 1);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
((live = live_before(((((children) ?? [])[0]) ?? null), live, graph)));
|
|
803
|
+
} else {
|
|
804
|
+
if ((kind === "if")) {
|
|
805
|
+
((live = live_before(((((children) ?? [])[0]) ?? null), live_union(live_before(((((children) ?? [])[1]) ?? null), live, graph), live_before(((((children) ?? [])[2]) ?? null), live, graph)), graph)));
|
|
806
|
+
} else {
|
|
807
|
+
if (((kind === "while") || (kind === "remainder-while") || (kind === "guarded-while"))) {
|
|
808
|
+
{
|
|
809
|
+
const __eliscript_value_89 = true;
|
|
810
|
+
{
|
|
811
|
+
let changed = __eliscript_value_89;
|
|
812
|
+
while (__eliscript_truthy(changed)) {
|
|
813
|
+
{
|
|
814
|
+
let next = live_before(((((children) ?? [])[0]) ?? null), live_union(after, live_before(((((children) ?? [])[1]) ?? null), live, graph)), graph);
|
|
815
|
+
let joined = live_union(live, next);
|
|
816
|
+
((changed = ((__eliscript_value_90, __eliscript_value_91) => (__eliscript_value_90 !== __eliscript_value_91))(((joined) ?? []).length, ((live) ?? []).length)));
|
|
817
|
+
((live = joined));
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
} else {
|
|
823
|
+
{
|
|
824
|
+
const __eliscript_value_92 = __eliscript_numeric_decrement(((children) ?? []).length);
|
|
825
|
+
{
|
|
826
|
+
let i = __eliscript_value_92;
|
|
827
|
+
while (__eliscript_numeric_relation(">=", i, 0)) {
|
|
828
|
+
((live = live_before(((((children) ?? [])[i]) ?? null), (((kind === "and") || (kind === "or")) ? live_union(after, live) : live), graph)));
|
|
829
|
+
((i = __eliscript_numeric_decrement(i)));
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return live;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
function allocate_registers(body, locals, arity) {
|
|
842
|
+
{
|
|
843
|
+
const __eliscript_value_93 = ((locals) ?? []).length;
|
|
844
|
+
const __eliscript_value_94 = [];
|
|
845
|
+
const __eliscript_value_95 = [];
|
|
846
|
+
const __eliscript_value_96 = [];
|
|
847
|
+
const __eliscript_value_97 = [];
|
|
848
|
+
const __eliscript_value_98 = [];
|
|
849
|
+
const __eliscript_value_99 = 0;
|
|
850
|
+
{
|
|
851
|
+
let count = __eliscript_value_93;
|
|
852
|
+
let counts = __eliscript_value_94;
|
|
853
|
+
let registers = __eliscript_value_95;
|
|
854
|
+
let available = __eliscript_value_96;
|
|
855
|
+
let integers = __eliscript_value_97;
|
|
856
|
+
let graph = __eliscript_value_98;
|
|
857
|
+
let i = __eliscript_value_99;
|
|
858
|
+
while (__eliscript_numeric_relation("<", i, count)) {
|
|
859
|
+
(counts)["push"](0);
|
|
860
|
+
(registers)["push"](-1);
|
|
861
|
+
(graph)["push"]([]);
|
|
862
|
+
((i = (i + 1)));
|
|
863
|
+
}
|
|
864
|
+
register_weights(body, counts);
|
|
865
|
+
live_before(body, [], graph);
|
|
866
|
+
((i = 0));
|
|
867
|
+
while (__eliscript_numeric_relation("<", i, arity)) {
|
|
868
|
+
{
|
|
869
|
+
const __eliscript_value_100 = 0;
|
|
870
|
+
{
|
|
871
|
+
let j = __eliscript_value_100;
|
|
872
|
+
while (__eliscript_numeric_relation("<", j, arity)) {
|
|
873
|
+
if ((((__eliscript_value_101, __eliscript_value_102) => (__eliscript_value_101 !== __eliscript_value_102))(i, j) && __eliscript_numeric_relation(">", ((((counts) ?? [])[i]) ?? null), 0) && __eliscript_numeric_relation(">", ((((counts) ?? [])[j]) ?? null), 0))) {
|
|
874
|
+
interference(graph, i, [j]);
|
|
875
|
+
}
|
|
876
|
+
((j = (j + 1)));
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
((i = (i + 1)));
|
|
881
|
+
}
|
|
882
|
+
((i = 2));
|
|
883
|
+
while (__eliscript_numeric_relation("<", i, 32)) {
|
|
884
|
+
if ((__eliscript_numeric_relation("<", i, 16) || __eliscript_numeric_relation(">=", i, 24))) {
|
|
885
|
+
(available)["push"](i);
|
|
886
|
+
}
|
|
887
|
+
((i = (i + 1)));
|
|
888
|
+
}
|
|
889
|
+
((i = 10));
|
|
890
|
+
while (__eliscript_numeric_relation("<", i, 29)) {
|
|
891
|
+
if ((__eliscript_numeric_relation("<", i, 16) || __eliscript_numeric_relation(">=", i, 19))) {
|
|
892
|
+
(integers)["push"](i);
|
|
893
|
+
}
|
|
894
|
+
((i = (i + 1)));
|
|
895
|
+
}
|
|
896
|
+
assign_register_class(counts, locals, registers, available, "f64", graph);
|
|
897
|
+
assign_register_class(counts, locals, registers, integers, "i32", graph);
|
|
898
|
+
return ({"registers": registers, "leaf": true});
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
function assign_register_class(counts, locals, registers, available, type, graph) {
|
|
903
|
+
{
|
|
904
|
+
const __eliscript_value_103 = 0;
|
|
905
|
+
const __eliscript_value_104 = ((locals) ?? []).length;
|
|
906
|
+
const __eliscript_value_105 = [];
|
|
907
|
+
{
|
|
908
|
+
let i = __eliscript_value_103;
|
|
909
|
+
let count = __eliscript_value_104;
|
|
910
|
+
let processed = __eliscript_value_105;
|
|
911
|
+
while (__eliscript_numeric_relation("<", i, count)) {
|
|
912
|
+
{
|
|
913
|
+
const __eliscript_value_106 = -1;
|
|
914
|
+
const __eliscript_value_107 = 0;
|
|
915
|
+
const __eliscript_value_108 = 0;
|
|
916
|
+
{
|
|
917
|
+
let best = __eliscript_value_106;
|
|
918
|
+
let weight = __eliscript_value_107;
|
|
919
|
+
let j = __eliscript_value_108;
|
|
920
|
+
while (__eliscript_numeric_relation("<", j, count)) {
|
|
921
|
+
if ((((((((locals) ?? [])[j]) ?? null))["type"] === type) && (!__eliscript_truthy((processed)["includes"](j))) && __eliscript_numeric_relation(">", ((((counts) ?? [])[j]) ?? null), weight))) {
|
|
922
|
+
((best = j));
|
|
923
|
+
((weight = ((((counts) ?? [])[j]) ?? null)));
|
|
924
|
+
}
|
|
925
|
+
((j = (j + 1)));
|
|
926
|
+
}
|
|
927
|
+
if (__eliscript_numeric_relation(">=", best, 0)) {
|
|
928
|
+
(processed)["push"](best);
|
|
929
|
+
((j = 0));
|
|
930
|
+
while ((__eliscript_numeric_relation("<", j, ((available) ?? []).length) && (((((registers) ?? [])[best]) ?? null) === -1))) {
|
|
931
|
+
{
|
|
932
|
+
const __eliscript_value_109 = ((type === "f64") ? ((((available) ?? [])[j]) ?? null) : __eliscript_numeric_sub(-2, ((((available) ?? [])[j]) ?? null)));
|
|
933
|
+
const __eliscript_value_110 = ((((graph) ?? [])[best]) ?? null);
|
|
934
|
+
const __eliscript_value_111 = 0;
|
|
935
|
+
const __eliscript_value_112 = null;
|
|
936
|
+
{
|
|
937
|
+
let r = __eliscript_value_109;
|
|
938
|
+
let neighbors = __eliscript_value_110;
|
|
939
|
+
let k = __eliscript_value_111;
|
|
940
|
+
let conflict = __eliscript_value_112;
|
|
941
|
+
while (__eliscript_numeric_relation("<", k, ((neighbors) ?? []).length)) {
|
|
942
|
+
if ((((((registers) ?? [])[((((neighbors) ?? [])[k]) ?? null)]) ?? null) === r)) {
|
|
943
|
+
((conflict = true));
|
|
944
|
+
}
|
|
945
|
+
((k = (k + 1)));
|
|
946
|
+
}
|
|
947
|
+
if ((!__eliscript_truthy(conflict))) {
|
|
948
|
+
(registers)["splice"](best, 1, r);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
((j = (j + 1)));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
((i = (i + 1)));
|
|
958
|
+
}
|
|
959
|
+
return registers;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
function preserve_registers(state, count, restore) {
|
|
964
|
+
{
|
|
965
|
+
const __eliscript_value_113 = 8;
|
|
966
|
+
const __eliscript_value_114 = (state)["registers"];
|
|
967
|
+
{
|
|
968
|
+
let register = __eliscript_value_113;
|
|
969
|
+
let registers = __eliscript_value_114;
|
|
970
|
+
while (__eliscript_numeric_relation("<", register, 16)) {
|
|
971
|
+
if (__eliscript_truthy((registers)["includes"](register))) {
|
|
972
|
+
integer_register(state, 9, __eliscript_numeric_mul((count + __eliscript_numeric_sub(register, 8) + 1), 8), 0);
|
|
973
|
+
word(state, 3406365609);
|
|
974
|
+
word(state, ((__eliscript_truthy(restore) ? 4248830240 : 4244635936) + register));
|
|
975
|
+
}
|
|
976
|
+
((register = (register + 1)));
|
|
977
|
+
}
|
|
978
|
+
((register = 19));
|
|
979
|
+
while (__eliscript_numeric_relation("<", register, 29)) {
|
|
980
|
+
if (__eliscript_truthy((registers)["includes"](__eliscript_numeric_sub(-2, register)))) {
|
|
981
|
+
integer_register(state, 9, __eliscript_numeric_mul((count + 8 + __eliscript_numeric_sub(register, 19) + 1), 8), 0);
|
|
982
|
+
word(state, 3406365609);
|
|
983
|
+
word(state, ((__eliscript_truthy(restore) ? 4181721376 : 4177527072) + register));
|
|
984
|
+
}
|
|
985
|
+
((register = (register + 1)));
|
|
986
|
+
}
|
|
987
|
+
return null;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
function local_register(state, node, type) {
|
|
992
|
+
if (((node)["kind"] === "local")) {
|
|
993
|
+
{
|
|
994
|
+
let registers = (state)["registers"];
|
|
995
|
+
let index = (node)["value"];
|
|
996
|
+
let register = (__eliscript_numeric_relation("<", index, ((registers) ?? []).length) ? ((((registers) ?? [])[index]) ?? null) : -1);
|
|
997
|
+
if ((type === "f64")) {
|
|
998
|
+
return register;
|
|
999
|
+
} else {
|
|
1000
|
+
if (__eliscript_numeric_relation("<=", register, -2)) {
|
|
1001
|
+
return __eliscript_numeric_sub(__eliscript_numeric_neg(register), 2);
|
|
1002
|
+
} else {
|
|
1003
|
+
return -1;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
} else {
|
|
1008
|
+
return -1;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function operands(state, left, right, type) {
|
|
1012
|
+
if (__eliscript_truthy(((__eliscript_value_115) => (__eliscript_truthy(__eliscript_value_115) ? ((__eliscript_value_116) => (__eliscript_truthy(__eliscript_value_116) ? ((__eliscript_value_117) => (__eliscript_truthy(__eliscript_value_117) ? __eliscript_numeric_relation("<=", (pure_depth(left) + pure_depth(right)), __eliscript_numeric_sub(7, ((state)["depth"] ?? 0))) : __eliscript_value_117))(direct_value(state, right)) : __eliscript_value_116))(direct_value(state, left)) : __eliscript_value_115))((type === "f64")))) {
|
|
1013
|
+
{
|
|
1014
|
+
let depth = ((state)["depth"] ?? 0);
|
|
1015
|
+
let l = capture_before(state, pure_value(state, left), right);
|
|
1016
|
+
let r = pure_value(state, right);
|
|
1017
|
+
((state)["depth"] = depth);
|
|
1018
|
+
return [l, r];
|
|
1019
|
+
}
|
|
1020
|
+
} else {
|
|
1021
|
+
if (__eliscript_truthy(((__eliscript_value_118) => (__eliscript_truthy(__eliscript_value_118) ? (((right)["kind"] === "literal") || ((right)["kind"] === "local") || ((right)["kind"] === "int-literal")) : __eliscript_value_118))(((state)["compact"] ?? null)))) {
|
|
1022
|
+
{
|
|
1023
|
+
const __eliscript_value_119 = local_register(state, left, type);
|
|
1024
|
+
const __eliscript_value_120 = local_register(state, right, type);
|
|
1025
|
+
{
|
|
1026
|
+
let l = __eliscript_value_119;
|
|
1027
|
+
let r = __eliscript_value_120;
|
|
1028
|
+
if (__eliscript_numeric_relation("<", l, 0)) {
|
|
1029
|
+
expression(state, left);
|
|
1030
|
+
if (__eliscript_numeric_relation("<", r, 0)) {
|
|
1031
|
+
word(state, ((type === "f64") ? 509624321 : 704644065));
|
|
1032
|
+
((l = 1));
|
|
1033
|
+
} else {
|
|
1034
|
+
((l = 0));
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
if (__eliscript_numeric_relation("<", r, 0)) {
|
|
1038
|
+
expression(state, right);
|
|
1039
|
+
((r = 0));
|
|
1040
|
+
}
|
|
1041
|
+
return [l, r];
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
} else {
|
|
1045
|
+
expression(state, left);
|
|
1046
|
+
push_value(state, type);
|
|
1047
|
+
expression(state, right);
|
|
1048
|
+
pop_value(state, type);
|
|
1049
|
+
return [1, 0];
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
function binary_word(state, opcode, registers) {
|
|
1054
|
+
return word(state, (__eliscript_numeric_sub(opcode, 32) + __eliscript_numeric_mul(((((registers) ?? [])[0]) ?? null), 32) + __eliscript_numeric_mul(((((registers) ?? [])[1]) ?? null), 65536)));
|
|
1055
|
+
}
|
|
1056
|
+
function pure_depth(node) {
|
|
1057
|
+
{
|
|
1058
|
+
const __eliscript_value_121 = 0;
|
|
1059
|
+
const __eliscript_value_122 = 0;
|
|
1060
|
+
const __eliscript_value_123 = (node)["children"];
|
|
1061
|
+
{
|
|
1062
|
+
let depth = __eliscript_value_121;
|
|
1063
|
+
let i = __eliscript_value_122;
|
|
1064
|
+
let children = __eliscript_value_123;
|
|
1065
|
+
if ((((node)["kind"] === "sequence") && __eliscript_numeric_relation(">", ((children) ?? []).length, 0))) {
|
|
1066
|
+
((i = __eliscript_numeric_decrement(((children) ?? []).length)));
|
|
1067
|
+
}
|
|
1068
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
1069
|
+
{
|
|
1070
|
+
const __eliscript_value_124 = pure_depth(((((children) ?? [])[i]) ?? null));
|
|
1071
|
+
{
|
|
1072
|
+
let child = __eliscript_value_124;
|
|
1073
|
+
if (__eliscript_numeric_relation(">", child, depth)) {
|
|
1074
|
+
((depth = child));
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
((i = (i + 1)));
|
|
1079
|
+
}
|
|
1080
|
+
if (((node)["kind"] === "sequence")) {
|
|
1081
|
+
return depth;
|
|
1082
|
+
} else {
|
|
1083
|
+
return (depth + 1);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
function direct_value_tree(node) {
|
|
1089
|
+
{
|
|
1090
|
+
const __eliscript_value_125 = (node)["kind"];
|
|
1091
|
+
const __eliscript_value_126 = (node)["children"];
|
|
1092
|
+
const __eliscript_value_127 = 0;
|
|
1093
|
+
const __eliscript_value_128 = true;
|
|
1094
|
+
{
|
|
1095
|
+
let kind = __eliscript_value_125;
|
|
1096
|
+
let children = __eliscript_value_126;
|
|
1097
|
+
let i = __eliscript_value_127;
|
|
1098
|
+
let valid = __eliscript_value_128;
|
|
1099
|
+
if (((kind === "call") || (kind === "while") || (kind === "remainder-while") || (kind === "guarded-while"))) {
|
|
1100
|
+
((valid = null));
|
|
1101
|
+
}
|
|
1102
|
+
while (__eliscript_truthy(((__eliscript_value_129) => (__eliscript_truthy(__eliscript_value_129) ? __eliscript_numeric_relation("<", i, ((children) ?? []).length) : __eliscript_value_129))(valid))) {
|
|
1103
|
+
((valid = direct_value_tree(((((children) ?? [])[i]) ?? null))));
|
|
1104
|
+
((i = (i + 1)));
|
|
1105
|
+
}
|
|
1106
|
+
return valid;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function direct_value(state, node) {
|
|
1111
|
+
return ((__eliscript_value_130) => (__eliscript_truthy(__eliscript_value_130) ? ((__eliscript_value_131) => (__eliscript_truthy(__eliscript_value_131) ? ((__eliscript_value_132) => (__eliscript_truthy(__eliscript_value_132) ? __eliscript_numeric_relation("<=", pure_depth(node), __eliscript_numeric_sub(7, ((state)["depth"] ?? 0))) : __eliscript_value_132))(direct_value_tree(node)) : __eliscript_value_131))(((node)["type"] === "f64")) : __eliscript_value_130))(((state)["compact"] ?? null));
|
|
1112
|
+
}
|
|
1113
|
+
function retarget_last(state, register) {
|
|
1114
|
+
{
|
|
1115
|
+
let words = (state)["words"];
|
|
1116
|
+
let at = __eliscript_numeric_decrement(((words) ?? []).length);
|
|
1117
|
+
return native_word_set(words, at, __eliscript_numeric_or(__eliscript_numeric_and(native_word_at(words, at), 4294967264), register));
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
function writes_physical(state, node, register) {
|
|
1121
|
+
{
|
|
1122
|
+
const __eliscript_value_133 = (node)["kind"];
|
|
1123
|
+
const __eliscript_value_134 = (node)["children"];
|
|
1124
|
+
const __eliscript_value_135 = 0;
|
|
1125
|
+
const __eliscript_value_136 = null;
|
|
1126
|
+
{
|
|
1127
|
+
let kind = __eliscript_value_133;
|
|
1128
|
+
let children = __eliscript_value_134;
|
|
1129
|
+
let i = __eliscript_value_135;
|
|
1130
|
+
let found = __eliscript_value_136;
|
|
1131
|
+
if (((kind === "set") || (kind === "initialize"))) {
|
|
1132
|
+
((found = (register === (((((state)["registers"]) ?? [])[(node)["value"]]) ?? null))));
|
|
1133
|
+
}
|
|
1134
|
+
while (((!__eliscript_truthy(found)) && __eliscript_numeric_relation("<", i, ((children) ?? []).length))) {
|
|
1135
|
+
((found = writes_physical(state, ((((children) ?? [])[i]) ?? null), register)));
|
|
1136
|
+
((i = (i + 1)));
|
|
1137
|
+
}
|
|
1138
|
+
return found;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
function capture_before(state, register, right) {
|
|
1143
|
+
if (__eliscript_truthy(writes_physical(state, right, register))) {
|
|
1144
|
+
{
|
|
1145
|
+
let depth = ((state)["depth"] ?? 0);
|
|
1146
|
+
let temp = (16 + depth);
|
|
1147
|
+
word(state, (509624320 + __eliscript_numeric_mul(register, 32) + temp));
|
|
1148
|
+
((state)["depth"] = (depth + 1));
|
|
1149
|
+
return temp;
|
|
1150
|
+
}
|
|
1151
|
+
} else {
|
|
1152
|
+
return register;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
function store_float_value(state, index, register) {
|
|
1156
|
+
{
|
|
1157
|
+
const __eliscript_value_137 = (((((state)["registers"]) ?? [])[index]) ?? null);
|
|
1158
|
+
{
|
|
1159
|
+
let target = __eliscript_value_137;
|
|
1160
|
+
if (__eliscript_numeric_relation(">=", target, 0)) {
|
|
1161
|
+
if ((!(target === register))) {
|
|
1162
|
+
word(state, (509624320 + __eliscript_numeric_mul(register, 32) + target));
|
|
1163
|
+
}
|
|
1164
|
+
return target;
|
|
1165
|
+
} else {
|
|
1166
|
+
if ((!(register === 0))) {
|
|
1167
|
+
word(state, (509624320 + __eliscript_numeric_mul(register, 32)));
|
|
1168
|
+
}
|
|
1169
|
+
local_access(state, index, "f64", true);
|
|
1170
|
+
return register;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function pure_value(state, node) {
|
|
1176
|
+
{
|
|
1177
|
+
const __eliscript_value_138 = (node)["kind"];
|
|
1178
|
+
const __eliscript_value_139 = (node)["children"];
|
|
1179
|
+
const __eliscript_value_140 = (node)["value"];
|
|
1180
|
+
const __eliscript_value_141 = ((state)["depth"] ?? 0);
|
|
1181
|
+
const __eliscript_value_142 = local_register(state, node, "f64");
|
|
1182
|
+
{
|
|
1183
|
+
let kind = __eliscript_value_138;
|
|
1184
|
+
let children = __eliscript_value_139;
|
|
1185
|
+
let value = __eliscript_value_140;
|
|
1186
|
+
let depth = __eliscript_value_141;
|
|
1187
|
+
let local = __eliscript_value_142;
|
|
1188
|
+
if (__eliscript_numeric_relation(">=", local, 0)) {
|
|
1189
|
+
return local;
|
|
1190
|
+
} else {
|
|
1191
|
+
{
|
|
1192
|
+
const __eliscript_value_143 = (16 + depth);
|
|
1193
|
+
{
|
|
1194
|
+
let register = __eliscript_value_143;
|
|
1195
|
+
if ((kind === "literal")) {
|
|
1196
|
+
{
|
|
1197
|
+
const __eliscript_value_144 = literal_register(state, value);
|
|
1198
|
+
{
|
|
1199
|
+
let constant = __eliscript_value_144;
|
|
1200
|
+
if (__eliscript_numeric_relation(">=", constant, 0)) {
|
|
1201
|
+
((register = constant));
|
|
1202
|
+
} else {
|
|
1203
|
+
float_literal(state, value);
|
|
1204
|
+
retarget_last(state, register);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
} else {
|
|
1209
|
+
if (((kind === "set") || (kind === "initialize"))) {
|
|
1210
|
+
{
|
|
1211
|
+
let rhs = ((((children) ?? [])[0]) ?? null);
|
|
1212
|
+
let r = pure_value(state, rhs);
|
|
1213
|
+
let target = (((((state)["registers"]) ?? [])[value]) ?? null);
|
|
1214
|
+
if ((__eliscript_numeric_relation(">=", target, 0) && (r === register) && (__eliscript_numeric_and(native_word_at((state)["words"], __eliscript_numeric_decrement((((state)["words"]) ?? []).length)), 31) === r) && (((rhs)["kind"] === "arithmetic") || ((rhs)["kind"] === "literal")))) {
|
|
1215
|
+
retarget_last(state, target);
|
|
1216
|
+
((register = target));
|
|
1217
|
+
} else {
|
|
1218
|
+
((register = store_float_value(state, value, r)));
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
} else {
|
|
1222
|
+
if ((kind === "sequence")) {
|
|
1223
|
+
{
|
|
1224
|
+
const __eliscript_value_145 = 0;
|
|
1225
|
+
{
|
|
1226
|
+
let i = __eliscript_value_145;
|
|
1227
|
+
while (__eliscript_numeric_relation("<", i, __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
1228
|
+
discarded(state, ((((children) ?? [])[i]) ?? null));
|
|
1229
|
+
((i = (i + 1)));
|
|
1230
|
+
}
|
|
1231
|
+
((register = pure_value(state, ((((children) ?? [])[i]) ?? null))));
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
} else {
|
|
1235
|
+
if ((kind === "int-number")) {
|
|
1236
|
+
{
|
|
1237
|
+
const __eliscript_value_146 = local_register(state, ((((children) ?? [])[0]) ?? null), "i32");
|
|
1238
|
+
{
|
|
1239
|
+
let source = __eliscript_value_146;
|
|
1240
|
+
if (__eliscript_numeric_relation("<", source, 0)) {
|
|
1241
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
1242
|
+
((source = 0));
|
|
1243
|
+
}
|
|
1244
|
+
word(state, (509739008 + __eliscript_numeric_mul(source, 32) + register));
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
} else {
|
|
1248
|
+
if ((kind === "arithmetic")) {
|
|
1249
|
+
{
|
|
1250
|
+
const __eliscript_value_147 = ((children) ?? []).length;
|
|
1251
|
+
{
|
|
1252
|
+
let length = __eliscript_value_147;
|
|
1253
|
+
if ((length === 0)) {
|
|
1254
|
+
float_literal(state, ((value === "*") ? 1 : 0));
|
|
1255
|
+
retarget_last(state, register);
|
|
1256
|
+
} else {
|
|
1257
|
+
if (((length === 1) && ((value === "+") || (value === "*")))) {
|
|
1258
|
+
((register = pure_value(state, ((((children) ?? [])[0]) ?? null))));
|
|
1259
|
+
} else {
|
|
1260
|
+
if (((length === 1) && (value === "-"))) {
|
|
1261
|
+
word(state, (509689856 + __eliscript_numeric_mul(pure_value(state, ((((children) ?? [])[0]) ?? null)), 32) + register));
|
|
1262
|
+
} else {
|
|
1263
|
+
{
|
|
1264
|
+
let left = (((length === 1) && (value === "/")) ? ({"kind": "literal", "type": "f64", "value": 1}) : ((((children) ?? [])[0]) ?? null));
|
|
1265
|
+
let right = ((length === 2) ? ((((children) ?? [])[1]) ?? null) : ((value === "/") ? ((((children) ?? [])[0]) ?? null) : ({"kind": "literal", "type": "f64", "value": 1})));
|
|
1266
|
+
let l = capture_before(state, pure_value(state, left), right);
|
|
1267
|
+
let r = pure_value(state, right);
|
|
1268
|
+
binary_word(state, (((value === "+") || (value === "1+")) ? 509618208 : (((value === "-") || (value === "1-")) ? 509622304 : ((value === "*") ? 509610016 : 509614112))), [l, r]);
|
|
1269
|
+
retarget_last(state, register);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
} else {
|
|
1277
|
+
expression(state, node);
|
|
1278
|
+
word(state, (509624320 + register));
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
((state)["depth"] = (depth + 1));
|
|
1285
|
+
return register;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
function discarded_pure(node) {
|
|
1293
|
+
if ((((node)["kind"] === "sequence") || ((node)["kind"] === "if"))) {
|
|
1294
|
+
{
|
|
1295
|
+
const __eliscript_value_148 = (node)["children"];
|
|
1296
|
+
const __eliscript_value_149 = 0;
|
|
1297
|
+
const __eliscript_value_150 = true;
|
|
1298
|
+
{
|
|
1299
|
+
let children = __eliscript_value_148;
|
|
1300
|
+
let i = __eliscript_value_149;
|
|
1301
|
+
let pure = __eliscript_value_150;
|
|
1302
|
+
while (__eliscript_truthy(((__eliscript_value_151) => (__eliscript_truthy(__eliscript_value_151) ? __eliscript_numeric_relation("<", i, ((children) ?? []).length) : __eliscript_value_151))(pure))) {
|
|
1303
|
+
((pure = discarded_pure(((((children) ?? [])[i]) ?? null))));
|
|
1304
|
+
((i = (i + 1)));
|
|
1305
|
+
}
|
|
1306
|
+
return pure;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
} else {
|
|
1310
|
+
return numeric_pure(node);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
function discarded(state, node) {
|
|
1314
|
+
{
|
|
1315
|
+
const __eliscript_value_152 = (node)["kind"];
|
|
1316
|
+
const __eliscript_value_153 = (node)["children"];
|
|
1317
|
+
const __eliscript_value_154 = 0;
|
|
1318
|
+
{
|
|
1319
|
+
let kind = __eliscript_value_152;
|
|
1320
|
+
let children = __eliscript_value_153;
|
|
1321
|
+
let i = __eliscript_value_154;
|
|
1322
|
+
if (((kind === "literal") || (kind === "int-literal") || (kind === "local"))) {
|
|
1323
|
+
return null;
|
|
1324
|
+
} else {
|
|
1325
|
+
if (__eliscript_truthy(((__eliscript_value_155) => (__eliscript_truthy(__eliscript_value_155) ? (((kind === "set") || (kind === "initialize")) && (!__eliscript_truthy(((node)["storeLive"] ?? null)))) : __eliscript_value_155))(((state)["compact"] ?? null)))) {
|
|
1326
|
+
return discarded(state, ((((children) ?? [])[0]) ?? null));
|
|
1327
|
+
} else {
|
|
1328
|
+
if (((kind === "sequence") || (kind === "arithmetic") || (kind === "compare") || (kind === "not") || (kind === "int-number") || (kind === "ceil-int") || (kind === "int-add") || (kind === "int-sub") || (kind === "int-and") || (kind === "int-compare"))) {
|
|
1329
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
1330
|
+
discarded(state, ((((children) ?? [])[i]) ?? null));
|
|
1331
|
+
((i = (i + 1)));
|
|
1332
|
+
}
|
|
1333
|
+
return null;
|
|
1334
|
+
} else {
|
|
1335
|
+
if ((kind === "if")) {
|
|
1336
|
+
if (__eliscript_truthy(((__eliscript_value_156) => (__eliscript_truthy(__eliscript_value_156) ? discarded_pure(((((children) ?? [])[2]) ?? null)) : __eliscript_value_156))(discarded_pure(((((children) ?? [])[1]) ?? null))))) {
|
|
1337
|
+
return discarded(state, ((((children) ?? [])[0]) ?? null));
|
|
1338
|
+
} else {
|
|
1339
|
+
{
|
|
1340
|
+
const __eliscript_value_157 = condition_jumps(state, ((((children) ?? [])[0]) ?? null), null);
|
|
1341
|
+
{
|
|
1342
|
+
let otherwise = __eliscript_value_157;
|
|
1343
|
+
discarded(state, ((((children) ?? [])[1]) ?? null));
|
|
1344
|
+
{
|
|
1345
|
+
const __eliscript_value_158 = jump(state, "jump");
|
|
1346
|
+
{
|
|
1347
|
+
let end = __eliscript_value_158;
|
|
1348
|
+
patch_conditions(state, otherwise, (((state)["words"]) ?? []).length);
|
|
1349
|
+
discarded(state, ((((children) ?? [])[2]) ?? null));
|
|
1350
|
+
return patch_jump(state, end, (((state)["words"]) ?? []).length);
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
} else {
|
|
1357
|
+
if (((kind === "while") || (kind === "remainder-while") || (kind === "guarded-while"))) {
|
|
1358
|
+
return emit_loop(state, children, null);
|
|
1359
|
+
} else {
|
|
1360
|
+
if (__eliscript_truthy(((__eliscript_value_159) => (__eliscript_truthy(__eliscript_value_159) ? ((__eliscript_value_160) => (__eliscript_truthy(__eliscript_value_160) ? ((__eliscript_value_161) => (__eliscript_truthy(__eliscript_value_161) ? (__eliscript_numeric_relation("<=", (((((state)["registers"]) ?? [])[(node)["value"]]) ?? null), -2) && (((((((children) ?? [])[0]) ?? null))["kind"] === "int-add") || ((((((children) ?? [])[0]) ?? null))["kind"] === "int-sub") || ((((((children) ?? [])[0]) ?? null))["kind"] === "int-and"))) : __eliscript_value_161))(((state)["compact"] ?? null)) : __eliscript_value_160))(((node)["type"] === "i32")) : __eliscript_value_159))(((kind === "set") || (kind === "initialize"))))) {
|
|
1361
|
+
return integer_operation(state, ((((children) ?? [])[0]) ?? null), __eliscript_numeric_sub(__eliscript_numeric_neg((((((state)["registers"]) ?? [])[(node)["value"]]) ?? null)), 2));
|
|
1362
|
+
} else {
|
|
1363
|
+
if (__eliscript_truthy(((__eliscript_value_162) => (__eliscript_truthy(__eliscript_value_162) ? direct_value(state, ((((children) ?? [])[0]) ?? null)) : __eliscript_value_162))(((kind === "set") || (kind === "initialize"))))) {
|
|
1364
|
+
{
|
|
1365
|
+
let depth = ((state)["depth"] ?? 0);
|
|
1366
|
+
let rhs = ((((children) ?? [])[0]) ?? null);
|
|
1367
|
+
let r = pure_value(state, rhs);
|
|
1368
|
+
let registers = (state)["registers"];
|
|
1369
|
+
let target = ((((registers) ?? [])[(node)["value"]]) ?? null);
|
|
1370
|
+
if ((__eliscript_numeric_relation(">=", target, 0) && (r === (16 + depth)) && (__eliscript_numeric_and(native_word_at((state)["words"], __eliscript_numeric_decrement((((state)["words"]) ?? []).length)), 31) === r) && (((rhs)["kind"] === "arithmetic") || ((rhs)["kind"] === "literal")))) {
|
|
1371
|
+
retarget_last(state, target);
|
|
1372
|
+
} else {
|
|
1373
|
+
store_float_value(state, (node)["value"], r);
|
|
1374
|
+
}
|
|
1375
|
+
return ((state)["depth"] = depth);
|
|
1376
|
+
}
|
|
1377
|
+
} else {
|
|
1378
|
+
return expression(state, node);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
function stack_float(state, offset, register, store) {
|
|
1390
|
+
word(state, 2432697321);
|
|
1391
|
+
while (__eliscript_numeric_relation(">", offset, 0)) {
|
|
1392
|
+
{
|
|
1393
|
+
const __eliscript_value_163 = (__eliscript_numeric_relation("<", offset, 4095) ? offset : 4095);
|
|
1394
|
+
{
|
|
1395
|
+
let part = __eliscript_value_163;
|
|
1396
|
+
word(state, (2432696617 + __eliscript_numeric_mul(part, 1024)));
|
|
1397
|
+
((offset = __eliscript_numeric_sub(offset, part)));
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
return word(state, ((__eliscript_truthy(store) ? 4244635936 : 4248830240) + register));
|
|
1402
|
+
}
|
|
1403
|
+
function jump(state, kind) {
|
|
1404
|
+
{
|
|
1405
|
+
const __eliscript_value_164 = (((state)["words"]) ?? []).length;
|
|
1406
|
+
{
|
|
1407
|
+
let at = __eliscript_value_164;
|
|
1408
|
+
word(state, ((kind === "zero") ? 872415232 : ((kind === "nonzero") ? 889192448 : 335544320)));
|
|
1409
|
+
return at;
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
function branch_kind(opcode) {
|
|
1414
|
+
if ((__eliscript_numeric_and(opcode, 2080374784) === 335544320)) {
|
|
1415
|
+
return 0;
|
|
1416
|
+
} else {
|
|
1417
|
+
if ((__eliscript_numeric_and(opcode, 4278190096) === 1409286144)) {
|
|
1418
|
+
return 1;
|
|
1419
|
+
} else {
|
|
1420
|
+
if ((__eliscript_numeric_and(opcode, 2113929216) === 872415232)) {
|
|
1421
|
+
return 2;
|
|
1422
|
+
} else {
|
|
1423
|
+
if ((__eliscript_numeric_and(opcode, 2113929216) === 905969664)) {
|
|
1424
|
+
return 3;
|
|
1425
|
+
} else {
|
|
1426
|
+
return backend_fail(null, "unsupported native branch instruction");
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
function branch_limit(kind) {
|
|
1433
|
+
if ((kind === 0)) {
|
|
1434
|
+
return 33554432;
|
|
1435
|
+
} else {
|
|
1436
|
+
if ((kind === 3)) {
|
|
1437
|
+
return 8192;
|
|
1438
|
+
} else {
|
|
1439
|
+
return 262144;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
function branch_fits(distance, limit) {
|
|
1444
|
+
return (__eliscript_numeric_relation(">=", distance, __eliscript_numeric_neg(limit)) && __eliscript_numeric_relation("<", distance, limit));
|
|
1445
|
+
}
|
|
1446
|
+
function branch_word(opcode, distance) {
|
|
1447
|
+
{
|
|
1448
|
+
let kind = branch_kind(opcode);
|
|
1449
|
+
let limit = branch_limit(kind);
|
|
1450
|
+
if ((!__eliscript_truthy(branch_fits(distance, limit)))) {
|
|
1451
|
+
backend_fail(null, "native branch exceeds ARM64 displacement range");
|
|
1452
|
+
}
|
|
1453
|
+
if ((kind === 0)) {
|
|
1454
|
+
return __eliscript_numeric_or(__eliscript_numeric_and(opcode, 4227858432), __eliscript_numeric_and(distance, 67108863));
|
|
1455
|
+
} else {
|
|
1456
|
+
return __eliscript_numeric_or(__eliscript_numeric_and(opcode, ((kind === 3) ? 4294443039 : 4278190111)), __eliscript_numeric_mul(__eliscript_numeric_and(distance, ((kind === 3) ? 16383 : 524287)), 32));
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
function patch_jump_record(state, at, target, record, descriptor) {
|
|
1461
|
+
{
|
|
1462
|
+
let words = (state)["words"];
|
|
1463
|
+
let opcode = native_word_at(words, at);
|
|
1464
|
+
let branches = ((__eliscript_value_165) => (__eliscript_truthy(__eliscript_value_165) ? __eliscript_value_165 : ((created) => {
|
|
1465
|
+
((state)["branches"] = created);
|
|
1466
|
+
return created;
|
|
1467
|
+
})([])))(((state)["branches"] ?? null));
|
|
1468
|
+
let kind = branch_kind(opcode);
|
|
1469
|
+
let distance = __eliscript_numeric_sub(target, at);
|
|
1470
|
+
{
|
|
1471
|
+
const __eliscript_value_166 = ((__eliscript_value_167) => (__eliscript_truthy(__eliscript_value_167) ? __eliscript_value_167 : ({"at": at, "target": target, "opcode": opcode, "kind": kind, "size": 1})))(record);
|
|
1472
|
+
{
|
|
1473
|
+
let entry = __eliscript_value_166;
|
|
1474
|
+
if (__eliscript_truthy(record)) {
|
|
1475
|
+
((entry)["at"] = at);
|
|
1476
|
+
((entry)["target"] = target);
|
|
1477
|
+
((descriptor)["value"] = opcode);
|
|
1478
|
+
Object.defineProperty(entry, "opcode", descriptor);
|
|
1479
|
+
((descriptor)["value"] = kind);
|
|
1480
|
+
Object.defineProperty(entry, "kind", descriptor);
|
|
1481
|
+
((descriptor)["value"] = 1);
|
|
1482
|
+
Object.defineProperty(entry, "size", descriptor);
|
|
1483
|
+
}
|
|
1484
|
+
(branches)["push"](entry);
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
if (__eliscript_truthy(branch_fits(distance, branch_limit(kind)))) {
|
|
1488
|
+
return native_word_set(words, at, branch_word(opcode, distance));
|
|
1489
|
+
} else {
|
|
1490
|
+
return null;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
function patch_jump(state, at, target) {
|
|
1495
|
+
return patch_jump_record(state, at, target, null, null);
|
|
1496
|
+
}
|
|
1497
|
+
function finish_calls(state, offsets) {
|
|
1498
|
+
{
|
|
1499
|
+
let calls = (state)["calls"];
|
|
1500
|
+
let count = ((calls) ?? []).length;
|
|
1501
|
+
let index = 0;
|
|
1502
|
+
let descriptor = Object.create(null);
|
|
1503
|
+
((descriptor)["value"] = 0);
|
|
1504
|
+
((descriptor)["writable"] = true);
|
|
1505
|
+
((descriptor)["enumerable"] = true);
|
|
1506
|
+
((descriptor)["configurable"] = true);
|
|
1507
|
+
while (__eliscript_numeric_relation("<", index, count)) {
|
|
1508
|
+
{
|
|
1509
|
+
let call = ((((calls) ?? [])[index]) ?? null);
|
|
1510
|
+
let at = (call)["at"];
|
|
1511
|
+
let target = __eliscript_numeric_div(((((offsets) ?? [])[(call)["target"]]) ?? null), 4);
|
|
1512
|
+
patch_jump_record(state, at, target, call, descriptor);
|
|
1513
|
+
((calls)[index] = null);
|
|
1514
|
+
}
|
|
1515
|
+
((index = (index + 1)));
|
|
1516
|
+
}
|
|
1517
|
+
((calls)["length"] = 0);
|
|
1518
|
+
return count;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
function branch_position(branches, position) {
|
|
1522
|
+
{
|
|
1523
|
+
const __eliscript_value_168 = 0;
|
|
1524
|
+
const __eliscript_value_169 = ((branches) ?? []).length;
|
|
1525
|
+
{
|
|
1526
|
+
let low = __eliscript_value_168;
|
|
1527
|
+
let high = __eliscript_value_169;
|
|
1528
|
+
while (__eliscript_numeric_relation("<", low, high)) {
|
|
1529
|
+
{
|
|
1530
|
+
const __eliscript_value_170 = (globalThis.Math)["floor"](__eliscript_numeric_div((low + high), 2));
|
|
1531
|
+
{
|
|
1532
|
+
let middle = __eliscript_value_170;
|
|
1533
|
+
if (__eliscript_numeric_relation("<", (((((branches) ?? [])[middle]) ?? null))["at"], position)) {
|
|
1534
|
+
((low = (middle + 1)));
|
|
1535
|
+
} else {
|
|
1536
|
+
((high = middle));
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
if ((low === 0)) {
|
|
1542
|
+
return position;
|
|
1543
|
+
} else {
|
|
1544
|
+
{
|
|
1545
|
+
const __eliscript_value_171 = ((((branches) ?? [])[__eliscript_numeric_decrement(low)]) ?? null);
|
|
1546
|
+
{
|
|
1547
|
+
let entry = __eliscript_value_171;
|
|
1548
|
+
return (position + (entry)["before"] + __eliscript_numeric_decrement((entry)["size"]));
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
function long_jump(state, distance, link) {
|
|
1556
|
+
word(state, 268435472);
|
|
1557
|
+
integer_register(state, 17, __eliscript_numeric_uint32(__eliscript_numeric_mul(distance, 4)), __eliscript_numeric_uint32((globalThis.Math)["floor"](__eliscript_numeric_div(__eliscript_numeric_mul(distance, 4), 4294967296))));
|
|
1558
|
+
word(state, 2333147664);
|
|
1559
|
+
return word(state, (__eliscript_truthy(link) ? 3594453504 : 3592356352));
|
|
1560
|
+
}
|
|
1561
|
+
function relaxed_branch(state, entry, at, target) {
|
|
1562
|
+
{
|
|
1563
|
+
const __eliscript_value_172 = (entry)["opcode"];
|
|
1564
|
+
const __eliscript_value_173 = (entry)["kind"];
|
|
1565
|
+
const __eliscript_value_174 = (entry)["size"];
|
|
1566
|
+
{
|
|
1567
|
+
let opcode = __eliscript_value_172;
|
|
1568
|
+
let kind = __eliscript_value_173;
|
|
1569
|
+
let size = __eliscript_value_174;
|
|
1570
|
+
if (__eliscript_truthy(branch_fits(__eliscript_numeric_sub(target, at), branch_limit(kind)))) {
|
|
1571
|
+
return word(state, branch_word(opcode, __eliscript_numeric_sub(target, at)));
|
|
1572
|
+
} else {
|
|
1573
|
+
if (((kind === 0) || ((kind === 1) && __eliscript_numeric_relation(">=", __eliscript_numeric_and(opcode, 15), 14)))) {
|
|
1574
|
+
if ((size === 1)) {
|
|
1575
|
+
return word(state, branch_word(335544320, __eliscript_numeric_sub(target, at)));
|
|
1576
|
+
} else {
|
|
1577
|
+
return long_jump(state, __eliscript_numeric_sub(target, at), ((__eliscript_value_175, __eliscript_value_176) => (__eliscript_value_175 !== __eliscript_value_176))(__eliscript_numeric_and(opcode, 2147483648), 0));
|
|
1578
|
+
}
|
|
1579
|
+
} else {
|
|
1580
|
+
word(state, branch_word(__eliscript_numeric_xor(opcode, ((kind === 1) ? 1 : 16777216)), size));
|
|
1581
|
+
if ((size === 2)) {
|
|
1582
|
+
return word(state, branch_word(335544320, __eliscript_numeric_decrement(__eliscript_numeric_sub(target, at))));
|
|
1583
|
+
} else {
|
|
1584
|
+
return long_jump(state, __eliscript_numeric_decrement(__eliscript_numeric_sub(target, at)), null);
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
function finish_branches(state, offsets) {
|
|
1592
|
+
{
|
|
1593
|
+
const __eliscript_value_177 = ((state)["branches"] ?? []);
|
|
1594
|
+
const __eliscript_value_178 = true;
|
|
1595
|
+
{
|
|
1596
|
+
let branches = __eliscript_value_177;
|
|
1597
|
+
let changed = __eliscript_value_178;
|
|
1598
|
+
(branches)["sort"](((left, right) => {
|
|
1599
|
+
return __eliscript_numeric_sub((left)["at"], (right)["at"]);
|
|
1600
|
+
}));
|
|
1601
|
+
while (__eliscript_truthy(changed)) {
|
|
1602
|
+
((changed = false));
|
|
1603
|
+
{
|
|
1604
|
+
const __eliscript_value_179 = 0;
|
|
1605
|
+
{
|
|
1606
|
+
let growth = __eliscript_value_179;
|
|
1607
|
+
(branches)["forEach"](((entry) => {
|
|
1608
|
+
((entry)["before"] = growth);
|
|
1609
|
+
return ((growth = (growth + __eliscript_numeric_decrement((entry)["size"]))));
|
|
1610
|
+
}));
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
(branches)["forEach"](((entry) => {
|
|
1614
|
+
{
|
|
1615
|
+
let at = branch_position(branches, (entry)["at"]);
|
|
1616
|
+
let target = branch_position(branches, (entry)["target"]);
|
|
1617
|
+
let kind = (entry)["kind"];
|
|
1618
|
+
let opcode = (entry)["opcode"];
|
|
1619
|
+
let always = ((kind === 1) && __eliscript_numeric_relation(">=", __eliscript_numeric_and(opcode, 15), 14));
|
|
1620
|
+
let size = (__eliscript_truthy(branch_fits(__eliscript_numeric_sub(target, at), branch_limit(kind))) ? 1 : (__eliscript_truthy(((__eliscript_value_180) => (__eliscript_truthy(__eliscript_value_180) ? __eliscript_value_180 : always))((kind === 0))) ? (__eliscript_truthy(branch_fits(__eliscript_numeric_sub(target, at), 33554432)) ? 1 : 7) : (__eliscript_truthy(branch_fits(__eliscript_numeric_decrement(__eliscript_numeric_sub(target, at)), 33554432)) ? 2 : 8)));
|
|
1621
|
+
if (__eliscript_numeric_relation(">", size, (entry)["size"])) {
|
|
1622
|
+
((entry)["size"] = size);
|
|
1623
|
+
return ((changed = true));
|
|
1624
|
+
} else {
|
|
1625
|
+
return null;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}));
|
|
1629
|
+
}
|
|
1630
|
+
{
|
|
1631
|
+
let words = (state)["words"];
|
|
1632
|
+
let original_size = ((words) ?? []).length;
|
|
1633
|
+
let count = ((branches) ?? []).length;
|
|
1634
|
+
let last = (__eliscript_numeric_relation(">", count, 0) ? ((((branches) ?? [])[__eliscript_numeric_decrement(count)]) ?? null) : null);
|
|
1635
|
+
let final_size = (original_size + (__eliscript_truthy(last) ? ((last)["before"] + __eliscript_numeric_decrement((last)["size"])) : 0));
|
|
1636
|
+
let scratch = [];
|
|
1637
|
+
let out = ({"words": scratch, "compact": null});
|
|
1638
|
+
let index = __eliscript_numeric_decrement(original_size);
|
|
1639
|
+
let next = __eliscript_numeric_decrement(count);
|
|
1640
|
+
let write = __eliscript_numeric_decrement(final_size);
|
|
1641
|
+
native_word_resize(words, final_size);
|
|
1642
|
+
while (__eliscript_numeric_relation(">=", index, 0)) {
|
|
1643
|
+
{
|
|
1644
|
+
const __eliscript_value_181 = (__eliscript_numeric_relation(">=", next, 0) ? ((((branches) ?? [])[next]) ?? null) : null);
|
|
1645
|
+
{
|
|
1646
|
+
let entry = __eliscript_value_181;
|
|
1647
|
+
if (__eliscript_truthy(((__eliscript_value_182) => (__eliscript_truthy(__eliscript_value_182) ? ((entry)["at"] === index) : __eliscript_value_182))(entry))) {
|
|
1648
|
+
{
|
|
1649
|
+
const __eliscript_value_183 = __eliscript_numeric_sub(write, __eliscript_numeric_decrement((entry)["size"]));
|
|
1650
|
+
const __eliscript_value_184 = branch_position(branches, (entry)["target"]);
|
|
1651
|
+
const __eliscript_value_185 = 0;
|
|
1652
|
+
{
|
|
1653
|
+
let at = __eliscript_value_183;
|
|
1654
|
+
let target = __eliscript_value_184;
|
|
1655
|
+
let j = __eliscript_value_185;
|
|
1656
|
+
((scratch)["length"] = 0);
|
|
1657
|
+
relaxed_branch(out, entry, at, target);
|
|
1658
|
+
((j = __eliscript_numeric_decrement(((scratch) ?? []).length)));
|
|
1659
|
+
while (__eliscript_numeric_relation(">=", j, 0)) {
|
|
1660
|
+
{
|
|
1661
|
+
const __eliscript_value_186 = ((((scratch) ?? [])[j]) ?? null);
|
|
1662
|
+
{
|
|
1663
|
+
let value = __eliscript_value_186;
|
|
1664
|
+
if ((!((write === index) && (native_word_at(words, index) === value)))) {
|
|
1665
|
+
native_word_set(words, write, value);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
((write = __eliscript_numeric_decrement(write)));
|
|
1670
|
+
((j = __eliscript_numeric_decrement(j)));
|
|
1671
|
+
}
|
|
1672
|
+
((next = __eliscript_numeric_decrement(next)));
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
} else {
|
|
1676
|
+
{
|
|
1677
|
+
const __eliscript_value_187 = native_word_at(words, index);
|
|
1678
|
+
{
|
|
1679
|
+
let value = __eliscript_value_187;
|
|
1680
|
+
if ((!(write === index))) {
|
|
1681
|
+
native_word_set(words, write, value);
|
|
1682
|
+
}
|
|
1683
|
+
((write = __eliscript_numeric_decrement(write)));
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
((index = __eliscript_numeric_decrement(index)));
|
|
1690
|
+
}
|
|
1691
|
+
((index = 0));
|
|
1692
|
+
while (__eliscript_numeric_relation("<", index, ((offsets) ?? []).length)) {
|
|
1693
|
+
((offsets)[index] = __eliscript_numeric_mul(branch_position(branches, __eliscript_numeric_div(((((offsets) ?? [])[index]) ?? null), 4)), 4));
|
|
1694
|
+
((index = (index + 1)));
|
|
1695
|
+
}
|
|
1696
|
+
(((state)["constants"] ?? []))["forEach"](((entry) => {
|
|
1697
|
+
{
|
|
1698
|
+
const __eliscript_value_188 = (entry)["uses"];
|
|
1699
|
+
const __eliscript_value_189 = 0;
|
|
1700
|
+
{
|
|
1701
|
+
let uses = __eliscript_value_188;
|
|
1702
|
+
let i = __eliscript_value_189;
|
|
1703
|
+
while (__eliscript_numeric_relation("<", i, ((uses) ?? []).length)) {
|
|
1704
|
+
((uses)[i] = branch_position(branches, ((((uses) ?? [])[i]) ?? null)));
|
|
1705
|
+
((i = (i + 1)));
|
|
1706
|
+
}
|
|
1707
|
+
return null;
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
}));
|
|
1711
|
+
{
|
|
1712
|
+
const __eliscript_value_190 = ((state)["tableUses"] ?? []);
|
|
1713
|
+
const __eliscript_value_191 = 0;
|
|
1714
|
+
{
|
|
1715
|
+
let uses = __eliscript_value_190;
|
|
1716
|
+
let i = __eliscript_value_191;
|
|
1717
|
+
while (__eliscript_numeric_relation("<", i, ((uses) ?? []).length)) {
|
|
1718
|
+
((uses)[i] = branch_position(branches, ((((uses) ?? [])[i]) ?? null)));
|
|
1719
|
+
((i = (i + 1)));
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
{
|
|
1724
|
+
const __eliscript_value_192 = ((state)["debugRanges"] ?? null);
|
|
1725
|
+
const __eliscript_value_193 = 0;
|
|
1726
|
+
{
|
|
1727
|
+
let ranges = __eliscript_value_192;
|
|
1728
|
+
let i = __eliscript_value_193;
|
|
1729
|
+
if (__eliscript_truthy(ranges)) {
|
|
1730
|
+
while (__eliscript_numeric_relation("<", i, ((ranges) ?? []).length)) {
|
|
1731
|
+
{
|
|
1732
|
+
const __eliscript_value_194 = ((((ranges) ?? [])[i]) ?? null);
|
|
1733
|
+
{
|
|
1734
|
+
let range = __eliscript_value_194;
|
|
1735
|
+
((range)["start"] = __eliscript_numeric_mul(branch_position(branches, __eliscript_numeric_div((range)["start"], 4)), 4));
|
|
1736
|
+
((range)["end"] = __eliscript_numeric_mul(branch_position(branches, __eliscript_numeric_div((range)["end"], 4)), 4));
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
((i = (i + 1)));
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
return ((state)["branches"] = []);
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
function condition(state, node) {
|
|
1750
|
+
expression(state, node);
|
|
1751
|
+
if ((((node)["type"] === "f64") || ((node)["type"] === "u32"))) {
|
|
1752
|
+
if (__eliscript_truthy(((state)["memory"] ?? null))) {
|
|
1753
|
+
return memory_integer_register(state, 0, 1);
|
|
1754
|
+
} else {
|
|
1755
|
+
return integer_register(state, 0, 1, 0);
|
|
1756
|
+
}
|
|
1757
|
+
} else {
|
|
1758
|
+
return null;
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
function comparison_code(operator, integer) {
|
|
1762
|
+
if ((operator === "=")) {
|
|
1763
|
+
return 0;
|
|
1764
|
+
} else {
|
|
1765
|
+
if ((operator === "/=")) {
|
|
1766
|
+
return 1;
|
|
1767
|
+
} else {
|
|
1768
|
+
if ((operator === "<")) {
|
|
1769
|
+
if (__eliscript_truthy(integer)) {
|
|
1770
|
+
return 11;
|
|
1771
|
+
} else {
|
|
1772
|
+
return 4;
|
|
1773
|
+
}
|
|
1774
|
+
} else {
|
|
1775
|
+
if ((operator === ">")) {
|
|
1776
|
+
return 12;
|
|
1777
|
+
} else {
|
|
1778
|
+
if ((operator === "<=")) {
|
|
1779
|
+
if (__eliscript_truthy(integer)) {
|
|
1780
|
+
return 13;
|
|
1781
|
+
} else {
|
|
1782
|
+
return 9;
|
|
1783
|
+
}
|
|
1784
|
+
} else {
|
|
1785
|
+
return 10;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function compare_result(state, operator, integer) {
|
|
1793
|
+
return word(state, (446629856 + __eliscript_numeric_mul(__eliscript_numeric_xor(comparison_code(operator, integer), 1), 4096)));
|
|
1794
|
+
}
|
|
1795
|
+
function patch_conditions(state, jumps, target) {
|
|
1796
|
+
{
|
|
1797
|
+
const __eliscript_value_195 = 0;
|
|
1798
|
+
{
|
|
1799
|
+
let i = __eliscript_value_195;
|
|
1800
|
+
while (__eliscript_numeric_relation("<", i, ((jumps) ?? []).length)) {
|
|
1801
|
+
patch_jump(state, ((((jumps) ?? [])[i]) ?? null), target);
|
|
1802
|
+
((i = (i + 1)));
|
|
1803
|
+
}
|
|
1804
|
+
return null;
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
function condition_jumps(state, node, when_true) {
|
|
1809
|
+
{
|
|
1810
|
+
const __eliscript_value_196 = (node)["kind"];
|
|
1811
|
+
const __eliscript_value_197 = (node)["children"];
|
|
1812
|
+
const __eliscript_value_198 = [];
|
|
1813
|
+
{
|
|
1814
|
+
let kind = __eliscript_value_196;
|
|
1815
|
+
let children = __eliscript_value_197;
|
|
1816
|
+
let jumps = __eliscript_value_198;
|
|
1817
|
+
if ((((kind === "and") || (kind === "or")) && ((node)["type"] === "i32"))) {
|
|
1818
|
+
{
|
|
1819
|
+
const __eliscript_value_199 = [];
|
|
1820
|
+
const __eliscript_value_200 = 0;
|
|
1821
|
+
const __eliscript_value_201 = ((kind === "and") ? (!__eliscript_truthy(when_true)) : when_true);
|
|
1822
|
+
{
|
|
1823
|
+
let skip = __eliscript_value_199;
|
|
1824
|
+
let i = __eliscript_value_200;
|
|
1825
|
+
let every = __eliscript_value_201;
|
|
1826
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
1827
|
+
{
|
|
1828
|
+
const __eliscript_value_202 = (i === __eliscript_numeric_decrement(((children) ?? []).length));
|
|
1829
|
+
{
|
|
1830
|
+
let last = __eliscript_value_202;
|
|
1831
|
+
{
|
|
1832
|
+
const __eliscript_value_203 = (__eliscript_truthy(((__eliscript_value_206) => (__eliscript_truthy(__eliscript_value_206) ? __eliscript_value_206 : last))(every)) ? jumps : skip);
|
|
1833
|
+
const __eliscript_value_204 = condition_jumps(state, ((((children) ?? [])[i]) ?? null), (__eliscript_truthy(((__eliscript_value_207) => (__eliscript_truthy(__eliscript_value_207) ? __eliscript_value_207 : last))(every)) ? when_true : (!__eliscript_truthy(when_true))));
|
|
1834
|
+
const __eliscript_value_205 = 0;
|
|
1835
|
+
{
|
|
1836
|
+
let output = __eliscript_value_203;
|
|
1837
|
+
let positions = __eliscript_value_204;
|
|
1838
|
+
let j = __eliscript_value_205;
|
|
1839
|
+
while (__eliscript_numeric_relation("<", j, ((positions) ?? []).length)) {
|
|
1840
|
+
(output)["push"](((((positions) ?? [])[j]) ?? null));
|
|
1841
|
+
((j = (j + 1)));
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
((i = (i + 1)));
|
|
1848
|
+
}
|
|
1849
|
+
if ((((children) ?? []).length === 0)) {
|
|
1850
|
+
if ((when_true === (kind === "and"))) {
|
|
1851
|
+
(jumps)["push"](jump(state, "jump"));
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
patch_conditions(state, skip, (((state)["words"]) ?? []).length);
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
} else {
|
|
1858
|
+
if ((kind === "not")) {
|
|
1859
|
+
((jumps = condition_jumps(state, ((((children) ?? [])[0]) ?? null), (!__eliscript_truthy(when_true)))));
|
|
1860
|
+
} else {
|
|
1861
|
+
if (__eliscript_truthy(((__eliscript_value_208) => (__eliscript_truthy(__eliscript_value_208) ? ((kind === "int-compare") && (__eliscript_numeric_relation(">=", integer_immediate(((((children) ?? [])[0]) ?? null)), 0) || __eliscript_numeric_relation(">=", integer_immediate(((((children) ?? [])[1]) ?? null)), 0))) : __eliscript_value_208))(((state)["compact"] ?? null)))) {
|
|
1862
|
+
{
|
|
1863
|
+
let reverse = __eliscript_numeric_relation("<", integer_immediate(((((children) ?? [])[1]) ?? null)), 0);
|
|
1864
|
+
let operand = ((((children) ?? [])[(__eliscript_truthy(reverse) ? 1 : 0)]) ?? null);
|
|
1865
|
+
let immediate = integer_immediate(((((children) ?? [])[(__eliscript_truthy(reverse) ? 0 : 1)]) ?? null));
|
|
1866
|
+
let r = local_register(state, operand, "i32");
|
|
1867
|
+
let op = (node)["value"];
|
|
1868
|
+
if (__eliscript_numeric_relation("<", r, 0)) {
|
|
1869
|
+
expression(state, operand);
|
|
1870
|
+
((r = 0));
|
|
1871
|
+
}
|
|
1872
|
+
word(state, (1895825439 + __eliscript_numeric_mul(immediate, 1024) + __eliscript_numeric_mul(r, 32)));
|
|
1873
|
+
if (__eliscript_truthy(reverse)) {
|
|
1874
|
+
((op = ((op === "<") ? ">" : ((op === ">") ? "<" : ((op === "<=") ? ">=" : ((op === ">=") ? "<=" : op))))));
|
|
1875
|
+
}
|
|
1876
|
+
{
|
|
1877
|
+
const __eliscript_value_209 = comparison_code(op, true);
|
|
1878
|
+
{
|
|
1879
|
+
let code = __eliscript_value_209;
|
|
1880
|
+
(jumps)["push"]((((state)["words"]) ?? []).length);
|
|
1881
|
+
word(state, (1409286144 + (__eliscript_truthy(when_true) ? code : __eliscript_numeric_xor(code, 1))));
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
} else {
|
|
1886
|
+
if (((kind === "compare") || (kind === "int-compare"))) {
|
|
1887
|
+
{
|
|
1888
|
+
let integer = (kind === "int-compare");
|
|
1889
|
+
let registers = operands(state, ((((children) ?? [])[0]) ?? null), ((((children) ?? [])[1]) ?? null), (__eliscript_truthy(integer) ? "i32" : "f64"));
|
|
1890
|
+
let code = comparison_code((node)["value"], integer);
|
|
1891
|
+
binary_word(state, (__eliscript_truthy(integer) ? 1795162175 : 509616160), registers);
|
|
1892
|
+
(jumps)["push"]((((state)["words"]) ?? []).length);
|
|
1893
|
+
word(state, (1409286144 + (__eliscript_truthy(when_true) ? code : __eliscript_numeric_xor(code, 1))));
|
|
1894
|
+
}
|
|
1895
|
+
} else {
|
|
1896
|
+
condition(state, node);
|
|
1897
|
+
(jumps)["push"](jump(state, (__eliscript_truthy(when_true) ? "nonzero" : "zero")));
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
return jumps;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
function emit_call(state, node) {
|
|
1907
|
+
{
|
|
1908
|
+
let args = (node)["children"];
|
|
1909
|
+
let count = ((args) ?? []).length;
|
|
1910
|
+
let extra = __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div((__eliscript_numeric_relation(">", count, 8) ? __eliscript_numeric_sub(count, 8) : 0), 2)), 16);
|
|
1911
|
+
let i = 0;
|
|
1912
|
+
let depth = ((state)["depth"] ?? 0);
|
|
1913
|
+
let leaf = ((state)["leaf"] ?? null);
|
|
1914
|
+
let saved = [];
|
|
1915
|
+
((state)["leaf"] = null);
|
|
1916
|
+
while (__eliscript_numeric_relation("<", i, count)) {
|
|
1917
|
+
expression(state, ((((args) ?? [])[i]) ?? null));
|
|
1918
|
+
push_value(state, "f64");
|
|
1919
|
+
((i = (i + 1)));
|
|
1920
|
+
}
|
|
1921
|
+
if (__eliscript_truthy(((state)["compact"] ?? null))) {
|
|
1922
|
+
{
|
|
1923
|
+
const __eliscript_value_210 = (state)["registers"];
|
|
1924
|
+
const __eliscript_value_211 = ((node)["callLive"] ?? []);
|
|
1925
|
+
const __eliscript_value_212 = 0;
|
|
1926
|
+
{
|
|
1927
|
+
let registers = __eliscript_value_210;
|
|
1928
|
+
let live = __eliscript_value_211;
|
|
1929
|
+
let j = __eliscript_value_212;
|
|
1930
|
+
while (__eliscript_numeric_relation("<", j, ((live) ?? []).length)) {
|
|
1931
|
+
{
|
|
1932
|
+
const __eliscript_value_213 = ((((registers) ?? [])[((((live) ?? [])[j]) ?? null)]) ?? null);
|
|
1933
|
+
{
|
|
1934
|
+
let r = __eliscript_value_213;
|
|
1935
|
+
if (((__eliscript_numeric_relation(">=", r, 2) && (__eliscript_numeric_relation("<", r, 8) || __eliscript_numeric_relation(">=", r, 24))) || (__eliscript_numeric_relation("<=", r, -12) && __eliscript_numeric_relation(">=", r, -17)))) {
|
|
1936
|
+
if ((!__eliscript_truthy((saved)["includes"](r)))) {
|
|
1937
|
+
(saved)["push"](r);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
((j = (j + 1)));
|
|
1943
|
+
}
|
|
1944
|
+
((j = 0));
|
|
1945
|
+
{
|
|
1946
|
+
const __eliscript_value_214 = ((state)["literalRegisters"] ?? []);
|
|
1947
|
+
{
|
|
1948
|
+
let constants = __eliscript_value_214;
|
|
1949
|
+
while (__eliscript_numeric_relation("<", j, ((constants) ?? []).length)) {
|
|
1950
|
+
{
|
|
1951
|
+
const __eliscript_value_215 = (((((constants) ?? [])[j]) ?? null))["register"];
|
|
1952
|
+
{
|
|
1953
|
+
let r = __eliscript_value_215;
|
|
1954
|
+
if (((__eliscript_numeric_relation("<", r, 8) || __eliscript_numeric_relation(">=", r, 24)) && (!__eliscript_truthy((saved)["includes"](r))))) {
|
|
1955
|
+
(saved)["push"](r);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
((j = (j + 1)));
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
((j = 0));
|
|
1964
|
+
while (__eliscript_numeric_relation("<", j, (__eliscript_numeric_relation("<", depth, 8) ? depth : 8))) {
|
|
1965
|
+
(saved)["push"]((16 + j));
|
|
1966
|
+
((j = (j + 1)));
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
((i = 0));
|
|
1971
|
+
while (__eliscript_numeric_relation("<", i, ((saved) ?? []).length)) {
|
|
1972
|
+
{
|
|
1973
|
+
const __eliscript_value_216 = ((((saved) ?? [])[i]) ?? null);
|
|
1974
|
+
{
|
|
1975
|
+
let r = __eliscript_value_216;
|
|
1976
|
+
stack_adjust(state, 16, true);
|
|
1977
|
+
word(state, ((__eliscript_numeric_relation(">=", r, 0) ? 4244636640 : 4177527776) + (__eliscript_numeric_relation(">=", r, 0) ? r : __eliscript_numeric_sub(__eliscript_numeric_neg(r), 2))));
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
((i = (i + 1)));
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
stack_adjust(state, extra, true);
|
|
1984
|
+
((i = 0));
|
|
1985
|
+
while (__eliscript_numeric_relation("<", i, count)) {
|
|
1986
|
+
stack_float(state, (extra + __eliscript_numeric_mul(((saved) ?? []).length, 16) + __eliscript_numeric_mul(__eliscript_numeric_decrement(__eliscript_numeric_sub(count, i)), 16)), (__eliscript_numeric_relation("<", i, 8) ? i : 16), null);
|
|
1987
|
+
if (__eliscript_numeric_relation(">=", i, 8)) {
|
|
1988
|
+
stack_float(state, __eliscript_numeric_mul(__eliscript_numeric_sub(i, 8), 8), 16, true);
|
|
1989
|
+
}
|
|
1990
|
+
((i = (i + 1)));
|
|
1991
|
+
}
|
|
1992
|
+
{
|
|
1993
|
+
const __eliscript_value_217 = (((state)["words"]) ?? []).length;
|
|
1994
|
+
{
|
|
1995
|
+
let at = __eliscript_value_217;
|
|
1996
|
+
word(state, 2483027968);
|
|
1997
|
+
((state)["calls"])["push"](({"at": at, "target": (node)["value"]}));
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
stack_adjust(state, extra, null);
|
|
2001
|
+
((i = __eliscript_numeric_decrement(((saved) ?? []).length)));
|
|
2002
|
+
while (__eliscript_numeric_relation(">=", i, 0)) {
|
|
2003
|
+
{
|
|
2004
|
+
const __eliscript_value_218 = ((((saved) ?? [])[i]) ?? null);
|
|
2005
|
+
{
|
|
2006
|
+
let r = __eliscript_value_218;
|
|
2007
|
+
word(state, ((__eliscript_numeric_relation(">=", r, 0) ? 4248830944 : 4181722080) + (__eliscript_numeric_relation(">=", r, 0) ? r : __eliscript_numeric_sub(__eliscript_numeric_neg(r), 2))));
|
|
2008
|
+
stack_adjust(state, 16, null);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
((i = __eliscript_numeric_decrement(i)));
|
|
2012
|
+
}
|
|
2013
|
+
stack_adjust(state, __eliscript_numeric_mul(count, 16), null);
|
|
2014
|
+
((state)["leaf"] = leaf);
|
|
2015
|
+
return ((state)["depth"] = depth);
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
function emit_loop(state, children, used) {
|
|
2019
|
+
if (__eliscript_truthy(((state)["compact"] ?? null))) {
|
|
2020
|
+
{
|
|
2021
|
+
let initial = jump(state, "jump");
|
|
2022
|
+
let start = (((state)["words"]) ?? []).length;
|
|
2023
|
+
discarded(state, ((((children) ?? [])[1]) ?? null));
|
|
2024
|
+
patch_jump(state, initial, (((state)["words"]) ?? []).length);
|
|
2025
|
+
patch_conditions(state, condition_jumps(state, ((((children) ?? [])[0]) ?? null), true), start);
|
|
2026
|
+
if (__eliscript_truthy(used)) {
|
|
2027
|
+
return integer_register(state, 0, 0, 0);
|
|
2028
|
+
} else {
|
|
2029
|
+
return null;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
} else {
|
|
2033
|
+
{
|
|
2034
|
+
const __eliscript_value_219 = (((state)["words"]) ?? []).length;
|
|
2035
|
+
{
|
|
2036
|
+
let start = __eliscript_value_219;
|
|
2037
|
+
condition(state, ((((children) ?? [])[0]) ?? null));
|
|
2038
|
+
{
|
|
2039
|
+
const __eliscript_value_220 = jump(state, "zero");
|
|
2040
|
+
{
|
|
2041
|
+
let end = __eliscript_value_220;
|
|
2042
|
+
if (__eliscript_truthy(((state)["memory"] ?? null))) {
|
|
2043
|
+
memory_discarded(state, ((((children) ?? [])[1]) ?? null));
|
|
2044
|
+
} else {
|
|
2045
|
+
expression(state, ((((children) ?? [])[1]) ?? null));
|
|
2046
|
+
}
|
|
2047
|
+
{
|
|
2048
|
+
const __eliscript_value_221 = jump(state, "jump");
|
|
2049
|
+
{
|
|
2050
|
+
let back = __eliscript_value_221;
|
|
2051
|
+
patch_jump(state, back, start);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
patch_jump(state, end, (((state)["words"]) ?? []).length);
|
|
2055
|
+
if (__eliscript_truthy(((state)["memory"] ?? null))) {
|
|
2056
|
+
if (__eliscript_truthy(used)) {
|
|
2057
|
+
return memory_integer_register(state, 0, 0);
|
|
2058
|
+
} else {
|
|
2059
|
+
return null;
|
|
2060
|
+
}
|
|
2061
|
+
} else {
|
|
2062
|
+
return integer_register(state, 0, 0, 0);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
function integer_immediate(node) {
|
|
2071
|
+
if (((((node)["kind"] === "int-literal") || (((node)["kind"] === "literal") && ((node)["type"] === "i32"))) && __eliscript_numeric_relation(">=", (node)["value"], 0) && __eliscript_numeric_relation("<", (node)["value"], 4096))) {
|
|
2072
|
+
return (node)["value"];
|
|
2073
|
+
} else {
|
|
2074
|
+
return -1;
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
function integer_mask_width(node) {
|
|
2078
|
+
{
|
|
2079
|
+
const __eliscript_value_222 = ((((node)["kind"] === "int-literal") || (((node)["kind"] === "literal") && ((node)["type"] === "i32"))) ? (node)["value"] : 0);
|
|
2080
|
+
const __eliscript_value_223 = 0;
|
|
2081
|
+
const __eliscript_value_224 = 0;
|
|
2082
|
+
{
|
|
2083
|
+
let value = __eliscript_value_222;
|
|
2084
|
+
let bits = __eliscript_value_223;
|
|
2085
|
+
let mask = __eliscript_value_224;
|
|
2086
|
+
while ((__eliscript_numeric_relation("<", bits, 31) && __eliscript_numeric_relation("<", mask, value))) {
|
|
2087
|
+
((mask = (__eliscript_numeric_mul(mask, 2) + 1)));
|
|
2088
|
+
((bits = (bits + 1)));
|
|
2089
|
+
}
|
|
2090
|
+
if ((__eliscript_numeric_relation(">", bits, 0) && (mask === value))) {
|
|
2091
|
+
return bits;
|
|
2092
|
+
} else {
|
|
2093
|
+
return 0;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
function integer_operation(state, node, destination) {
|
|
2099
|
+
{
|
|
2100
|
+
let kind = (node)["kind"];
|
|
2101
|
+
let children = (node)["children"];
|
|
2102
|
+
let left = ((((children) ?? [])[0]) ?? null);
|
|
2103
|
+
let right = ((((children) ?? [])[1]) ?? null);
|
|
2104
|
+
let immediate = integer_immediate(right);
|
|
2105
|
+
let mask = ((kind === "int-and") ? integer_mask_width(right) : 0);
|
|
2106
|
+
if (__eliscript_truthy(((__eliscript_value_225) => (__eliscript_truthy(__eliscript_value_225) ? (__eliscript_numeric_relation(">", mask, 0) || (((kind === "int-add") || (kind === "int-sub")) && __eliscript_numeric_relation(">=", immediate, 0))) : __eliscript_value_225))(((state)["compact"] ?? null)))) {
|
|
2107
|
+
{
|
|
2108
|
+
const __eliscript_value_226 = local_register(state, left, "i32");
|
|
2109
|
+
{
|
|
2110
|
+
let register = __eliscript_value_226;
|
|
2111
|
+
if (__eliscript_numeric_relation("<", register, 0)) {
|
|
2112
|
+
if ((((left)["kind"] === "int-add") || ((left)["kind"] === "int-sub") || ((left)["kind"] === "int-and"))) {
|
|
2113
|
+
integer_operation(state, left, destination);
|
|
2114
|
+
((register = destination));
|
|
2115
|
+
} else {
|
|
2116
|
+
expression(state, left);
|
|
2117
|
+
((register = 0));
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
return word(state, ((__eliscript_numeric_relation(">", mask, 0) ? 301989888 : ((kind === "int-add") ? 285212672 : 1358954496)) + __eliscript_numeric_mul((__eliscript_numeric_relation(">", mask, 0) ? __eliscript_numeric_decrement(mask) : immediate), 1024) + __eliscript_numeric_mul(register, 32) + destination));
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
} else {
|
|
2124
|
+
{
|
|
2125
|
+
const __eliscript_value_227 = operands(state, left, right, "i32");
|
|
2126
|
+
{
|
|
2127
|
+
let registers = __eliscript_value_227;
|
|
2128
|
+
binary_word(state, ((kind === "int-add") ? 184549408 : ((kind === "int-sub") ? 1258291232 : ((kind === "int-and") ? 167772192 : 1795162175))), registers);
|
|
2129
|
+
if ((!((kind === "int-compare") || (destination === 0)))) {
|
|
2130
|
+
return retarget_last(state, destination);
|
|
2131
|
+
} else {
|
|
2132
|
+
return null;
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
function expression(state, node, unused = null) {
|
|
2140
|
+
{
|
|
2141
|
+
const __eliscript_value_228 = ((state)["debugRanges"] ?? null);
|
|
2142
|
+
{
|
|
2143
|
+
let ranges = __eliscript_value_228;
|
|
2144
|
+
if (__eliscript_truthy(ranges)) {
|
|
2145
|
+
{
|
|
2146
|
+
let depth = ((state)["debugDepth"] ?? 0);
|
|
2147
|
+
let range = ({"kind": (node)["kind"], "function": (state)["debugFunction"], "functionIndex": (state)["debugFunctionIndex"], "depth": depth, "start": __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length), "end": 0, "span": ((node)["span"] ?? null)});
|
|
2148
|
+
(ranges)["push"](range);
|
|
2149
|
+
((state)["debugDepth"] = (depth + 1));
|
|
2150
|
+
{
|
|
2151
|
+
const __eliscript_value_229 = (__eliscript_truthy(((__eliscript_value_230) => (__eliscript_truthy(__eliscript_value_230) ? ((state)["memory"] ?? null) : __eliscript_value_230))(unused)) ? memory_discarded_body(state, node) : expression_body(state, node));
|
|
2152
|
+
{
|
|
2153
|
+
let result = __eliscript_value_229;
|
|
2154
|
+
((state)["debugDepth"] = depth);
|
|
2155
|
+
((range)["end"] = __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length));
|
|
2156
|
+
return result;
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
2159
|
+
}
|
|
2160
|
+
} else {
|
|
2161
|
+
if (__eliscript_truthy(((__eliscript_value_231) => (__eliscript_truthy(__eliscript_value_231) ? ((state)["memory"] ?? null) : __eliscript_value_231))(unused))) {
|
|
2162
|
+
return memory_discarded_body(state, node);
|
|
2163
|
+
} else {
|
|
2164
|
+
return expression_body(state, node);
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
function memory_discarded(state, node) {
|
|
2171
|
+
return expression(state, node, true);
|
|
2172
|
+
}
|
|
2173
|
+
function memory_discarded_body(state, node) {
|
|
2174
|
+
{
|
|
2175
|
+
const __eliscript_value_232 = (node)["kind"];
|
|
2176
|
+
const __eliscript_value_233 = (node)["children"];
|
|
2177
|
+
const __eliscript_value_234 = 0;
|
|
2178
|
+
{
|
|
2179
|
+
let kind = __eliscript_value_232;
|
|
2180
|
+
let children = __eliscript_value_233;
|
|
2181
|
+
let i = __eliscript_value_234;
|
|
2182
|
+
if (((kind === "literal") || (kind === "int-literal") || (kind === "local"))) {
|
|
2183
|
+
return null;
|
|
2184
|
+
} else {
|
|
2185
|
+
if (__eliscript_truthy(((__eliscript_value_235) => (__eliscript_truthy(__eliscript_value_235) ? __eliscript_value_235 : ((__eliscript_value_236) => (__eliscript_truthy(__eliscript_value_236) ? __eliscript_value_236 : ((__eliscript_value_237) => (__eliscript_truthy(__eliscript_value_237) ? ((__eliscript_value_238) => (__eliscript_truthy(__eliscript_value_238) ? (["+", "-", "*", "1+", "1-"])["includes"]((node)["value"]) : __eliscript_value_238))(__eliscript_numeric_relation("<=", ((children) ?? []).length, 2)) : __eliscript_value_237))((kind === "word-arithmetic"))))(((kind === "word-compare") && (((children) ?? []).length === 2)))))((kind === "sequence")))) {
|
|
2186
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
2187
|
+
memory_discarded(state, ((((children) ?? [])[i]) ?? null));
|
|
2188
|
+
((i = (i + 1)));
|
|
2189
|
+
}
|
|
2190
|
+
return null;
|
|
2191
|
+
} else {
|
|
2192
|
+
if ((kind === "if")) {
|
|
2193
|
+
condition(state, ((((children) ?? [])[0]) ?? null));
|
|
2194
|
+
{
|
|
2195
|
+
const __eliscript_value_239 = jump(state, "zero");
|
|
2196
|
+
{
|
|
2197
|
+
let otherwise = __eliscript_value_239;
|
|
2198
|
+
memory_discarded(state, ((((children) ?? [])[1]) ?? null));
|
|
2199
|
+
{
|
|
2200
|
+
const __eliscript_value_240 = jump(state, "jump");
|
|
2201
|
+
{
|
|
2202
|
+
let end = __eliscript_value_240;
|
|
2203
|
+
patch_jump(state, otherwise, (((state)["words"]) ?? []).length);
|
|
2204
|
+
memory_discarded(state, ((((children) ?? [])[2]) ?? null));
|
|
2205
|
+
return patch_jump(state, end, (((state)["words"]) ?? []).length);
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
} else {
|
|
2211
|
+
if (((kind === "while") || (kind === "remainder-while") || (kind === "guarded-while"))) {
|
|
2212
|
+
return emit_loop(state, children, null);
|
|
2213
|
+
} else {
|
|
2214
|
+
return expression_body(state, node);
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
function expression_body(state, node) {
|
|
2223
|
+
{
|
|
2224
|
+
const __eliscript_value_241 = (node)["kind"];
|
|
2225
|
+
const __eliscript_value_242 = (node)["value"];
|
|
2226
|
+
const __eliscript_value_243 = (node)["children"];
|
|
2227
|
+
{
|
|
2228
|
+
let kind = __eliscript_value_241;
|
|
2229
|
+
let value = __eliscript_value_242;
|
|
2230
|
+
let children = __eliscript_value_243;
|
|
2231
|
+
if (__eliscript_truthy(((__eliscript_value_244) => (__eliscript_truthy(__eliscript_value_244) ? (kind === "memory-op") : __eliscript_value_244))(((state)["memory"] ?? null)))) {
|
|
2232
|
+
return memory_operation(state, node);
|
|
2233
|
+
} else {
|
|
2234
|
+
if (__eliscript_truthy(((__eliscript_value_245) => (__eliscript_truthy(__eliscript_value_245) ? (kind === "memory-data-copy") : __eliscript_value_245))(((state)["memory"] ?? null)))) {
|
|
2235
|
+
return memory_data_copy(state, node);
|
|
2236
|
+
} else {
|
|
2237
|
+
if (__eliscript_truthy(((__eliscript_value_246) => (__eliscript_truthy(__eliscript_value_246) ? ((kind === "call") || (kind === "call-indirect")) : __eliscript_value_246))(((state)["memory"] ?? null)))) {
|
|
2238
|
+
return memory_call(state, node);
|
|
2239
|
+
} else {
|
|
2240
|
+
if (__eliscript_truthy(((__eliscript_value_247) => (__eliscript_truthy(__eliscript_value_247) ? (kind === "host-call") : __eliscript_value_247))(((state)["memory"] ?? null)))) {
|
|
2241
|
+
return memory_host_call(state, node);
|
|
2242
|
+
} else {
|
|
2243
|
+
if (((kind === "word-arithmetic") || (kind === "word-compare"))) {
|
|
2244
|
+
return memory_word(state, node);
|
|
2245
|
+
} else {
|
|
2246
|
+
if ((kind === "literal")) {
|
|
2247
|
+
if (((node)["type"] === "f64")) {
|
|
2248
|
+
return float_literal(state, value);
|
|
2249
|
+
} else {
|
|
2250
|
+
if (__eliscript_truthy(((__eliscript_value_248) => (__eliscript_truthy(__eliscript_value_248) ? memory_word_type((node)["type"]) : __eliscript_value_248))(((state)["memory"] ?? null)))) {
|
|
2251
|
+
return memory_integer_register(state, 0, value);
|
|
2252
|
+
} else {
|
|
2253
|
+
return integer_register(state, 0, value, 0);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
} else {
|
|
2257
|
+
if ((kind === "int-literal")) {
|
|
2258
|
+
if (__eliscript_truthy(((__eliscript_value_249) => (__eliscript_truthy(__eliscript_value_249) ? memory_word_type((node)["type"]) : __eliscript_value_249))(((state)["memory"] ?? null)))) {
|
|
2259
|
+
return memory_integer_register(state, 0, value);
|
|
2260
|
+
} else {
|
|
2261
|
+
return integer_register(state, 0, value, 0);
|
|
2262
|
+
}
|
|
2263
|
+
} else {
|
|
2264
|
+
if ((kind === "local")) {
|
|
2265
|
+
return local_access(state, value, (node)["type"], null);
|
|
2266
|
+
} else {
|
|
2267
|
+
if (((kind === "set") || (kind === "initialize"))) {
|
|
2268
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
2269
|
+
return local_access(state, value, (node)["type"], true);
|
|
2270
|
+
} else {
|
|
2271
|
+
if ((kind === "sequence")) {
|
|
2272
|
+
if ((((children) ?? []).length === 0)) {
|
|
2273
|
+
if (__eliscript_truthy(((state)["memory"] ?? null))) {
|
|
2274
|
+
return memory_integer_register(state, 0, 0);
|
|
2275
|
+
} else {
|
|
2276
|
+
return integer_register(state, 0, 0, 0);
|
|
2277
|
+
}
|
|
2278
|
+
} else {
|
|
2279
|
+
{
|
|
2280
|
+
const __eliscript_value_250 = 0;
|
|
2281
|
+
{
|
|
2282
|
+
let i = __eliscript_value_250;
|
|
2283
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
2284
|
+
if (__eliscript_numeric_relation("<", i, __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
2285
|
+
if (__eliscript_truthy(((state)["memory"] ?? null))) {
|
|
2286
|
+
memory_discarded(state, ((((children) ?? [])[i]) ?? null));
|
|
2287
|
+
} else {
|
|
2288
|
+
if (__eliscript_truthy(((state)["compact"] ?? null))) {
|
|
2289
|
+
discarded(state, ((((children) ?? [])[i]) ?? null));
|
|
2290
|
+
} else {
|
|
2291
|
+
expression(state, ((((children) ?? [])[i]) ?? null));
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
} else {
|
|
2295
|
+
expression(state, ((((children) ?? [])[i]) ?? null));
|
|
2296
|
+
}
|
|
2297
|
+
((i = (i + 1)));
|
|
2298
|
+
}
|
|
2299
|
+
return null;
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
} else {
|
|
2304
|
+
if ((kind === "int-number")) {
|
|
2305
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
2306
|
+
return word(state, 509739008);
|
|
2307
|
+
} else {
|
|
2308
|
+
if ((kind === "ceil-int")) {
|
|
2309
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
2310
|
+
word(state, 509919232);
|
|
2311
|
+
return word(state, 511180800);
|
|
2312
|
+
} else {
|
|
2313
|
+
if (((kind === "int-add") || (kind === "int-sub") || (kind === "int-and") || (kind === "int-compare"))) {
|
|
2314
|
+
integer_operation(state, node, 0);
|
|
2315
|
+
if ((kind === "int-compare")) {
|
|
2316
|
+
return compare_result(state, value, true);
|
|
2317
|
+
} else {
|
|
2318
|
+
return null;
|
|
2319
|
+
}
|
|
2320
|
+
} else {
|
|
2321
|
+
if ((kind === "arithmetic")) {
|
|
2322
|
+
if (__eliscript_truthy(direct_value(state, node))) {
|
|
2323
|
+
{
|
|
2324
|
+
let depth = ((state)["depth"] ?? 0);
|
|
2325
|
+
let r = pure_value(state, node);
|
|
2326
|
+
word(state, (509624320 + __eliscript_numeric_mul(r, 32)));
|
|
2327
|
+
return ((state)["depth"] = depth);
|
|
2328
|
+
}
|
|
2329
|
+
} else {
|
|
2330
|
+
if ((((children) ?? []).length === 0)) {
|
|
2331
|
+
return expression(state, ({"kind": "literal", "type": "f64", "value": ((value === "*") ? 1 : 0)}));
|
|
2332
|
+
} else {
|
|
2333
|
+
if (((((children) ?? []).length === 1) && (value === "-"))) {
|
|
2334
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
2335
|
+
return word(state, 509689856);
|
|
2336
|
+
} else {
|
|
2337
|
+
if (((((children) ?? []).length === 1) && (value === "/"))) {
|
|
2338
|
+
expression(state, ({"kind": "literal", "type": "f64", "value": 1}));
|
|
2339
|
+
push_value(state, "f64");
|
|
2340
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
2341
|
+
pop_value(state, "f64");
|
|
2342
|
+
return word(state, 509614112);
|
|
2343
|
+
} else {
|
|
2344
|
+
if (((((children) ?? []).length === 2) || (value === "1+") || (value === "1-"))) {
|
|
2345
|
+
{
|
|
2346
|
+
const __eliscript_value_251 = operands(state, ((((children) ?? [])[0]) ?? null), ((((children) ?? []).length === 2) ? ((((children) ?? [])[1]) ?? null) : ({"kind": "literal", "type": "f64", "value": 1})), "f64");
|
|
2347
|
+
{
|
|
2348
|
+
let registers = __eliscript_value_251;
|
|
2349
|
+
return binary_word(state, (((value === "+") || (value === "1+")) ? 509618208 : (((value === "-") || (value === "1-")) ? 509622304 : ((value === "*") ? 509610016 : 509614112))), registers);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
} else {
|
|
2353
|
+
return expression(state, ((((children) ?? [])[0]) ?? null));
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
} else {
|
|
2360
|
+
if ((kind === "compare")) {
|
|
2361
|
+
binary_word(state, 509616160, operands(state, ((((children) ?? [])[0]) ?? null), ((((children) ?? [])[1]) ?? null), "f64"));
|
|
2362
|
+
return compare_result(state, value, null);
|
|
2363
|
+
} else {
|
|
2364
|
+
if ((kind === "not")) {
|
|
2365
|
+
condition(state, ((((children) ?? [])[0]) ?? null));
|
|
2366
|
+
return word(state, 1375731712);
|
|
2367
|
+
} else {
|
|
2368
|
+
if ((kind === "if")) {
|
|
2369
|
+
{
|
|
2370
|
+
const __eliscript_value_252 = (__eliscript_truthy(((state)["compact"] ?? null)) ? condition_jumps(state, ((((children) ?? [])[0]) ?? null), null) : (() => {
|
|
2371
|
+
condition(state, ((((children) ?? [])[0]) ?? null));
|
|
2372
|
+
return [jump(state, "zero")];
|
|
2373
|
+
})());
|
|
2374
|
+
{
|
|
2375
|
+
let otherwise = __eliscript_value_252;
|
|
2376
|
+
expression(state, ((((children) ?? [])[1]) ?? null));
|
|
2377
|
+
{
|
|
2378
|
+
const __eliscript_value_253 = jump(state, "jump");
|
|
2379
|
+
{
|
|
2380
|
+
let end = __eliscript_value_253;
|
|
2381
|
+
patch_conditions(state, otherwise, (((state)["words"]) ?? []).length);
|
|
2382
|
+
expression(state, ((((children) ?? [])[2]) ?? null));
|
|
2383
|
+
return patch_jump(state, end, (((state)["words"]) ?? []).length);
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
} else {
|
|
2389
|
+
if (((kind === "while") || (kind === "remainder-while") || (kind === "guarded-while"))) {
|
|
2390
|
+
return emit_loop(state, children, true);
|
|
2391
|
+
} else {
|
|
2392
|
+
if (((kind === "and") || (kind === "or"))) {
|
|
2393
|
+
{
|
|
2394
|
+
const __eliscript_value_254 = 0;
|
|
2395
|
+
const __eliscript_value_255 = [];
|
|
2396
|
+
{
|
|
2397
|
+
let i = __eliscript_value_254;
|
|
2398
|
+
let jumps = __eliscript_value_255;
|
|
2399
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
2400
|
+
expression(state, ((((children) ?? [])[i]) ?? null));
|
|
2401
|
+
if (__eliscript_numeric_relation("<", i, __eliscript_numeric_decrement(((children) ?? []).length))) {
|
|
2402
|
+
if ((((node)["type"] === "f64") || ((node)["type"] === "u32"))) {
|
|
2403
|
+
if ((kind === "or")) {
|
|
2404
|
+
((i = ((children) ?? []).length));
|
|
2405
|
+
}
|
|
2406
|
+
} else {
|
|
2407
|
+
(jumps)["push"](jump(state, ((kind === "and") ? "zero" : "nonzero")));
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
((i = (i + 1)));
|
|
2411
|
+
}
|
|
2412
|
+
((i = 0));
|
|
2413
|
+
while (__eliscript_numeric_relation("<", i, ((jumps) ?? []).length)) {
|
|
2414
|
+
patch_jump(state, ((((jumps) ?? [])[i]) ?? null), (((state)["words"]) ?? []).length);
|
|
2415
|
+
((i = (i + 1)));
|
|
2416
|
+
}
|
|
2417
|
+
return null;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
} else {
|
|
2421
|
+
if ((kind === "call")) {
|
|
2422
|
+
return emit_call(state, node);
|
|
2423
|
+
} else {
|
|
2424
|
+
return backend_fail(node, (String("unknown typed native expression: ") + String(kind)));
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
function typed_code(program, options = null) {
|
|
2449
|
+
{
|
|
2450
|
+
let compact = ((((__eliscript_value_256) => (__eliscript_truthy(__eliscript_value_256) ? __eliscript_value_256 : ({})))(options))["registerAllocation"] ?? true);
|
|
2451
|
+
let state = ({"words": [], "calls": [], "constants": [], "compact": compact});
|
|
2452
|
+
let functions = (program)["functions"];
|
|
2453
|
+
let offsets = [];
|
|
2454
|
+
let i = 0;
|
|
2455
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
2456
|
+
{
|
|
2457
|
+
let function$ = ((((functions) ?? [])[i]) ?? null);
|
|
2458
|
+
let locals = (function$)["locals"];
|
|
2459
|
+
let arity = (function$)["arity"];
|
|
2460
|
+
let j = 0;
|
|
2461
|
+
(offsets)["push"](__eliscript_numeric_mul((((state)["words"]) ?? []).length, 4));
|
|
2462
|
+
((state)["locals"] = locals);
|
|
2463
|
+
{
|
|
2464
|
+
const __eliscript_value_257 = (__eliscript_truthy(compact) ? allocate_registers((function$)["body"], locals, arity) : ({}));
|
|
2465
|
+
{
|
|
2466
|
+
let allocation = __eliscript_value_257;
|
|
2467
|
+
((state)["registers"] = ((allocation)["registers"] ?? []));
|
|
2468
|
+
((state)["leaf"] = ((allocation)["leaf"] ?? null));
|
|
2469
|
+
((state)["depth"] = 0);
|
|
2470
|
+
}
|
|
2471
|
+
}
|
|
2472
|
+
((state)["literalRegisters"] = []);
|
|
2473
|
+
{
|
|
2474
|
+
const __eliscript_value_258 = (__eliscript_truthy(compact) ? allocate_literal_registers(state, (function$)["body"]) : []);
|
|
2475
|
+
{
|
|
2476
|
+
let constants = __eliscript_value_258;
|
|
2477
|
+
word(state, 2847898621);
|
|
2478
|
+
word(state, 2432697341);
|
|
2479
|
+
stack_adjust(state, __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div((((locals) ?? []).length + (__eliscript_truthy(compact) ? 18 : 0)), 2)), 16), true);
|
|
2480
|
+
if (__eliscript_truthy(compact)) {
|
|
2481
|
+
preserve_registers(state, ((locals) ?? []).length, null);
|
|
2482
|
+
}
|
|
2483
|
+
{
|
|
2484
|
+
const __eliscript_value_259 = (state)["registers"];
|
|
2485
|
+
const __eliscript_value_260 = null;
|
|
2486
|
+
const __eliscript_value_261 = 0;
|
|
2487
|
+
{
|
|
2488
|
+
let registers = __eliscript_value_259;
|
|
2489
|
+
let capture = __eliscript_value_260;
|
|
2490
|
+
let k = __eliscript_value_261;
|
|
2491
|
+
if (__eliscript_truthy(compact)) {
|
|
2492
|
+
while (__eliscript_numeric_relation("<", k, arity)) {
|
|
2493
|
+
{
|
|
2494
|
+
const __eliscript_value_262 = ((((registers) ?? [])[k]) ?? null);
|
|
2495
|
+
{
|
|
2496
|
+
let r = __eliscript_value_262;
|
|
2497
|
+
if ((__eliscript_numeric_relation(">=", r, 0) && __eliscript_numeric_relation("<", r, arity) && __eliscript_numeric_relation(">", r, k))) {
|
|
2498
|
+
((capture = true));
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
((k = (k + 1)));
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
if (__eliscript_truthy(capture)) {
|
|
2506
|
+
((state)["registers"] = []);
|
|
2507
|
+
}
|
|
2508
|
+
while (__eliscript_numeric_relation("<", j, arity)) {
|
|
2509
|
+
if (__eliscript_numeric_relation("<", j, 8)) {
|
|
2510
|
+
word(state, (509624320 + __eliscript_numeric_mul(j, 32)));
|
|
2511
|
+
} else {
|
|
2512
|
+
integer_register(state, 9, (16 + __eliscript_numeric_mul(__eliscript_numeric_sub(j, 8), 8)), 0);
|
|
2513
|
+
word(state, 2332623785);
|
|
2514
|
+
word(state, 4248830240);
|
|
2515
|
+
}
|
|
2516
|
+
local_access(state, j, "f64", true);
|
|
2517
|
+
((j = (j + 1)));
|
|
2518
|
+
}
|
|
2519
|
+
if (__eliscript_truthy(capture)) {
|
|
2520
|
+
((j = 0));
|
|
2521
|
+
while (__eliscript_numeric_relation("<", j, arity)) {
|
|
2522
|
+
((state)["registers"] = []);
|
|
2523
|
+
local_access(state, j, "f64", null);
|
|
2524
|
+
((state)["registers"] = registers);
|
|
2525
|
+
local_access(state, j, "f64", true);
|
|
2526
|
+
((j = (j + 1)));
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
((state)["registers"] = registers);
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
{
|
|
2533
|
+
const __eliscript_value_263 = 0;
|
|
2534
|
+
{
|
|
2535
|
+
let k = __eliscript_value_263;
|
|
2536
|
+
while (__eliscript_numeric_relation("<", k, ((constants) ?? []).length)) {
|
|
2537
|
+
{
|
|
2538
|
+
const __eliscript_value_264 = ((((constants) ?? [])[k]) ?? null);
|
|
2539
|
+
{
|
|
2540
|
+
let entry = __eliscript_value_264;
|
|
2541
|
+
float_literal(state, (entry)["value"]);
|
|
2542
|
+
retarget_last(state, (entry)["register"]);
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
((k = (k + 1)));
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
((state)["literalRegisters"] = constants);
|
|
2550
|
+
expression(state, (function$)["body"]);
|
|
2551
|
+
if (__eliscript_truthy(compact)) {
|
|
2552
|
+
preserve_registers(state, ((locals) ?? []).length, true);
|
|
2553
|
+
}
|
|
2554
|
+
word(state, 2432697279);
|
|
2555
|
+
word(state, 2831252477);
|
|
2556
|
+
word(state, 3596551104);
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
}
|
|
2560
|
+
((i = (i + 1)));
|
|
2561
|
+
}
|
|
2562
|
+
finish_calls(state, offsets);
|
|
2563
|
+
finish_branches(state, offsets);
|
|
2564
|
+
finish_literals(state);
|
|
2565
|
+
return ({"words": (state)["words"], "offsets": offsets});
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
function macho_object(program, code, options = null) {
|
|
2569
|
+
{
|
|
2570
|
+
let words = (code)["words"];
|
|
2571
|
+
let offsets = (code)["offsets"];
|
|
2572
|
+
let functions = (program)["functions"];
|
|
2573
|
+
let size = __eliscript_numeric_mul(((words) ?? []).length, 4);
|
|
2574
|
+
let symbol_offset = __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div((208 + size), 8)), 8);
|
|
2575
|
+
let strings = [0];
|
|
2576
|
+
let names = [];
|
|
2577
|
+
let output = binary_output(options);
|
|
2578
|
+
let i = 0;
|
|
2579
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
2580
|
+
(names)["push"](((strings) ?? []).length);
|
|
2581
|
+
string_bytes(strings, (String("_") + String((((((functions) ?? [])[i]) ?? null))["name"])));
|
|
2582
|
+
((i = (i + 1)));
|
|
2583
|
+
}
|
|
2584
|
+
u32(output, 4277009103);
|
|
2585
|
+
u32(output, 16777228);
|
|
2586
|
+
u32(output, 0);
|
|
2587
|
+
u32(output, 1);
|
|
2588
|
+
u32(output, 2);
|
|
2589
|
+
u32(output, 176);
|
|
2590
|
+
u32(output, 0);
|
|
2591
|
+
u32(output, 0);
|
|
2592
|
+
u32(output, 25);
|
|
2593
|
+
u32(output, 152);
|
|
2594
|
+
zeros(output, 16);
|
|
2595
|
+
u64(output, 0);
|
|
2596
|
+
u64(output, size);
|
|
2597
|
+
u64(output, 208);
|
|
2598
|
+
u64(output, size);
|
|
2599
|
+
u32(output, 7);
|
|
2600
|
+
u32(output, 7);
|
|
2601
|
+
u32(output, 1);
|
|
2602
|
+
u32(output, 0);
|
|
2603
|
+
ascii_field(output, "__text", 16);
|
|
2604
|
+
ascii_field(output, "__TEXT", 16);
|
|
2605
|
+
u64(output, 0);
|
|
2606
|
+
u64(output, size);
|
|
2607
|
+
u32(output, 208);
|
|
2608
|
+
u32(output, 2);
|
|
2609
|
+
u32(output, 0);
|
|
2610
|
+
u32(output, 0);
|
|
2611
|
+
u32(output, 2147484672);
|
|
2612
|
+
zeros(output, 12);
|
|
2613
|
+
u32(output, 2);
|
|
2614
|
+
u32(output, 24);
|
|
2615
|
+
u32(output, symbol_offset);
|
|
2616
|
+
u32(output, ((functions) ?? []).length);
|
|
2617
|
+
u32(output, (symbol_offset + __eliscript_numeric_mul(((functions) ?? []).length, 16)));
|
|
2618
|
+
u32(output, ((strings) ?? []).length);
|
|
2619
|
+
native_append_words(output, words);
|
|
2620
|
+
zeros(output, __eliscript_numeric_sub(symbol_offset, ((output) ?? []).length));
|
|
2621
|
+
((i = 0));
|
|
2622
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
2623
|
+
u32(output, ((((names) ?? [])[i]) ?? null));
|
|
2624
|
+
binary_byte(output, (__eliscript_truthy(((program)["exports"])["includes"]((((((functions) ?? [])[i]) ?? null))["name"])) ? 15 : 14));
|
|
2625
|
+
binary_byte(output, 1);
|
|
2626
|
+
binary_byte(output, 0);
|
|
2627
|
+
binary_byte(output, 0);
|
|
2628
|
+
u64(output, ((((offsets) ?? [])[i]) ?? null));
|
|
2629
|
+
((i = (i + 1)));
|
|
2630
|
+
}
|
|
2631
|
+
((i = 0));
|
|
2632
|
+
while (__eliscript_numeric_relation("<", i, ((strings) ?? []).length)) {
|
|
2633
|
+
binary_byte(output, ((((strings) ?? [])[i]) ?? null));
|
|
2634
|
+
((i = (i + 1)));
|
|
2635
|
+
}
|
|
2636
|
+
((code)["section"] = ({"name": "__text", "fileOffset": 208, "virtualAddress": 0, "size": size}));
|
|
2637
|
+
return binary_finish(output);
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
function emit_native_numeric_object(program, target, options = null) {
|
|
2641
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
2642
|
+
backend_fail(program, "native object target must be explicit arm64-macos or arm64-linux");
|
|
2643
|
+
}
|
|
2644
|
+
lower_numeric_program(program);
|
|
2645
|
+
{
|
|
2646
|
+
const __eliscript_value_265 = optimize_numeric_program(lower_numeric_program(optimize_program(program)), ({"unswitch": ((((__eliscript_value_266) => (__eliscript_truthy(__eliscript_value_266) ? __eliscript_value_266 : ({})))(options))["registerAllocation"] ?? true), "constantFlow": ((((__eliscript_value_267) => (__eliscript_truthy(__eliscript_value_267) ? __eliscript_value_267 : ({})))(options))["registerAllocation"] ?? true), "parallelSingle": ((((__eliscript_value_268) => (__eliscript_truthy(__eliscript_value_268) ? __eliscript_value_268 : ({})))(options))["registerAllocation"] ?? true), "cyclicMultiple": ((((__eliscript_value_269) => (__eliscript_truthy(__eliscript_value_269) ? __eliscript_value_269 : ({})))(options))["registerAllocation"] ?? true)}));
|
|
2647
|
+
{
|
|
2648
|
+
let typed_program = __eliscript_value_265;
|
|
2649
|
+
if ((target === "arm64-linux")) {
|
|
2650
|
+
return emit_elf_object(typed_program, typed_code(typed_program, options), options);
|
|
2651
|
+
} else {
|
|
2652
|
+
return macho_object(typed_program, typed_code(typed_program, options), options);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
function append(output, bytes) {
|
|
2658
|
+
return binary_append(output, bytes);
|
|
2659
|
+
}
|
|
2660
|
+
function leb(output, value) {
|
|
2661
|
+
while (__eliscript_numeric_relation(">=", value, 128)) {
|
|
2662
|
+
(output)["push"](__eliscript_numeric_or(128, __eliscript_numeric_and(value, 127)));
|
|
2663
|
+
((value = __eliscript_numeric_ushr(value, 7)));
|
|
2664
|
+
}
|
|
2665
|
+
return (output)["push"](value);
|
|
2666
|
+
}
|
|
2667
|
+
function align_size(value, alignment) {
|
|
2668
|
+
return __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div(value, alignment)), alignment);
|
|
2669
|
+
}
|
|
2670
|
+
function export_trie(program, offsets) {
|
|
2671
|
+
{
|
|
2672
|
+
const __eliscript_value_270 = ({"children": [], "address": -1, "offset": 0});
|
|
2673
|
+
const __eliscript_value_271 = (program)["functions"];
|
|
2674
|
+
const __eliscript_value_272 = [];
|
|
2675
|
+
const __eliscript_value_273 = 0;
|
|
2676
|
+
{
|
|
2677
|
+
let root = __eliscript_value_270;
|
|
2678
|
+
let functions = __eliscript_value_271;
|
|
2679
|
+
let nodes = __eliscript_value_272;
|
|
2680
|
+
let i = __eliscript_value_273;
|
|
2681
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
2682
|
+
if (__eliscript_truthy(((program)["exports"])["includes"]((((((functions) ?? [])[i]) ?? null))["name"]))) {
|
|
2683
|
+
{
|
|
2684
|
+
const __eliscript_value_274 = [];
|
|
2685
|
+
const __eliscript_value_275 = root;
|
|
2686
|
+
const __eliscript_value_276 = 0;
|
|
2687
|
+
{
|
|
2688
|
+
let bytes = __eliscript_value_274;
|
|
2689
|
+
let node = __eliscript_value_275;
|
|
2690
|
+
let j = __eliscript_value_276;
|
|
2691
|
+
string_bytes(bytes, (String("_") + String((((((functions) ?? [])[i]) ?? null))["name"])));
|
|
2692
|
+
while (__eliscript_numeric_relation("<", j, __eliscript_numeric_decrement(((bytes) ?? []).length))) {
|
|
2693
|
+
{
|
|
2694
|
+
let edges = (node)["children"];
|
|
2695
|
+
let k = 0;
|
|
2696
|
+
let next = null;
|
|
2697
|
+
while (__eliscript_numeric_relation("<", k, ((edges) ?? []).length)) {
|
|
2698
|
+
if (((((((edges) ?? [])[k]) ?? null))["byte"] === ((((bytes) ?? [])[j]) ?? null))) {
|
|
2699
|
+
((next = (((((edges) ?? [])[k]) ?? null))["node"]));
|
|
2700
|
+
}
|
|
2701
|
+
((k = (k + 1)));
|
|
2702
|
+
}
|
|
2703
|
+
if ((!__eliscript_truthy(next))) {
|
|
2704
|
+
((next = ({"children": [], "address": -1, "offset": 0})));
|
|
2705
|
+
(edges)["push"](({"byte": ((((bytes) ?? [])[j]) ?? null), "node": next}));
|
|
2706
|
+
}
|
|
2707
|
+
((node = next));
|
|
2708
|
+
}
|
|
2709
|
+
((j = (j + 1)));
|
|
2710
|
+
}
|
|
2711
|
+
((node)["address"] = (4096 + ((((offsets) ?? [])[i]) ?? null)));
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
((i = (i + 1)));
|
|
2716
|
+
}
|
|
2717
|
+
(nodes)["push"](root);
|
|
2718
|
+
((i = 0));
|
|
2719
|
+
while (__eliscript_numeric_relation("<", i, ((nodes) ?? []).length)) {
|
|
2720
|
+
{
|
|
2721
|
+
const __eliscript_value_277 = (((((nodes) ?? [])[i]) ?? null))["children"];
|
|
2722
|
+
const __eliscript_value_278 = 0;
|
|
2723
|
+
{
|
|
2724
|
+
let children = __eliscript_value_277;
|
|
2725
|
+
let j = __eliscript_value_278;
|
|
2726
|
+
while (__eliscript_numeric_relation("<", j, ((children) ?? []).length)) {
|
|
2727
|
+
(nodes)["push"]((((((children) ?? [])[j]) ?? null))["node"]);
|
|
2728
|
+
((j = (j + 1)));
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
((i = (i + 1)));
|
|
2733
|
+
}
|
|
2734
|
+
{
|
|
2735
|
+
const __eliscript_value_279 = true;
|
|
2736
|
+
const __eliscript_value_280 = 0;
|
|
2737
|
+
const __eliscript_value_281 = [];
|
|
2738
|
+
{
|
|
2739
|
+
let changed = __eliscript_value_279;
|
|
2740
|
+
let round = __eliscript_value_280;
|
|
2741
|
+
let output = __eliscript_value_281;
|
|
2742
|
+
while (__eliscript_truthy(changed)) {
|
|
2743
|
+
((changed = null));
|
|
2744
|
+
((output = []));
|
|
2745
|
+
((i = 0));
|
|
2746
|
+
while (__eliscript_numeric_relation("<", i, ((nodes) ?? []).length)) {
|
|
2747
|
+
{
|
|
2748
|
+
const __eliscript_value_282 = ((((nodes) ?? [])[i]) ?? null);
|
|
2749
|
+
{
|
|
2750
|
+
let node = __eliscript_value_282;
|
|
2751
|
+
if ((!((node)["offset"] === ((output) ?? []).length))) {
|
|
2752
|
+
((changed = true));
|
|
2753
|
+
}
|
|
2754
|
+
((node)["offset"] = ((output) ?? []).length);
|
|
2755
|
+
trie_node(output, node);
|
|
2756
|
+
}
|
|
2757
|
+
}
|
|
2758
|
+
((i = (i + 1)));
|
|
2759
|
+
}
|
|
2760
|
+
((round = (round + 1)));
|
|
2761
|
+
if (__eliscript_numeric_relation(">", round, (1 + __eliscript_numeric_mul(5, ((nodes) ?? []).length)))) {
|
|
2762
|
+
backend_fail(program, "native export trie offset convergence failed");
|
|
2763
|
+
}
|
|
2764
|
+
}
|
|
2765
|
+
return output;
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
function trie_node(output, node) {
|
|
2772
|
+
{
|
|
2773
|
+
const __eliscript_value_283 = [];
|
|
2774
|
+
const __eliscript_value_284 = (node)["children"];
|
|
2775
|
+
const __eliscript_value_285 = 0;
|
|
2776
|
+
{
|
|
2777
|
+
let terminal = __eliscript_value_283;
|
|
2778
|
+
let children = __eliscript_value_284;
|
|
2779
|
+
let i = __eliscript_value_285;
|
|
2780
|
+
if (__eliscript_numeric_relation(">=", (node)["address"], 0)) {
|
|
2781
|
+
leb(terminal, 0);
|
|
2782
|
+
leb(terminal, (node)["address"]);
|
|
2783
|
+
}
|
|
2784
|
+
leb(output, ((terminal) ?? []).length);
|
|
2785
|
+
append(output, terminal);
|
|
2786
|
+
if (__eliscript_numeric_relation(">", ((children) ?? []).length, 255)) {
|
|
2787
|
+
backend_fail(null, "native trie has too many edges");
|
|
2788
|
+
}
|
|
2789
|
+
(output)["push"](((children) ?? []).length);
|
|
2790
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
2791
|
+
{
|
|
2792
|
+
const __eliscript_value_286 = ((((children) ?? [])[i]) ?? null);
|
|
2793
|
+
{
|
|
2794
|
+
let edge = __eliscript_value_286;
|
|
2795
|
+
(output)["push"]((edge)["byte"], 0);
|
|
2796
|
+
leb(output, ((edge)["node"])["offset"]);
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
((i = (i + 1)));
|
|
2800
|
+
}
|
|
2801
|
+
return null;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
function dylib_command(output, command, name) {
|
|
2806
|
+
{
|
|
2807
|
+
const __eliscript_value_287 = [];
|
|
2808
|
+
{
|
|
2809
|
+
let bytes = __eliscript_value_287;
|
|
2810
|
+
string_bytes(bytes, name);
|
|
2811
|
+
{
|
|
2812
|
+
const __eliscript_value_288 = align_size((24 + ((bytes) ?? []).length), 8);
|
|
2813
|
+
{
|
|
2814
|
+
let size = __eliscript_value_288;
|
|
2815
|
+
u32(output, command);
|
|
2816
|
+
u32(output, size);
|
|
2817
|
+
u32(output, 24);
|
|
2818
|
+
u32(output, 0);
|
|
2819
|
+
u32(output, 65536);
|
|
2820
|
+
u32(output, 65536);
|
|
2821
|
+
append(output, bytes);
|
|
2822
|
+
return zeros(output, __eliscript_numeric_sub(__eliscript_numeric_sub(size, 24), ((bytes) ?? []).length));
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
function be32(output, value) {
|
|
2829
|
+
return (output)["push"](__eliscript_numeric_ushr(value, 24), __eliscript_numeric_and(__eliscript_numeric_ushr(value, 16), 255), __eliscript_numeric_and(__eliscript_numeric_ushr(value, 8), 255), __eliscript_numeric_and(value, 255));
|
|
2830
|
+
}
|
|
2831
|
+
function be64(output, value) {
|
|
2832
|
+
be32(output, __eliscript_numeric_uint32(__eliscript_numeric_div(value, 4294967296)));
|
|
2833
|
+
return be32(output, __eliscript_numeric_uint32(value));
|
|
2834
|
+
}
|
|
2835
|
+
function page_signature(image, executable_size, main) {
|
|
2836
|
+
{
|
|
2837
|
+
let identifier = [];
|
|
2838
|
+
let limit = ((image) ?? []).length;
|
|
2839
|
+
let pages = (globalThis.Math)["ceil"](__eliscript_numeric_div(limit, 4096));
|
|
2840
|
+
let directory = [];
|
|
2841
|
+
let output = [];
|
|
2842
|
+
string_bytes(identifier, "eliscript-native");
|
|
2843
|
+
{
|
|
2844
|
+
const __eliscript_value_289 = (88 + ((identifier) ?? []).length);
|
|
2845
|
+
{
|
|
2846
|
+
let hash_offset = __eliscript_value_289;
|
|
2847
|
+
be32(directory, 4208856066);
|
|
2848
|
+
be32(directory, (hash_offset + __eliscript_numeric_mul(pages, 32)));
|
|
2849
|
+
be32(directory, 132096);
|
|
2850
|
+
be32(directory, 131074);
|
|
2851
|
+
be32(directory, hash_offset);
|
|
2852
|
+
be32(directory, 88);
|
|
2853
|
+
be32(directory, 0);
|
|
2854
|
+
be32(directory, pages);
|
|
2855
|
+
be32(directory, limit);
|
|
2856
|
+
(directory)["push"](32, 2, 0, 12);
|
|
2857
|
+
be32(directory, 0);
|
|
2858
|
+
be32(directory, 0);
|
|
2859
|
+
be32(directory, 0);
|
|
2860
|
+
be32(directory, 0);
|
|
2861
|
+
be64(directory, 0);
|
|
2862
|
+
be64(directory, 0);
|
|
2863
|
+
be64(directory, executable_size);
|
|
2864
|
+
be64(directory, (__eliscript_truthy(main) ? 1 : 0));
|
|
2865
|
+
append(directory, identifier);
|
|
2866
|
+
{
|
|
2867
|
+
const __eliscript_value_290 = 0;
|
|
2868
|
+
{
|
|
2869
|
+
let i = __eliscript_value_290;
|
|
2870
|
+
while (__eliscript_numeric_relation("<", i, pages)) {
|
|
2871
|
+
append(directory, sha256_bytes(binary_slice(image, __eliscript_numeric_mul(i, 4096), __eliscript_numeric_mul((i + 1), 4096))));
|
|
2872
|
+
((i = (i + 1)));
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
be32(output, 4208856256);
|
|
2877
|
+
be32(output, (20 + ((directory) ?? []).length));
|
|
2878
|
+
be32(output, 1);
|
|
2879
|
+
be32(output, 0);
|
|
2880
|
+
be32(output, 20);
|
|
2881
|
+
append(output, directory);
|
|
2882
|
+
return output;
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
function macho_library(program, code, entry = null, options = null) {
|
|
2888
|
+
{
|
|
2889
|
+
let functions = (program)["functions"];
|
|
2890
|
+
let offsets = (code)["offsets"];
|
|
2891
|
+
let words = (code)["words"];
|
|
2892
|
+
let size = __eliscript_numeric_mul(4, ((words) ?? []).length);
|
|
2893
|
+
let text_size = align_size((4096 + size), 16384);
|
|
2894
|
+
let trie = export_trie(program, offsets);
|
|
2895
|
+
let symbols = [];
|
|
2896
|
+
let strings = [0];
|
|
2897
|
+
let local_count = 0;
|
|
2898
|
+
let commands = [];
|
|
2899
|
+
let image = binary_output(options);
|
|
2900
|
+
let i = 0;
|
|
2901
|
+
{
|
|
2902
|
+
const __eliscript_value_291 = 0;
|
|
2903
|
+
{
|
|
2904
|
+
let pass = __eliscript_value_291;
|
|
2905
|
+
while (__eliscript_numeric_relation("<", pass, 2)) {
|
|
2906
|
+
{
|
|
2907
|
+
const __eliscript_value_292 = (pass === 1);
|
|
2908
|
+
{
|
|
2909
|
+
let external = __eliscript_value_292;
|
|
2910
|
+
((i = 0));
|
|
2911
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
2912
|
+
{
|
|
2913
|
+
let function$ = ((((functions) ?? [])[i]) ?? null);
|
|
2914
|
+
let public$ = ((program)["exports"])["includes"]((function$)["name"]);
|
|
2915
|
+
if (__eliscript_truthy((__eliscript_truthy(public$) ? external : (!__eliscript_truthy(external))))) {
|
|
2916
|
+
u32(symbols, ((strings) ?? []).length);
|
|
2917
|
+
(symbols)["push"]((__eliscript_truthy(public$) ? 15 : 14), 1, 0, 0);
|
|
2918
|
+
u64(symbols, ((__eliscript_truthy(entry) ? 4294967296 : 0) + 4096 + ((((offsets) ?? [])[i]) ?? null)));
|
|
2919
|
+
string_bytes(strings, (String("_") + String((function$)["name"])));
|
|
2920
|
+
if ((!__eliscript_truthy(public$))) {
|
|
2921
|
+
((local_count = (local_count + 1)));
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
((i = (i + 1)));
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
((pass = (pass + 1)));
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
}
|
|
2933
|
+
{
|
|
2934
|
+
let string_offset = (text_size + ((symbols) ?? []).length);
|
|
2935
|
+
let trie_offset = align_size((string_offset + ((strings) ?? []).length), 8);
|
|
2936
|
+
let signature_offset = align_size((trie_offset + ((trie) ?? []).length), 16);
|
|
2937
|
+
let signature_size = (108 + 17 + __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div(signature_offset, 4096)), 32));
|
|
2938
|
+
let link_size = (__eliscript_numeric_sub(signature_offset, text_size) + signature_size);
|
|
2939
|
+
if (__eliscript_truthy(entry)) {
|
|
2940
|
+
u32(commands, 25);
|
|
2941
|
+
u32(commands, 72);
|
|
2942
|
+
ascii_field(commands, "__PAGEZERO", 16);
|
|
2943
|
+
u64(commands, 0);
|
|
2944
|
+
u64(commands, 4294967296);
|
|
2945
|
+
u64(commands, 0);
|
|
2946
|
+
u64(commands, 0);
|
|
2947
|
+
u32(commands, 0);
|
|
2948
|
+
u32(commands, 0);
|
|
2949
|
+
u32(commands, 0);
|
|
2950
|
+
u32(commands, 0);
|
|
2951
|
+
}
|
|
2952
|
+
u32(commands, 25);
|
|
2953
|
+
u32(commands, 152);
|
|
2954
|
+
ascii_field(commands, "__TEXT", 16);
|
|
2955
|
+
u64(commands, (__eliscript_truthy(entry) ? 4294967296 : 0));
|
|
2956
|
+
u64(commands, text_size);
|
|
2957
|
+
u64(commands, 0);
|
|
2958
|
+
u64(commands, text_size);
|
|
2959
|
+
u32(commands, 5);
|
|
2960
|
+
u32(commands, 5);
|
|
2961
|
+
u32(commands, 1);
|
|
2962
|
+
u32(commands, 0);
|
|
2963
|
+
ascii_field(commands, "__text", 16);
|
|
2964
|
+
ascii_field(commands, "__TEXT", 16);
|
|
2965
|
+
u64(commands, ((__eliscript_truthy(entry) ? 4294967296 : 0) + 4096));
|
|
2966
|
+
u64(commands, size);
|
|
2967
|
+
u32(commands, 4096);
|
|
2968
|
+
u32(commands, 2);
|
|
2969
|
+
u32(commands, 0);
|
|
2970
|
+
u32(commands, 0);
|
|
2971
|
+
u32(commands, 2147484672);
|
|
2972
|
+
zeros(commands, 12);
|
|
2973
|
+
u32(commands, 25);
|
|
2974
|
+
u32(commands, 72);
|
|
2975
|
+
ascii_field(commands, "__LINKEDIT", 16);
|
|
2976
|
+
u64(commands, ((__eliscript_truthy(entry) ? 4294967296 : 0) + text_size));
|
|
2977
|
+
u64(commands, align_size(link_size, 16384));
|
|
2978
|
+
u64(commands, text_size);
|
|
2979
|
+
u64(commands, link_size);
|
|
2980
|
+
u32(commands, 1);
|
|
2981
|
+
u32(commands, 1);
|
|
2982
|
+
u32(commands, 0);
|
|
2983
|
+
u32(commands, 0);
|
|
2984
|
+
if (__eliscript_truthy(entry)) {
|
|
2985
|
+
u32(commands, 14);
|
|
2986
|
+
u32(commands, 32);
|
|
2987
|
+
u32(commands, 12);
|
|
2988
|
+
ascii_field(commands, "/usr/lib/dyld", 20);
|
|
2989
|
+
u32(commands, 2147483688);
|
|
2990
|
+
u32(commands, 24);
|
|
2991
|
+
u64(commands, (4096 + entry));
|
|
2992
|
+
u64(commands, 0);
|
|
2993
|
+
} else {
|
|
2994
|
+
dylib_command(commands, 13, "@rpath/eliscript-native.dylib");
|
|
2995
|
+
}
|
|
2996
|
+
dylib_command(commands, 12, "/usr/lib/libSystem.B.dylib");
|
|
2997
|
+
u32(commands, 27);
|
|
2998
|
+
u32(commands, 24);
|
|
2999
|
+
append(commands, (sha256_words_le(words, (__eliscript_truthy(Array.isArray(words)) ? null : native_word_at)))["slice"](0, 16));
|
|
3000
|
+
u32(commands, 50);
|
|
3001
|
+
u32(commands, 24);
|
|
3002
|
+
u32(commands, 1);
|
|
3003
|
+
u32(commands, 983040);
|
|
3004
|
+
u32(commands, 983040);
|
|
3005
|
+
u32(commands, 0);
|
|
3006
|
+
u32(commands, 2);
|
|
3007
|
+
u32(commands, 24);
|
|
3008
|
+
u32(commands, text_size);
|
|
3009
|
+
u32(commands, ((functions) ?? []).length);
|
|
3010
|
+
u32(commands, string_offset);
|
|
3011
|
+
u32(commands, ((strings) ?? []).length);
|
|
3012
|
+
u32(commands, 11);
|
|
3013
|
+
u32(commands, 80);
|
|
3014
|
+
u32(commands, 0);
|
|
3015
|
+
u32(commands, local_count);
|
|
3016
|
+
u32(commands, local_count);
|
|
3017
|
+
u32(commands, __eliscript_numeric_sub(((functions) ?? []).length, local_count));
|
|
3018
|
+
u32(commands, ((functions) ?? []).length);
|
|
3019
|
+
zeros(commands, 52);
|
|
3020
|
+
u32(commands, 2147483682);
|
|
3021
|
+
u32(commands, 48);
|
|
3022
|
+
zeros(commands, 32);
|
|
3023
|
+
u32(commands, trie_offset);
|
|
3024
|
+
u32(commands, ((trie) ?? []).length);
|
|
3025
|
+
u32(commands, 29);
|
|
3026
|
+
u32(commands, 16);
|
|
3027
|
+
u32(commands, signature_offset);
|
|
3028
|
+
u32(commands, signature_size);
|
|
3029
|
+
u32(image, 4277009103);
|
|
3030
|
+
u32(image, 16777228);
|
|
3031
|
+
u32(image, 0);
|
|
3032
|
+
u32(image, (__eliscript_truthy(entry) ? 2 : 6));
|
|
3033
|
+
u32(image, (__eliscript_truthy(entry) ? 12 : 10));
|
|
3034
|
+
u32(image, ((commands) ?? []).length);
|
|
3035
|
+
u32(image, (__eliscript_truthy(entry) ? 2097285 : 133));
|
|
3036
|
+
u32(image, 0);
|
|
3037
|
+
append(image, commands);
|
|
3038
|
+
if (__eliscript_numeric_relation(">", ((image) ?? []).length, 4096)) {
|
|
3039
|
+
backend_fail(program, "native load commands exceed text prefix");
|
|
3040
|
+
}
|
|
3041
|
+
zeros(image, __eliscript_numeric_sub(4096, ((image) ?? []).length));
|
|
3042
|
+
native_append_words(image, words);
|
|
3043
|
+
zeros(image, __eliscript_numeric_sub(text_size, ((image) ?? []).length));
|
|
3044
|
+
append(image, symbols);
|
|
3045
|
+
append(image, strings);
|
|
3046
|
+
zeros(image, __eliscript_numeric_sub(trie_offset, ((image) ?? []).length));
|
|
3047
|
+
append(image, trie);
|
|
3048
|
+
zeros(image, __eliscript_numeric_sub(signature_offset, ((image) ?? []).length));
|
|
3049
|
+
{
|
|
3050
|
+
const __eliscript_value_293 = page_signature(image, text_size, entry);
|
|
3051
|
+
{
|
|
3052
|
+
let signature = __eliscript_value_293;
|
|
3053
|
+
if ((!(((signature) ?? []).length === signature_size))) {
|
|
3054
|
+
backend_fail(program, "native signature layout mismatch");
|
|
3055
|
+
}
|
|
3056
|
+
append(image, signature);
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
((code)["section"] = ({"name": "__text", "fileOffset": 4096, "virtualAddress": ((__eliscript_truthy(entry) ? 4294967296 : 0) + 4096), "size": size}));
|
|
3060
|
+
return binary_finish(image);
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
function emit_native_numeric_library(program, target, options = null) {
|
|
3065
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
3066
|
+
backend_fail(program, "native library target must be explicit arm64-macos or arm64-linux");
|
|
3067
|
+
}
|
|
3068
|
+
lower_numeric_program(program);
|
|
3069
|
+
{
|
|
3070
|
+
const __eliscript_value_294 = optimize_numeric_program(lower_numeric_program(optimize_program(program)), ({"unswitch": ((((__eliscript_value_295) => (__eliscript_truthy(__eliscript_value_295) ? __eliscript_value_295 : ({})))(options))["registerAllocation"] ?? true), "constantFlow": ((((__eliscript_value_296) => (__eliscript_truthy(__eliscript_value_296) ? __eliscript_value_296 : ({})))(options))["registerAllocation"] ?? true), "parallelSingle": ((((__eliscript_value_297) => (__eliscript_truthy(__eliscript_value_297) ? __eliscript_value_297 : ({})))(options))["registerAllocation"] ?? true), "cyclicMultiple": ((((__eliscript_value_298) => (__eliscript_truthy(__eliscript_value_298) ? __eliscript_value_298 : ({})))(options))["registerAllocation"] ?? true)}));
|
|
3071
|
+
{
|
|
3072
|
+
let typed_program = __eliscript_value_294;
|
|
3073
|
+
if ((target === "arm64-linux")) {
|
|
3074
|
+
return emit_elf_library(typed_program, typed_code(typed_program, options), options);
|
|
3075
|
+
} else {
|
|
3076
|
+
return macho_library(typed_program, typed_code(typed_program, options), null, options);
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
function emit_native_numeric_executable(program, target, entry, options = null) {
|
|
3082
|
+
if ((!(target === "arm64-macos"))) {
|
|
3083
|
+
backend_fail(program, "native target must be explicit arm64-macos");
|
|
3084
|
+
}
|
|
3085
|
+
lower_numeric_program(program);
|
|
3086
|
+
{
|
|
3087
|
+
let typed_program = optimize_numeric_program(lower_numeric_program(optimize_program(program)), ({"unswitch": ((((__eliscript_value_299) => (__eliscript_truthy(__eliscript_value_299) ? __eliscript_value_299 : ({})))(options))["registerAllocation"] ?? true), "constantFlow": ((((__eliscript_value_300) => (__eliscript_truthy(__eliscript_value_300) ? __eliscript_value_300 : ({})))(options))["registerAllocation"] ?? true), "parallelSingle": ((((__eliscript_value_301) => (__eliscript_truthy(__eliscript_value_301) ? __eliscript_value_301 : ({})))(options))["registerAllocation"] ?? true), "cyclicMultiple": ((((__eliscript_value_302) => (__eliscript_truthy(__eliscript_value_302) ? __eliscript_value_302 : ({})))(options))["registerAllocation"] ?? true)}));
|
|
3088
|
+
let function$ = find_function((typed_program)["functions"], entry);
|
|
3089
|
+
if ((!__eliscript_truthy(((__eliscript_value_303) => (__eliscript_truthy(__eliscript_value_303) ? ((__eliscript_value_304) => (__eliscript_truthy(__eliscript_value_304) ? ((typed_program)["exports"])["includes"](entry) : __eliscript_value_304))(((function$)["arity"] === 0)) : __eliscript_value_303))(function$)))) {
|
|
3090
|
+
backend_fail(program, "native executable entry must be an exported zero-argument f64 function");
|
|
3091
|
+
}
|
|
3092
|
+
{
|
|
3093
|
+
let code = typed_code(typed_program, options);
|
|
3094
|
+
let words = (code)["words"];
|
|
3095
|
+
let start = __eliscript_numeric_mul(((words) ?? []).length, 4);
|
|
3096
|
+
let state = ({"words": words});
|
|
3097
|
+
{
|
|
3098
|
+
const __eliscript_value_305 = ((words) ?? []).length;
|
|
3099
|
+
{
|
|
3100
|
+
let call = __eliscript_value_305;
|
|
3101
|
+
word(state, 2483027968);
|
|
3102
|
+
patch_jump(state, call, __eliscript_numeric_div((((((code)["offsets"]) ?? [])[(function$)["index"]]) ?? null), 4));
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
stack_adjust(state, 16, true);
|
|
3106
|
+
word(state, 4244636640);
|
|
3107
|
+
integer_register(state, 0, 1, 0);
|
|
3108
|
+
word(state, 2432697313);
|
|
3109
|
+
integer_register(state, 2, 8, 0);
|
|
3110
|
+
integer_register(state, 16, 4, 0);
|
|
3111
|
+
word(state, 3556773889);
|
|
3112
|
+
word(state, 4043317279);
|
|
3113
|
+
{
|
|
3114
|
+
const __eliscript_value_306 = ((words) ?? []).length;
|
|
3115
|
+
{
|
|
3116
|
+
let failed = __eliscript_value_306;
|
|
3117
|
+
word(state, 1409286145);
|
|
3118
|
+
integer_register(state, 0, 0, 0);
|
|
3119
|
+
integer_register(state, 16, 1, 0);
|
|
3120
|
+
word(state, 3556773889);
|
|
3121
|
+
patch_jump(state, failed, ((words) ?? []).length);
|
|
3122
|
+
integer_register(state, 0, 1, 0);
|
|
3123
|
+
integer_register(state, 16, 1, 0);
|
|
3124
|
+
word(state, 3556773889);
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
finish_branches(state, []);
|
|
3128
|
+
((code)["words"] = (state)["words"]);
|
|
3129
|
+
return macho_library(typed_program, code, start, options);
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
function memory_error(state, code) {
|
|
3134
|
+
memory_integer_register(state, 9, code);
|
|
3135
|
+
word(state, 3103791721);
|
|
3136
|
+
{
|
|
3137
|
+
const __eliscript_value_307 = ((state)["trapSites"] ?? null);
|
|
3138
|
+
{
|
|
3139
|
+
let sites = __eliscript_value_307;
|
|
3140
|
+
if (__eliscript_truthy(sites)) {
|
|
3141
|
+
memory_integer_register(state, 9, (((sites) ?? []).length + 1));
|
|
3142
|
+
{
|
|
3143
|
+
const __eliscript_value_308 = ({"kind": "trap-site", "function": (state)["debugFunction"], "functionIndex": (state)["debugFunctionIndex"], "depth": ((state)["debugDepth"] ?? 0), "start": __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length), "end": (4 + __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length)), "span": null, "code": code, "site": (((sites) ?? []).length + 1)});
|
|
3144
|
+
{
|
|
3145
|
+
let range = __eliscript_value_308;
|
|
3146
|
+
(sites)["push"](range);
|
|
3147
|
+
((state)["debugRanges"])["push"](range);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
word(state, 3103792745);
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
return ((state)["memoryErrors"])["push"](jump(state, "jump"));
|
|
3155
|
+
}
|
|
3156
|
+
function memory_conditional_error(state, opcode, code) {
|
|
3157
|
+
{
|
|
3158
|
+
const __eliscript_value_309 = (((state)["words"]) ?? []).length;
|
|
3159
|
+
{
|
|
3160
|
+
let safe = __eliscript_value_309;
|
|
3161
|
+
word(state, opcode);
|
|
3162
|
+
memory_error(state, code);
|
|
3163
|
+
return patch_jump(state, safe, (((state)["words"]) ?? []).length);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
function memory_width(name) {
|
|
3168
|
+
if (((name === "load-u8") || (name === "store-u8"))) {
|
|
3169
|
+
return 1;
|
|
3170
|
+
} else {
|
|
3171
|
+
if (((name === "load-u16") || (name === "store-u16"))) {
|
|
3172
|
+
return 2;
|
|
3173
|
+
} else {
|
|
3174
|
+
if (((name === "load-u32") || (name === "store-u32"))) {
|
|
3175
|
+
return 4;
|
|
3176
|
+
} else {
|
|
3177
|
+
if (((name === "load-f64") || (name === "store-f64"))) {
|
|
3178
|
+
return 8;
|
|
3179
|
+
} else {
|
|
3180
|
+
return 0;
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
function memory_data_copy(state, node) {
|
|
3187
|
+
{
|
|
3188
|
+
let text = (node)["value"];
|
|
3189
|
+
let length = ((text) ?? []).length;
|
|
3190
|
+
let index = 0;
|
|
3191
|
+
expression(state, (((((node)["children"]) ?? [])[0]) ?? null));
|
|
3192
|
+
memory_integer_register(state, 10, __eliscript_numeric_mul(length, 2));
|
|
3193
|
+
word(state, 2332688394);
|
|
3194
|
+
word(state, 4181722731);
|
|
3195
|
+
word(state, 3943367007);
|
|
3196
|
+
memory_conditional_error(state, 1409286153, 1);
|
|
3197
|
+
if (__eliscript_numeric_relation(">", length, 0)) {
|
|
3198
|
+
word(state, 4181721705);
|
|
3199
|
+
word(state, 2332033321);
|
|
3200
|
+
while (__eliscript_numeric_relation("<", index, length)) {
|
|
3201
|
+
{
|
|
3202
|
+
let count = (globalThis.Math)["min"](16384, __eliscript_numeric_sub(length, index));
|
|
3203
|
+
let end = (index + count);
|
|
3204
|
+
let cursor = index;
|
|
3205
|
+
let skip = null;
|
|
3206
|
+
let data_start = 0;
|
|
3207
|
+
word(state, 268435530);
|
|
3208
|
+
((skip = jump(state, "jump")));
|
|
3209
|
+
((data_start = __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length)));
|
|
3210
|
+
while (__eliscript_numeric_relation("<", cursor, end)) {
|
|
3211
|
+
word(state, __eliscript_numeric_or((text).charCodeAt(cursor), (__eliscript_numeric_relation("<", (cursor + 1), end) ? __eliscript_numeric_mul((text).charCodeAt((cursor + 1)), 65536) : 0)));
|
|
3212
|
+
((cursor = (cursor + 2)));
|
|
3213
|
+
}
|
|
3214
|
+
if (__eliscript_truthy(((state)["debugRanges"] ?? null))) {
|
|
3215
|
+
((state)["debugRanges"])["push"](({"kind": "static-data", "dataKind": "utf16le", "function": (state)["debugFunction"], "functionIndex": (state)["debugFunctionIndex"], "depth": ((state)["debugDepth"] ?? 0), "start": data_start, "end": __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length), "span": null}));
|
|
3216
|
+
}
|
|
3217
|
+
patch_jump(state, skip, (((state)["words"]) ?? []).length);
|
|
3218
|
+
memory_integer_register(state, 11, count);
|
|
3219
|
+
{
|
|
3220
|
+
const __eliscript_value_310 = (((state)["words"]) ?? []).length;
|
|
3221
|
+
const __eliscript_value_311 = null;
|
|
3222
|
+
{
|
|
3223
|
+
let loop = __eliscript_value_310;
|
|
3224
|
+
let again = __eliscript_value_311;
|
|
3225
|
+
word(state, 2034237772);
|
|
3226
|
+
word(state, 2030043436);
|
|
3227
|
+
word(state, 2432698698);
|
|
3228
|
+
word(state, 2432698665);
|
|
3229
|
+
word(state, 4043310443);
|
|
3230
|
+
((again = (((state)["words"]) ?? []).length));
|
|
3231
|
+
word(state, 1409286145);
|
|
3232
|
+
patch_jump(state, again, loop);
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
((index = end));
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
return memory_integer_register(state, 0, 0);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
function memory_word(state, node) {
|
|
3243
|
+
{
|
|
3244
|
+
let children = (node)["children"];
|
|
3245
|
+
let count = ((children) ?? []).length;
|
|
3246
|
+
let name = (node)["value"];
|
|
3247
|
+
if ((count === 0)) {
|
|
3248
|
+
if (__eliscript_truthy(((state)["memory"] ?? null))) {
|
|
3249
|
+
return memory_integer_register(state, 0, ((name === "*") ? 1 : 0));
|
|
3250
|
+
} else {
|
|
3251
|
+
return integer_register(state, 0, ((name === "*") ? 1 : 0), 0);
|
|
3252
|
+
}
|
|
3253
|
+
} else {
|
|
3254
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
3255
|
+
if ((count === 2)) {
|
|
3256
|
+
{
|
|
3257
|
+
const __eliscript_value_312 = ((((children) ?? [])[1]) ?? null);
|
|
3258
|
+
{
|
|
3259
|
+
let right = __eliscript_value_312;
|
|
3260
|
+
if (__eliscript_truthy(((__eliscript_value_313) => (__eliscript_truthy(__eliscript_value_313) ? ((__eliscript_value_314) => (__eliscript_truthy(__eliscript_value_314) ? ((__eliscript_value_315) => (__eliscript_truthy(__eliscript_value_315) ? ((__eliscript_value_316) => (__eliscript_truthy(__eliscript_value_316) ? ((__eliscript_value_317) => (__eliscript_truthy(__eliscript_value_317) ? (((right)["kind"] === "literal") || ((right)["kind"] === "local")) : __eliscript_value_317))(memory_word_type((right)["type"])) : __eliscript_value_316))(((((state)["registers"]) ?? []).length === 0)) : __eliscript_value_315))((!__eliscript_truthy(((state)["leaf"] ?? null)))) : __eliscript_value_314))((!__eliscript_truthy(((state)["compact"] ?? null)))) : __eliscript_value_313))(((state)["memory"] ?? null)))) {
|
|
3261
|
+
word(state, 704644065);
|
|
3262
|
+
expression(state, right);
|
|
3263
|
+
} else {
|
|
3264
|
+
push_value(state, "u32");
|
|
3265
|
+
expression(state, right);
|
|
3266
|
+
pop_value(state, "u32");
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
if (((node)["kind"] === "word-compare")) {
|
|
3271
|
+
{
|
|
3272
|
+
const __eliscript_value_318 = ((name === "=") ? 0 : ((name === "/=") ? 1 : ((name === "<") ? 3 : ((name === "<=") ? 9 : ((name === ">") ? 8 : 2)))));
|
|
3273
|
+
{
|
|
3274
|
+
let code = __eliscript_value_318;
|
|
3275
|
+
word(state, 1795162175);
|
|
3276
|
+
return word(state, (446629856 + __eliscript_numeric_mul(__eliscript_numeric_xor(code, 1), 4096)));
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
} else {
|
|
3280
|
+
return word(state, ((name === "+") ? 184549408 : ((name === "-") ? 1258291232 : 453016608)));
|
|
3281
|
+
}
|
|
3282
|
+
} else {
|
|
3283
|
+
if ((name === "-")) {
|
|
3284
|
+
return word(state, 1258292192);
|
|
3285
|
+
} else {
|
|
3286
|
+
if ((name === "1+")) {
|
|
3287
|
+
return word(state, 285213696);
|
|
3288
|
+
} else {
|
|
3289
|
+
if ((name === "1-")) {
|
|
3290
|
+
return word(state, 1358955520);
|
|
3291
|
+
} else {
|
|
3292
|
+
return null;
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
function memory_grow(state, node) {
|
|
3301
|
+
expression(state, (((((node)["children"]) ?? [])[0]) ?? null));
|
|
3302
|
+
word(state, 4181722731);
|
|
3303
|
+
word(state, 4181723756);
|
|
3304
|
+
word(state, 2332049770);
|
|
3305
|
+
word(state, 3943432543);
|
|
3306
|
+
{
|
|
3307
|
+
const __eliscript_value_319 = (((state)["words"]) ?? []).length;
|
|
3308
|
+
{
|
|
3309
|
+
let failed = __eliscript_value_319;
|
|
3310
|
+
word(state, 1409286152);
|
|
3311
|
+
word(state, 3545300320);
|
|
3312
|
+
word(state, 4181721705);
|
|
3313
|
+
word(state, 2332754217);
|
|
3314
|
+
word(state, 3406496076);
|
|
3315
|
+
{
|
|
3316
|
+
const __eliscript_value_320 = (((state)["words"]) ?? []).length;
|
|
3317
|
+
{
|
|
3318
|
+
let done = __eliscript_value_320;
|
|
3319
|
+
word(state, 3019898892);
|
|
3320
|
+
{
|
|
3321
|
+
const __eliscript_value_321 = (((state)["words"]) ?? []).length;
|
|
3322
|
+
{
|
|
3323
|
+
let loop = __eliscript_value_321;
|
|
3324
|
+
word(state, 939529535);
|
|
3325
|
+
word(state, 4043310476);
|
|
3326
|
+
{
|
|
3327
|
+
const __eliscript_value_322 = (((state)["words"]) ?? []).length;
|
|
3328
|
+
{
|
|
3329
|
+
let back = __eliscript_value_322;
|
|
3330
|
+
word(state, 1409286145);
|
|
3331
|
+
patch_jump(state, back, loop);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
patch_jump(state, done, (((state)["words"]) ?? []).length);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
word(state, 4177528426);
|
|
3340
|
+
{
|
|
3341
|
+
const __eliscript_value_323 = jump(state, "jump");
|
|
3342
|
+
{
|
|
3343
|
+
let end = __eliscript_value_323;
|
|
3344
|
+
patch_jump(state, failed, (((state)["words"]) ?? []).length);
|
|
3345
|
+
memory_integer_register(state, 0, 4294967295);
|
|
3346
|
+
return patch_jump(state, end, (((state)["words"]) ?? []).length);
|
|
3347
|
+
}
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
function memory_f64_unary_instruction(name) {
|
|
3353
|
+
if ((name === "f64-abs")) {
|
|
3354
|
+
return 509657088;
|
|
3355
|
+
} else {
|
|
3356
|
+
if ((name === "f64-neg")) {
|
|
3357
|
+
return 509689856;
|
|
3358
|
+
} else {
|
|
3359
|
+
if ((name === "f64-ceil")) {
|
|
3360
|
+
return 509919232;
|
|
3361
|
+
} else {
|
|
3362
|
+
if ((name === "f64-floor")) {
|
|
3363
|
+
return 509952000;
|
|
3364
|
+
} else {
|
|
3365
|
+
if ((name === "f64-trunc")) {
|
|
3366
|
+
return 509984768;
|
|
3367
|
+
} else {
|
|
3368
|
+
if ((name === "f64-nearest")) {
|
|
3369
|
+
return 509886464;
|
|
3370
|
+
} else {
|
|
3371
|
+
if ((name === "f64-sqrt")) {
|
|
3372
|
+
return 509722624;
|
|
3373
|
+
} else {
|
|
3374
|
+
return null;
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
function memory_f64_unary(state, node) {
|
|
3384
|
+
expression(state, (((((node)["children"]) ?? [])[0]) ?? null));
|
|
3385
|
+
word(state, 3577431049);
|
|
3386
|
+
word(state, 3575333919);
|
|
3387
|
+
word(state, memory_f64_unary_instruction((node)["value"]));
|
|
3388
|
+
return word(state, 3575333897);
|
|
3389
|
+
}
|
|
3390
|
+
function memory_operation(state, node) {
|
|
3391
|
+
{
|
|
3392
|
+
let name = (node)["value"];
|
|
3393
|
+
let children = (node)["children"];
|
|
3394
|
+
let width = memory_width(name);
|
|
3395
|
+
let store = (((children) ?? []).length === 2);
|
|
3396
|
+
if (__eliscript_truthy(memory_f64_unary_instruction(name))) {
|
|
3397
|
+
return memory_f64_unary(state, node);
|
|
3398
|
+
} else {
|
|
3399
|
+
if (__eliscript_numeric_relation(">", width, 0)) {
|
|
3400
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
3401
|
+
if (__eliscript_truthy(store)) {
|
|
3402
|
+
push_value(state, "u32");
|
|
3403
|
+
expression(state, ((((children) ?? [])[1]) ?? null));
|
|
3404
|
+
push_value(state, ((name === "store-f64") ? "f64" : "u32"));
|
|
3405
|
+
pop_value(state, ((name === "store-f64") ? "f64" : "u32"));
|
|
3406
|
+
word(state, ((name === "store-f64") ? 509624354 : 704709602));
|
|
3407
|
+
pop_value(state, "u32");
|
|
3408
|
+
word(state, 704709600);
|
|
3409
|
+
}
|
|
3410
|
+
word(state, (2432696330 + __eliscript_numeric_mul(width, 1024)));
|
|
3411
|
+
word(state, 4181722731);
|
|
3412
|
+
word(state, 3943367007);
|
|
3413
|
+
memory_conditional_error(state, 1409286153, 1);
|
|
3414
|
+
word(state, 4181721705);
|
|
3415
|
+
word(state, 2332033321);
|
|
3416
|
+
word(state, ((name === "load-u8") ? 960495904 : ((name === "load-u16") ? 2034237728 : ((name === "load-u32") ? 3107979552 : ((name === "load-f64") ? 4248830240 : ((name === "store-u8") ? 956301602 : ((name === "store-u16") ? 2030043426 : ((name === "store-u32") ? 3103785250 : 4244635938))))))));
|
|
3417
|
+
if (__eliscript_truthy(store)) {
|
|
3418
|
+
return memory_integer_register(state, 0, 0);
|
|
3419
|
+
} else {
|
|
3420
|
+
return null;
|
|
3421
|
+
}
|
|
3422
|
+
} else {
|
|
3423
|
+
if ((name === "memory-size")) {
|
|
3424
|
+
word(state, 4181722720);
|
|
3425
|
+
return word(state, 3545299968);
|
|
3426
|
+
} else {
|
|
3427
|
+
if ((name === "memory-grow")) {
|
|
3428
|
+
return memory_grow(state, node);
|
|
3429
|
+
} else {
|
|
3430
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
3431
|
+
push_value(state, "u32");
|
|
3432
|
+
expression(state, ((((children) ?? [])[1]) ?? null));
|
|
3433
|
+
pop_value(state, "u32");
|
|
3434
|
+
if ((name === "word-div")) {
|
|
3435
|
+
memory_conditional_error(state, 889192448, 2);
|
|
3436
|
+
}
|
|
3437
|
+
return word(state, ((name === "word-div") ? 448792608 : ((name === "word-shr") ? 448799776 : ((name === "word-shl") ? 448798752 : ((name === "word-and") ? 167772192 : ((name === "word-or") ? 704643104 : ((name === "word-xor") ? 1241514016 : backend_fail(node, "unsupported native memory32 opcode"))))))));
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
}
|
|
3444
|
+
function memory_call(state, node) {
|
|
3445
|
+
{
|
|
3446
|
+
let args = (node)["children"];
|
|
3447
|
+
let indirect = ((node)["kind"] === "call-indirect");
|
|
3448
|
+
let count = __eliscript_numeric_sub(((args) ?? []).length, (__eliscript_truthy(indirect) ? 1 : 0));
|
|
3449
|
+
let i = 0;
|
|
3450
|
+
let slot_size = (__eliscript_truthy(((state)["linux"] ?? null)) ? 8 : 4);
|
|
3451
|
+
let extra = __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div((__eliscript_numeric_relation(">", count, 7) ? __eliscript_numeric_mul(__eliscript_numeric_sub(count, 7), slot_size) : 0), 16)), 16);
|
|
3452
|
+
while (__eliscript_numeric_relation("<", i, ((args) ?? []).length)) {
|
|
3453
|
+
expression(state, ((((args) ?? [])[i]) ?? null));
|
|
3454
|
+
push_value(state, "u32");
|
|
3455
|
+
((i = (i + 1)));
|
|
3456
|
+
}
|
|
3457
|
+
if (__eliscript_truthy(indirect)) {
|
|
3458
|
+
pop_value(state, "u32");
|
|
3459
|
+
memory_indirect_target(state, node);
|
|
3460
|
+
}
|
|
3461
|
+
stack_adjust(state, extra, true);
|
|
3462
|
+
((i = 0));
|
|
3463
|
+
while (__eliscript_numeric_relation("<", i, count)) {
|
|
3464
|
+
word(state, 2432697321);
|
|
3465
|
+
{
|
|
3466
|
+
const __eliscript_value_324 = (extra + __eliscript_numeric_mul(__eliscript_numeric_decrement(__eliscript_numeric_sub(count, i)), 16));
|
|
3467
|
+
{
|
|
3468
|
+
let offset = __eliscript_value_324;
|
|
3469
|
+
while (__eliscript_numeric_relation(">", offset, 0)) {
|
|
3470
|
+
{
|
|
3471
|
+
const __eliscript_value_325 = (__eliscript_numeric_relation("<", offset, 4095) ? offset : 4095);
|
|
3472
|
+
{
|
|
3473
|
+
let part = __eliscript_value_325;
|
|
3474
|
+
word(state, (2432696617 + __eliscript_numeric_mul(part, 1024)));
|
|
3475
|
+
((offset = __eliscript_numeric_sub(offset, part)));
|
|
3476
|
+
}
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
}
|
|
3481
|
+
word(state, (3107979552 + (__eliscript_numeric_relation("<", i, 7) ? (i + 1) : 10)));
|
|
3482
|
+
if (__eliscript_numeric_relation(">=", i, 7)) {
|
|
3483
|
+
word(state, 2432697321);
|
|
3484
|
+
{
|
|
3485
|
+
const __eliscript_value_326 = __eliscript_numeric_mul(__eliscript_numeric_sub(i, 7), slot_size);
|
|
3486
|
+
{
|
|
3487
|
+
let offset = __eliscript_value_326;
|
|
3488
|
+
while (__eliscript_numeric_relation(">", offset, 0)) {
|
|
3489
|
+
{
|
|
3490
|
+
const __eliscript_value_327 = (__eliscript_numeric_relation("<", offset, 4095) ? offset : 4095);
|
|
3491
|
+
{
|
|
3492
|
+
let part = __eliscript_value_327;
|
|
3493
|
+
word(state, (2432696617 + __eliscript_numeric_mul(part, 1024)));
|
|
3494
|
+
((offset = __eliscript_numeric_sub(offset, part)));
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
word(state, 3103785258);
|
|
3501
|
+
}
|
|
3502
|
+
((i = (i + 1)));
|
|
3503
|
+
}
|
|
3504
|
+
word(state, 2853372896);
|
|
3505
|
+
if (__eliscript_truthy(indirect)) {
|
|
3506
|
+
word(state, 3594453504);
|
|
3507
|
+
} else {
|
|
3508
|
+
{
|
|
3509
|
+
const __eliscript_value_328 = (((state)["words"]) ?? []).length;
|
|
3510
|
+
{
|
|
3511
|
+
let at = __eliscript_value_328;
|
|
3512
|
+
word(state, 2483027968);
|
|
3513
|
+
((state)["calls"])["push"](({"at": at, "target": (node)["value"]}));
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
stack_adjust(state, (extra + __eliscript_numeric_mul(count, 16)), null);
|
|
3518
|
+
((state)["depth"] = __eliscript_numeric_sub((state)["depth"], count));
|
|
3519
|
+
word(state, 3107986025);
|
|
3520
|
+
{
|
|
3521
|
+
const __eliscript_value_329 = (((state)["words"]) ?? []).length;
|
|
3522
|
+
{
|
|
3523
|
+
let at = __eliscript_value_329;
|
|
3524
|
+
word(state, 889192457);
|
|
3525
|
+
return ((state)["memoryErrors"])["push"](at);
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
function memory_host_call(state, node) {
|
|
3531
|
+
{
|
|
3532
|
+
const __eliscript_value_330 = (node)["children"];
|
|
3533
|
+
const __eliscript_value_331 = host_capability_index((state)["hostCapabilities"], node);
|
|
3534
|
+
{
|
|
3535
|
+
let children = __eliscript_value_330;
|
|
3536
|
+
let index = __eliscript_value_331;
|
|
3537
|
+
expression(state, ((((children) ?? [])[0]) ?? null));
|
|
3538
|
+
push_value(state, "u32");
|
|
3539
|
+
expression(state, ((((children) ?? [])[1]) ?? null));
|
|
3540
|
+
word(state, 704644067);
|
|
3541
|
+
pop_value(state, "u32");
|
|
3542
|
+
word(state, 704709602);
|
|
3543
|
+
memory_integer_register(state, 1, index);
|
|
3544
|
+
word(state, 2853372896);
|
|
3545
|
+
word(state, 4181725808);
|
|
3546
|
+
memory_conditional_error(state, 3036676112, 6);
|
|
3547
|
+
word(state, 3594453504);
|
|
3548
|
+
word(state, 3107986025);
|
|
3549
|
+
{
|
|
3550
|
+
const __eliscript_value_332 = (((state)["words"]) ?? []).length;
|
|
3551
|
+
{
|
|
3552
|
+
let at = __eliscript_value_332;
|
|
3553
|
+
word(state, 889192457);
|
|
3554
|
+
return ((state)["memoryErrors"])["push"](at);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
function native_phase(observer, phase, count, words, branches, calls) {
|
|
3561
|
+
if ((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(observer) === "function")) {
|
|
3562
|
+
(() => {
|
|
3563
|
+
try {
|
|
3564
|
+
return observer(phase, ({"count": count, "words": words, "branches": branches, "calls": calls}));
|
|
3565
|
+
} catch (ignored) {
|
|
3566
|
+
return null;
|
|
3567
|
+
}
|
|
3568
|
+
})();
|
|
3569
|
+
}
|
|
3570
|
+
return null;
|
|
3571
|
+
}
|
|
3572
|
+
function native_memory_prepare(program, observer, fresh = null) {
|
|
3573
|
+
native_phase(observer, "native-prepare-start", 0, 0, 0, 0);
|
|
3574
|
+
{
|
|
3575
|
+
const __eliscript_value_333 = (__eliscript_truthy(fresh) ? memory_prepare_fresh_program(program) : memory_prepare_program(program));
|
|
3576
|
+
{
|
|
3577
|
+
let prepared = __eliscript_value_333;
|
|
3578
|
+
native_phase(observer, "native-prepare-complete", (((prepared)["functions"]) ?? []).length, 0, 0, 0);
|
|
3579
|
+
return prepared;
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
}
|
|
3583
|
+
function native_memory_container(program, code, target, format, options, observer) {
|
|
3584
|
+
{
|
|
3585
|
+
const __eliscript_value_334 = (((code)["words"]) ?? []).length;
|
|
3586
|
+
{
|
|
3587
|
+
let word_count = __eliscript_value_334;
|
|
3588
|
+
native_phase(observer, "native-container-start", (((program)["functions"]) ?? []).length, word_count, 0, 0);
|
|
3589
|
+
{
|
|
3590
|
+
const __eliscript_value_335 = ((target === "arm64-linux") ? ((format === "object") ? emit_elf_object(program, code, options) : emit_elf_library(program, code, options)) : ((format === "object") ? macho_object(program, code, options) : macho_library(program, code, null, options)));
|
|
3591
|
+
{
|
|
3592
|
+
let bytes = __eliscript_value_335;
|
|
3593
|
+
native_phase(observer, "native-container-complete", (((program)["functions"]) ?? []).length, word_count, 0, 0);
|
|
3594
|
+
((code)["words"] = null);
|
|
3595
|
+
return bytes;
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
function memory_code(program, target = null, options = null, observer = null) {
|
|
3602
|
+
{
|
|
3603
|
+
let linux = (target === "arm64-linux");
|
|
3604
|
+
let slot_size = (__eliscript_truthy(linux) ? 8 : 4);
|
|
3605
|
+
let debug = ((((__eliscript_value_336) => (__eliscript_truthy(__eliscript_value_336) ? __eliscript_value_336 : ({})))(options))["debug"] ?? null);
|
|
3606
|
+
let state = ({"words": (__eliscript_truthy(((((__eliscript_value_337) => (__eliscript_truthy(__eliscript_value_337) ? __eliscript_value_337 : ({})))(options))["packedWords"] ?? null)) ? native_word_buffer() : []), "calls": [], "constants": [], "compact": null, "leaf": null, "memory": true, "linux": linux, "registers": [], "debugRanges": (__eliscript_truthy(debug) ? [] : null), "trapSites": (__eliscript_truthy(debug) ? [] : null), "hostCapabilities": ((program)["hostCapabilities"] ?? []), "table": ((program)["table"] ?? null), "tableUses": []});
|
|
3607
|
+
let functions = (program)["functions"];
|
|
3608
|
+
let offsets = [];
|
|
3609
|
+
let i = 0;
|
|
3610
|
+
native_phase(observer, "native-code-start", 0, 0, 0, 0);
|
|
3611
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
3612
|
+
{
|
|
3613
|
+
let function$ = ((((functions) ?? [])[i]) ?? null);
|
|
3614
|
+
let locals = (function$)["locals"];
|
|
3615
|
+
let arity = (function$)["arity"];
|
|
3616
|
+
let frame = __eliscript_numeric_mul((globalThis.Math)["ceil"](__eliscript_numeric_div((((locals) ?? []).length + 1), 2)), 16);
|
|
3617
|
+
let j = 0;
|
|
3618
|
+
(offsets)["push"](__eliscript_numeric_mul((((state)["words"]) ?? []).length, 4));
|
|
3619
|
+
((state)["depth"] = 0);
|
|
3620
|
+
((state)["memoryErrors"] = []);
|
|
3621
|
+
if (__eliscript_truthy(debug)) {
|
|
3622
|
+
((state)["debugFunction"] = (function$)["name"]);
|
|
3623
|
+
((state)["debugFunctionIndex"] = i);
|
|
3624
|
+
((state)["debugDepth"] = 0);
|
|
3625
|
+
{
|
|
3626
|
+
let source = ((function$)["source"] ?? null);
|
|
3627
|
+
let range = ({"kind": "function", "function": (function$)["name"], "functionIndex": i, "depth": -1, "start": __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length), "end": 0, "span": ((function$)["span"] ?? (__eliscript_truthy(source) ? ((source)["span"] ?? null) : null))});
|
|
3628
|
+
((state)["debugFunctionRange"] = range);
|
|
3629
|
+
((state)["debugRanges"])["push"](range);
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
word(state, 2847898621);
|
|
3633
|
+
word(state, 2432697341);
|
|
3634
|
+
stack_adjust(state, frame, true);
|
|
3635
|
+
word(state, 4177527795);
|
|
3636
|
+
word(state, 2852127731);
|
|
3637
|
+
while (__eliscript_numeric_relation("<", j, arity)) {
|
|
3638
|
+
if (__eliscript_numeric_relation("<", j, 7)) {
|
|
3639
|
+
word(state, (704644064 + __eliscript_numeric_mul((j + 1), 65536)));
|
|
3640
|
+
} else {
|
|
3641
|
+
integer_register(state, 9, (16 + __eliscript_numeric_mul(__eliscript_numeric_sub(j, 7), slot_size)), 0);
|
|
3642
|
+
word(state, 2332623785);
|
|
3643
|
+
word(state, 3107979552);
|
|
3644
|
+
}
|
|
3645
|
+
local_access(state, j, "u32", true);
|
|
3646
|
+
((j = (j + 1)));
|
|
3647
|
+
}
|
|
3648
|
+
while (__eliscript_numeric_relation("<", j, ((locals) ?? []).length)) {
|
|
3649
|
+
{
|
|
3650
|
+
const __eliscript_value_338 = (((((locals) ?? [])[j]) ?? null))["type"];
|
|
3651
|
+
{
|
|
3652
|
+
let type = __eliscript_value_338;
|
|
3653
|
+
if ((type === "f64")) {
|
|
3654
|
+
word(state, 2657551328);
|
|
3655
|
+
} else {
|
|
3656
|
+
memory_integer_register(state, 0, 0);
|
|
3657
|
+
}
|
|
3658
|
+
local_access(state, j, type, true);
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
((j = (j + 1)));
|
|
3662
|
+
}
|
|
3663
|
+
expression(state, (function$)["body"]);
|
|
3664
|
+
{
|
|
3665
|
+
const __eliscript_value_339 = jump(state, "jump");
|
|
3666
|
+
{
|
|
3667
|
+
let normal = __eliscript_value_339;
|
|
3668
|
+
patch_conditions(state, (state)["memoryErrors"], (((state)["words"]) ?? []).length);
|
|
3669
|
+
memory_integer_register(state, 0, 0);
|
|
3670
|
+
patch_jump(state, normal, (((state)["words"]) ?? []).length);
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
integer_register(state, 9, frame, 0);
|
|
3674
|
+
word(state, 3406365609);
|
|
3675
|
+
word(state, 4181721395);
|
|
3676
|
+
word(state, 2432697279);
|
|
3677
|
+
word(state, 2831252477);
|
|
3678
|
+
word(state, 3596551104);
|
|
3679
|
+
if (__eliscript_truthy(debug)) {
|
|
3680
|
+
(((state)["debugFunctionRange"])["end"] = __eliscript_numeric_mul(4, (((state)["words"]) ?? []).length));
|
|
3681
|
+
}
|
|
3682
|
+
}
|
|
3683
|
+
((i = (i + 1)));
|
|
3684
|
+
if (((((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(observer) === "function") && (__eliscript_numeric_rem(i, 128) === 0))) {
|
|
3685
|
+
native_phase(observer, "native-code-progress", i, (((state)["words"]) ?? []).length, ((((state)["branches"] ?? [])) ?? []).length, (((state)["calls"]) ?? []).length);
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
{
|
|
3689
|
+
const __eliscript_value_340 = finish_calls(state, offsets);
|
|
3690
|
+
{
|
|
3691
|
+
let call_count = __eliscript_value_340;
|
|
3692
|
+
finish_branches(state, offsets);
|
|
3693
|
+
memory_finish_table(state, program, offsets);
|
|
3694
|
+
native_phase(observer, "native-code-complete", ((functions) ?? []).length, (((state)["words"]) ?? []).length, ((((state)["branches"] ?? [])) ?? []).length, call_count);
|
|
3695
|
+
{
|
|
3696
|
+
const __eliscript_value_341 = ({"words": (state)["words"], "offsets": offsets, "debugRanges": ((state)["debugRanges"] ?? null), "trapSites": ((state)["trapSites"] ?? null)});
|
|
3697
|
+
{
|
|
3698
|
+
let code = __eliscript_value_341;
|
|
3699
|
+
if ((!__eliscript_truthy(Array.isArray((code)["words"])))) {
|
|
3700
|
+
((code)["wordReader"] = native_word_at);
|
|
3701
|
+
}
|
|
3702
|
+
return code;
|
|
3703
|
+
}
|
|
3704
|
+
}
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
}
|
|
3708
|
+
}
|
|
3709
|
+
function emit_native_memory_object(program, target, options = null) {
|
|
3710
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
3711
|
+
backend_fail(program, "native memory target must be explicit arm64-macos or arm64-linux");
|
|
3712
|
+
}
|
|
3713
|
+
{
|
|
3714
|
+
const __eliscript_value_342 = lower_memory_program(program);
|
|
3715
|
+
{
|
|
3716
|
+
let typed_program = __eliscript_value_342;
|
|
3717
|
+
return emit_typed_native_memory_object(typed_program, target, options);
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
function emit_native_memory_library(program, target, options = null) {
|
|
3722
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
3723
|
+
backend_fail(program, "native memory target must be explicit arm64-macos or arm64-linux");
|
|
3724
|
+
}
|
|
3725
|
+
{
|
|
3726
|
+
const __eliscript_value_343 = lower_memory_program(program);
|
|
3727
|
+
{
|
|
3728
|
+
let typed_program = __eliscript_value_343;
|
|
3729
|
+
return emit_typed_native_memory_library(typed_program, target, options);
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
function memory_word_type(type) {
|
|
3734
|
+
return ((type === "u32") || (type === "i32"));
|
|
3735
|
+
}
|
|
3736
|
+
function memory_valid_index(value, limit) {
|
|
3737
|
+
return ((((__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") && (value === __eliscript_numeric_uint32(value)) && __eliscript_numeric_relation("<", value, limit));
|
|
3738
|
+
}
|
|
3739
|
+
function memory_validate_node(node, function$, program, arities, capabilities, completed = null) {
|
|
3740
|
+
if ((!__eliscript_truthy(((__eliscript_value_344) => (__eliscript_truthy(__eliscript_value_344) ? (completed)["has"](node) : __eliscript_value_344))(completed)))) {
|
|
3741
|
+
{
|
|
3742
|
+
const __eliscript_value_345 = (node)["kind"];
|
|
3743
|
+
const __eliscript_value_346 = (node)["children"];
|
|
3744
|
+
const __eliscript_value_347 = (node)["value"];
|
|
3745
|
+
const __eliscript_value_348 = 0;
|
|
3746
|
+
{
|
|
3747
|
+
let kind = __eliscript_value_345;
|
|
3748
|
+
let children = __eliscript_value_346;
|
|
3749
|
+
let value = __eliscript_value_347;
|
|
3750
|
+
let i = __eliscript_value_348;
|
|
3751
|
+
if ((!__eliscript_truthy(Array.isArray(children)))) {
|
|
3752
|
+
backend_fail(node, "native typed node requires children");
|
|
3753
|
+
}
|
|
3754
|
+
if (((kind === "local") || (kind === "set") || (kind === "initialize"))) {
|
|
3755
|
+
if ((!__eliscript_truthy(((__eliscript_value_349) => (__eliscript_truthy(__eliscript_value_349) ? ((node)["type"] === ((((((function$)["locals"]) ?? [])[value]) ?? null))["type"]) : __eliscript_value_349))(memory_valid_index(value, (((function$)["locals"]) ?? []).length))))) {
|
|
3756
|
+
backend_fail(node, "native typed local index or type is invalid");
|
|
3757
|
+
}
|
|
3758
|
+
}
|
|
3759
|
+
if ((kind === "call")) {
|
|
3760
|
+
if ((!__eliscript_truthy(((__eliscript_value_350) => (__eliscript_truthy(__eliscript_value_350) ? (((children) ?? []).length === ((((((program)["functions"]) ?? [])[value]) ?? null))["arity"]) : __eliscript_value_350))(memory_valid_index(value, (((program)["functions"]) ?? []).length))))) {
|
|
3761
|
+
backend_fail(node, "native direct call requires an exact declared signature");
|
|
3762
|
+
}
|
|
3763
|
+
}
|
|
3764
|
+
if ((kind === "call-indirect")) {
|
|
3765
|
+
if ((!__eliscript_truthy(((__eliscript_value_351) => (__eliscript_truthy(__eliscript_value_351) ? ((__eliscript_value_352) => (__eliscript_truthy(__eliscript_value_352) ? ((__eliscript_value_353) => (__eliscript_truthy(__eliscript_value_353) ? ((__eliscript_value_354) => (__eliscript_truthy(__eliscript_value_354) ? memory_word_type((node)["type"]) : __eliscript_value_354))((arities)["includes"](value)) : __eliscript_value_353))((((children) ?? []).length === (value + 1))) : __eliscript_value_352))(memory_valid_index(value, 65536)) : __eliscript_value_351))(Array.isArray(((program)["table"] ?? null)))))) {
|
|
3766
|
+
backend_fail(node, "indirect calls require a memory-u32 table and an exact signature");
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
if ((kind === "host-call")) {
|
|
3770
|
+
host_capability_index(capabilities, node);
|
|
3771
|
+
}
|
|
3772
|
+
if (__eliscript_truthy(((__eliscript_value_355) => (__eliscript_truthy(__eliscript_value_355) ? memory_f64_unary_instruction(value) : __eliscript_value_355))((kind === "memory-op")))) {
|
|
3773
|
+
if ((!__eliscript_truthy(((__eliscript_value_356) => (__eliscript_truthy(__eliscript_value_356) ? ((__eliscript_value_357) => (__eliscript_truthy(__eliscript_value_357) ? ((__eliscript_value_358) => (__eliscript_truthy(__eliscript_value_358) ? ((__eliscript_value_359) => (__eliscript_truthy(__eliscript_value_359) ? ((__eliscript_value_360) => (__eliscript_truthy(__eliscript_value_360) ? ((__eliscript_value_361) => (__eliscript_truthy(__eliscript_value_361) ? ((((((children) ?? [])[0]) ?? null))["type"] === "f64") : __eliscript_value_361))(Array.isArray((((((children) ?? [])[0]) ?? null))["children"])) : __eliscript_value_360))((!__eliscript_truthy(Array.isArray(((((children) ?? [])[0]) ?? null))))) : __eliscript_value_359))((((__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_358))((!(((((children) ?? [])[0]) ?? null) === null))) : __eliscript_value_357))((((children) ?? []).length === 1)) : __eliscript_value_356))(((node)["type"] === "f64"))))) {
|
|
3774
|
+
backend_fail(node, "f64 unary memory opcode requires one f64 operand and result");
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
if ((kind === "memory-data-copy")) {
|
|
3778
|
+
if ((!(((node)["type"] === "u32") && (((__eliscript_value) => { if (__eliscript_value === null) return "null"; const __eliscript_host_type = typeof __eliscript_value; if (__eliscript_host_type !== "object" && __eliscript_host_type !== "function") return __eliscript_host_type; try { const __eliscript_type = Object.getOwnPropertyDescriptor(__eliscript_value, Symbol.for("eliscript.value.type")); if (__eliscript_type && Object.prototype.hasOwnProperty.call(__eliscript_type, "value") && (__eliscript_type.value === "keyword" || __eliscript_type.value === "symbol")) return __eliscript_type.value; const __eliscript_kind = Object.getOwnPropertyDescriptor(__eliscript_value, "kind"); if (__eliscript_kind && Object.prototype.hasOwnProperty.call(__eliscript_kind, "value")) { if (__eliscript_kind.value === "eliscript/keyword") return "keyword"; if (__eliscript_kind.value === "eliscript/symbol") return "symbol"; } return __eliscript_host_type; } catch { return __eliscript_host_type; } })(value) === "string") && __eliscript_numeric_relation("<=", ((value) ?? []).length, 2147483647) && (((children) ?? []).length === 1) && ((((((children) ?? [])[0]) ?? null))["type"] === "u32")))) {
|
|
3779
|
+
backend_fail(node, "static UTF16 copy requires memory-u32, one word address and string data");
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
while (__eliscript_numeric_relation("<", i, ((children) ?? []).length)) {
|
|
3783
|
+
if ((((kind === "call") || (kind === "call-indirect") || (kind === "host-call")) && (!__eliscript_truthy(memory_word_type((((((children) ?? [])[i]) ?? null))["type"]))))) {
|
|
3784
|
+
backend_fail(node, "native memory calls require word arguments");
|
|
3785
|
+
}
|
|
3786
|
+
memory_validate_node(((((children) ?? [])[i]) ?? null), function$, program, arities, capabilities, completed);
|
|
3787
|
+
((i = (i + 1)));
|
|
3788
|
+
}
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
if (__eliscript_truthy(completed)) {
|
|
3792
|
+
return (completed)["set"](node, true);
|
|
3793
|
+
} else {
|
|
3794
|
+
return null;
|
|
3795
|
+
}
|
|
3796
|
+
} else {
|
|
3797
|
+
return null;
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
function memory_prepare_program_core(program, fresh) {
|
|
3801
|
+
if ((!((program)["abi"] === "memory-u32"))) {
|
|
3802
|
+
backend_fail(program, "native memory emitter requires memory-u32 typed input");
|
|
3803
|
+
}
|
|
3804
|
+
{
|
|
3805
|
+
let functions = (program)["functions"];
|
|
3806
|
+
let exports = (program)["exports"];
|
|
3807
|
+
let capabilities = (__eliscript_truthy(fresh) ? prepare_fresh_host_capabilities(program) : prepare_host_capabilities(program));
|
|
3808
|
+
let table = ((program)["table"] ?? null);
|
|
3809
|
+
let declared = ((program)["indirectArities"] ?? []);
|
|
3810
|
+
let arities = [];
|
|
3811
|
+
let i = 0;
|
|
3812
|
+
if ((!__eliscript_truthy(((__eliscript_value_362) => (__eliscript_truthy(__eliscript_value_362) ? ((__eliscript_value_363) => (__eliscript_truthy(__eliscript_value_363) ? ((__eliscript_value_364) => (__eliscript_truthy(__eliscript_value_364) ? ((__eliscript_value_365) => (__eliscript_truthy(__eliscript_value_365) ? ((__eliscript_value_367) => (__eliscript_truthy(__eliscript_value_367) ? __eliscript_value_367 : Array.isArray(table)))((((declared) ?? []).length === 0)) : __eliscript_value_365))(((__eliscript_value_366) => (__eliscript_truthy(__eliscript_value_366) ? __eliscript_value_366 : Array.isArray(table)))((table === null))) : __eliscript_value_364))(Array.isArray(declared)) : __eliscript_value_363))(Array.isArray(exports)) : __eliscript_value_362))(Array.isArray(functions))))) {
|
|
3813
|
+
backend_fail(program, "invalid native memory declarations");
|
|
3814
|
+
}
|
|
3815
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
3816
|
+
{
|
|
3817
|
+
let function$ = ((((functions) ?? [])[i]) ?? null);
|
|
3818
|
+
let arity = (function$)["arity"];
|
|
3819
|
+
let locals = (function$)["locals"];
|
|
3820
|
+
let j = 0;
|
|
3821
|
+
if ((!__eliscript_truthy(((__eliscript_value_368) => (__eliscript_truthy(__eliscript_value_368) ? ((__eliscript_value_369) => (__eliscript_truthy(__eliscript_value_369) ? ((__eliscript_value_370) => (__eliscript_truthy(__eliscript_value_370) ? ((__eliscript_value_371) => (__eliscript_truthy(__eliscript_value_371) ? memory_word_type(((function$)["body"])["type"]) : __eliscript_value_371))(__eliscript_numeric_relation("<=", arity, ((locals) ?? []).length)) : __eliscript_value_370))(Array.isArray(locals)) : __eliscript_value_369))(memory_valid_index(arity, 65536)) : __eliscript_value_368))(((function$)["index"] === i))))) {
|
|
3822
|
+
backend_fail(function$, "native memory function requires a word signature");
|
|
3823
|
+
}
|
|
3824
|
+
while (__eliscript_numeric_relation("<", j, ((locals) ?? []).length)) {
|
|
3825
|
+
{
|
|
3826
|
+
let local = ((((locals) ?? [])[j]) ?? null);
|
|
3827
|
+
let type = (local)["type"];
|
|
3828
|
+
if ((!__eliscript_truthy(((__eliscript_value_372) => (__eliscript_truthy(__eliscript_value_372) ? ((__eliscript_value_373) => (__eliscript_truthy(__eliscript_value_373) ? ((__eliscript_value_375) => (__eliscript_truthy(__eliscript_value_375) ? __eliscript_value_375 : memory_word_type(type)))(__eliscript_numeric_relation(">=", j, arity)) : __eliscript_value_373))(((__eliscript_value_374) => (__eliscript_truthy(__eliscript_value_374) ? __eliscript_value_374 : (type === "f64")))(memory_word_type(type))) : __eliscript_value_372))(((local)["index"] === j))))) {
|
|
3829
|
+
backend_fail(function$, "invalid native local layout or parameter type");
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
((j = (j + 1)));
|
|
3833
|
+
}
|
|
3834
|
+
if ((!__eliscript_truthy((arities)["includes"](arity)))) {
|
|
3835
|
+
(arities)["push"](arity);
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
((i = (i + 1)));
|
|
3839
|
+
}
|
|
3840
|
+
((i = 0));
|
|
3841
|
+
while (__eliscript_numeric_relation("<", i, ((declared) ?? []).length)) {
|
|
3842
|
+
{
|
|
3843
|
+
const __eliscript_value_376 = ((((declared) ?? [])[i]) ?? null);
|
|
3844
|
+
{
|
|
3845
|
+
let arity = __eliscript_value_376;
|
|
3846
|
+
if ((!__eliscript_truthy(memory_valid_index(arity, 65536)))) {
|
|
3847
|
+
backend_fail(program, "invalid indirect signature arity");
|
|
3848
|
+
}
|
|
3849
|
+
if ((!__eliscript_truthy((arities)["includes"](arity)))) {
|
|
3850
|
+
(arities)["push"](arity);
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
((i = (i + 1)));
|
|
3855
|
+
}
|
|
3856
|
+
if (__eliscript_truthy(table)) {
|
|
3857
|
+
((i = 0));
|
|
3858
|
+
while (__eliscript_numeric_relation("<", i, ((table) ?? []).length)) {
|
|
3859
|
+
if ((!__eliscript_truthy(memory_valid_index(((((table) ?? [])[i]) ?? null), ((functions) ?? []).length)))) {
|
|
3860
|
+
backend_fail(program, "native table entry is not a declared function index");
|
|
3861
|
+
}
|
|
3862
|
+
((i = (i + 1)));
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
((i = 0));
|
|
3866
|
+
while (__eliscript_numeric_relation("<", i, ((functions) ?? []).length)) {
|
|
3867
|
+
{
|
|
3868
|
+
const __eliscript_value_377 = ((((functions) ?? [])[i]) ?? null);
|
|
3869
|
+
{
|
|
3870
|
+
let function$ = __eliscript_value_377;
|
|
3871
|
+
memory_validate_node((function$)["body"], function$, program, arities, capabilities, (__eliscript_truthy(fresh) ? new (globalThis.WeakMap)() : null));
|
|
3872
|
+
}
|
|
3873
|
+
}
|
|
3874
|
+
((i = (i + 1)));
|
|
3875
|
+
}
|
|
3876
|
+
{
|
|
3877
|
+
const __eliscript_value_378 = (functions)["slice"]();
|
|
3878
|
+
const __eliscript_value_379 = (exports)["slice"]();
|
|
3879
|
+
const __eliscript_value_380 = ((program)["aliases"] ?? []);
|
|
3880
|
+
const __eliscript_value_381 = [];
|
|
3881
|
+
{
|
|
3882
|
+
let combined = __eliscript_value_378;
|
|
3883
|
+
let public$ = __eliscript_value_379;
|
|
3884
|
+
let aliases = __eliscript_value_380;
|
|
3885
|
+
let seen = __eliscript_value_381;
|
|
3886
|
+
if ((!__eliscript_truthy(Array.isArray(aliases)))) {
|
|
3887
|
+
backend_fail(program, "invalid native aliases");
|
|
3888
|
+
}
|
|
3889
|
+
((i = 0));
|
|
3890
|
+
while (__eliscript_numeric_relation("<", i, ((public$) ?? []).length)) {
|
|
3891
|
+
if ((!__eliscript_truthy(((__eliscript_value_382) => (__eliscript_truthy(__eliscript_value_382) ? (!__eliscript_truthy((seen)["includes"](((((public$) ?? [])[i]) ?? null)))) : __eliscript_value_382))(find_function(functions, ((((public$) ?? [])[i]) ?? null)))))) {
|
|
3892
|
+
backend_fail(program, "invalid or duplicate native export");
|
|
3893
|
+
}
|
|
3894
|
+
(seen)["push"](((((public$) ?? [])[i]) ?? null));
|
|
3895
|
+
((i = (i + 1)));
|
|
3896
|
+
}
|
|
3897
|
+
((i = 0));
|
|
3898
|
+
while (__eliscript_numeric_relation("<", i, ((aliases) ?? []).length)) {
|
|
3899
|
+
{
|
|
3900
|
+
let alias = ((((aliases) ?? [])[i]) ?? null);
|
|
3901
|
+
let name = (alias)["name"];
|
|
3902
|
+
let target = find_function(functions, (alias)["function"]);
|
|
3903
|
+
if ((!__eliscript_truthy(((__eliscript_value_383) => (__eliscript_truthy(__eliscript_value_383) ? ((((__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; } })(name) === "string") && (!__eliscript_truthy((seen)["includes"](name)))) : __eliscript_value_383))(target)))) {
|
|
3904
|
+
backend_fail(program, "invalid or duplicate native alias");
|
|
3905
|
+
}
|
|
3906
|
+
(seen)["push"](name);
|
|
3907
|
+
(public$)["push"](name);
|
|
3908
|
+
if ((name === (target)["name"])) {
|
|
3909
|
+
null;
|
|
3910
|
+
} else {
|
|
3911
|
+
if (__eliscript_truthy(find_function(functions, name))) {
|
|
3912
|
+
backend_fail(program, "native alias shadows a function");
|
|
3913
|
+
}
|
|
3914
|
+
{
|
|
3915
|
+
const __eliscript_value_384 = [];
|
|
3916
|
+
const __eliscript_value_385 = [];
|
|
3917
|
+
const __eliscript_value_386 = 0;
|
|
3918
|
+
{
|
|
3919
|
+
let locals = __eliscript_value_384;
|
|
3920
|
+
let arguments$ = __eliscript_value_385;
|
|
3921
|
+
let j = __eliscript_value_386;
|
|
3922
|
+
while (__eliscript_numeric_relation("<", j, (target)["arity"])) {
|
|
3923
|
+
(locals)["push"](({"name": (String("argument-") + String(j)), "type": "u32", "index": j}));
|
|
3924
|
+
(arguments$)["push"](({"kind": "local", "type": "u32", "value": j, "children": []}));
|
|
3925
|
+
((j = (j + 1)));
|
|
3926
|
+
}
|
|
3927
|
+
(combined)["push"](({"name": name, "index": ((combined) ?? []).length, "arity": (target)["arity"], "locals": locals, "body": ({"kind": "call", "type": "u32", "value": (target)["index"], "children": arguments$})}));
|
|
3928
|
+
}
|
|
3929
|
+
}
|
|
3930
|
+
}
|
|
3931
|
+
}
|
|
3932
|
+
((i = (i + 1)));
|
|
3933
|
+
}
|
|
3934
|
+
{
|
|
3935
|
+
const __eliscript_value_387 = ({"abi": "memory-u32", "filename": (program)["filename"], "functions": combined, "exports": public$, "table": table});
|
|
3936
|
+
{
|
|
3937
|
+
let prepared = __eliscript_value_387;
|
|
3938
|
+
if (__eliscript_numeric_relation(">", ((capabilities) ?? []).length, 0)) {
|
|
3939
|
+
((prepared)["hostCapabilities"] = capabilities);
|
|
3940
|
+
}
|
|
3941
|
+
return prepared;
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
function memory_prepare_program(program) {
|
|
3949
|
+
return memory_prepare_program_core(program, null);
|
|
3950
|
+
}
|
|
3951
|
+
function memory_prepare_fresh_program(program) {
|
|
3952
|
+
return memory_prepare_program_core(program, true);
|
|
3953
|
+
}
|
|
3954
|
+
function memory_indirect_target(state, node) {
|
|
3955
|
+
word(state, 704709612);
|
|
3956
|
+
memory_integer_register(state, 0, (((state)["table"]) ?? []).length);
|
|
3957
|
+
word(state, 1795162527);
|
|
3958
|
+
memory_conditional_error(state, 1409286147, 3);
|
|
3959
|
+
{
|
|
3960
|
+
const __eliscript_value_388 = (((state)["words"]) ?? []).length;
|
|
3961
|
+
{
|
|
3962
|
+
let at = __eliscript_value_388;
|
|
3963
|
+
word(state, 268435465);
|
|
3964
|
+
((state)["tableUses"])["push"](at);
|
|
3965
|
+
integer_register(state, 10, 0, 0);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
word(state, 2332688681);
|
|
3969
|
+
word(state, 2332822825);
|
|
3970
|
+
word(state, 3107980586);
|
|
3971
|
+
memory_integer_register(state, 11, (node)["value"]);
|
|
3972
|
+
word(state, 1795883359);
|
|
3973
|
+
memory_conditional_error(state, 1409286144, 4);
|
|
3974
|
+
word(state, 3112173866);
|
|
3975
|
+
return word(state, 2332688688);
|
|
3976
|
+
}
|
|
3977
|
+
function memory_finish_table(state, program, offsets) {
|
|
3978
|
+
{
|
|
3979
|
+
const __eliscript_value_389 = (state)["table"];
|
|
3980
|
+
const __eliscript_value_390 = (state)["tableUses"];
|
|
3981
|
+
const __eliscript_value_391 = 0;
|
|
3982
|
+
{
|
|
3983
|
+
let table = __eliscript_value_389;
|
|
3984
|
+
let uses = __eliscript_value_390;
|
|
3985
|
+
let i = __eliscript_value_391;
|
|
3986
|
+
if (__eliscript_truthy(table)) {
|
|
3987
|
+
if (((__eliscript_value_392, __eliscript_value_393) => (__eliscript_value_392 !== __eliscript_value_393))(__eliscript_numeric_and((((state)["words"]) ?? []).length, 1), 0)) {
|
|
3988
|
+
word(state, 3573751839);
|
|
3989
|
+
}
|
|
3990
|
+
{
|
|
3991
|
+
const __eliscript_value_394 = (((state)["words"]) ?? []).length;
|
|
3992
|
+
{
|
|
3993
|
+
let start = __eliscript_value_394;
|
|
3994
|
+
while (__eliscript_numeric_relation("<", i, ((table) ?? []).length)) {
|
|
3995
|
+
{
|
|
3996
|
+
let target = ((((table) ?? [])[i]) ?? null);
|
|
3997
|
+
let distance = __eliscript_numeric_sub(((((offsets) ?? [])[target]) ?? null), __eliscript_numeric_mul((((state)["words"]) ?? []).length, 4));
|
|
3998
|
+
if ((!(__eliscript_numeric_relation(">=", distance, -2147483648) && __eliscript_numeric_relation("<", distance, 2147483648)))) {
|
|
3999
|
+
backend_fail(program, "native table target exceeds relative range");
|
|
4000
|
+
}
|
|
4001
|
+
word(state, distance);
|
|
4002
|
+
word(state, ((((((program)["functions"]) ?? [])[target]) ?? null))["arity"]);
|
|
4003
|
+
}
|
|
4004
|
+
((i = (i + 1)));
|
|
4005
|
+
}
|
|
4006
|
+
((i = 0));
|
|
4007
|
+
while (__eliscript_numeric_relation("<", i, ((uses) ?? []).length)) {
|
|
4008
|
+
{
|
|
4009
|
+
let at = ((((uses) ?? [])[i]) ?? null);
|
|
4010
|
+
let distance = __eliscript_numeric_mul(__eliscript_numeric_sub(start, at), 4);
|
|
4011
|
+
if ((!__eliscript_truthy(memory_valid_index(distance, 4294967296)))) {
|
|
4012
|
+
backend_fail(program, "native table exceeds relative range");
|
|
4013
|
+
}
|
|
4014
|
+
native_word_set((state)["words"], (at + 1), (3531603978 + __eliscript_numeric_mul(__eliscript_numeric_and(distance, 65535), 32)));
|
|
4015
|
+
native_word_set((state)["words"], (at + 2), (4070572042 + __eliscript_numeric_mul(__eliscript_numeric_ushr(distance, 16), 32)));
|
|
4016
|
+
}
|
|
4017
|
+
((i = (i + 1)));
|
|
4018
|
+
}
|
|
4019
|
+
return null;
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
} else {
|
|
4023
|
+
return null;
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
function emit_observed_typed_native_memory_object(program, target, options, observer, fresh = null) {
|
|
4029
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
4030
|
+
backend_fail(program, "native memory target must be explicit arm64-macos or arm64-linux");
|
|
4031
|
+
}
|
|
4032
|
+
{
|
|
4033
|
+
let prepared = native_memory_prepare(program, observer, fresh);
|
|
4034
|
+
let code = memory_code(prepared, target, ({"packedWords": true}), observer);
|
|
4035
|
+
return native_memory_container(prepared, code, target, "object", options, observer);
|
|
4036
|
+
}
|
|
4037
|
+
}
|
|
4038
|
+
function emit_observed_typed_native_memory_library(program, target, options, observer, fresh = null) {
|
|
4039
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
4040
|
+
backend_fail(program, "native memory target must be explicit arm64-macos or arm64-linux");
|
|
4041
|
+
}
|
|
4042
|
+
{
|
|
4043
|
+
let prepared = native_memory_prepare(program, observer, fresh);
|
|
4044
|
+
let code = memory_code(prepared, target, ({"packedWords": true}), observer);
|
|
4045
|
+
return native_memory_container(prepared, code, target, "library", options, observer);
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
function emit_observed_typed_native_memory_artifact(program, target, options, observer, fresh = null) {
|
|
4049
|
+
if ((!((target === "arm64-macos") || (target === "arm64-linux")))) {
|
|
4050
|
+
backend_fail(program, "native memory target must be explicit arm64-macos or arm64-linux");
|
|
4051
|
+
}
|
|
4052
|
+
{
|
|
4053
|
+
let format = ((((__eliscript_value_395) => (__eliscript_truthy(__eliscript_value_395) ? __eliscript_value_395 : ({})))(options))["format"] ?? "library");
|
|
4054
|
+
let prepared = native_memory_prepare(program, observer, fresh);
|
|
4055
|
+
let code = memory_code(prepared, target, ({"debug": true, "packedWords": true}), observer);
|
|
4056
|
+
let bytes = null;
|
|
4057
|
+
let functions = [];
|
|
4058
|
+
let ranges = (code)["debugRanges"];
|
|
4059
|
+
let i = 0;
|
|
4060
|
+
if ((!((format === "object") || (format === "library")))) {
|
|
4061
|
+
backend_fail(program, "native memory artifact format must be object or library");
|
|
4062
|
+
}
|
|
4063
|
+
((bytes = native_memory_container(prepared, code, target, format, options, observer)));
|
|
4064
|
+
while (__eliscript_numeric_relation("<", i, ((ranges) ?? []).length)) {
|
|
4065
|
+
{
|
|
4066
|
+
const __eliscript_value_396 = ((((ranges) ?? [])[i]) ?? null);
|
|
4067
|
+
{
|
|
4068
|
+
let range = __eliscript_value_396;
|
|
4069
|
+
if (((range)["kind"] === "function")) {
|
|
4070
|
+
(functions)["push"](({"name": (range)["function"], "index": (range)["functionIndex"], "start": (range)["start"], "end": (range)["end"], "span": (range)["span"]}));
|
|
4071
|
+
}
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
((i = (i + 1)));
|
|
4075
|
+
}
|
|
4076
|
+
return ({"bytes": bytes, "debug": ({"format": "eliscript-native-source-map", "version": 1, "target": target, "abi": "memory-u32", "imageFormat": ((target === "arm64-linux") ? "elf64" : "mach-o64"), "artifactFormat": format, "offsetUnit": "byte", "offsetBase": "code-section", "relocatable": true, "trapSites": (((code)["trapSites"] ?? []))["map"](((site) => {
|
|
4077
|
+
return ({"site": (site)["site"], "address": (site)["start"], "offsetBase": "code-section", "functionIndex": (site)["functionIndex"], "returnAddress": false, "code": (site)["code"]});
|
|
4078
|
+
})), "codeSection": (code)["section"], "functions": functions, "ranges": ranges})});
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
4081
|
+
function emit_typed_native_memory_object(program, target, options = null) {
|
|
4082
|
+
return emit_observed_typed_native_memory_object(program, target, options, null);
|
|
4083
|
+
}
|
|
4084
|
+
function emit_typed_native_memory_library(program, target, options = null) {
|
|
4085
|
+
return emit_observed_typed_native_memory_library(program, target, options, null);
|
|
4086
|
+
}
|
|
4087
|
+
function emit_typed_native_memory_artifact(program, target, options = null) {
|
|
4088
|
+
return emit_observed_typed_native_memory_artifact(program, target, options, null);
|
|
4089
|
+
}
|
|
4090
|
+
function emit_fresh_observed_typed_native_memory_object(program, target, options, observer) {
|
|
4091
|
+
return emit_observed_typed_native_memory_object(program, target, options, observer, true);
|
|
4092
|
+
}
|
|
4093
|
+
function emit_fresh_observed_typed_native_memory_library(program, target, options, observer) {
|
|
4094
|
+
return emit_observed_typed_native_memory_library(program, target, options, observer, true);
|
|
4095
|
+
}
|
|
4096
|
+
function emit_fresh_observed_typed_native_memory_artifact(program, target, options, observer) {
|
|
4097
|
+
return emit_observed_typed_native_memory_artifact(program, target, options, observer, true);
|
|
4098
|
+
}
|
|
4099
|
+
export {emit_typed_native_memory_artifact, emit_typed_native_memory_object, emit_typed_native_memory_library, emit_native_memory_object, emit_native_memory_library, emit_native_numeric_object, emit_native_numeric_library, emit_native_numeric_executable, emit_observed_typed_native_memory_object, emit_observed_typed_native_memory_library, emit_observed_typed_native_memory_artifact, emit_fresh_observed_typed_native_memory_object, emit_fresh_observed_typed_native_memory_library, emit_fresh_observed_typed_native_memory_artifact};
|