eliscript 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/bootstrap/README.md +26 -0
- package/bootstrap/backends/README.md +515 -0
- package/bootstrap/backends/async.eli +230 -0
- package/bootstrap/backends/binary.eli +173 -0
- package/bootstrap/backends/capabilities.eli +74 -0
- package/bootstrap/backends/elf.eli +246 -0
- package/bootstrap/backends/managed.eli +5976 -0
- package/bootstrap/backends/memory.eli +100 -0
- package/bootstrap/backends/native.eli +2000 -0
- package/bootstrap/backends/numeric.eli +1362 -0
- package/bootstrap/backends/optimize.eli +79 -0
- package/bootstrap/backends/regexp.eli +2263 -0
- package/bootstrap/backends/sha256.eli +138 -0
- package/bootstrap/backends/wasm.eli +1161 -0
- package/bootstrap/compiler/analyzer.eli +165 -77
- package/bootstrap/compiler/compiler.eli +43 -19
- package/bootstrap/compiler/emitter.eli +780 -170
- package/bootstrap/compiler/expander.eli +136 -45
- package/bootstrap/compiler/formatter.eli +8 -1
- package/bootstrap/compiler/ir.eli +148 -45
- package/bootstrap/compiler/lower.eli +29 -2
- package/bootstrap/compiler/project.eli +51 -21
- package/bootstrap/compiler/reader.eli +128 -36
- package/bootstrap/compiler/source-map.eli +46 -4
- package/bootstrap/compiler/symbol.eli +2 -1
- package/bootstrap/compiler/syntax.eli +47 -12
- package/bootstrap/compiler/transient-analysis.eli +40 -4
- package/bootstrap/host/check-cli-legacy.mjs +163 -0
- package/bootstrap/host/check-cli.mjs +59 -158
- package/bootstrap/host/check-cli.mjs.map +1 -0
- package/bootstrap/host/compiler-session.eli +1579 -0
- package/bootstrap/host/compiler-tools.eli +513 -0
- package/bootstrap/host/eliscript-cli.mjs +53 -33
- package/bootstrap/host/eliscript-cli.mjs.map +1 -0
- package/bootstrap/host/project-cli-legacy.mjs +295 -0
- package/bootstrap/host/project-cli.mjs +74 -289
- package/bootstrap/host/project-cli.mjs.map +1 -0
- package/bootstrap/host/project-legacy.mjs +1080 -0
- package/bootstrap/host/project.mjs +210 -1060
- package/bootstrap/host/project.mjs.map +1 -0
- package/bootstrap/runtime/UNICODE-LICENSE.txt +39 -0
- package/bootstrap/runtime/memory.eli +30379 -0
- package/browser/host.mjs +732 -11
- package/browser/worker.mjs +6 -3
- package/compiler/eliscript-analyzer.el +371 -4
- package/compiler/eliscript-cli.el +84 -1
- package/compiler/eliscript-emitter.el +1189 -256
- package/compiler/eliscript-expander.el +147 -10
- package/compiler/eliscript-ir-emitter.el +725 -208
- package/compiler/eliscript-lower.el +127 -1
- package/compiler/eliscript-portable.el +177 -51
- package/compiler/eliscript-project.el +20 -2
- package/compiler/eliscript-reader.el +141 -57
- package/compiler/eliscript-source-map.el +26 -12
- package/compiler/eliscript-transient-analysis.el +382 -19
- package/dist/backends/async.mjs +561 -0
- package/dist/backends/async.mjs.macro-origins.json +1 -0
- package/dist/backends/async.mjs.map +1 -0
- package/dist/backends/binary.mjs +381 -0
- package/dist/backends/binary.mjs.macro-origins.json +1 -0
- package/dist/backends/binary.mjs.map +1 -0
- package/dist/backends/capabilities.mjs +237 -0
- package/dist/backends/capabilities.mjs.macro-origins.json +1 -0
- package/dist/backends/capabilities.mjs.map +1 -0
- package/dist/backends/elf.mjs +540 -0
- package/dist/backends/elf.mjs.macro-origins.json +1 -0
- package/dist/backends/elf.mjs.map +1 -0
- package/dist/backends/managed.mjs +10616 -0
- package/dist/backends/managed.mjs.macro-origins.json +1 -0
- package/dist/backends/managed.mjs.map +1 -0
- package/dist/backends/memory.mjs +278 -0
- package/dist/backends/memory.mjs.macro-origins.json +1 -0
- package/dist/backends/memory.mjs.map +1 -0
- package/dist/backends/native.mjs +4099 -0
- package/dist/backends/native.mjs.macro-origins.json +1 -0
- package/dist/backends/native.mjs.map +1 -0
- package/dist/backends/numeric.mjs +2458 -0
- package/dist/backends/numeric.mjs.macro-origins.json +1 -0
- package/dist/backends/numeric.mjs.map +1 -0
- package/dist/backends/optimize.mjs +204 -0
- package/dist/backends/optimize.mjs.macro-origins.json +1 -0
- package/dist/backends/optimize.mjs.map +1 -0
- package/dist/backends/regexp.mjs +2033 -0
- package/dist/backends/regexp.mjs.macro-origins.json +1 -0
- package/dist/backends/regexp.mjs.map +1 -0
- package/dist/backends/sha256.mjs +310 -0
- package/dist/backends/sha256.mjs.macro-origins.json +1 -0
- package/dist/backends/sha256.mjs.map +1 -0
- package/dist/backends/wasm.mjs +2258 -0
- package/dist/backends/wasm.mjs.macro-origins.json +1 -0
- package/dist/backends/wasm.mjs.map +1 -0
- package/dist/bootstrap/analyzer.mjs +1908 -776
- package/dist/bootstrap/analyzer.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +450 -142
- package/dist/bootstrap/compiler.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +3083 -909
- package/dist/bootstrap/emitter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +2887 -1233
- package/dist/bootstrap/expander.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/formatter.mjs +582 -218
- package/dist/bootstrap/formatter.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/formatter.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +670 -116
- package/dist/bootstrap/ir.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/lower.mjs +866 -257
- package/dist/bootstrap/lower.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/lower.mjs.map +1 -1
- package/dist/bootstrap/package.json +1 -0
- package/dist/bootstrap/project.mjs +1168 -498
- package/dist/bootstrap/project.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +674 -175
- package/dist/bootstrap/reader.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/runtime/math.mjs +1117 -0
- package/dist/bootstrap/runtime/math.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs +10125 -0
- package/dist/bootstrap/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/bootstrap/runtime/unicode-case.mjs +281 -0
- package/dist/bootstrap/runtime/unicode-case.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +430 -119
- package/dist/bootstrap/source-map.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/symbol.mjs +229 -53
- package/dist/bootstrap/symbol.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/symbol.mjs.map +1 -1
- package/dist/bootstrap/syntax.mjs +205 -7
- package/dist/bootstrap/syntax.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/syntax.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +1185 -489
- package/dist/bootstrap/transient-analysis.mjs.macro-origins.json +1 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +199 -6478
- package/dist/browser/host.mjs +1078 -0
- package/dist/browser/loader.js +1 -0
- package/dist/browser/loader.mjs +231 -0
- package/dist/browser/worker.mjs +63 -0
- package/dist/compiler-artifact.json +1 -0
- package/dist/host/compiler-session.mjs +2980 -0
- package/dist/host/compiler-session.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-session.mjs.map +1 -0
- package/dist/host/compiler-tools.mjs +1084 -0
- package/dist/host/compiler-tools.mjs.macro-origins.json +1 -0
- package/dist/host/compiler-tools.mjs.map +1 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +60 -0
- package/dist/literal-sources/runtime/core/collection.eli +639 -0
- package/dist/literal-sources/runtime/core/data-text.eli +290 -0
- package/dist/literal-sources/runtime/core/data.eli +22 -0
- package/dist/literal-sources/runtime/core/identifier.eli +44 -0
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +131 -0
- package/dist/literal-sources/runtime/core/list.eli +19 -0
- package/dist/literal-sources/runtime/core/map.eli +9 -0
- package/dist/literal-sources/runtime/core/metadata-internals.eli +6 -0
- package/dist/literal-sources/runtime/core/metadata.eli +40 -0
- package/dist/literal-sources/runtime/core/object.eli +8 -0
- package/dist/literal-sources/runtime/core/order.eli +123 -0
- package/dist/literal-sources/runtime/core/persistent-kind.eli +28 -0
- package/dist/literal-sources/runtime/core/protocol-error.eli +32 -0
- package/dist/literal-sources/runtime/core/protocol.eli +28 -0
- package/dist/literal-sources/runtime/core/queue.eli +9 -0
- package/dist/literal-sources/runtime/core/record.eli +191 -0
- package/dist/literal-sources/runtime/core/regex.eli +158 -0
- package/dist/literal-sources/runtime/core/sequence.eli +305 -0
- package/dist/literal-sources/runtime/core/set-algebra.eli +28 -0
- package/dist/literal-sources/runtime/core/set.eli +9 -0
- package/dist/literal-sources/runtime/core/sorted.eli +408 -0
- package/dist/literal-sources/runtime/core/text.eli +14 -0
- package/dist/literal-sources/runtime/core/transducer.eli +268 -0
- package/dist/literal-sources/runtime/core/transient.eli +17 -0
- package/dist/literal-sources/runtime/core/truth.eli +4 -0
- package/dist/literal-sources/runtime/core/type.eli +232 -0
- package/dist/literal-sources/runtime/core/value-internals.eli +13 -0
- package/dist/literal-sources/runtime/core/value.eli +19 -0
- package/dist/literal-sources/runtime/core/vector.eli +25 -0
- package/dist/literal-sources/runtime/literals.eli +23 -0
- package/dist/literal-sources/runtime/testing/value.eli +6 -0
- package/dist/literal-sources/runtime/wire/http-rpc.eli +362 -0
- package/dist/literal-sources/runtime/wire/markdown.eli +275 -0
- package/dist/literal-sources/runtime/wire/schema.eli +193 -0
- package/dist/literal-sources/stdlib/bit.eli +36 -0
- package/dist/literal-sources/stdlib/core/data.eli +306 -0
- package/dist/literal-sources/stdlib/core/object.eli +89 -0
- package/dist/literal-sources/stdlib/core/protocol.eli +451 -0
- package/dist/literal-sources/stdlib/core/set.eli +312 -0
- package/dist/literal-sources/stdlib/core/text.eli +103 -0
- package/dist/literal-sources/stdlib/managed-literal-protocols.eli +494 -0
- package/dist/literal-sources/stdlib/managed-literals.eli +1469 -0
- package/dist/literal-sources/stdlib/managed-queue-state.eli +65 -0
- package/dist/literal-sources/stdlib/managed-sorted-state.eli +233 -0
- package/dist/literal-sources/stdlib/managed-transient-state.eli +348 -0
- package/dist/literal-sources/stdlib/managed-value-state.eli +153 -0
- package/dist/literal-sources/stdlib/managed-vector-view-state.eli +102 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +145 -0
- package/dist/literal-sources/stdlib/persistent-map.eli +724 -0
- package/dist/literal-sources/stdlib/persistent-set.eli +236 -0
- package/dist/literal-sources/stdlib/persistent-vector.eli +359 -0
- package/dist/literal-sources/stdlib/value.eli +325 -0
- package/dist/package.json +10 -0
- package/dist/runtime/math.mjs +1116 -0
- package/dist/runtime/math.mjs.macro-origins.json +1 -0
- package/dist/runtime/math.mjs.map +1 -0
- package/dist/runtime/unicode-case-data.mjs +10124 -0
- package/dist/runtime/unicode-case-data.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case-data.mjs.map +1 -0
- package/dist/runtime/unicode-case.mjs +280 -0
- package/dist/runtime/unicode-case.mjs.macro-origins.json +1 -0
- package/dist/runtime/unicode-case.mjs.map +1 -0
- package/dist/runtime.eli +30379 -0
- package/dist/stage3-release.json +1 -0
- package/editor/README.md +1 -1
- package/editor/eliscript-mode.el +1 -1
- package/editor/eliscript-repl.el +1 -1
- package/package.json +106 -11
- package/platform/http.mjs +20 -0
- package/runtime/array-text.mjs +159 -0
- package/runtime/core/map-internals.mjs +27 -9
- package/runtime/core/object-impl.mjs +26 -17
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/protocol-impl.mjs +682 -255
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/protocol.mjs +4 -0
- package/runtime/core/record.mjs +23 -2
- package/runtime/core/regex.mjs +4 -0
- package/runtime/core/sorted.mjs +53 -0
- package/runtime/core/text-impl.mjs +167 -48
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/type.mjs +75 -3
- package/runtime/core/vector.mjs +6 -0
- package/runtime/math.eli +429 -0
- package/runtime/math.mjs +1116 -0
- package/runtime/math.mjs.map +1 -0
- package/runtime/number-radix.mjs +105 -0
- package/runtime/unicode-case-data.eli +29 -0
- package/runtime/unicode-case-data.mjs +10124 -0
- package/runtime/unicode-case-data.mjs.map +1 -0
- package/runtime/unicode-case.eli +100 -0
- package/runtime/unicode-case.mjs +280 -0
- package/runtime/unicode-case.mjs.map +1 -0
- package/runtime/wire/http-rpc.mjs +168 -0
- package/runtime/wire/markdown.mjs +196 -0
- package/runtime/wire/schema.mjs +109 -0
- package/stdlib/README.md +54 -0
- package/stdlib/core/protocol.eli +81 -17
- package/stdlib/core/seq.eli +1 -1
- package/stdlib/core/zipper.eli +172 -72
- package/stdlib/gepo.eli +12 -0
- package/stdlib/interop/js.eli +56 -15
- package/stdlib/managed-literal-protocols.eli +494 -0
- package/stdlib/managed-literals.eli +1469 -0
- package/stdlib/managed-protocol-error.eli +32 -0
- package/stdlib/managed-queue-state.eli +65 -0
- package/stdlib/managed-runtime-collection-internals.eli +60 -0
- package/stdlib/managed-runtime-collection.eli +639 -0
- package/stdlib/managed-runtime-data-text.eli +290 -0
- package/stdlib/managed-runtime-data.eli +22 -0
- package/stdlib/managed-runtime-identifier.eli +44 -0
- package/stdlib/managed-runtime-lazy-sequence.eli +131 -0
- package/stdlib/managed-runtime-list.eli +19 -0
- package/stdlib/managed-runtime-literals.eli +23 -0
- package/stdlib/managed-runtime-map.eli +9 -0
- package/stdlib/managed-runtime-metadata-internals.eli +6 -0
- package/stdlib/managed-runtime-metadata.eli +40 -0
- package/stdlib/managed-runtime-object.eli +8 -0
- package/stdlib/managed-runtime-order.eli +123 -0
- package/stdlib/managed-runtime-persistent-kind.eli +28 -0
- package/stdlib/managed-runtime-protocol.eli +28 -0
- package/stdlib/managed-runtime-queue.eli +9 -0
- package/stdlib/managed-runtime-record.eli +191 -0
- package/stdlib/managed-runtime-regex.eli +158 -0
- package/stdlib/managed-runtime-sequence.eli +305 -0
- package/stdlib/managed-runtime-set-algebra.eli +28 -0
- package/stdlib/managed-runtime-set.eli +9 -0
- package/stdlib/managed-runtime-sorted.eli +408 -0
- package/stdlib/managed-runtime-text.eli +14 -0
- package/stdlib/managed-runtime-transducer.eli +268 -0
- package/stdlib/managed-runtime-transient.eli +17 -0
- package/stdlib/managed-runtime-truth.eli +4 -0
- package/stdlib/managed-runtime-type.eli +232 -0
- package/stdlib/managed-runtime-value-internals.eli +13 -0
- package/stdlib/managed-runtime-value.eli +19 -0
- package/stdlib/managed-runtime-vector.eli +25 -0
- package/stdlib/managed-sorted-state.eli +233 -0
- package/stdlib/managed-testing-value.eli +6 -0
- package/stdlib/managed-transient-state.eli +348 -0
- package/stdlib/managed-value-state.eli +153 -0
- package/stdlib/managed-vector-view-state.eli +102 -0
- package/stdlib/managed-wire-http-rpc.eli +362 -0
- package/stdlib/managed-wire-markdown.eli +275 -0
- package/stdlib/managed-wire-schema.eli +193 -0
- package/stdlib/mdp.eli +7 -0
- package/stdlib/mds.eli +4 -0
- package/stdlib/persistent-vector.eli +23 -6
- package/tools/acceptance/check-legacy.mjs +687 -0
- package/tools/acceptance/check.eli +431 -0
- package/tools/acceptance/compile-evidence.el +49 -0
- package/tools/acceptance/finalize-legacy.mjs +498 -0
- package/tools/acceptance/finalize.eli +270 -0
- package/tools/backends/benchmark.mjs +175 -0
- package/tools/backends/build.mjs +135 -0
- package/tools/backends/compile.mjs +94 -0
- package/tools/backends/compiler-bootstrap.mjs +1001 -0
- package/tools/backends/compiler-browser.mjs +361 -0
- package/tools/backends/compiler-build.mjs +1628 -0
- package/tools/backends/compiler-cli-legacy.mjs +334 -0
- package/tools/backends/compiler-cli.mjs +29 -0
- package/tools/backends/compiler-corpus-bit.mjs +234 -0
- package/tools/backends/compiler-corpus-cli-adapters-legacy.mjs +362 -0
- package/tools/backends/compiler-corpus-cli-adapters.mjs +247 -0
- package/tools/backends/compiler-corpus-debugging.mjs +221 -0
- package/tools/backends/compiler-corpus-emitter.mjs +324 -0
- package/tools/backends/compiler-corpus-evaluation-adapters.mjs +65 -0
- package/tools/backends/compiler-corpus-execution-legacy.mjs +769 -0
- package/tools/backends/compiler-corpus-execution.mjs +3324 -0
- package/tools/backends/compiler-corpus-fuzz.mjs +229 -0
- package/tools/backends/compiler-corpus-generations.mjs +208 -0
- package/tools/backends/compiler-corpus-host-context-legacy.mjs +114 -0
- package/tools/backends/compiler-corpus-host-context.mjs +550 -0
- package/tools/backends/compiler-corpus-identity-host.mjs +553 -0
- package/tools/backends/compiler-corpus-identity-value-adapters-legacy.mjs +298 -0
- package/tools/backends/compiler-corpus-identity-value-adapters.mjs +69 -0
- package/tools/backends/compiler-corpus-isolated-exports.mjs +21 -0
- package/tools/backends/compiler-corpus-legacy.mjs +1155 -0
- package/tools/backends/compiler-corpus-literal-provider.mjs +282 -0
- package/tools/backends/compiler-corpus-managed-adapters-legacy.mjs +334 -0
- package/tools/backends/compiler-corpus-managed-adapters.mjs +937 -0
- package/tools/backends/compiler-corpus-managed-cases.mjs +179 -0
- package/tools/backends/compiler-corpus-managed-fixtures-legacy.mjs +879 -0
- package/tools/backends/compiler-corpus-managed-fixtures.mjs +1287 -0
- package/tools/backends/compiler-corpus-matchers.mjs +173 -0
- package/tools/backends/compiler-corpus-original-program.mjs +612 -0
- package/tools/backends/compiler-corpus-process.mjs +765 -0
- package/tools/backends/compiler-corpus-program-driver.mjs +306 -0
- package/tools/backends/compiler-corpus-project-adapters-legacy.mjs +497 -0
- package/tools/backends/compiler-corpus-project-adapters.mjs +340 -0
- package/tools/backends/compiler-corpus-project-entry-host.mjs +511 -0
- package/tools/backends/compiler-corpus-project-transport.mjs +151 -0
- package/tools/backends/compiler-corpus-raw-fixture-observer.mjs +1438 -0
- package/tools/backends/compiler-corpus-raw-language-fixtures.mjs +1456 -0
- package/tools/backends/compiler-corpus-raw-math-fixture.mjs +346 -0
- package/tools/backends/compiler-corpus-raw-special-fixtures.mjs +523 -0
- package/tools/backends/compiler-corpus-reference-legacy.mjs +263 -0
- package/tools/backends/compiler-corpus-reference.mjs +241 -0
- package/tools/backends/compiler-corpus-runtime-adapters-legacy.mjs +843 -0
- package/tools/backends/compiler-corpus-runtime-adapters.mjs +663 -0
- package/tools/backends/compiler-corpus-source-archive.mjs +206 -0
- package/tools/backends/compiler-corpus-tools-artifact-adapters.mjs +410 -0
- package/tools/backends/compiler-corpus-tools-cli.mjs +363 -0
- package/tools/backends/compiler-corpus-tools-reference.mjs +264 -0
- package/tools/backends/compiler-corpus.mjs +2054 -0
- package/tools/backends/compiler-debug.mjs +142 -0
- package/tools/backends/compiler-matrix.mjs +1955 -0
- package/tools/backends/compiler-metadata.mjs +203 -0
- package/tools/backends/compiler-package-browser.mjs +120 -0
- package/tools/backends/compiler-package-legacy.mjs +654 -0
- package/tools/backends/compiler-package.mjs +464 -0
- package/tools/backends/compiler-project.mjs +126 -0
- package/tools/backends/compiler-session.mjs +843 -0
- package/tools/backends/compiler-sha256.mjs +152 -0
- package/tools/backends/compiler-unicode-profile-host.mjs +196 -0
- package/tools/backends/compiler-worker.mjs +573 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs +919 -0
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -0
- package/tools/backends/dist/managed-ir-inventory.mjs +488 -0
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -0
- package/tools/backends/dist/record-grid.mjs +1256 -0
- package/tools/backends/dist/record-grid.mjs.map +1 -0
- package/tools/backends/dist/release-cli.mjs +462 -0
- package/tools/backends/dist/release-cli.mjs.map +1 -0
- package/tools/backends/dist/run-artifact.mjs +517 -0
- package/tools/backends/dist/run-artifact.mjs.map +1 -0
- package/tools/backends/eliscript/compiler-corpus-bit.eli +77 -0
- package/tools/backends/eliscript/compiler-corpus-debugging.eli +70 -0
- package/tools/backends/eliscript/compiler-corpus-project-entry-host.eli +256 -0
- package/tools/backends/managed-foreign-binding.mjs +497 -0
- package/tools/backends/managed-host-legacy.mjs +1181 -0
- package/tools/backends/managed-host-lifecycle.mjs +310 -0
- package/tools/backends/managed-host-object-provider.mjs +155 -0
- package/tools/backends/managed-host-object-realm.mjs +797 -0
- package/tools/backends/managed-host-proxy.mjs +71 -0
- package/tools/backends/managed-host-runtime.mjs +5868 -0
- package/tools/backends/managed-host.mjs +716 -0
- package/tools/backends/managed-module-graph-legacy.mjs +308 -0
- package/tools/backends/managed-module-graph.mjs +694 -0
- package/tools/backends/managed-runtime-host-legacy.mjs +195 -0
- package/tools/backends/managed-runtime.mjs +939 -0
- package/tools/backends/managed-source-view-legacy.mjs +332 -0
- package/tools/backends/managed-source-view.mjs +959 -0
- package/tools/backends/memory-runtime.mjs +100 -0
- package/tools/backends/native-benchmark.mjs +88 -0
- package/tools/backends/native-managed-runtime.mjs +677 -0
- package/tools/backends/native-memory.mjs +768 -0
- package/tools/backends/native-node-memory.mjs +142 -0
- package/tools/backends/native-node-runner.mjs +99 -0
- package/tools/backends/native-node-watchdog.mjs +19 -0
- package/tools/backends/native-node-worker.mjs +75 -0
- package/tools/backends/stage3-targets.mjs +493 -0
- package/tools/bootstrap-command.el +13 -0
- package/tools/bootstrap-runtime.el +101 -0
- package/tools/bootstrap-seed.el +55 -0
- package/tools/project/check-cli.eli +31 -0
- package/tools/project/project-cli.eli +42 -0
- package/tools/project/project.eli +122 -0
- package/tools/runtime/unicode-case-profiles.mjs +13 -0
- package/tools/runtime/unicode-case-runtime.el +57 -0
- package/tools/testing/source-debugging-corpus-host.eli +16 -0
- package/tools/testing/source-debugging.eli +139 -0
- package/tools/testing/stdlib-bit-corpus-host.eli +21 -0
- package/tools/testing/stdlib-bit-corpus-host.mjs +118 -0
- package/tools/testing/stdlib-bit.eli +104 -0
- package/tools/testing/stdlib-bit.mjs +255 -0
- package/bin/eliscript-bootstrap +0 -15
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-transducer
|
|
2
|
+
(import "./collection.mjs" conj contains empty isReduced memoizedSequenceView reduce reduced reductionView seq unreduced)
|
|
3
|
+
(import "./protocol.mjs" implementsProtocolOperation)
|
|
4
|
+
(import "./set.mjs" EMPTY_SET)
|
|
5
|
+
(import "./transient.mjs" IEditable conjBang persistentBang transient)
|
|
6
|
+
(import "./truth.mjs" isTruthy)
|
|
7
|
+
(import "./value.mjs" equalValues)
|
|
8
|
+
(import "./vector.mjs" EMPTY_VECTOR)
|
|
9
|
+
(import "../../stdlib/managed-literals.eli" literal-each)
|
|
10
|
+
|
|
11
|
+
(defconst reducing-function-key (funcall globalThis/Symbol "eliscript.transducer.reducing-function"))
|
|
12
|
+
(defconst zero-input-key (funcall globalThis/Symbol "eliscript.transducer.zero-input"))
|
|
13
|
+
(defconst no-previous (funcall globalThis/Symbol "eliscript.transducer.no-previous-value"))
|
|
14
|
+
(defconst no-partition (funcall globalThis/Symbol "eliscript.transducer.no-partition-key"))
|
|
15
|
+
(defconst no-initial (funcall globalThis/Symbol "eliscript.transducer.no-reduction-initial"))
|
|
16
|
+
(defun fail (message) (throw (new globalThis/TypeError message)))
|
|
17
|
+
(defun identity (value) value)
|
|
18
|
+
(defun callable? (value) (= (js* "typeof value") "function"))
|
|
19
|
+
(defun truth (value) (js* "!!value"))
|
|
20
|
+
(defun require-function (value label)
|
|
21
|
+
(unless (callable? value) (fail (str label " must be a function"))) value)
|
|
22
|
+
(defun require-positive (value label)
|
|
23
|
+
(unless (and (Number/isSafeInteger value) (> value 0)) (fail (str label " must be a positive safe integer"))) value)
|
|
24
|
+
(defun as-reducer (value label)
|
|
25
|
+
(require-function value label)
|
|
26
|
+
(if (eq (aref value reducing-function-key) t) value (completing value)))
|
|
27
|
+
(defun make-transducer (transform &optional zero-input)
|
|
28
|
+
(Object/defineProperty transform zero-input-key (js-object :value (if (undefined? zero-input) false zero-input)))
|
|
29
|
+
(Object/freeze transform))
|
|
30
|
+
(defun apply-transducer (transducer reducer)
|
|
31
|
+
(require-function transducer "transducer")
|
|
32
|
+
(as-reducer (funcall transducer reducer) "transducer result"))
|
|
33
|
+
(defun method (implementation name arity)
|
|
34
|
+
(let ((function (funcall
|
|
35
|
+
(js* "(fn, name) => { if (typeof name !== \"string\") throw new TypeError(\"method name must be a string\"); return ({ [name](...args) { return Reflect.apply(fn, undefined, [this, ...args]); } })[name]; }")
|
|
36
|
+
implementation name)))
|
|
37
|
+
(Object/defineProperty function "length" (js-object :value arity :configurable t)) function))
|
|
38
|
+
(defun partition-buffer ()
|
|
39
|
+
(let ((builder (transient EMPTY_VECTOR)) (length 0))
|
|
40
|
+
(Object/freeze (js-object
|
|
41
|
+
:append (method (lambda (self value) (setq builder (conjBang builder value) length (1+ length)) length) "append" 1)
|
|
42
|
+
:flush (method (lambda (self result downstream)
|
|
43
|
+
(if (= length 0) result
|
|
44
|
+
(let ((partition (persistentBang builder)))
|
|
45
|
+
(setq builder (transient EMPTY_VECTOR) length 0) (funcall downstream result partition)))) "flush" 2)))))
|
|
46
|
+
(defconst identity-transducer (make-transducer (lambda (reducer) reducer) false))
|
|
47
|
+
(defun completing (step &rest optional-complete)
|
|
48
|
+
(let ((complete (if (or (= (js-length optional-complete) 0) (undefined? (get optional-complete 0))) identity (get optional-complete 0))))
|
|
49
|
+
(require-function step "reducing step") (require-function complete "reducing completion")
|
|
50
|
+
(let ((function (lambda (&rest arguments)
|
|
51
|
+
(cond ((= (js-length arguments) 1) (funcall complete (get arguments 0)))
|
|
52
|
+
((= (js-length arguments) 2) (funcall step (get arguments 0) (get arguments 1)))
|
|
53
|
+
(t (fail "reducing functions accept one completion argument or two step arguments"))))))
|
|
54
|
+
(Object/defineProperty function "name" (js-object :value "reducingFunction" :configurable t))
|
|
55
|
+
(Object/defineProperty function reducing-function-key (js-object :value t)) (Object/freeze function))))
|
|
56
|
+
(defun mapping (transform)
|
|
57
|
+
(require-function transform "mapping transform")
|
|
58
|
+
(make-transducer (lambda (reducer)
|
|
59
|
+
(let ((downstream (as-reducer reducer "mapping reducing function")))
|
|
60
|
+
(completing (lambda (result input) (funcall downstream result (funcall transform input)))
|
|
61
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
62
|
+
(defun mappingIndexed (transform)
|
|
63
|
+
(require-function transform "mapping-indexed transform")
|
|
64
|
+
(make-transducer (lambda (reducer)
|
|
65
|
+
(let ((downstream (as-reducer reducer "mapping-indexed reducing function")) (index 0))
|
|
66
|
+
(completing (lambda (result input) (let ((current index))
|
|
67
|
+
(setq index (1+ index)) (funcall downstream result (funcall transform current input))))
|
|
68
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
69
|
+
(defun keeping (transform)
|
|
70
|
+
(require-function transform "keeping transform")
|
|
71
|
+
(make-transducer (lambda (reducer)
|
|
72
|
+
(let ((downstream (as-reducer reducer "keeping reducing function")))
|
|
73
|
+
(completing (lambda (result input) (let ((value (funcall transform input)))
|
|
74
|
+
(if (nil? value) result (funcall downstream result value))))
|
|
75
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
76
|
+
(defun keepingIndexed (transform)
|
|
77
|
+
(require-function transform "keeping-indexed transform")
|
|
78
|
+
(make-transducer (lambda (reducer)
|
|
79
|
+
(let ((downstream (as-reducer reducer "keeping-indexed reducing function")) (index 0))
|
|
80
|
+
(completing (lambda (result input) (let ((current index))
|
|
81
|
+
(setq index (1+ index)) (let ((value (funcall transform current input)))
|
|
82
|
+
(if (nil? value) result (funcall downstream result value)))))
|
|
83
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
84
|
+
(defun catting ()
|
|
85
|
+
(make-transducer (lambda (reducer)
|
|
86
|
+
(let ((downstream (as-reducer reducer "catting reducing function")))
|
|
87
|
+
(completing (lambda (result input)
|
|
88
|
+
(let* ((stopped false) (flattened (reduce input (lambda (nested value)
|
|
89
|
+
(let ((stepped (funcall downstream nested value))) (when (isReduced stepped) (setq stopped t)) stepped)) result)))
|
|
90
|
+
(if stopped (reduced flattened) flattened)))
|
|
91
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
92
|
+
(defun mapcatting (transform)
|
|
93
|
+
(require-function transform "mapcatting transform") (composeTransducers (mapping transform) (catting)))
|
|
94
|
+
(defun filtering (predicate)
|
|
95
|
+
(require-function predicate "filtering predicate")
|
|
96
|
+
(make-transducer (lambda (reducer)
|
|
97
|
+
(let ((downstream (as-reducer reducer "filtering reducing function")))
|
|
98
|
+
(completing (lambda (result input) (if (isTruthy (funcall predicate input)) (funcall downstream result input) result))
|
|
99
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
100
|
+
(defun removing (predicate)
|
|
101
|
+
(require-function predicate "removing predicate")
|
|
102
|
+
(make-transducer (lambda (reducer)
|
|
103
|
+
(let ((downstream (as-reducer reducer "removing reducing function")))
|
|
104
|
+
(completing (lambda (result input) (if (isTruthy (funcall predicate input)) result (funcall downstream result input)))
|
|
105
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
106
|
+
(defun taking (limit)
|
|
107
|
+
(unless (and (Number/isSafeInteger limit) (>= limit 0)) (fail "taking limit must be a non-negative safe integer"))
|
|
108
|
+
(make-transducer (lambda (reducer)
|
|
109
|
+
(let ((downstream (as-reducer reducer "taking reducing function")) (remaining limit))
|
|
110
|
+
(completing (lambda (result input)
|
|
111
|
+
(if (= remaining 0) (reduced result)
|
|
112
|
+
(progn (setq remaining (1- remaining)) (let ((stepped (funcall downstream result input)))
|
|
113
|
+
(if (and (= remaining 0) (not (isReduced stepped))) (reduced stepped) stepped)))))
|
|
114
|
+
(lambda (result) (funcall downstream result))))) (= limit 0)))
|
|
115
|
+
(defun dropping (limit)
|
|
116
|
+
(unless (and (Number/isSafeInteger limit) (>= limit 0)) (fail "dropping limit must be a non-negative safe integer"))
|
|
117
|
+
(make-transducer (lambda (reducer)
|
|
118
|
+
(let ((downstream (as-reducer reducer "dropping reducing function")) (remaining limit))
|
|
119
|
+
(completing (lambda (result input) (if (> remaining 0)
|
|
120
|
+
(progn (setq remaining (1- remaining)) result) (funcall downstream result input)))
|
|
121
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
122
|
+
(defun takingWhile (predicate)
|
|
123
|
+
(require-function predicate "taking-while predicate")
|
|
124
|
+
(make-transducer (lambda (reducer)
|
|
125
|
+
(let ((downstream (as-reducer reducer "taking-while reducing function")))
|
|
126
|
+
(completing (lambda (result input) (if (isTruthy (funcall predicate input)) (funcall downstream result input) (reduced result)))
|
|
127
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
128
|
+
(defun droppingWhile (predicate)
|
|
129
|
+
(require-function predicate "dropping-while predicate")
|
|
130
|
+
(make-transducer (lambda (reducer)
|
|
131
|
+
(let ((downstream (as-reducer reducer "dropping-while reducing function")) (dropping t))
|
|
132
|
+
(completing (lambda (result input)
|
|
133
|
+
(if (and dropping (isTruthy (funcall predicate input))) result
|
|
134
|
+
(progn (setq dropping false) (funcall downstream result input))))
|
|
135
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
136
|
+
(defun takingNth (interval)
|
|
137
|
+
(require-positive interval "taking-nth interval")
|
|
138
|
+
(make-transducer (lambda (reducer)
|
|
139
|
+
(let ((downstream (as-reducer reducer "taking-nth reducing function")) (remaining 0))
|
|
140
|
+
(completing (lambda (result input) (if (> remaining 0)
|
|
141
|
+
(progn (setq remaining (1- remaining)) result)
|
|
142
|
+
(progn (setq remaining (1- interval)) (funcall downstream result input))))
|
|
143
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
144
|
+
(defun interposing (separator)
|
|
145
|
+
(make-transducer (lambda (reducer)
|
|
146
|
+
(let ((downstream (as-reducer reducer "interposing reducing function")) (started false))
|
|
147
|
+
(completing (lambda (result input)
|
|
148
|
+
(if (not started) (progn (setq started t) (funcall downstream result input))
|
|
149
|
+
(let ((separated (funcall downstream result separator)))
|
|
150
|
+
(if (isReduced separated) separated (funcall downstream separated input)))))
|
|
151
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
152
|
+
(defun partitioningAll (size)
|
|
153
|
+
(require-positive size "partitioning-all size")
|
|
154
|
+
(make-transducer (lambda (reducer)
|
|
155
|
+
(let ((downstream (as-reducer reducer "partitioning-all reducing function")) (buffer (partition-buffer)))
|
|
156
|
+
(completing (lambda (result input)
|
|
157
|
+
(if (= (js-call buffer :append input) size) (js-call buffer :flush result downstream) result))
|
|
158
|
+
(lambda (result) (funcall downstream (unreduced (js-call buffer :flush result downstream))))))) false))
|
|
159
|
+
(defun partitioningBy (classifier)
|
|
160
|
+
(require-function classifier "partitioning-by classifier")
|
|
161
|
+
(make-transducer (lambda (reducer)
|
|
162
|
+
(let ((downstream (as-reducer reducer "partitioning-by reducing function")) (buffer (partition-buffer)) (previous no-partition))
|
|
163
|
+
(completing (lambda (result input)
|
|
164
|
+
(let ((key (funcall classifier input)))
|
|
165
|
+
(if (or (eq previous no-partition) (equalValues previous key))
|
|
166
|
+
(progn (setq previous key) (js-call buffer :append input) result)
|
|
167
|
+
(let ((stepped (js-call buffer :flush result downstream)))
|
|
168
|
+
(if (isReduced stepped) stepped (progn (setq previous key) (js-call buffer :append input) stepped))))))
|
|
169
|
+
(lambda (result) (funcall downstream (unreduced (js-call buffer :flush result downstream))))))) false))
|
|
170
|
+
(defun deduping ()
|
|
171
|
+
(make-transducer (lambda (reducer)
|
|
172
|
+
(let ((downstream (as-reducer reducer "deduping reducing function")) (previous no-previous))
|
|
173
|
+
(completing (lambda (result input)
|
|
174
|
+
(if (and (not (eq previous no-previous)) (equalValues previous input)) result
|
|
175
|
+
(progn (setq previous input) (funcall downstream result input))))
|
|
176
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
177
|
+
(defun distincting ()
|
|
178
|
+
(make-transducer (lambda (reducer)
|
|
179
|
+
(let ((downstream (as-reducer reducer "distincting reducing function")) (seen EMPTY_SET))
|
|
180
|
+
(completing (lambda (result input) (if (contains seen input) result
|
|
181
|
+
(progn (setq seen (conj seen input)) (funcall downstream result input))))
|
|
182
|
+
(lambda (result) (funcall downstream result))))) false))
|
|
183
|
+
(defun composeTransducers (&rest transducers)
|
|
184
|
+
(literal-each transducers (lambda (transducer) (require-function transducer "composed transducer")))
|
|
185
|
+
(make-transducer (lambda (reducer)
|
|
186
|
+
(js-call transducers :reduceRight (lambda (downstream transducer) (apply-transducer transducer downstream))
|
|
187
|
+
(as-reducer reducer "composed reducing function")))
|
|
188
|
+
(js-call transducers :some (lambda (transducer) (eq (aref transducer zero-input-key) t)))))
|
|
189
|
+
(defun transduce (&rest arguments)
|
|
190
|
+
(unless (= (js-length arguments) 4) (fail "transduce requires a transducer, reducer, initial value, and collection"))
|
|
191
|
+
(let* ((transducer (get arguments 0))
|
|
192
|
+
(transformed (apply-transducer transducer (as-reducer (get arguments 1) "transduce reducer")))
|
|
193
|
+
(seed (unreduced (get arguments 2)))
|
|
194
|
+
(result (if (eq (aref transducer zero-input-key) t) seed (reduce (get arguments 3) transformed seed))))
|
|
195
|
+
(unreduced (funcall transformed (unreduced result)))))
|
|
196
|
+
(defun eduction (&rest arguments)
|
|
197
|
+
(when (< (js-length arguments) 2) (fail "eduction requires one or more transducers and a collection"))
|
|
198
|
+
(let* ((collection (get arguments (1- (js-length arguments))))
|
|
199
|
+
(transducer (apply composeTransducers (js-call arguments :slice 0 -1))))
|
|
200
|
+
(reductionView (lambda (reducer &rest initial)
|
|
201
|
+
(require-function reducer "eduction reducer")
|
|
202
|
+
(if (> (js-length initial) 0) (transduce transducer (completing reducer) (get initial 0) collection)
|
|
203
|
+
(transduce transducer (completing
|
|
204
|
+
(lambda (result value) (if (eq result no-initial) value (funcall reducer result value)))
|
|
205
|
+
(lambda (result) (when (eq result no-initial) (fail "cannot reduce an empty eduction without an initial value")) result))
|
|
206
|
+
no-initial collection))))))
|
|
207
|
+
(defun transformed-iterator (transducer collection)
|
|
208
|
+
(let ((output (js-array)) (output-index 0) (input nil) (transformed nil)
|
|
209
|
+
(accumulator nil) (initialized false) (complete false))
|
|
210
|
+
(let* ((close-input (lambda ()
|
|
211
|
+
(when (and (not (nil? input)) (callable? (get input :return))) (js-call input :return))
|
|
212
|
+
(setq input nil)))
|
|
213
|
+
(finish (lambda () (unless complete
|
|
214
|
+
(setq complete t) (funcall close-input)
|
|
215
|
+
(setq accumulator (unreduced (funcall transformed (unreduced accumulator)))))))
|
|
216
|
+
(initialize (lambda () (unless initialized
|
|
217
|
+
(setq initialized t transformed (apply-transducer transducer
|
|
218
|
+
(completing (lambda (result value) (js-call output :push value) result))))
|
|
219
|
+
(if (eq (aref transducer zero-input-key) t) (funcall finish)
|
|
220
|
+
(let ((source (seq collection)))
|
|
221
|
+
(if (nil? source) (funcall finish)
|
|
222
|
+
(setq input (js-call source (get globalThis/Symbol :iterator)))))))))
|
|
223
|
+
(pump (lambda ()
|
|
224
|
+
(funcall initialize)
|
|
225
|
+
(while (and (= output-index (js-length output)) (not complete))
|
|
226
|
+
(put output :length 0) (setq output-index 0)
|
|
227
|
+
(let ((next (try (js-call input :next)
|
|
228
|
+
(catch error (funcall close-input) (setq complete t) (throw error)))))
|
|
229
|
+
(if (truth (get next :done)) (funcall finish)
|
|
230
|
+
(let ((stepped (try (funcall transformed accumulator (get next :value))
|
|
231
|
+
(catch error (funcall close-input) (setq complete t) (throw error)))))
|
|
232
|
+
(if (isReduced stepped)
|
|
233
|
+
(progn (setq accumulator (unreduced stepped)) (funcall finish))
|
|
234
|
+
(setq accumulator stepped)))))))))
|
|
235
|
+
(let ((iterator (js-object
|
|
236
|
+
:next (method (lambda (self) (funcall pump)
|
|
237
|
+
(if (= output-index (js-length output)) (js-object :value undefined :done t)
|
|
238
|
+
(let ((value (get output output-index))) (setq output-index (1+ output-index))
|
|
239
|
+
(js-object :value value :done false)))) "next" 0)
|
|
240
|
+
:return (method (lambda (self value)
|
|
241
|
+
(put output :length 0) (setq output-index 0 complete t) (funcall close-input)
|
|
242
|
+
(js-object :value value :done t)) "return" 1))))
|
|
243
|
+
(put iterator (get globalThis/Symbol :iterator) (method (lambda (self) self) "[Symbol.iterator]" 0)) iterator))))
|
|
244
|
+
(defun sequence (&rest arguments)
|
|
245
|
+
(unless (= (js-length arguments) 2) (fail "sequence requires a transducer and collection"))
|
|
246
|
+
(let ((transducer (get arguments 0)) (collection (get arguments 1)))
|
|
247
|
+
(require-function transducer "sequence transducer")
|
|
248
|
+
(memoizedSequenceView (lambda () (transformed-iterator transducer collection)))))
|
|
249
|
+
(defun runBang (&rest arguments)
|
|
250
|
+
(unless (= (js-length arguments) 2) (fail "run! requires a procedure and collection"))
|
|
251
|
+
(let ((procedure (get arguments 0)))
|
|
252
|
+
(require-function procedure "run! procedure")
|
|
253
|
+
(reduce (get arguments 1) (lambda (result value) (funcall procedure value) nil) nil)) nil)
|
|
254
|
+
(defun into (target &rest arguments)
|
|
255
|
+
(unless (or (= (js-length arguments) 1) (= (js-length arguments) 2))
|
|
256
|
+
(fail "into requires a target and source, or a target, transducer, and source"))
|
|
257
|
+
(let* ((transducer (if (= (js-length arguments) 1) identity-transducer (get arguments 0)))
|
|
258
|
+
(source (get arguments (1- (js-length arguments)))) (seed (empty target)))
|
|
259
|
+
(if (implementsProtocolOperation IEditable "transient" seed)
|
|
260
|
+
(transduce transducer (completing (lambda (result value) (conjBang result value))
|
|
261
|
+
(lambda (result) (persistentBang result))) (transient seed) source)
|
|
262
|
+
(transduce transducer (lambda (result value) (conj result value)) seed source))))
|
|
263
|
+
(Object/defineProperty transduce "length" (js-object :value 4 :configurable t))
|
|
264
|
+
(Object/defineProperty sequence "length" (js-object :value 2 :configurable t))
|
|
265
|
+
(Object/defineProperty runBang "length" (js-object :value 2 :configurable t))
|
|
266
|
+
(export completing mapping mappingIndexed keeping keepingIndexed catting mapcatting filtering removing taking dropping
|
|
267
|
+
takingWhile droppingWhile takingNth interposing partitioningAll partitioningBy deduping distincting composeTransducers
|
|
268
|
+
transduce eduction sequence runBang into))
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-transient
|
|
2
|
+
(import "../../stdlib/managed-literal-protocols.eli"
|
|
3
|
+
I_EDITABLE I_TRANSIENT_COLLECTION managed-literal-transient managed-literal-conj-bang
|
|
4
|
+
managed-literal-assoc-bang managed-literal-dissoc-bang managed-literal-persistent-bang)
|
|
5
|
+
|
|
6
|
+
(defconst IEditable I_EDITABLE)
|
|
7
|
+
(defconst ITransientCollection I_TRANSIENT_COLLECTION)
|
|
8
|
+
(defun transient (collection) (managed-literal-transient collection))
|
|
9
|
+
(defun conjBang (collection &rest values)
|
|
10
|
+
(apply managed-literal-conj-bang (js-call (js-array collection) :concat values)))
|
|
11
|
+
(defun assocBang (&rest arguments) (apply managed-literal-assoc-bang arguments))
|
|
12
|
+
(Object/defineProperty assocBang "length" (js-object :value 3 :configurable t))
|
|
13
|
+
(defun dissocBang (collection &rest keys)
|
|
14
|
+
(apply managed-literal-dissoc-bang (js-call (js-array collection) :concat keys)))
|
|
15
|
+
(defun persistentBang (collection) (managed-literal-persistent-bang collection))
|
|
16
|
+
|
|
17
|
+
(export IEditable ITransientCollection transient conjBang assocBang dissocBang persistentBang))
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-type
|
|
2
|
+
(import "../../stdlib/managed-literals.eli" literal-register-transport literal-each)
|
|
3
|
+
|
|
4
|
+
(defconst type-constructor-token (funcall globalThis/Symbol "eliscript.type.constructor-token"))
|
|
5
|
+
(defconst type-value-states (new globalThis/WeakMap))
|
|
6
|
+
(defconst type-states (new globalThis/WeakMap))
|
|
7
|
+
(defconst reified-states (new globalThis/WeakMap))
|
|
8
|
+
(defun fail (message) (throw (new globalThis/TypeError message)))
|
|
9
|
+
(defun truth (value) (js* "!!value"))
|
|
10
|
+
(defun callable? (value) (= (js* "typeof value") "function"))
|
|
11
|
+
(defun method (implementation name arity)
|
|
12
|
+
(let ((result (funcall
|
|
13
|
+
(js* "(fn, name) => { if (typeof name !== \"string\") throw new TypeError(\"method name must be a string\"); return ({ [name](...args) { return Reflect.apply(fn, undefined, [this, ...args]); } })[name]; }")
|
|
14
|
+
implementation name)))
|
|
15
|
+
(Object/defineProperty result "length" (js-object :value arity :configurable t)) result))
|
|
16
|
+
(defun dense-array (value label maximum)
|
|
17
|
+
(unless (and (Array/isArray value) (<= (js-length value) maximum))
|
|
18
|
+
(fail (str label " must be a dense array of at most " maximum " values")))
|
|
19
|
+
(let ((descriptors (Object/getOwnPropertyDescriptors value)) (index 0))
|
|
20
|
+
(unless (= (js-length (Reflect/ownKeys descriptors)) (1+ (js-length value)))
|
|
21
|
+
(fail (str label " must be a dense array with no extra properties")))
|
|
22
|
+
(while (< index (js-length value))
|
|
23
|
+
(let ((descriptor (get descriptors (funcall globalThis/String index))))
|
|
24
|
+
(unless (and (not (nullish? descriptor)) (truth (get descriptor :enumerable))
|
|
25
|
+
(Reflect/has descriptor "value"))
|
|
26
|
+
(fail (str label " must contain enumerable data values"))))
|
|
27
|
+
(setq index (1+ index)))) value)
|
|
28
|
+
(defun normalize-name (name)
|
|
29
|
+
(unless (and (= (js* "typeof name") "string") (> (js-length name) 0))
|
|
30
|
+
(fail "type name must be a non-empty string")) name)
|
|
31
|
+
(defun normalize-fields (fields)
|
|
32
|
+
(dense-array fields "type fields" 1024)
|
|
33
|
+
(let ((seen (new globalThis/Set)))
|
|
34
|
+
(Object/freeze (js-call fields :map (lambda (field)
|
|
35
|
+
(unless (and (= (js* "typeof field") "string") (> (js-length field) 0)
|
|
36
|
+
(not (js-call field :includes "/")))
|
|
37
|
+
(fail "type field names must be non-empty unqualified strings"))
|
|
38
|
+
(when (js-call seen :has field) (fail (str "type declares duplicate field " field)))
|
|
39
|
+
(js-call seen :add field) field)))))
|
|
40
|
+
(defun protocol-shape (protocol)
|
|
41
|
+
(unless (and (not (nil? protocol)) (= (js* "typeof protocol") "object"))
|
|
42
|
+
(fail "expected an Eliscript protocol"))
|
|
43
|
+
(let* ((descriptors (Object/getOwnPropertyDescriptors protocol)) (keys (Reflect/ownKeys descriptors))
|
|
44
|
+
(name-descriptor (get descriptors :name)) (operations-descriptor (get descriptors :operations)))
|
|
45
|
+
(unless (and (= (js-length keys) 2) (not (nullish? name-descriptor))
|
|
46
|
+
(truth (get name-descriptor :enumerable)) (Reflect/has name-descriptor "value")
|
|
47
|
+
(= (value-type (get name-descriptor :value)) "string") (> (js-length (get name-descriptor :value)) 0)
|
|
48
|
+
(not (nullish? operations-descriptor)) (truth (get operations-descriptor :enumerable))
|
|
49
|
+
(Reflect/has operations-descriptor "value") (Object/isFrozen protocol))
|
|
50
|
+
(fail "expected an Eliscript protocol"))
|
|
51
|
+
(let ((operations (get operations-descriptor :value)))
|
|
52
|
+
(unless (and (not (nil? operations)) (= (js* "typeof operations") "object")
|
|
53
|
+
(not (Array/isArray operations)) (Object/isFrozen operations))
|
|
54
|
+
(fail "expected an Eliscript protocol"))
|
|
55
|
+
(let* ((operation-descriptors (Object/getOwnPropertyDescriptors operations))
|
|
56
|
+
(operation-names (Reflect/ownKeys operation-descriptors)))
|
|
57
|
+
(when (or (= (js-length operation-names) 0) (> (js-length operation-names) 1024)
|
|
58
|
+
(js-call operation-names :some (lambda (operation) (not (= (js* "typeof operation") "string")))))
|
|
59
|
+
(fail "expected an Eliscript protocol"))
|
|
60
|
+
(let ((methods (js-call operation-names :map (lambda (operation)
|
|
61
|
+
(let* ((descriptor (get operation-descriptors operation))
|
|
62
|
+
(operation-method (if (nullish? descriptor) undefined (get descriptor :value)))
|
|
63
|
+
(method-descriptors (if (callable? operation-method)
|
|
64
|
+
(Object/getOwnPropertyDescriptors operation-method) (js-object)))
|
|
65
|
+
(protocol-descriptor (get method-descriptors :protocol))
|
|
66
|
+
(operation-descriptor (get method-descriptors :operation))
|
|
67
|
+
(slot-descriptor (get method-descriptors :slot))
|
|
68
|
+
(slot (if (nullish? slot-descriptor) undefined (get slot-descriptor :value))))
|
|
69
|
+
(unless (and (not (nullish? descriptor)) (truth (get descriptor :enumerable))
|
|
70
|
+
(Reflect/has descriptor "value")
|
|
71
|
+
(not (nullish? protocol-descriptor)) (eq (get protocol-descriptor :value) protocol)
|
|
72
|
+
(not (nullish? operation-descriptor)) (eq (get operation-descriptor :value) operation)
|
|
73
|
+
(not (nullish? slot-descriptor)) (= (js* "typeof slot") "symbol")
|
|
74
|
+
(Object/isFrozen operation-method))
|
|
75
|
+
(fail "expected an Eliscript protocol"))
|
|
76
|
+
(Object/freeze (js-object :operation operation :slot slot)))))))
|
|
77
|
+
(Object/freeze (js-object :name (get name-descriptor :value) :operations (Object/freeze methods))))))))
|
|
78
|
+
(defun normalize-methods (protocol implementations)
|
|
79
|
+
(let ((definition (protocol-shape protocol)))
|
|
80
|
+
(unless (and (not (nil? implementations)) (= (js* "typeof implementations") "object")
|
|
81
|
+
(not (Array/isArray implementations)))
|
|
82
|
+
(fail (str "protocol " (get definition :name) " implementations must be a plain object")))
|
|
83
|
+
(let ((prototype (Object/getPrototypeOf implementations)))
|
|
84
|
+
(unless (or (eq prototype (get globalThis/Object :prototype)) (nil? prototype))
|
|
85
|
+
(fail (str "protocol " (get definition :name) " implementations must be a plain object"))))
|
|
86
|
+
(let* ((descriptors (Object/getOwnPropertyDescriptors implementations)) (keys (Reflect/ownKeys descriptors))
|
|
87
|
+
(operations (get definition :operations)))
|
|
88
|
+
(unless (= (js-length keys) (js-length operations))
|
|
89
|
+
(fail (str "protocol " (get definition :name) " implementation must define every operation")))
|
|
90
|
+
(let ((names (js-call operations :map (lambda (operation) (get operation :operation)))))
|
|
91
|
+
(when (js-call keys :some (lambda (key)
|
|
92
|
+
(or (not (= (js* "typeof key") "string")) (not (js-call names :includes key)))))
|
|
93
|
+
(fail (str "protocol " (get definition :name) " implementation contains an unknown operation"))))
|
|
94
|
+
(let ((normalized (js-array)))
|
|
95
|
+
(literal-each operations (lambda (entry)
|
|
96
|
+
(let* ((operation (get entry :operation)) (slot (get entry :slot))
|
|
97
|
+
(descriptor (get descriptors operation)))
|
|
98
|
+
(unless (and (not (nullish? descriptor)) (truth (get descriptor :enumerable))
|
|
99
|
+
(Reflect/has descriptor "value") (callable? (get descriptor :value)))
|
|
100
|
+
(fail (str "protocol " (get definition :name) "/" operation " implementation must be a function")))
|
|
101
|
+
(js-call normalized :push (Object/freeze (js-object :operation operation :slot slot :implementation (get descriptor :value)))))))
|
|
102
|
+
(Object/freeze (js-object :protocol protocol :name (get definition :name) :methods normalized))))))
|
|
103
|
+
(defun normalize-plans (plans allow-empty)
|
|
104
|
+
(dense-array plans "protocol implementations" 1024)
|
|
105
|
+
(when (and (not allow-empty) (= (js-length plans) 0))
|
|
106
|
+
(fail "reify requires at least one protocol implementation"))
|
|
107
|
+
(let ((seen (new globalThis/Set)))
|
|
108
|
+
(Object/freeze (js-call plans :map (lambda (plan index)
|
|
109
|
+
(dense-array plan (str "protocol implementation " index) 2)
|
|
110
|
+
(unless (= (js-length plan) 2)
|
|
111
|
+
(fail (str "protocol implementation " index " must contain a protocol and methods")))
|
|
112
|
+
(let ((protocol (get plan 0)) (methods (get plan 1)))
|
|
113
|
+
(when (js-call seen :has protocol) (fail "protocol may be implemented only once"))
|
|
114
|
+
(js-call seen :add protocol) (normalize-methods protocol methods)))))))
|
|
115
|
+
(defun plans-snapshot (plans)
|
|
116
|
+
(let ((result (js-array)) (plan-index 0))
|
|
117
|
+
(while (< plan-index (js-length plans))
|
|
118
|
+
(let* ((plan (get plans plan-index)) (implementations (Object/create nil))
|
|
119
|
+
(methods (get plan :methods)) (index 0))
|
|
120
|
+
(while (< index (js-length methods))
|
|
121
|
+
(let ((entry (get methods index)))
|
|
122
|
+
(Object/defineProperty implementations (get entry :operation)
|
|
123
|
+
(js-object :enumerable t :value (get entry :implementation))))
|
|
124
|
+
(setq index (1+ index)))
|
|
125
|
+
(Object/defineProperty result (funcall globalThis/String plan-index)
|
|
126
|
+
(js-object :enumerable t :writable t :configurable t
|
|
127
|
+
:value (Object/freeze (js-array (get plan :protocol) (Object/freeze implementations))))))
|
|
128
|
+
(setq plan-index (1+ plan-index)))
|
|
129
|
+
(Object/freeze result)))
|
|
130
|
+
(defun install-protocol-methods (target plans)
|
|
131
|
+
(literal-each plans (lambda (plan)
|
|
132
|
+
(literal-each (get plan :methods) (lambda (entry)
|
|
133
|
+
(let* ((slot (get entry :slot)) (implementation (get entry :implementation)))
|
|
134
|
+
(when (Reflect/has target slot)
|
|
135
|
+
(fail (str "protocol slot conflict while implementing " (get plan :name))))
|
|
136
|
+
(let ((wrapper (funcall
|
|
137
|
+
(js* "(fn) => function (...args) { return Reflect.apply(fn, undefined, [this, ...args]); }") implementation)))
|
|
138
|
+
(Object/defineProperty wrapper "name" (js-object :value "value" :configurable t))
|
|
139
|
+
(Object/defineProperty target slot (js-object :value wrapper
|
|
140
|
+
:configurable false :enumerable false :writable false)))))))) target)
|
|
141
|
+
(defun define-fields (type field-names)
|
|
142
|
+
(let ((index 0))
|
|
143
|
+
(while (< index (js-length field-names))
|
|
144
|
+
(let ((field (get field-names index)) (position index) (prototype (get type :prototype)))
|
|
145
|
+
(when (Reflect/has prototype field) (fail (str "type field " field " conflicts with a type member")))
|
|
146
|
+
(Object/defineProperty prototype field (js-object :configurable false :enumerable t
|
|
147
|
+
:get (method (lambda (self) (get (get (js-call type-value-states :get self) :values) position)) "get" 0))))
|
|
148
|
+
(setq index (1+ index)))))
|
|
149
|
+
(defun defineType (name fields &rest optional-plans)
|
|
150
|
+
(make-type-definition name fields
|
|
151
|
+
(if (or (= (js-length optional-plans) 0) (undefined? (get optional-plans 0)))
|
|
152
|
+
(js-array) (get optional-plans 0)) false))
|
|
153
|
+
(defun materializeTypeDefinition (name fields &rest optional-plans)
|
|
154
|
+
(make-type-definition name fields
|
|
155
|
+
(if (or (= (js-length optional-plans) 0) (undefined? (get optional-plans 0)))
|
|
156
|
+
(js-array) (get optional-plans 0)) t))
|
|
157
|
+
(defun make-type-definition (name fields protocol-plans retain-fields)
|
|
158
|
+
(let* ((type-name (normalize-name name)) (normalized (normalize-fields fields))
|
|
159
|
+
(field-names (progn
|
|
160
|
+
(when (and retain-fields (not (Object/isFrozen fields))) (fail "transported type fields must be frozen"))
|
|
161
|
+
(if retain-fields fields normalized)))
|
|
162
|
+
(plans (normalize-plans protocol-plans t)) (type nil))
|
|
163
|
+
(setq type (funcall
|
|
164
|
+
(js* "(implementation, name) => { if (typeof name !== \"string\") throw new TypeError(\"class name must be a string\"); return ({ [name]: class { constructor(...args) { return implementation(this, ...args); } } })[name]; }")
|
|
165
|
+
(lambda (self token values)
|
|
166
|
+
(unless (eq token type-constructor-token)
|
|
167
|
+
(fail (str type-name " values must be created with its positional constructor")))
|
|
168
|
+
(js-call type-value-states :set self
|
|
169
|
+
(Object/freeze (js-object :type type :values (Object/freeze values))))
|
|
170
|
+
(Object/freeze self)) "TypeValue"))
|
|
171
|
+
(Object/defineProperty type "length" (js-object :value 2 :configurable t))
|
|
172
|
+
(Object/defineProperty type "create" (js-object :writable t :configurable t
|
|
173
|
+
:value (method (lambda (self &rest values)
|
|
174
|
+
(unless (= (js-length values) (js-length field-names))
|
|
175
|
+
(fail (str "->" type-name " expects " (js-length field-names) " values, received " (js-length values))))
|
|
176
|
+
(new type type-constructor-token values)) "create" 0)))
|
|
177
|
+
(Object/defineProperty type "isInstance" (js-object :writable t :configurable t
|
|
178
|
+
:value (method (lambda (self value)
|
|
179
|
+
(let ((state (js-call type-value-states :get value)))
|
|
180
|
+
(and (not (undefined? state)) (eq (get state :type) type)))) "isInstance" 1)))
|
|
181
|
+
(Object/defineProperty (get type :prototype) (get globalThis/Symbol :toStringTag)
|
|
182
|
+
(js-object :configurable t :get (method (lambda (self) (str "EliscriptType:" type-name)) "get [Symbol.toStringTag]" 0)))
|
|
183
|
+
(Object/defineProperty type "name" (js-object :value type-name))
|
|
184
|
+
(Object/defineProperties type (js-object
|
|
185
|
+
:typeName (js-object :enumerable t :value type-name) :typeFields (js-object :enumerable t :value field-names)))
|
|
186
|
+
(define-fields type field-names)
|
|
187
|
+
(install-protocol-methods (get type :prototype) plans)
|
|
188
|
+
(Object/freeze (get type :prototype)) (Object/freeze type)
|
|
189
|
+
(js-call type-states :set type (Object/freeze (js-object :name type-name :fields field-names :protocolPlans (plans-snapshot plans))))
|
|
190
|
+
type))
|
|
191
|
+
(defun reifyProtocols (protocol-plans)
|
|
192
|
+
(let* ((plans (normalize-plans protocol-plans false))
|
|
193
|
+
(value (Object/freeze (install-protocol-methods (Object/create nil) plans))))
|
|
194
|
+
(js-call reified-states :set value (Object/freeze (js-object :protocolPlans (plans-snapshot plans)))) value))
|
|
195
|
+
(defun isType (value)
|
|
196
|
+
(and (= (js* "typeof value") "function") (js-call type-states :has value)))
|
|
197
|
+
(defun isTypeValue (value)
|
|
198
|
+
(and (not (nil? value)) (= (js* "typeof value") "object") (js-call type-value-states :has value)))
|
|
199
|
+
(defun typeOf (value)
|
|
200
|
+
(let ((state (js-call type-value-states :get value)))
|
|
201
|
+
(when (undefined? state) (fail "expected an Eliscript type value")) (get state :type)))
|
|
202
|
+
(defun typeName (value)
|
|
203
|
+
(let ((type (if (isType value) value (typeOf value)))) (get (js-call type-states :get type) :name)))
|
|
204
|
+
(defun typeFieldNames (value)
|
|
205
|
+
(let ((type (if (isType value) value (typeOf value)))) (get (js-call type-states :get type) :fields)))
|
|
206
|
+
(defun readTypeState (value) (js-call type-states :get value))
|
|
207
|
+
(defun readTypeValueState (value) (js-call type-value-states :get value))
|
|
208
|
+
(defun readReifiedState (value) (js-call reified-states :get value))
|
|
209
|
+
(defun materializeTypeValue (type values)
|
|
210
|
+
(let ((state (readTypeState type)))
|
|
211
|
+
(when (undefined? state) (fail "expected an Eliscript type"))
|
|
212
|
+
(dense-array values "type values" 1024)
|
|
213
|
+
(unless (= (js-length values) (js-length (get state :fields)))
|
|
214
|
+
(fail (str "->" (get state :name) " expects " (js-length (get state :fields))
|
|
215
|
+
" values, received " (js-length values))))
|
|
216
|
+
(unless (Object/isFrozen values) (fail "transported type values must be frozen"))
|
|
217
|
+
(new type type-constructor-token values)))
|
|
218
|
+
(literal-register-transport "type-definition" isType
|
|
219
|
+
(lambda (type) (let ((state (readTypeState type)))
|
|
220
|
+
(js-object :kind "type-definition" :name (get state :name) :fields (get state :fields)
|
|
221
|
+
:protocolPlans (get state :protocolPlans))))
|
|
222
|
+
(lambda (record) (materializeTypeDefinition (get record :name) (get record :fields) (get record :protocolPlans))))
|
|
223
|
+
(literal-register-transport "type-value" isTypeValue
|
|
224
|
+
(lambda (value) (let ((state (readTypeValueState value)))
|
|
225
|
+
(js-object :kind "type-value" :type (get state :type) :values (get state :values))))
|
|
226
|
+
(lambda (record) (materializeTypeValue (get record :type) (get record :values))))
|
|
227
|
+
(literal-register-transport "reified"
|
|
228
|
+
(lambda (value) (js-call reified-states :has value))
|
|
229
|
+
(lambda (value) (js-object :kind "reified" :protocolPlans (get (readReifiedState value) :protocolPlans)))
|
|
230
|
+
(lambda (record) (reifyProtocols (get record :protocolPlans))))
|
|
231
|
+
(export defineType reifyProtocols isType isTypeValue typeOf typeName typeFieldNames
|
|
232
|
+
readTypeState readTypeValueState readReifiedState materializeTypeDefinition materializeTypeValue))
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-value-internals
|
|
2
|
+
(import "../../stdlib/core/protocol.eli" protocol-method)
|
|
3
|
+
(import "../../stdlib/managed-literal-protocols.eli" I_EQUIV I_HASH VALUE_EQUAL VALUE_HASH)
|
|
4
|
+
(import "../../stdlib/managed-value-state.eli"
|
|
5
|
+
avalancheHash mixHash finishHash hashString hashNumber hashBigInt hashBoolean hashNull hashUndefined hashGlobalSymbol
|
|
6
|
+
orderedCollectionHash unorderedCollectionHash cachedProtocolHash recordHashValueCall hostIdentityHash
|
|
7
|
+
resetValueMetrics clearValueCaches readValueMetrics)
|
|
8
|
+
(defconst dispatchValueEqual (protocol-method I_EQUIV "equal"))
|
|
9
|
+
(defconst dispatchValueHash (protocol-method I_HASH "hash"))
|
|
10
|
+
(export I_EQUIV I_HASH VALUE_EQUAL VALUE_HASH dispatchValueEqual dispatchValueHash
|
|
11
|
+
avalancheHash mixHash finishHash hashString hashNumber hashBigInt hashBoolean hashNull hashUndefined hashGlobalSymbol
|
|
12
|
+
orderedCollectionHash unorderedCollectionHash cachedProtocolHash recordHashValueCall hostIdentityHash
|
|
13
|
+
resetValueMetrics clearValueCaches readValueMetrics))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-value
|
|
2
|
+
(import "../../stdlib/core/protocol.eli" extend-protocol-type)
|
|
3
|
+
(import "../../stdlib/managed-literal-protocols.eli"
|
|
4
|
+
I_EQUIV I_HASH managed-literal-equal-values managed-literal-hash-value)
|
|
5
|
+
(import "../../stdlib/managed-literals.eli" literal-protocols)
|
|
6
|
+
(defconst IEquiv I_EQUIV)
|
|
7
|
+
(defconst IHash I_HASH)
|
|
8
|
+
(defun callable? (value) (= (js* "typeof value") "function"))
|
|
9
|
+
(defun extendValueType (constructor implementations)
|
|
10
|
+
(unless (and (not (nil? implementations)) (= (js* "typeof implementations") "object")
|
|
11
|
+
(callable? (aref implementations "equal"))
|
|
12
|
+
(callable? (aref implementations "hash")))
|
|
13
|
+
(throw (new globalThis/TypeError "value type extension requires equal and hash functions")))
|
|
14
|
+
(extend-protocol-type IEquiv constructor (js-object :equal (aref implementations "equal")))
|
|
15
|
+
(extend-protocol-type IHash constructor (js-object :hash (aref implementations "hash")))
|
|
16
|
+
constructor)
|
|
17
|
+
(defun equalValues (left right) (literal-protocols) (managed-literal-equal-values left right))
|
|
18
|
+
(defun hashValue (value) (literal-protocols) (managed-literal-hash-value value))
|
|
19
|
+
(export IEquiv IHash extendValueType equalValues hashValue))
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
(module eliscript.managed-runtime-vector
|
|
2
|
+
(import "../../stdlib/managed-literals.eli"
|
|
3
|
+
PersistentVector literal-vector literal-vector-from-array-values literal-subvec literal-instance? literal-type literal-export-value)
|
|
4
|
+
|
|
5
|
+
(defconst EMPTY_VECTOR (literal-vector))
|
|
6
|
+
(defconst view-states (new globalThis/WeakMap))
|
|
7
|
+
(defconst freeze Object/freeze)
|
|
8
|
+
(defun persistentVector (&rest values)
|
|
9
|
+
(if (= (js-length values) 0) EMPTY_VECTOR
|
|
10
|
+
(progn
|
|
11
|
+
(when (<= (js-length values) 32) (funcall freeze values))
|
|
12
|
+
(literal-vector-from-array-values values))))
|
|
13
|
+
(defun isPersistentVector (value) (literal-instance? value PersistentVector))
|
|
14
|
+
(defun subvec (vector start &optional end) (literal-subvec vector start end))
|
|
15
|
+
(defun readPersistentVectorView (value)
|
|
16
|
+
(if (not (= (literal-type value) 8)) undefined
|
|
17
|
+
(let ((state (js-call view-states :get value)))
|
|
18
|
+
(when (undefined? state)
|
|
19
|
+
(let ((record (literal-export-value value)))
|
|
20
|
+
(setq state (Object/freeze (js-object :vector (get record :source)
|
|
21
|
+
:start (get record :start) :end (get record :end) :metadata (get record :metadata))))
|
|
22
|
+
(js-call view-states :set value state)))
|
|
23
|
+
state)))
|
|
24
|
+
|
|
25
|
+
(export PersistentVector EMPTY_VECTOR persistentVector subvec isPersistentVector readPersistentVectorView))
|