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,153 @@
|
|
|
1
|
+
(module eliscript.managed-value-state
|
|
2
|
+
(import-portable "./bit.eli" rotate-left)
|
|
3
|
+
|
|
4
|
+
(defvar protocol-hashes (new globalThis/WeakMap))
|
|
5
|
+
(defvar host-object-hashes (new globalThis/WeakMap))
|
|
6
|
+
(defvar host-symbol-hashes (new globalThis/Map))
|
|
7
|
+
(defvar next-host-identity 1)
|
|
8
|
+
(defconst metrics (js-object :hashValueCalls 0 :protocolHashComputations 0
|
|
9
|
+
:protocolHashCacheHits 0 :hostIdentityAssignments 0))
|
|
10
|
+
(defun callable? (value) (= (js* "typeof value") "function"))
|
|
11
|
+
(defun object? (value)
|
|
12
|
+
(and (not (nil? value)) (or (= (js* "typeof value") "object") (callable? value))))
|
|
13
|
+
(defun fail (message) (throw (new globalThis/TypeError message)))
|
|
14
|
+
(defun numberPrimitive (value)
|
|
15
|
+
(if (not (object? value)) value
|
|
16
|
+
(let ((exotic (aref value (get globalThis/Symbol :toPrimitive))))
|
|
17
|
+
(if (not (nullish? exotic))
|
|
18
|
+
(progn
|
|
19
|
+
(unless (callable? exotic) (fail "Symbol.toPrimitive must be callable"))
|
|
20
|
+
(let ((primitive (js-call exotic :call value "number")))
|
|
21
|
+
(when (object? primitive) (fail "Cannot convert object to primitive value")) primitive))
|
|
22
|
+
(let ((names (js-array "valueOf" "toString")) (index 0) (found false) (primitive undefined))
|
|
23
|
+
(while (and (< index 2) (not found))
|
|
24
|
+
(let ((method (get value (get names index))))
|
|
25
|
+
(when (callable? method)
|
|
26
|
+
(setq primitive (js-call method :call value))
|
|
27
|
+
(unless (object? primitive) (setq found t))))
|
|
28
|
+
(setq index (1+ index)))
|
|
29
|
+
(unless found (fail "Cannot convert object to primitive value")) primitive)))))
|
|
30
|
+
(defun toNumber (value)
|
|
31
|
+
(let ((primitive (numberPrimitive value)))
|
|
32
|
+
(when (= (js* "typeof primitive") "bigint") (fail "Cannot convert a BigInt value to a number"))
|
|
33
|
+
(funcall globalThis/Number primitive)))
|
|
34
|
+
(defun avalancheHash (value)
|
|
35
|
+
(let ((hash (uint32 value)))
|
|
36
|
+
(setq hash (bit-xor hash (unsigned-bit-shift-right hash 16)))
|
|
37
|
+
(setq hash (imul32 hash 2246822507))
|
|
38
|
+
(setq hash (bit-xor hash (unsigned-bit-shift-right hash 13)))
|
|
39
|
+
(setq hash (imul32 hash 3266489909))
|
|
40
|
+
(uint32 (bit-xor hash (unsigned-bit-shift-right hash 16)))))
|
|
41
|
+
(defun mixHash (hash value)
|
|
42
|
+
(let ((mixed (imul32 (uint32 (bit-xor hash value)) 1540483477)))
|
|
43
|
+
(uint32 (bit-xor mixed (unsigned-bit-shift-right mixed 15)))))
|
|
44
|
+
(defun finishHash (hash count) (avalancheHash (mixHash hash (uint32 count))))
|
|
45
|
+
(defun hashString (value &rest tags)
|
|
46
|
+
(let* ((tag (if (or (= (js-length tags) 0) (undefined? (aref tags 0)))
|
|
47
|
+
1831565813 (aref tags 0)))
|
|
48
|
+
(hash (mixHash tag (aref value "length"))) (index 0))
|
|
49
|
+
(while (< index (aref value "length"))
|
|
50
|
+
(setq hash (mixHash hash (js-call value :charCodeAt index)) index (1+ index)))
|
|
51
|
+
(finishHash hash (aref value "length"))))
|
|
52
|
+
(defun hashNumber (value)
|
|
53
|
+
(if (funcall globalThis/Boolean (Number/isNaN value)) 1490037359
|
|
54
|
+
(let* ((normalized (if (= value 0) 0 value))
|
|
55
|
+
(words (number-float64-words (toNumber normalized))))
|
|
56
|
+
(finishHash (mixHash (mixHash 374761393 (get words 0)) (get words 1)) 2))))
|
|
57
|
+
(defun hashBigInt (value)
|
|
58
|
+
(let* ((zero (funcall globalThis/BigInt "0")) (base (funcall globalThis/BigInt "4294967296"))
|
|
59
|
+
(negative (< value zero)) (magnitude (if negative (- value) value))
|
|
60
|
+
(hash (mixHash 2017827537 (if negative 1 0))) (limbs 0) (complete false))
|
|
61
|
+
(while (not complete)
|
|
62
|
+
(setq hash (mixHash hash (funcall globalThis/Number (% magnitude base)))
|
|
63
|
+
magnitude (/ magnitude base) limbs (1+ limbs) complete (= magnitude zero)))
|
|
64
|
+
(finishHash hash limbs)))
|
|
65
|
+
(defun hashBoolean (value) (mixHash 1260232563 (if (funcall globalThis/Boolean value) 1911856395 423263297)))
|
|
66
|
+
(defun hashNull () 1108378657)
|
|
67
|
+
(defun hashUndefined () 2135587861)
|
|
68
|
+
(defun hashGlobalSymbol (key) (hashString key 2657455275))
|
|
69
|
+
(defun walkIterable (iterable visit)
|
|
70
|
+
(let* ((iterator (js-call (aref iterable (get globalThis/Symbol :iterator)) :call iterable))
|
|
71
|
+
(next nil) (complete false) (active false))
|
|
72
|
+
(unless (object? iterator) (fail "iterator must be an object"))
|
|
73
|
+
(setq next (aref iterator "next"))
|
|
74
|
+
(try
|
|
75
|
+
(while (not complete)
|
|
76
|
+
(setq active false)
|
|
77
|
+
(let ((step (js-call next :call iterator)))
|
|
78
|
+
(unless (object? step) (fail "iterator result must be an object"))
|
|
79
|
+
(if (funcall globalThis/Boolean (aref step "done")) (setq complete t)
|
|
80
|
+
(let ((value (aref step "value")))
|
|
81
|
+
(setq active t) (funcall visit value)))))
|
|
82
|
+
(catch error
|
|
83
|
+
(when (and active (not complete))
|
|
84
|
+
(try
|
|
85
|
+
(let ((close (get iterator :return)))
|
|
86
|
+
(unless (nullish? close) (js-call close :call iterator)))
|
|
87
|
+
(catch close-error nil)))
|
|
88
|
+
(throw error)))))
|
|
89
|
+
(defun orderedCollectionHash (iterable hashValue tag)
|
|
90
|
+
(let ((hash (uint32 tag)) (count 0))
|
|
91
|
+
(walkIterable iterable (lambda (value)
|
|
92
|
+
(setq hash (mixHash hash (funcall hashValue value)) count (1+ count))))
|
|
93
|
+
(finishHash hash count)))
|
|
94
|
+
(defun unorderedCollectionHash (iterable hashElement tag)
|
|
95
|
+
(let ((sum 0) (xor 0) (product 1) (count 0))
|
|
96
|
+
(walkIterable iterable (lambda (value)
|
|
97
|
+
(let ((hash (uint32 (funcall hashElement value))))
|
|
98
|
+
(setq sum (uint32 (+ sum hash))
|
|
99
|
+
xor (uint32 (bit-xor xor (rotate-left hash (bit-and hash 31))))
|
|
100
|
+
product (uint32 (imul32 product (bit-or hash 1))) count (1+ count)))))
|
|
101
|
+
(finishHash (mixHash (mixHash (mixHash tag sum) xor) product) count)))
|
|
102
|
+
(defun cachedProtocolHash (value compute)
|
|
103
|
+
(let ((cached (js-call protocol-hashes :get value)))
|
|
104
|
+
(if (not (undefined? cached))
|
|
105
|
+
(progn (put metrics :protocolHashCacheHits (1+ (get metrics :protocolHashCacheHits))) cached)
|
|
106
|
+
(progn
|
|
107
|
+
(put metrics :protocolHashComputations (1+ (get metrics :protocolHashComputations)))
|
|
108
|
+
(let ((hash (uint32 (funcall compute))))
|
|
109
|
+
(js-call protocol-hashes :set value hash) hash)))))
|
|
110
|
+
(defun recordHashValueCall ()
|
|
111
|
+
(put metrics :hashValueCalls (1+ (get metrics :hashValueCalls))) undefined)
|
|
112
|
+
(defun hostIdentityHash (value)
|
|
113
|
+
(let* ((hashes (if (= (js* "typeof value") "symbol") host-symbol-hashes host-object-hashes))
|
|
114
|
+
(cached (js-call hashes :get value)))
|
|
115
|
+
(if (not (undefined? cached)) cached
|
|
116
|
+
(let ((hash (finishHash 762272397 next-host-identity)))
|
|
117
|
+
(setq next-host-identity (1+ next-host-identity))
|
|
118
|
+
(put metrics :hostIdentityAssignments (1+ (get metrics :hostIdentityAssignments)))
|
|
119
|
+
(js-call hashes :set value hash) hash))))
|
|
120
|
+
(defun resetValueMetrics ()
|
|
121
|
+
(put metrics :hashValueCalls 0)
|
|
122
|
+
(put metrics :protocolHashComputations 0)
|
|
123
|
+
(put metrics :protocolHashCacheHits 0)
|
|
124
|
+
(put metrics :hostIdentityAssignments 0)
|
|
125
|
+
undefined)
|
|
126
|
+
(defun clearValueCaches ()
|
|
127
|
+
(setq protocol-hashes (new globalThis/WeakMap)
|
|
128
|
+
host-object-hashes (new globalThis/WeakMap)
|
|
129
|
+
host-symbol-hashes (new globalThis/Map)
|
|
130
|
+
next-host-identity 1)
|
|
131
|
+
(resetValueMetrics))
|
|
132
|
+
(defun readValueMetrics ()
|
|
133
|
+
(Object/freeze (js-object :hashValueCalls (get metrics :hashValueCalls)
|
|
134
|
+
:protocolHashComputations (get metrics :protocolHashComputations)
|
|
135
|
+
:protocolHashCacheHits (get metrics :protocolHashCacheHits)
|
|
136
|
+
:hostIdentityAssignments (get metrics :hostIdentityAssignments))))
|
|
137
|
+
(defun hashPrimitiveValue (value)
|
|
138
|
+
(let ((type (js* "typeof value")))
|
|
139
|
+
(cond ((nil? value) (hashNull))
|
|
140
|
+
((= type "undefined") (hashUndefined))
|
|
141
|
+
((= type "boolean") (hashBoolean value))
|
|
142
|
+
((= type "number") (hashNumber value))
|
|
143
|
+
((= type "bigint") (hashBigInt value))
|
|
144
|
+
((= type "string") (hashString value))
|
|
145
|
+
((= type "symbol")
|
|
146
|
+
(let ((key (js-call globalThis/Symbol :keyFor value)))
|
|
147
|
+
(if (undefined? key) (hostIdentityHash value) (hashGlobalSymbol key))))
|
|
148
|
+
((or (= type "object") (= type "function")) (hostIdentityHash value))
|
|
149
|
+
(t (fail (str "cannot hash JavaScript value of type " type))))))
|
|
150
|
+
(Object/defineProperty hashString "length" (js-object :value 1 :configurable t))
|
|
151
|
+
(export avalancheHash mixHash finishHash hashString hashNumber hashBigInt hashBoolean hashNull hashUndefined hashGlobalSymbol
|
|
152
|
+
orderedCollectionHash unorderedCollectionHash cachedProtocolHash recordHashValueCall hostIdentityHash
|
|
153
|
+
resetValueMetrics clearValueCaches readValueMetrics hashPrimitiveValue))
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
(module eliscript.managed-vector-view-state
|
|
2
|
+
(import-portable "./persistent-vector.eli"
|
|
3
|
+
empty-persistent-vector persistent-vector? persistent-vector-count
|
|
4
|
+
persistent-vector-nth persistent-vector-assoc persistent-vector-conj
|
|
5
|
+
persistent-vector-with-meta)
|
|
6
|
+
|
|
7
|
+
;; Private range storage. Frozen public SubVector objects and their brands
|
|
8
|
+
;; are created by the literal adapter, never by accepting these record keys.
|
|
9
|
+
(defportable managed-vector-view-state? (value)
|
|
10
|
+
(and (not (nullish? value)) (= (get value :kind nil) "managed-vector-view")))
|
|
11
|
+
|
|
12
|
+
(defportable managed-vector-view-state-make (vector start end metadata)
|
|
13
|
+
(js-object :kind "managed-vector-view" :vector vector :start start :end end :metadata metadata))
|
|
14
|
+
|
|
15
|
+
(defportable managed-vector-view-state-vector (view) (get view :vector))
|
|
16
|
+
(defportable managed-vector-view-state-start (view) (get view :start))
|
|
17
|
+
(defportable managed-vector-view-state-end (view) (get view :end))
|
|
18
|
+
(defportable managed-vector-view-state-count (view) (- (get view :end) (get view :start)))
|
|
19
|
+
(defportable managed-vector-view-state-meta (view) (get view :metadata))
|
|
20
|
+
|
|
21
|
+
(defportable managed-vector-view-state-valid-index? (index count inclusive)
|
|
22
|
+
(and (= (value-type index) "number")
|
|
23
|
+
(>= index -9007199254740991) (<= index 9007199254740991)
|
|
24
|
+
(= (% index 1) 0) (>= index 0)
|
|
25
|
+
(if inclusive (<= index count) (< index count))))
|
|
26
|
+
|
|
27
|
+
(defportable managed-vector-view-state-subvec (vector start end)
|
|
28
|
+
(let* ((view? (managed-vector-view-state? vector))
|
|
29
|
+
(valid? (or view? (persistent-vector? vector)))
|
|
30
|
+
(count (if view? (managed-vector-view-state-count vector)
|
|
31
|
+
(if valid? (persistent-vector-count vector) 0)))
|
|
32
|
+
(limit (if (nullish? end) count end)))
|
|
33
|
+
(if (or (not valid?)
|
|
34
|
+
(not (managed-vector-view-state-valid-index? start count t))
|
|
35
|
+
(not (managed-vector-view-state-valid-index? limit count t)) (< limit start))
|
|
36
|
+
nil
|
|
37
|
+
;; subvec creates a new unannotated view, including when its source is
|
|
38
|
+
;; itself annotated. Nested views share the original underlying trie.
|
|
39
|
+
(if view?
|
|
40
|
+
(managed-vector-view-state-make (get vector :vector)
|
|
41
|
+
(+ (get vector :start) start) (+ (get vector :start) limit) nil)
|
|
42
|
+
(managed-vector-view-state-make vector start limit nil)))))
|
|
43
|
+
|
|
44
|
+
(defportable managed-vector-view-state-with-meta (view metadata)
|
|
45
|
+
(if (eq metadata (get view :metadata)) view
|
|
46
|
+
(managed-vector-view-state-make (get view :vector) (get view :start) (get view :end) metadata)))
|
|
47
|
+
|
|
48
|
+
(defportable managed-vector-view-state-nth (view index not-found)
|
|
49
|
+
(if (managed-vector-view-state-valid-index? index (managed-vector-view-state-count view) false)
|
|
50
|
+
(persistent-vector-nth (get view :vector) (+ (get view :start) index) not-found)
|
|
51
|
+
not-found))
|
|
52
|
+
|
|
53
|
+
(defportable managed-vector-view-state-assoc (view index value)
|
|
54
|
+
(let ((count (managed-vector-view-state-count view)))
|
|
55
|
+
(if (not (managed-vector-view-state-valid-index? index count t)) nil
|
|
56
|
+
(let* ((vector (get view :vector)) (absolute (+ (get view :start) index))
|
|
57
|
+
(next (if (= absolute (persistent-vector-count vector))
|
|
58
|
+
(persistent-vector-conj vector value)
|
|
59
|
+
(persistent-vector-assoc vector absolute value))))
|
|
60
|
+
(if (nil? next) nil
|
|
61
|
+
(managed-vector-view-state-make next (get view :start)
|
|
62
|
+
(if (> (1+ absolute) (get view :end)) (1+ absolute) (get view :end))
|
|
63
|
+
(get view :metadata)))))))
|
|
64
|
+
|
|
65
|
+
(defportable managed-vector-view-state-conj (view value)
|
|
66
|
+
(managed-vector-view-state-assoc view (managed-vector-view-state-count view) value))
|
|
67
|
+
|
|
68
|
+
(defportable managed-vector-view-state-peek (view not-found)
|
|
69
|
+
(if (= (get view :start) (get view :end)) not-found
|
|
70
|
+
(persistent-vector-nth (get view :vector) (1- (get view :end)) not-found)))
|
|
71
|
+
|
|
72
|
+
(defportable managed-vector-view-state-empty (view)
|
|
73
|
+
(persistent-vector-with-meta (empty-persistent-vector) (get view :metadata)))
|
|
74
|
+
|
|
75
|
+
(defportable managed-vector-view-state-pop (view)
|
|
76
|
+
(let ((count (managed-vector-view-state-count view)))
|
|
77
|
+
(if (= count 0) nil
|
|
78
|
+
(if (= count 1) (managed-vector-view-state-empty view)
|
|
79
|
+
(managed-vector-view-state-make (get view :vector) (get view :start)
|
|
80
|
+
(1- (get view :end)) (get view :metadata))))))
|
|
81
|
+
|
|
82
|
+
(defportable managed-vector-view-state-array-reverse (values)
|
|
83
|
+
(let ((result (js-array)) (index 0))
|
|
84
|
+
(while (< index (js-length values))
|
|
85
|
+
(setq result (js-cons (get values index) result) index (1+ index)))
|
|
86
|
+
result))
|
|
87
|
+
|
|
88
|
+
(defportable managed-vector-view-state-to-array (view)
|
|
89
|
+
(let ((values (js-array)) (index (get view :start))
|
|
90
|
+
(end (get view :end)) (vector (get view :vector)))
|
|
91
|
+
(while (< index end)
|
|
92
|
+
(setq values (js-cons (persistent-vector-nth vector index nil) values)
|
|
93
|
+
index (1+ index)))
|
|
94
|
+
(managed-vector-view-state-array-reverse values)))
|
|
95
|
+
|
|
96
|
+
(export managed-vector-view-state? managed-vector-view-state-make
|
|
97
|
+
managed-vector-view-state-vector managed-vector-view-state-start managed-vector-view-state-end
|
|
98
|
+
managed-vector-view-state-count managed-vector-view-state-meta managed-vector-view-state-subvec
|
|
99
|
+
managed-vector-view-state-valid-index? managed-vector-view-state-with-meta
|
|
100
|
+
managed-vector-view-state-nth managed-vector-view-state-assoc managed-vector-view-state-conj
|
|
101
|
+
managed-vector-view-state-peek managed-vector-view-state-empty managed-vector-view-state-pop
|
|
102
|
+
managed-vector-view-state-to-array))
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
(module eliscript.persistent-list
|
|
2
|
+
(defconst persistent-list-kind "eliscript/persistent-list")
|
|
3
|
+
(defconst persistent-list-max-count 2147483647)
|
|
4
|
+
|
|
5
|
+
(defportable make-empty-persistent-list (metadata)
|
|
6
|
+
(js-object :kind persistent-list-kind
|
|
7
|
+
:count 0
|
|
8
|
+
:empty t
|
|
9
|
+
:value nil
|
|
10
|
+
:rest nil
|
|
11
|
+
:metadata metadata))
|
|
12
|
+
|
|
13
|
+
(defportable make-persistent-list-node (value rest metadata)
|
|
14
|
+
(js-object :kind persistent-list-kind
|
|
15
|
+
:count (1+ (get rest "count" 0))
|
|
16
|
+
:empty false
|
|
17
|
+
:value value
|
|
18
|
+
:rest rest
|
|
19
|
+
:metadata metadata))
|
|
20
|
+
|
|
21
|
+
(defportable persistent-list? (value)
|
|
22
|
+
(and (not (nullish? value))
|
|
23
|
+
(object-has? value "kind")
|
|
24
|
+
(= (get value "kind" nil) persistent-list-kind)))
|
|
25
|
+
|
|
26
|
+
(defportable empty-persistent-list ()
|
|
27
|
+
(make-empty-persistent-list nil))
|
|
28
|
+
|
|
29
|
+
(defportable persistent-list-empty? (list)
|
|
30
|
+
(= (get list "count" 0) 0))
|
|
31
|
+
|
|
32
|
+
(defportable persistent-list-count (list)
|
|
33
|
+
(get list "count" 0))
|
|
34
|
+
|
|
35
|
+
(defportable persistent-list-cons (list value)
|
|
36
|
+
(if (>= (persistent-list-count list) persistent-list-max-count)
|
|
37
|
+
nil
|
|
38
|
+
(make-persistent-list-node
|
|
39
|
+
value list (get list "metadata" nil))))
|
|
40
|
+
|
|
41
|
+
(defportable persistent-list-conj (list value)
|
|
42
|
+
(persistent-list-cons list value))
|
|
43
|
+
|
|
44
|
+
(defportable persistent-list-first (list not-found)
|
|
45
|
+
(if (persistent-list-empty? list)
|
|
46
|
+
not-found
|
|
47
|
+
(get list "value")))
|
|
48
|
+
|
|
49
|
+
(defportable persistent-list-rest (list not-found)
|
|
50
|
+
(if (persistent-list-empty? list)
|
|
51
|
+
not-found
|
|
52
|
+
(get list "rest" nil)))
|
|
53
|
+
|
|
54
|
+
(defportable persistent-list-peek (list not-found)
|
|
55
|
+
(persistent-list-first list not-found))
|
|
56
|
+
|
|
57
|
+
(defportable persistent-list-pop (list)
|
|
58
|
+
(if (persistent-list-empty? list)
|
|
59
|
+
nil
|
|
60
|
+
(get list "rest" nil)))
|
|
61
|
+
|
|
62
|
+
(defportable persistent-list-meta (list)
|
|
63
|
+
(get list "metadata" nil))
|
|
64
|
+
|
|
65
|
+
(defportable persistent-list-with-meta (list metadata)
|
|
66
|
+
(if (= metadata (persistent-list-meta list))
|
|
67
|
+
list
|
|
68
|
+
(if (persistent-list-empty? list)
|
|
69
|
+
(make-empty-persistent-list metadata)
|
|
70
|
+
(make-persistent-list-node
|
|
71
|
+
(get list "value")
|
|
72
|
+
(get list "rest" nil)
|
|
73
|
+
metadata))))
|
|
74
|
+
|
|
75
|
+
(defportable persistent-list-valid-index? (index count)
|
|
76
|
+
(and (= index (int32 index))
|
|
77
|
+
(>= index 0)
|
|
78
|
+
(< index count)))
|
|
79
|
+
|
|
80
|
+
(defportable persistent-list-nth (list index not-found)
|
|
81
|
+
(if (not (persistent-list-valid-index?
|
|
82
|
+
index
|
|
83
|
+
(persistent-list-count list)))
|
|
84
|
+
not-found
|
|
85
|
+
(let ((current list)
|
|
86
|
+
(current-index 0))
|
|
87
|
+
(while (< current-index index)
|
|
88
|
+
(setq current (get current "rest" nil)
|
|
89
|
+
current-index (1+ current-index)))
|
|
90
|
+
(get current "value"))))
|
|
91
|
+
|
|
92
|
+
(defportable persistent-list-reduce (function initial list)
|
|
93
|
+
(let ((result initial)
|
|
94
|
+
(current list))
|
|
95
|
+
(while (not (persistent-list-empty? current))
|
|
96
|
+
(setq result (funcall function result (get current "value"))
|
|
97
|
+
current (get current "rest" nil)))
|
|
98
|
+
result))
|
|
99
|
+
|
|
100
|
+
(defportable persistent-list-reverse (list)
|
|
101
|
+
(persistent-list-reduce
|
|
102
|
+
(lambda (result value) (persistent-list-cons result value))
|
|
103
|
+
(make-empty-persistent-list (persistent-list-meta list))
|
|
104
|
+
list))
|
|
105
|
+
|
|
106
|
+
(defportable persistent-list-array-reverse (values)
|
|
107
|
+
(let ((result (js-array))
|
|
108
|
+
(index 0))
|
|
109
|
+
(while (< index (js-length values))
|
|
110
|
+
(setq result (js-cons (get values index) result)
|
|
111
|
+
index (1+ index)))
|
|
112
|
+
result))
|
|
113
|
+
|
|
114
|
+
(defportable persistent-list-to-array (list)
|
|
115
|
+
(persistent-list-array-reverse
|
|
116
|
+
(persistent-list-reduce
|
|
117
|
+
(lambda (result value) (js-cons value result))
|
|
118
|
+
(js-array)
|
|
119
|
+
list)))
|
|
120
|
+
|
|
121
|
+
(defportable persistent-list-from-array (values)
|
|
122
|
+
(let ((result (empty-persistent-list))
|
|
123
|
+
(index (1- (js-length values))))
|
|
124
|
+
(while (>= index 0)
|
|
125
|
+
(setq result (persistent-list-cons result (get values index))
|
|
126
|
+
index (1- index)))
|
|
127
|
+
result))
|
|
128
|
+
|
|
129
|
+
(export empty-persistent-list
|
|
130
|
+
persistent-list?
|
|
131
|
+
persistent-list-empty?
|
|
132
|
+
persistent-list-count
|
|
133
|
+
persistent-list-cons
|
|
134
|
+
persistent-list-conj
|
|
135
|
+
persistent-list-first
|
|
136
|
+
persistent-list-rest
|
|
137
|
+
persistent-list-peek
|
|
138
|
+
persistent-list-pop
|
|
139
|
+
persistent-list-meta
|
|
140
|
+
persistent-list-with-meta
|
|
141
|
+
persistent-list-nth
|
|
142
|
+
persistent-list-reduce
|
|
143
|
+
persistent-list-reverse
|
|
144
|
+
persistent-list-to-array
|
|
145
|
+
persistent-list-from-array))
|