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,724 @@
|
|
|
1
|
+
(module eliscript.persistent-map
|
|
2
|
+
(defconst persistent-map-kind "eliscript/persistent-map")
|
|
3
|
+
(defconst persistent-map-entry-kind "entry")
|
|
4
|
+
(defconst persistent-map-bitmap-kind "bitmap")
|
|
5
|
+
(defconst persistent-map-array-kind "array")
|
|
6
|
+
(defconst persistent-map-collision-kind "collision")
|
|
7
|
+
(defconst persistent-map-branch-bits 5)
|
|
8
|
+
(defconst persistent-map-branch-width 32)
|
|
9
|
+
(defconst persistent-map-branch-mask 31)
|
|
10
|
+
(defconst persistent-map-array-threshold 32)
|
|
11
|
+
(defconst persistent-map-bitmap-threshold 24)
|
|
12
|
+
(defconst persistent-map-max-count 2147483647)
|
|
13
|
+
|
|
14
|
+
(defportable persistent-map-array-reverse (values)
|
|
15
|
+
(let ((result (js-array))
|
|
16
|
+
(index 0))
|
|
17
|
+
(while (< index (js-length values))
|
|
18
|
+
(setq result (js-cons (get values index) result)
|
|
19
|
+
index (1+ index)))
|
|
20
|
+
result))
|
|
21
|
+
|
|
22
|
+
(defportable persistent-map-array-copy-assoc (values wanted-index value)
|
|
23
|
+
(let ((result (js-array))
|
|
24
|
+
(index 0)
|
|
25
|
+
(result-length
|
|
26
|
+
(if (< wanted-index (js-length values))
|
|
27
|
+
(js-length values)
|
|
28
|
+
(1+ wanted-index))))
|
|
29
|
+
(while (< index result-length)
|
|
30
|
+
(setq result
|
|
31
|
+
(js-cons
|
|
32
|
+
(if (= index wanted-index) value (get values index))
|
|
33
|
+
result)
|
|
34
|
+
index (1+ index)))
|
|
35
|
+
(persistent-map-array-reverse result)))
|
|
36
|
+
|
|
37
|
+
(defportable persistent-map-array-insert (values wanted-index value)
|
|
38
|
+
(let ((result (js-array))
|
|
39
|
+
(index 0))
|
|
40
|
+
(while (< index (js-length values))
|
|
41
|
+
(when (= index wanted-index)
|
|
42
|
+
(setq result (js-cons value result)))
|
|
43
|
+
(setq result (js-cons (get values index) result)
|
|
44
|
+
index (1+ index)))
|
|
45
|
+
(when (= wanted-index (js-length values))
|
|
46
|
+
(setq result (js-cons value result)))
|
|
47
|
+
(persistent-map-array-reverse result)))
|
|
48
|
+
|
|
49
|
+
(defportable persistent-map-array-remove (values wanted-index)
|
|
50
|
+
(let ((result (js-array))
|
|
51
|
+
(index 0))
|
|
52
|
+
(while (< index (js-length values))
|
|
53
|
+
(unless (= index wanted-index)
|
|
54
|
+
(setq result (js-cons (get values index) result)))
|
|
55
|
+
(setq index (1+ index)))
|
|
56
|
+
(persistent-map-array-reverse result)))
|
|
57
|
+
|
|
58
|
+
(defportable persistent-map-array-append (values value)
|
|
59
|
+
(persistent-map-array-copy-assoc values (js-length values) value))
|
|
60
|
+
|
|
61
|
+
(defportable persistent-map-bit-count (value)
|
|
62
|
+
(let* ((bits (uint32 value))
|
|
63
|
+
(pairs
|
|
64
|
+
(- bits
|
|
65
|
+
(bit-and
|
|
66
|
+
(unsigned-bit-shift-right bits 1)
|
|
67
|
+
1431655765)))
|
|
68
|
+
(quads
|
|
69
|
+
(+ (bit-and pairs 858993459)
|
|
70
|
+
(bit-and
|
|
71
|
+
(unsigned-bit-shift-right pairs 2)
|
|
72
|
+
858993459)))
|
|
73
|
+
(octets
|
|
74
|
+
(bit-and
|
|
75
|
+
(+ quads (unsigned-bit-shift-right quads 4))
|
|
76
|
+
252645135)))
|
|
77
|
+
(unsigned-bit-shift-right
|
|
78
|
+
(imul32 octets 16843009)
|
|
79
|
+
24)))
|
|
80
|
+
|
|
81
|
+
(defportable persistent-map-branch-index (hash shift)
|
|
82
|
+
(bit-and
|
|
83
|
+
(unsigned-bit-shift-right hash shift)
|
|
84
|
+
persistent-map-branch-mask))
|
|
85
|
+
|
|
86
|
+
(defportable persistent-map-bit-position (hash shift)
|
|
87
|
+
(uint32
|
|
88
|
+
(bit-shift-left 1 (persistent-map-branch-index hash shift))))
|
|
89
|
+
|
|
90
|
+
(defportable persistent-map-packed-index (bitmap bit)
|
|
91
|
+
(persistent-map-bit-count (bit-and bitmap (1- bit))))
|
|
92
|
+
|
|
93
|
+
(defportable persistent-map-make-entry (hash key value)
|
|
94
|
+
(js-object :kind persistent-map-entry-kind
|
|
95
|
+
:hash hash
|
|
96
|
+
:key key
|
|
97
|
+
:value value))
|
|
98
|
+
|
|
99
|
+
(defportable persistent-map-make-bitmap-node (bitmap items)
|
|
100
|
+
(js-object :kind persistent-map-bitmap-kind
|
|
101
|
+
:bitmap (uint32 bitmap)
|
|
102
|
+
:items items))
|
|
103
|
+
|
|
104
|
+
(defportable persistent-map-make-array-node (count children)
|
|
105
|
+
(js-object :kind persistent-map-array-kind
|
|
106
|
+
:count count
|
|
107
|
+
:children children))
|
|
108
|
+
|
|
109
|
+
(defportable persistent-map-make-collision-node (hash entries)
|
|
110
|
+
(js-object :kind persistent-map-collision-kind
|
|
111
|
+
:hash hash
|
|
112
|
+
:entries entries))
|
|
113
|
+
|
|
114
|
+
(defportable persistent-map-item-kind (item)
|
|
115
|
+
(get item "kind" nil))
|
|
116
|
+
|
|
117
|
+
(defportable persistent-map-entry? (item)
|
|
118
|
+
(= (persistent-map-item-kind item) persistent-map-entry-kind))
|
|
119
|
+
|
|
120
|
+
(defportable persistent-map-make-result (item added changed)
|
|
121
|
+
(js-object :item item :added added :changed changed))
|
|
122
|
+
|
|
123
|
+
(defportable persistent-map-make-removal (item removed)
|
|
124
|
+
(js-object :item item :removed removed))
|
|
125
|
+
|
|
126
|
+
(defportable persistent-map-same-entry?
|
|
127
|
+
(entry hash key key-equal-function)
|
|
128
|
+
(and (= (get entry "hash" 0) hash)
|
|
129
|
+
(funcall key-equal-function (get entry "key") key)))
|
|
130
|
+
|
|
131
|
+
(defportable persistent-map-merge-entries (shift left right)
|
|
132
|
+
(let ((left-hash (get left "hash" 0))
|
|
133
|
+
(right-hash (get right "hash" 0)))
|
|
134
|
+
(if (= left-hash right-hash)
|
|
135
|
+
(persistent-map-make-collision-node
|
|
136
|
+
left-hash
|
|
137
|
+
(js-array left right))
|
|
138
|
+
(let* ((left-index
|
|
139
|
+
(persistent-map-branch-index left-hash shift))
|
|
140
|
+
(right-index
|
|
141
|
+
(persistent-map-branch-index right-hash shift)))
|
|
142
|
+
(if (= left-index right-index)
|
|
143
|
+
(persistent-map-make-bitmap-node
|
|
144
|
+
(persistent-map-bit-position left-hash shift)
|
|
145
|
+
(js-array (persistent-map-merge-entries
|
|
146
|
+
(+ shift persistent-map-branch-bits)
|
|
147
|
+
left
|
|
148
|
+
right)))
|
|
149
|
+
(persistent-map-make-bitmap-node
|
|
150
|
+
(uint32
|
|
151
|
+
(bit-or
|
|
152
|
+
(persistent-map-bit-position left-hash shift)
|
|
153
|
+
(persistent-map-bit-position right-hash shift)))
|
|
154
|
+
(if (< left-index right-index)
|
|
155
|
+
(js-array left right)
|
|
156
|
+
(js-array right left))))))))
|
|
157
|
+
|
|
158
|
+
(defportable persistent-map-merge-hash-node-entry
|
|
159
|
+
(shift node node-hash entry)
|
|
160
|
+
(let ((node-index (persistent-map-branch-index node-hash shift))
|
|
161
|
+
(entry-index
|
|
162
|
+
(persistent-map-branch-index (get entry "hash" 0) shift)))
|
|
163
|
+
(if (= node-index entry-index)
|
|
164
|
+
(persistent-map-make-bitmap-node
|
|
165
|
+
(persistent-map-bit-position node-hash shift)
|
|
166
|
+
(js-array (persistent-map-merge-hash-node-entry
|
|
167
|
+
(+ shift persistent-map-branch-bits)
|
|
168
|
+
node
|
|
169
|
+
node-hash
|
|
170
|
+
entry)))
|
|
171
|
+
(persistent-map-make-bitmap-node
|
|
172
|
+
(uint32
|
|
173
|
+
(bit-or
|
|
174
|
+
(persistent-map-bit-position node-hash shift)
|
|
175
|
+
(persistent-map-bit-position (get entry "hash" 0) shift)))
|
|
176
|
+
(if (< node-index entry-index)
|
|
177
|
+
(js-array node entry)
|
|
178
|
+
(js-array entry node))))))
|
|
179
|
+
|
|
180
|
+
(defportable persistent-map-promote-bitmap-node (node shift entry)
|
|
181
|
+
(let ((children (js-array))
|
|
182
|
+
(index 0)
|
|
183
|
+
(packed 0)
|
|
184
|
+
(bitmap (get node "bitmap" 0))
|
|
185
|
+
(items (get node "items" (js-array)))
|
|
186
|
+
(entry-index
|
|
187
|
+
(persistent-map-branch-index (get entry "hash" 0) shift)))
|
|
188
|
+
(while (< index persistent-map-branch-width)
|
|
189
|
+
(let* ((bit (uint32 (bit-shift-left 1 index)))
|
|
190
|
+
(occupied (/= (bit-and bitmap bit) 0))
|
|
191
|
+
(child
|
|
192
|
+
(if occupied
|
|
193
|
+
(js-nth packed items)
|
|
194
|
+
(if (= index entry-index) entry nil))))
|
|
195
|
+
(setq children (js-cons child children))
|
|
196
|
+
(when occupied
|
|
197
|
+
(setq packed (1+ packed))))
|
|
198
|
+
(setq index (1+ index)))
|
|
199
|
+
(persistent-map-make-array-node
|
|
200
|
+
(1+ (js-length items))
|
|
201
|
+
(persistent-map-array-reverse children))))
|
|
202
|
+
|
|
203
|
+
(defportable persistent-map-pack-array-node (node)
|
|
204
|
+
(let ((bitmap 0)
|
|
205
|
+
(items (js-array))
|
|
206
|
+
(children (get node "children" (js-array)))
|
|
207
|
+
(index 0))
|
|
208
|
+
(while (< index persistent-map-branch-width)
|
|
209
|
+
(let ((child (js-nth index children)))
|
|
210
|
+
(when child
|
|
211
|
+
(setq bitmap
|
|
212
|
+
(uint32 (bit-or bitmap (bit-shift-left 1 index)))
|
|
213
|
+
items (js-cons child items))))
|
|
214
|
+
(setq index (1+ index)))
|
|
215
|
+
(persistent-map-make-bitmap-node
|
|
216
|
+
bitmap
|
|
217
|
+
(persistent-map-array-reverse items))))
|
|
218
|
+
|
|
219
|
+
(defportable persistent-map-assoc-entry
|
|
220
|
+
(entry shift hash key value key-equal-function value-equal-function)
|
|
221
|
+
(if (persistent-map-same-entry? entry hash key key-equal-function)
|
|
222
|
+
(if (funcall value-equal-function
|
|
223
|
+
(get entry "value")
|
|
224
|
+
value)
|
|
225
|
+
(persistent-map-make-result entry false false)
|
|
226
|
+
(persistent-map-make-result
|
|
227
|
+
(persistent-map-make-entry
|
|
228
|
+
hash
|
|
229
|
+
(get entry "key")
|
|
230
|
+
value)
|
|
231
|
+
false
|
|
232
|
+
t))
|
|
233
|
+
(persistent-map-make-result
|
|
234
|
+
(persistent-map-merge-entries
|
|
235
|
+
shift
|
|
236
|
+
entry
|
|
237
|
+
(persistent-map-make-entry hash key value))
|
|
238
|
+
t
|
|
239
|
+
t)))
|
|
240
|
+
|
|
241
|
+
(defportable persistent-map-assoc-item
|
|
242
|
+
(item shift hash key value key-equal-function value-equal-function)
|
|
243
|
+
(if (persistent-map-entry? item)
|
|
244
|
+
(persistent-map-assoc-entry
|
|
245
|
+
item
|
|
246
|
+
shift
|
|
247
|
+
hash
|
|
248
|
+
key
|
|
249
|
+
value
|
|
250
|
+
key-equal-function
|
|
251
|
+
value-equal-function)
|
|
252
|
+
(let ((kind (persistent-map-item-kind item)))
|
|
253
|
+
(if (= kind persistent-map-bitmap-kind)
|
|
254
|
+
(let* ((bit (persistent-map-bit-position hash shift))
|
|
255
|
+
(bitmap (get item "bitmap" 0))
|
|
256
|
+
(items (get item "items" (js-array)))
|
|
257
|
+
(index (persistent-map-packed-index bitmap bit)))
|
|
258
|
+
(if (= (bit-and bitmap bit) 0)
|
|
259
|
+
(if (>= (1+ (js-length items))
|
|
260
|
+
persistent-map-array-threshold)
|
|
261
|
+
(persistent-map-make-result
|
|
262
|
+
(persistent-map-promote-bitmap-node
|
|
263
|
+
item
|
|
264
|
+
shift
|
|
265
|
+
(persistent-map-make-entry hash key value))
|
|
266
|
+
t
|
|
267
|
+
t)
|
|
268
|
+
(persistent-map-make-result
|
|
269
|
+
(persistent-map-make-bitmap-node
|
|
270
|
+
(uint32 (bit-or bitmap bit))
|
|
271
|
+
(persistent-map-array-insert
|
|
272
|
+
items
|
|
273
|
+
index
|
|
274
|
+
(persistent-map-make-entry hash key value)))
|
|
275
|
+
t
|
|
276
|
+
t))
|
|
277
|
+
(let* ((existing (js-nth index items))
|
|
278
|
+
(result
|
|
279
|
+
(persistent-map-assoc-item
|
|
280
|
+
existing
|
|
281
|
+
(+ shift persistent-map-branch-bits)
|
|
282
|
+
hash
|
|
283
|
+
key
|
|
284
|
+
value
|
|
285
|
+
key-equal-function
|
|
286
|
+
value-equal-function)))
|
|
287
|
+
(if (not (get result "changed" false))
|
|
288
|
+
(persistent-map-make-result item false false)
|
|
289
|
+
(persistent-map-make-result
|
|
290
|
+
(persistent-map-make-bitmap-node
|
|
291
|
+
bitmap
|
|
292
|
+
(persistent-map-array-copy-assoc
|
|
293
|
+
items
|
|
294
|
+
index
|
|
295
|
+
(get result "item" nil)))
|
|
296
|
+
(get result "added" false)
|
|
297
|
+
t)))))
|
|
298
|
+
(if (= kind persistent-map-array-kind)
|
|
299
|
+
(let* ((index (persistent-map-branch-index hash shift))
|
|
300
|
+
(children (get item "children" (js-array)))
|
|
301
|
+
(existing (js-nth index children)))
|
|
302
|
+
(if (nil? existing)
|
|
303
|
+
(persistent-map-make-result
|
|
304
|
+
(persistent-map-make-array-node
|
|
305
|
+
(1+ (get item "count" 0))
|
|
306
|
+
(persistent-map-array-copy-assoc
|
|
307
|
+
children
|
|
308
|
+
index
|
|
309
|
+
(persistent-map-make-entry hash key value)))
|
|
310
|
+
t
|
|
311
|
+
t)
|
|
312
|
+
(let ((result
|
|
313
|
+
(persistent-map-assoc-item
|
|
314
|
+
existing
|
|
315
|
+
(+ shift persistent-map-branch-bits)
|
|
316
|
+
hash
|
|
317
|
+
key
|
|
318
|
+
value
|
|
319
|
+
key-equal-function
|
|
320
|
+
value-equal-function)))
|
|
321
|
+
(if (not (get result "changed" false))
|
|
322
|
+
(persistent-map-make-result item false false)
|
|
323
|
+
(persistent-map-make-result
|
|
324
|
+
(persistent-map-make-array-node
|
|
325
|
+
(get item "count" 0)
|
|
326
|
+
(persistent-map-array-copy-assoc
|
|
327
|
+
children
|
|
328
|
+
index
|
|
329
|
+
(get result "item" nil)))
|
|
330
|
+
(get result "added" false)
|
|
331
|
+
t)))))
|
|
332
|
+
(let ((node-hash (get item "hash" 0)))
|
|
333
|
+
(if (/= node-hash hash)
|
|
334
|
+
(persistent-map-make-result
|
|
335
|
+
(persistent-map-merge-hash-node-entry
|
|
336
|
+
shift
|
|
337
|
+
item
|
|
338
|
+
node-hash
|
|
339
|
+
(persistent-map-make-entry hash key value))
|
|
340
|
+
t
|
|
341
|
+
t)
|
|
342
|
+
(let ((entries (get item "entries" (js-array)))
|
|
343
|
+
(index 0)
|
|
344
|
+
(found-index -1))
|
|
345
|
+
(while (and (< index (js-length entries))
|
|
346
|
+
(< found-index 0))
|
|
347
|
+
(when (funcall
|
|
348
|
+
key-equal-function
|
|
349
|
+
(get (js-nth index entries) "key")
|
|
350
|
+
key)
|
|
351
|
+
(setq found-index index))
|
|
352
|
+
(setq index (1+ index)))
|
|
353
|
+
(if (>= found-index 0)
|
|
354
|
+
(let ((existing (js-nth found-index entries)))
|
|
355
|
+
(if (funcall
|
|
356
|
+
value-equal-function
|
|
357
|
+
(get existing "value")
|
|
358
|
+
value)
|
|
359
|
+
(persistent-map-make-result item false false)
|
|
360
|
+
(persistent-map-make-result
|
|
361
|
+
(persistent-map-make-collision-node
|
|
362
|
+
hash
|
|
363
|
+
(persistent-map-array-copy-assoc
|
|
364
|
+
entries
|
|
365
|
+
found-index
|
|
366
|
+
(persistent-map-make-entry
|
|
367
|
+
hash
|
|
368
|
+
(get existing "key")
|
|
369
|
+
value)))
|
|
370
|
+
false
|
|
371
|
+
t)))
|
|
372
|
+
(persistent-map-make-result
|
|
373
|
+
(persistent-map-make-collision-node
|
|
374
|
+
hash
|
|
375
|
+
(persistent-map-array-append
|
|
376
|
+
entries
|
|
377
|
+
(persistent-map-make-entry hash key value)))
|
|
378
|
+
t
|
|
379
|
+
t))))))))))
|
|
380
|
+
|
|
381
|
+
(defportable persistent-map-remove-bitmap-item (node bit index)
|
|
382
|
+
(let* ((items
|
|
383
|
+
(persistent-map-array-remove
|
|
384
|
+
(get node "items" (js-array))
|
|
385
|
+
index))
|
|
386
|
+
(bitmap
|
|
387
|
+
(uint32
|
|
388
|
+
(bit-and (get node "bitmap" 0) (bit-not bit)))))
|
|
389
|
+
(if (= (js-length items) 0)
|
|
390
|
+
nil
|
|
391
|
+
(persistent-map-make-bitmap-node bitmap items))))
|
|
392
|
+
|
|
393
|
+
(defportable persistent-map-dissoc-item
|
|
394
|
+
(item shift hash key key-equal-function)
|
|
395
|
+
(if (persistent-map-entry? item)
|
|
396
|
+
(if (persistent-map-same-entry?
|
|
397
|
+
item hash key key-equal-function)
|
|
398
|
+
(persistent-map-make-removal nil t)
|
|
399
|
+
(persistent-map-make-removal item false))
|
|
400
|
+
(let ((kind (persistent-map-item-kind item)))
|
|
401
|
+
(if (= kind persistent-map-bitmap-kind)
|
|
402
|
+
(let* ((bit (persistent-map-bit-position hash shift))
|
|
403
|
+
(bitmap (get item "bitmap" 0)))
|
|
404
|
+
(if (= (bit-and bitmap bit) 0)
|
|
405
|
+
(persistent-map-make-removal item false)
|
|
406
|
+
(let* ((index
|
|
407
|
+
(persistent-map-packed-index bitmap bit))
|
|
408
|
+
(items (get item "items" (js-array)))
|
|
409
|
+
(existing (js-nth index items))
|
|
410
|
+
(result
|
|
411
|
+
(persistent-map-dissoc-item
|
|
412
|
+
existing
|
|
413
|
+
(+ shift persistent-map-branch-bits)
|
|
414
|
+
hash
|
|
415
|
+
key
|
|
416
|
+
key-equal-function)))
|
|
417
|
+
(if (not (get result "removed" false))
|
|
418
|
+
(persistent-map-make-removal item false)
|
|
419
|
+
(let ((next-item (get result "item" nil)))
|
|
420
|
+
(if (nil? next-item)
|
|
421
|
+
(persistent-map-make-removal
|
|
422
|
+
(persistent-map-remove-bitmap-item
|
|
423
|
+
item bit index)
|
|
424
|
+
t)
|
|
425
|
+
(persistent-map-make-removal
|
|
426
|
+
(persistent-map-make-bitmap-node
|
|
427
|
+
bitmap
|
|
428
|
+
(persistent-map-array-copy-assoc
|
|
429
|
+
items index next-item))
|
|
430
|
+
t)))))))
|
|
431
|
+
(if (= kind persistent-map-array-kind)
|
|
432
|
+
(let* ((index (persistent-map-branch-index hash shift))
|
|
433
|
+
(children (get item "children" (js-array)))
|
|
434
|
+
(existing (js-nth index children)))
|
|
435
|
+
(if (nil? existing)
|
|
436
|
+
(persistent-map-make-removal item false)
|
|
437
|
+
(let ((result
|
|
438
|
+
(persistent-map-dissoc-item
|
|
439
|
+
existing
|
|
440
|
+
(+ shift persistent-map-branch-bits)
|
|
441
|
+
hash
|
|
442
|
+
key
|
|
443
|
+
key-equal-function)))
|
|
444
|
+
(if (not (get result "removed" false))
|
|
445
|
+
(persistent-map-make-removal item false)
|
|
446
|
+
(let* ((next-item (get result "item" nil))
|
|
447
|
+
(next-count
|
|
448
|
+
(if (nil? next-item)
|
|
449
|
+
(1- (get item "count" 0))
|
|
450
|
+
(get item "count" 0)))
|
|
451
|
+
(next-node
|
|
452
|
+
(persistent-map-make-array-node
|
|
453
|
+
next-count
|
|
454
|
+
(persistent-map-array-copy-assoc
|
|
455
|
+
children index next-item))))
|
|
456
|
+
(persistent-map-make-removal
|
|
457
|
+
(if (<= next-count
|
|
458
|
+
persistent-map-bitmap-threshold)
|
|
459
|
+
(persistent-map-pack-array-node next-node)
|
|
460
|
+
next-node)
|
|
461
|
+
t))))))
|
|
462
|
+
(if (/= (get item "hash" 0) hash)
|
|
463
|
+
(persistent-map-make-removal item false)
|
|
464
|
+
(let ((entries (get item "entries" (js-array)))
|
|
465
|
+
(index 0)
|
|
466
|
+
(found-index -1))
|
|
467
|
+
(while (and (< index (js-length entries))
|
|
468
|
+
(< found-index 0))
|
|
469
|
+
(when (funcall
|
|
470
|
+
key-equal-function
|
|
471
|
+
(get (js-nth index entries) "key")
|
|
472
|
+
key)
|
|
473
|
+
(setq found-index index))
|
|
474
|
+
(setq index (1+ index)))
|
|
475
|
+
(if (< found-index 0)
|
|
476
|
+
(persistent-map-make-removal item false)
|
|
477
|
+
(if (= (js-length entries) 2)
|
|
478
|
+
(persistent-map-make-removal
|
|
479
|
+
(js-nth (if (= found-index 0) 1 0) entries)
|
|
480
|
+
t)
|
|
481
|
+
(persistent-map-make-removal
|
|
482
|
+
(persistent-map-make-collision-node
|
|
483
|
+
hash
|
|
484
|
+
(persistent-map-array-remove entries found-index))
|
|
485
|
+
t))))))))))
|
|
486
|
+
|
|
487
|
+
(defportable persistent-map-find-item
|
|
488
|
+
(item shift hash key key-equal-function)
|
|
489
|
+
(let ((current item)
|
|
490
|
+
(current-shift shift)
|
|
491
|
+
(finished false)
|
|
492
|
+
(found false)
|
|
493
|
+
(value nil))
|
|
494
|
+
(while (and current (not finished))
|
|
495
|
+
(let ((kind (persistent-map-item-kind current)))
|
|
496
|
+
(if (= kind persistent-map-entry-kind)
|
|
497
|
+
(progn
|
|
498
|
+
(when (persistent-map-same-entry?
|
|
499
|
+
current hash key key-equal-function)
|
|
500
|
+
(setq found t
|
|
501
|
+
value (get current "value")))
|
|
502
|
+
(setq finished t))
|
|
503
|
+
(if (= kind persistent-map-bitmap-kind)
|
|
504
|
+
(let* ((bit
|
|
505
|
+
(persistent-map-bit-position hash current-shift))
|
|
506
|
+
(bitmap (get current "bitmap" 0)))
|
|
507
|
+
(if (= (bit-and bitmap bit) 0)
|
|
508
|
+
(setq finished t)
|
|
509
|
+
(setq current
|
|
510
|
+
(js-nth
|
|
511
|
+
(persistent-map-packed-index bitmap bit)
|
|
512
|
+
(get current "items" (js-array)))
|
|
513
|
+
current-shift
|
|
514
|
+
(+ current-shift persistent-map-branch-bits))))
|
|
515
|
+
(if (= kind persistent-map-array-kind)
|
|
516
|
+
(let ((child
|
|
517
|
+
(js-nth
|
|
518
|
+
(persistent-map-branch-index
|
|
519
|
+
hash current-shift)
|
|
520
|
+
(get current "children" (js-array)))))
|
|
521
|
+
(if (nil? child)
|
|
522
|
+
(setq finished t)
|
|
523
|
+
(setq current child
|
|
524
|
+
current-shift
|
|
525
|
+
(+ current-shift
|
|
526
|
+
persistent-map-branch-bits))))
|
|
527
|
+
(progn
|
|
528
|
+
(when (= (get current "hash" 0) hash)
|
|
529
|
+
(let ((entries (get current "entries" (js-array)))
|
|
530
|
+
(index 0))
|
|
531
|
+
(while (and (< index (js-length entries)) (not found))
|
|
532
|
+
(let ((entry (js-nth index entries)))
|
|
533
|
+
(when (funcall
|
|
534
|
+
key-equal-function
|
|
535
|
+
(get entry "key")
|
|
536
|
+
key)
|
|
537
|
+
(setq found t
|
|
538
|
+
value (get entry "value"))))
|
|
539
|
+
(setq index (1+ index)))))
|
|
540
|
+
(setq finished t)))))))
|
|
541
|
+
(js-object :found found :value value)))
|
|
542
|
+
|
|
543
|
+
(defportable persistent-map-reduce-item (function initial item)
|
|
544
|
+
(let ((kind (persistent-map-item-kind item)))
|
|
545
|
+
(if (= kind persistent-map-entry-kind)
|
|
546
|
+
(funcall function
|
|
547
|
+
initial
|
|
548
|
+
(get item "key")
|
|
549
|
+
(get item "value"))
|
|
550
|
+
(let ((result initial)
|
|
551
|
+
(index 0)
|
|
552
|
+
(children
|
|
553
|
+
(if (= kind persistent-map-bitmap-kind)
|
|
554
|
+
(get item "items" (js-array))
|
|
555
|
+
(if (= kind persistent-map-array-kind)
|
|
556
|
+
(get item "children" (js-array))
|
|
557
|
+
(get item "entries" (js-array))))))
|
|
558
|
+
(while (< index (js-length children))
|
|
559
|
+
(let ((child (js-nth index children)))
|
|
560
|
+
(when child
|
|
561
|
+
(setq result
|
|
562
|
+
(persistent-map-reduce-item
|
|
563
|
+
function result child))))
|
|
564
|
+
(setq index (1+ index)))
|
|
565
|
+
result))))
|
|
566
|
+
|
|
567
|
+
(defportable persistent-map-make
|
|
568
|
+
(count root hash-function key-equal-function value-equal-function metadata)
|
|
569
|
+
(js-object :kind persistent-map-kind
|
|
570
|
+
:count count
|
|
571
|
+
:root root
|
|
572
|
+
:hash-function hash-function
|
|
573
|
+
:key-equal-function key-equal-function
|
|
574
|
+
:value-equal-function value-equal-function
|
|
575
|
+
:metadata metadata))
|
|
576
|
+
|
|
577
|
+
(defportable empty-persistent-map
|
|
578
|
+
(hash-function key-equal-function value-equal-function)
|
|
579
|
+
(persistent-map-make
|
|
580
|
+
0 nil hash-function key-equal-function value-equal-function nil))
|
|
581
|
+
|
|
582
|
+
(defportable persistent-map? (value)
|
|
583
|
+
(and (not (nullish? value))
|
|
584
|
+
(object-has? value "kind")
|
|
585
|
+
(= (get value "kind" nil) persistent-map-kind)))
|
|
586
|
+
|
|
587
|
+
(defportable persistent-map-count (map)
|
|
588
|
+
(get map "count" 0))
|
|
589
|
+
|
|
590
|
+
(defportable persistent-map-meta (map)
|
|
591
|
+
(get map "metadata" nil))
|
|
592
|
+
|
|
593
|
+
(defportable persistent-map-with-meta (map metadata)
|
|
594
|
+
(if (= metadata (persistent-map-meta map))
|
|
595
|
+
map
|
|
596
|
+
(persistent-map-make
|
|
597
|
+
(persistent-map-count map)
|
|
598
|
+
(get map "root" nil)
|
|
599
|
+
(get map "hash-function" nil)
|
|
600
|
+
(get map "key-equal-function" nil)
|
|
601
|
+
(get map "value-equal-function" nil)
|
|
602
|
+
metadata)))
|
|
603
|
+
|
|
604
|
+
(defportable persistent-map-find (map key)
|
|
605
|
+
(let ((root (get map "root" nil)))
|
|
606
|
+
(if (nil? root)
|
|
607
|
+
(js-object :found false :value nil)
|
|
608
|
+
(persistent-map-find-item
|
|
609
|
+
root
|
|
610
|
+
0
|
|
611
|
+
(uint32 (funcall (get map "hash-function" nil) key))
|
|
612
|
+
key
|
|
613
|
+
(get map "key-equal-function" nil)))))
|
|
614
|
+
|
|
615
|
+
(defportable persistent-map-has? (map key)
|
|
616
|
+
(get (persistent-map-find map key) "found" false))
|
|
617
|
+
|
|
618
|
+
(defportable persistent-map-get (map key not-found)
|
|
619
|
+
(let ((result (persistent-map-find map key)))
|
|
620
|
+
(if (get result "found" false)
|
|
621
|
+
(get result "value")
|
|
622
|
+
not-found)))
|
|
623
|
+
|
|
624
|
+
(defportable persistent-map-assoc (map key value)
|
|
625
|
+
(let* ((root (get map "root" nil))
|
|
626
|
+
(hash-function (get map "hash-function" nil))
|
|
627
|
+
(key-equal-function (get map "key-equal-function" nil))
|
|
628
|
+
(value-equal-function (get map "value-equal-function" nil))
|
|
629
|
+
(hash (uint32 (funcall hash-function key)))
|
|
630
|
+
(result
|
|
631
|
+
(if (nil? root)
|
|
632
|
+
(persistent-map-make-result
|
|
633
|
+
(persistent-map-make-entry hash key value)
|
|
634
|
+
t
|
|
635
|
+
t)
|
|
636
|
+
(persistent-map-assoc-item
|
|
637
|
+
root
|
|
638
|
+
0
|
|
639
|
+
hash
|
|
640
|
+
key
|
|
641
|
+
value
|
|
642
|
+
key-equal-function
|
|
643
|
+
value-equal-function))))
|
|
644
|
+
(if (not (get result "changed" false))
|
|
645
|
+
map
|
|
646
|
+
(if (and (get result "added" false)
|
|
647
|
+
(>= (persistent-map-count map)
|
|
648
|
+
persistent-map-max-count))
|
|
649
|
+
nil
|
|
650
|
+
(persistent-map-make
|
|
651
|
+
(if (get result "added" false)
|
|
652
|
+
(1+ (persistent-map-count map))
|
|
653
|
+
(persistent-map-count map))
|
|
654
|
+
(get result "item" nil)
|
|
655
|
+
hash-function
|
|
656
|
+
key-equal-function
|
|
657
|
+
value-equal-function
|
|
658
|
+
(persistent-map-meta map))))))
|
|
659
|
+
|
|
660
|
+
(defportable persistent-map-dissoc (map key)
|
|
661
|
+
(let ((root (get map "root" nil)))
|
|
662
|
+
(if (nil? root)
|
|
663
|
+
map
|
|
664
|
+
(let* ((hash-function (get map "hash-function" nil))
|
|
665
|
+
(key-equal-function
|
|
666
|
+
(get map "key-equal-function" nil))
|
|
667
|
+
(result
|
|
668
|
+
(persistent-map-dissoc-item
|
|
669
|
+
root
|
|
670
|
+
0
|
|
671
|
+
(uint32 (funcall hash-function key))
|
|
672
|
+
key
|
|
673
|
+
key-equal-function)))
|
|
674
|
+
(if (not (get result "removed" false))
|
|
675
|
+
map
|
|
676
|
+
(persistent-map-make
|
|
677
|
+
(1- (persistent-map-count map))
|
|
678
|
+
(get result "item" nil)
|
|
679
|
+
hash-function
|
|
680
|
+
key-equal-function
|
|
681
|
+
(get map "value-equal-function" nil)
|
|
682
|
+
(persistent-map-meta map)))))))
|
|
683
|
+
|
|
684
|
+
(defportable persistent-map-reduce (function initial map)
|
|
685
|
+
(let ((root (get map "root" nil)))
|
|
686
|
+
(if (nil? root)
|
|
687
|
+
initial
|
|
688
|
+
(persistent-map-reduce-item function initial root))))
|
|
689
|
+
|
|
690
|
+
(defportable persistent-map-to-entries (map)
|
|
691
|
+
(persistent-map-array-reverse
|
|
692
|
+
(persistent-map-reduce
|
|
693
|
+
(lambda (result key value) (js-cons (js-array key value) result))
|
|
694
|
+
(js-array)
|
|
695
|
+
map)))
|
|
696
|
+
|
|
697
|
+
(defportable persistent-map-from-entries
|
|
698
|
+
(hash-function key-equal-function value-equal-function entries)
|
|
699
|
+
(let ((result
|
|
700
|
+
(empty-persistent-map
|
|
701
|
+
hash-function key-equal-function value-equal-function))
|
|
702
|
+
(index 0))
|
|
703
|
+
(while (< index (js-length entries))
|
|
704
|
+
(let ((entry (get entries index)))
|
|
705
|
+
(setq result
|
|
706
|
+
(persistent-map-assoc
|
|
707
|
+
result
|
|
708
|
+
(get entry 0)
|
|
709
|
+
(get entry 1))))
|
|
710
|
+
(setq index (1+ index)))
|
|
711
|
+
result))
|
|
712
|
+
|
|
713
|
+
(export empty-persistent-map
|
|
714
|
+
persistent-map?
|
|
715
|
+
persistent-map-count
|
|
716
|
+
persistent-map-meta
|
|
717
|
+
persistent-map-with-meta
|
|
718
|
+
persistent-map-has?
|
|
719
|
+
persistent-map-get
|
|
720
|
+
persistent-map-assoc
|
|
721
|
+
persistent-map-dissoc
|
|
722
|
+
persistent-map-reduce
|
|
723
|
+
persistent-map-to-entries
|
|
724
|
+
persistent-map-from-entries))
|