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,451 @@
|
|
|
1
|
+
(module eliscript.core.protocol
|
|
2
|
+
(import "../../runtime/core/protocol-error.mjs" ProtocolDispatchError)
|
|
3
|
+
|
|
4
|
+
(defconst protocol-states (new globalThis/WeakMap))
|
|
5
|
+
(defconst protocol-operation-owners (new globalThis/WeakMap))
|
|
6
|
+
(defconst protocol-method-owners (new globalThis/WeakMap))
|
|
7
|
+
(defconst protocol-missing
|
|
8
|
+
(funcall globalThis/Symbol "eliscript.protocol.missing"))
|
|
9
|
+
(defconst protocol-host-categories
|
|
10
|
+
(js-array "null" "undefined" "boolean" "number" "bigint" "string"
|
|
11
|
+
"symbol" "function" "object"))
|
|
12
|
+
(defconst protocol-definition-format "eliscript-protocol-definition")
|
|
13
|
+
(defconst protocol-definition-version 1)
|
|
14
|
+
(defconst protocol-max-operations 1024)
|
|
15
|
+
|
|
16
|
+
;; These capabilities isolate host reflection from dispatch policy. They are
|
|
17
|
+
;; deliberately private and contain no protocol-specific decisions.
|
|
18
|
+
(defconst protocol-symbol
|
|
19
|
+
(lambda (description) (funcall globalThis/Symbol description)))
|
|
20
|
+
(defconst protocol-array? (js* "Array.isArray"))
|
|
21
|
+
(defconst protocol-map (lambda () (new globalThis/Map)))
|
|
22
|
+
(defconst protocol-null-object
|
|
23
|
+
(lambda () (js-call globalThis/Object :create nil)))
|
|
24
|
+
(defconst protocol-own-descriptors
|
|
25
|
+
(js* "Object.getOwnPropertyDescriptors"))
|
|
26
|
+
(defconst protocol-own-keys (js* "Reflect.ownKeys"))
|
|
27
|
+
(defconst protocol-has-own
|
|
28
|
+
(lambda (value key)
|
|
29
|
+
(js-call (aref (aref globalThis/Object "prototype") "hasOwnProperty")
|
|
30
|
+
:call value key)))
|
|
31
|
+
(defconst protocol-property-present
|
|
32
|
+
(lambda (value key)
|
|
33
|
+
(if (or (nil? value) (undefined? value))
|
|
34
|
+
false
|
|
35
|
+
(js-call globalThis/Reflect :has (funcall globalThis/Object value) key))))
|
|
36
|
+
(defconst protocol-property-value
|
|
37
|
+
(lambda (value key) (aref (funcall globalThis/Object value) key)))
|
|
38
|
+
(defconst protocol-host-type (lambda (value) (js* "typeof value")))
|
|
39
|
+
(defconst protocol-exact-prototype
|
|
40
|
+
(lambda (value missing)
|
|
41
|
+
(if (or (and (= (js* "typeof value") "object") (not (nil? value)))
|
|
42
|
+
(= (js* "typeof value") "function"))
|
|
43
|
+
(js-call globalThis/Object :getPrototypeOf value)
|
|
44
|
+
missing)))
|
|
45
|
+
(defconst protocol-object-prototype (js* "Object.prototype"))
|
|
46
|
+
(defconst protocol-get-prototype (js* "Object.getPrototypeOf"))
|
|
47
|
+
(defconst protocol-freeze (js* "Object.freeze"))
|
|
48
|
+
(defconst protocol-define-enumerable
|
|
49
|
+
(lambda (target key value)
|
|
50
|
+
(js-call globalThis/Object :defineProperty target key
|
|
51
|
+
(js-object :value value :enumerable t))
|
|
52
|
+
target))
|
|
53
|
+
(defconst protocol-define-metadata
|
|
54
|
+
(lambda (target protocol operation slot)
|
|
55
|
+
(js-call globalThis/Object :defineProperties target
|
|
56
|
+
(js-object :protocol (js-object :value protocol)
|
|
57
|
+
:operation (js-object :value operation)
|
|
58
|
+
:slot (js-object :value slot)))
|
|
59
|
+
target))
|
|
60
|
+
|
|
61
|
+
(defun protocol-fail (message)
|
|
62
|
+
(throw (new globalThis/TypeError message)))
|
|
63
|
+
|
|
64
|
+
(defun protocol-state (protocol)
|
|
65
|
+
(let ((state (js-call protocol-states :get protocol)))
|
|
66
|
+
(if (undefined? state)
|
|
67
|
+
(protocol-fail "expected an Eliscript protocol")
|
|
68
|
+
state)))
|
|
69
|
+
|
|
70
|
+
(defun normalize-name (value label)
|
|
71
|
+
(if (or (not (= (value-type value) "string"))
|
|
72
|
+
(= (js-length value) 0))
|
|
73
|
+
(protocol-fail (str label " must be a non-empty string"))
|
|
74
|
+
value))
|
|
75
|
+
|
|
76
|
+
(defun normalize-protocol-operations (operations)
|
|
77
|
+
(when (not (funcall protocol-array? operations))
|
|
78
|
+
(protocol-fail "protocol operations must be a non-empty dense array"))
|
|
79
|
+
(let ((length (js-length operations)))
|
|
80
|
+
(when (= length 0)
|
|
81
|
+
(protocol-fail "protocol operations must be a non-empty dense array"))
|
|
82
|
+
(when (> length protocol-max-operations)
|
|
83
|
+
(protocol-fail
|
|
84
|
+
(str "protocol operations exceed " protocol-max-operations)))
|
|
85
|
+
(let* ((descriptors (funcall protocol-own-descriptors operations))
|
|
86
|
+
(keys (funcall protocol-own-keys descriptors))
|
|
87
|
+
(normalized (js-array))
|
|
88
|
+
(index 0))
|
|
89
|
+
;; A dense Array has one own descriptor per item plus "length". This
|
|
90
|
+
;; also rejects Symbol keys and named side-channel properties.
|
|
91
|
+
(when (/= (js-length keys) (1+ length))
|
|
92
|
+
(protocol-fail
|
|
93
|
+
"protocol operations must be a dense array with no extra properties"))
|
|
94
|
+
(while (< index length)
|
|
95
|
+
(let ((descriptor (get descriptors (str index) undefined)))
|
|
96
|
+
(when (or (undefined? descriptor)
|
|
97
|
+
(not (funcall protocol-has-own descriptor "value"))
|
|
98
|
+
(not (get descriptor :enumerable false)))
|
|
99
|
+
(protocol-fail
|
|
100
|
+
"protocol operations must contain enumerable data values"))
|
|
101
|
+
(js-call normalized :push
|
|
102
|
+
(normalize-name (get descriptor :value)
|
|
103
|
+
"protocol operation")))
|
|
104
|
+
(setq index (1+ index)))
|
|
105
|
+
normalized)))
|
|
106
|
+
|
|
107
|
+
(defun protocol-definition-field (descriptors name)
|
|
108
|
+
(let ((descriptor (get descriptors name undefined)))
|
|
109
|
+
(when (or (undefined? descriptor)
|
|
110
|
+
(not (funcall protocol-has-own descriptor "value"))
|
|
111
|
+
(not (get descriptor :enumerable false)))
|
|
112
|
+
(protocol-fail
|
|
113
|
+
(str "protocol definition field " name
|
|
114
|
+
" must be an enumerable data property")))
|
|
115
|
+
(get descriptor :value)))
|
|
116
|
+
|
|
117
|
+
(defun normalize-protocol-definition (definition)
|
|
118
|
+
(when (or (nil? definition)
|
|
119
|
+
(not (= (value-type definition) "object"))
|
|
120
|
+
(funcall protocol-array? definition))
|
|
121
|
+
(protocol-fail "protocol definition must be a plain object"))
|
|
122
|
+
(let ((prototype (funcall protocol-get-prototype definition)))
|
|
123
|
+
(when (and (/= prototype protocol-object-prototype)
|
|
124
|
+
(not (nil? prototype)))
|
|
125
|
+
(protocol-fail "protocol definition must be a plain object")))
|
|
126
|
+
(let* ((descriptors (funcall protocol-own-descriptors definition))
|
|
127
|
+
(keys (funcall protocol-own-keys descriptors)))
|
|
128
|
+
(when (/= (js-length keys) 4)
|
|
129
|
+
(protocol-fail
|
|
130
|
+
"protocol definition must contain exactly format, version, name, and operations"))
|
|
131
|
+
(let ((format (protocol-definition-field descriptors "format"))
|
|
132
|
+
(version (protocol-definition-field descriptors "version"))
|
|
133
|
+
(name (protocol-definition-field descriptors "name"))
|
|
134
|
+
(operations (protocol-definition-field descriptors "operations")))
|
|
135
|
+
(when (/= format protocol-definition-format)
|
|
136
|
+
(protocol-fail (str "unsupported protocol definition format " format)))
|
|
137
|
+
(when (/= version protocol-definition-version)
|
|
138
|
+
(protocol-fail (str "unsupported protocol definition version " version)))
|
|
139
|
+
(js-object :name (normalize-name name "protocol name")
|
|
140
|
+
:operations (normalize-protocol-operations operations)))))
|
|
141
|
+
|
|
142
|
+
(defun operation-record (protocol operation)
|
|
143
|
+
(let* ((state (protocol-state protocol))
|
|
144
|
+
(record (js-call (get state :operations) :get operation)))
|
|
145
|
+
(if (undefined? record)
|
|
146
|
+
(protocol-fail
|
|
147
|
+
(str "protocol " (get protocol :name) " has no operation " operation))
|
|
148
|
+
record)))
|
|
149
|
+
|
|
150
|
+
(defun protocol-host-category (value)
|
|
151
|
+
(if (nil? value) "null" (funcall protocol-host-type value)))
|
|
152
|
+
|
|
153
|
+
(defun known-host-category? (category)
|
|
154
|
+
(let ((index 0)
|
|
155
|
+
(found false))
|
|
156
|
+
(while (and (< index (js-length protocol-host-categories)) (not found))
|
|
157
|
+
(when (= category (js-nth index protocol-host-categories))
|
|
158
|
+
(setq found t))
|
|
159
|
+
(setq index (1+ index)))
|
|
160
|
+
found))
|
|
161
|
+
|
|
162
|
+
(defun normalize-implementations (protocol implementations)
|
|
163
|
+
(when (or (nil? implementations)
|
|
164
|
+
(not (= (value-type implementations) "object")))
|
|
165
|
+
(protocol-fail
|
|
166
|
+
(str "protocol " (get protocol :name)
|
|
167
|
+
" implementations must be an object")))
|
|
168
|
+
(let* ((descriptors (funcall protocol-own-descriptors implementations))
|
|
169
|
+
(keys (funcall protocol-own-keys descriptors))
|
|
170
|
+
(normalized (funcall protocol-null-object))
|
|
171
|
+
(index 0))
|
|
172
|
+
(when (= (js-length keys) 0)
|
|
173
|
+
(protocol-fail
|
|
174
|
+
(str "protocol " (get protocol :name)
|
|
175
|
+
" extension must implement at least one operation")))
|
|
176
|
+
(while (< index (js-length keys))
|
|
177
|
+
(let* ((key (js-nth index keys))
|
|
178
|
+
(descriptor (get descriptors key)))
|
|
179
|
+
(when (not (= (value-type key) "string"))
|
|
180
|
+
(protocol-fail
|
|
181
|
+
(str "protocol " (get protocol :name)
|
|
182
|
+
" implementation names must be strings")))
|
|
183
|
+
(operation-record protocol key)
|
|
184
|
+
(when (or (not (funcall protocol-has-own descriptor "value"))
|
|
185
|
+
(not (= (value-type (get descriptor :value)) "function")))
|
|
186
|
+
(protocol-fail
|
|
187
|
+
(str "protocol " (get protocol :name) "/" key
|
|
188
|
+
" implementation must be a function")))
|
|
189
|
+
(funcall protocol-define-enumerable
|
|
190
|
+
normalized key (get descriptor :value)))
|
|
191
|
+
(setq index (1+ index)))
|
|
192
|
+
(funcall protocol-freeze normalized)))
|
|
193
|
+
|
|
194
|
+
(defun merge-implementations (current incoming)
|
|
195
|
+
(let ((merged (funcall protocol-null-object))
|
|
196
|
+
(copy nil))
|
|
197
|
+
(setq copy
|
|
198
|
+
(lambda (source)
|
|
199
|
+
(unless (nullish? source)
|
|
200
|
+
(let ((keys (object-keys source))
|
|
201
|
+
(index 0))
|
|
202
|
+
(while (< index (js-length keys))
|
|
203
|
+
(let ((key (js-nth index keys)))
|
|
204
|
+
(funcall protocol-define-enumerable
|
|
205
|
+
merged key (get source key)))
|
|
206
|
+
(setq index (1+ index)))))))
|
|
207
|
+
(funcall copy current)
|
|
208
|
+
(funcall copy incoming)
|
|
209
|
+
(funcall protocol-freeze merged)))
|
|
210
|
+
|
|
211
|
+
(defun direct-method (record receiver)
|
|
212
|
+
(if (or (nil? receiver) (undefined? receiver))
|
|
213
|
+
protocol-missing
|
|
214
|
+
(let ((slot (get record :slot)))
|
|
215
|
+
(if (not (funcall protocol-property-present receiver slot))
|
|
216
|
+
protocol-missing
|
|
217
|
+
(let ((method (funcall protocol-property-value receiver slot)))
|
|
218
|
+
(if (= (value-type method) "function") method nil))))))
|
|
219
|
+
|
|
220
|
+
(defun external-method (state record receiver)
|
|
221
|
+
(let* ((prototype
|
|
222
|
+
(funcall protocol-exact-prototype receiver protocol-missing))
|
|
223
|
+
(exact-implementations
|
|
224
|
+
(if (= prototype protocol-missing)
|
|
225
|
+
undefined
|
|
226
|
+
(js-call (get state :types) :get prototype)))
|
|
227
|
+
(exact
|
|
228
|
+
(if (undefined? exact-implementations)
|
|
229
|
+
undefined
|
|
230
|
+
(get exact-implementations (get record :name) undefined))))
|
|
231
|
+
(if (not (undefined? exact))
|
|
232
|
+
exact
|
|
233
|
+
(let* ((category-implementations
|
|
234
|
+
(js-call (get state :categories) :get
|
|
235
|
+
(protocol-host-category receiver)))
|
|
236
|
+
(category
|
|
237
|
+
(if (undefined? category-implementations)
|
|
238
|
+
undefined
|
|
239
|
+
(get category-implementations
|
|
240
|
+
(get record :name) undefined))))
|
|
241
|
+
(if (not (undefined? category))
|
|
242
|
+
category
|
|
243
|
+
(get (get state :defaults)
|
|
244
|
+
(get record :name) protocol-missing))))))
|
|
245
|
+
|
|
246
|
+
(defun dispatch (protocol record receiver arguments)
|
|
247
|
+
(let ((direct (direct-method record receiver)))
|
|
248
|
+
(when (nil? direct)
|
|
249
|
+
(throw
|
|
250
|
+
(new ProtocolDispatchError
|
|
251
|
+
protocol (get record :name) receiver "invalid-direct-slot")))
|
|
252
|
+
(if (/= direct protocol-missing)
|
|
253
|
+
(js-call direct :apply receiver arguments)
|
|
254
|
+
(let ((external
|
|
255
|
+
(external-method (protocol-state protocol) record receiver)))
|
|
256
|
+
(if (= external protocol-missing)
|
|
257
|
+
(throw
|
|
258
|
+
(new ProtocolDispatchError protocol (get record :name) receiver))
|
|
259
|
+
(apply external (js-cons receiver arguments)))))))
|
|
260
|
+
|
|
261
|
+
(defun make-protocol-with-slots (name operations slots)
|
|
262
|
+
(let ((protocol-name (normalize-name name "protocol name"))
|
|
263
|
+
(protocol-operations (normalize-protocol-operations operations)))
|
|
264
|
+
(let ((records (funcall protocol-map))
|
|
265
|
+
(operation-table (funcall protocol-null-object))
|
|
266
|
+
(protocol nil)
|
|
267
|
+
(index 0))
|
|
268
|
+
(while (< index (js-length protocol-operations))
|
|
269
|
+
(let ((operation
|
|
270
|
+
(js-nth index protocol-operations)))
|
|
271
|
+
(when (js-call records :has operation)
|
|
272
|
+
(protocol-fail
|
|
273
|
+
(str "protocol " protocol-name
|
|
274
|
+
" declares duplicate operation " operation)))
|
|
275
|
+
(let* ((slot
|
|
276
|
+
(if (nil? slots)
|
|
277
|
+
(funcall protocol-symbol
|
|
278
|
+
(str "eliscript.protocol." protocol-name "/" operation))
|
|
279
|
+
(get slots index)))
|
|
280
|
+
(method
|
|
281
|
+
(lambda (&rest invocation)
|
|
282
|
+
(when (= (js-length invocation) 0)
|
|
283
|
+
(protocol-fail
|
|
284
|
+
(str "protocol " protocol-name "/" operation
|
|
285
|
+
" requires a dispatch value")))
|
|
286
|
+
(dispatch protocol
|
|
287
|
+
(js-call records :get operation)
|
|
288
|
+
(aref invocation 0)
|
|
289
|
+
(js-call invocation :slice 1))))
|
|
290
|
+
(record
|
|
291
|
+
(js-object :name operation :slot slot :method method)))
|
|
292
|
+
(js-call records :set operation record)
|
|
293
|
+
(funcall protocol-define-enumerable
|
|
294
|
+
operation-table operation method)))
|
|
295
|
+
(setq index (1+ index)))
|
|
296
|
+
|
|
297
|
+
(setq protocol
|
|
298
|
+
(funcall protocol-freeze
|
|
299
|
+
(js-object :name protocol-name
|
|
300
|
+
:operations
|
|
301
|
+
(funcall protocol-freeze operation-table))))
|
|
302
|
+
(js-call protocol-operation-owners :set operation-table protocol)
|
|
303
|
+
(setq index 0)
|
|
304
|
+
(while (< index (js-length protocol-operations))
|
|
305
|
+
(let* ((operation (js-nth index protocol-operations))
|
|
306
|
+
(record (js-call records :get operation))
|
|
307
|
+
(method (get record :method)))
|
|
308
|
+
(funcall protocol-define-metadata
|
|
309
|
+
method protocol operation (get record :slot))
|
|
310
|
+
(js-call protocol-method-owners :set method
|
|
311
|
+
(funcall protocol-freeze
|
|
312
|
+
(js-object :protocol protocol :operation operation)))
|
|
313
|
+
(funcall protocol-freeze method)
|
|
314
|
+
(funcall protocol-freeze record))
|
|
315
|
+
(setq index (1+ index)))
|
|
316
|
+
|
|
317
|
+
(js-call protocol-states :set protocol
|
|
318
|
+
(js-object :operations records
|
|
319
|
+
:types (funcall protocol-map)
|
|
320
|
+
:categories (funcall protocol-map)
|
|
321
|
+
:defaults
|
|
322
|
+
(funcall protocol-freeze
|
|
323
|
+
(funcall protocol-null-object))))
|
|
324
|
+
protocol)))
|
|
325
|
+
|
|
326
|
+
(defun define-protocol (name operations)
|
|
327
|
+
(make-protocol-with-slots name operations nil))
|
|
328
|
+
|
|
329
|
+
(defun protocol-definition (protocol)
|
|
330
|
+
(protocol-state protocol)
|
|
331
|
+
(let ((operations
|
|
332
|
+
(js-call (object-keys (get protocol :operations)) :slice)))
|
|
333
|
+
(funcall protocol-freeze operations)
|
|
334
|
+
(funcall protocol-freeze
|
|
335
|
+
(js-object :format protocol-definition-format
|
|
336
|
+
:version protocol-definition-version
|
|
337
|
+
:name (get protocol :name)
|
|
338
|
+
:operations operations))))
|
|
339
|
+
|
|
340
|
+
(defun define-protocol-from-definition (definition)
|
|
341
|
+
(let ((normalized (normalize-protocol-definition definition)))
|
|
342
|
+
(define-protocol (get normalized :name)
|
|
343
|
+
(get normalized :operations))))
|
|
344
|
+
|
|
345
|
+
;; Bulk materialization reuses already transported Symbols, so observing a
|
|
346
|
+
;; slot before its protocol does not create two identities for one slot.
|
|
347
|
+
(defun materialize-protocol-from-definition (definition slots)
|
|
348
|
+
(let* ((normalized (normalize-protocol-definition definition))
|
|
349
|
+
(operations (get normalized :operations)))
|
|
350
|
+
(unless (and (funcall protocol-array? slots) (= (js-length slots) (js-length operations)))
|
|
351
|
+
(protocol-fail "protocol slots must be a dense array matching its operations"))
|
|
352
|
+
(let* ((descriptors (funcall protocol-own-descriptors slots))
|
|
353
|
+
(keys (funcall protocol-own-keys descriptors))
|
|
354
|
+
(seen (new globalThis/Set)) (symbols (js-array)) (index 0))
|
|
355
|
+
(unless (= (js-length keys) (1+ (js-length slots)))
|
|
356
|
+
(protocol-fail "protocol slots must be a dense array with no extra properties"))
|
|
357
|
+
(while (< index (js-length slots))
|
|
358
|
+
(let* ((descriptor (get descriptors (str index) undefined))
|
|
359
|
+
(value (if (undefined? descriptor) undefined (get descriptor :value))))
|
|
360
|
+
(unless (and (not (undefined? descriptor))
|
|
361
|
+
(funcall protocol-has-own descriptor "value")
|
|
362
|
+
(get descriptor :enumerable false)
|
|
363
|
+
(= (funcall protocol-host-type value) "symbol"))
|
|
364
|
+
(protocol-fail "protocol slots must contain enumerable Symbol data values"))
|
|
365
|
+
(when (js-call seen :has value) (protocol-fail "protocol slots must be distinct Symbols"))
|
|
366
|
+
(js-call seen :add value) (js-call symbols :push value))
|
|
367
|
+
(setq index (1+ index)))
|
|
368
|
+
(make-protocol-with-slots (get normalized :name) operations symbols))))
|
|
369
|
+
|
|
370
|
+
(defun protocol-method (protocol operation)
|
|
371
|
+
(get (operation-record protocol operation) :method))
|
|
372
|
+
|
|
373
|
+
(defun protocol-slot (protocol operation)
|
|
374
|
+
(get (operation-record protocol operation) :slot))
|
|
375
|
+
|
|
376
|
+
(defun extend-protocol-type (protocol constructor implementations)
|
|
377
|
+
(let ((state (protocol-state protocol)))
|
|
378
|
+
(when (not (= (value-type constructor) "function"))
|
|
379
|
+
(protocol-fail
|
|
380
|
+
(str "protocol " (get protocol :name)
|
|
381
|
+
" exact type must be a constructor with a prototype")))
|
|
382
|
+
(let ((prototype (get constructor :prototype nil)))
|
|
383
|
+
(when (or (nil? prototype)
|
|
384
|
+
(not (= (value-type prototype) "object")))
|
|
385
|
+
(protocol-fail
|
|
386
|
+
(str "protocol " (get protocol :name)
|
|
387
|
+
" exact type must be a constructor with a prototype")))
|
|
388
|
+
(let* ((normalized
|
|
389
|
+
(normalize-implementations protocol implementations))
|
|
390
|
+
(current (js-call (get state :types) :get prototype)))
|
|
391
|
+
(js-call (get state :types) :set prototype
|
|
392
|
+
(merge-implementations current normalized)))
|
|
393
|
+
protocol)))
|
|
394
|
+
|
|
395
|
+
(defun extend-protocol-category (protocol category implementations)
|
|
396
|
+
(let ((state (protocol-state protocol)))
|
|
397
|
+
(when (not (known-host-category? category))
|
|
398
|
+
(protocol-fail (str "unknown protocol host category " category)))
|
|
399
|
+
(let* ((normalized
|
|
400
|
+
(normalize-implementations protocol implementations))
|
|
401
|
+
(current (js-call (get state :categories) :get category)))
|
|
402
|
+
(js-call (get state :categories) :set category
|
|
403
|
+
(merge-implementations current normalized)))
|
|
404
|
+
protocol))
|
|
405
|
+
|
|
406
|
+
(defun extend-protocol-default (protocol implementations)
|
|
407
|
+
(let* ((state (protocol-state protocol))
|
|
408
|
+
(normalized (normalize-implementations protocol implementations)))
|
|
409
|
+
(put state :defaults
|
|
410
|
+
(merge-implementations (get state :defaults) normalized))
|
|
411
|
+
protocol))
|
|
412
|
+
|
|
413
|
+
(defun implements-protocol-operation? (protocol operation value)
|
|
414
|
+
(let* ((record (operation-record protocol operation))
|
|
415
|
+
(direct (direct-method record value)))
|
|
416
|
+
(and (not (nil? direct))
|
|
417
|
+
(or (/= direct protocol-missing)
|
|
418
|
+
(/= (external-method (protocol-state protocol) record value)
|
|
419
|
+
protocol-missing)))))
|
|
420
|
+
|
|
421
|
+
(defun implements-protocol? (protocol value)
|
|
422
|
+
(let* ((state (protocol-state protocol))
|
|
423
|
+
(operations (object-keys (get protocol :operations)))
|
|
424
|
+
(index 0)
|
|
425
|
+
(implemented t))
|
|
426
|
+
(while (and (< index (js-length operations)) implemented)
|
|
427
|
+
(let* ((record
|
|
428
|
+
(js-call (get state :operations) :get (js-nth index operations)))
|
|
429
|
+
(direct (direct-method record value)))
|
|
430
|
+
(when (or (nil? direct)
|
|
431
|
+
(and (= direct protocol-missing)
|
|
432
|
+
(= (external-method state record value)
|
|
433
|
+
protocol-missing)))
|
|
434
|
+
(setq implemented false)))
|
|
435
|
+
(setq index (1+ index)))
|
|
436
|
+
implemented))
|
|
437
|
+
|
|
438
|
+
(defun protocol? (value) (js-call protocol-states :has value))
|
|
439
|
+
|
|
440
|
+
(defun read-protocol-operations-owner (value)
|
|
441
|
+
(js-call protocol-operation-owners :get value))
|
|
442
|
+
|
|
443
|
+
(defun read-protocol-method-owner (value)
|
|
444
|
+
(js-call protocol-method-owners :get value))
|
|
445
|
+
|
|
446
|
+
(export protocol? define-protocol define-protocol-from-definition materialize-protocol-from-definition
|
|
447
|
+
read-protocol-operations-owner read-protocol-method-owner
|
|
448
|
+
extend-protocol-category extend-protocol-default
|
|
449
|
+
extend-protocol-type implements-protocol-operation?
|
|
450
|
+
implements-protocol? protocol-definition protocol-host-category
|
|
451
|
+
protocol-method protocol-slot))
|