eliscript 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/bootstrap/README.md +26 -0
- package/bootstrap/backends/README.md +515 -0
- package/bootstrap/backends/async.eli +230 -0
- package/bootstrap/backends/binary.eli +173 -0
- package/bootstrap/backends/capabilities.eli +74 -0
- package/bootstrap/backends/elf.eli +246 -0
- package/bootstrap/backends/managed.eli +5976 -0
- package/bootstrap/backends/memory.eli +100 -0
- package/bootstrap/backends/native.eli +2000 -0
- package/bootstrap/backends/numeric.eli +1362 -0
- package/bootstrap/backends/optimize.eli +79 -0
- package/bootstrap/backends/regexp.eli +2263 -0
- package/bootstrap/backends/sha256.eli +138 -0
- package/bootstrap/backends/wasm.eli +1161 -0
- package/bootstrap/compiler/analyzer.eli +165 -77
- package/bootstrap/compiler/compiler.eli +43 -19
- package/bootstrap/compiler/emitter.eli +780 -170
- package/bootstrap/compiler/expander.eli +136 -45
- package/bootstrap/compiler/formatter.eli +8 -1
- package/bootstrap/compiler/ir.eli +148 -45
- package/bootstrap/compiler/lower.eli +29 -2
- package/bootstrap/compiler/project.eli +51 -21
- package/bootstrap/compiler/reader.eli +128 -36
- package/bootstrap/compiler/source-map.eli +46 -4
- package/bootstrap/compiler/symbol.eli +2 -1
- package/bootstrap/compiler/syntax.eli +47 -12
- package/bootstrap/compiler/transient-analysis.eli +40 -4
- package/bootstrap/host/check-cli-legacy.mjs +163 -0
- package/bootstrap/host/check-cli.mjs +59 -158
- package/bootstrap/host/check-cli.mjs.map +1 -0
- package/bootstrap/host/compiler-session.eli +1579 -0
- package/bootstrap/host/compiler-tools.eli +513 -0
- package/bootstrap/host/eliscript-cli-legacy.mjs +37 -0
- package/bootstrap/host/eliscript-cli.mjs +53 -33
- package/bootstrap/host/eliscript-cli.mjs.map +1 -0
- package/bootstrap/host/project-cli-legacy.mjs +295 -0
- package/bootstrap/host/project-cli.mjs +74 -289
- package/bootstrap/host/project-cli.mjs.map +1 -0
- package/bootstrap/host/project-legacy.mjs +1080 -0
- package/bootstrap/host/project.mjs +210 -1060
- package/bootstrap/host/project.mjs.map +1 -0
- package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
- package/bootstrap/runtime/memory.eli +30379 -0
- package/browser/host.mjs +89 -0
- package/compiler/eliscript-analyzer.el +371 -4
- package/compiler/eliscript-cli.el +84 -1
- package/compiler/eliscript-emitter.el +1189 -256
- package/compiler/eliscript-expander.el +147 -10
- package/compiler/eliscript-ir-emitter.el +725 -208
- package/compiler/eliscript-lower.el +127 -1
- package/compiler/eliscript-portable.el +177 -51
- package/compiler/eliscript-project.el +20 -2
- package/compiler/eliscript-reader.el +141 -57
- package/compiler/eliscript-source-map.el +26 -12
- package/compiler/eliscript-transient-analysis.el +382 -19
- package/dist/backends/async.mjs +561 -0
- package/dist/backends/async.mjs.macro-origins.json +1 -0
- package/dist/backends/async.mjs.map +1 -0
- package/dist/backends/binary.mjs +381 -0
- package/dist/backends/binary.mjs.macro-origins.json +1 -0
- package/dist/backends/binary.mjs.map +1 -0
- package/dist/backends/capabilities.mjs +237 -0
- package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
- package/dist/backends/capabilities.mjs.map +1 -0
- package/dist/backends/elf.mjs +540 -0
- package/dist/backends/elf.mjs.macro-origins.json +1 -0
- package/dist/backends/elf.mjs.map +1 -0
- package/dist/backends/managed.mjs +10616 -0
- package/dist/backends/managed.mjs.macro-origins.json +1 -0
- package/dist/backends/managed.mjs.map +1 -0
- package/dist/backends/memory.mjs +278 -0
- package/dist/backends/memory.mjs.macro-origins.json +1 -0
- package/dist/backends/memory.mjs.map +1 -0
- package/dist/backends/native.mjs +4099 -0
- package/dist/backends/native.mjs.macro-origins.json +1 -0
- package/dist/backends/native.mjs.map +1 -0
- package/dist/backends/numeric.mjs +2458 -0
- package/dist/backends/numeric.mjs.macro-origins.json +1 -0
- package/dist/backends/numeric.mjs.map +1 -0
- package/dist/backends/optimize.mjs +204 -0
- package/dist/backends/optimize.mjs.macro-origins.json +1 -0
- package/dist/backends/optimize.mjs.map +1 -0
- package/dist/backends/regexp.mjs +2033 -0
- package/dist/backends/regexp.mjs.macro-origins.json +1 -0
- package/dist/backends/regexp.mjs.map +1 -0
- package/dist/backends/sha256.mjs +310 -0
- package/dist/backends/sha256.mjs.macro-origins.json +1 -0
- package/dist/backends/sha256.mjs.map +1 -0
- package/dist/backends/wasm.mjs +2258 -0
- package/dist/backends/wasm.mjs.macro-origins.json +1 -0
- package/dist/backends/wasm.mjs.map +1 -0
- package/dist/bootstrap/analyzer.mjs +1908 -776
- package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +450 -142
- package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +3083 -909
- package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +2887 -1233
- package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/formatter.mjs +582 -218
- package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/formatter.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +670 -116
- package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/lower.mjs +866 -257
- package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/lower.mjs.map +1 -1
- package/dist/bootstrap/package.json +1 -0
- package/dist/bootstrap/project.mjs +1168 -498
- package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +674 -175
- package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/runtime/math.mjs +1117 -0
- package/dist/bootstrap/runtime/math.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
- package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +430 -119
- package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/symbol.mjs +229 -53
- package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/symbol.mjs.map +1 -1
- package/dist/bootstrap/syntax.mjs +205 -7
- package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/syntax.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +1185 -489
- package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +199 -6478
- package/dist/browser/host.mjs +446 -0
- package/dist/browser/loader.js +1 -0
- package/dist/browser/loader.mjs +231 -0
- package/dist/browser/worker.mjs +60 -0
- package/dist/compiler-artifact.json +1 -0
- package/dist/host/compiler-session.mjs +2980 -0
- package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-session.mjs.map +1 -0
- package/dist/host/compiler-tools.mjs +1084 -0
- package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-tools.mjs.map +1 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
- package/dist/literal-sources/runtime/core/collection.eli +579 -0
- package/dist/literal-sources/runtime/core/data-text.eli +290 -0
- package/dist/literal-sources/runtime/core/data.eli +22 -0
- package/dist/literal-sources/runtime/core/identifier.eli +44 -0
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
- package/dist/literal-sources/runtime/core/list.eli +19 -0
- package/dist/literal-sources/runtime/core/map.eli +9 -0
- package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
- package/dist/literal-sources/runtime/core/metadata.eli +23 -0
- package/dist/literal-sources/runtime/core/object.eli +8 -0
- package/dist/literal-sources/runtime/core/order.eli +123 -0
- package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
- package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
- package/dist/literal-sources/runtime/core/protocol.eli +28 -0
- package/dist/literal-sources/runtime/core/queue.eli +9 -0
- package/dist/literal-sources/runtime/core/record.eli +191 -0
- package/dist/literal-sources/runtime/core/regex.eli +158 -0
- package/dist/literal-sources/runtime/core/sequence.eli +305 -0
- package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
- package/dist/literal-sources/runtime/core/set.eli +9 -0
- package/dist/literal-sources/runtime/core/sorted.eli +408 -0
- package/dist/literal-sources/runtime/core/text.eli +14 -0
- package/dist/literal-sources/runtime/core/transducer.eli +268 -0
- package/dist/literal-sources/runtime/core/transient.eli +17 -0
- package/dist/literal-sources/runtime/core/truth.eli +4 -0
- package/dist/literal-sources/runtime/core/type.eli +232 -0
- package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
- package/dist/literal-sources/runtime/core/value.eli +19 -0
- package/dist/literal-sources/runtime/core/vector.eli +20 -0
- package/dist/literal-sources/runtime/literals.eli +23 -0
- package/dist/literal-sources/runtime/testing/value.eli +6 -0
- package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
- package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
- package/dist/literal-sources/runtime/wire/schema.eli +193 -0
- package/dist/literal-sources/stdlib/bit.eli +36 -0
- package/dist/literal-sources/stdlib/core/data.eli +306 -0
- package/dist/literal-sources/stdlib/core/object.eli +89 -0
- package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
- package/dist/literal-sources/stdlib/core/set.eli +312 -0
- package/dist/literal-sources/stdlib/core/text.eli +103 -0
- package/dist/literal-sources/stdlib/managed-literal-protocols.eli +483 -0
- package/dist/literal-sources/stdlib/managed-literals.eli +1414 -0
- package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
- package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
- package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
- package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
- package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
- package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
- package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
- package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
- package/dist/literal-sources/stdlib/value.eli +325 -0
- package/dist/package.json +10 -0
- package/dist/runtime/math.mjs +1116 -0
- package/dist/runtime/math.mjs.macro-origins.json +1 -0
- package/dist/runtime/math.mjs.map +1 -0
- package/dist/runtime/unicode-case-data.mjs +10124 -0
- package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/runtime/unicode-case.mjs +280 -0
- package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case.mjs.map +1 -0
- package/dist/runtime.eli +30379 -0
- package/dist/stage3-release.json +1 -0
- package/editor/README.md +1 -1
- package/editor/eliscript-mode.el +1 -1
- package/editor/eliscript-repl.el +1 -1
- package/package.json +97 -10
- package/platform/http.mjs +20 -0
- package/runtime/array-text.mjs +159 -0
- package/runtime/core/map-internals.mjs +27 -9
- package/runtime/core/object-impl.mjs +26 -17
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/protocol-impl.mjs +682 -255
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/protocol.mjs +4 -0
- package/runtime/core/record.mjs +23 -2
- package/runtime/core/regex.mjs +4 -0
- package/runtime/core/sorted.mjs +53 -0
- package/runtime/core/text-impl.mjs +167 -48
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/type.mjs +75 -3
- package/runtime/core/vector.mjs +6 -0
- package/runtime/math.eli +429 -0
- package/runtime/math.mjs +1116 -0
- package/runtime/math.mjs.map +1 -0
- package/runtime/number-radix.mjs +105 -0
- package/runtime/unicode-case-data.eli +29 -0
- package/runtime/unicode-case-data.mjs +10124 -0
- package/runtime/unicode-case-data.mjs.map +1 -0
- package/runtime/unicode-case.eli +100 -0
- package/runtime/unicode-case.mjs +280 -0
- package/runtime/unicode-case.mjs.map +1 -0
- package/runtime/wire/http-rpc.mjs +168 -0
- package/runtime/wire/markdown.mjs +196 -0
- package/runtime/wire/schema.mjs +109 -0
- package/stdlib/README.md +54 -0
- package/stdlib/core/protocol.eli +81 -17
- package/stdlib/core/seq.eli +1 -1
- package/stdlib/core/zipper.eli +114 -47
- package/stdlib/gepo.eli +12 -0
- package/stdlib/interop/js.eli +56 -15
- package/stdlib/managed-literal-protocols.eli +483 -0
- package/stdlib/managed-literals.eli +1414 -0
- package/stdlib/managed-protocol-error.eli +32 -0
- package/stdlib/managed-queue-state.eli +65 -0
- package/stdlib/managed-runtime-collection-internals.eli +60 -0
- package/stdlib/managed-runtime-collection.eli +579 -0
- package/stdlib/managed-runtime-data-text.eli +290 -0
- package/stdlib/managed-runtime-data.eli +22 -0
- package/stdlib/managed-runtime-identifier.eli +44 -0
- package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
- package/stdlib/managed-runtime-list.eli +19 -0
- package/stdlib/managed-runtime-literals.eli +23 -0
- package/stdlib/managed-runtime-map.eli +9 -0
- package/stdlib/managed-runtime-metadata-internals.eli +6 -0
- package/stdlib/managed-runtime-metadata.eli +23 -0
- package/stdlib/managed-runtime-object.eli +8 -0
- package/stdlib/managed-runtime-order.eli +123 -0
- package/stdlib/managed-runtime-persistent-kind.eli +28 -0
- package/stdlib/managed-runtime-protocol.eli +28 -0
- package/stdlib/managed-runtime-queue.eli +9 -0
- package/stdlib/managed-runtime-record.eli +191 -0
- package/stdlib/managed-runtime-regex.eli +158 -0
- package/stdlib/managed-runtime-sequence.eli +305 -0
- package/stdlib/managed-runtime-set-algebra.eli +28 -0
- package/stdlib/managed-runtime-set.eli +9 -0
- package/stdlib/managed-runtime-sorted.eli +408 -0
- package/stdlib/managed-runtime-text.eli +14 -0
- package/stdlib/managed-runtime-transducer.eli +268 -0
- package/stdlib/managed-runtime-transient.eli +17 -0
- package/stdlib/managed-runtime-truth.eli +4 -0
- package/stdlib/managed-runtime-type.eli +232 -0
- package/stdlib/managed-runtime-value-internals.eli +13 -0
- package/stdlib/managed-runtime-value.eli +19 -0
- package/stdlib/managed-runtime-vector.eli +20 -0
- package/stdlib/managed-sorted-state.eli +233 -0
- package/stdlib/managed-testing-value.eli +6 -0
- package/stdlib/managed-transient-state.eli +348 -0
- package/stdlib/managed-value-state.eli +153 -0
- package/stdlib/managed-vector-view-state.eli +102 -0
- package/stdlib/managed-wire-http-rpc.eli +362 -0
- package/stdlib/managed-wire-markdown.eli +275 -0
- package/stdlib/managed-wire-schema.eli +193 -0
- package/stdlib/mdp.eli +7 -0
- package/stdlib/mds.eli +4 -0
- package/stdlib/persistent-vector.eli +23 -6
- package/tools/acceptance/check-legacy.mjs +687 -0
- package/tools/acceptance/check.eli +431 -0
- package/tools/acceptance/compile-evidence.el +49 -0
- package/tools/acceptance/finalize-legacy.mjs +498 -0
- package/tools/acceptance/finalize.eli +270 -0
- package/tools/backends/benchmark.mjs +175 -0
- package/tools/backends/build.mjs +135 -0
- package/tools/backends/compile.mjs +94 -0
- package/tools/backends/compiler-bootstrap.mjs +1001 -0
- package/tools/backends/compiler-browser.mjs +361 -0
- package/tools/backends/compiler-build.mjs +1628 -0
- package/tools/backends/compiler-cli-legacy.mjs +334 -0
- package/tools/backends/compiler-cli.mjs +29 -0
- package/tools/backends/compiler-corpus-bit.mjs +234 -0
- package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
- package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
- package/tools/backends/compiler-corpus-debugging.mjs +221 -0
- package/tools/backends/compiler-corpus-emitter.mjs +324 -0
- package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
- package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
- package/tools/backends/compiler-corpus-execution.mjs +3324 -0
- package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
- package/tools/backends/compiler-corpus-generations.mjs +208 -0
- package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
- package/tools/backends/compiler-corpus-host-context.mjs +550 -0
- package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
- package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
- package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
- package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
- package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
- package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
- package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
- package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
- package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
- package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
- package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
- package/tools/backends/compiler-corpus-matchers.mjs +173 -0
- package/tools/backends/compiler-corpus-original-program.mjs +612 -0
- package/tools/backends/compiler-corpus-process.mjs +765 -0
- package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
- package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
- package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
- package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
- package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
- package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
- package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
- package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
- package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
- package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
- package/tools/backends/compiler-corpus-reference.mjs +241 -0
- package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
- package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
- package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
- package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
- package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
- package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
- package/tools/backends/compiler-corpus.mjs +2054 -0
- package/tools/backends/compiler-debug.mjs +142 -0
- package/tools/backends/compiler-matrix.mjs +1955 -0
- package/tools/backends/compiler-metadata.mjs +203 -0
- package/tools/backends/compiler-package-browser.mjs +120 -0
- package/tools/backends/compiler-package-legacy.mjs +654 -0
- package/tools/backends/compiler-package.mjs +464 -0
- package/tools/backends/compiler-project.mjs +126 -0
- package/tools/backends/compiler-session.mjs +843 -0
- package/tools/backends/compiler-sha256.mjs +152 -0
- package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
- package/tools/backends/compiler-worker.mjs +573 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
- package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
- package/tools/backends/dist/record-grid.mjs +1256 -0
- package/tools/backends/dist/record-grid.mjs.map +1 -0
- package/tools/backends/dist/release-cli.mjs +460 -0
- package/tools/backends/dist/release-cli.mjs.map +1 -0
- package/tools/backends/dist/run-artifact.mjs +517 -0
- package/tools/backends/dist/run-artifact.mjs.map +1 -0
- package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
- package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
- package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
- package/tools/backends/managed-foreign-binding.mjs +497 -0
- package/tools/backends/managed-host-legacy.mjs +1181 -0
- package/tools/backends/managed-host-lifecycle.mjs +310 -0
- package/tools/backends/managed-host-object-provider.mjs +155 -0
- package/tools/backends/managed-host-object-realm.mjs +797 -0
- package/tools/backends/managed-host-proxy.mjs +71 -0
- package/tools/backends/managed-host-runtime.mjs +5868 -0
- package/tools/backends/managed-host.mjs +716 -0
- package/tools/backends/managed-module-graph-legacy.mjs +308 -0
- package/tools/backends/managed-module-graph.mjs +694 -0
- package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
- package/tools/backends/managed-runtime.mjs +939 -0
- package/tools/backends/managed-source-view-legacy.mjs +332 -0
- package/tools/backends/managed-source-view.mjs +959 -0
- package/tools/backends/memory-runtime.mjs +100 -0
- package/tools/backends/native-benchmark.mjs +88 -0
- package/tools/backends/native-managed-runtime.mjs +677 -0
- package/tools/backends/native-memory.mjs +768 -0
- package/tools/backends/native-node-memory.mjs +142 -0
- package/tools/backends/native-node-runner.mjs +99 -0
- package/tools/backends/native-node-watchdog.mjs +19 -0
- package/tools/backends/native-node-worker.mjs +75 -0
- package/tools/backends/stage3-targets.mjs +486 -0
- package/tools/bootstrap-command.el +13 -0
- package/tools/bootstrap-runtime.el +101 -0
- package/tools/bootstrap-seed.el +55 -0
- package/tools/project/check-cli.eli +31 -0
- package/tools/project/project-cli.eli +42 -0
- package/tools/project/project.eli +122 -0
- package/tools/runtime/unicode-case-profiles.mjs +13 -0
- package/tools/runtime/unicode-case-runtime.el +57 -0
- package/tools/testing/source-debugging-corpus-host.eli +16 -0
- package/tools/testing/source-debugging.eli +139 -0
- package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
- package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
- package/tools/testing/stdlib-bit.eli +104 -0
- package/tools/testing/stdlib-bit.mjs +255 -0
- package/bin/eliscript-bootstrap +0 -15
|
@@ -0,0 +1,579 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-collection
|
|
2
|
+
(import "../../stdlib/core/protocol.eli"
|
|
3
|
+
extend-protocol-category extend-protocol-type implements-protocol? protocol-method)
|
|
4
|
+
(import "../../stdlib/managed-literal-protocols.eli"
|
|
5
|
+
I_COUNTED I_EMPTYABLE I_CONJ I_INDEXED I_LOOKUP I_ASSOCIATIVE I_REDUCE I_KV_REDUCE I_MAP I_SET I_STACK I_REVERSIBLE I_SEQABLE
|
|
6
|
+
managed-literal-is-reduced managed-literal-reduced managed-literal-unreduced
|
|
7
|
+
managed-literal-reduce-iterable managed-literal-sequence-view managed-literal-unbounded-sequence-view
|
|
8
|
+
managed-literal-install-slot managed-literal-checked-count ManagedLiteralSequenceView
|
|
9
|
+
managed-literal-read-sequence-state managed-literal-shift-sequence-count managed-literal-sequence-from-count
|
|
10
|
+
PERSISTENT_MAP_KIND PERSISTENT_MAP_HAS_VALUE_KEY PERSISTENT_SET_KIND PERSISTENT_SET_HAS_VALUE)
|
|
11
|
+
(import "./list.mjs" isPersistentList)
|
|
12
|
+
(import "./vector.mjs" isPersistentVector)
|
|
13
|
+
(import "./queue.mjs" isPersistentQueue)
|
|
14
|
+
(import "./record.mjs" isRecord)
|
|
15
|
+
(import "./set.mjs" persistentHashSet)
|
|
16
|
+
|
|
17
|
+
(defconst ICounted I_COUNTED)
|
|
18
|
+
(defconst IEmptyable I_EMPTYABLE)
|
|
19
|
+
(defconst IConj I_CONJ)
|
|
20
|
+
(defconst ILookup I_LOOKUP)
|
|
21
|
+
(defconst IAssociative I_ASSOCIATIVE)
|
|
22
|
+
(defconst IIndexed I_INDEXED)
|
|
23
|
+
(defconst ISeqable I_SEQABLE)
|
|
24
|
+
(defconst IReduce I_REDUCE)
|
|
25
|
+
(defconst IKVReduce I_KV_REDUCE)
|
|
26
|
+
(defconst IMap I_MAP)
|
|
27
|
+
(defconst ISet I_SET)
|
|
28
|
+
(defconst IStack I_STACK)
|
|
29
|
+
(defconst IReversible I_REVERSIBLE)
|
|
30
|
+
(defconst SequenceView ManagedLiteralSequenceView)
|
|
31
|
+
(defconst MISSING (funcall globalThis/Symbol "eliscript.collection.missing"))
|
|
32
|
+
(defconst memo-state (funcall globalThis/Symbol "eliscript.collection.memoized-sequence-state"))
|
|
33
|
+
(defconst memo-token (funcall globalThis/Symbol "eliscript.collection.memoized-sequence-token"))
|
|
34
|
+
(defconst no-memo-failure (funcall globalThis/Symbol "eliscript.collection.no-memoized-sequence-failure"))
|
|
35
|
+
(defconst reduction-state (funcall globalThis/Symbol "eliscript.collection.reduction-state"))
|
|
36
|
+
(defconst reduction-token (funcall globalThis/Symbol "eliscript.collection.reduction-token"))
|
|
37
|
+
(defun fail (message) (throw (new globalThis/TypeError message)))
|
|
38
|
+
(defun callable? (value) (= (js* "typeof value") "function"))
|
|
39
|
+
(defun boolean? (value) (= (js* "typeof value") "boolean"))
|
|
40
|
+
(defun object? (value) (and (not (nil? value)) (= (js* "typeof value") "object")))
|
|
41
|
+
(defun instance? (value constructor)
|
|
42
|
+
(let ((method (aref constructor (aref globalThis/Symbol "hasInstance"))))
|
|
43
|
+
(when (nullish? method)
|
|
44
|
+
(setq method (aref (aref globalThis/Function "prototype") (aref globalThis/Symbol "hasInstance"))))
|
|
45
|
+
(js-call method :call constructor value)))
|
|
46
|
+
(defun truth (value) (funcall globalThis/Boolean value))
|
|
47
|
+
(defun selfIterable (iterator enumerable)
|
|
48
|
+
(let ((method (funcall
|
|
49
|
+
(js* "(fn, name) => { if (typeof name !== \"string\") throw new TypeError(\"method name must be a string\"); return ({ [name](...args) { return Reflect.apply(fn, undefined, [this, ...args]); } })[name]; }")
|
|
50
|
+
(lambda (receiver) receiver) "[Symbol.iterator]")))
|
|
51
|
+
(Object/defineProperty iterator (aref globalThis/Symbol "iterator")
|
|
52
|
+
(js-object :value method :enumerable enumerable :writable t :configurable t))) iterator)
|
|
53
|
+
(defun invoke (protocol operation &rest arguments) (apply (protocol-method protocol operation) arguments))
|
|
54
|
+
(defun iteratorFromFactory (factory)
|
|
55
|
+
(let ((iterator (funcall factory)))
|
|
56
|
+
(unless (and (object? iterator) (callable? (aref iterator "next")))
|
|
57
|
+
(fail "sequence view factory must return an iterator")) iterator))
|
|
58
|
+
(defun isPersistentMapValue (value)
|
|
59
|
+
(and (not (nullish? value)) (eq (aref value PERSISTENT_MAP_KIND) t)
|
|
60
|
+
(callable? (aref value PERSISTENT_MAP_HAS_VALUE_KEY))))
|
|
61
|
+
(defun isPersistentSetValue (value)
|
|
62
|
+
(and (not (nullish? value)) (eq (aref value PERSISTENT_SET_KIND) t)
|
|
63
|
+
(callable? (aref value PERSISTENT_SET_HAS_VALUE))))
|
|
64
|
+
|
|
65
|
+
(defun memoRead (state index)
|
|
66
|
+
(cond
|
|
67
|
+
((< index (js-length (aref state "values")))
|
|
68
|
+
(js-object :value (aref (aref state "values") index) :done false))
|
|
69
|
+
((not (eq (aref state "failure") no-memo-failure)) (throw (aref state "failure")))
|
|
70
|
+
((aref state "complete") (js-object :value undefined :done t))
|
|
71
|
+
(t
|
|
72
|
+
(unless (aref state "started")
|
|
73
|
+
(put state :started t)
|
|
74
|
+
(try
|
|
75
|
+
(put state :source (iteratorFromFactory (aref state "factory")))
|
|
76
|
+
(put state :factory nil)
|
|
77
|
+
(catch error (put state :failure error) (throw error))))
|
|
78
|
+
(try
|
|
79
|
+
(let ((result (js-call (aref state "source") :next)))
|
|
80
|
+
(unless (and (object? result) (boolean? (aref result "done")))
|
|
81
|
+
(fail "sequence iterator must return an iterator result"))
|
|
82
|
+
(if (truth (aref result "done"))
|
|
83
|
+
(progn (put state :complete t) (put state :source nil) (js-object :value undefined :done t))
|
|
84
|
+
(progn
|
|
85
|
+
(js-call (aref state "values") :push (aref result "value"))
|
|
86
|
+
(js-object :value (aref result "value") :done false))))
|
|
87
|
+
(catch error
|
|
88
|
+
(let ((source (aref state "source")))
|
|
89
|
+
(put state :failure error)
|
|
90
|
+
(put state :source nil)
|
|
91
|
+
(when (and (not (nil? source)) (callable? (aref source "return")))
|
|
92
|
+
(try (js-call source :return) (catch close-error nil)))
|
|
93
|
+
(throw error)))))))
|
|
94
|
+
(defun memoSourceIterator (state)
|
|
95
|
+
(let ((index 0) (closed false) (iterator nil))
|
|
96
|
+
(setq iterator (js-object
|
|
97
|
+
:next (lambda ()
|
|
98
|
+
(if closed (js-object :value undefined :done t)
|
|
99
|
+
(let ((result (js-call state :read index)))
|
|
100
|
+
(unless (truth (aref result "done")) (setq index (1+ index))) result)))
|
|
101
|
+
:return (lambda (&optional value) (setq closed t) (js-object :value value :done t))))
|
|
102
|
+
(selfIterable iterator t)))
|
|
103
|
+
(defun memoIterator (receiver)
|
|
104
|
+
(js-call (aref (aref receiver memo-state) "source") :iterator))
|
|
105
|
+
(defun MemoizedSequenceSource (factory)
|
|
106
|
+
(put (js* "this") :factory factory)
|
|
107
|
+
(put (js* "this") :source nil)
|
|
108
|
+
(put (js* "this") :values (js-array))
|
|
109
|
+
(put (js* "this") :started false)
|
|
110
|
+
(put (js* "this") :complete false)
|
|
111
|
+
(put (js* "this") :failure no-memo-failure))
|
|
112
|
+
(defun installMethod (prototype name implementation arity)
|
|
113
|
+
(let ((method (funcall
|
|
114
|
+
(js* "(fn, name) => { if (typeof name !== \"string\") throw new TypeError(\"method name must be a string\"); return ({ [name](...args) { return Reflect.apply(fn, undefined, [this, ...args]); } })[name]; }")
|
|
115
|
+
implementation name)))
|
|
116
|
+
(Object/defineProperty method "length" (js-object :value arity :configurable t))
|
|
117
|
+
(Object/defineProperty prototype name (js-object :value method :writable t :configurable t))))
|
|
118
|
+
(installMethod (aref MemoizedSequenceSource "prototype") "read" memoRead 1)
|
|
119
|
+
(installMethod (aref MemoizedSequenceSource "prototype") "iterator" memoSourceIterator 0)
|
|
120
|
+
(defun MemoizedSequenceView (token factory count)
|
|
121
|
+
(unless (and (eq token memo-token) (callable? factory))
|
|
122
|
+
(fail "MemoizedSequenceView values must be created by memoizedSequenceView"))
|
|
123
|
+
(Object/defineProperty (js* "this") memo-state
|
|
124
|
+
(js-object :value (Object/freeze (js-object :source (new MemoizedSequenceSource factory) :count count))
|
|
125
|
+
:enumerable t :writable t :configurable t))
|
|
126
|
+
(Object/freeze (js* "this")))
|
|
127
|
+
(defun memoizedSequenceView (factory &optional count)
|
|
128
|
+
(when (undefined? count) (setq count nil))
|
|
129
|
+
(unless (callable? factory) (fail "memoized sequence view factory must be a function"))
|
|
130
|
+
(unless (nil? count) (managed-literal-checked-count count))
|
|
131
|
+
(if (eq count 0) nil (new MemoizedSequenceView memo-token factory count)))
|
|
132
|
+
(defun memoCount (receiver)
|
|
133
|
+
(let ((count (aref (aref receiver memo-state) "count")))
|
|
134
|
+
(if (not (nil? count)) count
|
|
135
|
+
(let ((iterator (memoIterator receiver)) (result 0) (done false))
|
|
136
|
+
(while (not done)
|
|
137
|
+
(setq done (truth (aref (js-call iterator :next) "done")))
|
|
138
|
+
(unless done (setq result (managed-literal-checked-count (1+ result))))) result))))
|
|
139
|
+
(defun memoSeq (receiver)
|
|
140
|
+
(let ((iterator (memoIterator receiver)))
|
|
141
|
+
(try (if (truth (aref (js-call iterator :next) "done")) nil receiver)
|
|
142
|
+
(finally (js-call iterator :return)))))
|
|
143
|
+
(defun memoizedSequenceStatus (value)
|
|
144
|
+
(unless (instance? value MemoizedSequenceView) (fail "expected a memoized sequence view"))
|
|
145
|
+
(let ((source (aref (aref value memo-state) "source")))
|
|
146
|
+
(Object/freeze (js-object :started (aref source "started") :complete (aref source "complete")
|
|
147
|
+
:failed (not (eq (aref source "failure") no-memo-failure)) :realizedCount (js-length (aref source "values"))))))
|
|
148
|
+
(defun ReductionView (token reduce-function)
|
|
149
|
+
(unless (and (eq token reduction-token) (callable? reduce-function))
|
|
150
|
+
(fail "ReductionView values must be created by reductionView"))
|
|
151
|
+
(Object/defineProperty (js* "this") reduction-state
|
|
152
|
+
(js-object :value reduce-function :enumerable t :writable t :configurable t))
|
|
153
|
+
(Object/freeze (js* "this")))
|
|
154
|
+
(defun reductionView (reduce-function)
|
|
155
|
+
(unless (callable? reduce-function) (fail "reduction view function must be a function"))
|
|
156
|
+
(new ReductionView reduction-token reduce-function))
|
|
157
|
+
(defun sequenceView (factory &optional count)
|
|
158
|
+
(managed-literal-sequence-view factory (if (undefined? count) nil count)))
|
|
159
|
+
(defun unboundedSequenceView (factory) (managed-literal-unbounded-sequence-view factory))
|
|
160
|
+
(defun sequenceState (sequence)
|
|
161
|
+
(if (instance? sequence SequenceView) (managed-literal-read-sequence-state sequence)
|
|
162
|
+
(js-object :factory (lambda () (js-call (aref sequence (aref globalThis/Symbol "iterator")) :call sequence))
|
|
163
|
+
:count (aref (aref sequence memo-state) "count"))))
|
|
164
|
+
(defun sliceSequenceView (sequence offset)
|
|
165
|
+
(if (nil? sequence) nil
|
|
166
|
+
(progn
|
|
167
|
+
(unless (isSequenceView sequence) (fail "sequence slice expects a SequenceView or nil"))
|
|
168
|
+
(managed-literal-checked-count offset)
|
|
169
|
+
(if (= offset 0) sequence
|
|
170
|
+
(let* ((state (sequenceState sequence))
|
|
171
|
+
(factory (lambda ()
|
|
172
|
+
(let ((iterator (js-call (aref sequence (aref globalThis/Symbol "iterator")) :call sequence))
|
|
173
|
+
(remaining offset) (done false))
|
|
174
|
+
(while (and (> remaining 0) (not done))
|
|
175
|
+
(if (truth (aref (js-call iterator :next) "done")) (setq done t)
|
|
176
|
+
(setq remaining (1- remaining)))) iterator)))
|
|
177
|
+
(count (managed-literal-shift-sequence-count state offset false)))
|
|
178
|
+
(managed-literal-sequence-from-count factory count))))))
|
|
179
|
+
(defun prependIterator (value sequence)
|
|
180
|
+
(let ((stage 0) (running false) (delegate nil) (next nil) (iterator nil) (action nil))
|
|
181
|
+
(setq action (lambda (operation sent)
|
|
182
|
+
(when running (fail "Generator is already running"))
|
|
183
|
+
(setq running t)
|
|
184
|
+
(try
|
|
185
|
+
(cond
|
|
186
|
+
((= stage 3)
|
|
187
|
+
(if (= operation 2) (throw sent) (js-object :value (if (= operation 1) sent undefined) :done t)))
|
|
188
|
+
((and (< stage 2) (/= operation 0))
|
|
189
|
+
(setq stage 3)
|
|
190
|
+
(if (= operation 2) (throw sent) (js-object :value sent :done t)))
|
|
191
|
+
((= stage 0) (setq stage 1) (js-object :value value :done false))
|
|
192
|
+
(t
|
|
193
|
+
(let ((beginning (= stage 1)))
|
|
194
|
+
(when beginning
|
|
195
|
+
(setq stage 2)
|
|
196
|
+
(unless (nil? sequence)
|
|
197
|
+
(setq delegate (js-call (aref sequence (aref globalThis/Symbol "iterator")) :call sequence))
|
|
198
|
+
(unless (or (object? delegate) (callable? delegate)) (fail "iterator must be an object"))
|
|
199
|
+
(setq next (aref delegate "next"))))
|
|
200
|
+
(if (nil? delegate) (progn (setq stage 3) (js-object :value undefined :done t))
|
|
201
|
+
(let ((method (if (= operation 0) next (aref delegate (if (= operation 1) "return" "throw")))))
|
|
202
|
+
(cond
|
|
203
|
+
((and (= operation 1) (nullish? method))
|
|
204
|
+
(setq stage 3) (js-object :value sent :done t))
|
|
205
|
+
((and (= operation 2) (nullish? method))
|
|
206
|
+
(let ((close (aref delegate "return")))
|
|
207
|
+
(unless (nullish? close)
|
|
208
|
+
(let ((result (js-call close :call delegate)))
|
|
209
|
+
(unless (or (object? result) (callable? result)) (fail "iterator return must return an object")))))
|
|
210
|
+
(fail "The iterator does not provide a throw method"))
|
|
211
|
+
(t
|
|
212
|
+
(let ((result (js-call method :call delegate (if beginning undefined sent))))
|
|
213
|
+
(unless (or (object? result) (callable? result)) (fail "iterator result must be an object"))
|
|
214
|
+
(if (truth (aref result "done"))
|
|
215
|
+
(let ((returned (aref result "value")))
|
|
216
|
+
(setq stage 3) (js-object :value (if (= operation 1) returned undefined) :done t)) result)))))))))
|
|
217
|
+
(catch error (setq stage 3) (throw error))
|
|
218
|
+
(finally (setq running false)))))
|
|
219
|
+
(setq iterator (js-object
|
|
220
|
+
:next (lambda (&optional sent) (funcall action 0 sent))
|
|
221
|
+
:return (lambda (&optional sent) (funcall action 1 sent))
|
|
222
|
+
:throw (lambda (&optional sent) (funcall action 2 sent))))
|
|
223
|
+
(selfIterable iterator false)))
|
|
224
|
+
(defun prependSequenceView (value sequence)
|
|
225
|
+
(unless (or (nil? sequence) (isSequenceView sequence)) (fail "sequence prepend expects a SequenceView or nil"))
|
|
226
|
+
(let ((factory (lambda () (prependIterator value sequence))))
|
|
227
|
+
(if (nil? sequence) (sequenceView factory 1)
|
|
228
|
+
(managed-literal-sequence-from-count factory (managed-literal-shift-sequence-count (sequenceState sequence) 0 t)))))
|
|
229
|
+
(defun viewReduce (receiver reducer &rest initial)
|
|
230
|
+
(managed-literal-reduce-iterable receiver reducer initial))
|
|
231
|
+
(defun reductionReduce (receiver reducer &rest initial)
|
|
232
|
+
(let ((method (aref receiver reduction-state)))
|
|
233
|
+
(js-call method :apply receiver (js-cons reducer initial))))
|
|
234
|
+
(managed-literal-install-slot (aref MemoizedSequenceView "prototype") (aref globalThis/Symbol "iterator") memoIterator)
|
|
235
|
+
(managed-literal-install-slot (aref MemoizedSequenceView "prototype") (aref (protocol-method ICounted "count") "slot") memoCount)
|
|
236
|
+
(managed-literal-install-slot (aref MemoizedSequenceView "prototype") (aref (protocol-method ISeqable "seq") "slot") memoSeq)
|
|
237
|
+
(managed-literal-install-slot (aref MemoizedSequenceView "prototype") (aref (protocol-method IReduce "reduce") "slot") viewReduce)
|
|
238
|
+
(managed-literal-install-slot (aref ReductionView "prototype") (aref (protocol-method IReduce "reduce") "slot") reductionReduce)
|
|
239
|
+
(Object/defineProperty (aref MemoizedSequenceView "prototype") (aref globalThis/Symbol "toStringTag")
|
|
240
|
+
(js-object :get (lambda () "EliscriptMemoizedSequenceView") :configurable t))
|
|
241
|
+
(Object/defineProperty (aref ReductionView "prototype") (aref globalThis/Symbol "toStringTag")
|
|
242
|
+
(js-object :get (lambda () "EliscriptReductionView") :configurable t))
|
|
243
|
+
|
|
244
|
+
(defun indexedValue (values index &rest fallbacks)
|
|
245
|
+
(let ((not-found (if (or (= (js-length fallbacks) 0) (undefined? (aref fallbacks 0)))
|
|
246
|
+
MISSING (aref fallbacks 0))))
|
|
247
|
+
(cond ((and (Number/isInteger index) (>= index 0) (< index (js-length values))) (aref values index))
|
|
248
|
+
((not (eq not-found MISSING)) not-found)
|
|
249
|
+
(t (throw (new globalThis/RangeError (str "nth index " index " is outside collection bounds")))))))
|
|
250
|
+
(defun indexedAssoc (values index value)
|
|
251
|
+
(unless (and (Number/isInteger index) (>= index 0) (<= index (js-length values)))
|
|
252
|
+
(throw (new globalThis/RangeError (str "assoc index " index " is outside collection bounds"))))
|
|
253
|
+
(let ((result (js-call values :slice))) (put result index value) result))
|
|
254
|
+
(defun indexedContains (values index) (and (Number/isInteger index) (>= index 0) (< index (js-length values))))
|
|
255
|
+
(defun readEntry (entry)
|
|
256
|
+
(unless (and (not (nullish? entry)) (callable? (aref entry (aref globalThis/Symbol "iterator"))))
|
|
257
|
+
(fail "persistent hash map entries must be iterable key/value pairs"))
|
|
258
|
+
(let ((iterator (iteratorFromFactory (lambda () (js-call (aref entry (aref globalThis/Symbol "iterator")) :call entry))))
|
|
259
|
+
(complete false))
|
|
260
|
+
(try
|
|
261
|
+
(let* ((first (js-call iterator :next)))
|
|
262
|
+
(when (truth (aref first "done")) (fail "persistent hash map entries must contain exactly two values"))
|
|
263
|
+
(let ((second (js-call iterator :next)))
|
|
264
|
+
(when (truth (aref second "done")) (fail "persistent hash map entries must contain exactly two values"))
|
|
265
|
+
(let ((third (js-call iterator :next)))
|
|
266
|
+
(unless (truth (aref third "done")) (fail "persistent hash map entries must contain exactly two values")))
|
|
267
|
+
(setq complete t) (js-array (aref first "value") (aref second "value"))))
|
|
268
|
+
(finally (when (and (not complete) (callable? (aref iterator "return"))) (js-call iterator :return))))))
|
|
269
|
+
(defun cloneObject (source)
|
|
270
|
+
(let ((result (js-object)) (keys (Reflect/ownKeys source)) (index 0))
|
|
271
|
+
(while (< index (js-length keys))
|
|
272
|
+
(let* ((key (aref keys index)) (descriptor (Object/getOwnPropertyDescriptor source key)))
|
|
273
|
+
(when (and (not (undefined? descriptor)) (aref descriptor "enumerable"))
|
|
274
|
+
(Object/defineProperty result key (js-object :value (aref source key) :writable t :enumerable t :configurable t))))
|
|
275
|
+
(setq index (1+ index))) result))
|
|
276
|
+
(defun objectAssoc (values key value)
|
|
277
|
+
(unless (= (js* "typeof key") "string") (fail "plain object association keys must be strings"))
|
|
278
|
+
(let ((result (cloneObject values)))
|
|
279
|
+
(Object/defineProperty result key (js-object :value value :writable t :enumerable t :configurable t)) result))
|
|
280
|
+
(defun objectConj (values entry) (let ((pair (readEntry entry))) (objectAssoc values (aref pair 0) (aref pair 1))))
|
|
281
|
+
(defun objectDissoc (values key)
|
|
282
|
+
(unless (= (js* "typeof key") "string") (fail "plain object dissociation keys must be strings"))
|
|
283
|
+
(let ((result (cloneObject values))) (Reflect/deleteProperty result key) result))
|
|
284
|
+
(defun mapConj (values entry)
|
|
285
|
+
(let* ((pair (readEntry entry)) (result (new globalThis/Map values)))
|
|
286
|
+
(js-call result :set (aref pair 0) (aref pair 1)) result))
|
|
287
|
+
(defun mapAssoc (values key value) (let ((result (new globalThis/Map values))) (js-call result :set key value) result))
|
|
288
|
+
(defun mapDissoc (values key) (let ((result (new globalThis/Map values))) (js-call result :delete key) result))
|
|
289
|
+
(defun setConj (values value) (let ((result (new globalThis/Set values))) (js-call result :add value) result))
|
|
290
|
+
(defun setDisj (values value) (let ((result (new globalThis/Set values))) (js-call result :delete value) result))
|
|
291
|
+
(defun arrayConj (values value)
|
|
292
|
+
(let ((result (managed-literal-reduce-iterable values
|
|
293
|
+
(lambda (result item)
|
|
294
|
+
(Object/defineProperty result (js-length result)
|
|
295
|
+
(js-object :value item :writable t :enumerable t :configurable t)) result)
|
|
296
|
+
(js-array (js-array)))))
|
|
297
|
+
(Object/defineProperty result (js-length result) (js-object :value value :writable t :enumerable t :configurable t)) result))
|
|
298
|
+
(defun arrayPeek (values) (if (= (js-length values) 0) nil (aref values (1- (js-length values)))))
|
|
299
|
+
(defun arrayPop (values)
|
|
300
|
+
(when (= (js-length values) 0) (throw (new globalThis/RangeError "cannot pop an empty array")))
|
|
301
|
+
(js-call values :slice 0 -1))
|
|
302
|
+
(defun indexedReverseSequence (values)
|
|
303
|
+
(if (= (js-length values) 0) nil
|
|
304
|
+
(sequenceView (lambda ()
|
|
305
|
+
(let ((index (js-length values)))
|
|
306
|
+
(js-object :next (lambda ()
|
|
307
|
+
(if (= index 0) (js-object :value undefined :done t)
|
|
308
|
+
(progn (setq index (1- index)) (js-object :value (aref values index) :done false)))))))
|
|
309
|
+
(lambda () (js-length values)))))
|
|
310
|
+
(defun arraySequence (values)
|
|
311
|
+
(if (= (js-length values) 0) nil
|
|
312
|
+
(sequenceView (lambda () (js-call (aref values (aref globalThis/Symbol "iterator")) :call values)) (lambda () (js-length values)))))
|
|
313
|
+
(defun stringSequence (value)
|
|
314
|
+
(if (= (js-length value) 0) nil
|
|
315
|
+
(sequenceView (lambda ()
|
|
316
|
+
(let ((index 0))
|
|
317
|
+
(js-object :next (lambda ()
|
|
318
|
+
(if (>= index (js-length value)) (js-object :value undefined :done t)
|
|
319
|
+
(let ((current (aref value index))) (setq index (1+ index)) (js-object :value current :done false)))))))
|
|
320
|
+
(lambda () (js-length value)))))
|
|
321
|
+
(defun objectSequence (value)
|
|
322
|
+
(if (= (js-length (Object/keys value)) 0) nil
|
|
323
|
+
(sequenceView (lambda ()
|
|
324
|
+
(let ((keys nil) (index 0))
|
|
325
|
+
(js-object :next (lambda ()
|
|
326
|
+
(when (nil? keys) (setq keys (Object/keys value)))
|
|
327
|
+
(if (>= index (js-length keys)) (js-object :value undefined :done t)
|
|
328
|
+
(let ((key (aref keys index))) (setq index (1+ index))
|
|
329
|
+
(js-object :value (Object/freeze (js-array key (aref value key))) :done false)))))))
|
|
330
|
+
(lambda () (js-length (Object/keys value))))))
|
|
331
|
+
(defun mappedIterator (factory transform)
|
|
332
|
+
(let ((source nil) (next nil) (closed false) (iterator nil))
|
|
333
|
+
(setq iterator (js-object :next (lambda ()
|
|
334
|
+
(if closed (js-object :value undefined :done t)
|
|
335
|
+
(progn
|
|
336
|
+
(when (nil? source)
|
|
337
|
+
(setq source (funcall factory))
|
|
338
|
+
(unless (or (object? source) (callable? source)) (fail "iterator must be an object"))
|
|
339
|
+
(setq next (aref source "next")))
|
|
340
|
+
(let ((result (js-call next :call source)))
|
|
341
|
+
(unless (or (object? result) (callable? result)) (fail "iterator result must be an object"))
|
|
342
|
+
(if (truth (aref result "done")) (progn (setq closed t) (js-object :value undefined :done t))
|
|
343
|
+
(try (js-object :value (funcall transform (aref result "value")) :done false)
|
|
344
|
+
(catch error (setq closed t)
|
|
345
|
+
(try (let ((close (aref source "return")))
|
|
346
|
+
(unless (nullish? close) (js-call close :call source))) (catch close-error nil))
|
|
347
|
+
(throw error))))))))
|
|
348
|
+
:return (lambda (&optional value)
|
|
349
|
+
(unless closed (setq closed t)
|
|
350
|
+
(unless (nil? source)
|
|
351
|
+
(let ((close (aref source "return")))
|
|
352
|
+
(unless (nullish? close)
|
|
353
|
+
(let ((result (js-call close :call source)))
|
|
354
|
+
(unless (or (object? result) (callable? result)) (fail "iterator return must return an object")))))))
|
|
355
|
+
(js-object :value value :done t))))
|
|
356
|
+
(selfIterable iterator false)))
|
|
357
|
+
(defun mapSequence (values)
|
|
358
|
+
(if (= (aref values "size") 0) nil
|
|
359
|
+
(sequenceView (lambda () (mappedIterator
|
|
360
|
+
(lambda () (js-call (aref values (aref globalThis/Symbol "iterator")) :call values))
|
|
361
|
+
(lambda (entry) (Object/freeze (js-array (aref entry 0) (aref entry 1))))))
|
|
362
|
+
(lambda () (aref values "size")))))
|
|
363
|
+
(defun setSequence (values)
|
|
364
|
+
(if (= (aref values "size") 0) nil
|
|
365
|
+
(sequenceView (lambda () (js-call (aref values (aref globalThis/Symbol "iterator")) :call values)) (lambda () (aref values "size")))))
|
|
366
|
+
(defun reduceIndexedValues (values reducer initial)
|
|
367
|
+
(let ((result initial) (index 0) (done false))
|
|
368
|
+
(while (and (< index (js-length values)) (not done))
|
|
369
|
+
(setq result (funcall reducer result index (aref values index)))
|
|
370
|
+
(when (managed-literal-is-reduced result)
|
|
371
|
+
(setq result (managed-literal-unreduced result) done t))
|
|
372
|
+
(setq index (1+ index)))
|
|
373
|
+
result))
|
|
374
|
+
(defun reduceObjectValues (value reducer initial)
|
|
375
|
+
(let ((keys (Object/keys value)) (index 0) (result initial) (done false))
|
|
376
|
+
(while (and (< index (js-length keys)) (not done))
|
|
377
|
+
(let ((key (aref keys index)))
|
|
378
|
+
(setq result (funcall reducer result key (aref value key))))
|
|
379
|
+
(setq index (1+ index))
|
|
380
|
+
(when (managed-literal-is-reduced result)
|
|
381
|
+
(setq result (managed-literal-unreduced result) done t)))
|
|
382
|
+
result))
|
|
383
|
+
(defun reduceMapValues (values reducer initial)
|
|
384
|
+
(managed-literal-reduce-iterable values
|
|
385
|
+
(lambda (result entry)
|
|
386
|
+
(let* ((iterator (js-call (aref entry (aref globalThis/Symbol "iterator")) :call entry))
|
|
387
|
+
(next nil) (done false) (key undefined) (value undefined) (active false))
|
|
388
|
+
(unless (or (object? iterator) (callable? iterator)) (fail "iterator must be an object"))
|
|
389
|
+
(setq next (aref iterator "next"))
|
|
390
|
+
(try
|
|
391
|
+
(let ((first (js-call next :call iterator)))
|
|
392
|
+
(unless (or (object? first) (callable? first)) (fail "iterator result must be an object"))
|
|
393
|
+
(setq done (truth (aref first "done")))
|
|
394
|
+
(unless done
|
|
395
|
+
(setq key (aref first "value"))
|
|
396
|
+
(let ((second (js-call next :call iterator)))
|
|
397
|
+
(unless (or (object? second) (callable? second)) (fail "iterator result must be an object"))
|
|
398
|
+
(setq done (truth (aref second "done")))
|
|
399
|
+
(unless done (setq value (aref second "value"))))))
|
|
400
|
+
(setq active t)
|
|
401
|
+
(unless done
|
|
402
|
+
(setq done t)
|
|
403
|
+
(let ((close (aref iterator "return")))
|
|
404
|
+
(unless (nullish? close)
|
|
405
|
+
(let ((closed (js-call close :call iterator)))
|
|
406
|
+
(unless (or (object? closed) (callable? closed)) (fail "iterator return must return an object"))))))
|
|
407
|
+
(setq done t)
|
|
408
|
+
(funcall reducer result key value)
|
|
409
|
+
(catch error
|
|
410
|
+
(when (and active (not done))
|
|
411
|
+
(try (let ((close (aref iterator "return")))
|
|
412
|
+
(unless (nullish? close) (js-call close :call iterator))) (catch ignored nil)))
|
|
413
|
+
(throw error))))) (js-array initial)))
|
|
414
|
+
|
|
415
|
+
(extend-protocol-category ICounted "string" (js-object :count (lambda (value) (js-length value))))
|
|
416
|
+
(extend-protocol-category IEmptyable "string" (js-object :empty (lambda (&rest ignored) "")))
|
|
417
|
+
(extend-protocol-category ILookup "string" (js-object :get (lambda (value index &optional not-found)
|
|
418
|
+
(indexedValue value index (if (undefined? not-found) nil not-found)))))
|
|
419
|
+
(extend-protocol-category IIndexed "string" (js-object :nth indexedValue))
|
|
420
|
+
(extend-protocol-category ISeqable "string" (js-object :seq stringSequence))
|
|
421
|
+
(extend-protocol-category IReduce "string" (js-object :reduce (lambda (value reducer &rest initial)
|
|
422
|
+
(managed-literal-reduce-iterable (or (stringSequence value) (js-array)) reducer initial))))
|
|
423
|
+
(extend-protocol-category IReversible "string" (js-object :rseq indexedReverseSequence))
|
|
424
|
+
(extend-protocol-type ICounted globalThis/Object (js-object :count (lambda (value) (js-length (Object/keys value)))))
|
|
425
|
+
(extend-protocol-type IEmptyable globalThis/Object (js-object :empty (lambda (&rest ignored) (js-object))))
|
|
426
|
+
(extend-protocol-type IConj globalThis/Object (js-object :conj objectConj))
|
|
427
|
+
(extend-protocol-type ILookup globalThis/Object (js-object :get (lambda (value key &optional not-found)
|
|
428
|
+
(if (and (= (js* "typeof key") "string") (Object/hasOwn value key)) (aref value key) (if (undefined? not-found) nil not-found)))))
|
|
429
|
+
(extend-protocol-type IAssociative globalThis/Object (js-object :assoc objectAssoc :contains
|
|
430
|
+
(lambda (value key) (and (= (js* "typeof key") "string") (Object/hasOwn value key)))))
|
|
431
|
+
(extend-protocol-type ISeqable globalThis/Object (js-object :seq objectSequence))
|
|
432
|
+
(extend-protocol-type IReduce globalThis/Object (js-object :reduce (lambda (value reducer &rest initial)
|
|
433
|
+
(managed-literal-reduce-iterable (or (objectSequence value) (js-array)) reducer initial))))
|
|
434
|
+
(extend-protocol-type IKVReduce globalThis/Object (js-object :reduceKV reduceObjectValues))
|
|
435
|
+
(extend-protocol-type IMap globalThis/Object (js-object :dissoc objectDissoc))
|
|
436
|
+
(extend-protocol-type ICounted globalThis/Array (js-object :count (lambda (values) (js-length values))))
|
|
437
|
+
(extend-protocol-type IEmptyable globalThis/Array (js-object :empty (lambda (&rest ignored) (js-array))))
|
|
438
|
+
(extend-protocol-type IConj globalThis/Array (js-object :conj arrayConj))
|
|
439
|
+
(extend-protocol-type ILookup globalThis/Array (js-object :get (lambda (values index &optional not-found)
|
|
440
|
+
(indexedValue values index (if (undefined? not-found) nil not-found)))))
|
|
441
|
+
(extend-protocol-type IAssociative globalThis/Array (js-object :assoc indexedAssoc :contains indexedContains))
|
|
442
|
+
(extend-protocol-type IIndexed globalThis/Array (js-object :nth indexedValue))
|
|
443
|
+
(extend-protocol-type ISeqable globalThis/Array (js-object :seq arraySequence))
|
|
444
|
+
(extend-protocol-type IReduce globalThis/Array (js-object :reduce (lambda (values reducer &rest initial)
|
|
445
|
+
(managed-literal-reduce-iterable values reducer initial))))
|
|
446
|
+
(extend-protocol-type IKVReduce globalThis/Array (js-object :reduceKV reduceIndexedValues))
|
|
447
|
+
(extend-protocol-type IStack globalThis/Array (js-object :peek arrayPeek :pop arrayPop))
|
|
448
|
+
(extend-protocol-type IReversible globalThis/Array (js-object :rseq indexedReverseSequence))
|
|
449
|
+
(extend-protocol-type ICounted globalThis/Map (js-object :count (lambda (values) (aref values "size"))))
|
|
450
|
+
(extend-protocol-type IEmptyable globalThis/Map (js-object :empty (lambda (&rest ignored) (new globalThis/Map))))
|
|
451
|
+
(extend-protocol-type IConj globalThis/Map (js-object :conj mapConj))
|
|
452
|
+
(extend-protocol-type ILookup globalThis/Map (js-object :get (lambda (values key &optional not-found)
|
|
453
|
+
(if (truth (js-call values :has key)) (js-call values :get key) (if (undefined? not-found) nil not-found)))))
|
|
454
|
+
(extend-protocol-type IAssociative globalThis/Map (js-object :assoc mapAssoc :contains (lambda (values key) (js-call values :has key))))
|
|
455
|
+
(extend-protocol-type ISeqable globalThis/Map (js-object :seq mapSequence))
|
|
456
|
+
(extend-protocol-type IReduce globalThis/Map (js-object :reduce (lambda (values reducer &rest initial)
|
|
457
|
+
(managed-literal-reduce-iterable (or (mapSequence values) (js-array)) reducer initial))))
|
|
458
|
+
(extend-protocol-type IKVReduce globalThis/Map (js-object :reduceKV reduceMapValues))
|
|
459
|
+
(extend-protocol-type IMap globalThis/Map (js-object :dissoc mapDissoc))
|
|
460
|
+
(extend-protocol-type ICounted globalThis/Set (js-object :count (lambda (values) (aref values "size"))))
|
|
461
|
+
(extend-protocol-type IEmptyable globalThis/Set (js-object :empty (lambda (&rest ignored) (new globalThis/Set))))
|
|
462
|
+
(extend-protocol-type IConj globalThis/Set (js-object :conj setConj))
|
|
463
|
+
(extend-protocol-type ILookup globalThis/Set (js-object :get (lambda (values key &optional not-found)
|
|
464
|
+
(if (truth (js-call values :has key)) key (if (undefined? not-found) nil not-found)))))
|
|
465
|
+
(extend-protocol-type IAssociative globalThis/Set (js-object :contains (lambda (values key) (js-call values :has key))))
|
|
466
|
+
(extend-protocol-type ISeqable globalThis/Set (js-object :seq setSequence))
|
|
467
|
+
(extend-protocol-type IReduce globalThis/Set (js-object :reduce (lambda (values reducer &rest initial)
|
|
468
|
+
(managed-literal-reduce-iterable values reducer initial))))
|
|
469
|
+
(extend-protocol-type ISet globalThis/Set (js-object :disj setDisj))
|
|
470
|
+
(extend-protocol-category ICounted "null" (js-object :count (lambda (&rest ignored) 0)))
|
|
471
|
+
(extend-protocol-category IEmptyable "null" (js-object :empty (lambda (&rest ignored) nil)))
|
|
472
|
+
(extend-protocol-category ISeqable "null" (js-object :seq (lambda (&rest ignored) nil)))
|
|
473
|
+
(extend-protocol-category IReduce "null" (js-object :reduce (lambda (_ reducer &rest initial)
|
|
474
|
+
(managed-literal-reduce-iterable (js-array) reducer initial))))
|
|
475
|
+
(extend-protocol-category IKVReduce "null" (js-object :reduceKV (lambda (_ reducer initial) initial)))
|
|
476
|
+
(extend-protocol-category IMap "null" (js-object :dissoc (lambda (&rest ignored) nil)))
|
|
477
|
+
(extend-protocol-category ISet "null" (js-object :disj (lambda (&rest ignored) nil)))
|
|
478
|
+
(extend-protocol-category IStack "null" (js-object :peek (lambda (&rest ignored) nil) :pop (lambda (&rest ignored) nil)))
|
|
479
|
+
(extend-protocol-category IReversible "null" (js-object :rseq (lambda (&rest ignored) nil)))
|
|
480
|
+
|
|
481
|
+
(defun count (collection) (managed-literal-checked-count (invoke ICounted "count" collection)))
|
|
482
|
+
(defun isCounted (collection) (implements-protocol? ICounted collection))
|
|
483
|
+
(defun isIndexed (collection) (implements-protocol? IIndexed collection))
|
|
484
|
+
(defun isSeqable (collection) (implements-protocol? ISeqable collection))
|
|
485
|
+
(defun isReducible (collection) (implements-protocol? IReduce collection))
|
|
486
|
+
(defun isReversible (collection) (implements-protocol? IReversible collection))
|
|
487
|
+
(defun isAssociative (collection) (implements-protocol? IAssociative collection))
|
|
488
|
+
(defun isSequenceView (value) (or (instance? value SequenceView) (instance? value MemoizedSequenceView)))
|
|
489
|
+
(defun isReductionView (value) (instance? value ReductionView))
|
|
490
|
+
(defun isCollection (value) (or (isSequenceView value) (isPersistentList value) (isPersistentQueue value)
|
|
491
|
+
(isPersistentVector value) (isPersistentMapValue value) (isRecord value) (isPersistentSetValue value)))
|
|
492
|
+
(defun isList (value) (isPersistentList value))
|
|
493
|
+
(defun isVector (value) (isPersistentVector value))
|
|
494
|
+
(defun isQueue (value) (isPersistentQueue value))
|
|
495
|
+
(defun isMap (value) (or (isPersistentMapValue value) (isRecord value)))
|
|
496
|
+
(defun isSet (value) (isPersistentSetValue value))
|
|
497
|
+
(defun isSequential (value) (or (isSequenceView value) (isPersistentList value) (isPersistentQueue value) (isPersistentVector value)))
|
|
498
|
+
(defun isSequence (value) (or (isSequenceView value) (isPersistentList value)))
|
|
499
|
+
(defun boundedCount (limit collection)
|
|
500
|
+
(unless (and (Number/isSafeInteger limit) (>= limit 0)) (fail "boundedCount limit must be a non-negative safe integer"))
|
|
501
|
+
(if (= limit 0) 0
|
|
502
|
+
(let ((sequence (seq collection)))
|
|
503
|
+
(if (nil? sequence) 0
|
|
504
|
+
(let ((iterator (js-call (aref sequence (aref globalThis/Symbol "iterator")) :call sequence)) (result 0) (complete false))
|
|
505
|
+
(try
|
|
506
|
+
(while (and (< result limit) (not (truth (aref (js-call iterator :next) "done"))))
|
|
507
|
+
(setq result (1+ result)))
|
|
508
|
+
(setq complete t)
|
|
509
|
+
(finally
|
|
510
|
+
(when (and (or (not complete) (= result limit)) (callable? (aref iterator "return")))
|
|
511
|
+
(js-call iterator :return))))
|
|
512
|
+
result)))))
|
|
513
|
+
(defun areDistinct (&rest values)
|
|
514
|
+
(let ((seen (persistentHashSet)) (index 0) (distinct t))
|
|
515
|
+
(while (and distinct (< index (js-length values)))
|
|
516
|
+
(let ((value (aref values index)))
|
|
517
|
+
(if (truth (js-call seen :has value)) (setq distinct false) (setq seen (js-call seen :conj value))))
|
|
518
|
+
(setq index (1+ index))) distinct))
|
|
519
|
+
(defun empty (collection) (invoke IEmptyable "empty" collection))
|
|
520
|
+
(defun conj (collection &rest values)
|
|
521
|
+
(let ((result collection) (index 0))
|
|
522
|
+
(while (< index (js-length values)) (setq result (invoke IConj "conj" result (aref values index)) index (1+ index))) result))
|
|
523
|
+
(defun get (collection key &optional not-found)
|
|
524
|
+
(invoke ILookup "get" collection key (if (undefined? not-found) nil not-found)))
|
|
525
|
+
(defun assoc (&rest arguments)
|
|
526
|
+
(unless (and (>= (js-length arguments) 3) (= (% (- (js-length arguments) 1) 2) 0))
|
|
527
|
+
(fail "assoc requires a collection followed by one or more key/value pairs"))
|
|
528
|
+
(let ((result (aref arguments 0)) (index 1))
|
|
529
|
+
(while (< index (js-length arguments))
|
|
530
|
+
(setq result (invoke IAssociative "assoc" result (aref arguments index) (aref arguments (1+ index))) index (+ index 2))) result))
|
|
531
|
+
(defun contains (collection key)
|
|
532
|
+
(let ((result (invoke IAssociative "contains" collection key)))
|
|
533
|
+
(unless (= (js* "typeof result") "boolean") (fail "IAssociative/contains must return a boolean")) result))
|
|
534
|
+
(defun nth (collection index &rest not-found)
|
|
535
|
+
(if (= (js-length not-found) 0) (invoke IIndexed "nth" collection index) (invoke IIndexed "nth" collection index (aref not-found 0))))
|
|
536
|
+
(defun checkedSequence (result message)
|
|
537
|
+
(if (nil? result) nil
|
|
538
|
+
(progn (when (or (undefined? result) (not (callable? (aref result (aref globalThis/Symbol "iterator"))))) (fail message)) result)))
|
|
539
|
+
(defun seq (collection) (checkedSequence (invoke ISeqable "seq" collection) "ISeqable/seq must return null or an iterable sequence view"))
|
|
540
|
+
(defun isEmpty (collection) (nil? (seq collection)))
|
|
541
|
+
(defun notEmpty (collection) (if (isEmpty collection) nil collection))
|
|
542
|
+
(defun reduce (collection reducer &rest initial)
|
|
543
|
+
(unless (callable? reducer) (fail "collection reducer must be a function"))
|
|
544
|
+
(managed-literal-unreduced (if (= (js-length initial) 0)
|
|
545
|
+
(invoke IReduce "reduce" collection reducer) (invoke IReduce "reduce" collection reducer (aref initial 0)))))
|
|
546
|
+
(defun reduceKV (&rest arguments)
|
|
547
|
+
(unless (= (js-length arguments) 3) (fail "reduceKV requires a collection, reducer, and initial value"))
|
|
548
|
+
(unless (callable? (aref arguments 1)) (fail "key/value reducer must be a function"))
|
|
549
|
+
(managed-literal-unreduced (invoke IKVReduce "reduceKV" (aref arguments 0) (aref arguments 1) (aref arguments 2))))
|
|
550
|
+
(defun dissoc (collection &rest keys)
|
|
551
|
+
(let ((result collection) (index 0))
|
|
552
|
+
(while (< index (js-length keys)) (setq result (invoke IMap "dissoc" result (aref keys index)) index (1+ index))) result))
|
|
553
|
+
(defun disj (collection &rest values)
|
|
554
|
+
(let ((result collection) (index 0))
|
|
555
|
+
(while (< index (js-length values)) (setq result (invoke ISet "disj" result (aref values index)) index (1+ index))) result))
|
|
556
|
+
(defun peek (&rest arguments)
|
|
557
|
+
(unless (= (js-length arguments) 1) (fail "peek requires exactly one collection")) (invoke IStack "peek" (aref arguments 0)))
|
|
558
|
+
(defun pop (&rest arguments)
|
|
559
|
+
(unless (= (js-length arguments) 1) (fail "pop requires exactly one collection")) (invoke IStack "pop" (aref arguments 0)))
|
|
560
|
+
(defun rseq (&rest arguments)
|
|
561
|
+
(unless (= (js-length arguments) 1) (fail "rseq requires exactly one collection"))
|
|
562
|
+
(checkedSequence (invoke IReversible "rseq" (aref arguments 0)) "IReversible/rseq must return null or an iterable sequence view"))
|
|
563
|
+
(defun reduced (value) (managed-literal-reduced value))
|
|
564
|
+
(defun isReduced (value) (managed-literal-is-reduced value))
|
|
565
|
+
(defun unreduced (value) (managed-literal-unreduced value))
|
|
566
|
+
(Object/defineProperty assoc "length" (js-object :value 3 :configurable t))
|
|
567
|
+
(Object/defineProperty reduceKV "length" (js-object :value 3 :configurable t))
|
|
568
|
+
(Object/defineProperty peek "length" (js-object :value 1 :configurable t))
|
|
569
|
+
(Object/defineProperty pop "length" (js-object :value 1 :configurable t))
|
|
570
|
+
(Object/defineProperty rseq "length" (js-object :value 1 :configurable t))
|
|
571
|
+
(Object/defineProperty sequenceView "length" (js-object :value 1 :configurable t))
|
|
572
|
+
(Object/defineProperty memoizedSequenceView "length" (js-object :value 1 :configurable t))
|
|
573
|
+
(Object/defineProperty get "length" (js-object :value 2 :configurable t))
|
|
574
|
+
(export ICounted IEmptyable IConj ILookup IAssociative IIndexed ISeqable IReduce IKVReduce IMap ISet IStack IReversible
|
|
575
|
+
ReductionView MemoizedSequenceView SequenceView reductionView memoizedSequenceView memoizedSequenceStatus sequenceView unboundedSequenceView
|
|
576
|
+
sliceSequenceView prependSequenceView
|
|
577
|
+
count isCounted isIndexed isSeqable isReducible isReversible isAssociative isCollection isList isVector isQueue isMap isSet
|
|
578
|
+
isSequential isSequence boundedCount areDistinct empty conj get assoc contains nth seq isEmpty notEmpty reduce reduceKV
|
|
579
|
+
dissoc disj peek pop rseq reduced isReduced unreduced isSequenceView isReductionView))
|