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,193 @@
|
|
|
1
|
+
(module eliscript.managed-wire-schema
|
|
2
|
+
(import "./markdown.eli" parse)
|
|
3
|
+
(import "../../stdlib/managed-literal-protocols.eli" managed-literal-reduce-iterable managed-literal-reduced)
|
|
4
|
+
|
|
5
|
+
(defconst types (new globalThis/Set (js-array "any" "string" "int" "float" "number" "bool" "null" "date" "datetime")))
|
|
6
|
+
(defconst reserved (new globalThis/Set (js-array "Preamble" "Sections")))
|
|
7
|
+
(defconst date-pattern (js* "/^\\d{4}-\\d{2}-\\d{2}$/u"))
|
|
8
|
+
(defconst datetime-pattern (js* "/^\\d{4}-\\d{2}-\\d{2}[Tt]\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:[Zz]|[+-]\\d{2}:\\d{2})$/u"))
|
|
9
|
+
(defun fail (message) (throw (new globalThis/TypeError message)))
|
|
10
|
+
(defun object? (value) (and (not (nil? value)) (= (js* "typeof value") "object") (not (Array/isArray value))))
|
|
11
|
+
(defun truth (value) (funcall globalThis/Boolean value))
|
|
12
|
+
(defun each (values visit)
|
|
13
|
+
(managed-literal-reduce-iterable values (lambda (ignored value) (funcall visit value) nil) (js-array nil)))
|
|
14
|
+
(defun at (document path)
|
|
15
|
+
(managed-literal-reduce-iterable (js-call path :split ".")
|
|
16
|
+
(lambda (value part)
|
|
17
|
+
(if (and (object? value) (Object/hasOwn value part)) (aref value part)
|
|
18
|
+
(managed-literal-reduced undefined))) (js-array document)))
|
|
19
|
+
(defun copy-row (row)
|
|
20
|
+
(let ((result (js-object)))
|
|
21
|
+
(each (Reflect/ownKeys row) (lambda (key)
|
|
22
|
+
(let ((descriptor (Object/getOwnPropertyDescriptor row key)))
|
|
23
|
+
(when (and (not (undefined? descriptor)) (truth (aref descriptor "enumerable")))
|
|
24
|
+
(Object/defineProperty result key (js-object :value (aref row key) :enumerable t :writable t :configurable t))))))
|
|
25
|
+
result))
|
|
26
|
+
(defun decimal-part (text start end) (funcall globalThis/Number (js-call text :slice start end)))
|
|
27
|
+
(defun valid-date? (value)
|
|
28
|
+
(and (= (js* "typeof value") "string") (= (js-length value) 10) (js-call date-pattern :test value)
|
|
29
|
+
(let* ((year (decimal-part value 0 4)) (month (decimal-part value 5 7)) (day (decimal-part value 8 10))
|
|
30
|
+
(leap (and (= (% year 4) 0) (or (/= (% year 100) 0) (= (% year 400) 0))))
|
|
31
|
+
(days (if (= month 2) (if leap 29 28)
|
|
32
|
+
(if (js-call (js-array 4 6 9 11) :includes month) 30 31))))
|
|
33
|
+
(and (>= month 1) (<= month 12) (>= day 1) (<= day days)))))
|
|
34
|
+
(defun valid-datetime? (value)
|
|
35
|
+
(and (= (js* "typeof value") "string") (js-call datetime-pattern :test value)
|
|
36
|
+
(valid-date? (js-call value :slice 0 10))
|
|
37
|
+
(let* ((hour (decimal-part value 11 13)) (minute (decimal-part value 14 16)) (second (decimal-part value 17 19))
|
|
38
|
+
(zone-end (1- (js-length value))) (last (aref value zone-end))
|
|
39
|
+
(zulu (or (= last "Z") (= last "z")))
|
|
40
|
+
(zone-start (if zulu zone-end (- (js-length value) 6)))
|
|
41
|
+
(millisecond 0))
|
|
42
|
+
;; The ISO Date parser keeps the first three fractional second digits;
|
|
43
|
+
;; subsequent digits do not turn a midnight millisecond into nonzero.
|
|
44
|
+
(when (= (aref value 19) ".")
|
|
45
|
+
(let ((fraction (js-call value :slice 20 zone-start)))
|
|
46
|
+
(setq millisecond (funcall globalThis/Number (js-call (str fraction "000") :slice 0 3)))))
|
|
47
|
+
(and (<= hour 24) (<= minute 59) (<= second 59)
|
|
48
|
+
(or (< hour 24) (and (= minute 0) (= second 0) (= millisecond 0)))
|
|
49
|
+
(or zulu (and (<= (decimal-part value (1+ zone-start) (+ zone-start 3)) 23)
|
|
50
|
+
(<= (decimal-part value (+ zone-start 4) (+ zone-start 6)) 59)))))))
|
|
51
|
+
(defun typed? (value type)
|
|
52
|
+
(cond ((= type "any") t)
|
|
53
|
+
((= type "string") (= (js* "typeof value") "string"))
|
|
54
|
+
((= type "int") (and (Number/isFinite value) (Number/isInteger value)))
|
|
55
|
+
((or (= type "float") (= type "number")) (and (= (js* "typeof value") "number") (Number/isFinite value)))
|
|
56
|
+
((= type "bool") (= (js* "typeof value") "boolean"))
|
|
57
|
+
((= type "null") (nil? value))
|
|
58
|
+
((= type "date") (valid-date? value))
|
|
59
|
+
((= type "datetime") (valid-datetime? value))
|
|
60
|
+
(t undefined)))
|
|
61
|
+
(defun validate (data schema)
|
|
62
|
+
(when (= (js* "typeof data") "string") (setq data (parse data)))
|
|
63
|
+
(when (= (js* "typeof schema") "string") (setq schema (parse schema)))
|
|
64
|
+
(unless (and (object? data) (object? schema) (= (aref schema "mds") "0.1"))
|
|
65
|
+
(fail "Expected object data and an MDS/0.1 schema"))
|
|
66
|
+
(each (Object/entries schema) (lambda (entry)
|
|
67
|
+
(let ((name (aref entry 0)) (value (aref entry 1)))
|
|
68
|
+
(when (and (not (js-call reserved :has name)) (object? value))
|
|
69
|
+
(fail "Schema field definition must be a table")))))
|
|
70
|
+
(let* ((definitions (js-call (Object/keys schema) :filter
|
|
71
|
+
(lambda (key &rest ignored) (and (not (js-call reserved :has key)) (Array/isArray (aref schema key))))))
|
|
72
|
+
(fields (new globalThis/Map)) (names (js-call definitions :slice)))
|
|
73
|
+
(when (Object/hasOwn schema "Preamble") (js-call names :push "Preamble"))
|
|
74
|
+
(each names (lambda (name)
|
|
75
|
+
(let ((rows (aref schema name)) (seen (new globalThis/Set)))
|
|
76
|
+
(unless (Array/isArray rows) (fail "Schema field definition must be a table"))
|
|
77
|
+
(js-call fields :set name (js-call rows :map (lambda (row &rest ignored)
|
|
78
|
+
(unless (and (object? row)
|
|
79
|
+
(let ((name (aref row "name"))) (= (js* "typeof name") "string"))
|
|
80
|
+
(truth (aref row "name"))
|
|
81
|
+
(js-call types :has (aref row "type")) (not (js-call seen :has (aref row "name"))))
|
|
82
|
+
(fail "Invalid schema field declaration"))
|
|
83
|
+
(js-call seen :add (aref row "name"))
|
|
84
|
+
(when (and (Object/hasOwn row "required")
|
|
85
|
+
(let ((required (aref row "required"))) (/= (js* "typeof required") "boolean")))
|
|
86
|
+
(fail "required must be boolean"))
|
|
87
|
+
(each (js-array "min" "max" "min_len" "max_len") (lambda (key)
|
|
88
|
+
(when (and (Object/hasOwn row key)
|
|
89
|
+
(or (let ((value (aref row key))) (/= (js* "typeof value") "number"))
|
|
90
|
+
(not (Number/isFinite (aref row key)))
|
|
91
|
+
(and (js-call key :endsWith "_len")
|
|
92
|
+
(or (not (Number/isInteger (aref row key))) (< (aref row key) 0)))))
|
|
93
|
+
(fail (str "Invalid " key " constraint")))))
|
|
94
|
+
(when (or (and (not (undefined? (aref row "min"))) (not (undefined? (aref row "max")))
|
|
95
|
+
(> (aref row "min") (aref row "max")))
|
|
96
|
+
(and (not (undefined? (aref row "min_len"))) (not (undefined? (aref row "max_len")))
|
|
97
|
+
(> (aref row "min_len") (aref row "max_len")))) (fail "Inverted field bounds"))
|
|
98
|
+
(when (and (Object/hasOwn row "enum")
|
|
99
|
+
(let ((value (aref row "enum"))) (/= (js* "typeof value") "string"))) (fail "enum must be text"))
|
|
100
|
+
(let ((pattern undefined))
|
|
101
|
+
(when (Object/hasOwn row "pattern")
|
|
102
|
+
(unless (let ((value (aref row "pattern"))) (= (js* "typeof value") "string")) (fail "pattern must be text"))
|
|
103
|
+
(setq pattern (new globalThis/RegExp (aref row "pattern") "u")))
|
|
104
|
+
(let ((result (copy-row row)))
|
|
105
|
+
(Object/defineProperty result "pattern" (js-object :value pattern :enumerable t :writable t :configurable t)) result))))))))
|
|
106
|
+
(let ((declarations undefined) (declared (new globalThis/Map)))
|
|
107
|
+
(if (Object/hasOwn schema "Sections")
|
|
108
|
+
(progn (unless (Array/isArray (aref schema "Sections")) (fail "Sections must be a table"))
|
|
109
|
+
(setq declarations (aref schema "Sections")))
|
|
110
|
+
(setq declarations (js-call definitions :map (lambda (name &rest ignored) (js-object :name name :required t)))))
|
|
111
|
+
(each declarations (lambda (row)
|
|
112
|
+
(unless (and (object? row)
|
|
113
|
+
(let ((name (aref row "name"))) (= (js* "typeof name") "string"))
|
|
114
|
+
(truth (aref row "name"))
|
|
115
|
+
(not (js-call (js-call (aref row "name") :split ".") :some
|
|
116
|
+
(lambda (part &rest ignored) (not (truth part)))))
|
|
117
|
+
(not (js-call declared :has (aref row "name")))
|
|
118
|
+
(let ((kind (aref row "kind")))
|
|
119
|
+
(js-call (js-array "object" "list" "any") :includes
|
|
120
|
+
(if (nullish? kind) "any" kind))))
|
|
121
|
+
(fail "Invalid section declaration"))
|
|
122
|
+
(each (js-array "required" "additional") (lambda (key)
|
|
123
|
+
(when (and (Object/hasOwn row key)
|
|
124
|
+
(let ((value (aref row key))) (/= (js* "typeof value") "boolean"))) (fail (str key " must be boolean")))))
|
|
125
|
+
(each (js-array "min_rows" "max_rows") (lambda (key)
|
|
126
|
+
(when (and (Object/hasOwn row key) (or (not (Number/isSafeInteger (aref row key))) (< (aref row key) 0)))
|
|
127
|
+
(fail (str "Invalid " key " constraint")))))
|
|
128
|
+
(when (and (not (undefined? (aref row "min_rows"))) (not (undefined? (aref row "max_rows")))
|
|
129
|
+
(> (aref row "min_rows") (aref row "max_rows"))) (fail "Inverted row bounds"))
|
|
130
|
+
(js-call declared :set (aref row "name") row)))
|
|
131
|
+
(let ((errors (js-array)) (error nil) (check-row nil))
|
|
132
|
+
(setq error (lambda (path rule expected actual)
|
|
133
|
+
(js-call errors :push (js-object :path path :rule rule :expected expected :actual actual))))
|
|
134
|
+
(setq check-row (lambda (value rows path &rest optional-arguments)
|
|
135
|
+
(let ((additional (aref optional-arguments 0)))
|
|
136
|
+
(when (undefined? additional) (setq additional t))
|
|
137
|
+
(if (not (object? value)) (funcall error path "kind" "object" value)
|
|
138
|
+
(progn
|
|
139
|
+
(each rows (lambda (row)
|
|
140
|
+
(let ((field-path (str path "." (aref row "name"))))
|
|
141
|
+
(if (not (Object/hasOwn value (aref row "name")))
|
|
142
|
+
(when (truth (aref row "required")) (funcall error field-path "required" t "missing"))
|
|
143
|
+
(let ((actual (aref value (aref row "name"))))
|
|
144
|
+
(if (not (truth (typed? actual (aref row "type"))))
|
|
145
|
+
(funcall error field-path "type" (aref row "type") actual)
|
|
146
|
+
(progn
|
|
147
|
+
(when (and (not (undefined? (aref row "enum"))))
|
|
148
|
+
(unless (js-call (js-call (js-call (aref row "enum") :split ",") :map
|
|
149
|
+
(lambda (text &rest ignored) (js-call text :trim))) :includes (funcall globalThis/String actual))
|
|
150
|
+
(funcall error field-path "enum" (aref row "enum") actual)))
|
|
151
|
+
(each (js-array "min" "max") (lambda (key)
|
|
152
|
+
(when (and (= (js* "typeof actual") "number") (not (undefined? (aref row key)))
|
|
153
|
+
(if (= key "min") (< actual (aref row key)) (> actual (aref row key))))
|
|
154
|
+
(funcall error field-path key (aref row key) actual))))
|
|
155
|
+
(when (= (js* "typeof actual") "string")
|
|
156
|
+
(let ((length (managed-literal-reduce-iterable actual
|
|
157
|
+
(lambda (size ignored) (1+ size)) (js-array 0))))
|
|
158
|
+
(each (js-array "min_len" "max_len") (lambda (key)
|
|
159
|
+
(when (and (not (undefined? (aref row key)))
|
|
160
|
+
(if (= key "min_len") (< length (aref row key)) (> length (aref row key))))
|
|
161
|
+
(funcall error field-path key (aref row key) length)))))
|
|
162
|
+
(when (and (truth (aref row "pattern")) (not (js-call (aref row "pattern") :test actual)))
|
|
163
|
+
(funcall error field-path "pattern" (aref (aref row "pattern") "source") actual))))))))))
|
|
164
|
+
(unless (truth additional)
|
|
165
|
+
(let ((allowed (new globalThis/Set (js-call rows :map (lambda (row &rest ignored) (aref row "name"))))))
|
|
166
|
+
(each (Object/keys value) (lambda (key)
|
|
167
|
+
(when (and (not (js-call allowed :has key))
|
|
168
|
+
(or (nil? (aref value key)) (let ((item (aref value key))) (/= (js* "typeof item") "object"))))
|
|
169
|
+
(funcall error (str path "." key) "additional" false (aref value key))))))))))))
|
|
170
|
+
(when (js-call fields :has "Preamble") (funcall check-row data (js-call fields :get "Preamble") "preamble"))
|
|
171
|
+
(let ((names (new globalThis/Set definitions)))
|
|
172
|
+
(each (js-call declared :keys) (lambda (name) (js-call names :add name)))
|
|
173
|
+
(each names (lambda (name)
|
|
174
|
+
(let* ((raw-policy (js-call declared :get name)) (policy (if (nullish? raw-policy) (js-object) raw-policy))
|
|
175
|
+
(value (at data name)))
|
|
176
|
+
(if (undefined? value)
|
|
177
|
+
(when (truth (aref policy "required")) (funcall error name "required" t "missing"))
|
|
178
|
+
(let ((kind (if (Array/isArray value) "list" (if (object? value) "object" "scalar"))))
|
|
179
|
+
(if (and (truth (aref policy "kind")) (/= (aref policy "kind") "any") (/= (aref policy "kind") kind))
|
|
180
|
+
(funcall error name "kind" (aref policy "kind") kind)
|
|
181
|
+
(if (Array/isArray value)
|
|
182
|
+
(progn
|
|
183
|
+
(each (js-array "min_rows" "max_rows") (lambda (key)
|
|
184
|
+
(when (and (not (undefined? (aref policy key)))
|
|
185
|
+
(if (= key "min_rows") (< (js-length value) (aref policy key)) (> (js-length value) (aref policy key))))
|
|
186
|
+
(funcall error name key (aref policy key) (js-length value)))))
|
|
187
|
+
(when (js-call fields :has name)
|
|
188
|
+
(js-call value :forEach (lambda (row index &rest ignored)
|
|
189
|
+
(funcall check-row row (js-call fields :get name) (str name "[" index "]") (aref policy "additional"))))))
|
|
190
|
+
(when (js-call fields :has name)
|
|
191
|
+
(funcall check-row value (js-call fields :get name) name (aref policy "additional")))))))))))
|
|
192
|
+
(js-object :valid (= (js-length errors) 0) :errors errors)))))
|
|
193
|
+
(export validate))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
(module eliscript.bit
|
|
2
|
+
(defportable bit-count (value)
|
|
3
|
+
(let* ((bits (uint32 value))
|
|
4
|
+
(pairs
|
|
5
|
+
(- bits
|
|
6
|
+
(bit-and
|
|
7
|
+
(unsigned-bit-shift-right bits 1)
|
|
8
|
+
1431655765)))
|
|
9
|
+
(quads
|
|
10
|
+
(+ (bit-and pairs 858993459)
|
|
11
|
+
(bit-and
|
|
12
|
+
(unsigned-bit-shift-right pairs 2)
|
|
13
|
+
858993459)))
|
|
14
|
+
(octets
|
|
15
|
+
(bit-and
|
|
16
|
+
(+ quads (unsigned-bit-shift-right quads 4))
|
|
17
|
+
252645135)))
|
|
18
|
+
(unsigned-bit-shift-right
|
|
19
|
+
(imul32 octets 16843009)
|
|
20
|
+
24)))
|
|
21
|
+
|
|
22
|
+
(defportable rotate-left (value distance)
|
|
23
|
+
(let ((amount (bit-and distance 31)))
|
|
24
|
+
(uint32
|
|
25
|
+
(bit-or
|
|
26
|
+
(bit-shift-left value amount)
|
|
27
|
+
(unsigned-bit-shift-right value (- 32 amount))))))
|
|
28
|
+
|
|
29
|
+
(defportable rotate-right (value distance)
|
|
30
|
+
(let ((amount (bit-and distance 31)))
|
|
31
|
+
(uint32
|
|
32
|
+
(bit-or
|
|
33
|
+
(unsigned-bit-shift-right value amount)
|
|
34
|
+
(bit-shift-left value (- 32 amount))))))
|
|
35
|
+
|
|
36
|
+
(export bit-count rotate-left rotate-right))
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
(module eliscript.core.data
|
|
2
|
+
(import "../../runtime/core/collection.mjs" :as Collection)
|
|
3
|
+
(import "../../runtime/core/map.mjs" EMPTY_MAP)
|
|
4
|
+
(import "../../runtime/core/protocol.mjs" :as Protocol)
|
|
5
|
+
(import "../../runtime/core/transducer.mjs" into)
|
|
6
|
+
(import "../../runtime/core/transient.mjs"
|
|
7
|
+
assocBang
|
|
8
|
+
conjBang
|
|
9
|
+
persistentBang
|
|
10
|
+
transient)
|
|
11
|
+
(import "../../runtime/core/vector.mjs" EMPTY_VECTOR)
|
|
12
|
+
(defconst missing-value (js-object))
|
|
13
|
+
(defun require-function
|
|
14
|
+
(value label)
|
|
15
|
+
(if (= (value-type value) "function")
|
|
16
|
+
value
|
|
17
|
+
(throw (new globalThis/TypeError (str label " must be a function")))))
|
|
18
|
+
(defun nullish? (value) (or (eq value nil) (eq value globalThis/undefined)))
|
|
19
|
+
(defun path-vector (path) (into EMPTY_VECTOR path))
|
|
20
|
+
(defun read-entry
|
|
21
|
+
(entry)
|
|
22
|
+
(if (= (Collection/count entry) 2)
|
|
23
|
+
(js-object :key (Collection/nth entry 0) :value (Collection/nth entry 1))
|
|
24
|
+
(throw
|
|
25
|
+
(new
|
|
26
|
+
globalThis/TypeError
|
|
27
|
+
"data entries must contain exactly one key/value pair"))))
|
|
28
|
+
(defun reduce-entries
|
|
29
|
+
(collection reducer initial)
|
|
30
|
+
(if
|
|
31
|
+
(and
|
|
32
|
+
(Protocol/implementsProtocolOperation
|
|
33
|
+
Collection/IKVReduce
|
|
34
|
+
"reduceKV"
|
|
35
|
+
collection)
|
|
36
|
+
(not
|
|
37
|
+
(Protocol/implementsProtocolOperation Collection/IIndexed "nth" collection)))
|
|
38
|
+
(Collection/reduceKV collection reducer initial)
|
|
39
|
+
(Collection/reduce
|
|
40
|
+
collection
|
|
41
|
+
(lambda
|
|
42
|
+
(result entry)
|
|
43
|
+
(let ((pair (read-entry entry)))
|
|
44
|
+
(funcall reducer result (get pair :key) (get pair :value))))
|
|
45
|
+
initial)))
|
|
46
|
+
(defun collect-buckets
|
|
47
|
+
(key-function collection create-bucket update-bucket)
|
|
48
|
+
(require-function key-function "data key function")
|
|
49
|
+
(let ((bucket-index EMPTY_MAP) (keys (js-array)) (buckets (js-array)))
|
|
50
|
+
(Collection/reduce
|
|
51
|
+
collection
|
|
52
|
+
(lambda
|
|
53
|
+
(result value)
|
|
54
|
+
(let*
|
|
55
|
+
((key (funcall key-function value))
|
|
56
|
+
(index (js-call bucket-index :get key missing-value)))
|
|
57
|
+
(if (eq index missing-value)
|
|
58
|
+
(progn
|
|
59
|
+
(setq
|
|
60
|
+
index
|
|
61
|
+
(js-length keys)
|
|
62
|
+
bucket-index
|
|
63
|
+
(js-call bucket-index :assoc key index))
|
|
64
|
+
(js-call keys :push key)
|
|
65
|
+
(js-call buckets :push (funcall create-bucket value)))
|
|
66
|
+
(funcall update-bucket buckets index value))
|
|
67
|
+
result))
|
|
68
|
+
nil)
|
|
69
|
+
(js-object :keys keys :buckets buckets)))
|
|
70
|
+
(defun persistent-map-from-buckets
|
|
71
|
+
(keys buckets finish-bucket)
|
|
72
|
+
(let ((result (transient EMPTY_MAP)) (index 0))
|
|
73
|
+
(while (< index (js-length keys))
|
|
74
|
+
(assocBang
|
|
75
|
+
result
|
|
76
|
+
(js-nth index keys)
|
|
77
|
+
(funcall finish-bucket (js-nth index buckets)))
|
|
78
|
+
(setq index (1+ index)))
|
|
79
|
+
(persistentBang result)))
|
|
80
|
+
(defun index-by
|
|
81
|
+
(key-function collection)
|
|
82
|
+
(require-function key-function "indexBy key function")
|
|
83
|
+
(let ((result (transient EMPTY_MAP)))
|
|
84
|
+
(Collection/reduce
|
|
85
|
+
collection
|
|
86
|
+
(lambda
|
|
87
|
+
(builder value)
|
|
88
|
+
(assocBang builder (funcall key-function value) value)
|
|
89
|
+
builder)
|
|
90
|
+
result)
|
|
91
|
+
(persistentBang result)))
|
|
92
|
+
(defun group-by
|
|
93
|
+
(key-function collection)
|
|
94
|
+
(let*
|
|
95
|
+
(
|
|
96
|
+
(grouped
|
|
97
|
+
(collect-buckets
|
|
98
|
+
key-function
|
|
99
|
+
collection
|
|
100
|
+
(lambda (value) (js-array value))
|
|
101
|
+
(lambda (buckets index value) (js-call (js-nth index buckets) :push value))))
|
|
102
|
+
(keys (get grouped :keys))
|
|
103
|
+
(buckets (get grouped :buckets)))
|
|
104
|
+
(persistent-map-from-buckets
|
|
105
|
+
keys
|
|
106
|
+
buckets
|
|
107
|
+
(lambda (values) (into EMPTY_VECTOR values)))))
|
|
108
|
+
(defun count-by
|
|
109
|
+
(key-function collection)
|
|
110
|
+
(let*
|
|
111
|
+
(
|
|
112
|
+
(counted
|
|
113
|
+
(collect-buckets
|
|
114
|
+
key-function
|
|
115
|
+
collection
|
|
116
|
+
(lambda (_value) 1)
|
|
117
|
+
(lambda (counts index _value) (put counts index (1+ (js-nth index counts))))))
|
|
118
|
+
(keys (get counted :keys))
|
|
119
|
+
(buckets (get counted :buckets)))
|
|
120
|
+
(persistent-map-from-buckets keys buckets (lambda (count) count))))
|
|
121
|
+
(defun frequencies (collection) (count-by (lambda (value) value) collection))
|
|
122
|
+
(defun get-in
|
|
123
|
+
(collection path &optional not-found)
|
|
124
|
+
(let*
|
|
125
|
+
((keys (path-vector path))
|
|
126
|
+
(size (Collection/count keys))
|
|
127
|
+
(index 0)
|
|
128
|
+
(current collection))
|
|
129
|
+
(while (and (< index size) (not (nullish? current)))
|
|
130
|
+
(setq
|
|
131
|
+
current
|
|
132
|
+
(Collection/get current (Collection/nth keys index) missing-value))
|
|
133
|
+
(if (eq current missing-value) (setq index size) (setq index (1+ index))))
|
|
134
|
+
(if (or (eq current missing-value) (and (< index size) (nullish? current)))
|
|
135
|
+
not-found
|
|
136
|
+
current)))
|
|
137
|
+
(defun assoc-in
|
|
138
|
+
(collection path value)
|
|
139
|
+
(let* ((keys (path-vector path)) (size (Collection/count keys)))
|
|
140
|
+
(if (= size 0)
|
|
141
|
+
value
|
|
142
|
+
(let ((parents (js-array)) (current collection) (index 0))
|
|
143
|
+
(while (< index (1- size))
|
|
144
|
+
(js-call parents :push current)
|
|
145
|
+
(if (nullish? current)
|
|
146
|
+
(setq current EMPTY_MAP)
|
|
147
|
+
(let
|
|
148
|
+
(
|
|
149
|
+
(child
|
|
150
|
+
(Collection/get current (Collection/nth keys index) missing-value)))
|
|
151
|
+
(setq
|
|
152
|
+
current
|
|
153
|
+
(if (or (eq child missing-value) (nullish? child)) EMPTY_MAP child))))
|
|
154
|
+
(setq index (1+ index)))
|
|
155
|
+
(let
|
|
156
|
+
(
|
|
157
|
+
(result
|
|
158
|
+
(Collection/assoc
|
|
159
|
+
(if (nullish? current) EMPTY_MAP current)
|
|
160
|
+
(Collection/nth keys (1- size))
|
|
161
|
+
value)))
|
|
162
|
+
(setq index (- size 2))
|
|
163
|
+
(while (>= index 0)
|
|
164
|
+
(setq
|
|
165
|
+
current
|
|
166
|
+
(js-nth index parents)
|
|
167
|
+
result
|
|
168
|
+
(Collection/assoc
|
|
169
|
+
(if (nullish? current) EMPTY_MAP current)
|
|
170
|
+
(Collection/nth keys index)
|
|
171
|
+
result)
|
|
172
|
+
index
|
|
173
|
+
(1- index)))
|
|
174
|
+
result)))))
|
|
175
|
+
(defun update
|
|
176
|
+
(collection key transform &rest arguments)
|
|
177
|
+
(require-function transform "update transform")
|
|
178
|
+
(let ((target (if (nullish? collection) EMPTY_MAP collection)))
|
|
179
|
+
(Collection/assoc
|
|
180
|
+
target
|
|
181
|
+
key
|
|
182
|
+
(apply transform (js-cons (Collection/get target key) arguments)))))
|
|
183
|
+
(defun update-in
|
|
184
|
+
(collection path transform &rest arguments)
|
|
185
|
+
(require-function transform "updateIn transform")
|
|
186
|
+
(assoc-in
|
|
187
|
+
collection
|
|
188
|
+
path
|
|
189
|
+
(apply transform (js-cons (get-in collection path) arguments))))
|
|
190
|
+
(defun keys
|
|
191
|
+
(collection)
|
|
192
|
+
(let ((result (transient EMPTY_VECTOR)))
|
|
193
|
+
(Collection/reduceKV
|
|
194
|
+
collection
|
|
195
|
+
(lambda (builder key _value) (conjBang builder key) builder)
|
|
196
|
+
result)
|
|
197
|
+
(persistentBang result)))
|
|
198
|
+
(defun vals
|
|
199
|
+
(collection)
|
|
200
|
+
(let ((result (transient EMPTY_VECTOR)))
|
|
201
|
+
(Collection/reduceKV
|
|
202
|
+
collection
|
|
203
|
+
(lambda (builder _key value) (conjBang builder value) builder)
|
|
204
|
+
result)
|
|
205
|
+
(persistentBang result)))
|
|
206
|
+
(defun update-keys
|
|
207
|
+
(collection transform)
|
|
208
|
+
(require-function transform "updateKeys transform")
|
|
209
|
+
(let ((result (transient EMPTY_MAP)))
|
|
210
|
+
(Collection/reduceKV
|
|
211
|
+
collection
|
|
212
|
+
(lambda
|
|
213
|
+
(builder key value)
|
|
214
|
+
(assocBang builder (funcall transform key) value)
|
|
215
|
+
builder)
|
|
216
|
+
result)
|
|
217
|
+
(persistentBang result)))
|
|
218
|
+
(defun update-vals
|
|
219
|
+
(collection transform)
|
|
220
|
+
(require-function transform "updateVals transform")
|
|
221
|
+
(let ((result (transient EMPTY_MAP)))
|
|
222
|
+
(Collection/reduceKV
|
|
223
|
+
collection
|
|
224
|
+
(lambda
|
|
225
|
+
(builder key value)
|
|
226
|
+
(assocBang builder key (funcall transform value))
|
|
227
|
+
builder)
|
|
228
|
+
result)
|
|
229
|
+
(persistentBang result)))
|
|
230
|
+
(defun select-keys
|
|
231
|
+
(collection keys)
|
|
232
|
+
(let ((result (transient EMPTY_MAP)))
|
|
233
|
+
(Collection/reduce
|
|
234
|
+
keys
|
|
235
|
+
(lambda
|
|
236
|
+
(builder key)
|
|
237
|
+
(when (and (not (nullish? collection)) (Collection/contains collection key))
|
|
238
|
+
(assocBang builder key (Collection/get collection key)))
|
|
239
|
+
builder)
|
|
240
|
+
result)
|
|
241
|
+
(persistentBang result)))
|
|
242
|
+
(defun merge
|
|
243
|
+
(&rest collections)
|
|
244
|
+
(let ((result (transient EMPTY_MAP)) (index 0))
|
|
245
|
+
(while (< index (js-length collections))
|
|
246
|
+
(reduce-entries
|
|
247
|
+
(js-nth index collections)
|
|
248
|
+
(lambda (builder key value) (assocBang builder key value) builder)
|
|
249
|
+
result)
|
|
250
|
+
(setq index (1+ index)))
|
|
251
|
+
(persistentBang result)))
|
|
252
|
+
(defun merge-with
|
|
253
|
+
(combine &rest collections)
|
|
254
|
+
(require-function combine "mergeWith combine function")
|
|
255
|
+
(let ((result EMPTY_MAP) (index 0))
|
|
256
|
+
(while (< index (js-length collections))
|
|
257
|
+
(setq
|
|
258
|
+
result
|
|
259
|
+
(reduce-entries
|
|
260
|
+
(js-nth index collections)
|
|
261
|
+
(lambda
|
|
262
|
+
(current key value)
|
|
263
|
+
(Collection/assoc
|
|
264
|
+
current
|
|
265
|
+
key
|
|
266
|
+
(if (Collection/contains current key)
|
|
267
|
+
(funcall combine (Collection/get current key) value)
|
|
268
|
+
value)))
|
|
269
|
+
result)
|
|
270
|
+
index
|
|
271
|
+
(1+ index)))
|
|
272
|
+
result))
|
|
273
|
+
(defun zipmap
|
|
274
|
+
(keys values)
|
|
275
|
+
(let*
|
|
276
|
+
((key-vector (path-vector keys))
|
|
277
|
+
(value-vector (path-vector values))
|
|
278
|
+
(key-count (Collection/count key-vector))
|
|
279
|
+
(value-count (Collection/count value-vector))
|
|
280
|
+
(size (if (< key-count value-count) key-count value-count))
|
|
281
|
+
(result (transient EMPTY_MAP))
|
|
282
|
+
(index 0))
|
|
283
|
+
(while (< index size)
|
|
284
|
+
(assocBang
|
|
285
|
+
result
|
|
286
|
+
(Collection/nth key-vector index)
|
|
287
|
+
(Collection/nth value-vector index))
|
|
288
|
+
(setq index (1+ index)))
|
|
289
|
+
(persistentBang result)))
|
|
290
|
+
(export
|
|
291
|
+
assoc-in
|
|
292
|
+
count-by
|
|
293
|
+
frequencies
|
|
294
|
+
get-in
|
|
295
|
+
group-by
|
|
296
|
+
index-by
|
|
297
|
+
keys
|
|
298
|
+
merge
|
|
299
|
+
merge-with
|
|
300
|
+
select-keys
|
|
301
|
+
update
|
|
302
|
+
update-in
|
|
303
|
+
update-keys
|
|
304
|
+
update-vals
|
|
305
|
+
vals
|
|
306
|
+
zipmap))
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
(module eliscript.core.object
|
|
2
|
+
(import "../../runtime/core/collection.mjs" :as Collection)
|
|
3
|
+
(import "../../runtime/core/transducer.mjs" :as Transducer)
|
|
4
|
+
(import "../../runtime/core/truth.mjs" isTruthy)
|
|
5
|
+
(import "../../runtime/core/value.mjs" equalValues)
|
|
6
|
+
(import "../../runtime/core/vector.mjs" EMPTY_VECTOR)
|
|
7
|
+
|
|
8
|
+
(defun entry-key (entry)
|
|
9
|
+
(Collection/nth entry 0))
|
|
10
|
+
|
|
11
|
+
(defun entry-value (entry)
|
|
12
|
+
(Collection/nth entry 1))
|
|
13
|
+
|
|
14
|
+
(defun keys (object)
|
|
15
|
+
(Transducer/into
|
|
16
|
+
EMPTY_VECTOR
|
|
17
|
+
(Transducer/mapping entry-key)
|
|
18
|
+
object))
|
|
19
|
+
|
|
20
|
+
(defun has? (object key)
|
|
21
|
+
(Collection/contains object key))
|
|
22
|
+
|
|
23
|
+
(defun assoc (object key value &rest key-values)
|
|
24
|
+
(apply Collection/assoc
|
|
25
|
+
(js-cons object (js-cons key (js-cons value key-values)))))
|
|
26
|
+
|
|
27
|
+
(defun key-in? (key key-list)
|
|
28
|
+
(Collection/reduce
|
|
29
|
+
key-list
|
|
30
|
+
(lambda (matched current)
|
|
31
|
+
(if (equalValues key current)
|
|
32
|
+
(Collection/reduced t)
|
|
33
|
+
matched))
|
|
34
|
+
false))
|
|
35
|
+
|
|
36
|
+
(defun dissoc (object key)
|
|
37
|
+
(if (not (has? object key))
|
|
38
|
+
object
|
|
39
|
+
(Transducer/into
|
|
40
|
+
object
|
|
41
|
+
(Transducer/filtering
|
|
42
|
+
(lambda (entry) (not (equalValues key (entry-key entry)))))
|
|
43
|
+
object)))
|
|
44
|
+
|
|
45
|
+
(defun merge (left right)
|
|
46
|
+
(Collection/reduce
|
|
47
|
+
right
|
|
48
|
+
(lambda (result entry)
|
|
49
|
+
(Collection/assoc result (entry-key entry) (entry-value entry)))
|
|
50
|
+
left))
|
|
51
|
+
|
|
52
|
+
(defun map-values (function object)
|
|
53
|
+
(Transducer/into
|
|
54
|
+
object
|
|
55
|
+
(Transducer/mapping
|
|
56
|
+
(lambda (entry)
|
|
57
|
+
(js-array (entry-key entry) (funcall function (entry-value entry)))))
|
|
58
|
+
object))
|
|
59
|
+
|
|
60
|
+
(defun filter-values (predicate object)
|
|
61
|
+
(Transducer/into
|
|
62
|
+
object
|
|
63
|
+
(Transducer/filtering
|
|
64
|
+
(lambda (entry)
|
|
65
|
+
(isTruthy (funcall predicate (entry-value entry)))))
|
|
66
|
+
object))
|
|
67
|
+
|
|
68
|
+
(defun pick (object wanted-keys)
|
|
69
|
+
(Transducer/into
|
|
70
|
+
object
|
|
71
|
+
(Transducer/composeTransducers
|
|
72
|
+
(Transducer/filtering (lambda (key) (has? object key)))
|
|
73
|
+
(Transducer/mapping
|
|
74
|
+
(lambda (key) (js-array key (Collection/get object key)))))
|
|
75
|
+
wanted-keys))
|
|
76
|
+
|
|
77
|
+
(defun omit (object omitted-keys)
|
|
78
|
+
(Transducer/into
|
|
79
|
+
object
|
|
80
|
+
(Transducer/filtering
|
|
81
|
+
(lambda (entry) (not (key-in? (entry-key entry) omitted-keys))))
|
|
82
|
+
object))
|
|
83
|
+
|
|
84
|
+
(defun update (object key function)
|
|
85
|
+
(Collection/assoc
|
|
86
|
+
object key (funcall function (Collection/get object key))))
|
|
87
|
+
|
|
88
|
+
(export assoc dissoc filter-values has? key-in? keys map-values merge omit
|
|
89
|
+
pick update))
|