eliscript 0.0.1 → 0.0.3
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 +61 -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.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 +732 -11
- package/browser/worker.mjs +6 -3
- 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 +1078 -0
- package/dist/browser/loader.js +1 -0
- package/dist/browser/loader.mjs +231 -0
- package/dist/browser/worker.mjs +63 -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 +639 -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 +40 -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 +25 -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 +494 -0
- package/dist/literal-sources/stdlib/managed-literals.eli +1469 -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 +106 -11
- 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 +172 -72
- package/stdlib/gepo.eli +12 -0
- package/stdlib/interop/js.eli +56 -15
- package/stdlib/managed-literal-protocols.eli +494 -0
- package/stdlib/managed-literals.eli +1469 -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 +639 -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 +40 -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 +25 -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 +462 -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 +493 -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
|
@@ -1,1469 +1,3123 @@
|
|
|
1
1
|
// Generated by Eliscript. Do not edit.
|
|
2
|
+
import { tdz as __eliscript_tdz_error, immutable as __eliscript_const_error } from "data:text/javascript;base64,Y29uc3QgRSA9IFJlZmVyZW5jZUVycm9yOyBjb25zdCBUID0gVHlwZUVycm9yOyBleHBvcnQgZnVuY3Rpb24gdGR6KG5hbWUpIHsgdGhyb3cgbmV3IEUoIkNhbm5vdCBhY2Nlc3MgJyIgKyBuYW1lICsgIicgYmVmb3JlIGluaXRpYWxpemF0aW9uIik7IH0gZXhwb3J0IGZ1bmN0aW9uIGltbXV0YWJsZSgpIHsgdGhyb3cgbmV3IFQoIkFzc2lnbm1lbnQgdG8gY29uc3RhbnQgdmFyaWFibGUuIik7IH0K";
|
|
3
|
+
var __eliscript_tdz_ready_0;
|
|
4
|
+
function __eliscript_tdz_read_0() { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("maximum_depth"); return maximum_depth; }
|
|
5
|
+
function __eliscript_tdz_write_0(__eliscript_tdz_value_0) { if (__eliscript_tdz_ready_0 !== true) __eliscript_tdz_error("maximum_depth"); return __eliscript_const_error(); }
|
|
6
|
+
var __eliscript_tdz_ready_1;
|
|
7
|
+
function __eliscript_tdz_read_1() { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("gensym_prefix_pattern"); return gensym_prefix_pattern; }
|
|
8
|
+
function __eliscript_tdz_write_1(__eliscript_tdz_value_1) { if (__eliscript_tdz_ready_1 !== true) __eliscript_tdz_error("gensym_prefix_pattern"); return __eliscript_const_error(); }
|
|
9
|
+
var __eliscript_tdz_ready_2;
|
|
10
|
+
function __eliscript_tdz_read_2() { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("raise_error"); return raise_error; }
|
|
11
|
+
function __eliscript_tdz_write_2(__eliscript_tdz_value_2) { if (__eliscript_tdz_ready_2 !== true) __eliscript_tdz_error("raise_error"); return __eliscript_const_error(); }
|
|
12
|
+
var __eliscript_tdz_ready_3;
|
|
13
|
+
function __eliscript_tdz_read_3() { if (__eliscript_tdz_ready_3 !== true) __eliscript_tdz_error("raise_diagnostic"); return raise_diagnostic; }
|
|
14
|
+
function __eliscript_tdz_write_3(__eliscript_tdz_value_3) { if (__eliscript_tdz_ready_3 !== true) __eliscript_tdz_error("raise_diagnostic"); return __eliscript_const_error(); }
|
|
15
|
+
var __eliscript_tdz_ready_4;
|
|
16
|
+
function __eliscript_tdz_read_4() { if (__eliscript_tdz_ready_4 !== true) __eliscript_tdz_error("guard"); return guard; }
|
|
17
|
+
function __eliscript_tdz_write_4(__eliscript_tdz_value_4) { if (__eliscript_tdz_ready_4 !== true) __eliscript_tdz_error("guard"); return __eliscript_const_error(); }
|
|
18
|
+
import "eliscript/runtime/unicode-case.mjs";
|
|
19
|
+
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=";
|
|
2
20
|
const __eliscript_truthy = (value) => value !== false && value != null;
|
|
21
|
+
const __eliscript_number_intrinsic = globalThis.Number;
|
|
22
|
+
const __eliscript_bigint_intrinsic = globalThis.BigInt;
|
|
23
|
+
const __eliscript_numeric_apply = globalThis.Reflect.apply;
|
|
24
|
+
const __eliscript_numeric_symbol = globalThis.Symbol.toPrimitive;
|
|
25
|
+
const __eliscript_numeric_error = globalThis.TypeError;
|
|
26
|
+
const __eliscript_numeric_trim = globalThis.String.prototype.trim;
|
|
27
|
+
const __eliscript_numeric_slice = globalThis.String.prototype.slice;
|
|
28
|
+
const __eliscript_numeric_exec = globalThis.RegExp.prototype.exec;
|
|
29
|
+
const __eliscript_numeric_radix = /^(?:0[xX][0-9a-fA-F]+|0[oO][0-7]+|0[bB][01]+)$/;
|
|
30
|
+
const __eliscript_numeric_object = (value) => value !== null && (typeof value === "object" || typeof value === "function" || (typeof value === "undefined" && value !== void 0));
|
|
31
|
+
const __eliscript_numeric_primitive = (value) => {
|
|
32
|
+
if (!__eliscript_numeric_object(value)) return value;
|
|
33
|
+
const exotic = value[__eliscript_numeric_symbol];
|
|
34
|
+
if (exotic !== void 0 && exotic !== null) {
|
|
35
|
+
const result = __eliscript_numeric_apply(exotic, value, ["number"]);
|
|
36
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
37
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
38
|
+
}
|
|
39
|
+
for (let index = 0; index < 2; index++) {
|
|
40
|
+
const method = value[index === 0 ? "valueOf" : "toString"];
|
|
41
|
+
if (typeof method === "function" || (typeof method === "undefined" && method !== void 0)) {
|
|
42
|
+
const result = __eliscript_numeric_apply(method, value, []);
|
|
43
|
+
if (!__eliscript_numeric_object(result)) return result;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
throw new __eliscript_numeric_error("Cannot convert object to primitive value");
|
|
47
|
+
};
|
|
48
|
+
const __eliscript_to_number = (value) => {
|
|
49
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
50
|
+
if (typeof primitive === "string") {
|
|
51
|
+
const text = __eliscript_numeric_apply(__eliscript_numeric_trim, primitive, []);
|
|
52
|
+
if (__eliscript_numeric_apply(__eliscript_numeric_exec, __eliscript_numeric_radix, [text]) !== null) {
|
|
53
|
+
let first = 2;
|
|
54
|
+
while (first < text.length && text[first] === "0") first++;
|
|
55
|
+
if (first === text.length) return 0;
|
|
56
|
+
const prefix = text[1];
|
|
57
|
+
const limit = prefix === "x" || prefix === "X" ? 256 : prefix === "b" || prefix === "B" ? 1024 : 342;
|
|
58
|
+
if (text.length - first > limit) return 1 / 0;
|
|
59
|
+
const token = __eliscript_numeric_apply(__eliscript_numeric_slice, text, [0, 2]) + __eliscript_numeric_apply(__eliscript_numeric_slice, text, [first]);
|
|
60
|
+
return __eliscript_number_intrinsic(__eliscript_bigint_intrinsic(token));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return __eliscript_number_intrinsic(primitive);
|
|
64
|
+
};
|
|
65
|
+
const __eliscript_numeric = (value) => {
|
|
66
|
+
if (typeof value === "number" || typeof value === "bigint") return value;
|
|
67
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
68
|
+
if (typeof primitive === "number" || typeof primitive === "bigint") return primitive;
|
|
69
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
70
|
+
};
|
|
71
|
+
const __eliscript_implicit_number = (value) => {
|
|
72
|
+
if (typeof value === "number") return value;
|
|
73
|
+
const primitive = __eliscript_numeric_primitive(value);
|
|
74
|
+
if (typeof primitive === "bigint") throw new __eliscript_numeric_error("Cannot convert a BigInt value to a number");
|
|
75
|
+
return typeof primitive === "string" ? __eliscript_to_number(primitive) : +primitive;
|
|
76
|
+
};
|
|
77
|
+
const __eliscript_numeric_decrement = (value) => __eliscript_implicit_number(value) - 1;
|
|
78
|
+
const __eliscript_numeric_sub = (a, b) => { if (typeof a === "number" && typeof b === "number") return a - b; return __eliscript_numeric(a) - __eliscript_numeric(b); };
|
|
79
|
+
const __eliscript_numeric_mul = (a, b) => { if (typeof a === "number" && typeof b === "number") return a * b; return __eliscript_numeric(a) * __eliscript_numeric(b); };
|
|
80
|
+
const __eliscript_numeric_div = (a, b) => { if (typeof a === "number" && typeof b === "number") return a / b; return __eliscript_numeric(a) / __eliscript_numeric(b); };
|
|
81
|
+
const __eliscript_numeric_rem = (a, b) => { if (typeof a === "number" && typeof b === "number") return a % b; return __eliscript_numeric(a) % __eliscript_numeric(b); };
|
|
82
|
+
const __eliscript_numeric_and = (a, b) => { if (typeof a === "number" && typeof b === "number") return a & b; return __eliscript_numeric(a) & __eliscript_numeric(b); };
|
|
83
|
+
const __eliscript_numeric_or = (a, b) => { if (typeof a === "number" && typeof b === "number") return a | b; return __eliscript_numeric(a) | __eliscript_numeric(b); };
|
|
84
|
+
const __eliscript_numeric_xor = (a, b) => { if (typeof a === "number" && typeof b === "number") return a ^ b; return __eliscript_numeric(a) ^ __eliscript_numeric(b); };
|
|
85
|
+
const __eliscript_numeric_shl = (a, b) => { if (typeof a === "number" && typeof b === "number") return a << b; return __eliscript_numeric(a) << __eliscript_numeric(b); };
|
|
86
|
+
const __eliscript_numeric_shr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >> b; return __eliscript_numeric(a) >> __eliscript_numeric(b); };
|
|
87
|
+
const __eliscript_numeric_ushr = (a, b) => { if (typeof a === "number" && typeof b === "number") return a >>> b; return __eliscript_numeric(a) >>> __eliscript_numeric(b); };
|
|
88
|
+
const __eliscript_numeric_neg = (a) => typeof a === "number" ? -a : -__eliscript_numeric(a);
|
|
89
|
+
const __eliscript_numeric_int32 = (a) => typeof a === "number" ? a | 0 : __eliscript_numeric(a) | 0;
|
|
90
|
+
const __eliscript_numeric_uint32 = (a) => typeof a === "number" ? a >>> 0 : __eliscript_numeric(a) >>> 0;
|
|
91
|
+
const __eliscript_numeric_not = (a) => typeof a === "number" ? ~a : ~__eliscript_numeric(a);
|
|
92
|
+
const __eliscript_numeric_relation = (operator, left, right) => {
|
|
93
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
94
|
+
if (operator === "<") return left < right;
|
|
95
|
+
if (operator === "<=") return left <= right;
|
|
96
|
+
if (operator === ">") return left > right;
|
|
97
|
+
return left >= right;
|
|
98
|
+
}
|
|
99
|
+
let a = __eliscript_numeric_primitive(left);
|
|
100
|
+
let b = __eliscript_numeric_primitive(right);
|
|
101
|
+
const x = typeof a, y = typeof b;
|
|
102
|
+
if (!((x === "string" && y === "string") || (x === "bigint" && y === "string") || (x === "string" && y === "bigint"))) {
|
|
103
|
+
a = __eliscript_numeric(a);
|
|
104
|
+
b = __eliscript_numeric(b);
|
|
105
|
+
}
|
|
106
|
+
if (operator === "<") return a < b;
|
|
107
|
+
if (operator === "<=") return a <= b;
|
|
108
|
+
if (operator === ">") return a > b;
|
|
109
|
+
return a >= b;
|
|
110
|
+
};
|
|
3
111
|
|
|
4
112
|
import {literal_node, undefined_node, symbol_node, keyword_node, collection_node, node_kind, node_span, node_value, node_name, node_items} from "./syntax.mjs";
|
|
5
113
|
const maximum_depth = 100;
|
|
114
|
+
__eliscript_tdz_ready_0 = true;
|
|
6
115
|
const gensym_prefix_pattern = /^[A-Za-z_$][A-Za-z0-9_$?!*+=<>-]*$/;
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
116
|
+
__eliscript_tdz_ready_1 = true;
|
|
117
|
+
const raise_error = ((message) => {
|
|
118
|
+
return ((__eliscript_value_1) => { throw __eliscript_value_1; })(new (Error)(message));
|
|
119
|
+
});
|
|
120
|
+
__eliscript_tdz_ready_2 = true;
|
|
121
|
+
const raise_diagnostic = ((diagnostic) => {
|
|
122
|
+
{
|
|
123
|
+
const __eliscript_value_2 = ((diagnostic)["location"])["start"];
|
|
124
|
+
{
|
|
125
|
+
let p = __eliscript_value_2;
|
|
126
|
+
{
|
|
127
|
+
const __eliscript_value_3 = new (Error)(((file_value) => {
|
|
128
|
+
return ((file) => {
|
|
129
|
+
return ((line_value) => {
|
|
130
|
+
return ((line) => {
|
|
131
|
+
return ((column_value) => {
|
|
132
|
+
return ((column) => {
|
|
133
|
+
return ((message_value) => {
|
|
134
|
+
return ((message) => {
|
|
135
|
+
return (file + ":" + line + ":" + column + ": " + message);
|
|
136
|
+
})(`${message_value}`);
|
|
137
|
+
})((diagnostic)["message"]);
|
|
138
|
+
})(`${column_value}`);
|
|
139
|
+
})((p)["column"]);
|
|
140
|
+
})(`${line_value}`);
|
|
141
|
+
})((p)["line"]);
|
|
142
|
+
})(`${file_value}`);
|
|
143
|
+
})(((diagnostic)["location"])["file"]));
|
|
144
|
+
{
|
|
145
|
+
let error = __eliscript_value_3;
|
|
146
|
+
((error)["eliscriptDiagnostic"] = diagnostic);
|
|
147
|
+
return ((__eliscript_value_4) => { throw __eliscript_value_4; })(error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
__eliscript_tdz_ready_3 = true;
|
|
154
|
+
const guard = ((operation, onError) => {
|
|
155
|
+
return (() => {
|
|
156
|
+
try {
|
|
157
|
+
return operation();
|
|
158
|
+
} catch (error) {
|
|
159
|
+
return onError((error)["message"]);
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
});
|
|
163
|
+
__eliscript_tdz_ready_4 = true;
|
|
10
164
|
function expander_fail(context, span, message) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
165
|
+
{
|
|
166
|
+
const __eliscript_value_5 = ((__eliscript_value_6) => (__eliscript_truthy(__eliscript_value_6) ? __eliscript_value_6 : ((__eliscript_value_7) => (__eliscript_truthy(__eliscript_value_7) ? __eliscript_value_7 : "<input>"))(((__eliscript_value_8) => (__eliscript_truthy(__eliscript_value_8) ? (span)["filename"] : __eliscript_value_8))(span))))((context)["filename"]);
|
|
167
|
+
{
|
|
168
|
+
let file = __eliscript_value_5;
|
|
169
|
+
return (__eliscript_tdz_read_3())(({"format": "eliscript-diagnostic", "version": 1, "code": "ELI-X0001", "severity": "error", "phase": "expansion", "message": message, "location": ({"file": file, "start": ({"offset": (__eliscript_truthy(span) ? (span)["start"] : 0), "line": (__eliscript_truthy(span) ? (span)["line"] : 1), "column": (__eliscript_truthy(span) ? (span)["column"] : 1)}), "end": ({"offset": (__eliscript_truthy(span) ? (span)["end"] : 0), "line": (__eliscript_truthy(span) ? (span)["endLine"] : 1), "column": (__eliscript_truthy(span) ? (span)["endColumn"] : 1)})})}));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
14
172
|
}
|
|
15
173
|
function symbol_node_p(node) {
|
|
16
|
-
return ((
|
|
174
|
+
return ((__eliscript_value_9) => (__eliscript_truthy(__eliscript_value_9) ? (node_kind(node) === "symbol") : __eliscript_value_9))(node);
|
|
17
175
|
}
|
|
18
176
|
function keyword_node_p(node) {
|
|
19
|
-
return ((
|
|
177
|
+
return ((__eliscript_value_10) => (__eliscript_truthy(__eliscript_value_10) ? (node_kind(node) === "keyword") : __eliscript_value_10))(node);
|
|
20
178
|
}
|
|
21
179
|
function literal_node_p(node) {
|
|
22
|
-
return ((
|
|
180
|
+
return ((__eliscript_value_11) => (__eliscript_truthy(__eliscript_value_11) ? (node_kind(node) === "literal") : __eliscript_value_11))(node);
|
|
23
181
|
}
|
|
24
182
|
function null_node_p(node) {
|
|
25
|
-
return ((
|
|
183
|
+
return ((__eliscript_value_12) => (__eliscript_truthy(__eliscript_value_12) ? (node_value(node) == null) : __eliscript_value_12))(literal_node_p(node));
|
|
26
184
|
}
|
|
27
185
|
function list_node_p(node) {
|
|
28
|
-
return ((
|
|
186
|
+
return ((__eliscript_value_13) => (__eliscript_truthy(__eliscript_value_13) ? __eliscript_value_13 : ((__eliscript_value_14) => (__eliscript_truthy(__eliscript_value_14) ? (node_kind(node) === "list") : __eliscript_value_14))(node)))(null_node_p(node));
|
|
29
187
|
}
|
|
30
188
|
function vector_node_p(node) {
|
|
31
|
-
return ((
|
|
189
|
+
return ((__eliscript_value_15) => (__eliscript_truthy(__eliscript_value_15) ? (node_kind(node) === "vector") : __eliscript_value_15))(node);
|
|
32
190
|
}
|
|
33
191
|
function map_node_p(node) {
|
|
34
|
-
return ((
|
|
192
|
+
return ((__eliscript_value_16) => (__eliscript_truthy(__eliscript_value_16) ? ((__eliscript_value_17) => (__eliscript_truthy(__eliscript_value_17) ? ((__eliscript_value_18) => (__eliscript_truthy(__eliscript_value_18) ? ((__eliscript_value_19) => (__eliscript_truthy(__eliscript_value_19) ? (node_name(((((node_items(node)) ?? [])[0]) ?? null)) === "hash-map") : __eliscript_value_19))(symbol_node_p(((((node_items(node)) ?? [])[0]) ?? null))) : __eliscript_value_18))(__eliscript_numeric_relation(">", (node_items(node))["length"], 0)) : __eliscript_value_17))((node_kind(node) === "list")) : __eliscript_value_16))(node);
|
|
35
193
|
}
|
|
36
194
|
function list_items(node) {
|
|
37
|
-
|
|
195
|
+
if (__eliscript_truthy(null_node_p(node))) {
|
|
196
|
+
return [];
|
|
197
|
+
} else {
|
|
198
|
+
if (__eliscript_truthy(((__eliscript_value_20) => (__eliscript_truthy(__eliscript_value_20) ? (node_kind(node) === "list") : __eliscript_value_20))(node))) {
|
|
199
|
+
return node_items(node);
|
|
200
|
+
} else {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
38
204
|
}
|
|
39
205
|
function sequence_items(node) {
|
|
40
|
-
|
|
206
|
+
if (__eliscript_truthy(null_node_p(node))) {
|
|
207
|
+
return [];
|
|
208
|
+
} else {
|
|
209
|
+
if (__eliscript_truthy(((__eliscript_value_21) => (__eliscript_truthy(__eliscript_value_21) ? __eliscript_value_21 : ((__eliscript_value_23) => (__eliscript_truthy(__eliscript_value_23) ? (node_kind(node) === "vector") : __eliscript_value_23))(node)))(((__eliscript_value_22) => (__eliscript_truthy(__eliscript_value_22) ? (node_kind(node) === "list") : __eliscript_value_22))(node)))) {
|
|
210
|
+
return node_items(node);
|
|
211
|
+
} else {
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
41
215
|
}
|
|
42
216
|
function make_list(items, span) {
|
|
43
|
-
|
|
217
|
+
if (((items)["length"] === 0)) {
|
|
218
|
+
return literal_node(null, span);
|
|
219
|
+
} else {
|
|
220
|
+
return collection_node("list", items, span);
|
|
221
|
+
}
|
|
44
222
|
}
|
|
45
223
|
function rebuild_collection(source, items) {
|
|
46
|
-
|
|
224
|
+
if ((node_kind(source) === "list")) {
|
|
225
|
+
return make_list(items, node_span(source));
|
|
226
|
+
} else {
|
|
227
|
+
return collection_node(node_kind(source), items, node_span(source));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function expand_same_items_p(left, right) {
|
|
231
|
+
{
|
|
232
|
+
const __eliscript_value_24 = 0;
|
|
233
|
+
const __eliscript_value_25 = ((left)["length"] === (right)["length"]);
|
|
234
|
+
{
|
|
235
|
+
let index = __eliscript_value_24;
|
|
236
|
+
let same = __eliscript_value_25;
|
|
237
|
+
while (__eliscript_truthy(((__eliscript_value_26) => (__eliscript_truthy(__eliscript_value_26) ? __eliscript_numeric_relation("<", index, (left)["length"]) : __eliscript_value_26))(same))) {
|
|
238
|
+
if ((!(((((left) ?? [])[index]) ?? null) === ((((right) ?? [])[index]) ?? null)))) {
|
|
239
|
+
((same = false));
|
|
240
|
+
}
|
|
241
|
+
((index = (index + 1)));
|
|
242
|
+
}
|
|
243
|
+
return same;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function expand_collection_result(kind, source, items, context) {
|
|
248
|
+
if (__eliscript_truthy(((__eliscript_value_27) => (__eliscript_truthy(__eliscript_value_27) ? ((__eliscript_value_28) => (__eliscript_truthy(__eliscript_value_28) ? expand_same_items_p(node_items(source), items) : __eliscript_value_28))((node_kind(source) === kind)) : __eliscript_value_27))(((context)["ownedForms"] ?? false)))) {
|
|
249
|
+
return source;
|
|
250
|
+
} else {
|
|
251
|
+
if ((kind === "list")) {
|
|
252
|
+
return make_list(items, node_span(source));
|
|
253
|
+
} else {
|
|
254
|
+
return collection_node(kind, items, node_span(source));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
47
257
|
}
|
|
48
258
|
function locate_generated(node, span) {
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
259
|
+
if ((node_kind(node) === "literal")) {
|
|
260
|
+
return literal_node(node_value(node), span);
|
|
261
|
+
} else {
|
|
262
|
+
if ((node_kind(node) === "undefined")) {
|
|
263
|
+
return undefined_node(span);
|
|
264
|
+
} else {
|
|
265
|
+
if ((node_kind(node) === "symbol")) {
|
|
266
|
+
return symbol_node(node_name(node), span);
|
|
267
|
+
} else {
|
|
268
|
+
if ((node_kind(node) === "keyword")) {
|
|
269
|
+
return keyword_node(node_name(node), span);
|
|
270
|
+
} else {
|
|
271
|
+
if (((node_kind(node) === "list") || (node_kind(node) === "vector"))) {
|
|
272
|
+
{
|
|
273
|
+
const __eliscript_value_29 = [];
|
|
274
|
+
{
|
|
275
|
+
let items = __eliscript_value_29;
|
|
276
|
+
(node_items(node))["forEach"](((item) => {
|
|
277
|
+
return (items)["push"](locate_generated(item, span));
|
|
278
|
+
}));
|
|
279
|
+
if ((node_kind(node) === "list")) {
|
|
280
|
+
return make_list(items, span);
|
|
281
|
+
} else {
|
|
282
|
+
return collection_node("vector", items, span);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
} else {
|
|
287
|
+
return (__eliscript_tdz_read_2())("macro produced an unsupported value");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
55
293
|
}
|
|
56
294
|
function node_display(node) {
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
295
|
+
if ((!__eliscript_truthy(node))) {
|
|
296
|
+
return "nil";
|
|
297
|
+
} else {
|
|
298
|
+
if ((node_kind(node) === "undefined")) {
|
|
299
|
+
return "undefined";
|
|
300
|
+
} else {
|
|
301
|
+
if ((node_kind(node) === "symbol")) {
|
|
302
|
+
return node_name(node);
|
|
303
|
+
} else {
|
|
304
|
+
if ((node_kind(node) === "keyword")) {
|
|
305
|
+
return (String(":") + String(node_name(node)));
|
|
306
|
+
} else {
|
|
307
|
+
if ((node_kind(node) === "literal")) {
|
|
308
|
+
{
|
|
309
|
+
const __eliscript_value_30 = node_value(node);
|
|
310
|
+
{
|
|
311
|
+
let value = __eliscript_value_30;
|
|
312
|
+
if ((value == null)) {
|
|
313
|
+
return "nil";
|
|
314
|
+
} else {
|
|
315
|
+
if ((value === true)) {
|
|
316
|
+
return "t";
|
|
317
|
+
} else {
|
|
318
|
+
if ((value === false)) {
|
|
319
|
+
return "false";
|
|
320
|
+
} else {
|
|
321
|
+
if ((typeof value === "string")) {
|
|
322
|
+
return (JSON)["stringify"](value);
|
|
323
|
+
} else {
|
|
324
|
+
return (String(value));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
if (((node_kind(node) === "list") || (node_kind(node) === "vector"))) {
|
|
333
|
+
{
|
|
334
|
+
let items = node_items(node);
|
|
335
|
+
let contents = __eliscript_at_direct((items)["map"](node_display), "join", " ");
|
|
336
|
+
if (__eliscript_truthy(((__eliscript_value_31) => (__eliscript_truthy(__eliscript_value_31) ? ((__eliscript_value_32) => (__eliscript_truthy(__eliscript_value_32) ? ((__eliscript_value_33) => (__eliscript_truthy(__eliscript_value_33) ? (node_name(((((items) ?? [])[0]) ?? null)) === "quote") : __eliscript_value_33))(symbol_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_32))(((items)["length"] === 2)) : __eliscript_value_31))((node_kind(node) === "list")))) {
|
|
337
|
+
return (String("'") + String(node_display(((((items) ?? [])[1]) ?? null))));
|
|
338
|
+
} else {
|
|
339
|
+
if ((node_kind(node) === "list")) {
|
|
340
|
+
return (String("(") + String(contents) + String(")"));
|
|
341
|
+
} else {
|
|
342
|
+
return (String("[") + String(contents) + String("]"));
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
return "<unsupported>";
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
64
354
|
}
|
|
65
355
|
function form_operator_p(node, name) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
356
|
+
{
|
|
357
|
+
const __eliscript_value_34 = list_items(node);
|
|
358
|
+
{
|
|
359
|
+
let items = __eliscript_value_34;
|
|
360
|
+
return ((__eliscript_value_35) => (__eliscript_truthy(__eliscript_value_35) ? ((__eliscript_value_36) => (__eliscript_truthy(__eliscript_value_36) ? ((__eliscript_value_37) => (__eliscript_truthy(__eliscript_value_37) ? (node_name(((((items) ?? [])[0]) ?? null)) === name) : __eliscript_value_37))(symbol_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_36))(__eliscript_numeric_relation(">", (items)["length"], 0)) : __eliscript_value_35))((!(items === undefined)));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
69
363
|
}
|
|
70
364
|
function make_eval_scope(parent, context = null) {
|
|
71
|
-
return ({"parent": parent, "values": new Map(), "context": ((
|
|
365
|
+
return ({"parent": parent, "values": new (Map)(), "context": ((__eliscript_value_38) => (__eliscript_truthy(__eliscript_value_38) ? __eliscript_value_38 : ((__eliscript_value_39) => (__eliscript_truthy(__eliscript_value_39) ? (parent)["context"] : __eliscript_value_39))(parent)))(context)});
|
|
72
366
|
}
|
|
73
367
|
function scope_bind(scope, name, value) {
|
|
74
368
|
((scope)["values"])["set"](name, value);
|
|
75
369
|
return value;
|
|
76
370
|
}
|
|
77
371
|
function scope_find(scope, name) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
372
|
+
{
|
|
373
|
+
const __eliscript_value_40 = scope;
|
|
374
|
+
const __eliscript_value_41 = undefined;
|
|
375
|
+
{
|
|
376
|
+
let current = __eliscript_value_40;
|
|
377
|
+
let found = __eliscript_value_41;
|
|
378
|
+
while (__eliscript_truthy(((__eliscript_value_42) => (__eliscript_truthy(__eliscript_value_42) ? (found === undefined) : __eliscript_value_42))(current))) {
|
|
379
|
+
{
|
|
380
|
+
const __eliscript_value_43 = (current)["values"];
|
|
381
|
+
{
|
|
382
|
+
let values = __eliscript_value_43;
|
|
383
|
+
if (__eliscript_truthy((values)["has"](name))) {
|
|
384
|
+
((found = ({"scope": current, "value": (values)["get"](name)})));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
84
388
|
((current = (current)["parent"]));
|
|
85
389
|
}
|
|
86
|
-
return
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
})(scope, undefined);
|
|
390
|
+
return found;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
90
393
|
}
|
|
91
394
|
function scope_value(scope, name) {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
395
|
+
{
|
|
396
|
+
const __eliscript_value_44 = scope_find(scope, name);
|
|
397
|
+
{
|
|
398
|
+
let found = __eliscript_value_44;
|
|
399
|
+
if ((found === undefined)) {
|
|
400
|
+
return (__eliscript_tdz_read_2())((String("void variable: ") + String(name)));
|
|
401
|
+
} else {
|
|
402
|
+
return (found)["value"];
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
95
406
|
}
|
|
96
407
|
function scope_set(scope, name, value) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
408
|
+
{
|
|
409
|
+
const __eliscript_value_45 = scope_find(scope, name);
|
|
410
|
+
{
|
|
411
|
+
let found = __eliscript_value_45;
|
|
412
|
+
if ((found === undefined)) {
|
|
413
|
+
return (__eliscript_tdz_read_2())((String("cannot set unbound macro variable: ") + String(name)));
|
|
414
|
+
} else {
|
|
415
|
+
(((found)["scope"])["values"])["set"](name, value);
|
|
416
|
+
return value;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
103
420
|
}
|
|
104
421
|
function reserve_name(scope, name) {
|
|
105
422
|
(((scope)["context"])["reservedNames"])["add"](name);
|
|
106
423
|
return name;
|
|
107
424
|
}
|
|
108
425
|
function gensym_prefix(node) {
|
|
109
|
-
|
|
110
|
-
(__eliscript_truthy(((
|
|
111
|
-
|
|
112
|
-
|
|
426
|
+
{
|
|
427
|
+
const __eliscript_value_46 = (__eliscript_truthy(symbol_node_p(node)) ? node_name(node) : (__eliscript_truthy(((__eliscript_value_47) => (__eliscript_truthy(__eliscript_value_47) ? (typeof node.value === "string") : __eliscript_value_47))(literal_node_p(node))) ? node_value(node) : (__eliscript_tdz_read_2())("gensym prefix must be a symbol or string")));
|
|
428
|
+
{
|
|
429
|
+
let prefix = __eliscript_value_46;
|
|
430
|
+
if (__eliscript_truthy(((__eliscript_value_48) => (__eliscript_truthy(__eliscript_value_48) ? __eliscript_value_48 : (prefix)["startsWith"]("__eliscript_")))((!__eliscript_truthy(((__eliscript_tdz_read_1()))["test"](prefix)))))) {
|
|
431
|
+
(__eliscript_tdz_read_2())((String("invalid gensym prefix: ") + String(prefix)));
|
|
432
|
+
}
|
|
433
|
+
return prefix;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
113
436
|
}
|
|
114
437
|
function allocate_name(scope, prefix_node) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(reserved)["add"](candidate);
|
|
128
|
-
return symbol_node(candidate, null);
|
|
129
|
-
})();
|
|
130
|
-
})(undefined);
|
|
131
|
-
})(gensym_prefix(prefix_node));
|
|
132
|
-
})((context)["reservedNames"]);
|
|
133
|
-
})((scope)["context"]);
|
|
438
|
+
{
|
|
439
|
+
let context = (scope)["context"];
|
|
440
|
+
let reserved = (context)["reservedNames"];
|
|
441
|
+
let prefix = gensym_prefix(prefix_node);
|
|
442
|
+
let candidate = undefined;
|
|
443
|
+
while (__eliscript_truthy(((__eliscript_value_49) => (__eliscript_truthy(__eliscript_value_49) ? __eliscript_value_49 : (reserved)["has"](candidate)))((candidate === undefined)))) {
|
|
444
|
+
((context)["gensymCounter"] = ((context)["gensymCounter"] + 1));
|
|
445
|
+
((candidate = (String(prefix) + String("$G") + String((context)["gensymCounter"]))));
|
|
446
|
+
}
|
|
447
|
+
(reserved)["add"](candidate);
|
|
448
|
+
return symbol_node(candidate, null);
|
|
449
|
+
}
|
|
134
450
|
}
|
|
135
451
|
function auto_gensym(node, scope, names) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
452
|
+
{
|
|
453
|
+
const __eliscript_value_50 = node_name(node);
|
|
454
|
+
{
|
|
455
|
+
let name = __eliscript_value_50;
|
|
456
|
+
if (__eliscript_truthy((names)["has"](name))) {
|
|
457
|
+
return (names)["get"](name);
|
|
458
|
+
} else {
|
|
459
|
+
{
|
|
460
|
+
const __eliscript_value_51 = allocate_name(scope, literal_node((name)["slice"](0, -1), null));
|
|
461
|
+
{
|
|
462
|
+
let generated = __eliscript_value_51;
|
|
463
|
+
(names)["set"](name, generated);
|
|
464
|
+
return generated;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
142
470
|
}
|
|
143
471
|
function truthy_p(node) {
|
|
144
|
-
return (!__eliscript_truthy(((
|
|
472
|
+
return (!__eliscript_truthy(((__eliscript_value_52) => (__eliscript_truthy(__eliscript_value_52) ? __eliscript_value_52 : ((__eliscript_value_53) => (__eliscript_truthy(__eliscript_value_53) ? __eliscript_value_53 : ((__eliscript_value_54) => (__eliscript_truthy(__eliscript_value_54) ? (node_value(node) === false) : __eliscript_value_54))(literal_node_p(node))))((node_kind(node) === "undefined"))))(null_node_p(node))));
|
|
145
473
|
}
|
|
146
474
|
function make_boolean(value) {
|
|
147
475
|
return literal_node((__eliscript_truthy(value) ? true : false), null);
|
|
148
476
|
}
|
|
149
477
|
function value_string(node) {
|
|
150
|
-
|
|
478
|
+
if (__eliscript_truthy(((__eliscript_value_55) => (__eliscript_truthy(__eliscript_value_55) ? (typeof node.value === "string") : __eliscript_value_55))(literal_node_p(node)))) {
|
|
479
|
+
return node_value(node);
|
|
480
|
+
} else {
|
|
481
|
+
if (__eliscript_truthy(symbol_node_p(node))) {
|
|
482
|
+
return node_name(node);
|
|
483
|
+
} else {
|
|
484
|
+
if (__eliscript_truthy(keyword_node_p(node))) {
|
|
485
|
+
return (String(":") + String(node_name(node)));
|
|
486
|
+
} else {
|
|
487
|
+
if (__eliscript_truthy(null_node_p(node))) {
|
|
488
|
+
return "nil";
|
|
489
|
+
} else {
|
|
490
|
+
if (__eliscript_truthy(literal_node_p(node))) {
|
|
491
|
+
return (String(node_value(node)));
|
|
492
|
+
} else {
|
|
493
|
+
return node_display(node);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}
|
|
151
499
|
}
|
|
152
500
|
function require_number(node, operator) {
|
|
153
|
-
(
|
|
501
|
+
if ((!__eliscript_truthy(((__eliscript_value_56) => (__eliscript_truthy(__eliscript_value_56) ? (typeof node.value === "number") : __eliscript_value_56))(literal_node_p(node))))) {
|
|
502
|
+
(__eliscript_tdz_read_2())((String(operator) + String(" expects numbers, got ") + String(node_display(node))));
|
|
503
|
+
}
|
|
154
504
|
return node_value(node);
|
|
155
505
|
}
|
|
156
506
|
function nodes_equal(left, right) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
507
|
+
if ((!(node_kind(left) === node_kind(right)))) {
|
|
508
|
+
return false;
|
|
509
|
+
} else {
|
|
510
|
+
if ((node_kind(left) === "literal")) {
|
|
511
|
+
return (node_value(left) === node_value(right));
|
|
512
|
+
} else {
|
|
513
|
+
if ((node_kind(left) === "undefined")) {
|
|
514
|
+
return true;
|
|
515
|
+
} else {
|
|
516
|
+
if (((node_kind(left) === "symbol") || (node_kind(left) === "keyword"))) {
|
|
517
|
+
return (node_name(left) === node_name(right));
|
|
518
|
+
} else {
|
|
519
|
+
if (((node_kind(left) === "list") || (node_kind(left) === "vector"))) {
|
|
520
|
+
{
|
|
521
|
+
const __eliscript_value_57 = node_items(left);
|
|
522
|
+
const __eliscript_value_58 = node_items(right);
|
|
523
|
+
const __eliscript_value_59 = 0;
|
|
524
|
+
const __eliscript_value_60 = ((node_items(left))["length"] === (node_items(right))["length"]);
|
|
525
|
+
{
|
|
526
|
+
let left_items = __eliscript_value_57;
|
|
527
|
+
let right_items = __eliscript_value_58;
|
|
528
|
+
let index = __eliscript_value_59;
|
|
529
|
+
let same = __eliscript_value_60;
|
|
530
|
+
while (__eliscript_truthy(((__eliscript_value_61) => (__eliscript_truthy(__eliscript_value_61) ? __eliscript_numeric_relation("<", index, (left_items)["length"]) : __eliscript_value_61))(same))) {
|
|
531
|
+
if ((!__eliscript_truthy(nodes_equal(((((left_items) ?? [])[index]) ?? null), ((((right_items) ?? [])[index]) ?? null))))) {
|
|
532
|
+
((same = false));
|
|
533
|
+
}
|
|
534
|
+
((index = (index + 1)));
|
|
535
|
+
}
|
|
536
|
+
return same;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
162
543
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return same;
|
|
166
|
-
})(node_items(left), node_items(right), 0, ((node_items(left))["length"] === (node_items(right))["length"])) : false)))));
|
|
544
|
+
}
|
|
545
|
+
}
|
|
167
546
|
}
|
|
168
547
|
function eval_sequence(forms, scope) {
|
|
169
|
-
|
|
170
|
-
(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
548
|
+
{
|
|
549
|
+
const __eliscript_value_62 = literal_node(null, null);
|
|
550
|
+
{
|
|
551
|
+
let result = __eliscript_value_62;
|
|
552
|
+
(forms)["forEach"](((form) => {
|
|
553
|
+
return ((result = eval_form(form, scope)));
|
|
554
|
+
}));
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
175
558
|
}
|
|
176
559
|
function eval_args(forms, scope) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
560
|
+
{
|
|
561
|
+
const __eliscript_value_63 = [];
|
|
562
|
+
{
|
|
563
|
+
let values = __eliscript_value_63;
|
|
564
|
+
(forms)["forEach"](((form) => {
|
|
565
|
+
return (values)["push"](eval_form(form, scope));
|
|
566
|
+
}));
|
|
567
|
+
return values;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
183
570
|
}
|
|
184
571
|
function eval_if(args, scope) {
|
|
185
|
-
(
|
|
186
|
-
|
|
572
|
+
if ((__eliscript_numeric_relation("<", (args)["length"], 2) || __eliscript_numeric_relation(">", (args)["length"], 3))) {
|
|
573
|
+
(__eliscript_tdz_read_2())("if expects 2..3 arguments");
|
|
574
|
+
}
|
|
575
|
+
if (__eliscript_truthy(truthy_p(eval_form(((((args) ?? [])[0]) ?? null), scope)))) {
|
|
576
|
+
return eval_form(((((args) ?? [])[1]) ?? null), scope);
|
|
577
|
+
} else {
|
|
578
|
+
if (((args)["length"] === 3)) {
|
|
579
|
+
return eval_form(((((args) ?? [])[2]) ?? null), scope);
|
|
580
|
+
} else {
|
|
581
|
+
return literal_node(null, null);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
187
584
|
}
|
|
188
585
|
function eval_cond(clauses, scope) {
|
|
189
|
-
|
|
190
|
-
(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
586
|
+
{
|
|
587
|
+
const __eliscript_value_64 = literal_node(null, null);
|
|
588
|
+
const __eliscript_value_65 = false;
|
|
589
|
+
{
|
|
590
|
+
let result = __eliscript_value_64;
|
|
591
|
+
let done = __eliscript_value_65;
|
|
592
|
+
(clauses)["forEach"](((clause) => {
|
|
593
|
+
if ((!__eliscript_truthy(done))) {
|
|
594
|
+
{
|
|
595
|
+
const __eliscript_value_66 = list_items(clause);
|
|
596
|
+
{
|
|
597
|
+
let items = __eliscript_value_66;
|
|
598
|
+
if (((items === undefined) || ((items)["length"] === 0))) {
|
|
599
|
+
(__eliscript_tdz_read_2())((String("invalid macro cond clause: ") + String(node_display(clause))));
|
|
600
|
+
}
|
|
601
|
+
{
|
|
602
|
+
const __eliscript_value_67 = eval_form(((((items) ?? [])[0]) ?? null), scope);
|
|
603
|
+
{
|
|
604
|
+
let test_value = __eliscript_value_67;
|
|
605
|
+
if (__eliscript_truthy(truthy_p(test_value))) {
|
|
606
|
+
((result = (((items)["length"] === 1) ? test_value : eval_sequence((items)["slice"](1), scope))));
|
|
607
|
+
return ((done = true));
|
|
608
|
+
} else {
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
} else {
|
|
616
|
+
return null;
|
|
617
|
+
}
|
|
618
|
+
}));
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
203
622
|
}
|
|
204
623
|
function parse_eval_binding(binding) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
624
|
+
if (__eliscript_truthy(symbol_node_p(binding))) {
|
|
625
|
+
return ({"name": node_name(binding), "value": undefined});
|
|
626
|
+
} else {
|
|
627
|
+
{
|
|
628
|
+
const __eliscript_value_68 = list_items(binding);
|
|
629
|
+
{
|
|
630
|
+
let items = __eliscript_value_68;
|
|
631
|
+
if ((!__eliscript_truthy(((__eliscript_value_69) => (__eliscript_truthy(__eliscript_value_69) ? ((__eliscript_value_70) => (__eliscript_truthy(__eliscript_value_70) ? ((__eliscript_value_71) => (__eliscript_truthy(__eliscript_value_71) ? symbol_node_p(((((items) ?? [])[0]) ?? null)) : __eliscript_value_71))(__eliscript_numeric_relation("<=", (items)["length"], 2)) : __eliscript_value_70))(__eliscript_numeric_relation(">=", (items)["length"], 1)) : __eliscript_value_69))((!(items === undefined)))))) {
|
|
632
|
+
(__eliscript_tdz_read_2())((String("invalid macro let binding: ") + String(node_display(binding))));
|
|
633
|
+
}
|
|
634
|
+
return ({"name": node_name(((((items) ?? [])[0]) ?? null)), "value": ((((items) ?? [])[1]) ?? null)});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
209
638
|
}
|
|
210
639
|
function eval_let(args, scope, sequential) {
|
|
211
|
-
(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
640
|
+
if (((args)["length"] === 0)) {
|
|
641
|
+
(__eliscript_tdz_read_2())("macro let requires a binding list");
|
|
642
|
+
}
|
|
643
|
+
{
|
|
644
|
+
let binding_items = list_items(((((args) ?? [])[0]) ?? null));
|
|
645
|
+
let child = make_eval_scope(scope);
|
|
646
|
+
if ((binding_items === undefined)) {
|
|
647
|
+
(__eliscript_tdz_read_2())("macro let bindings must be a list");
|
|
648
|
+
}
|
|
649
|
+
if (__eliscript_truthy(sequential)) {
|
|
650
|
+
(binding_items)["forEach"](((binding) => {
|
|
651
|
+
{
|
|
652
|
+
let parsed = parse_eval_binding(binding);
|
|
653
|
+
let value_form = (parsed)["value"];
|
|
654
|
+
let value = ((value_form === undefined) ? literal_node(null, null) : eval_form(value_form, child));
|
|
655
|
+
return scope_bind(child, (parsed)["name"], value);
|
|
656
|
+
}
|
|
657
|
+
}));
|
|
658
|
+
} else {
|
|
659
|
+
{
|
|
660
|
+
const __eliscript_value_72 = [];
|
|
661
|
+
{
|
|
662
|
+
let parsed_bindings = __eliscript_value_72;
|
|
663
|
+
(binding_items)["forEach"](((binding) => {
|
|
664
|
+
{
|
|
665
|
+
let parsed = parse_eval_binding(binding);
|
|
666
|
+
let value_form = (parsed)["value"];
|
|
667
|
+
let value = ((value_form === undefined) ? literal_node(null, null) : eval_form(value_form, scope));
|
|
668
|
+
return (parsed_bindings)["push"](({"name": (parsed)["name"], "value": value}));
|
|
669
|
+
}
|
|
670
|
+
}));
|
|
671
|
+
(parsed_bindings)["forEach"](((binding) => {
|
|
235
672
|
return scope_bind(child, (binding)["name"], (binding)["value"]);
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
}
|
|
673
|
+
}));
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return eval_sequence((args)["slice"](1), child);
|
|
678
|
+
}
|
|
242
679
|
}
|
|
243
680
|
function eval_setq(args, scope) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
681
|
+
if ((((args)["length"] === 0) || (__eliscript_numeric_rem((args)["length"], 2) === 1))) {
|
|
682
|
+
(__eliscript_tdz_read_2())("macro setq expects name/value pairs");
|
|
683
|
+
}
|
|
684
|
+
{
|
|
685
|
+
const __eliscript_value_73 = 0;
|
|
686
|
+
const __eliscript_value_74 = literal_node(null, null);
|
|
687
|
+
{
|
|
688
|
+
let index = __eliscript_value_73;
|
|
689
|
+
let result = __eliscript_value_74;
|
|
690
|
+
while (__eliscript_numeric_relation("<", index, (args)["length"])) {
|
|
691
|
+
{
|
|
692
|
+
const __eliscript_value_75 = ((((args) ?? [])[index]) ?? null);
|
|
693
|
+
{
|
|
694
|
+
let name = __eliscript_value_75;
|
|
695
|
+
if ((!__eliscript_truthy(symbol_node_p(name)))) {
|
|
696
|
+
(__eliscript_tdz_read_2())("macro setq target must be a symbol");
|
|
697
|
+
}
|
|
698
|
+
((result = eval_form(((((args) ?? [])[(index + 1)]) ?? null), scope)));
|
|
699
|
+
scope_set(scope, node_name(name), result);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
253
702
|
((index = (index + 2)));
|
|
254
703
|
}
|
|
255
|
-
return
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
})(0, literal_node(null, null));
|
|
704
|
+
return result;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
259
707
|
}
|
|
260
708
|
function splice_form_p(node, depth) {
|
|
261
|
-
return ((
|
|
709
|
+
return ((__eliscript_value_76) => (__eliscript_truthy(__eliscript_value_76) ? form_operator_p(node, ",@") : __eliscript_value_76))((depth === 1));
|
|
262
710
|
}
|
|
263
711
|
function quasiquote_items(items, scope, depth, auto_gensyms) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
712
|
+
{
|
|
713
|
+
const __eliscript_value_77 = [];
|
|
714
|
+
{
|
|
715
|
+
let result = __eliscript_value_77;
|
|
716
|
+
(items)["forEach"](((item) => {
|
|
717
|
+
if (__eliscript_truthy(splice_form_p(item, depth))) {
|
|
718
|
+
{
|
|
719
|
+
let parts = node_items(item);
|
|
720
|
+
let value = (((parts)["length"] === 2) ? eval_form(((((parts) ?? [])[1]) ?? null), scope) : (__eliscript_tdz_read_2())(",@ expects one value"));
|
|
721
|
+
let spliced = sequence_items(value);
|
|
722
|
+
if ((spliced === undefined)) {
|
|
723
|
+
(__eliscript_tdz_read_2())((String("cannot splice ") + String(node_display(value))));
|
|
724
|
+
}
|
|
725
|
+
return (spliced)["forEach"](((part) => {
|
|
726
|
+
return (result)["push"](part);
|
|
727
|
+
}));
|
|
728
|
+
}
|
|
729
|
+
} else {
|
|
730
|
+
return (result)["push"](quasiquote_node(item, scope, depth, auto_gensyms));
|
|
731
|
+
}
|
|
732
|
+
}));
|
|
733
|
+
return result;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
281
736
|
}
|
|
282
737
|
function quasiquote_node(node, scope, depth, auto_gensyms) {
|
|
283
|
-
|
|
284
|
-
return (
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
738
|
+
if (__eliscript_truthy(vector_node_p(node))) {
|
|
739
|
+
return collection_node("vector", quasiquote_items(node_items(node), scope, depth, auto_gensyms), node_span(node));
|
|
740
|
+
} else {
|
|
741
|
+
if (__eliscript_truthy(((__eliscript_value_78) => (__eliscript_truthy(__eliscript_value_78) ? form_operator_p(node, ",") : __eliscript_value_78))((depth === 1)))) {
|
|
742
|
+
{
|
|
743
|
+
const __eliscript_value_79 = node_items(node);
|
|
744
|
+
{
|
|
745
|
+
let items = __eliscript_value_79;
|
|
746
|
+
if (((items)["length"] === 2)) {
|
|
747
|
+
return eval_form(((((items) ?? [])[1]) ?? null), scope);
|
|
748
|
+
} else {
|
|
749
|
+
return (__eliscript_tdz_read_2())(", expects one value");
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
} else {
|
|
754
|
+
if (__eliscript_truthy(((__eliscript_value_80) => (__eliscript_truthy(__eliscript_value_80) ? form_operator_p(node, ",@") : __eliscript_value_80))((depth === 1)))) {
|
|
755
|
+
return (__eliscript_tdz_read_2())(",@ is only valid inside a collection");
|
|
756
|
+
} else {
|
|
757
|
+
if (__eliscript_truthy(form_operator_p(node, "`"))) {
|
|
758
|
+
{
|
|
759
|
+
const __eliscript_value_81 = node_items(node);
|
|
760
|
+
{
|
|
761
|
+
let items = __eliscript_value_81;
|
|
762
|
+
if (((items)["length"] === 2)) {
|
|
763
|
+
return make_list([((((items) ?? [])[0]) ?? null), quasiquote_node(((((items) ?? [])[1]) ?? null), scope, (depth + 1), auto_gensyms)], node_span(node));
|
|
764
|
+
} else {
|
|
765
|
+
return (__eliscript_tdz_read_2())("` expects one value");
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
} else {
|
|
770
|
+
if (__eliscript_truthy(((__eliscript_value_82) => (__eliscript_truthy(__eliscript_value_82) ? form_operator_p(node, ",") : __eliscript_value_82))(__eliscript_numeric_relation(">", depth, 1)))) {
|
|
771
|
+
{
|
|
772
|
+
const __eliscript_value_83 = node_items(node);
|
|
773
|
+
{
|
|
774
|
+
let items = __eliscript_value_83;
|
|
775
|
+
return make_list([((((items) ?? [])[0]) ?? null), quasiquote_node(((((items) ?? [])[1]) ?? null), scope, __eliscript_numeric_decrement(depth), auto_gensyms)], node_span(node));
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
} else {
|
|
779
|
+
if (__eliscript_truthy(list_node_p(node))) {
|
|
780
|
+
return make_list(quasiquote_items(list_items(node), scope, depth, auto_gensyms), node_span(node));
|
|
781
|
+
} else {
|
|
782
|
+
if (__eliscript_truthy(((__eliscript_value_84) => (__eliscript_truthy(__eliscript_value_84) ? ((__eliscript_value_85) => (__eliscript_truthy(__eliscript_value_85) ? (node_name(node))["endsWith"]("$") : __eliscript_value_85))(symbol_node_p(node)) : __eliscript_value_84))((depth === 1)))) {
|
|
783
|
+
return auto_gensym(node, scope, auto_gensyms);
|
|
784
|
+
} else {
|
|
785
|
+
return node;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
290
793
|
}
|
|
291
794
|
function eval_list_operation(operator, values) {
|
|
292
|
-
|
|
293
|
-
(
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return (
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
795
|
+
if ((operator === "list")) {
|
|
796
|
+
return make_list(values, null);
|
|
797
|
+
} else {
|
|
798
|
+
if ((operator === "vector")) {
|
|
799
|
+
return collection_node("vector", values, null);
|
|
800
|
+
} else {
|
|
801
|
+
if ((operator === "car")) {
|
|
802
|
+
if ((!((values)["length"] === 1))) {
|
|
803
|
+
(__eliscript_tdz_read_2())("car expects 1 argument");
|
|
804
|
+
}
|
|
805
|
+
{
|
|
806
|
+
const __eliscript_value_86 = sequence_items(((((values) ?? [])[0]) ?? null));
|
|
807
|
+
{
|
|
808
|
+
let items = __eliscript_value_86;
|
|
809
|
+
if ((items === undefined)) {
|
|
810
|
+
(__eliscript_tdz_read_2())("car expects a list or vector");
|
|
811
|
+
}
|
|
812
|
+
if (((items)["length"] === 0)) {
|
|
813
|
+
return literal_node(null, null);
|
|
814
|
+
} else {
|
|
815
|
+
return ((((items) ?? [])[0]) ?? null);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
} else {
|
|
820
|
+
if ((operator === "cdr")) {
|
|
821
|
+
if ((!((values)["length"] === 1))) {
|
|
822
|
+
(__eliscript_tdz_read_2())("cdr expects 1 argument");
|
|
823
|
+
}
|
|
824
|
+
{
|
|
825
|
+
const __eliscript_value_87 = sequence_items(((((values) ?? [])[0]) ?? null));
|
|
826
|
+
{
|
|
827
|
+
let items = __eliscript_value_87;
|
|
828
|
+
if ((items === undefined)) {
|
|
829
|
+
(__eliscript_tdz_read_2())("cdr expects a list or vector");
|
|
830
|
+
}
|
|
831
|
+
return make_list((items)["slice"](1), null);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
} else {
|
|
835
|
+
if ((operator === "nth")) {
|
|
836
|
+
if ((!((values)["length"] === 2))) {
|
|
837
|
+
(__eliscript_tdz_read_2())("nth expects 2 arguments");
|
|
838
|
+
}
|
|
839
|
+
{
|
|
840
|
+
let index = require_number(((((values) ?? [])[0]) ?? null), "nth");
|
|
841
|
+
let items = sequence_items(((((values) ?? [])[1]) ?? null));
|
|
842
|
+
if ((items === undefined)) {
|
|
843
|
+
(__eliscript_tdz_read_2())("nth expects a list or vector");
|
|
844
|
+
}
|
|
845
|
+
if ((__eliscript_numeric_relation(">=", index, 0) && __eliscript_numeric_relation("<", index, (items)["length"]))) {
|
|
846
|
+
return ((((items) ?? [])[index]) ?? null);
|
|
847
|
+
} else {
|
|
848
|
+
return literal_node(null, null);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
} else {
|
|
852
|
+
if ((operator === "length")) {
|
|
853
|
+
if ((!((values)["length"] === 1))) {
|
|
854
|
+
(__eliscript_tdz_read_2())("length expects 1 argument");
|
|
855
|
+
}
|
|
856
|
+
{
|
|
857
|
+
const __eliscript_value_88 = sequence_items(((((values) ?? [])[0]) ?? null));
|
|
858
|
+
{
|
|
859
|
+
let items = __eliscript_value_88;
|
|
860
|
+
if ((!(items === undefined))) {
|
|
861
|
+
return literal_node((items)["length"], null);
|
|
862
|
+
} else {
|
|
863
|
+
if (__eliscript_truthy(((__eliscript_value_89) => (__eliscript_truthy(__eliscript_value_89) ? (typeof values[0].value === "string") : __eliscript_value_89))(literal_node_p(((((values) ?? [])[0]) ?? null))))) {
|
|
864
|
+
return literal_node((node_value(((((values) ?? [])[0]) ?? null)))["length"], null);
|
|
865
|
+
} else {
|
|
866
|
+
return (__eliscript_tdz_read_2())("length expects a sequence");
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
} else {
|
|
872
|
+
if ((operator === "cons")) {
|
|
873
|
+
if ((!((values)["length"] === 2))) {
|
|
874
|
+
(__eliscript_tdz_read_2())("cons expects 2 arguments");
|
|
875
|
+
}
|
|
876
|
+
{
|
|
877
|
+
const __eliscript_value_90 = sequence_items(((((values) ?? [])[1]) ?? null));
|
|
878
|
+
{
|
|
879
|
+
let tail = __eliscript_value_90;
|
|
880
|
+
if ((tail === undefined)) {
|
|
881
|
+
(__eliscript_tdz_read_2())("cons tail must be a list or vector");
|
|
882
|
+
}
|
|
883
|
+
{
|
|
884
|
+
const __eliscript_value_91 = [((((values) ?? [])[0]) ?? null)];
|
|
885
|
+
{
|
|
886
|
+
let items = __eliscript_value_91;
|
|
887
|
+
(tail)["forEach"](((item) => {
|
|
888
|
+
return (items)["push"](item);
|
|
889
|
+
}));
|
|
890
|
+
return make_list(items, null);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
} else {
|
|
896
|
+
if ((operator === "append")) {
|
|
897
|
+
{
|
|
898
|
+
const __eliscript_value_92 = [];
|
|
899
|
+
{
|
|
900
|
+
let items = __eliscript_value_92;
|
|
901
|
+
(values)["forEach"](((value) => {
|
|
902
|
+
{
|
|
903
|
+
const __eliscript_value_93 = sequence_items(value);
|
|
904
|
+
{
|
|
905
|
+
let parts = __eliscript_value_93;
|
|
906
|
+
if ((parts === undefined)) {
|
|
907
|
+
(__eliscript_tdz_read_2())("append expects lists or vectors");
|
|
908
|
+
}
|
|
909
|
+
return (parts)["forEach"](((part) => {
|
|
910
|
+
return (items)["push"](part);
|
|
911
|
+
}));
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
}));
|
|
915
|
+
return make_list(items, null);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
} else {
|
|
919
|
+
return undefined;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
341
928
|
}
|
|
342
929
|
function eval_predicate(operator, values) {
|
|
343
|
-
|
|
344
|
-
(
|
|
930
|
+
if ((operator === "not")) {
|
|
931
|
+
if ((!((values)["length"] === 1))) {
|
|
932
|
+
(__eliscript_tdz_read_2())((String(operator) + String(" expects 1 argument")));
|
|
933
|
+
}
|
|
345
934
|
return make_boolean((!__eliscript_truthy(truthy_p(((((values) ?? [])[0]) ?? null)))));
|
|
346
|
-
}
|
|
347
|
-
(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
935
|
+
} else {
|
|
936
|
+
if ((operator === "nil?")) {
|
|
937
|
+
if ((!((values)["length"] === 1))) {
|
|
938
|
+
(__eliscript_tdz_read_2())("nil? expects 1 argument");
|
|
939
|
+
}
|
|
940
|
+
return make_boolean(null_node_p(((((values) ?? [])[0]) ?? null)));
|
|
941
|
+
} else {
|
|
942
|
+
if ((operator === "undefined?")) {
|
|
943
|
+
if ((!((values)["length"] === 1))) {
|
|
944
|
+
(__eliscript_tdz_read_2())("undefined? expects 1 argument");
|
|
945
|
+
}
|
|
946
|
+
return make_boolean((node_kind(((((values) ?? [])[0]) ?? null)) === "undefined"));
|
|
947
|
+
} else {
|
|
948
|
+
if (((operator === "null") || (operator === "nullish?"))) {
|
|
949
|
+
if ((!((values)["length"] === 1))) {
|
|
950
|
+
(__eliscript_tdz_read_2())((String(operator) + String(" expects 1 argument")));
|
|
951
|
+
}
|
|
952
|
+
return make_boolean(((__eliscript_value_94) => (__eliscript_truthy(__eliscript_value_94) ? __eliscript_value_94 : (node_kind(((((values) ?? [])[0]) ?? null)) === "undefined")))(null_node_p(((((values) ?? [])[0]) ?? null))));
|
|
953
|
+
} else {
|
|
954
|
+
if ((operator === "symbolp")) {
|
|
955
|
+
if ((!((values)["length"] === 1))) {
|
|
956
|
+
(__eliscript_tdz_read_2())("symbolp expects 1 argument");
|
|
957
|
+
}
|
|
958
|
+
return make_boolean(symbol_node_p(((((values) ?? [])[0]) ?? null)));
|
|
959
|
+
} else {
|
|
960
|
+
if ((operator === "keywordp")) {
|
|
961
|
+
if ((!((values)["length"] === 1))) {
|
|
962
|
+
(__eliscript_tdz_read_2())("keywordp expects 1 argument");
|
|
963
|
+
}
|
|
964
|
+
return make_boolean(keyword_node_p(((((values) ?? [])[0]) ?? null)));
|
|
965
|
+
} else {
|
|
966
|
+
if ((operator === "listp")) {
|
|
967
|
+
if ((!((values)["length"] === 1))) {
|
|
968
|
+
(__eliscript_tdz_read_2())("listp expects 1 argument");
|
|
969
|
+
}
|
|
970
|
+
return make_boolean(list_node_p(((((values) ?? [])[0]) ?? null)));
|
|
971
|
+
} else {
|
|
972
|
+
if ((operator === "consp")) {
|
|
973
|
+
if ((!((values)["length"] === 1))) {
|
|
974
|
+
(__eliscript_tdz_read_2())("consp expects 1 argument");
|
|
975
|
+
}
|
|
976
|
+
return make_boolean(((__eliscript_value_95) => (__eliscript_truthy(__eliscript_value_95) ? list_node_p(((((values) ?? [])[0]) ?? null)) : __eliscript_value_95))((!__eliscript_truthy(null_node_p(((((values) ?? [])[0]) ?? null))))));
|
|
977
|
+
} else {
|
|
978
|
+
if ((operator === "vectorp")) {
|
|
979
|
+
if ((!((values)["length"] === 1))) {
|
|
980
|
+
(__eliscript_tdz_read_2())("vectorp expects 1 argument");
|
|
981
|
+
}
|
|
982
|
+
return make_boolean(vector_node_p(((((values) ?? [])[0]) ?? null)));
|
|
983
|
+
} else {
|
|
984
|
+
if ((operator === "stringp")) {
|
|
985
|
+
if ((!((values)["length"] === 1))) {
|
|
986
|
+
(__eliscript_tdz_read_2())("stringp expects 1 argument");
|
|
987
|
+
}
|
|
988
|
+
return make_boolean(((__eliscript_value_96) => (__eliscript_truthy(__eliscript_value_96) ? (typeof values[0].value === "string") : __eliscript_value_96))(literal_node_p(((((values) ?? [])[0]) ?? null))));
|
|
989
|
+
} else {
|
|
990
|
+
if ((operator === "numberp")) {
|
|
991
|
+
if ((!((values)["length"] === 1))) {
|
|
992
|
+
(__eliscript_tdz_read_2())("numberp expects 1 argument");
|
|
993
|
+
}
|
|
994
|
+
return make_boolean(((__eliscript_value_97) => (__eliscript_truthy(__eliscript_value_97) ? (typeof values[0].value === "number") : __eliscript_value_97))(literal_node_p(((((values) ?? [])[0]) ?? null))));
|
|
995
|
+
} else {
|
|
996
|
+
if ((operator === "atom")) {
|
|
997
|
+
if ((!((values)["length"] === 1))) {
|
|
998
|
+
(__eliscript_tdz_read_2())("atom expects 1 argument");
|
|
999
|
+
}
|
|
1000
|
+
return make_boolean((!__eliscript_truthy(((__eliscript_value_98) => (__eliscript_truthy(__eliscript_value_98) ? list_node_p(((((values) ?? [])[0]) ?? null)) : __eliscript_value_98))((!__eliscript_truthy(null_node_p(((((values) ?? [])[0]) ?? null))))))));
|
|
1001
|
+
} else {
|
|
1002
|
+
if ((operator === "eq")) {
|
|
1003
|
+
if ((!((values)["length"] === 2))) {
|
|
1004
|
+
(__eliscript_tdz_read_2())("eq expects 2 arguments");
|
|
1005
|
+
}
|
|
1006
|
+
{
|
|
1007
|
+
const __eliscript_value_99 = ((((values) ?? [])[0]) ?? null);
|
|
1008
|
+
const __eliscript_value_100 = ((((values) ?? [])[1]) ?? null);
|
|
1009
|
+
{
|
|
1010
|
+
let left = __eliscript_value_99;
|
|
1011
|
+
let right = __eliscript_value_100;
|
|
1012
|
+
return make_boolean((__eliscript_truthy(((__eliscript_value_101) => (__eliscript_truthy(__eliscript_value_101) ? symbol_node_p(right) : __eliscript_value_101))(symbol_node_p(left))) ? (node_name(left) === node_name(right)) : (__eliscript_truthy(((__eliscript_value_102) => (__eliscript_truthy(__eliscript_value_102) ? keyword_node_p(right) : __eliscript_value_102))(keyword_node_p(left))) ? (node_name(left) === node_name(right)) : (__eliscript_truthy(((__eliscript_value_103) => (__eliscript_truthy(__eliscript_value_103) ? literal_node_p(right) : __eliscript_value_103))(literal_node_p(left))) ? (node_value(left) === node_value(right)) : (left === right)))));
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
} else {
|
|
1016
|
+
if ((operator === "equal")) {
|
|
1017
|
+
if ((!((values)["length"] === 2))) {
|
|
1018
|
+
(__eliscript_tdz_read_2())("equal expects 2 arguments");
|
|
1019
|
+
}
|
|
1020
|
+
return make_boolean(nodes_equal(((((values) ?? [])[0]) ?? null), ((((values) ?? [])[1]) ?? null)));
|
|
1021
|
+
} else {
|
|
1022
|
+
return undefined;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
388
1037
|
}
|
|
389
1038
|
function eval_arithmetic(operator, values) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
1039
|
+
if ((!__eliscript_truthy((["+", "-", "*", "/", "%", "mod", "1+", "1-", "=", "/=", "<", "<=", ">", ">="])["includes"](operator)))) {
|
|
1040
|
+
return undefined;
|
|
1041
|
+
} else {
|
|
1042
|
+
{
|
|
1043
|
+
const __eliscript_value_104 = [];
|
|
1044
|
+
{
|
|
1045
|
+
let numbers = __eliscript_value_104;
|
|
1046
|
+
if (((operator === "1+") || (operator === "1-"))) {
|
|
1047
|
+
if ((!((values)["length"] === 1))) {
|
|
1048
|
+
(__eliscript_tdz_read_2())((String(operator) + String(" expects 1 argument")));
|
|
1049
|
+
}
|
|
1050
|
+
} else {
|
|
1051
|
+
if (((operator === "%") || (operator === "mod") || (operator === "=") || (operator === "/=") || (operator === "<") || (operator === "<=") || (operator === ">") || (operator === ">="))) {
|
|
1052
|
+
if ((!((values)["length"] === 2))) {
|
|
1053
|
+
(__eliscript_tdz_read_2())((String(operator) + String(" expects 2 arguments")));
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
if (((operator === "-") || (operator === "/"))) {
|
|
1057
|
+
if (((values)["length"] === 0)) {
|
|
1058
|
+
(__eliscript_tdz_read_2())((String(operator) + String(" expects one or more numbers")));
|
|
1059
|
+
}
|
|
1060
|
+
} else {
|
|
1061
|
+
|
|
1062
|
+
}
|
|
411
1063
|
}
|
|
412
|
-
return null;
|
|
413
|
-
})();
|
|
414
|
-
})(1));
|
|
415
|
-
return literal_node(result, null);
|
|
416
|
-
})(((((numbers) ?? [])[0]) ?? null)) : (__eliscript_truthy((operator === "/")) ? ((result, index) => {
|
|
417
|
-
(__eliscript_truthy(((numbers)["length"] === 1)) ? ((result = (1 / result))) : (() => {
|
|
418
|
-
while (__eliscript_truthy((index < (numbers)["length"]))) {
|
|
419
|
-
((result = (result / ((((numbers) ?? [])[index]) ?? null))));
|
|
420
|
-
((index = (index + 1)));
|
|
421
1064
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
1065
|
+
(values)["forEach"](((value) => {
|
|
1066
|
+
return (numbers)["push"](require_number(value, operator));
|
|
1067
|
+
}));
|
|
1068
|
+
if ((operator === "1+")) {
|
|
1069
|
+
return literal_node((((((numbers) ?? [])[0]) ?? null) + 1), null);
|
|
1070
|
+
} else {
|
|
1071
|
+
if ((operator === "1-")) {
|
|
1072
|
+
return literal_node(__eliscript_numeric_decrement(((((numbers) ?? [])[0]) ?? null)), null);
|
|
1073
|
+
} else {
|
|
1074
|
+
if ((operator === "+")) {
|
|
1075
|
+
{
|
|
1076
|
+
const __eliscript_value_105 = 0;
|
|
1077
|
+
{
|
|
1078
|
+
let result = __eliscript_value_105;
|
|
1079
|
+
(numbers)["forEach"](((number) => {
|
|
1080
|
+
return ((result = (result + number)));
|
|
1081
|
+
}));
|
|
1082
|
+
return literal_node(result, null);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
} else {
|
|
1086
|
+
if ((operator === "*")) {
|
|
1087
|
+
{
|
|
1088
|
+
const __eliscript_value_106 = 1;
|
|
1089
|
+
{
|
|
1090
|
+
let result = __eliscript_value_106;
|
|
1091
|
+
(numbers)["forEach"](((number) => {
|
|
1092
|
+
return ((result = __eliscript_numeric_mul(result, number)));
|
|
1093
|
+
}));
|
|
1094
|
+
return literal_node(result, null);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
} else {
|
|
1098
|
+
if ((operator === "-")) {
|
|
1099
|
+
{
|
|
1100
|
+
const __eliscript_value_107 = ((((numbers) ?? [])[0]) ?? null);
|
|
1101
|
+
{
|
|
1102
|
+
let result = __eliscript_value_107;
|
|
1103
|
+
if (((numbers)["length"] === 1)) {
|
|
1104
|
+
((result = __eliscript_numeric_neg(result)));
|
|
1105
|
+
} else {
|
|
1106
|
+
{
|
|
1107
|
+
const __eliscript_value_108 = 1;
|
|
1108
|
+
{
|
|
1109
|
+
let index = __eliscript_value_108;
|
|
1110
|
+
while (__eliscript_numeric_relation("<", index, (numbers)["length"])) {
|
|
1111
|
+
((result = __eliscript_numeric_sub(result, ((((numbers) ?? [])[index]) ?? null))));
|
|
1112
|
+
((index = (index + 1)));
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
return literal_node(result, null);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
} else {
|
|
1121
|
+
if ((operator === "/")) {
|
|
1122
|
+
{
|
|
1123
|
+
const __eliscript_value_109 = ((((numbers) ?? [])[0]) ?? null);
|
|
1124
|
+
const __eliscript_value_110 = 1;
|
|
1125
|
+
{
|
|
1126
|
+
let result = __eliscript_value_109;
|
|
1127
|
+
let index = __eliscript_value_110;
|
|
1128
|
+
if (((numbers)["length"] === 1)) {
|
|
1129
|
+
((result = __eliscript_numeric_div(1, result)));
|
|
1130
|
+
} else {
|
|
1131
|
+
while (__eliscript_numeric_relation("<", index, (numbers)["length"])) {
|
|
1132
|
+
((result = __eliscript_numeric_div(result, ((((numbers) ?? [])[index]) ?? null))));
|
|
1133
|
+
((index = (index + 1)));
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
return literal_node(result, null);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
} else {
|
|
1140
|
+
if (((operator === "%") || (operator === "mod"))) {
|
|
1141
|
+
return literal_node(__eliscript_numeric_rem(((((numbers) ?? [])[0]) ?? null), ((((numbers) ?? [])[1]) ?? null)), null);
|
|
1142
|
+
} else {
|
|
1143
|
+
if ((operator === "=")) {
|
|
1144
|
+
return make_boolean((((((numbers) ?? [])[0]) ?? null) === ((((numbers) ?? [])[1]) ?? null)));
|
|
1145
|
+
} else {
|
|
1146
|
+
if ((operator === "/=")) {
|
|
1147
|
+
return make_boolean((!(((((numbers) ?? [])[0]) ?? null) === ((((numbers) ?? [])[1]) ?? null))));
|
|
1148
|
+
} else {
|
|
1149
|
+
if ((operator === "<")) {
|
|
1150
|
+
return make_boolean(__eliscript_numeric_relation("<", ((((numbers) ?? [])[0]) ?? null), ((((numbers) ?? [])[1]) ?? null)));
|
|
1151
|
+
} else {
|
|
1152
|
+
if ((operator === "<=")) {
|
|
1153
|
+
return make_boolean(__eliscript_numeric_relation("<=", ((((numbers) ?? [])[0]) ?? null), ((((numbers) ?? [])[1]) ?? null)));
|
|
1154
|
+
} else {
|
|
1155
|
+
if ((operator === ">")) {
|
|
1156
|
+
return make_boolean(__eliscript_numeric_relation(">", ((((numbers) ?? [])[0]) ?? null), ((((numbers) ?? [])[1]) ?? null)));
|
|
1157
|
+
} else {
|
|
1158
|
+
if ((operator === ">=")) {
|
|
1159
|
+
return make_boolean(__eliscript_numeric_relation(">=", ((((numbers) ?? [])[0]) ?? null), ((((numbers) ?? [])[1]) ?? null)));
|
|
1160
|
+
} else {
|
|
1161
|
+
return null;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
427
1178
|
}
|
|
428
1179
|
function eval_call(form, scope) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1180
|
+
{
|
|
1181
|
+
let items = node_items(form);
|
|
1182
|
+
let operator_node = ((((items) ?? [])[0]) ?? null);
|
|
1183
|
+
let args = (items)["slice"](1);
|
|
1184
|
+
if ((!__eliscript_truthy(symbol_node_p(operator_node)))) {
|
|
1185
|
+
(__eliscript_tdz_read_2())("macro call operator must be a symbol");
|
|
1186
|
+
}
|
|
1187
|
+
{
|
|
1188
|
+
const __eliscript_value_111 = node_name(operator_node);
|
|
1189
|
+
{
|
|
1190
|
+
let operator = __eliscript_value_111;
|
|
1191
|
+
if ((operator === "quote")) {
|
|
1192
|
+
if ((!((args)["length"] === 1))) {
|
|
1193
|
+
(__eliscript_tdz_read_2())("quote expects 1 argument");
|
|
1194
|
+
}
|
|
1195
|
+
return ((((args) ?? [])[0]) ?? null);
|
|
1196
|
+
} else {
|
|
1197
|
+
if ((operator === "`")) {
|
|
1198
|
+
if ((!((args)["length"] === 1))) {
|
|
1199
|
+
(__eliscript_tdz_read_2())("` expects 1 argument");
|
|
1200
|
+
}
|
|
1201
|
+
return quasiquote_node(((((args) ?? [])[0]) ?? null), scope, 1, new (Map)());
|
|
1202
|
+
} else {
|
|
1203
|
+
if ((operator === "if")) {
|
|
1204
|
+
return eval_if(args, scope);
|
|
1205
|
+
} else {
|
|
1206
|
+
if ((operator === "when")) {
|
|
1207
|
+
if (__eliscript_truthy(((__eliscript_value_112) => (__eliscript_truthy(__eliscript_value_112) ? truthy_p(eval_form(((((args) ?? [])[0]) ?? null), scope)) : __eliscript_value_112))(__eliscript_numeric_relation(">", (args)["length"], 0)))) {
|
|
1208
|
+
return eval_sequence((args)["slice"](1), scope);
|
|
1209
|
+
} else {
|
|
1210
|
+
return literal_node(null, null);
|
|
446
1211
|
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
1212
|
+
} else {
|
|
1213
|
+
if ((operator === "unless")) {
|
|
1214
|
+
if ((__eliscript_numeric_relation(">", (args)["length"], 0) && (!__eliscript_truthy(truthy_p(eval_form(((((args) ?? [])[0]) ?? null), scope)))))) {
|
|
1215
|
+
return eval_sequence((args)["slice"](1), scope);
|
|
1216
|
+
} else {
|
|
1217
|
+
return literal_node(null, null);
|
|
1218
|
+
}
|
|
1219
|
+
} else {
|
|
1220
|
+
if (((operator === "progn") || (operator === "do"))) {
|
|
1221
|
+
return eval_sequence(args, scope);
|
|
1222
|
+
} else {
|
|
1223
|
+
if ((operator === "let")) {
|
|
1224
|
+
return eval_let(args, scope, false);
|
|
1225
|
+
} else {
|
|
1226
|
+
if ((operator === "let*")) {
|
|
1227
|
+
return eval_let(args, scope, true);
|
|
1228
|
+
} else {
|
|
1229
|
+
if ((operator === "setq")) {
|
|
1230
|
+
return eval_setq(args, scope);
|
|
1231
|
+
} else {
|
|
1232
|
+
if ((operator === "cond")) {
|
|
1233
|
+
return eval_cond(args, scope);
|
|
1234
|
+
} else {
|
|
1235
|
+
if ((operator === "and")) {
|
|
1236
|
+
{
|
|
1237
|
+
const __eliscript_value_113 = literal_node(true, null);
|
|
1238
|
+
const __eliscript_value_114 = 0;
|
|
1239
|
+
{
|
|
1240
|
+
let result = __eliscript_value_113;
|
|
1241
|
+
let index = __eliscript_value_114;
|
|
1242
|
+
while (__eliscript_truthy(((__eliscript_value_115) => (__eliscript_truthy(__eliscript_value_115) ? truthy_p(result) : __eliscript_value_115))(__eliscript_numeric_relation("<", index, (args)["length"])))) {
|
|
1243
|
+
((result = eval_form(((((args) ?? [])[index]) ?? null), scope)));
|
|
1244
|
+
((index = (index + 1)));
|
|
1245
|
+
}
|
|
1246
|
+
return result;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
} else {
|
|
1250
|
+
if ((operator === "or")) {
|
|
1251
|
+
{
|
|
1252
|
+
const __eliscript_value_116 = literal_node(null, null);
|
|
1253
|
+
const __eliscript_value_117 = 0;
|
|
1254
|
+
{
|
|
1255
|
+
let result = __eliscript_value_116;
|
|
1256
|
+
let index = __eliscript_value_117;
|
|
1257
|
+
while ((__eliscript_numeric_relation("<", index, (args)["length"]) && (!__eliscript_truthy(truthy_p(result))))) {
|
|
1258
|
+
((result = eval_form(((((args) ?? [])[index]) ?? null), scope)));
|
|
1259
|
+
((index = (index + 1)));
|
|
1260
|
+
}
|
|
1261
|
+
return result;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
} else {
|
|
1265
|
+
if ((operator === "error")) {
|
|
1266
|
+
if ((!__eliscript_numeric_relation(">", (args)["length"], 0))) {
|
|
1267
|
+
(__eliscript_tdz_read_2())("error expects a message");
|
|
1268
|
+
}
|
|
1269
|
+
return (__eliscript_tdz_read_2())(value_string(eval_form(((((args) ?? [])[0]) ?? null), scope)));
|
|
1270
|
+
} else {
|
|
1271
|
+
if ((operator === "gensym")) {
|
|
1272
|
+
if ((!__eliscript_numeric_relation("<=", (args)["length"], 1))) {
|
|
1273
|
+
(__eliscript_tdz_read_2())("gensym expects 0..1 arguments");
|
|
1274
|
+
}
|
|
1275
|
+
return allocate_name(scope, (((args)["length"] === 0) ? literal_node("G", null) : eval_form(((((args) ?? [])[0]) ?? null), scope)));
|
|
1276
|
+
} else {
|
|
1277
|
+
if ((operator === "macro-read-file")) {
|
|
1278
|
+
if ((!((args)["length"] === 1))) {
|
|
1279
|
+
(__eliscript_tdz_read_2())("macro-read-file expects 1 argument");
|
|
1280
|
+
}
|
|
1281
|
+
{
|
|
1282
|
+
let specifier_node = eval_form(((((args) ?? [])[0]) ?? null), scope);
|
|
1283
|
+
let context = (scope)["context"];
|
|
1284
|
+
if ((!__eliscript_truthy(((__eliscript_value_118) => (__eliscript_truthy(__eliscript_value_118) ? ((typeof specifier_node.value === "string") && __eliscript_numeric_relation(">", (node_value(specifier_node))["length"], 0)) : __eliscript_value_118))(literal_node_p(specifier_node))))) {
|
|
1285
|
+
(__eliscript_tdz_read_2())("macro-read-file expects a non-empty string");
|
|
1286
|
+
}
|
|
1287
|
+
{
|
|
1288
|
+
const __eliscript_value_119 = node_value(specifier_node);
|
|
1289
|
+
{
|
|
1290
|
+
let specifier = __eliscript_value_119;
|
|
1291
|
+
if ((!__eliscript_truthy(((context)["capabilities"])["has"]("read-file")))) {
|
|
1292
|
+
(__eliscript_tdz_read_2())("macro capability is not enabled: read-file");
|
|
1293
|
+
}
|
|
1294
|
+
if ((!__eliscript_truthy(((context)["files"])["has"](specifier)))) {
|
|
1295
|
+
(__eliscript_tdz_read_2())((String("macro file dependency is not declared: ") + String(specifier)));
|
|
1296
|
+
}
|
|
1297
|
+
return literal_node(((context)["files"])["get"](specifier), null);
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
} else {
|
|
1302
|
+
{
|
|
1303
|
+
let values = eval_args(args, scope);
|
|
1304
|
+
let list_result = eval_list_operation(operator, values);
|
|
1305
|
+
let predicate_result = ((list_result === undefined) ? eval_predicate(operator, values) : undefined);
|
|
1306
|
+
let arithmetic_result = (((list_result === undefined) && (predicate_result === undefined)) ? eval_arithmetic(operator, values) : undefined);
|
|
1307
|
+
if ((!(list_result === undefined))) {
|
|
1308
|
+
return list_result;
|
|
1309
|
+
} else {
|
|
1310
|
+
if ((!(predicate_result === undefined))) {
|
|
1311
|
+
return predicate_result;
|
|
1312
|
+
} else {
|
|
1313
|
+
if ((!(arithmetic_result === undefined))) {
|
|
1314
|
+
return arithmetic_result;
|
|
1315
|
+
} else {
|
|
1316
|
+
if ((operator === "symbol-name")) {
|
|
1317
|
+
if ((!__eliscript_truthy(((__eliscript_value_120) => (__eliscript_truthy(__eliscript_value_120) ? symbol_node_p(((((values) ?? [])[0]) ?? null)) : __eliscript_value_120))(((values)["length"] === 1))))) {
|
|
1318
|
+
(__eliscript_tdz_read_2())("symbol-name expects a symbol");
|
|
1319
|
+
}
|
|
1320
|
+
return literal_node(node_name(((((values) ?? [])[0]) ?? null)), null);
|
|
1321
|
+
} else {
|
|
1322
|
+
if ((operator === "intern")) {
|
|
1323
|
+
if ((!__eliscript_truthy(((__eliscript_value_121) => (__eliscript_truthy(__eliscript_value_121) ? ((__eliscript_value_122) => (__eliscript_truthy(__eliscript_value_122) ? (typeof values[0].value === "string") : __eliscript_value_122))(literal_node_p(((((values) ?? [])[0]) ?? null))) : __eliscript_value_121))(((values)["length"] === 1))))) {
|
|
1324
|
+
(__eliscript_tdz_read_2())("intern expects a string");
|
|
1325
|
+
}
|
|
1326
|
+
{
|
|
1327
|
+
const __eliscript_value_123 = node_value(((((values) ?? [])[0]) ?? null));
|
|
1328
|
+
{
|
|
1329
|
+
let name = __eliscript_value_123;
|
|
1330
|
+
reserve_name(scope, name);
|
|
1331
|
+
return symbol_node(name, null);
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
} else {
|
|
1335
|
+
if (((operator === "concat") || (operator === "str"))) {
|
|
1336
|
+
{
|
|
1337
|
+
const __eliscript_value_124 = [];
|
|
1338
|
+
{
|
|
1339
|
+
let pieces = __eliscript_value_124;
|
|
1340
|
+
(values)["forEach"](((value) => {
|
|
1341
|
+
return (pieces)["push"](value_string(value));
|
|
1342
|
+
}));
|
|
1343
|
+
return literal_node(__eliscript_at_direct(pieces, "join", ""), null);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
} else {
|
|
1347
|
+
return (__eliscript_tdz_read_2())((String("unsupported macro function: ") + String(operator)));
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
455
1365
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
(__eliscript_truthy((!__eliscript_truthy(((args)["length"] <= 1)))) ? raise_error("gensym expects 0..1 arguments") : null);
|
|
464
|
-
return allocate_name(scope, (__eliscript_truthy(((args)["length"] === 0)) ? literal_node("G", null) : eval_form(((((args) ?? [])[0]) ?? null), scope)));
|
|
465
|
-
})() : (__eliscript_truthy((operator === "macro-read-file")) ? (() => {
|
|
466
|
-
(__eliscript_truthy((!__eliscript_truthy(((args)["length"] === 1)))) ? raise_error("macro-read-file expects 1 argument") : null);
|
|
467
|
-
return ((specifier_node) => {
|
|
468
|
-
return ((context) => {
|
|
469
|
-
return (() => {
|
|
470
|
-
(__eliscript_truthy((!__eliscript_truthy(((__eliscript_value_79) => (__eliscript_truthy(__eliscript_value_79) ? ((__eliscript_value_80) => (__eliscript_truthy(__eliscript_value_80) ? ((node_value(specifier_node))["length"] > 0) : __eliscript_value_80))((typeof specifier_node.value === "string")) : __eliscript_value_79))(literal_node_p(specifier_node))))) ? raise_error("macro-read-file expects a non-empty string") : null);
|
|
471
|
-
return ((specifier) => {
|
|
472
|
-
(__eliscript_truthy((!__eliscript_truthy(((context)["capabilities"])["has"]("read-file")))) ? raise_error("macro capability is not enabled: read-file") : null);
|
|
473
|
-
(__eliscript_truthy((!__eliscript_truthy(((context)["files"])["has"](specifier)))) ? raise_error((String("macro file dependency is not declared: ") + String(specifier))) : null);
|
|
474
|
-
return literal_node(((context)["files"])["get"](specifier), null);
|
|
475
|
-
})(node_value(specifier_node));
|
|
476
|
-
})();
|
|
477
|
-
})((scope)["context"]);
|
|
478
|
-
})(eval_form(((((args) ?? [])[0]) ?? null), scope));
|
|
479
|
-
})() : ((values) => {
|
|
480
|
-
return ((list_result) => {
|
|
481
|
-
return ((predicate_result) => {
|
|
482
|
-
return ((arithmetic_result) => {
|
|
483
|
-
return (__eliscript_truthy((!__eliscript_truthy((list_result === undefined)))) ? list_result : (__eliscript_truthy((!__eliscript_truthy((predicate_result === undefined)))) ? predicate_result : (__eliscript_truthy((!__eliscript_truthy((arithmetic_result === undefined)))) ? arithmetic_result : (__eliscript_truthy((operator === "symbol-name")) ? (() => {
|
|
484
|
-
(__eliscript_truthy((!__eliscript_truthy(((__eliscript_value_82) => (__eliscript_truthy(__eliscript_value_82) ? symbol_node_p(((((values) ?? [])[0]) ?? null)) : __eliscript_value_82))(((values)["length"] === 1))))) ? raise_error("symbol-name expects a symbol") : null);
|
|
485
|
-
return literal_node(node_name(((((values) ?? [])[0]) ?? null)), null);
|
|
486
|
-
})() : (__eliscript_truthy((operator === "intern")) ? (() => {
|
|
487
|
-
(__eliscript_truthy((!__eliscript_truthy(((__eliscript_value_83) => (__eliscript_truthy(__eliscript_value_83) ? ((__eliscript_value_84) => (__eliscript_truthy(__eliscript_value_84) ? (typeof values[0].value === "string") : __eliscript_value_84))(literal_node_p(((((values) ?? [])[0]) ?? null))) : __eliscript_value_83))(((values)["length"] === 1))))) ? raise_error("intern expects a string") : null);
|
|
488
|
-
return ((name) => {
|
|
489
|
-
reserve_name(scope, name);
|
|
490
|
-
return symbol_node(name, null);
|
|
491
|
-
})(node_value(((((values) ?? [])[0]) ?? null)));
|
|
492
|
-
})() : (__eliscript_truthy(((__eliscript_value_85) => (__eliscript_truthy(__eliscript_value_85) ? __eliscript_value_85 : (operator === "str")))((operator === "concat"))) ? ((pieces) => {
|
|
493
|
-
(values)["forEach"]((value) => {
|
|
494
|
-
return (pieces)["push"](value_string(value));
|
|
495
|
-
});
|
|
496
|
-
return literal_node((pieces)["join"](""), null);
|
|
497
|
-
})([]) : raise_error((String("unsupported macro function: ") + String(operator)))))))));
|
|
498
|
-
})((__eliscript_truthy(((__eliscript_value_81) => (__eliscript_truthy(__eliscript_value_81) ? (predicate_result === undefined) : __eliscript_value_81))((list_result === undefined))) ? eval_arithmetic(operator, values) : undefined));
|
|
499
|
-
})((__eliscript_truthy((list_result === undefined)) ? eval_predicate(operator, values) : undefined));
|
|
500
|
-
})(eval_list_operation(operator, values));
|
|
501
|
-
})(eval_args(args, scope)))))))))))))))));
|
|
502
|
-
})(node_name(operator_node));
|
|
503
|
-
})();
|
|
504
|
-
})((items)["slice"](1));
|
|
505
|
-
})(((((items) ?? [])[0]) ?? null));
|
|
506
|
-
})(node_items(form));
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
507
1373
|
}
|
|
508
1374
|
function eval_form(form, scope) {
|
|
509
|
-
|
|
1375
|
+
if (__eliscript_truthy(symbol_node_p(form))) {
|
|
1376
|
+
return scope_value(scope, node_name(form));
|
|
1377
|
+
} else {
|
|
1378
|
+
if (__eliscript_truthy(((__eliscript_value_125) => (__eliscript_truthy(__eliscript_value_125) ? __eliscript_value_125 : ((__eliscript_value_126) => (__eliscript_truthy(__eliscript_value_126) ? __eliscript_value_126 : ((__eliscript_value_127) => (__eliscript_truthy(__eliscript_value_127) ? __eliscript_value_127 : vector_node_p(form)))((node_kind(form) === "undefined"))))(keyword_node_p(form))))(literal_node_p(form)))) {
|
|
1379
|
+
return form;
|
|
1380
|
+
} else {
|
|
1381
|
+
if ((node_kind(form) === "list")) {
|
|
1382
|
+
return eval_call(form, scope);
|
|
1383
|
+
} else {
|
|
1384
|
+
return (__eliscript_tdz_read_2())((String("unsupported macro value: ") + String(node_display(form))));
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
510
1388
|
}
|
|
511
1389
|
function parameter_list_display(parameters) {
|
|
512
1390
|
return node_display(parameters);
|
|
513
1391
|
}
|
|
514
1392
|
function parse_parameters(parameters, context, span) {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
1393
|
+
{
|
|
1394
|
+
const __eliscript_value_128 = list_items(parameters);
|
|
1395
|
+
{
|
|
1396
|
+
let items = __eliscript_value_128;
|
|
1397
|
+
if ((items === undefined)) {
|
|
1398
|
+
expander_fail(context, span, (String("macro parameters must be a list: ") + String(parameter_list_display(parameters))));
|
|
1399
|
+
}
|
|
1400
|
+
{
|
|
1401
|
+
const __eliscript_value_129 = [];
|
|
1402
|
+
const __eliscript_value_130 = [];
|
|
1403
|
+
const __eliscript_value_131 = undefined;
|
|
1404
|
+
const __eliscript_value_132 = "required";
|
|
1405
|
+
const __eliscript_value_133 = 0;
|
|
1406
|
+
{
|
|
1407
|
+
let required = __eliscript_value_129;
|
|
1408
|
+
let optional = __eliscript_value_130;
|
|
1409
|
+
let rest_name = __eliscript_value_131;
|
|
1410
|
+
let mode = __eliscript_value_132;
|
|
1411
|
+
let index = __eliscript_value_133;
|
|
1412
|
+
while (__eliscript_numeric_relation("<", index, (items)["length"])) {
|
|
1413
|
+
{
|
|
1414
|
+
const __eliscript_value_134 = ((((items) ?? [])[index]) ?? null);
|
|
1415
|
+
{
|
|
1416
|
+
let parameter = __eliscript_value_134;
|
|
1417
|
+
if ((!__eliscript_truthy(symbol_node_p(parameter)))) {
|
|
1418
|
+
expander_fail(context, span, (String("macro parameters must be symbols: ") + String(parameter_list_display(parameters))));
|
|
1419
|
+
}
|
|
1420
|
+
{
|
|
1421
|
+
const __eliscript_value_135 = node_name(parameter);
|
|
1422
|
+
{
|
|
1423
|
+
let name = __eliscript_value_135;
|
|
1424
|
+
if ((name === "&optional")) {
|
|
1425
|
+
if (((mode === "rest") || (!(rest_name === undefined)))) {
|
|
1426
|
+
expander_fail(context, span, "invalid macro parameter list");
|
|
1427
|
+
}
|
|
1428
|
+
((mode = "optional"));
|
|
1429
|
+
} else {
|
|
1430
|
+
if (((name === "&rest") || (name === "&body"))) {
|
|
1431
|
+
if (((mode === "rest") || (!(rest_name === undefined)))) {
|
|
1432
|
+
expander_fail(context, span, "invalid macro parameter list");
|
|
1433
|
+
}
|
|
1434
|
+
((mode = "rest"));
|
|
1435
|
+
} else {
|
|
1436
|
+
if ((mode === "rest")) {
|
|
1437
|
+
((rest_name = name));
|
|
1438
|
+
((mode = "done"));
|
|
1439
|
+
} else {
|
|
1440
|
+
if ((mode === "done")) {
|
|
1441
|
+
expander_fail(context, span, "invalid macro parameter list");
|
|
1442
|
+
} else {
|
|
1443
|
+
if ((mode === "required")) {
|
|
1444
|
+
(required)["push"](name);
|
|
1445
|
+
} else {
|
|
1446
|
+
(optional)["push"](name);
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
((index = (index + 1)));
|
|
1457
|
+
}
|
|
1458
|
+
if ((mode === "rest")) {
|
|
1459
|
+
expander_fail(context, span, "invalid macro parameter list");
|
|
1460
|
+
}
|
|
1461
|
+
return ({"required": required, "optional": optional, "rest": rest_name});
|
|
536
1462
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
return ({"required": required, "optional": optional, "rest": rest_name});
|
|
541
|
-
})([], [], undefined, "required", 0);
|
|
542
|
-
})(list_items(parameters));
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
543
1466
|
}
|
|
544
1467
|
function register_macro(form, environment, context) {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
1468
|
+
{
|
|
1469
|
+
let items = node_items(form);
|
|
1470
|
+
let args = (items)["slice"](1);
|
|
1471
|
+
let span = node_span(form);
|
|
1472
|
+
if ((!__eliscript_numeric_relation(">=", (args)["length"], 2))) {
|
|
1473
|
+
expander_fail(context, span, "defmacro expects a name and parameter list");
|
|
1474
|
+
}
|
|
1475
|
+
{
|
|
1476
|
+
const __eliscript_value_136 = ((((args) ?? [])[0]) ?? null);
|
|
1477
|
+
const __eliscript_value_137 = ((((args) ?? [])[1]) ?? null);
|
|
1478
|
+
{
|
|
1479
|
+
let name_node = __eliscript_value_136;
|
|
1480
|
+
let parameters = __eliscript_value_137;
|
|
1481
|
+
if ((!__eliscript_truthy(symbol_node_p(name_node)))) {
|
|
1482
|
+
expander_fail(context, span, (String("macro name must be a symbol: ") + String(node_display(name_node))));
|
|
1483
|
+
}
|
|
1484
|
+
{
|
|
1485
|
+
const __eliscript_value_138 = node_name(name_node);
|
|
1486
|
+
{
|
|
1487
|
+
let name = __eliscript_value_138;
|
|
1488
|
+
if (__eliscript_truthy((environment)["has"](name))) {
|
|
1489
|
+
expander_fail(context, span, (String("duplicate macro definition: ") + String(name)));
|
|
1490
|
+
}
|
|
1491
|
+
return (environment)["set"](name, ({"name": name, "definitionSpan": node_span(name_node), "parameters": parse_parameters(parameters, context, span), "body": (args)["slice"](2)}));
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
function expand_user_macro(definition, args, environment, depth, context, span, top_level) {
|
|
1499
|
+
{
|
|
1500
|
+
let events = ((context)["originEvents"] ?? null);
|
|
1501
|
+
let parent = ((context)["originParent"] ?? null);
|
|
1502
|
+
let event = null;
|
|
1503
|
+
if (__eliscript_truthy(events)) {
|
|
1504
|
+
((event = ({"id": ((events) ?? []).length, "macroName": (definition)["name"], "definitionSpan": ((definition)["definitionSpan"] ?? null), "callSpan": span, "parent": parent, "depth": depth, "status": "expanding"})));
|
|
1505
|
+
(events)["push"](event);
|
|
1506
|
+
((context)["originParent"] = (event)["id"]);
|
|
1507
|
+
}
|
|
1508
|
+
return (() => {
|
|
1509
|
+
try {
|
|
1510
|
+
{
|
|
1511
|
+
let generated = locate_generated(invoke_macro(definition, args, depth, context, span), span);
|
|
1512
|
+
let result = (__eliscript_truthy(top_level) ? expand_top_level(generated, environment, (depth + 1), context) : expand_expression(generated, environment, (depth + 1), context));
|
|
1513
|
+
if (__eliscript_truthy(event)) {
|
|
1514
|
+
((event)["status"] = "expanded");
|
|
1515
|
+
}
|
|
1516
|
+
return result;
|
|
1517
|
+
}
|
|
1518
|
+
} catch (error) {
|
|
1519
|
+
if (__eliscript_truthy(event)) {
|
|
1520
|
+
((event)["status"] = "failed");
|
|
1521
|
+
}
|
|
1522
|
+
return ((__eliscript_value_139) => { throw __eliscript_value_139; })(error);
|
|
1523
|
+
} finally {
|
|
1524
|
+
if (__eliscript_truthy(events)) {
|
|
1525
|
+
((context)["originParent"] = parent);
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
})();
|
|
1529
|
+
}
|
|
561
1530
|
}
|
|
562
1531
|
function bind_macro_args(definition, args, context) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
1532
|
+
{
|
|
1533
|
+
let parameters = (definition)["parameters"];
|
|
1534
|
+
let required = (parameters)["required"];
|
|
1535
|
+
let optional = (parameters)["optional"];
|
|
1536
|
+
let rest_name = (parameters)["rest"];
|
|
1537
|
+
let minimum = (required)["length"];
|
|
1538
|
+
let maximum = (minimum + (optional)["length"]);
|
|
1539
|
+
let count = (args)["length"];
|
|
1540
|
+
let scope = make_eval_scope(null, context);
|
|
1541
|
+
if (__eliscript_numeric_relation("<", count, minimum)) {
|
|
1542
|
+
(__eliscript_tdz_read_2())((String("wrong number of arguments for ") + String((definition)["name"])));
|
|
1543
|
+
}
|
|
1544
|
+
if (((rest_name === undefined) && __eliscript_numeric_relation(">", count, maximum))) {
|
|
1545
|
+
(__eliscript_tdz_read_2())((String("wrong number of arguments for ") + String((definition)["name"])));
|
|
1546
|
+
}
|
|
1547
|
+
{
|
|
1548
|
+
const __eliscript_value_140 = 0;
|
|
1549
|
+
{
|
|
1550
|
+
let index = __eliscript_value_140;
|
|
1551
|
+
(required)["forEach"](((name) => {
|
|
1552
|
+
scope_bind(scope, name, ((((args) ?? [])[index]) ?? null));
|
|
1553
|
+
return ((index = (index + 1)));
|
|
1554
|
+
}));
|
|
1555
|
+
(optional)["forEach"](((name) => {
|
|
1556
|
+
scope_bind(scope, name, (__eliscript_numeric_relation("<", index, count) ? ((((args) ?? [])[index]) ?? null) : literal_node(null, null)));
|
|
1557
|
+
return ((index = (index + 1)));
|
|
1558
|
+
}));
|
|
1559
|
+
if ((!(rest_name === undefined))) {
|
|
1560
|
+
scope_bind(scope, rest_name, make_list((args)["slice"](index), null));
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
return scope;
|
|
1565
|
+
}
|
|
595
1566
|
}
|
|
596
1567
|
function invoke_macro(definition, args, depth, context, span) {
|
|
597
|
-
(
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
1568
|
+
if (__eliscript_numeric_relation(">=", depth, (__eliscript_tdz_read_0()))) {
|
|
1569
|
+
expander_fail(context, span, (String("macro expansion exceeded ") + String((__eliscript_tdz_read_0())) + String(" steps near ") + String((definition)["name"])));
|
|
1570
|
+
}
|
|
1571
|
+
return (__eliscript_tdz_read_4())((() => {
|
|
1572
|
+
{
|
|
1573
|
+
const __eliscript_value_141 = bind_macro_args(definition, args, context);
|
|
1574
|
+
{
|
|
1575
|
+
let scope = __eliscript_value_141;
|
|
1576
|
+
return eval_sequence((definition)["body"], scope);
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
}), ((message) => {
|
|
603
1580
|
return expander_fail(context, span, (String("macro ") + String((definition)["name"]) + String(" failed: ") + String(message)));
|
|
604
|
-
});
|
|
1581
|
+
}));
|
|
605
1582
|
}
|
|
606
1583
|
function expand_sequence(forms, environment, depth, context) {
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
1584
|
+
{
|
|
1585
|
+
const __eliscript_value_142 = [];
|
|
1586
|
+
{
|
|
1587
|
+
let result = __eliscript_value_142;
|
|
1588
|
+
(forms)["forEach"](((form) => {
|
|
1589
|
+
return (result)["push"](expand_expression(form, environment, depth, context));
|
|
1590
|
+
}));
|
|
1591
|
+
return result;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
613
1594
|
}
|
|
614
1595
|
function expand_binding(binding, environment, depth, context) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
1596
|
+
{
|
|
1597
|
+
const __eliscript_value_143 = list_items(binding);
|
|
1598
|
+
{
|
|
1599
|
+
let items = __eliscript_value_143;
|
|
1600
|
+
if (((items === undefined) || ((items)["length"] === 0))) {
|
|
1601
|
+
return binding;
|
|
1602
|
+
} else {
|
|
1603
|
+
{
|
|
1604
|
+
const __eliscript_value_144 = [((((items) ?? [])[0]) ?? null)];
|
|
1605
|
+
{
|
|
1606
|
+
let expanded = __eliscript_value_144;
|
|
1607
|
+
((items)["slice"](1))["forEach"](((item) => {
|
|
1608
|
+
return (expanded)["push"](expand_expression(item, environment, depth, context));
|
|
1609
|
+
}));
|
|
1610
|
+
return expand_collection_result("list", binding, expanded, context);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
623
1616
|
}
|
|
624
1617
|
function expand_bindings(args, environment, depth, context) {
|
|
625
|
-
|
|
626
|
-
return
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
1618
|
+
if (((args)["length"] === 0)) {
|
|
1619
|
+
return args;
|
|
1620
|
+
} else {
|
|
1621
|
+
{
|
|
1622
|
+
let bindings_form = ((((args) ?? [])[0]) ?? null);
|
|
1623
|
+
let bindings = list_items(bindings_form);
|
|
1624
|
+
let result = [];
|
|
1625
|
+
if ((bindings === undefined)) {
|
|
1626
|
+
(result)["push"](bindings_form);
|
|
1627
|
+
} else {
|
|
1628
|
+
{
|
|
1629
|
+
const __eliscript_value_145 = [];
|
|
1630
|
+
{
|
|
1631
|
+
let expanded_bindings = __eliscript_value_145;
|
|
1632
|
+
(bindings)["forEach"](((binding) => {
|
|
631
1633
|
return (expanded_bindings)["push"](expand_binding(binding, environment, depth, context));
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}
|
|
642
|
-
}
|
|
1634
|
+
}));
|
|
1635
|
+
(result)["push"](expand_collection_result("list", bindings_form, expanded_bindings, context));
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
(expand_sequence((args)["slice"](1), environment, depth, context))["forEach"](((item) => {
|
|
1640
|
+
return (result)["push"](item);
|
|
1641
|
+
}));
|
|
1642
|
+
return result;
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
643
1645
|
}
|
|
644
1646
|
function expand_alternating(args, environment, depth, context, expand_even, literal_key_mode) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
1647
|
+
{
|
|
1648
|
+
const __eliscript_value_146 = [];
|
|
1649
|
+
const __eliscript_value_147 = 0;
|
|
1650
|
+
{
|
|
1651
|
+
let result = __eliscript_value_146;
|
|
1652
|
+
let index = __eliscript_value_147;
|
|
1653
|
+
(args)["forEach"](((item) => {
|
|
1654
|
+
{
|
|
1655
|
+
const __eliscript_value_148 = ((__eliscript_numeric_rem(index, 2) === 0) ? expand_even : true);
|
|
1656
|
+
{
|
|
1657
|
+
let expand = __eliscript_value_148;
|
|
1658
|
+
if (__eliscript_truthy(((__eliscript_value_149) => (__eliscript_truthy(__eliscript_value_149) ? ((__eliscript_value_150) => (__eliscript_truthy(__eliscript_value_150) ? ((__eliscript_value_151) => (__eliscript_truthy(__eliscript_value_151) ? __eliscript_value_151 : ((__eliscript_value_152) => (__eliscript_truthy(__eliscript_value_152) ? __eliscript_value_152 : ((__eliscript_value_153) => (__eliscript_truthy(__eliscript_value_153) ? (typeof item.value === "string") : __eliscript_value_153))(literal_node_p(item))))(symbol_node_p(item))))(keyword_node_p(item)) : __eliscript_value_150))((__eliscript_numeric_rem(index, 2) === 0)) : __eliscript_value_149))(literal_key_mode))) {
|
|
1659
|
+
((expand = false));
|
|
1660
|
+
}
|
|
1661
|
+
(result)["push"]((__eliscript_truthy(expand) ? expand_expression(item, environment, depth, context) : item));
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
return ((index = (index + 1)));
|
|
1665
|
+
}));
|
|
1666
|
+
return result;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
655
1669
|
}
|
|
656
1670
|
function expand_property_call(args, environment, depth, context) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
1671
|
+
{
|
|
1672
|
+
const __eliscript_value_154 = [];
|
|
1673
|
+
const __eliscript_value_155 = 0;
|
|
1674
|
+
{
|
|
1675
|
+
let result = __eliscript_value_154;
|
|
1676
|
+
let index = __eliscript_value_155;
|
|
1677
|
+
(args)["forEach"](((item) => {
|
|
1678
|
+
(result)["push"]((__eliscript_truthy(((__eliscript_value_156) => (__eliscript_truthy(__eliscript_value_156) ? ((__eliscript_value_157) => (__eliscript_truthy(__eliscript_value_157) ? __eliscript_value_157 : ((__eliscript_value_158) => (__eliscript_truthy(__eliscript_value_158) ? (typeof item.value === "string") : __eliscript_value_158))(literal_node_p(item))))(keyword_node_p(item)) : __eliscript_value_156))((index === 1))) ? item : expand_expression(item, environment, depth, context)));
|
|
1679
|
+
return ((index = (index + 1)));
|
|
1680
|
+
}));
|
|
1681
|
+
return result;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
664
1684
|
}
|
|
665
1685
|
function expand_cond(clauses, environment, depth, context) {
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
1686
|
+
{
|
|
1687
|
+
const __eliscript_value_159 = [];
|
|
1688
|
+
{
|
|
1689
|
+
let result = __eliscript_value_159;
|
|
1690
|
+
(clauses)["forEach"](((clause) => {
|
|
1691
|
+
{
|
|
1692
|
+
const __eliscript_value_160 = list_items(clause);
|
|
1693
|
+
{
|
|
1694
|
+
let items = __eliscript_value_160;
|
|
1695
|
+
return (result)["push"](((items === undefined) ? clause : expand_collection_result("list", clause, expand_sequence(items, environment, depth, context), context)));
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}));
|
|
1699
|
+
return result;
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
674
1702
|
}
|
|
675
1703
|
function expand_try_clause(clause, environment, depth, context) {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
1704
|
+
{
|
|
1705
|
+
let items = list_items(clause);
|
|
1706
|
+
let operator = ((__eliscript_value_161) => (__eliscript_truthy(__eliscript_value_161) ? ((__eliscript_value_162) => (__eliscript_truthy(__eliscript_value_162) ? ((__eliscript_value_163) => (__eliscript_truthy(__eliscript_value_163) ? node_name(((((items) ?? [])[0]) ?? null)) : __eliscript_value_163))(symbol_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_162))(__eliscript_numeric_relation(">", (items)["length"], 0)) : __eliscript_value_161))((!(items === undefined)));
|
|
1707
|
+
if ((operator === "catch")) {
|
|
1708
|
+
if (__eliscript_numeric_relation(">", (items)["length"], 1)) {
|
|
1709
|
+
{
|
|
1710
|
+
const __eliscript_value_164 = [((((items) ?? [])[0]) ?? null), ((((items) ?? [])[1]) ?? null)];
|
|
1711
|
+
{
|
|
1712
|
+
let expanded = __eliscript_value_164;
|
|
1713
|
+
(expand_sequence((items)["slice"](2), environment, depth, context))["forEach"](((item) => {
|
|
1714
|
+
return (expanded)["push"](item);
|
|
1715
|
+
}));
|
|
1716
|
+
return expand_collection_result("list", clause, expanded, context);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
} else {
|
|
1720
|
+
return clause;
|
|
1721
|
+
}
|
|
1722
|
+
} else {
|
|
1723
|
+
if ((operator === "finally")) {
|
|
1724
|
+
{
|
|
1725
|
+
const __eliscript_value_165 = [((((items) ?? [])[0]) ?? null)];
|
|
1726
|
+
{
|
|
1727
|
+
let expanded = __eliscript_value_165;
|
|
1728
|
+
(expand_sequence((items)["slice"](1), environment, depth, context))["forEach"](((item) => {
|
|
1729
|
+
return (expanded)["push"](item);
|
|
1730
|
+
}));
|
|
1731
|
+
return expand_collection_result("list", clause, expanded, context);
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
} else {
|
|
1735
|
+
return expand_expression(clause, environment, depth, context);
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
691
1739
|
}
|
|
692
1740
|
function desugar_defmulti(args, context, span) {
|
|
693
|
-
(
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
1741
|
+
if ((__eliscript_numeric_relation("<", (args)["length"], 2) || __eliscript_numeric_relation(">", (args)["length"], 3))) {
|
|
1742
|
+
expander_fail(context, span, "defmulti expects a name, dispatch function, and optional default value");
|
|
1743
|
+
}
|
|
1744
|
+
{
|
|
1745
|
+
const __eliscript_value_166 = ((((args) ?? [])[0]) ?? null);
|
|
1746
|
+
{
|
|
1747
|
+
let name_node = __eliscript_value_166;
|
|
1748
|
+
if ((!__eliscript_truthy(symbol_node_p(name_node)))) {
|
|
1749
|
+
expander_fail(context, span, (String("defmulti name must be a symbol: ") + String(node_display(name_node))));
|
|
1750
|
+
}
|
|
1751
|
+
{
|
|
1752
|
+
const __eliscript_value_167 = [symbol_node("multi-fn", span), literal_node(node_name(name_node), span), ((((args) ?? [])[1]) ?? null)];
|
|
1753
|
+
{
|
|
1754
|
+
let call_items = __eliscript_value_167;
|
|
1755
|
+
if (((args)["length"] === 3)) {
|
|
1756
|
+
(call_items)["push"](((((args) ?? [])[2]) ?? null));
|
|
1757
|
+
}
|
|
1758
|
+
return make_list([symbol_node("defconst", span), name_node, make_list(call_items, span)], span);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
701
1763
|
}
|
|
702
1764
|
function desugar_defmethod(args, context, span) {
|
|
703
|
-
(
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
1765
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 3)) {
|
|
1766
|
+
expander_fail(context, span, "defmethod expects a multimethod, dispatch value, and parameter list");
|
|
1767
|
+
}
|
|
1768
|
+
{
|
|
1769
|
+
const __eliscript_value_168 = ((((args) ?? [])[0]) ?? null);
|
|
1770
|
+
{
|
|
1771
|
+
let target_node = __eliscript_value_168;
|
|
1772
|
+
if ((!__eliscript_truthy(symbol_node_p(target_node)))) {
|
|
1773
|
+
expander_fail(context, span, (String("defmethod target must be a symbol: ") + String(node_display(target_node))));
|
|
1774
|
+
}
|
|
1775
|
+
{
|
|
1776
|
+
const __eliscript_value_169 = [symbol_node("lambda", span), ((((args) ?? [])[2]) ?? null)];
|
|
1777
|
+
{
|
|
1778
|
+
let lambda_items = __eliscript_value_169;
|
|
1779
|
+
((args)["slice"](3))["forEach"](((item) => {
|
|
1780
|
+
return (lambda_items)["push"](item);
|
|
1781
|
+
}));
|
|
1782
|
+
return make_list([symbol_node("add-method!", span), target_node, ((((args) ?? [])[1]) ?? null), make_list(lambda_items, span)], span);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
713
1787
|
}
|
|
714
1788
|
function thread_step(value_node, step_node, position, context, span) {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
1789
|
+
{
|
|
1790
|
+
const __eliscript_value_170 = list_items(step_node);
|
|
1791
|
+
{
|
|
1792
|
+
let step_items = __eliscript_value_170;
|
|
1793
|
+
if (__eliscript_truthy(symbol_node_p(step_node))) {
|
|
1794
|
+
return make_list([step_node, value_node], node_span(step_node));
|
|
1795
|
+
} else {
|
|
1796
|
+
if (((!(step_items === undefined)) && __eliscript_numeric_relation(">", (step_items)["length"], 0))) {
|
|
1797
|
+
if ((position === "first")) {
|
|
1798
|
+
return make_list(([((((step_items) ?? [])[0]) ?? null), value_node])["concat"]((step_items)["slice"](1)), node_span(step_node));
|
|
1799
|
+
} else {
|
|
1800
|
+
return make_list((step_items)["concat"]([value_node]), node_span(step_node));
|
|
1801
|
+
}
|
|
1802
|
+
} else {
|
|
1803
|
+
return expander_fail(context, span, (String("thread step must be a symbol or non-empty list: ") + String(node_display(step_node))));
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
718
1808
|
}
|
|
719
1809
|
function desugar_thread(form_name, args, position, context, span) {
|
|
720
|
-
(
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
1810
|
+
if (((args)["length"] === 0)) {
|
|
1811
|
+
expander_fail(context, span, (String(form_name) + String(" expects an initial expression")));
|
|
1812
|
+
}
|
|
1813
|
+
{
|
|
1814
|
+
const __eliscript_value_171 = ((((args) ?? [])[0]) ?? null);
|
|
1815
|
+
{
|
|
1816
|
+
let result = __eliscript_value_171;
|
|
1817
|
+
((args)["slice"](1))["forEach"](((step_node) => {
|
|
1818
|
+
return ((result = thread_step(result, step_node, position, context, span)));
|
|
1819
|
+
}));
|
|
1820
|
+
return result;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
727
1823
|
}
|
|
728
1824
|
function fresh_name_node(prefix, context, span) {
|
|
729
1825
|
return symbol_node(node_name(allocate_name(make_eval_scope(null, context), literal_node(prefix, null))), span);
|
|
730
1826
|
}
|
|
731
1827
|
function make_let_form(name_node, value_node, body_node, span) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
})(((__eliscript_value_107) => (__eliscript_truthy(__eliscript_value_107) ? __eliscript_value_107 : span))(node_span(value_node)));
|
|
1828
|
+
{
|
|
1829
|
+
let value_span = ((__eliscript_value_172) => (__eliscript_truthy(__eliscript_value_172) ? __eliscript_value_172 : span))(node_span(value_node));
|
|
1830
|
+
let binding = make_list([name_node, value_node], value_span);
|
|
1831
|
+
let bindings = make_list([binding], value_span);
|
|
1832
|
+
return make_list([symbol_node("let", value_span), bindings, body_node], value_span);
|
|
1833
|
+
}
|
|
739
1834
|
}
|
|
740
1835
|
function desugar_as_thread(args, context, span) {
|
|
741
|
-
(
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1836
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 3)) {
|
|
1837
|
+
expander_fail(context, span, "as-> expects an initial expression, binding name, and at least one form");
|
|
1838
|
+
}
|
|
1839
|
+
{
|
|
1840
|
+
const __eliscript_value_173 = ((((args) ?? [])[0]) ?? null);
|
|
1841
|
+
const __eliscript_value_174 = ((((args) ?? [])[1]) ?? null);
|
|
1842
|
+
const __eliscript_value_175 = (args)["slice"](2);
|
|
1843
|
+
{
|
|
1844
|
+
let initial_node = __eliscript_value_173;
|
|
1845
|
+
let name_node = __eliscript_value_174;
|
|
1846
|
+
let step_nodes = __eliscript_value_175;
|
|
1847
|
+
if ((!__eliscript_truthy(symbol_node_p(name_node)))) {
|
|
1848
|
+
expander_fail(context, span, (String("as-> binding name must be a symbol: ") + String(node_display(name_node))));
|
|
1849
|
+
}
|
|
1850
|
+
{
|
|
1851
|
+
const __eliscript_value_176 = __eliscript_numeric_sub((step_nodes)["length"], 2);
|
|
1852
|
+
const __eliscript_value_177 = ((((step_nodes) ?? [])[__eliscript_numeric_decrement((step_nodes)["length"])]) ?? null);
|
|
1853
|
+
{
|
|
1854
|
+
let index = __eliscript_value_176;
|
|
1855
|
+
let body_node = __eliscript_value_177;
|
|
1856
|
+
while (__eliscript_numeric_relation(">=", index, 0)) {
|
|
1857
|
+
((body_node = make_let_form(name_node, ((((step_nodes) ?? [])[index]) ?? null), body_node, span)));
|
|
1858
|
+
((index = __eliscript_numeric_decrement(index)));
|
|
1859
|
+
}
|
|
1860
|
+
return make_let_form(name_node, initial_node, body_node, span);
|
|
749
1861
|
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
})(((step_nodes)["length"] - 2), ((((step_nodes) ?? [])[((step_nodes)["length"] - 1)]) ?? null));
|
|
754
|
-
})(((((args) ?? [])[0]) ?? null), ((((args) ?? [])[1]) ?? null), (args)["slice"](2));
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
755
1865
|
}
|
|
756
1866
|
function desugar_cond_thread(form_name, args, position, context, span) {
|
|
757
|
-
(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
1867
|
+
if (((args)["length"] === 0)) {
|
|
1868
|
+
expander_fail(context, span, (String(form_name) + String(" expects an initial expression")));
|
|
1869
|
+
}
|
|
1870
|
+
{
|
|
1871
|
+
const __eliscript_value_178 = __eliscript_numeric_decrement((args)["length"]);
|
|
1872
|
+
{
|
|
1873
|
+
let clause_count = __eliscript_value_178;
|
|
1874
|
+
if ((__eliscript_numeric_rem(clause_count, 2) === 1)) {
|
|
1875
|
+
expander_fail(context, span, (String(form_name) + String(" expects test and step pairs")));
|
|
1876
|
+
}
|
|
1877
|
+
if ((clause_count === 0)) {
|
|
1878
|
+
return ((((args) ?? [])[0]) ?? null);
|
|
1879
|
+
} else {
|
|
1880
|
+
{
|
|
1881
|
+
const __eliscript_value_179 = fresh_name_node("thread", context, span);
|
|
1882
|
+
const __eliscript_value_180 = undefined;
|
|
1883
|
+
const __eliscript_value_181 = __eliscript_numeric_sub((args)["length"], 2);
|
|
1884
|
+
{
|
|
1885
|
+
let name_node = __eliscript_value_179;
|
|
1886
|
+
let body_node = __eliscript_value_180;
|
|
1887
|
+
let index = __eliscript_value_181;
|
|
1888
|
+
((body_node = name_node));
|
|
1889
|
+
while (__eliscript_numeric_relation(">=", index, 1)) {
|
|
1890
|
+
{
|
|
1891
|
+
let test_node = ((((args) ?? [])[index]) ?? null);
|
|
1892
|
+
let step_node = ((((args) ?? [])[(index + 1)]) ?? null);
|
|
1893
|
+
let if_node = make_list([symbol_node("if", span), test_node, thread_step(name_node, step_node, position, context, span), name_node], span);
|
|
1894
|
+
((body_node = make_let_form(name_node, if_node, body_node, span)));
|
|
1895
|
+
}
|
|
1896
|
+
((index = __eliscript_numeric_sub(index, 2)));
|
|
1897
|
+
}
|
|
1898
|
+
return make_let_form(name_node, ((((args) ?? [])[0]) ?? null), body_node, span);
|
|
1899
|
+
}
|
|
772
1900
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
})(fresh_name_node("thread", context, span), undefined, ((args)["length"] - 2)));
|
|
777
|
-
})(((args)["length"] - 1));
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
778
1904
|
}
|
|
779
1905
|
function desugar_some_thread(form_name, args, position, context, span) {
|
|
780
|
-
(
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
1906
|
+
if (((args)["length"] === 0)) {
|
|
1907
|
+
expander_fail(context, span, (String(form_name) + String(" expects an initial expression")));
|
|
1908
|
+
}
|
|
1909
|
+
if (((args)["length"] === 1)) {
|
|
1910
|
+
return ((((args) ?? [])[0]) ?? null);
|
|
1911
|
+
} else {
|
|
1912
|
+
{
|
|
1913
|
+
const __eliscript_value_182 = fresh_name_node("thread", context, span);
|
|
1914
|
+
const __eliscript_value_183 = undefined;
|
|
1915
|
+
const __eliscript_value_184 = __eliscript_numeric_decrement((args)["length"]);
|
|
1916
|
+
{
|
|
1917
|
+
let name_node = __eliscript_value_182;
|
|
1918
|
+
let body_node = __eliscript_value_183;
|
|
1919
|
+
let index = __eliscript_value_184;
|
|
1920
|
+
((body_node = name_node));
|
|
1921
|
+
while (__eliscript_numeric_relation(">=", index, 1)) {
|
|
1922
|
+
{
|
|
1923
|
+
let step_node = ((((args) ?? [])[index]) ?? null);
|
|
1924
|
+
let next_node = make_let_form(name_node, thread_step(name_node, step_node, position, context, span), body_node, span);
|
|
1925
|
+
((body_node = make_list([symbol_node("if", span), conditional_test(name_node, true, span), next_node, literal_node(null, span)], span)));
|
|
1926
|
+
}
|
|
1927
|
+
((index = __eliscript_numeric_decrement(index)));
|
|
1928
|
+
}
|
|
1929
|
+
return make_let_form(name_node, ((((args) ?? [])[0]) ?? null), body_node, span);
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
796
1933
|
}
|
|
797
1934
|
function conditional_binding(form_name, binding_node, context, span) {
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
1935
|
+
{
|
|
1936
|
+
const __eliscript_value_185 = list_items(binding_node);
|
|
1937
|
+
{
|
|
1938
|
+
let binding_items = __eliscript_value_185;
|
|
1939
|
+
if ((!((!(binding_items === undefined)) && ((binding_items)["length"] === 2)))) {
|
|
1940
|
+
expander_fail(context, span, (String(form_name) + String(" binding must contain a name and initializer: ") + String(node_display(binding_node))));
|
|
1941
|
+
}
|
|
1942
|
+
if ((!__eliscript_truthy(symbol_node_p(((((binding_items) ?? [])[0]) ?? null))))) {
|
|
1943
|
+
expander_fail(context, span, (String(form_name) + String(" binding name must be a symbol: ") + String(node_display(((((binding_items) ?? [])[0]) ?? null)))));
|
|
1944
|
+
}
|
|
1945
|
+
return binding_items;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
803
1948
|
}
|
|
804
1949
|
function conditional_test(name_node, some_p, span) {
|
|
805
|
-
|
|
1950
|
+
if (__eliscript_truthy(some_p)) {
|
|
1951
|
+
return make_list([symbol_node("not", span), make_list([symbol_node("nil?", span), name_node], span)], span);
|
|
1952
|
+
} else {
|
|
1953
|
+
return name_node;
|
|
1954
|
+
}
|
|
806
1955
|
}
|
|
807
1956
|
function desugar_if_binding(form_name, args, some_p, context, span) {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
})(conditional_binding(form_name, ((((args) ?? [])[0]) ?? null), context, span));
|
|
1957
|
+
if ((__eliscript_numeric_relation("<", (args)["length"], 2) || __eliscript_numeric_relation(">", (args)["length"], 3))) {
|
|
1958
|
+
expander_fail(context, span, (String(form_name) + String(" expects a binding, then form, and optional else form")));
|
|
1959
|
+
}
|
|
1960
|
+
{
|
|
1961
|
+
let binding_items = conditional_binding(form_name, ((((args) ?? [])[0]) ?? null), context, span);
|
|
1962
|
+
let name_node = ((((binding_items) ?? [])[0]) ?? null);
|
|
1963
|
+
let initializer_node = ((((binding_items) ?? [])[1]) ?? null);
|
|
1964
|
+
let else_node = (((args)["length"] === 3) ? ((((args) ?? [])[2]) ?? null) : literal_node(null, span));
|
|
1965
|
+
let if_node = make_list([symbol_node("if", span), conditional_test(name_node, some_p, span), ((((args) ?? [])[1]) ?? null), else_node], span);
|
|
1966
|
+
return make_let_form(name_node, initializer_node, if_node, span);
|
|
1967
|
+
}
|
|
820
1968
|
}
|
|
821
1969
|
function desugar_when_binding(form_name, args, some_p, context, span) {
|
|
822
|
-
(
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
})(conditional_binding(form_name, ((((args) ?? [])[0]) ?? null), context, span));
|
|
1970
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 2)) {
|
|
1971
|
+
expander_fail(context, span, (String(form_name) + String(" expects a binding and at least one body form")));
|
|
1972
|
+
}
|
|
1973
|
+
{
|
|
1974
|
+
let binding_items = conditional_binding(form_name, ((((args) ?? [])[0]) ?? null), context, span);
|
|
1975
|
+
let name_node = ((((binding_items) ?? [])[0]) ?? null);
|
|
1976
|
+
let initializer_node = ((((binding_items) ?? [])[1]) ?? null);
|
|
1977
|
+
let body_node = make_list(([symbol_node("progn", span)])["concat"]((args)["slice"](1)), span);
|
|
1978
|
+
let if_node = make_list([symbol_node("if", span), conditional_test(name_node, some_p, span), body_node, literal_node(null, span)], span);
|
|
1979
|
+
return make_let_form(name_node, initializer_node, if_node, span);
|
|
1980
|
+
}
|
|
834
1981
|
}
|
|
835
1982
|
function quoted_value(node, span) {
|
|
836
|
-
return make_list([symbol_node("quote", node_span(node)), node], ((
|
|
1983
|
+
return make_list([symbol_node("quote", node_span(node)), node], ((__eliscript_value_186) => (__eliscript_truthy(__eliscript_value_186) ? __eliscript_value_186 : span))(node_span(node)));
|
|
837
1984
|
}
|
|
838
1985
|
function case_constants(match_node) {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1986
|
+
{
|
|
1987
|
+
const __eliscript_value_187 = list_items(match_node);
|
|
1988
|
+
{
|
|
1989
|
+
let items = __eliscript_value_187;
|
|
1990
|
+
if (((!(items === undefined)) && __eliscript_numeric_relation(">", (items)["length"], 0))) {
|
|
1991
|
+
return items;
|
|
1992
|
+
} else {
|
|
1993
|
+
return [match_node];
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
842
1997
|
}
|
|
843
1998
|
function desugar_case(args, context, span) {
|
|
844
|
-
(
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
1999
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 3)) {
|
|
2000
|
+
expander_fail(context, span, "case expects a dispatch expression and at least one match/result pair");
|
|
2001
|
+
}
|
|
2002
|
+
{
|
|
2003
|
+
const __eliscript_value_188 = ((((args) ?? [])[0]) ?? null);
|
|
2004
|
+
{
|
|
2005
|
+
let dispatch_node = __eliscript_value_188;
|
|
2006
|
+
{
|
|
2007
|
+
const __eliscript_value_189 = (args)["slice"](1);
|
|
2008
|
+
{
|
|
2009
|
+
let remaining = __eliscript_value_189;
|
|
2010
|
+
{
|
|
2011
|
+
const __eliscript_value_190 = (__eliscript_numeric_rem((remaining)["length"], 2) === 1);
|
|
2012
|
+
{
|
|
2013
|
+
let has_default = __eliscript_value_190;
|
|
2014
|
+
{
|
|
2015
|
+
const __eliscript_value_191 = (__eliscript_truthy(has_default) ? ((((remaining) ?? [])[__eliscript_numeric_decrement((remaining)["length"])]) ?? null) : literal_node(null, span));
|
|
2016
|
+
{
|
|
2017
|
+
let default_node = __eliscript_value_191;
|
|
2018
|
+
{
|
|
2019
|
+
const __eliscript_value_192 = (__eliscript_truthy(has_default) ? __eliscript_numeric_decrement((remaining)["length"]) : (remaining)["length"]);
|
|
2020
|
+
{
|
|
2021
|
+
let pair_limit = __eliscript_value_192;
|
|
2022
|
+
{
|
|
2023
|
+
const __eliscript_value_193 = fresh_name_node("case-value", context, span);
|
|
2024
|
+
{
|
|
2025
|
+
let dispatch_name = __eliscript_value_193;
|
|
2026
|
+
{
|
|
2027
|
+
const __eliscript_value_194 = new (Set)();
|
|
2028
|
+
{
|
|
2029
|
+
let seen = __eliscript_value_194;
|
|
2030
|
+
{
|
|
2031
|
+
let cond_items = [];
|
|
2032
|
+
let index = 0;
|
|
2033
|
+
while (__eliscript_numeric_relation("<", index, pair_limit)) {
|
|
2034
|
+
{
|
|
2035
|
+
let match_node = ((((remaining) ?? [])[index]) ?? null);
|
|
2036
|
+
let result_node = ((((remaining) ?? [])[(index + 1)]) ?? null);
|
|
2037
|
+
let constants = case_constants(match_node);
|
|
2038
|
+
let comparisons = [];
|
|
2039
|
+
let constant_index = 0;
|
|
2040
|
+
while (__eliscript_numeric_relation("<", constant_index, (constants)["length"])) {
|
|
2041
|
+
{
|
|
2042
|
+
let constant_node = ((((constants) ?? [])[constant_index]) ?? null);
|
|
2043
|
+
let identity = node_display(constant_node);
|
|
2044
|
+
if (__eliscript_truthy((seen)["has"](identity))) {
|
|
2045
|
+
expander_fail(context, span, (String("case declares duplicate match constant: ") + String(identity)));
|
|
875
2046
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
2047
|
+
(seen)["add"](identity);
|
|
2048
|
+
(comparisons)["push"](make_list([symbol_node("equal", node_span(constant_node)), dispatch_name, quoted_value(constant_node, span)], ((__eliscript_value_195) => (__eliscript_truthy(__eliscript_value_195) ? __eliscript_value_195 : span))(node_span(constant_node))));
|
|
2049
|
+
}
|
|
2050
|
+
((constant_index = (constant_index + 1)));
|
|
2051
|
+
}
|
|
2052
|
+
(cond_items)["push"](make_list([(((comparisons)["length"] === 1) ? ((((comparisons) ?? [])[0]) ?? null) : make_list(([symbol_node("or", node_span(match_node))])["concat"](comparisons), ((__eliscript_value_196) => (__eliscript_truthy(__eliscript_value_196) ? __eliscript_value_196 : span))(node_span(match_node)))), result_node], ((__eliscript_value_197) => (__eliscript_truthy(__eliscript_value_197) ? __eliscript_value_197 : span))(node_span(match_node))));
|
|
2053
|
+
}
|
|
2054
|
+
((index = (index + 2)));
|
|
2055
|
+
}
|
|
2056
|
+
(cond_items)["push"](make_list([literal_node(true, span), default_node], span));
|
|
2057
|
+
return make_let_form(dispatch_name, dispatch_node, make_list(([symbol_node("cond", span)])["concat"](cond_items), span), span);
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
886
2061
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
})((((remaining)["length"] % 2) === 1));
|
|
899
|
-
})((args)["slice"](1));
|
|
900
|
-
})(((((args) ?? [])[0]) ?? null));
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
901
2073
|
}
|
|
902
2074
|
function condp_redirect_p(node) {
|
|
903
|
-
return ((
|
|
2075
|
+
return ((__eliscript_value_198) => (__eliscript_truthy(__eliscript_value_198) ? (node_name(node) === ">>") : __eliscript_value_198))(keyword_node_p(node));
|
|
904
2076
|
}
|
|
905
2077
|
function condp_no_match_form(span) {
|
|
906
2078
|
return make_list([symbol_node("throw", span), make_list([symbol_node("new", span), symbol_node("globalThis/TypeError", span), literal_node("condp found no matching clause", span)], span)], span);
|
|
907
2079
|
}
|
|
908
2080
|
function desugar_condp(args, context, span) {
|
|
909
|
-
(
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
})(fresh_name_node("condp-result", context, span));
|
|
943
|
-
})((clause)["result"]);
|
|
944
|
-
})((clause)["test"]);
|
|
945
|
-
})(((((clauses) ?? [])[clause_index]) ?? null));
|
|
946
|
-
((clause_index = (clause_index - 1)));
|
|
2081
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 4)) {
|
|
2082
|
+
expander_fail(context, span, "condp expects a predicate, dispatch expression, and at least one clause");
|
|
2083
|
+
}
|
|
2084
|
+
{
|
|
2085
|
+
const __eliscript_value_199 = ((((args) ?? [])[0]) ?? null);
|
|
2086
|
+
const __eliscript_value_200 = ((((args) ?? [])[1]) ?? null);
|
|
2087
|
+
const __eliscript_value_201 = (args)["slice"](2);
|
|
2088
|
+
const __eliscript_value_202 = [];
|
|
2089
|
+
const __eliscript_value_203 = 0;
|
|
2090
|
+
{
|
|
2091
|
+
let predicate_node = __eliscript_value_199;
|
|
2092
|
+
let dispatch_node = __eliscript_value_200;
|
|
2093
|
+
let remaining = __eliscript_value_201;
|
|
2094
|
+
let clauses = __eliscript_value_202;
|
|
2095
|
+
let index = __eliscript_value_203;
|
|
2096
|
+
while (__eliscript_numeric_relation("<", (index + 1), (remaining)["length"])) {
|
|
2097
|
+
{
|
|
2098
|
+
const __eliscript_value_204 = ((((remaining) ?? [])[index]) ?? null);
|
|
2099
|
+
const __eliscript_value_205 = ((((remaining) ?? [])[(index + 1)]) ?? null);
|
|
2100
|
+
{
|
|
2101
|
+
let test_node = __eliscript_value_204;
|
|
2102
|
+
let result_or_marker = __eliscript_value_205;
|
|
2103
|
+
if (__eliscript_truthy(condp_redirect_p(result_or_marker))) {
|
|
2104
|
+
if (__eliscript_numeric_relation(">=", (index + 2), (remaining)["length"])) {
|
|
2105
|
+
expander_fail(context, span, "condp :>> clause requires a result function");
|
|
2106
|
+
}
|
|
2107
|
+
(clauses)["push"](({"test": test_node, "result": ((((remaining) ?? [])[(index + 2)]) ?? null), "redirect": true}));
|
|
2108
|
+
((index = (index + 3)));
|
|
2109
|
+
} else {
|
|
2110
|
+
(clauses)["push"](({"test": test_node, "result": result_or_marker, "redirect": false}));
|
|
2111
|
+
((index = (index + 2)));
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
947
2114
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
2115
|
+
}
|
|
2116
|
+
if (((clauses)["length"] === 0)) {
|
|
2117
|
+
expander_fail(context, span, "condp expects a predicate, dispatch expression, and at least one clause");
|
|
2118
|
+
}
|
|
2119
|
+
{
|
|
2120
|
+
const __eliscript_value_206 = (__eliscript_numeric_relation("<", index, (remaining)["length"]) ? ((((remaining) ?? [])[index]) ?? null) : condp_no_match_form(span));
|
|
2121
|
+
const __eliscript_value_207 = fresh_name_node("condp-predicate", context, span);
|
|
2122
|
+
const __eliscript_value_208 = fresh_name_node("condp-value", context, span);
|
|
2123
|
+
const __eliscript_value_209 = null;
|
|
2124
|
+
const __eliscript_value_210 = __eliscript_numeric_decrement((clauses)["length"]);
|
|
2125
|
+
{
|
|
2126
|
+
let default_node = __eliscript_value_206;
|
|
2127
|
+
let predicate_name = __eliscript_value_207;
|
|
2128
|
+
let dispatch_name = __eliscript_value_208;
|
|
2129
|
+
let body_node = __eliscript_value_209;
|
|
2130
|
+
let clause_index = __eliscript_value_210;
|
|
2131
|
+
((body_node = default_node));
|
|
2132
|
+
while (__eliscript_numeric_relation(">=", clause_index, 0)) {
|
|
2133
|
+
{
|
|
2134
|
+
let clause = ((((clauses) ?? [])[clause_index]) ?? null);
|
|
2135
|
+
let test_node = (clause)["test"];
|
|
2136
|
+
let result_node = (clause)["result"];
|
|
2137
|
+
let match_name = fresh_name_node("condp-result", context, span);
|
|
2138
|
+
let predicate_call = make_list([symbol_node("funcall", node_span(test_node)), predicate_name, test_node, dispatch_name], ((__eliscript_value_211) => (__eliscript_truthy(__eliscript_value_211) ? __eliscript_value_211 : span))(node_span(test_node)));
|
|
2139
|
+
let selected_node = (__eliscript_truthy((clause)["redirect"]) ? make_list([symbol_node("funcall", node_span(result_node)), result_node, match_name], ((__eliscript_value_212) => (__eliscript_truthy(__eliscript_value_212) ? __eliscript_value_212 : span))(node_span(result_node))) : result_node);
|
|
2140
|
+
let if_node = make_list([symbol_node("if", node_span(test_node)), match_name, selected_node, body_node], ((__eliscript_value_213) => (__eliscript_truthy(__eliscript_value_213) ? __eliscript_value_213 : span))(node_span(test_node)));
|
|
2141
|
+
((body_node = make_let_form(match_name, predicate_call, if_node, span)));
|
|
2142
|
+
}
|
|
2143
|
+
((clause_index = __eliscript_numeric_decrement(clause_index)));
|
|
2144
|
+
}
|
|
2145
|
+
return make_let_form(predicate_name, predicate_node, make_let_form(dispatch_name, dispatch_node, body_node, span), span);
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
953
2150
|
}
|
|
954
2151
|
function multi_arity_clause_p(node) {
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
2152
|
+
{
|
|
2153
|
+
const __eliscript_value_214 = list_items(node);
|
|
2154
|
+
{
|
|
2155
|
+
let items = __eliscript_value_214;
|
|
2156
|
+
return ((__eliscript_value_215) => (__eliscript_truthy(__eliscript_value_215) ? ((__eliscript_value_216) => (__eliscript_truthy(__eliscript_value_216) ? ((__eliscript_value_217) => (__eliscript_truthy(__eliscript_value_217) ? (!__eliscript_truthy(map_node_p(((((items) ?? [])[0]) ?? null)))) : __eliscript_value_217))(list_node_p(((((items) ?? [])[0]) ?? null))) : __eliscript_value_216))(__eliscript_numeric_relation(">", (items)["length"], 0)) : __eliscript_value_215))((!(items === undefined)));
|
|
2157
|
+
}
|
|
2158
|
+
}
|
|
958
2159
|
}
|
|
959
2160
|
function multi_arity_layout(parameters, context, span) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
2161
|
+
{
|
|
2162
|
+
const __eliscript_value_218 = list_items(parameters);
|
|
2163
|
+
const __eliscript_value_219 = 0;
|
|
2164
|
+
const __eliscript_value_220 = false;
|
|
2165
|
+
const __eliscript_value_221 = 0;
|
|
2166
|
+
{
|
|
2167
|
+
let items = __eliscript_value_218;
|
|
2168
|
+
let required = __eliscript_value_219;
|
|
2169
|
+
let variadic = __eliscript_value_220;
|
|
2170
|
+
let index = __eliscript_value_221;
|
|
2171
|
+
if ((items === undefined)) {
|
|
2172
|
+
expander_fail(context, span, "multi-arity clause parameters must be a list");
|
|
2173
|
+
}
|
|
2174
|
+
while (__eliscript_numeric_relation("<", index, (items)["length"])) {
|
|
2175
|
+
{
|
|
2176
|
+
let parameter = ((((items) ?? [])[index]) ?? null);
|
|
2177
|
+
let name = ((__eliscript_value_222) => (__eliscript_truthy(__eliscript_value_222) ? node_name(parameter) : __eliscript_value_222))(symbol_node_p(parameter));
|
|
2178
|
+
if (((name === "&optional") || (name === "&body"))) {
|
|
2179
|
+
expander_fail(context, ((__eliscript_value_223) => (__eliscript_truthy(__eliscript_value_223) ? __eliscript_value_223 : span))(node_span(parameter)), (String("multi-arity clauses do not support ") + String(name)));
|
|
2180
|
+
} else {
|
|
2181
|
+
if ((name === "&rest")) {
|
|
2182
|
+
{
|
|
2183
|
+
const __eliscript_value_224 = ((((items) ?? [])[(index + 1)]) ?? null);
|
|
2184
|
+
{
|
|
2185
|
+
let rest_node = __eliscript_value_224;
|
|
2186
|
+
if ((!__eliscript_truthy(((__eliscript_value_225) => (__eliscript_truthy(__eliscript_value_225) ? ((__eliscript_value_226) => (__eliscript_truthy(__eliscript_value_226) ? (!__eliscript_truthy((["&optional", "&rest", "&body"])["includes"](node_name(rest_node)))) : __eliscript_value_226))(symbol_node_p(rest_node)) : __eliscript_value_225))(((index + 2) === (items)["length"]))))) {
|
|
2187
|
+
expander_fail(context, ((__eliscript_value_227) => (__eliscript_truthy(__eliscript_value_227) ? __eliscript_value_227 : span))(node_span(parameter)), "multi-arity clause requires one final &rest symbol");
|
|
2188
|
+
}
|
|
2189
|
+
((variadic = true));
|
|
2190
|
+
((index = (items)["length"]));
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
} else {
|
|
971
2194
|
((required = (required + 1)));
|
|
972
|
-
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
}
|
|
2195
|
+
((index = (index + 1)));
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
976
2199
|
}
|
|
977
|
-
return
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
})(list_items(parameters), 0, false, 0);
|
|
2200
|
+
return ({"required": required, "variadic": variadic});
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
981
2203
|
}
|
|
982
2204
|
function multi_arity_clauses(forms, context, span) {
|
|
983
|
-
(
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
2205
|
+
if (__eliscript_numeric_relation("<", (forms)["length"], 2)) {
|
|
2206
|
+
expander_fail(context, span, "multi-arity function requires at least two clauses");
|
|
2207
|
+
}
|
|
2208
|
+
{
|
|
2209
|
+
const __eliscript_value_228 = new (Set)();
|
|
2210
|
+
const __eliscript_value_229 = [];
|
|
2211
|
+
const __eliscript_value_230 = false;
|
|
2212
|
+
const __eliscript_value_231 = null;
|
|
2213
|
+
const __eliscript_value_232 = [];
|
|
2214
|
+
const __eliscript_value_233 = 0;
|
|
2215
|
+
{
|
|
2216
|
+
let fixed = __eliscript_value_228;
|
|
2217
|
+
let fixed_arities = __eliscript_value_229;
|
|
2218
|
+
let variadic = __eliscript_value_230;
|
|
2219
|
+
let variadic_minimum = __eliscript_value_231;
|
|
2220
|
+
let clauses = __eliscript_value_232;
|
|
2221
|
+
let index = __eliscript_value_233;
|
|
2222
|
+
while (__eliscript_numeric_relation("<", index, (forms)["length"])) {
|
|
2223
|
+
{
|
|
2224
|
+
let form = ((((forms) ?? [])[index]) ?? null);
|
|
2225
|
+
let items = list_items(form);
|
|
2226
|
+
if (((items === undefined) || __eliscript_numeric_relation("<", (items)["length"], 2) || (!__eliscript_truthy(list_node_p(((((items) ?? [])[0]) ?? null)))))) {
|
|
2227
|
+
expander_fail(context, ((__eliscript_value_234) => (__eliscript_truthy(__eliscript_value_234) ? __eliscript_value_234 : span))(node_span(form)), "multi-arity clause requires a parameter list and body");
|
|
2228
|
+
}
|
|
2229
|
+
{
|
|
2230
|
+
let layout = multi_arity_layout(((((items) ?? [])[0]) ?? null), context, ((__eliscript_value_235) => (__eliscript_truthy(__eliscript_value_235) ? __eliscript_value_235 : span))(node_span(form)));
|
|
2231
|
+
let required = (layout)["required"];
|
|
2232
|
+
let variadic_clause = (layout)["variadic"];
|
|
2233
|
+
let clause = ({"form": form, "parameters": ((((items) ?? [])[0]) ?? null), "body": (items)["slice"](1), "required": required, "variadic": variadic_clause});
|
|
2234
|
+
if (__eliscript_truthy(variadic_clause)) {
|
|
2235
|
+
if (__eliscript_truthy(variadic)) {
|
|
2236
|
+
expander_fail(context, ((__eliscript_value_236) => (__eliscript_truthy(__eliscript_value_236) ? __eliscript_value_236 : span))(node_span(form)), "multi-arity function declares more than one variadic clause");
|
|
2237
|
+
}
|
|
2238
|
+
((variadic = true));
|
|
2239
|
+
((variadic_minimum = required));
|
|
2240
|
+
} else {
|
|
2241
|
+
if (__eliscript_truthy((fixed)["has"](required))) {
|
|
2242
|
+
expander_fail(context, ((__eliscript_value_237) => (__eliscript_truthy(__eliscript_value_237) ? __eliscript_value_237 : span))(node_span(form)), (String("multi-arity function declares duplicate fixed arity: ") + String(required)));
|
|
2243
|
+
}
|
|
2244
|
+
(fixed)["add"](required);
|
|
2245
|
+
(fixed_arities)["push"](required);
|
|
2246
|
+
}
|
|
2247
|
+
(clauses)["push"](clause);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
1014
2250
|
((index = (index + 1)));
|
|
1015
2251
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
2252
|
+
if (__eliscript_truthy(variadic)) {
|
|
2253
|
+
{
|
|
2254
|
+
const __eliscript_value_238 = 0;
|
|
2255
|
+
{
|
|
2256
|
+
let arity_index = __eliscript_value_238;
|
|
2257
|
+
while (__eliscript_numeric_relation("<", arity_index, (fixed_arities)["length"])) {
|
|
2258
|
+
{
|
|
2259
|
+
const __eliscript_value_239 = ((((fixed_arities) ?? [])[arity_index]) ?? null);
|
|
2260
|
+
{
|
|
2261
|
+
let arity = __eliscript_value_239;
|
|
2262
|
+
if (__eliscript_numeric_relation(">=", arity, variadic_minimum)) {
|
|
2263
|
+
expander_fail(context, span, (String("multi-arity fixed arity ") + String(arity) + String(" is unreachable behind variadic arity ") + String(variadic_minimum)));
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
((arity_index = (arity_index + 1)));
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
1025
2270
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
})(new Set(), [], false, null, [], 0);
|
|
2271
|
+
}
|
|
2272
|
+
return clauses;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
1031
2275
|
}
|
|
1032
2276
|
function desugar_multi_arity(operator_node, name_node, clause_forms, source_node, context, span) {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
return ((result_items) => {
|
|
1075
|
-
return (() => {
|
|
1076
|
-
(__eliscript_truthy(name_node) ? (result_items)["push"](name_node) : null);
|
|
1077
|
-
(result_items)["push"](parameters);
|
|
1078
|
-
(result_items)["push"](dispatch);
|
|
1079
|
-
return make_list(result_items, node_span(source_node));
|
|
1080
|
-
})();
|
|
1081
|
-
})([operator_node]);
|
|
1082
|
-
})(make_list([symbol_node("&rest", span), arguments_name], span));
|
|
1083
|
-
})(make_let_form(arity_name, arity_value, make_list(([symbol_node("cond", span)])["concat"](cond_clauses), span), span));
|
|
1084
|
-
})(make_list([symbol_node("js-length", span), arguments_name], span));
|
|
1085
|
-
})();
|
|
1086
|
-
})(0);
|
|
1087
|
-
})([]);
|
|
1088
|
-
})((__eliscript_truthy(name_node) ? node_display(name_node) : "anonymous function"));
|
|
1089
|
-
})((__eliscript_truthy(((__eliscript_value_134) => (__eliscript_truthy(__eliscript_value_134) ? __eliscript_value_134 : (operator === "defasync")))((operator === "async"))) ? "async" : "lambda"));
|
|
1090
|
-
})(fresh_name_node("arity-count", context, span));
|
|
1091
|
-
})(fresh_name_node("arity-arguments", context, span));
|
|
1092
|
-
})(multi_arity_clauses(clause_forms, context, span));
|
|
1093
|
-
})(node_name(operator_node));
|
|
2277
|
+
{
|
|
2278
|
+
let operator = node_name(operator_node);
|
|
2279
|
+
let clauses = multi_arity_clauses(clause_forms, context, span);
|
|
2280
|
+
let arguments_name = fresh_name_node("arity-arguments", context, span);
|
|
2281
|
+
let arity_name = fresh_name_node("arity-count", context, span);
|
|
2282
|
+
let branch_operator = (((operator === "async") || (operator === "defasync")) ? "async" : "lambda");
|
|
2283
|
+
let label = (__eliscript_truthy(name_node) ? node_display(name_node) : "anonymous function");
|
|
2284
|
+
let cond_clauses = [];
|
|
2285
|
+
let index = 0;
|
|
2286
|
+
while (__eliscript_numeric_relation("<", index, (clauses)["length"])) {
|
|
2287
|
+
{
|
|
2288
|
+
let clause = ((((clauses) ?? [])[index]) ?? null);
|
|
2289
|
+
let clause_node = (clause)["form"];
|
|
2290
|
+
let clause_span = ((__eliscript_value_240) => (__eliscript_truthy(__eliscript_value_240) ? __eliscript_value_240 : span))(node_span(clause_node));
|
|
2291
|
+
let comparison = make_list([symbol_node((__eliscript_truthy((clause)["variadic"]) ? ">=" : "="), clause_span), arity_name, literal_node((clause)["required"], clause_span)], clause_span);
|
|
2292
|
+
let branch_items = [symbol_node(branch_operator, clause_span), (clause)["parameters"]];
|
|
2293
|
+
let branch = null;
|
|
2294
|
+
let selected = null;
|
|
2295
|
+
((clause)["body"])["forEach"](((body_node) => {
|
|
2296
|
+
return (branch_items)["push"](body_node);
|
|
2297
|
+
}));
|
|
2298
|
+
((branch = make_list(branch_items, clause_span)));
|
|
2299
|
+
((selected = make_list([symbol_node("apply", clause_span), branch, arguments_name], clause_span)));
|
|
2300
|
+
(cond_clauses)["push"](make_list([comparison, selected], clause_span));
|
|
2301
|
+
}
|
|
2302
|
+
((index = (index + 1)));
|
|
2303
|
+
}
|
|
2304
|
+
(cond_clauses)["push"](make_list([literal_node(true, span), make_list([symbol_node("__eliscript_arity_error", span), literal_node(label, span), arity_name], span)], span));
|
|
2305
|
+
{
|
|
2306
|
+
let arity_value = make_list([symbol_node("js-length", span), arguments_name], span);
|
|
2307
|
+
let dispatch = make_let_form(arity_name, arity_value, make_list(([symbol_node("cond", span)])["concat"](cond_clauses), span), span);
|
|
2308
|
+
let parameters = make_list([symbol_node("&rest", span), arguments_name], span);
|
|
2309
|
+
let result_items = [operator_node];
|
|
2310
|
+
if (__eliscript_truthy(name_node)) {
|
|
2311
|
+
(result_items)["push"](name_node);
|
|
2312
|
+
}
|
|
2313
|
+
(result_items)["push"](parameters);
|
|
2314
|
+
(result_items)["push"](dispatch);
|
|
2315
|
+
return make_list(result_items, node_span(source_node));
|
|
2316
|
+
}
|
|
2317
|
+
}
|
|
1094
2318
|
}
|
|
1095
2319
|
function desugar_letfn(args, source_node, context, span) {
|
|
1096
|
-
(
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
})
|
|
1146
|
-
|
|
2320
|
+
if (((args)["length"] === 0)) {
|
|
2321
|
+
expander_fail(context, span, "letfn requires a binding list");
|
|
2322
|
+
}
|
|
2323
|
+
if (((args)["length"] === 1)) {
|
|
2324
|
+
expander_fail(context, span, "letfn requires at least one body form");
|
|
2325
|
+
}
|
|
2326
|
+
{
|
|
2327
|
+
let bindings_node = ((((args) ?? [])[0]) ?? null);
|
|
2328
|
+
let declarations = list_items(bindings_node);
|
|
2329
|
+
let bindings = [];
|
|
2330
|
+
let assignments = [];
|
|
2331
|
+
if ((declarations === undefined)) {
|
|
2332
|
+
expander_fail(context, span, "letfn bindings must be a list");
|
|
2333
|
+
}
|
|
2334
|
+
(declarations)["forEach"](((declaration) => {
|
|
2335
|
+
{
|
|
2336
|
+
let declaration_span = ((__eliscript_value_241) => (__eliscript_truthy(__eliscript_value_241) ? __eliscript_value_241 : span))(node_span(declaration));
|
|
2337
|
+
let items = list_items(declaration);
|
|
2338
|
+
if (((items === undefined) || __eliscript_numeric_relation("<", (items)["length"], 3))) {
|
|
2339
|
+
expander_fail(context, declaration_span, "letfn declaration requires a name, parameter list, and body");
|
|
2340
|
+
}
|
|
2341
|
+
{
|
|
2342
|
+
let name_node = ((((items) ?? [])[0]) ?? null);
|
|
2343
|
+
let marker_node = ((((items) ?? [])[1]) ?? null);
|
|
2344
|
+
let async_function = ((__eliscript_value_242) => (__eliscript_truthy(__eliscript_value_242) ? (node_name(marker_node) === "async") : __eliscript_value_242))(symbol_node_p(marker_node));
|
|
2345
|
+
let function_forms = (items)["slice"]((__eliscript_truthy(async_function) ? 2 : 1));
|
|
2346
|
+
let operator_node = symbol_node((__eliscript_truthy(async_function) ? "async" : "lambda"), declaration_span);
|
|
2347
|
+
let parameters = ((((function_forms) ?? [])[0]) ?? null);
|
|
2348
|
+
let function_node = null;
|
|
2349
|
+
if ((!__eliscript_truthy(symbol_node_p(name_node)))) {
|
|
2350
|
+
expander_fail(context, declaration_span, (String("letfn name must be a symbol: ") + String(node_display(name_node))));
|
|
2351
|
+
}
|
|
2352
|
+
if ((!__eliscript_truthy(list_node_p(parameters)))) {
|
|
2353
|
+
expander_fail(context, declaration_span, "letfn declaration requires a parameter list");
|
|
2354
|
+
}
|
|
2355
|
+
((function_node = (__eliscript_truthy(multi_arity_clause_p(parameters)) ? ((named) => {
|
|
2356
|
+
return ((named_items) => {
|
|
2357
|
+
return make_list(([((((named_items) ?? [])[0]) ?? null)])["concat"]((named_items)["slice"](2)), node_span(named));
|
|
2358
|
+
})(node_items(named));
|
|
2359
|
+
})(desugar_multi_arity(operator_node, name_node, function_forms, declaration, context, declaration_span)) : (() => {
|
|
2360
|
+
if (((function_forms)["length"] === 1)) {
|
|
2361
|
+
expander_fail(context, declaration_span, "letfn declaration requires a function body");
|
|
2362
|
+
}
|
|
2363
|
+
return make_list(([operator_node])["concat"](function_forms), declaration_span);
|
|
2364
|
+
})())));
|
|
2365
|
+
(bindings)["push"](make_list([name_node, literal_node(null, declaration_span)], declaration_span));
|
|
2366
|
+
return (assignments)["push"](make_list([symbol_node("set!", declaration_span), name_node, function_node], declaration_span));
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
}));
|
|
2370
|
+
return make_list(([symbol_node("let", span), make_list(bindings, span)])["concat"](assignments, (args)["slice"](1)), node_span(source_node));
|
|
2371
|
+
}
|
|
1147
2372
|
}
|
|
1148
2373
|
function desugar_defprotocol(args, context, span) {
|
|
1149
|
-
(
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
2374
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 2)) {
|
|
2375
|
+
expander_fail(context, span, "defprotocol expects a name and at least one operation");
|
|
2376
|
+
}
|
|
2377
|
+
{
|
|
2378
|
+
const __eliscript_value_243 = ((((args) ?? [])[0]) ?? null);
|
|
2379
|
+
{
|
|
2380
|
+
let name_node = __eliscript_value_243;
|
|
2381
|
+
{
|
|
2382
|
+
const __eliscript_value_244 = (args)["slice"](1);
|
|
2383
|
+
{
|
|
2384
|
+
let operation_nodes = __eliscript_value_244;
|
|
2385
|
+
{
|
|
2386
|
+
const __eliscript_value_245 = new (Set)();
|
|
2387
|
+
{
|
|
2388
|
+
let seen = __eliscript_value_245;
|
|
2389
|
+
{
|
|
2390
|
+
let operation_names = [];
|
|
2391
|
+
let forms = [];
|
|
2392
|
+
if ((!__eliscript_truthy(symbol_node_p(name_node)))) {
|
|
2393
|
+
expander_fail(context, span, (String("defprotocol name must be a symbol: ") + String(node_display(name_node))));
|
|
2394
|
+
}
|
|
2395
|
+
(operation_nodes)["forEach"](((operation_node) => {
|
|
2396
|
+
if ((!__eliscript_truthy(symbol_node_p(operation_node)))) {
|
|
2397
|
+
expander_fail(context, span, (String("defprotocol operation must be a symbol: ") + String(node_display(operation_node))));
|
|
2398
|
+
}
|
|
2399
|
+
{
|
|
2400
|
+
const __eliscript_value_246 = node_name(operation_node);
|
|
2401
|
+
{
|
|
2402
|
+
let operation_name = __eliscript_value_246;
|
|
2403
|
+
if (__eliscript_truthy((seen)["has"](operation_name))) {
|
|
2404
|
+
expander_fail(context, span, (String("defprotocol declares duplicate operation: ") + String(operation_name)));
|
|
2405
|
+
}
|
|
2406
|
+
(seen)["add"](operation_name);
|
|
2407
|
+
return (operation_names)["push"](literal_node(operation_name, node_span(operation_node)));
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
}));
|
|
2411
|
+
(forms)["push"](make_list([symbol_node("defconst", span), name_node, make_list([symbol_node("define-protocol", span), literal_node(node_name(name_node), node_span(name_node)), make_list(([symbol_node("js-array", span)])["concat"](operation_names), span)], span)], span));
|
|
2412
|
+
(operation_nodes)["forEach"](((operation_node) => {
|
|
2413
|
+
return (forms)["push"](make_list([symbol_node("defconst", span), operation_node, make_list([symbol_node("protocol-method", span), name_node, literal_node(node_name(operation_node), node_span(operation_node))], span)], span));
|
|
2414
|
+
}));
|
|
2415
|
+
return forms;
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
1176
2423
|
}
|
|
1177
2424
|
function desugar_defrecord(args, context, span) {
|
|
1178
|
-
(
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
((
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
2425
|
+
if (((__eliscript_value_247, __eliscript_value_248) => (__eliscript_value_247 !== __eliscript_value_248))((args)["length"], 2)) {
|
|
2426
|
+
expander_fail(context, span, "defrecord expects a name and field vector");
|
|
2427
|
+
}
|
|
2428
|
+
{
|
|
2429
|
+
const __eliscript_value_249 = ((((args) ?? [])[0]) ?? null);
|
|
2430
|
+
{
|
|
2431
|
+
let name_node = __eliscript_value_249;
|
|
2432
|
+
{
|
|
2433
|
+
const __eliscript_value_250 = ((((args) ?? [])[1]) ?? null);
|
|
2434
|
+
{
|
|
2435
|
+
let fields_node = __eliscript_value_250;
|
|
2436
|
+
{
|
|
2437
|
+
const __eliscript_value_251 = new (Set)();
|
|
2438
|
+
{
|
|
2439
|
+
let seen = __eliscript_value_251;
|
|
2440
|
+
{
|
|
2441
|
+
let field_nodes = [];
|
|
2442
|
+
let field_names = [];
|
|
2443
|
+
let forms = [];
|
|
2444
|
+
if ((!__eliscript_truthy(((__eliscript_value_252) => (__eliscript_truthy(__eliscript_value_252) ? (!__eliscript_truthy((node_name(name_node))["includes"]("/"))) : __eliscript_value_252))(symbol_node_p(name_node))))) {
|
|
2445
|
+
expander_fail(context, span, (String("defrecord name must be an unqualified symbol: ") + String(node_display(name_node))));
|
|
2446
|
+
}
|
|
2447
|
+
if ((!__eliscript_truthy(vector_node_p(fields_node)))) {
|
|
2448
|
+
expander_fail(context, span, (String("defrecord fields must be a vector: ") + String(node_display(fields_node))));
|
|
2449
|
+
}
|
|
2450
|
+
(node_items(fields_node))["forEach"](((field_node) => {
|
|
2451
|
+
if ((!__eliscript_truthy(((__eliscript_value_253) => (__eliscript_truthy(__eliscript_value_253) ? (!__eliscript_truthy((node_name(field_node))["includes"]("/"))) : __eliscript_value_253))(symbol_node_p(field_node))))) {
|
|
2452
|
+
expander_fail(context, span, (String("defrecord fields must be unqualified symbols: ") + String(node_display(field_node))));
|
|
2453
|
+
}
|
|
2454
|
+
{
|
|
2455
|
+
const __eliscript_value_254 = node_name(field_node);
|
|
2456
|
+
{
|
|
2457
|
+
let field_name = __eliscript_value_254;
|
|
2458
|
+
if (__eliscript_truthy((seen)["has"](field_name))) {
|
|
2459
|
+
expander_fail(context, span, (String("defrecord declares duplicate field: ") + String(field_name)));
|
|
2460
|
+
}
|
|
2461
|
+
(seen)["add"](field_name);
|
|
2462
|
+
(field_nodes)["push"](field_node);
|
|
2463
|
+
return (field_names)["push"](literal_node(field_name, node_span(field_node)));
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
}));
|
|
2467
|
+
{
|
|
2468
|
+
let name = node_name(name_node);
|
|
2469
|
+
let constructor_node = symbol_node((String("->") + String(name)), node_span(name_node));
|
|
2470
|
+
let map_constructor_node = symbol_node((String("map->") + String(name)), node_span(name_node));
|
|
2471
|
+
let predicate_node = symbol_node((String(name) + String("?")), node_span(name_node));
|
|
2472
|
+
let source_node = symbol_node("source", node_span(fields_node));
|
|
2473
|
+
let value_node = symbol_node("value", node_span(name_node));
|
|
2474
|
+
(forms)["push"](make_list([symbol_node("defconst", span), name_node, make_list([symbol_node("define-record-type", span), literal_node(name, node_span(name_node)), make_list(([symbol_node("js-array", span)])["concat"](field_names), span)], span)], span));
|
|
2475
|
+
(forms)["push"](make_list([symbol_node("defconst", span), constructor_node, make_list([symbol_node("lambda", span), make_list(field_nodes, node_span(fields_node)), make_list(([symbol_node("js-call", span), name_node, keyword_node("create", span)])["concat"](field_nodes), span)], span)], span));
|
|
2476
|
+
(forms)["push"](make_list([symbol_node("defconst", span), map_constructor_node, make_list([symbol_node("lambda", span), make_list([source_node], span), make_list([symbol_node("js-call", span), name_node, keyword_node("fromMap", span), source_node], span)], span)], span));
|
|
2477
|
+
(forms)["push"](make_list([symbol_node("defconst", span), predicate_node, make_list([symbol_node("lambda", span), make_list([value_node], span), make_list([symbol_node("js-call", span), name_node, keyword_node("isInstance", span), value_node], span)], span)], span));
|
|
2478
|
+
}
|
|
1215
2479
|
return forms;
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
1223
2487
|
}
|
|
1224
2488
|
function protocol_method_object(form_name, method_nodes, context, span, require_receiver = null) {
|
|
1225
|
-
(
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
2489
|
+
if (((method_nodes)["length"] === 0)) {
|
|
2490
|
+
expander_fail(context, span, (String(form_name) + String(" expects at least one method")));
|
|
2491
|
+
}
|
|
2492
|
+
{
|
|
2493
|
+
const __eliscript_value_255 = new (Set)();
|
|
2494
|
+
const __eliscript_value_256 = [symbol_node("js-object", span)];
|
|
2495
|
+
{
|
|
2496
|
+
let seen = __eliscript_value_255;
|
|
2497
|
+
let object_items = __eliscript_value_256;
|
|
2498
|
+
(method_nodes)["forEach"](((method_node) => {
|
|
2499
|
+
{
|
|
2500
|
+
const __eliscript_value_257 = list_items(method_node);
|
|
2501
|
+
{
|
|
2502
|
+
let method_items = __eliscript_value_257;
|
|
2503
|
+
if (((method_items === undefined) || __eliscript_numeric_relation("<", (method_items)["length"], 2))) {
|
|
2504
|
+
expander_fail(context, span, (String(form_name) + String(" method must contain an operation and parameter list: ") + String(node_display(method_node))));
|
|
2505
|
+
}
|
|
2506
|
+
if (__eliscript_truthy(require_receiver)) {
|
|
2507
|
+
{
|
|
2508
|
+
const __eliscript_value_258 = list_items(((((method_items) ?? [])[1]) ?? null));
|
|
2509
|
+
{
|
|
2510
|
+
let parameter_items = __eliscript_value_258;
|
|
2511
|
+
if (((parameter_items === undefined) || ((parameter_items)["length"] === 0))) {
|
|
2512
|
+
expander_fail(context, span, (String(form_name) + String(" method must declare a receiver parameter: ") + String(node_display(method_node))));
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
{
|
|
2518
|
+
const __eliscript_value_259 = ((((method_items) ?? [])[0]) ?? null);
|
|
2519
|
+
{
|
|
2520
|
+
let operation_node = __eliscript_value_259;
|
|
2521
|
+
if ((!__eliscript_truthy(symbol_node_p(operation_node)))) {
|
|
2522
|
+
expander_fail(context, span, (String(form_name) + String(" method operation must be a symbol: ") + String(node_display(operation_node))));
|
|
2523
|
+
}
|
|
2524
|
+
{
|
|
2525
|
+
const __eliscript_value_260 = node_name(operation_node);
|
|
2526
|
+
{
|
|
2527
|
+
let operation_name = __eliscript_value_260;
|
|
2528
|
+
if (__eliscript_truthy((seen)["has"](operation_name))) {
|
|
2529
|
+
expander_fail(context, span, (String(form_name) + String(" declares duplicate method: ") + String(operation_name)));
|
|
2530
|
+
}
|
|
2531
|
+
(seen)["add"](operation_name);
|
|
2532
|
+
(object_items)["push"](literal_node(operation_name, node_span(operation_node)));
|
|
2533
|
+
return (object_items)["push"](make_list(([symbol_node("lambda", node_span(method_node))])["concat"]((method_items)["slice"](1)), node_span(method_node)));
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
}));
|
|
2541
|
+
return make_list(object_items, span);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
1246
2544
|
}
|
|
1247
2545
|
function protocol_implementation_plans(form_name, implementation_nodes, context, span, allow_empty = null) {
|
|
1248
|
-
(
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
2546
|
+
if (((!__eliscript_truthy(allow_empty)) && ((implementation_nodes)["length"] === 0))) {
|
|
2547
|
+
expander_fail(context, span, (String(form_name) + String(" expects at least one protocol implementation")));
|
|
2548
|
+
}
|
|
2549
|
+
{
|
|
2550
|
+
const __eliscript_value_261 = new (Set)();
|
|
2551
|
+
const __eliscript_value_262 = [symbol_node("js-array", span)];
|
|
2552
|
+
const __eliscript_value_263 = 0;
|
|
2553
|
+
{
|
|
2554
|
+
let seen = __eliscript_value_261;
|
|
2555
|
+
let plans = __eliscript_value_262;
|
|
2556
|
+
let index = __eliscript_value_263;
|
|
2557
|
+
while (__eliscript_numeric_relation("<", index, (implementation_nodes)["length"])) {
|
|
2558
|
+
{
|
|
2559
|
+
const __eliscript_value_264 = ((((implementation_nodes) ?? [])[index]) ?? null);
|
|
2560
|
+
{
|
|
2561
|
+
let protocol_node = __eliscript_value_264;
|
|
2562
|
+
if ((!__eliscript_truthy(symbol_node_p(protocol_node)))) {
|
|
2563
|
+
expander_fail(context, span, (String(form_name) + String(" protocol must be a symbol: ") + String(node_display(protocol_node))));
|
|
2564
|
+
}
|
|
2565
|
+
{
|
|
2566
|
+
const __eliscript_value_265 = node_name(protocol_node);
|
|
2567
|
+
const __eliscript_value_266 = [];
|
|
2568
|
+
{
|
|
2569
|
+
let protocol_name = __eliscript_value_265;
|
|
2570
|
+
let method_nodes = __eliscript_value_266;
|
|
2571
|
+
if (__eliscript_truthy((seen)["has"](protocol_name))) {
|
|
2572
|
+
expander_fail(context, span, (String(form_name) + String(" declares duplicate protocol: ") + String(protocol_name)));
|
|
2573
|
+
}
|
|
2574
|
+
(seen)["add"](protocol_name);
|
|
1261
2575
|
((index = (index + 1)));
|
|
2576
|
+
while ((__eliscript_numeric_relation("<", index, (implementation_nodes)["length"]) && (node_kind(((((implementation_nodes) ?? [])[index]) ?? null)) === "list"))) {
|
|
2577
|
+
(method_nodes)["push"](((((implementation_nodes) ?? [])[index]) ?? null));
|
|
2578
|
+
((index = (index + 1)));
|
|
2579
|
+
}
|
|
2580
|
+
if (((method_nodes)["length"] === 0)) {
|
|
2581
|
+
expander_fail(context, span, (String(form_name) + String(" protocol ") + String(protocol_name) + String(" expects at least one method")));
|
|
2582
|
+
}
|
|
2583
|
+
(plans)["push"](make_list([symbol_node("js-array", span), protocol_node, protocol_method_object(form_name, method_nodes, context, span, true)], span));
|
|
1262
2584
|
}
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
return null;
|
|
1271
|
-
})();
|
|
1272
|
-
return make_list(plans, span);
|
|
1273
|
-
})(new Set(), [symbol_node("js-array", span)], 0);
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
return make_list(plans, span);
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
1274
2592
|
}
|
|
1275
2593
|
function desugar_deftype(args, context, span) {
|
|
1276
|
-
(
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
((
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
2594
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 2)) {
|
|
2595
|
+
expander_fail(context, span, "deftype expects a name, field vector, and optional protocol implementations");
|
|
2596
|
+
}
|
|
2597
|
+
{
|
|
2598
|
+
const __eliscript_value_267 = ((((args) ?? [])[0]) ?? null);
|
|
2599
|
+
{
|
|
2600
|
+
let name_node = __eliscript_value_267;
|
|
2601
|
+
{
|
|
2602
|
+
const __eliscript_value_268 = ((((args) ?? [])[1]) ?? null);
|
|
2603
|
+
{
|
|
2604
|
+
let fields_node = __eliscript_value_268;
|
|
2605
|
+
{
|
|
2606
|
+
const __eliscript_value_269 = new (Set)();
|
|
2607
|
+
{
|
|
2608
|
+
let seen = __eliscript_value_269;
|
|
2609
|
+
{
|
|
2610
|
+
let field_nodes = [];
|
|
2611
|
+
let field_names = [];
|
|
2612
|
+
let forms = [];
|
|
2613
|
+
if ((!__eliscript_truthy(((__eliscript_value_270) => (__eliscript_truthy(__eliscript_value_270) ? (!__eliscript_truthy((node_name(name_node))["includes"]("/"))) : __eliscript_value_270))(symbol_node_p(name_node))))) {
|
|
2614
|
+
expander_fail(context, span, (String("deftype name must be an unqualified symbol: ") + String(node_display(name_node))));
|
|
2615
|
+
}
|
|
2616
|
+
if ((!__eliscript_truthy(vector_node_p(fields_node)))) {
|
|
2617
|
+
expander_fail(context, span, (String("deftype fields must be a vector: ") + String(node_display(fields_node))));
|
|
2618
|
+
}
|
|
2619
|
+
(node_items(fields_node))["forEach"](((field_node) => {
|
|
2620
|
+
if ((!__eliscript_truthy(((__eliscript_value_271) => (__eliscript_truthy(__eliscript_value_271) ? (!__eliscript_truthy((node_name(field_node))["includes"]("/"))) : __eliscript_value_271))(symbol_node_p(field_node))))) {
|
|
2621
|
+
expander_fail(context, span, (String("deftype fields must be unqualified symbols: ") + String(node_display(field_node))));
|
|
2622
|
+
}
|
|
2623
|
+
{
|
|
2624
|
+
const __eliscript_value_272 = node_name(field_node);
|
|
2625
|
+
{
|
|
2626
|
+
let field_name = __eliscript_value_272;
|
|
2627
|
+
if (__eliscript_truthy((seen)["has"](field_name))) {
|
|
2628
|
+
expander_fail(context, span, (String("deftype declares duplicate field: ") + String(field_name)));
|
|
2629
|
+
}
|
|
2630
|
+
(seen)["add"](field_name);
|
|
2631
|
+
(field_nodes)["push"](field_node);
|
|
2632
|
+
return (field_names)["push"](literal_node(field_name, node_span(field_node)));
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
}));
|
|
2636
|
+
{
|
|
2637
|
+
let name = node_name(name_node);
|
|
2638
|
+
let constructor_node = symbol_node((String("->") + String(name)), node_span(name_node));
|
|
2639
|
+
let predicate_node = symbol_node((String(name) + String("?")), node_span(name_node));
|
|
2640
|
+
let value_node = symbol_node("value", node_span(name_node));
|
|
2641
|
+
let plans_node = protocol_implementation_plans("deftype", (args)["slice"](2), context, span, true);
|
|
2642
|
+
(forms)["push"](make_list([symbol_node("defconst", span), name_node, make_list([symbol_node("define-type", span), literal_node(name, node_span(name_node)), make_list(([symbol_node("js-array", span)])["concat"](field_names), span), plans_node], span)], span));
|
|
2643
|
+
(forms)["push"](make_list([symbol_node("defconst", span), constructor_node, make_list([symbol_node("lambda", span), make_list(field_nodes, node_span(fields_node)), make_list(([symbol_node("js-call", span), name_node, keyword_node("create", span)])["concat"](field_nodes), span)], span)], span));
|
|
2644
|
+
(forms)["push"](make_list([symbol_node("defconst", span), predicate_node, make_list([symbol_node("lambda", span), make_list([value_node], span), make_list([symbol_node("js-call", span), name_node, keyword_node("isInstance", span), value_node], span)], span)], span));
|
|
2645
|
+
}
|
|
1310
2646
|
return forms;
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
1318
2654
|
}
|
|
1319
2655
|
function desugar_reify(args, context, span) {
|
|
1320
2656
|
return make_list([symbol_node("reify-protocols", span), protocol_implementation_plans("reify", args, context, span, false)], span);
|
|
1321
2657
|
}
|
|
1322
2658
|
function desugar_extend_type(args, context, span) {
|
|
1323
|
-
(
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
2659
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 3)) {
|
|
2660
|
+
expander_fail(context, span, "extend-type expects a target, protocol, and at least one method");
|
|
2661
|
+
}
|
|
2662
|
+
{
|
|
2663
|
+
const __eliscript_value_273 = ((((args) ?? [])[0]) ?? null);
|
|
2664
|
+
const __eliscript_value_274 = ((((args) ?? [])[1]) ?? null);
|
|
2665
|
+
{
|
|
2666
|
+
let target_node = __eliscript_value_273;
|
|
2667
|
+
let protocol_node = __eliscript_value_274;
|
|
2668
|
+
if ((!__eliscript_truthy(symbol_node_p(target_node)))) {
|
|
2669
|
+
expander_fail(context, span, (String("extend-type target must be a symbol: ") + String(node_display(target_node))));
|
|
2670
|
+
}
|
|
2671
|
+
if ((!__eliscript_truthy(symbol_node_p(protocol_node)))) {
|
|
2672
|
+
expander_fail(context, span, (String("extend-type protocol must be a symbol: ") + String(node_display(protocol_node))));
|
|
2673
|
+
}
|
|
2674
|
+
return make_list([symbol_node("extend-protocol-type", span), protocol_node, target_node, protocol_method_object("extend-type", (args)["slice"](2), context, span)], span);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
1329
2677
|
}
|
|
1330
2678
|
function desugar_extend_category(args, context, span) {
|
|
1331
|
-
(
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
2679
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 3)) {
|
|
2680
|
+
expander_fail(context, span, "extend-category expects a category, protocol, and at least one method");
|
|
2681
|
+
}
|
|
2682
|
+
{
|
|
2683
|
+
const __eliscript_value_275 = ((((args) ?? [])[0]) ?? null);
|
|
2684
|
+
const __eliscript_value_276 = ((((args) ?? [])[1]) ?? null);
|
|
2685
|
+
{
|
|
2686
|
+
let category_node = __eliscript_value_275;
|
|
2687
|
+
let protocol_node = __eliscript_value_276;
|
|
2688
|
+
if ((!__eliscript_truthy(((__eliscript_value_277) => (__eliscript_truthy(__eliscript_value_277) ? ((((__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; } })(node_value(category_node)) === "string") && __eliscript_numeric_relation(">", (node_value(category_node))["length"], 0)) : __eliscript_value_277))(literal_node_p(category_node))))) {
|
|
2689
|
+
expander_fail(context, span, (String("extend-category category must be a non-empty string: ") + String(node_display(category_node))));
|
|
2690
|
+
}
|
|
2691
|
+
if ((!__eliscript_truthy(symbol_node_p(protocol_node)))) {
|
|
2692
|
+
expander_fail(context, span, (String("extend-category protocol must be a symbol: ") + String(node_display(protocol_node))));
|
|
2693
|
+
}
|
|
2694
|
+
return make_list([symbol_node("extend-protocol-category", span), protocol_node, category_node, protocol_method_object("extend-category", (args)["slice"](2), context, span)], span);
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
1337
2697
|
}
|
|
1338
2698
|
function desugar_extend_default(args, context, span) {
|
|
1339
|
-
(
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
2699
|
+
if (__eliscript_numeric_relation("<", (args)["length"], 2)) {
|
|
2700
|
+
expander_fail(context, span, "extend-default expects a protocol and at least one method");
|
|
2701
|
+
}
|
|
2702
|
+
{
|
|
2703
|
+
const __eliscript_value_278 = ((((args) ?? [])[0]) ?? null);
|
|
2704
|
+
{
|
|
2705
|
+
let protocol_node = __eliscript_value_278;
|
|
2706
|
+
if ((!__eliscript_truthy(symbol_node_p(protocol_node)))) {
|
|
2707
|
+
expander_fail(context, span, (String("extend-default protocol must be a symbol: ") + String(node_display(protocol_node))));
|
|
2708
|
+
}
|
|
2709
|
+
return make_list([symbol_node("extend-protocol-default", span), protocol_node, protocol_method_object("extend-default", (args)["slice"](1), context, span)], span);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
1344
2712
|
}
|
|
1345
2713
|
function expand_expression(form, environment, depth, context) {
|
|
1346
|
-
|
|
1347
|
-
return ((
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
2714
|
+
if ((node_kind(form) === "vector")) {
|
|
2715
|
+
return expand_collection_result("vector", form, expand_sequence(node_items(form), environment, depth, context), context);
|
|
2716
|
+
} else {
|
|
2717
|
+
if ((!(node_kind(form) === "list"))) {
|
|
2718
|
+
return form;
|
|
2719
|
+
} else {
|
|
2720
|
+
{
|
|
2721
|
+
let items = node_items(form);
|
|
2722
|
+
let operator_node = ((((items) ?? [])[0]) ?? null);
|
|
2723
|
+
let operator = ((__eliscript_value_279) => (__eliscript_truthy(__eliscript_value_279) ? node_name(operator_node) : __eliscript_value_279))(symbol_node_p(operator_node));
|
|
2724
|
+
let args = (items)["slice"](1);
|
|
2725
|
+
let span = node_span(form);
|
|
2726
|
+
if ((operator === "quote")) {
|
|
2727
|
+
return form;
|
|
2728
|
+
} else {
|
|
2729
|
+
if ((operator === "defmacro")) {
|
|
2730
|
+
return expander_fail(context, span, "defmacro is only valid at module top level");
|
|
2731
|
+
} else {
|
|
2732
|
+
if ((operator === "defportable")) {
|
|
2733
|
+
return expander_fail(context, span, "defportable is only valid at module top level");
|
|
2734
|
+
} else {
|
|
2735
|
+
if ((operator === "defasync")) {
|
|
2736
|
+
return expander_fail(context, span, "defasync is only valid at module top level");
|
|
2737
|
+
} else {
|
|
2738
|
+
if ((operator === "defmulti")) {
|
|
2739
|
+
return expander_fail(context, span, "defmulti is only valid at module top level");
|
|
2740
|
+
} else {
|
|
2741
|
+
if ((operator === "defmethod")) {
|
|
2742
|
+
return expander_fail(context, span, "defmethod is only valid at module top level");
|
|
2743
|
+
} else {
|
|
2744
|
+
if (((operator === "deftype") || (operator === "defrecord") || (operator === "defprotocol") || (operator === "extend-type") || (operator === "extend-category") || (operator === "extend-default"))) {
|
|
2745
|
+
return expander_fail(context, span, (String(operator) + String(" is only valid at module top level")));
|
|
2746
|
+
} else {
|
|
2747
|
+
if (__eliscript_truthy(((__eliscript_value_280) => (__eliscript_truthy(__eliscript_value_280) ? (environment)["has"](operator) : __eliscript_value_280))(operator))) {
|
|
2748
|
+
return expand_user_macro((environment)["get"](operator), args, environment, depth, context, span, false);
|
|
2749
|
+
} else {
|
|
2750
|
+
if ((operator === "->")) {
|
|
2751
|
+
return expand_expression(desugar_thread("->", args, "first", context, span), environment, depth, context);
|
|
2752
|
+
} else {
|
|
2753
|
+
if ((operator === "->>")) {
|
|
2754
|
+
return expand_expression(desugar_thread("->>", args, "last", context, span), environment, depth, context);
|
|
2755
|
+
} else {
|
|
2756
|
+
if ((operator === "as->")) {
|
|
2757
|
+
return expand_expression(desugar_as_thread(args, context, span), environment, depth, context);
|
|
2758
|
+
} else {
|
|
2759
|
+
if ((operator === "cond->")) {
|
|
2760
|
+
return expand_expression(desugar_cond_thread("cond->", args, "first", context, span), environment, depth, context);
|
|
2761
|
+
} else {
|
|
2762
|
+
if ((operator === "cond->>")) {
|
|
2763
|
+
return expand_expression(desugar_cond_thread("cond->>", args, "last", context, span), environment, depth, context);
|
|
2764
|
+
} else {
|
|
2765
|
+
if ((operator === "some->")) {
|
|
2766
|
+
return expand_expression(desugar_some_thread("some->", args, "first", context, span), environment, depth, context);
|
|
2767
|
+
} else {
|
|
2768
|
+
if ((operator === "some->>")) {
|
|
2769
|
+
return expand_expression(desugar_some_thread("some->>", args, "last", context, span), environment, depth, context);
|
|
2770
|
+
} else {
|
|
2771
|
+
if ((operator === "if-let")) {
|
|
2772
|
+
return expand_expression(desugar_if_binding("if-let", args, false, context, span), environment, depth, context);
|
|
2773
|
+
} else {
|
|
2774
|
+
if ((operator === "when-let")) {
|
|
2775
|
+
return expand_expression(desugar_when_binding("when-let", args, false, context, span), environment, depth, context);
|
|
2776
|
+
} else {
|
|
2777
|
+
if ((operator === "if-some")) {
|
|
2778
|
+
return expand_expression(desugar_if_binding("if-some", args, true, context, span), environment, depth, context);
|
|
2779
|
+
} else {
|
|
2780
|
+
if ((operator === "when-some")) {
|
|
2781
|
+
return expand_expression(desugar_when_binding("when-some", args, true, context, span), environment, depth, context);
|
|
2782
|
+
} else {
|
|
2783
|
+
if ((operator === "case")) {
|
|
2784
|
+
return expand_expression(desugar_case(args, context, span), environment, depth, context);
|
|
2785
|
+
} else {
|
|
2786
|
+
if ((operator === "condp")) {
|
|
2787
|
+
return expand_expression(desugar_condp(args, context, span), environment, depth, context);
|
|
2788
|
+
} else {
|
|
2789
|
+
if (__eliscript_truthy(((__eliscript_value_281) => (__eliscript_truthy(__eliscript_value_281) ? ((__eliscript_value_282) => (__eliscript_truthy(__eliscript_value_282) ? multi_arity_clause_p(((((args) ?? [])[0]) ?? null)) : __eliscript_value_282))(__eliscript_numeric_relation(">", (args)["length"], 0)) : __eliscript_value_281))(((operator === "lambda") || (operator === "fn") || (operator === "async"))))) {
|
|
2790
|
+
return expand_expression(desugar_multi_arity(operator_node, null, args, form, context, span), environment, depth, context);
|
|
2791
|
+
} else {
|
|
2792
|
+
if ((operator === "reify")) {
|
|
2793
|
+
return expand_expression(desugar_reify(args, context, span), environment, depth, context);
|
|
2794
|
+
} else {
|
|
2795
|
+
{
|
|
2796
|
+
const __eliscript_value_283 = [operator_node];
|
|
2797
|
+
{
|
|
2798
|
+
let expanded = __eliscript_value_283;
|
|
2799
|
+
if (((operator === "lambda") || (operator === "fn") || (operator === "async"))) {
|
|
2800
|
+
if (__eliscript_numeric_relation(">", (args)["length"], 0)) {
|
|
2801
|
+
(expanded)["push"](((((args) ?? [])[0]) ?? null));
|
|
2802
|
+
(expand_sequence((args)["slice"](1), environment, depth, context))["forEach"](((item) => {
|
|
2803
|
+
return (expanded)["push"](item);
|
|
2804
|
+
}));
|
|
2805
|
+
}
|
|
2806
|
+
} else {
|
|
2807
|
+
if (((operator === "let") || (operator === "let*"))) {
|
|
2808
|
+
(expand_bindings(args, environment, depth, context))["forEach"](((item) => {
|
|
2809
|
+
return (expanded)["push"](item);
|
|
2810
|
+
}));
|
|
2811
|
+
} else {
|
|
2812
|
+
if ((operator === "letfn")) {
|
|
2813
|
+
((expanded = node_items(expand_expression(desugar_letfn(args, form, context, span), environment, depth, context))));
|
|
2814
|
+
} else {
|
|
2815
|
+
if ((operator === "setq")) {
|
|
2816
|
+
(expand_alternating(args, environment, depth, context, false, false))["forEach"](((item) => {
|
|
2817
|
+
return (expanded)["push"](item);
|
|
2818
|
+
}));
|
|
2819
|
+
} else {
|
|
2820
|
+
if ((operator === "set!")) {
|
|
2821
|
+
if (__eliscript_numeric_relation(">", (args)["length"], 0)) {
|
|
2822
|
+
(expanded)["push"](((((args) ?? [])[0]) ?? null));
|
|
2823
|
+
(expand_sequence((args)["slice"](1), environment, depth, context))["forEach"](((item) => {
|
|
2824
|
+
return (expanded)["push"](item);
|
|
2825
|
+
}));
|
|
2826
|
+
}
|
|
2827
|
+
} else {
|
|
2828
|
+
if ((operator === "cond")) {
|
|
2829
|
+
(expand_cond(args, environment, depth, context))["forEach"](((item) => {
|
|
2830
|
+
return (expanded)["push"](item);
|
|
2831
|
+
}));
|
|
2832
|
+
} else {
|
|
2833
|
+
if ((operator === "try")) {
|
|
2834
|
+
(args)["forEach"](((clause) => {
|
|
2835
|
+
return (expanded)["push"](expand_try_clause(clause, environment, depth, context));
|
|
2836
|
+
}));
|
|
2837
|
+
} else {
|
|
2838
|
+
if ((operator === "js-object")) {
|
|
2839
|
+
(expand_alternating(args, environment, depth, context, true, true))["forEach"](((item) => {
|
|
2840
|
+
return (expanded)["push"](item);
|
|
2841
|
+
}));
|
|
2842
|
+
} else {
|
|
2843
|
+
if (((operator === "get") || (operator === "put") || (operator === "js-call"))) {
|
|
2844
|
+
(expand_property_call(args, environment, depth, context))["forEach"](((item) => {
|
|
2845
|
+
return (expanded)["push"](item);
|
|
2846
|
+
}));
|
|
2847
|
+
} else {
|
|
2848
|
+
if ((!__eliscript_truthy(symbol_node_p(operator_node)))) {
|
|
2849
|
+
((expanded)[0] = expand_expression(operator_node, environment, depth, context));
|
|
2850
|
+
}
|
|
2851
|
+
(expand_sequence(args, environment, depth, context))["forEach"](((item) => {
|
|
2852
|
+
return (expanded)["push"](item);
|
|
2853
|
+
}));
|
|
2854
|
+
}
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return expand_collection_result("list", form, expanded, context);
|
|
2864
|
+
}
|
|
2865
|
+
}
|
|
2866
|
+
}
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
1387
2892
|
}
|
|
1388
2893
|
function expand_top_level(form, environment, depth, context) {
|
|
1389
|
-
|
|
1390
|
-
return (
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
2894
|
+
if ((!(node_kind(form) === "list"))) {
|
|
2895
|
+
return [expand_expression(form, environment, depth, context)];
|
|
2896
|
+
} else {
|
|
2897
|
+
{
|
|
2898
|
+
let items = node_items(form);
|
|
2899
|
+
let operator_node = ((((items) ?? [])[0]) ?? null);
|
|
2900
|
+
let operator = ((__eliscript_value_284) => (__eliscript_truthy(__eliscript_value_284) ? node_name(operator_node) : __eliscript_value_284))(symbol_node_p(operator_node));
|
|
2901
|
+
let owned_module = ((__eliscript_value_285) => (__eliscript_truthy(__eliscript_value_285) ? ((operator === "module") && (!__eliscript_truthy((environment)["has"](operator)))) : __eliscript_value_285))(((context)["ownedForms"] ?? false));
|
|
2902
|
+
let args = (__eliscript_truthy(owned_module) ? null : (items)["slice"](1));
|
|
2903
|
+
let span = node_span(form);
|
|
2904
|
+
if ((operator === "defmacro")) {
|
|
2905
|
+
register_macro(form, environment, context);
|
|
2906
|
+
return [];
|
|
2907
|
+
} else {
|
|
2908
|
+
if ((operator === "defmulti")) {
|
|
2909
|
+
return expand_top_level(desugar_defmulti(args, context, span), environment, depth, context);
|
|
2910
|
+
} else {
|
|
2911
|
+
if ((operator === "defmethod")) {
|
|
2912
|
+
return expand_top_level(desugar_defmethod(args, context, span), environment, depth, context);
|
|
2913
|
+
} else {
|
|
2914
|
+
if ((operator === "defprotocol")) {
|
|
2915
|
+
return expand_top_level_sequence(desugar_defprotocol(args, context, span), environment, depth, context);
|
|
2916
|
+
} else {
|
|
2917
|
+
if ((operator === "deftype")) {
|
|
2918
|
+
return expand_top_level_sequence(desugar_deftype(args, context, span), environment, depth, context);
|
|
2919
|
+
} else {
|
|
2920
|
+
if ((operator === "defrecord")) {
|
|
2921
|
+
return expand_top_level_sequence(desugar_defrecord(args, context, span), environment, depth, context);
|
|
2922
|
+
} else {
|
|
2923
|
+
if ((operator === "extend-type")) {
|
|
2924
|
+
return expand_top_level(desugar_extend_type(args, context, span), environment, depth, context);
|
|
2925
|
+
} else {
|
|
2926
|
+
if ((operator === "extend-category")) {
|
|
2927
|
+
return expand_top_level(desugar_extend_category(args, context, span), environment, depth, context);
|
|
2928
|
+
} else {
|
|
2929
|
+
if ((operator === "extend-default")) {
|
|
2930
|
+
return expand_top_level(desugar_extend_default(args, context, span), environment, depth, context);
|
|
2931
|
+
} else {
|
|
2932
|
+
if (__eliscript_truthy(((__eliscript_value_286) => (__eliscript_truthy(__eliscript_value_286) ? ((__eliscript_value_287) => (__eliscript_truthy(__eliscript_value_287) ? multi_arity_clause_p(((((args) ?? [])[1]) ?? null)) : __eliscript_value_287))(__eliscript_numeric_relation(">=", (args)["length"], 2)) : __eliscript_value_286))(((operator === "defun") || (operator === "defn") || (operator === "defportable") || (operator === "defasync"))))) {
|
|
2933
|
+
return expand_top_level(desugar_multi_arity(operator_node, ((((args) ?? [])[0]) ?? null), (args)["slice"](1), form, context, span), environment, depth, context);
|
|
2934
|
+
} else {
|
|
2935
|
+
if (__eliscript_truthy(((__eliscript_value_288) => (__eliscript_truthy(__eliscript_value_288) ? (environment)["has"](operator) : __eliscript_value_288))(operator))) {
|
|
2936
|
+
return expand_user_macro((environment)["get"](operator), args, environment, depth, context, span, true);
|
|
2937
|
+
} else {
|
|
2938
|
+
{
|
|
2939
|
+
const __eliscript_value_289 = [operator_node];
|
|
2940
|
+
{
|
|
2941
|
+
let expanded = __eliscript_value_289;
|
|
2942
|
+
if ((operator === "module")) {
|
|
2943
|
+
if (__eliscript_truthy(owned_module)) {
|
|
2944
|
+
if (__eliscript_numeric_relation(">", (items)["length"], 1)) {
|
|
2945
|
+
(expanded)["push"](((((items) ?? [])[1]) ?? null));
|
|
2946
|
+
(expand_owned_top_level_sequence(items, 2, environment, depth, context))["forEach"](((item) => {
|
|
2947
|
+
return (expanded)["push"](item);
|
|
2948
|
+
}));
|
|
2949
|
+
}
|
|
2950
|
+
} else {
|
|
2951
|
+
if (__eliscript_numeric_relation(">", (args)["length"], 0)) {
|
|
2952
|
+
(expanded)["push"](((((args) ?? [])[0]) ?? null));
|
|
2953
|
+
(expand_top_level_sequence((args)["slice"](1), environment, depth, context))["forEach"](((item) => {
|
|
2954
|
+
return (expanded)["push"](item);
|
|
2955
|
+
}));
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
} else {
|
|
2959
|
+
if (((operator === "defun") || (operator === "defn") || (operator === "defportable") || (operator === "defasync"))) {
|
|
2960
|
+
if (__eliscript_numeric_relation(">=", (args)["length"], 2)) {
|
|
2961
|
+
(expanded)["push"](((((args) ?? [])[0]) ?? null));
|
|
2962
|
+
(expanded)["push"](((((args) ?? [])[1]) ?? null));
|
|
2963
|
+
(expand_sequence((args)["slice"](2), environment, depth, context))["forEach"](((item) => {
|
|
2964
|
+
return (expanded)["push"](item);
|
|
2965
|
+
}));
|
|
2966
|
+
} else {
|
|
2967
|
+
((expanded = items));
|
|
2968
|
+
}
|
|
2969
|
+
} else {
|
|
2970
|
+
if (((operator === "defvar") || (operator === "defconst"))) {
|
|
2971
|
+
if (__eliscript_numeric_relation(">", (args)["length"], 0)) {
|
|
2972
|
+
(expanded)["push"](((((args) ?? [])[0]) ?? null));
|
|
2973
|
+
(expand_sequence((args)["slice"](1), environment, depth, context))["forEach"](((item) => {
|
|
2974
|
+
return (expanded)["push"](item);
|
|
2975
|
+
}));
|
|
2976
|
+
}
|
|
2977
|
+
} else {
|
|
2978
|
+
if (((operator === "import") || (operator === "import-portable") || (operator === "export"))) {
|
|
2979
|
+
((expanded = items));
|
|
2980
|
+
} else {
|
|
2981
|
+
if ((operator === "export-default")) {
|
|
2982
|
+
(expand_sequence(args, environment, depth, context))["forEach"](((item) => {
|
|
2983
|
+
return (expanded)["push"](item);
|
|
2984
|
+
}));
|
|
2985
|
+
} else {
|
|
2986
|
+
((expanded = node_items(expand_expression(form, environment, depth, context))));
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
}
|
|
2992
|
+
return [expand_collection_result("list", form, expanded, context)];
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
function expand_owned_top_level_sequence(forms, start, environment, depth, context) {
|
|
3010
|
+
{
|
|
3011
|
+
const __eliscript_value_290 = [];
|
|
3012
|
+
const __eliscript_value_291 = start;
|
|
3013
|
+
{
|
|
3014
|
+
let result = __eliscript_value_290;
|
|
3015
|
+
let index = __eliscript_value_291;
|
|
3016
|
+
while (__eliscript_numeric_relation("<", index, (forms)["length"])) {
|
|
3017
|
+
{
|
|
3018
|
+
const __eliscript_value_292 = expand_top_level(((((forms) ?? [])[index]) ?? null), environment, depth, context);
|
|
3019
|
+
{
|
|
3020
|
+
let expanded = __eliscript_value_292;
|
|
3021
|
+
(expanded)["forEach"](((form) => {
|
|
3022
|
+
return (result)["push"](form);
|
|
3023
|
+
}));
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
((forms)[index] = null);
|
|
3027
|
+
((index = (index + 1)));
|
|
3028
|
+
}
|
|
3029
|
+
return result;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
1424
3032
|
}
|
|
1425
3033
|
function expand_top_level_sequence(forms, environment, depth, context) {
|
|
1426
|
-
|
|
1427
|
-
(forms
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
3034
|
+
if (__eliscript_truthy(((context)["ownedForms"] ?? false))) {
|
|
3035
|
+
return expand_owned_top_level_sequence(forms, 0, environment, depth, context);
|
|
3036
|
+
} else {
|
|
3037
|
+
{
|
|
3038
|
+
const __eliscript_value_293 = [];
|
|
3039
|
+
{
|
|
3040
|
+
let result = __eliscript_value_293;
|
|
3041
|
+
(forms)["forEach"](((form) => {
|
|
3042
|
+
return (expand_top_level(form, environment, depth, context))["forEach"](((expanded) => {
|
|
3043
|
+
return (result)["push"](expanded);
|
|
3044
|
+
}));
|
|
3045
|
+
}));
|
|
3046
|
+
return result;
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
1434
3050
|
}
|
|
1435
3051
|
function collect_symbol_names(node, names) {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
3052
|
+
{
|
|
3053
|
+
const __eliscript_value_294 = [node];
|
|
3054
|
+
const __eliscript_value_295 = null;
|
|
3055
|
+
const __eliscript_value_296 = null;
|
|
3056
|
+
const __eliscript_value_297 = null;
|
|
3057
|
+
const __eliscript_value_298 = 0;
|
|
3058
|
+
{
|
|
3059
|
+
let pending = __eliscript_value_294;
|
|
3060
|
+
let current = __eliscript_value_295;
|
|
3061
|
+
let kind = __eliscript_value_296;
|
|
3062
|
+
let items = __eliscript_value_297;
|
|
3063
|
+
let index = __eliscript_value_298;
|
|
3064
|
+
while (__eliscript_numeric_relation(">", (pending)["length"], 0)) {
|
|
1439
3065
|
((current = (pending)["pop"]()));
|
|
1440
|
-
(__eliscript_truthy(symbol_node_p(current))
|
|
3066
|
+
if (__eliscript_truthy(symbol_node_p(current))) {
|
|
3067
|
+
(names)["add"](node_name(current));
|
|
3068
|
+
} else {
|
|
1441
3069
|
((kind = node_kind(current)));
|
|
1442
|
-
|
|
3070
|
+
if (((kind === "list") || (kind === "vector"))) {
|
|
1443
3071
|
((items = node_items(current)));
|
|
1444
|
-
((index = ((items)["length"]
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
})();
|
|
1452
|
-
})() : null);
|
|
1453
|
-
})());
|
|
3072
|
+
((index = __eliscript_numeric_decrement((items)["length"])));
|
|
3073
|
+
while (__eliscript_numeric_relation(">=", index, 0)) {
|
|
3074
|
+
(pending)["push"](((((items) ?? [])[index]) ?? null));
|
|
3075
|
+
((index = __eliscript_numeric_decrement(index)));
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
1454
3079
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
})([node], null, null, null, 0);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
1458
3082
|
return names;
|
|
1459
3083
|
}
|
|
3084
|
+
function expand_module_core(forms, filename, macro_context, owned) {
|
|
3085
|
+
{
|
|
3086
|
+
const __eliscript_value_299 = new (Set)();
|
|
3087
|
+
{
|
|
3088
|
+
let reserved_names = __eliscript_value_299;
|
|
3089
|
+
(forms)["forEach"](((form) => {
|
|
3090
|
+
return collect_symbol_names(form, reserved_names);
|
|
3091
|
+
}));
|
|
3092
|
+
return expand_top_level_sequence(forms, new (Map)(), 0, ({"filename": filename, "ownedForms": owned, "gensymCounter": 0, "reservedNames": reserved_names, "originEvents": (__eliscript_truthy(macro_context) ? ((macro_context)["originEvents"] ?? null) : null), "originParent": (__eliscript_truthy(macro_context) ? ((macro_context)["originParent"] ?? null) : null), "capabilities": (__eliscript_truthy(macro_context) ? (macro_context)["capabilities"] : new (Set)()), "files": (__eliscript_truthy(macro_context) ? (macro_context)["files"] : new (Map)())}));
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
1460
3096
|
function expand_module(forms, filename, macro_context = null) {
|
|
1461
|
-
return (
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
3097
|
+
return expand_module_core(forms, filename, macro_context, false);
|
|
3098
|
+
}
|
|
3099
|
+
function expand_owned_module(forms, filename, macro_context = null) {
|
|
3100
|
+
return expand_module_core(forms, filename, macro_context, true);
|
|
3101
|
+
}
|
|
3102
|
+
function expand_module_with_origins_core(forms, filename, macro_context, owned) {
|
|
3103
|
+
{
|
|
3104
|
+
let events = [];
|
|
3105
|
+
let context = (globalThis.Object)["assign"](({"capabilities": new (globalThis.Set)(), "files": new (globalThis.Map)()}), ((__eliscript_value_300) => (__eliscript_truthy(__eliscript_value_300) ? __eliscript_value_300 : ({})))(macro_context), ({"originEvents": events, "originParent": null}));
|
|
3106
|
+
let expanded = (() => {
|
|
3107
|
+
try {
|
|
3108
|
+
return expand_module_core(forms, filename, context, owned);
|
|
3109
|
+
} catch (error) {
|
|
3110
|
+
((error)["macroOrigins"] = events);
|
|
3111
|
+
return ((__eliscript_value_301) => { throw __eliscript_value_301; })(error);
|
|
3112
|
+
}
|
|
3113
|
+
})();
|
|
3114
|
+
return ({"forms": expanded, "macroOrigins": events});
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
function expand_module_with_origins(forms, filename, macro_context = null) {
|
|
3118
|
+
return expand_module_with_origins_core(forms, filename, macro_context, false);
|
|
3119
|
+
}
|
|
3120
|
+
function expand_owned_module_with_origins(forms, filename, macro_context = null) {
|
|
3121
|
+
return expand_module_with_origins_core(forms, filename, macro_context, true);
|
|
3122
|
+
}
|
|
3123
|
+
export {expand_module, expand_module_with_origins, expand_owned_module, expand_owned_module_with_origins};
|