eliscript 0.1.3 → 0.1.4
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/COPYING.RUNTIME +93 -0
- package/README.md +15 -3
- package/bin/eliscript-test +29 -0
- package/bootstrap/backends/README.md +5 -4
- package/bootstrap/backends/binary.eli +89 -22
- package/bootstrap/backends/capabilities.eli +9 -4
- package/bootstrap/backends/managed-layout.eli +93 -81
- package/bootstrap/backends/managed.eli +651 -125
- package/bootstrap/backends/native.eli +1791 -324
- package/bootstrap/backends/numeric.eli +71 -7
- package/bootstrap/backends/sha256.eli +165 -68
- package/bootstrap/backends/wasm.eli +461 -52
- package/bootstrap/compiler/analyzer.eli +692 -2
- package/bootstrap/compiler/compiler.eli +16 -3
- package/bootstrap/compiler/emitter.eli +80 -35
- package/bootstrap/compiler/project.eli +175 -1
- package/bootstrap/compiler/transient-analysis.eli +2 -2
- package/bootstrap/host/build.eli +1 -0
- package/bootstrap/host/build.mjs +1 -1
- package/bootstrap/host/build.mjs.map +1 -1
- package/bootstrap/host/bun.mjs +7 -9
- package/bootstrap/host/bun.mjs.map +1 -1
- package/bootstrap/host/check-cli-ground.eli +47 -5
- package/bootstrap/host/check-cli-ground.mjs +60 -19
- package/bootstrap/host/check-cli-ground.mjs.map +1 -1
- package/bootstrap/host/check-cli.mjs +41 -1
- package/bootstrap/host/check-cli.mjs.map +1 -1
- package/bootstrap/host/compiler-session.eli +136 -22
- package/bootstrap/host/eliscript-cli.mjs +1 -1
- package/bootstrap/host/eliscript-cli.mjs.map +1 -1
- package/bootstrap/host/evaluation-cli.eli +33 -1
- package/bootstrap/host/evaluation-cli.mjs +65 -28
- package/bootstrap/host/evaluation-cli.mjs.map +1 -1
- package/bootstrap/host/evaluation.eli +651 -42
- package/bootstrap/host/evaluation.mjs +884 -72
- package/bootstrap/host/evaluation.mjs.map +1 -1
- package/bootstrap/host/project-cli-ground.eli +6 -1
- package/bootstrap/host/project-cli-ground.mjs +33 -32
- package/bootstrap/host/project-cli-ground.mjs.map +1 -1
- package/bootstrap/host/project-cli.mjs +1 -1
- package/bootstrap/host/project-cli.mjs.map +1 -1
- package/bootstrap/host/project-ground.eli +266 -45
- package/bootstrap/host/project-ground.mjs +429 -159
- package/bootstrap/host/project-ground.mjs.map +1 -1
- package/bootstrap/host/project.mjs +30 -40
- package/bootstrap/host/project.mjs.map +1 -1
- package/bootstrap/host/test-cli.eli +379 -0
- package/bootstrap/host/test-cli.mjs +494 -0
- package/bootstrap/host/test-cli.mjs.map +1 -0
- package/browser/README.md +7 -0
- package/browser/host.mjs +21 -29
- package/browser/host.mjs.map +1 -1
- package/browser/worker.mjs +7 -9
- package/browser/worker.mjs.map +1 -1
- package/compiler/eliscript-analyzer.el +694 -0
- package/compiler/eliscript-cli.el +66 -22
- package/compiler/eliscript-emitter.el +67 -43
- package/compiler/eliscript-ir-emitter.el +71 -36
- package/compiler/eliscript-project.el +360 -80
- package/compiler/eliscript-transient-analysis.el +5 -5
- package/compiler/eliscript.el +6 -0
- package/dist/backends/binary.mjs +148 -26
- package/dist/backends/binary.mjs.map +1 -1
- package/dist/backends/capabilities.mjs +11 -4
- package/dist/backends/capabilities.mjs.map +1 -1
- package/dist/backends/elf.mjs +4 -4
- package/dist/backends/elf.mjs.map +1 -1
- package/dist/backends/managed-layout.mjs +53 -56
- package/dist/backends/managed-layout.mjs.map +1 -1
- package/dist/backends/managed.mjs +1116 -375
- package/dist/backends/managed.mjs.map +1 -1
- package/dist/backends/memory.mjs +24 -26
- package/dist/backends/memory.mjs.map +1 -1
- package/dist/backends/native.mjs +2529 -434
- package/dist/backends/native.mjs.map +1 -1
- package/dist/backends/numeric.mjs +140 -33
- package/dist/backends/numeric.mjs.map +1 -1
- package/dist/backends/optimize.mjs +2 -2
- package/dist/backends/optimize.mjs.map +1 -1
- package/dist/backends/regexp.mjs +33 -35
- package/dist/backends/regexp.mjs.map +1 -1
- package/dist/backends/sha256.mjs +159 -59
- package/dist/backends/sha256.mjs.map +1 -1
- package/dist/backends/wasm.mjs +609 -73
- package/dist/backends/wasm.mjs.map +1 -1
- package/dist/bootstrap/analyzer.mjs +1018 -2
- package/dist/bootstrap/analyzer.mjs.map +1 -1
- package/dist/bootstrap/compiler.mjs +30 -23
- package/dist/bootstrap/compiler.mjs.map +1 -1
- package/dist/bootstrap/emitter.mjs +206 -161
- package/dist/bootstrap/emitter.mjs.macro-origins.json +16 -16
- package/dist/bootstrap/emitter.mjs.map +1 -1
- package/dist/bootstrap/expander.mjs +27 -31
- package/dist/bootstrap/expander.mjs.map +1 -1
- package/dist/bootstrap/ir.mjs +22 -24
- package/dist/bootstrap/ir.mjs.map +1 -1
- package/dist/bootstrap/project.mjs +246 -1
- package/dist/bootstrap/project.mjs.map +1 -1
- package/dist/bootstrap/reader.mjs +2 -2
- package/dist/bootstrap/reader.mjs.map +1 -1
- package/dist/bootstrap/source-map.mjs +34 -48
- package/dist/bootstrap/source-map.mjs.map +1 -1
- package/dist/bootstrap/transient-analysis.mjs +2 -2
- package/dist/bootstrap/transient-analysis.mjs.map +1 -1
- package/dist/browser/compiler.js +106 -106
- package/dist/browser/host.mjs +21 -29
- package/dist/browser/loader.js +1 -1
- package/dist/browser/worker.mjs +95 -95
- package/dist/compiler-artifact.json +1 -1
- package/dist/host/compiler-session.mjs +405 -228
- package/dist/host/compiler-session.mjs.map +1 -1
- package/dist/host/compiler-tools.mjs +44 -46
- package/dist/host/compiler-tools.mjs.map +1 -1
- package/dist/literal-sources/runtime/core/array-map.eli +45 -0
- package/dist/literal-sources/runtime/core/collection-internals.eli +22 -2
- package/dist/literal-sources/runtime/core/collection.eli +282 -23
- package/dist/literal-sources/runtime/core/data-text.eli +196 -13
- package/dist/literal-sources/runtime/core/data.eli +1 -1
- package/dist/literal-sources/runtime/core/identifier.eli +1 -1
- package/dist/literal-sources/runtime/core/lazy-sequence.eli +822 -44
- package/dist/literal-sources/runtime/core/list.eli +1 -1
- package/dist/literal-sources/runtime/core/map.eli +1 -1
- package/dist/literal-sources/runtime/core/metadata-internals.eli +2 -2
- package/dist/literal-sources/runtime/core/metadata.eli +2 -2
- package/dist/literal-sources/{stdlib/core/object.eli → runtime/core/object-impl.eli} +6 -6
- package/dist/literal-sources/runtime/core/object.eli +1 -1
- package/dist/literal-sources/runtime/core/order.eli +3 -3
- package/dist/literal-sources/runtime/core/persistent-kind.eli +1 -1
- package/dist/literal-sources/{stdlib/core/protocol.eli → runtime/core/protocol-impl.eli} +2 -2
- package/dist/literal-sources/runtime/core/protocol.eli +5 -3
- package/dist/literal-sources/runtime/core/queue.eli +1 -1
- package/dist/literal-sources/runtime/core/record.eli +3 -3
- package/dist/literal-sources/runtime/core/regex.eli +2 -2
- package/dist/literal-sources/runtime/core/sequence.eli +1 -1
- package/dist/literal-sources/runtime/core/set-algebra.eli +1 -1
- package/dist/literal-sources/runtime/core/set.eli +1 -1
- package/dist/literal-sources/runtime/core/sorted.eli +4 -4
- package/dist/literal-sources/{stdlib/core/text.eli → runtime/core/text-impl.eli} +2 -2
- package/dist/literal-sources/runtime/core/text.eli +1 -1
- package/dist/literal-sources/runtime/core/transducer.eli +24 -2
- package/dist/literal-sources/runtime/core/transient.eli +7 -5
- package/dist/literal-sources/runtime/core/type.eli +1 -1
- package/dist/literal-sources/runtime/core/value-internals.eli +3 -3
- package/dist/literal-sources/runtime/core/value.eli +2 -2
- package/dist/literal-sources/runtime/core/vector.eli +5 -2
- package/dist/literal-sources/{stdlib → runtime/managed}/managed-literal-protocols.eli +100 -34
- package/dist/literal-sources/{stdlib → runtime/managed}/managed-literals.eli +406 -81
- package/{stdlib → dist/literal-sources/runtime/managed}/managed-queue-state.eli +1 -1
- package/{stdlib → dist/literal-sources/runtime/managed}/managed-sorted-state.eli +1 -1
- package/dist/literal-sources/runtime/managed/managed-transient-state.eli +1206 -0
- package/{stdlib → dist/literal-sources/runtime/managed}/managed-value-state.eli +30 -6
- package/dist/literal-sources/{stdlib → runtime/managed}/managed-vector-view-state.eli +1 -1
- package/dist/literal-sources/runtime/wire/http-rpc.eli +1 -1
- package/dist/literal-sources/runtime/wire/markdown.eli +1 -1
- package/dist/literal-sources/runtime/wire/schema.eli +1 -1
- package/dist/literal-sources/stdlib/bit.eli +89 -1
- package/dist/literal-sources/stdlib/data.eli +522 -0
- package/dist/literal-sources/stdlib/interop/object.eli +39 -0
- package/dist/literal-sources/stdlib/persistent-list.eli +60 -21
- package/dist/literal-sources/stdlib/persistent-map.eli +335 -324
- package/dist/literal-sources/stdlib/persistent-set.eli +8 -6
- package/dist/literal-sources/stdlib/persistent-vector.eli +18 -18
- package/dist/literal-sources/stdlib/protocol.eli +63 -0
- package/{stdlib/core → dist/literal-sources/stdlib}/set.eli +8 -8
- package/dist/literal-sources/stdlib/string.eli +362 -0
- package/dist/runtime/lisp/async-runtime.mjs +55 -59
- package/dist/runtime/lisp/async-runtime.mjs.map +1 -1
- package/dist/runtime/lisp/builtins.mjs +232 -280
- package/dist/runtime/lisp/builtins.mjs.map +1 -1
- package/dist/runtime/lisp/cli.mjs +159 -167
- package/dist/runtime/lisp/cli.mjs.map +1 -1
- package/dist/runtime/lisp/compiler.mjs +359 -419
- package/dist/runtime/lisp/compiler.mjs.map +1 -1
- package/dist/runtime/lisp/core.mjs +24 -24
- package/dist/runtime/lisp/core.mjs.map +1 -1
- package/dist/runtime/lisp/evaluator.mjs +315 -385
- package/dist/runtime/lisp/evaluator.mjs.map +1 -1
- package/dist/runtime/lisp/extensions.mjs +85 -103
- package/dist/runtime/lisp/extensions.mjs.map +1 -1
- package/dist/runtime/lisp/host-io.mjs +106 -122
- package/dist/runtime/lisp/host-io.mjs.map +1 -1
- package/dist/runtime/lisp/io-worker.mjs +117 -135
- package/dist/runtime/lisp/io-worker.mjs.map +1 -1
- package/dist/runtime/lisp/keymap.mjs +5 -5
- package/dist/runtime/lisp/keymap.mjs.map +1 -1
- package/dist/runtime/lisp/macros-forms.mjs +49 -51
- package/dist/runtime/lisp/macros-forms.mjs.map +1 -1
- package/dist/runtime/lisp/reader-format.mjs +31 -31
- package/dist/runtime/lisp/reader-format.mjs.map +1 -1
- package/dist/runtime/lisp/regexp-buffer.mjs +9 -9
- package/dist/runtime/lisp/regexp-buffer.mjs.map +1 -1
- package/dist/runtime/math.mjs +32 -38
- package/dist/runtime/math.mjs.map +1 -1
- package/dist/runtime/number-radix.mjs +5 -7
- package/dist/runtime/number-radix.mjs.map +1 -1
- package/dist/runtime/primitives.mjs +81 -46
- package/dist/runtime/primitives.mjs.macro-origins.json +294 -44
- package/dist/runtime/primitives.mjs.map +1 -1
- package/dist/runtime/unicode-case.mjs +6 -6
- package/dist/runtime/unicode-case.mjs.map +1 -1
- package/dist/runtime.eli +3068 -1882
- package/dist/stage3-release.json +1 -1
- package/dist/stdlib/async.mjs +1838 -0
- package/dist/stdlib/bit.mjs +116 -0
- package/dist/stdlib/collection.mjs +193 -0
- package/dist/stdlib/core.mjs +28 -0
- package/dist/stdlib/data-text.mjs +54 -0
- package/dist/stdlib/data.mjs +601 -0
- package/dist/stdlib/devtools.mjs +565 -0
- package/dist/stdlib/diff.mjs +180 -0
- package/dist/stdlib/fn.mjs +164 -0
- package/dist/stdlib/hierarchy.mjs +189 -0
- package/dist/stdlib/identifier.mjs +33 -0
- package/dist/stdlib/interop/js.mjs +706 -0
- package/dist/stdlib/interop/object.mjs +40 -0
- package/dist/stdlib/json.mjs +843 -0
- package/dist/stdlib/lazy-sequence.mjs +117 -0
- package/dist/stdlib/math.mjs +386 -0
- package/dist/stdlib/meta.mjs +21 -0
- package/dist/stdlib/multimethod.mjs +345 -0
- package/dist/stdlib/numeric.mjs +327 -0
- package/dist/stdlib/order.mjs +194 -0
- package/dist/stdlib/persistent-list.mjs +171 -0
- package/dist/stdlib/persistent-map.mjs +781 -0
- package/dist/stdlib/persistent-queue.mjs +44 -0
- package/dist/stdlib/persistent-set.mjs +225 -0
- package/dist/stdlib/persistent-vector.mjs +316 -0
- package/dist/stdlib/portable/data-text.mjs +1094 -0
- package/dist/stdlib/portable/data.mjs +62 -0
- package/dist/stdlib/portable/identifier.mjs +179 -0
- package/dist/stdlib/portable/metadata.mjs +63 -0
- package/dist/stdlib/portable/object.mjs +140 -0
- package/dist/stdlib/portable/sequence.mjs +142 -0
- package/dist/stdlib/portable/text.mjs +111 -0
- package/dist/stdlib/pprint.mjs +807 -0
- package/dist/stdlib/protocol.mjs +61 -0
- package/dist/stdlib/record.mjs +25 -0
- package/dist/stdlib/regex.mjs +115 -0
- package/dist/stdlib/result.mjs +198 -0
- package/dist/stdlib/schema.mjs +2828 -0
- package/dist/stdlib/seq.mjs +913 -0
- package/dist/stdlib/set.mjs +317 -0
- package/dist/stdlib/sorted.mjs +56 -0
- package/dist/stdlib/state.mjs +451 -0
- package/dist/stdlib/string.mjs +494 -0
- package/dist/stdlib/tap.mjs +187 -0
- package/dist/stdlib/test.mjs +669 -0
- package/dist/stdlib/time.mjs +522 -0
- package/dist/stdlib/transducer.mjs +85 -0
- package/dist/stdlib/transient.mjs +32 -0
- package/dist/stdlib/type.mjs +28 -0
- package/dist/stdlib/uuid.mjs +377 -0
- package/dist/stdlib/value.mjs +334 -0
- package/dist/stdlib/walk.mjs +243 -0
- package/dist/stdlib/wire/gepo.mjs +28 -0
- package/dist/stdlib/wire/mdp.mjs +13 -0
- package/dist/stdlib/wire/mds.mjs +10 -0
- package/dist/stdlib/zipper.mjs +1025 -0
- package/editor/README.md +15 -0
- package/editor/eliscript-data.el +221 -8
- package/editor/eliscript-mode.el +207 -48
- package/editor/eliscript-runtime.el +6 -3
- package/package.json +49 -15
- package/platform/README.md +6 -0
- package/platform/browser.mjs +10 -12
- package/platform/browser.mjs.map +1 -1
- package/runtime/README.md +12 -5
- package/runtime/core/array-map.eli +538 -0
- package/runtime/core/array-map.mjs +651 -0
- package/runtime/core/array-map.mjs.map +1 -0
- package/runtime/core/collection-internals.eli +85 -33
- package/runtime/core/collection-internals.mjs +245 -193
- package/runtime/core/collection-internals.mjs.map +1 -1
- package/runtime/core/collection.eli +105 -3
- package/runtime/core/collection.mjs +190 -53
- package/runtime/core/collection.mjs.map +1 -1
- package/runtime/core/data-text.eli +224 -16
- package/runtime/core/data-text.mjs +345 -83
- package/runtime/core/data-text.mjs.map +1 -1
- package/runtime/core/data.eli +50 -33
- package/runtime/core/data.mjs +72 -36
- package/runtime/core/data.mjs.map +1 -1
- package/runtime/core/identifier.mjs +15 -19
- package/runtime/core/identifier.mjs.map +1 -1
- package/runtime/core/lazy-sequence.eli +885 -15
- package/runtime/core/lazy-sequence.mjs +1265 -38
- package/runtime/core/lazy-sequence.mjs.map +1 -1
- package/runtime/core/map-internals.eli +209 -1
- package/runtime/core/map-internals.mjs +359 -71
- package/runtime/core/map-internals.mjs.map +1 -1
- package/runtime/core/map.eli +75 -7
- package/runtime/core/map.mjs +122 -47
- package/runtime/core/map.mjs.map +1 -1
- package/{stdlib/core/object.eli → runtime/core/object-impl.eli} +6 -6
- package/runtime/core/object-impl.mjs +5 -5
- package/runtime/core/object-impl.mjs.map +1 -1
- package/runtime/core/order.eli +15 -3
- package/runtime/core/order.mjs +23 -8
- package/runtime/core/order.mjs.map +1 -1
- package/runtime/core/persistent-kind.mjs +9 -13
- package/runtime/core/persistent-kind.mjs.map +1 -1
- package/runtime/core/protocol-error.mjs +9 -11
- package/runtime/core/protocol-error.mjs.map +1 -1
- package/{stdlib/core/protocol.eli → runtime/core/protocol-impl.eli} +2 -2
- package/runtime/core/protocol-impl.mjs +10 -10
- package/runtime/core/protocol-impl.mjs.map +1 -1
- package/runtime/core/queue.mjs +14 -16
- package/runtime/core/queue.mjs.map +1 -1
- package/runtime/core/record.eli +2 -2
- package/runtime/core/record.mjs +13 -17
- package/runtime/core/record.mjs.map +1 -1
- package/runtime/core/regex.mjs +18 -22
- package/runtime/core/regex.mjs.map +1 -1
- package/runtime/core/sequence.eli +33 -31
- package/runtime/core/sequence.mjs +60 -93
- package/runtime/core/sequence.mjs.map +1 -1
- package/runtime/core/set.eli +53 -27
- package/runtime/core/set.mjs +113 -82
- package/runtime/core/set.mjs.map +1 -1
- package/runtime/core/sorted.mjs +91 -108
- package/runtime/core/sorted.mjs.map +1 -1
- package/{stdlib/core/text.eli → runtime/core/text-impl.eli} +2 -2
- package/runtime/core/text-impl.mjs +1 -1
- package/runtime/core/text-impl.mjs.map +1 -1
- package/runtime/core/transducer.eli +24 -0
- package/runtime/core/transducer.mjs +27 -1
- package/runtime/core/transducer.mjs.map +1 -1
- package/runtime/core/transient-internals.eli +12 -4
- package/runtime/core/transient-internals.mjs +19 -6
- package/runtime/core/transient-internals.mjs.map +1 -1
- package/runtime/core/transient.eli +31 -0
- package/runtime/core/transient.mjs +33 -2
- package/runtime/core/transient.mjs.map +1 -1
- package/runtime/core/value-internals.mjs +29 -35
- package/runtime/core/value-internals.mjs.map +1 -1
- package/runtime/core/vector.eli +73 -20
- package/runtime/core/vector.mjs +159 -156
- package/runtime/core/vector.mjs.map +1 -1
- package/runtime/literals.eli +16 -9
- package/runtime/literals.mjs +25 -9
- package/runtime/literals.mjs.map +1 -1
- package/{stdlib → runtime/managed}/managed-literal-protocols.eli +100 -34
- package/{stdlib → runtime/managed}/managed-literals.eli +406 -81
- package/{dist/literal-sources/stdlib → runtime/managed}/managed-queue-state.eli +1 -1
- package/runtime/managed/managed-runtime-array-map.eli +45 -0
- package/{stdlib → runtime/managed}/managed-runtime-collection-internals.eli +22 -2
- package/{stdlib → runtime/managed}/managed-runtime-collection.eli +282 -23
- package/{stdlib → runtime/managed}/managed-runtime-data-text.eli +196 -13
- package/{stdlib → runtime/managed}/managed-runtime-data.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-identifier.eli +1 -1
- package/runtime/managed/managed-runtime-lazy-sequence.eli +935 -0
- package/{stdlib → runtime/managed}/managed-runtime-list.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-map.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-metadata-internals.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-metadata.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-object.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-order.eli +3 -3
- package/{stdlib → runtime/managed}/managed-runtime-persistent-kind.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-protocol.eli +5 -3
- package/{stdlib → runtime/managed}/managed-runtime-queue.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-record.eli +3 -3
- package/{stdlib → runtime/managed}/managed-runtime-regex.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-sequence.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-set-algebra.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-set.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-sorted.eli +4 -4
- package/{stdlib → runtime/managed}/managed-runtime-text.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-transducer.eli +24 -2
- package/{stdlib → runtime/managed}/managed-runtime-transient.eli +7 -5
- package/{stdlib → runtime/managed}/managed-runtime-type.eli +1 -1
- package/{stdlib → runtime/managed}/managed-runtime-value-internals.eli +3 -3
- package/{stdlib → runtime/managed}/managed-runtime-value.eli +2 -2
- package/{stdlib → runtime/managed}/managed-runtime-vector.eli +5 -2
- package/{dist/literal-sources/stdlib → runtime/managed}/managed-sorted-state.eli +1 -1
- package/runtime/managed/managed-transient-state.eli +1206 -0
- package/{dist/literal-sources/stdlib → runtime/managed}/managed-value-state.eli +30 -6
- package/{stdlib → runtime/managed}/managed-vector-view-state.eli +1 -1
- package/{stdlib → runtime/managed}/managed-wire-http-rpc.eli +1 -1
- package/{stdlib → runtime/managed}/managed-wire-markdown.eli +1 -1
- package/{stdlib → runtime/managed}/managed-wire-schema.eli +1 -1
- package/runtime/math.mjs +32 -38
- package/runtime/math.mjs.map +1 -1
- package/runtime/number-radix.mjs +5 -7
- package/runtime/number-radix.mjs.map +1 -1
- package/runtime/primitives.eli +19 -6
- package/runtime/primitives.mjs +81 -46
- package/runtime/primitives.mjs.map +1 -1
- package/runtime/source-mapping.mjs +17 -23
- package/runtime/source-mapping.mjs.map +1 -1
- package/runtime/testing/map.eli +70 -41
- package/runtime/testing/map.mjs +57 -34
- package/runtime/testing/map.mjs.map +1 -1
- package/runtime/unicode-case.mjs +6 -6
- package/runtime/unicode-case.mjs.map +1 -1
- package/runtime/wire/http-rpc.mjs +12 -18
- package/runtime/wire/http-rpc.mjs.map +1 -1
- package/runtime/wire/markdown.mjs +42 -42
- package/runtime/wire/markdown.mjs.map +1 -1
- package/runtime/wire/schema.mjs +13 -13
- package/runtime/wire/schema.mjs.map +1 -1
- package/runtime/worker-value-codec.mjs +5 -7
- package/runtime/worker-value-codec.mjs.map +1 -1
- package/runtime/worker-value-stream.mjs +128 -135
- package/runtime/worker-value-stream.mjs.map +1 -1
- package/runtime/worker.mjs +75 -89
- package/runtime/worker.mjs.map +1 -1
- package/stdlib/README.md +25 -18
- package/stdlib/async.eli +1245 -0
- package/stdlib/bit.eli +89 -1
- package/stdlib/bit.mjs +89 -2
- package/stdlib/bit.mjs.map +1 -1
- package/stdlib/{core/collection.eli → collection.eli} +39 -4
- package/stdlib/core.eli +956 -0
- package/stdlib/data-text.eli +62 -1091
- package/stdlib/data.eli +517 -37
- package/stdlib/devtools.eli +399 -0
- package/stdlib/diff.eli +134 -0
- package/stdlib/{function.eli → fn.eli} +1 -1
- package/stdlib/identifier.eli +21 -136
- package/stdlib/interop/object.eli +39 -0
- package/stdlib/{core/lazy-sequence.eli → lazy-sequence.eli} +28 -2
- package/stdlib/math.eli +267 -0
- package/stdlib/{core/metadata.eli → meta.eli} +2 -2
- package/stdlib/{core/order.eli → order.eli} +6 -6
- package/stdlib/persistent-list.eli +60 -21
- package/stdlib/persistent-map.eli +335 -324
- package/stdlib/persistent-set.eli +8 -6
- package/stdlib/persistent-vector.eli +18 -18
- package/stdlib/portable/data-text.eli +1092 -0
- package/stdlib/portable/data.eli +42 -0
- package/stdlib/portable/identifier.eli +147 -0
- package/stdlib/{metadata.eli → portable/metadata.eli} +5 -5
- package/stdlib/{object.eli → portable/object.eli} +1 -1
- package/stdlib/{sequence.eli → portable/sequence.eli} +1 -1
- package/stdlib/{text.eli → portable/text.eli} +1 -1
- package/stdlib/pprint.eli +588 -0
- package/stdlib/protocol.eli +63 -0
- package/stdlib/{core/record.eli → record.eli} +2 -2
- package/stdlib/regex.eli +70 -0
- package/stdlib/result.eli +53 -44
- package/stdlib/schema.eli +1886 -0
- package/stdlib/{core/seq.eli → seq.eli} +97 -90
- package/{dist/literal-sources/stdlib/core → stdlib}/set.eli +8 -8
- package/stdlib/{core/sorted.eli → sorted.eli} +2 -2
- package/stdlib/{state/atom.eli → state.eli} +137 -7
- package/stdlib/string.eli +362 -0
- package/stdlib/tap.eli +135 -0
- package/stdlib/test.eli +566 -0
- package/stdlib/time.eli +419 -0
- package/stdlib/{core/transducer.eli → transducer.eli} +4 -2
- package/stdlib/{core/transient.eli → transient.eli} +11 -5
- package/stdlib/{core/type.eli → type.eli} +2 -2
- package/stdlib/uuid.eli +288 -0
- package/stdlib/{core/walk.eli → walk.eli} +6 -6
- package/stdlib/{gepo.eli → wire/gepo.eli} +2 -2
- package/stdlib/{mdp.eli → wire/mdp.eli} +2 -2
- package/stdlib/{mds.eli → wire/mds.eli} +2 -2
- package/stdlib/{core/zipper.eli → zipper.eli} +179 -138
- package/tests/helpers/wasm-managed-math-node.mjs +495 -582
- package/tools/acceptance/check-ground.mjs +106 -132
- package/tools/acceptance/check.mjs +16 -16
- package/tools/acceptance/retained-performance-snapshot.mjs +265 -149
- package/tools/acceptance/retained-soak.mjs +5 -7
- package/tools/acceptance/retained-transient.mjs +5 -7
- package/tools/backends/build.mjs +373 -95
- package/tools/backends/compiler-bootstrap.mjs +271 -317
- package/tools/backends/compiler-browser.mjs +7 -9
- package/tools/backends/compiler-build.mjs +77 -97
- package/tools/backends/compiler-cli-ground.mjs +47 -47
- package/tools/backends/compiler-data-transport.mjs +27 -31
- package/tools/backends/compiler-host-iteration.mjs +13 -21
- package/tools/backends/compiler-host-record.mjs +28 -34
- package/tools/backends/compiler-metadata.mjs +145 -53
- package/tools/backends/compiler-package-ground.mjs +39 -47
- package/tools/backends/compiler-package-loader.mjs +164 -206
- package/tools/backends/compiler-session.mjs +432 -324
- package/tools/backends/compiler-worker.mjs +79 -89
- package/tools/backends/dist/bootstrap-js-stages.mjs +17 -19
- package/tools/backends/dist/bootstrap-js-stages.mjs.map +1 -1
- package/tools/backends/dist/managed-ir-inventory.mjs +1 -1
- package/tools/backends/dist/managed-ir-inventory.mjs.map +1 -1
- package/tools/backends/dist/release-cli.mjs +151 -22
- package/tools/backends/dist/release-cli.mjs.map +1 -1
- package/tools/backends/dist/run-artifact.mjs +54 -76
- package/tools/backends/dist/run-artifact.mjs.map +1 -1
- package/tools/backends/managed-foreign-binding.mjs +370 -114
- package/tools/backends/managed-host-ground.mjs +14 -17
- package/tools/backends/managed-host-lifecycle.mjs +42 -53
- package/tools/backends/managed-host-object-realm.mjs +121 -111
- package/tools/backends/managed-host-proxy.mjs +5 -7
- package/tools/backends/managed-host-runtime.mjs +6295 -4350
- package/tools/backends/managed-host.mjs +234 -188
- package/tools/backends/managed-layout.mjs +53 -56
- package/tools/backends/managed-module-graph-ground.mjs +488 -568
- package/tools/backends/managed-module-graph.mjs +62 -76
- package/tools/backends/managed-runtime-host-ground.mjs +352 -400
- package/tools/backends/managed-runtime.mjs +227 -266
- package/tools/backends/managed-source-view-ground.mjs +165 -161
- package/tools/backends/managed-source-view.mjs +415 -154
- package/tools/backends/native-managed-runtime.mjs +96 -138
- package/tools/backends/native-memory.mjs +1122 -742
- package/tools/backends/native-node-ffi.mjs +2439 -0
- package/tools/backends/native-node-memory.mjs +793 -383
- package/tools/backends/native-node-runner.mjs +1458 -579
- package/tools/backends/native-node-watchdog.mjs +12 -14
- package/tools/backends/native-node-worker.mjs +46 -50
- package/tools/backends/stage3-targets.mjs +2 -2
- package/tools/bootstrap-runtime.el +4 -4
- package/tools/collections/transient-builder-benchmark.mjs +17 -17
- package/tools/project/check-cli.eli +27 -3
- package/tools/project/project-cli.eli +1 -1
- package/tools/testing/maintained-suite-source.mjs +5 -7
- package/tools/testing/maintained-suite-source.mjs.map +1 -1
- package/dist/literal-sources/stdlib/core/data.eli +0 -306
- package/dist/literal-sources/stdlib/managed-transient-state.eli +0 -353
- package/stdlib/core/data-text.eli +0 -16
- package/stdlib/core/data.eli +0 -306
- package/stdlib/core/identifier.eli +0 -32
- package/stdlib/core/regex.eli +0 -17
- package/stdlib/deferred.eli +0 -70
- package/stdlib/managed-runtime-lazy-sequence.eli +0 -157
- package/stdlib/managed-transient-state.eli +0 -353
- /package/{stdlib → runtime/managed}/managed-protocol-error.eli +0 -0
- /package/{stdlib → runtime/managed}/managed-runtime-literals.eli +0 -0
- /package/{stdlib → runtime/managed}/managed-runtime-truth.eli +0 -0
- /package/{stdlib → runtime/managed}/managed-testing-value.eli +0 -0
|
@@ -1117,6 +1117,700 @@ Return FORMS unchanged for the emitter."
|
|
|
1117
1117
|
(eliscript-portable-validate-module forms filename)
|
|
1118
1118
|
forms))
|
|
1119
1119
|
|
|
1120
|
+
(defconst eliscript-analyzer--lint-rule-codes
|
|
1121
|
+
'("ELI-L0001" "ELI-L0002" "ELI-L0003" "ELI-L0004" "ELI-L0005"
|
|
1122
|
+
"ELI-L0006" "ELI-L0007" "ELI-L0008" "ELI-L0009")
|
|
1123
|
+
"Static lint rule codes emitted by Seed and self-hosted analyzers.")
|
|
1124
|
+
|
|
1125
|
+
(defconst eliscript-analyzer--lint-transient-constructors
|
|
1126
|
+
'(transient as-transient asTransient transient-vector transientVector
|
|
1127
|
+
transient-map transientMap transient-set transientSet)
|
|
1128
|
+
"Constructor names recognized by ELI-L0009.")
|
|
1129
|
+
|
|
1130
|
+
(defconst eliscript-analyzer--lint-transient-updaters
|
|
1131
|
+
'(conj! conjBang assoc! assocBang dissoc! dissocBang disj! disjBang)
|
|
1132
|
+
"Mutator names preserving transient provenance for ELI-L0009.")
|
|
1133
|
+
|
|
1134
|
+
(defconst eliscript-analyzer--lint-transient-finalizers
|
|
1135
|
+
'(persistent! persistentBang)
|
|
1136
|
+
"Finalizer names consuming transient values for ELI-L0009.")
|
|
1137
|
+
|
|
1138
|
+
(cl-defstruct (eliscript-analyzer--lint-binding
|
|
1139
|
+
(:constructor eliscript-analyzer--lint-binding-create))
|
|
1140
|
+
name
|
|
1141
|
+
kind
|
|
1142
|
+
fn-depth
|
|
1143
|
+
span
|
|
1144
|
+
mutable
|
|
1145
|
+
used
|
|
1146
|
+
is-transient
|
|
1147
|
+
transient-finalized
|
|
1148
|
+
transient-escaped
|
|
1149
|
+
transient-escape-span)
|
|
1150
|
+
|
|
1151
|
+
(cl-defstruct (eliscript-analyzer--lint-scope
|
|
1152
|
+
(:constructor eliscript-analyzer--lint-scope-create))
|
|
1153
|
+
parent
|
|
1154
|
+
fn-depth
|
|
1155
|
+
bindings
|
|
1156
|
+
order)
|
|
1157
|
+
|
|
1158
|
+
(defun eliscript-analyzer--lint-ignored-name-p (name)
|
|
1159
|
+
"Return non-nil when symbol NAME starts with an underscore."
|
|
1160
|
+
(and (symbolp name)
|
|
1161
|
+
(string-prefix-p "_" (symbol-name name))))
|
|
1162
|
+
|
|
1163
|
+
(defun eliscript-analyzer--lint-rule-level (options code)
|
|
1164
|
+
"Return effective severity level (`off', `warning', `error') for CODE."
|
|
1165
|
+
(let* ((rules (cond
|
|
1166
|
+
((hash-table-p options) (gethash "rules" options))
|
|
1167
|
+
((and (listp options) (not (keywordp (car options))))
|
|
1168
|
+
(alist-get 'rules options))
|
|
1169
|
+
((listp options) (plist-get options :rules))
|
|
1170
|
+
(t nil)))
|
|
1171
|
+
(raw (cond
|
|
1172
|
+
((hash-table-p rules)
|
|
1173
|
+
(or (gethash code rules)
|
|
1174
|
+
(gethash (intern code) rules)))
|
|
1175
|
+
((listp rules)
|
|
1176
|
+
(or (alist-get code rules nil nil #'equal)
|
|
1177
|
+
(alist-get (intern code) rules)
|
|
1178
|
+
(plist-get rules (intern code))))
|
|
1179
|
+
(t nil))))
|
|
1180
|
+
(cond
|
|
1181
|
+
((or (equal raw "off") (eq raw 'off) (eq raw :off)) "off")
|
|
1182
|
+
((or (equal raw "error") (eq raw 'error) (eq raw :error)) "error")
|
|
1183
|
+
(t "warning"))))
|
|
1184
|
+
|
|
1185
|
+
(defun eliscript-analyzer--lint-emit (state code span format-string &rest args)
|
|
1186
|
+
"Record lint diagnostic CODE at SPAN in STATE when enabled."
|
|
1187
|
+
(let ((severity (eliscript-analyzer--lint-rule-level
|
|
1188
|
+
(plist-get state :options) code)))
|
|
1189
|
+
(unless (equal severity "off")
|
|
1190
|
+
(let* ((effective-span (or span (plist-get state :current-span)))
|
|
1191
|
+
(file (or (plist-get state :filename)
|
|
1192
|
+
(and effective-span
|
|
1193
|
+
(eliscript-source-span-filename effective-span))
|
|
1194
|
+
"<input>"))
|
|
1195
|
+
(diag (eliscript-diagnostic-create
|
|
1196
|
+
:code code
|
|
1197
|
+
:severity severity
|
|
1198
|
+
:phase "lint"
|
|
1199
|
+
:message (apply #'format format-string args)
|
|
1200
|
+
:file file
|
|
1201
|
+
:span effective-span)))
|
|
1202
|
+
(push diag (plist-get state :diagnostics))))))
|
|
1203
|
+
|
|
1204
|
+
(defun eliscript-analyzer--lint-make-scope (parent fn-depth)
|
|
1205
|
+
"Create a lint lexical scope below PARENT at FN-DEPTH."
|
|
1206
|
+
(eliscript-analyzer--lint-scope-create
|
|
1207
|
+
:parent parent
|
|
1208
|
+
:fn-depth fn-depth
|
|
1209
|
+
:bindings (make-hash-table :test #'eq)
|
|
1210
|
+
:order nil))
|
|
1211
|
+
|
|
1212
|
+
(defun eliscript-analyzer--lint-lookup (scope name)
|
|
1213
|
+
"Resolve NAME in lint SCOPE and its parents."
|
|
1214
|
+
(let (binding)
|
|
1215
|
+
(while (and scope (not binding))
|
|
1216
|
+
(setq binding (gethash name (eliscript-analyzer--lint-scope-bindings scope))
|
|
1217
|
+
scope (eliscript-analyzer--lint-scope-parent scope)))
|
|
1218
|
+
binding))
|
|
1219
|
+
|
|
1220
|
+
(defun eliscript-analyzer--lint-declare
|
|
1221
|
+
(scope name-form kind fn-depth mutable state &optional check-shadow is-transient)
|
|
1222
|
+
"Declare NAME-FORM in lint SCOPE and optionally check ELI-L0003."
|
|
1223
|
+
(let* ((name (eliscript-form-value name-form))
|
|
1224
|
+
(span (or (eliscript-form-span name-form)
|
|
1225
|
+
(plist-get state :current-span))))
|
|
1226
|
+
(when (symbolp name)
|
|
1227
|
+
(when (and check-shadow
|
|
1228
|
+
(not (eliscript-analyzer--lint-ignored-name-p name))
|
|
1229
|
+
(eliscript-analyzer--lint-scope-parent scope)
|
|
1230
|
+
(eliscript-analyzer--lint-lookup
|
|
1231
|
+
(eliscript-analyzer--lint-scope-parent scope) name))
|
|
1232
|
+
(eliscript-analyzer--lint-emit
|
|
1233
|
+
state "ELI-L0003" span
|
|
1234
|
+
"binding shadows outer binding: %s" (symbol-name name)))
|
|
1235
|
+
(let ((binding (eliscript-analyzer--lint-binding-create
|
|
1236
|
+
:name name
|
|
1237
|
+
:kind kind
|
|
1238
|
+
:fn-depth fn-depth
|
|
1239
|
+
:span span
|
|
1240
|
+
:mutable mutable
|
|
1241
|
+
:used nil
|
|
1242
|
+
:is-transient is-transient
|
|
1243
|
+
:transient-finalized nil
|
|
1244
|
+
:transient-escaped nil
|
|
1245
|
+
:transient-escape-span nil)))
|
|
1246
|
+
(unless (gethash name (eliscript-analyzer--lint-scope-bindings scope))
|
|
1247
|
+
(push binding (eliscript-analyzer--lint-scope-order scope)))
|
|
1248
|
+
(puthash name binding (eliscript-analyzer--lint-scope-bindings scope))
|
|
1249
|
+
binding))))
|
|
1250
|
+
|
|
1251
|
+
(defun eliscript-analyzer--lint-finalize-scope (scope state)
|
|
1252
|
+
"Emit ELI-L0001 and ELI-L0009 for unused/unfinalized bindings in SCOPE."
|
|
1253
|
+
(dolist (binding (reverse (eliscript-analyzer--lint-scope-order scope)))
|
|
1254
|
+
(let ((name (eliscript-analyzer--lint-binding-name binding))
|
|
1255
|
+
(kind (eliscript-analyzer--lint-binding-kind binding)))
|
|
1256
|
+
(when (and (memq kind '(local parameter loop catch))
|
|
1257
|
+
(not (eliscript-analyzer--lint-binding-used binding))
|
|
1258
|
+
(not (eliscript-analyzer--lint-ignored-name-p name)))
|
|
1259
|
+
(eliscript-analyzer--lint-emit
|
|
1260
|
+
state "ELI-L0001"
|
|
1261
|
+
(eliscript-analyzer--lint-binding-span binding)
|
|
1262
|
+
"unused local binding: %s" (symbol-name name)))
|
|
1263
|
+
(when (and (eliscript-analyzer--lint-binding-is-transient binding)
|
|
1264
|
+
(or (eliscript-analyzer--lint-binding-transient-escaped binding)
|
|
1265
|
+
(not (eliscript-analyzer--lint-binding-transient-finalized binding))))
|
|
1266
|
+
(eliscript-analyzer--lint-emit
|
|
1267
|
+
state "ELI-L0009"
|
|
1268
|
+
(or (eliscript-analyzer--lint-binding-transient-escape-span binding)
|
|
1269
|
+
(eliscript-analyzer--lint-binding-span binding))
|
|
1270
|
+
"transient binding escapes or is not finalized with persistent!: %s"
|
|
1271
|
+
(symbol-name name))))))
|
|
1272
|
+
|
|
1273
|
+
(defun eliscript-analyzer--lint-transient-init-p (form)
|
|
1274
|
+
"Return non-nil when FORM is a transient constructor expression."
|
|
1275
|
+
(let ((value (and form (eliscript-form-value form))))
|
|
1276
|
+
(and (proper-list-p value)
|
|
1277
|
+
value
|
|
1278
|
+
(symbolp (eliscript-form-value (car value)))
|
|
1279
|
+
(memq (eliscript-form-value (car value))
|
|
1280
|
+
eliscript-analyzer--lint-transient-constructors))))
|
|
1281
|
+
|
|
1282
|
+
(defun eliscript-analyzer--lint-mark-finalized-transient (arg scope state)
|
|
1283
|
+
"Mark transient bindings finalized directly or through fluent updaters in ARG."
|
|
1284
|
+
(when arg
|
|
1285
|
+
(let ((value (eliscript-form-value arg)))
|
|
1286
|
+
(cond
|
|
1287
|
+
((symbolp value)
|
|
1288
|
+
(let ((binding (eliscript-analyzer--lint-lookup scope value)))
|
|
1289
|
+
(when (and binding
|
|
1290
|
+
(eliscript-analyzer--lint-binding-is-transient binding)
|
|
1291
|
+
(= (eliscript-analyzer--lint-binding-fn-depth binding)
|
|
1292
|
+
(eliscript-analyzer--lint-scope-fn-depth scope)))
|
|
1293
|
+
(setf (eliscript-analyzer--lint-binding-transient-finalized binding) t))))
|
|
1294
|
+
((proper-list-p value)
|
|
1295
|
+
(let ((head (and value (eliscript-form-value (car value)))))
|
|
1296
|
+
(when (and (symbolp head)
|
|
1297
|
+
(memq head eliscript-analyzer--lint-transient-updaters)
|
|
1298
|
+
(cdr value))
|
|
1299
|
+
(eliscript-analyzer--lint-mark-finalized-transient
|
|
1300
|
+
(cadr value) scope state))))))))
|
|
1301
|
+
|
|
1302
|
+
(defun eliscript-analyzer--lint-constant-condition-p (form)
|
|
1303
|
+
"Return non-nil when FORM is an always-constant conditional test."
|
|
1304
|
+
(let ((value (eliscript-form-value form)))
|
|
1305
|
+
(or (null value)
|
|
1306
|
+
(eq value t)
|
|
1307
|
+
(eq value 'false)
|
|
1308
|
+
(eq value 'undefined)
|
|
1309
|
+
(numberp value)
|
|
1310
|
+
(stringp value)
|
|
1311
|
+
(keywordp value)
|
|
1312
|
+
(and (proper-list-p value)
|
|
1313
|
+
value
|
|
1314
|
+
(eq (eliscript-form-value (car value)) 'quote)))))
|
|
1315
|
+
|
|
1316
|
+
(defun eliscript-analyzer--lint-useless-expr-p (form)
|
|
1317
|
+
"Return non-nil when FORM has no side effects as a non-final sequence item."
|
|
1318
|
+
(let ((value (eliscript-form-value form)))
|
|
1319
|
+
(or (null value)
|
|
1320
|
+
(eq value t)
|
|
1321
|
+
(eq value 'false)
|
|
1322
|
+
(eq value 'undefined)
|
|
1323
|
+
(numberp value)
|
|
1324
|
+
(stringp value)
|
|
1325
|
+
(keywordp value)
|
|
1326
|
+
(and (symbolp value)
|
|
1327
|
+
(not (eliscript-analyzer--lint-ignored-name-p value)))
|
|
1328
|
+
(and (proper-list-p value)
|
|
1329
|
+
value
|
|
1330
|
+
(eq (eliscript-form-value (car value)) 'quote)))))
|
|
1331
|
+
|
|
1332
|
+
(defun eliscript-analyzer--lint-literal-key (form)
|
|
1333
|
+
"Return canonical scalar key string for literal FORM, or nil if dynamic."
|
|
1334
|
+
(let ((value (eliscript-form-value form)))
|
|
1335
|
+
(cond
|
|
1336
|
+
((null value) "nil:nil")
|
|
1337
|
+
((eq value t) "bool:t")
|
|
1338
|
+
((eq value 'false) "bool:false")
|
|
1339
|
+
((eq value 'undefined) "undef:undefined")
|
|
1340
|
+
((keywordp value) (concat "kw:" (substring (symbol-name value) 1)))
|
|
1341
|
+
((stringp value) (concat "str:" value))
|
|
1342
|
+
((numberp value)
|
|
1343
|
+
(concat "num:" (number-to-string (if (= value 0) 0 value))))
|
|
1344
|
+
(t nil))))
|
|
1345
|
+
|
|
1346
|
+
(defun eliscript-analyzer--lint-key-display (form)
|
|
1347
|
+
"Return readable representation of scalar FORM for ELI-L0007 messages."
|
|
1348
|
+
(let ((value (eliscript-form-value form)))
|
|
1349
|
+
(cond
|
|
1350
|
+
((null value) "nil")
|
|
1351
|
+
((eq value t) "t")
|
|
1352
|
+
((eq value 'false) "false")
|
|
1353
|
+
((eq value 'undefined) "undefined")
|
|
1354
|
+
((keywordp value) (symbol-name value))
|
|
1355
|
+
((stringp value) (json-serialize value))
|
|
1356
|
+
((numberp value) (number-to-string value))
|
|
1357
|
+
(t (format "%S" value)))))
|
|
1358
|
+
|
|
1359
|
+
(defun eliscript-analyzer--lint-collect-arities (forms)
|
|
1360
|
+
"Map top-level function names in FORMS to (MIN . MAX) arity bounds."
|
|
1361
|
+
(let ((arities (make-hash-table :test #'eq)))
|
|
1362
|
+
(dolist (form forms)
|
|
1363
|
+
(let ((value (eliscript-form-value form)))
|
|
1364
|
+
(when (and (proper-list-p value)
|
|
1365
|
+
(>= (length value) 3)
|
|
1366
|
+
(memq (eliscript-form-value (car value))
|
|
1367
|
+
'(defun defn defportable defasync)))
|
|
1368
|
+
(let* ((name (eliscript-form-value (nth 1 value)))
|
|
1369
|
+
(params-form (nth 2 value))
|
|
1370
|
+
(parsed (ignore-errors
|
|
1371
|
+
(eliscript-parameters-parse
|
|
1372
|
+
params-form (lambda (&rest _) nil))))
|
|
1373
|
+
(min-arity 0)
|
|
1374
|
+
(max-arity 0)
|
|
1375
|
+
(variadic nil))
|
|
1376
|
+
(when (and (symbolp name) parsed)
|
|
1377
|
+
(dolist (param parsed)
|
|
1378
|
+
(pcase (eliscript-parameter-kind param)
|
|
1379
|
+
('required
|
|
1380
|
+
(setq min-arity (1+ min-arity)
|
|
1381
|
+
max-arity (1+ max-arity)))
|
|
1382
|
+
('optional
|
|
1383
|
+
(setq max-arity (1+ max-arity)))
|
|
1384
|
+
('rest
|
|
1385
|
+
(setq variadic t))))
|
|
1386
|
+
(puthash name (cons min-arity (if variadic nil max-arity))
|
|
1387
|
+
arities))))))
|
|
1388
|
+
arities))
|
|
1389
|
+
|
|
1390
|
+
(defun eliscript-analyzer--lint-sequence (forms scope tail state)
|
|
1391
|
+
"Lint statement sequence FORMS in SCOPE with TAIL status."
|
|
1392
|
+
(let ((rest forms))
|
|
1393
|
+
(while rest
|
|
1394
|
+
(let ((item (car rest))
|
|
1395
|
+
(is-last (null (cdr rest))))
|
|
1396
|
+
(when (and (not is-last)
|
|
1397
|
+
(eliscript-analyzer--lint-useless-expr-p item))
|
|
1398
|
+
(eliscript-analyzer--lint-emit
|
|
1399
|
+
state "ELI-L0008"
|
|
1400
|
+
(or (eliscript-form-span item) (plist-get state :current-span))
|
|
1401
|
+
"useless literal expression in sequence"))
|
|
1402
|
+
(eliscript-analyzer--lint-expression item scope (and tail is-last) state))
|
|
1403
|
+
(setq rest (cdr rest)))))
|
|
1404
|
+
|
|
1405
|
+
(defun eliscript-analyzer--lint-pattern-defaults (pattern scope state)
|
|
1406
|
+
"Lint map binding default expressions in PATTERN using SCOPE."
|
|
1407
|
+
(let ((defaults (ignore-errors
|
|
1408
|
+
(eliscript-binding-defaults
|
|
1409
|
+
pattern (lambda (&rest _) nil)))))
|
|
1410
|
+
(dolist (default defaults)
|
|
1411
|
+
(eliscript-analyzer--lint-expression default scope nil state))))
|
|
1412
|
+
|
|
1413
|
+
(defun eliscript-analyzer--lint-declare-pattern
|
|
1414
|
+
(scope pattern kind fn-depth mutable state &optional check-shadow is-transient)
|
|
1415
|
+
"Declare all scalar bindings from PATTERN in lint SCOPE."
|
|
1416
|
+
(let ((names (ignore-errors
|
|
1417
|
+
(eliscript-binding-names
|
|
1418
|
+
pattern (lambda (&rest _) nil))))
|
|
1419
|
+
(single (symbolp (eliscript-form-value pattern))))
|
|
1420
|
+
(dolist (name-form names)
|
|
1421
|
+
(eliscript-analyzer--lint-declare
|
|
1422
|
+
scope name-form kind fn-depth mutable state check-shadow
|
|
1423
|
+
(and single is-transient)))))
|
|
1424
|
+
|
|
1425
|
+
(defun eliscript-analyzer--lint-let (args scope sequential tail state)
|
|
1426
|
+
"Lint let/let* expression ARGS in SCOPE."
|
|
1427
|
+
(when args
|
|
1428
|
+
(let* ((bindings (eliscript-form-value (car args)))
|
|
1429
|
+
(body (cdr args))
|
|
1430
|
+
(child (eliscript-analyzer--lint-make-scope
|
|
1431
|
+
scope (eliscript-analyzer--lint-scope-fn-depth scope))))
|
|
1432
|
+
(when (proper-list-p bindings)
|
|
1433
|
+
(if sequential
|
|
1434
|
+
(dolist (binding bindings)
|
|
1435
|
+
(let* ((val (eliscript-form-value binding))
|
|
1436
|
+
(pair (if (eliscript-binding-pattern-p binding)
|
|
1437
|
+
(list binding nil)
|
|
1438
|
+
(list (car val) (cadr val))))
|
|
1439
|
+
(pat (car pair))
|
|
1440
|
+
(init (cadr pair)))
|
|
1441
|
+
(when init
|
|
1442
|
+
(eliscript-analyzer--lint-expression init child nil state))
|
|
1443
|
+
(eliscript-analyzer--lint-pattern-defaults pat child state)
|
|
1444
|
+
(eliscript-analyzer--lint-declare-pattern
|
|
1445
|
+
child pat 'local (eliscript-analyzer--lint-scope-fn-depth child)
|
|
1446
|
+
t state t (eliscript-analyzer--lint-transient-init-p init))))
|
|
1447
|
+
(let ((pairs (mapcar (lambda (binding)
|
|
1448
|
+
(let ((val (eliscript-form-value binding)))
|
|
1449
|
+
(if (eliscript-binding-pattern-p binding)
|
|
1450
|
+
(list binding nil)
|
|
1451
|
+
(list (car val) (cadr val)))))
|
|
1452
|
+
bindings)))
|
|
1453
|
+
(dolist (pair pairs)
|
|
1454
|
+
(when (cadr pair)
|
|
1455
|
+
(eliscript-analyzer--lint-expression (cadr pair) scope nil state))
|
|
1456
|
+
(eliscript-analyzer--lint-pattern-defaults (car pair) scope state))
|
|
1457
|
+
(dolist (pair pairs)
|
|
1458
|
+
(eliscript-analyzer--lint-declare-pattern
|
|
1459
|
+
child (car pair) 'local
|
|
1460
|
+
(eliscript-analyzer--lint-scope-fn-depth child)
|
|
1461
|
+
t state t
|
|
1462
|
+
(eliscript-analyzer--lint-transient-init-p (cadr pair)))))))
|
|
1463
|
+
(eliscript-analyzer--lint-sequence body child tail state)
|
|
1464
|
+
(eliscript-analyzer--lint-finalize-scope child state))))
|
|
1465
|
+
|
|
1466
|
+
(defun eliscript-analyzer--lint-loop (args scope tail state)
|
|
1467
|
+
"Lint loop expression ARGS in SCOPE."
|
|
1468
|
+
(when args
|
|
1469
|
+
(let* ((bindings (eliscript-form-value (car args)))
|
|
1470
|
+
(body (cdr args))
|
|
1471
|
+
(child (eliscript-analyzer--lint-make-scope
|
|
1472
|
+
scope (eliscript-analyzer--lint-scope-fn-depth scope)))
|
|
1473
|
+
pairs)
|
|
1474
|
+
(when (proper-list-p bindings)
|
|
1475
|
+
(dolist (binding bindings)
|
|
1476
|
+
(let ((val (eliscript-form-value binding)))
|
|
1477
|
+
(when (and (proper-list-p val) (= (length val) 2))
|
|
1478
|
+
(push (list (car val) (cadr val)) pairs))))
|
|
1479
|
+
(setq pairs (nreverse pairs))
|
|
1480
|
+
(dolist (pair pairs)
|
|
1481
|
+
(eliscript-analyzer--lint-expression (cadr pair) scope nil state)
|
|
1482
|
+
(eliscript-analyzer--lint-pattern-defaults (car pair) scope state))
|
|
1483
|
+
(dolist (pair pairs)
|
|
1484
|
+
(eliscript-analyzer--lint-declare-pattern
|
|
1485
|
+
child (car pair) 'loop
|
|
1486
|
+
(eliscript-analyzer--lint-scope-fn-depth child)
|
|
1487
|
+
t state t
|
|
1488
|
+
(eliscript-analyzer--lint-transient-init-p (cadr pair)))))
|
|
1489
|
+
(eliscript-analyzer--lint-sequence body child tail state)
|
|
1490
|
+
(eliscript-analyzer--lint-finalize-scope child state))))
|
|
1491
|
+
|
|
1492
|
+
(defun eliscript-analyzer--lint-function (parameters body scope asynchronous state)
|
|
1493
|
+
"Lint function PARAMETERS and BODY inside SCOPE."
|
|
1494
|
+
(let* ((parsed (ignore-errors
|
|
1495
|
+
(eliscript-parameters-parse
|
|
1496
|
+
parameters (lambda (&rest _) nil))))
|
|
1497
|
+
(clean-body (if (and body
|
|
1498
|
+
(proper-list-p (eliscript-form-value (car body)))
|
|
1499
|
+
(eq (eliscript-form-value
|
|
1500
|
+
(car (eliscript-form-value (car body))))
|
|
1501
|
+
'memory-sig))
|
|
1502
|
+
(cdr body)
|
|
1503
|
+
body))
|
|
1504
|
+
(child (eliscript-analyzer--lint-make-scope
|
|
1505
|
+
scope (1+ (eliscript-analyzer--lint-scope-fn-depth scope)))))
|
|
1506
|
+
(ignore asynchronous)
|
|
1507
|
+
(dolist (param parsed)
|
|
1508
|
+
(eliscript-analyzer--lint-pattern-defaults
|
|
1509
|
+
(eliscript-parameter-form param) scope state))
|
|
1510
|
+
(dolist (param parsed)
|
|
1511
|
+
(eliscript-analyzer--lint-declare-pattern
|
|
1512
|
+
child (eliscript-parameter-form param) 'parameter
|
|
1513
|
+
(eliscript-analyzer--lint-scope-fn-depth child) t state t nil))
|
|
1514
|
+
(eliscript-analyzer--lint-sequence clean-body child t state)
|
|
1515
|
+
(eliscript-analyzer--lint-finalize-scope child state)))
|
|
1516
|
+
|
|
1517
|
+
(defun eliscript-analyzer--lint-assignment (form-span args scope state)
|
|
1518
|
+
"Lint assignment ARGS at FORM-SPAN in SCOPE."
|
|
1519
|
+
(let ((rest args))
|
|
1520
|
+
(while rest
|
|
1521
|
+
(let* ((target-form (pop rest))
|
|
1522
|
+
(value-form (pop rest))
|
|
1523
|
+
(target (eliscript-form-value target-form)))
|
|
1524
|
+
(when value-form
|
|
1525
|
+
(eliscript-analyzer--lint-expression value-form scope nil state))
|
|
1526
|
+
(when (symbolp target)
|
|
1527
|
+
(let ((binding (eliscript-analyzer--lint-lookup scope target)))
|
|
1528
|
+
(when binding
|
|
1529
|
+
(when (and (not (eliscript-analyzer--lint-ignored-name-p target))
|
|
1530
|
+
(or (eq (eliscript-analyzer--lint-binding-kind binding) 'parameter)
|
|
1531
|
+
(and (> (eliscript-analyzer--lint-binding-fn-depth binding) 0)
|
|
1532
|
+
(< (eliscript-analyzer--lint-binding-fn-depth binding)
|
|
1533
|
+
(eliscript-analyzer--lint-scope-fn-depth scope)))))
|
|
1534
|
+
(eliscript-analyzer--lint-emit
|
|
1535
|
+
state "ELI-L0006" form-span
|
|
1536
|
+
"mutating parameter or captured binding with setq: %s"
|
|
1537
|
+
(symbol-name target)))
|
|
1538
|
+
(when (and value-form
|
|
1539
|
+
(eliscript-analyzer--lint-transient-init-p value-form))
|
|
1540
|
+
(setf (eliscript-analyzer--lint-binding-is-transient binding) t)))))))))
|
|
1541
|
+
|
|
1542
|
+
(defun eliscript-analyzer--lint-call (form scope tail state)
|
|
1543
|
+
"Lint call expression FORM in SCOPE with TAIL status."
|
|
1544
|
+
(let* ((items (eliscript-form-value form))
|
|
1545
|
+
(op-form (car items))
|
|
1546
|
+
(op (eliscript-form-value op-form))
|
|
1547
|
+
(args (cdr items))
|
|
1548
|
+
(form-span (or (eliscript-form-span form)
|
|
1549
|
+
(plist-get state :current-span))))
|
|
1550
|
+
(pcase op
|
|
1551
|
+
((or 'lambda 'fn 'async)
|
|
1552
|
+
(when args
|
|
1553
|
+
(eliscript-analyzer--lint-function
|
|
1554
|
+
(car args) (cdr args) scope (eq op 'async) state)))
|
|
1555
|
+
('let (eliscript-analyzer--lint-let args scope nil tail state))
|
|
1556
|
+
('let* (eliscript-analyzer--lint-let args scope t tail state))
|
|
1557
|
+
('loop (eliscript-analyzer--lint-loop args scope tail state))
|
|
1558
|
+
((or 'setq 'set!)
|
|
1559
|
+
(eliscript-analyzer--lint-assignment form-span args scope state))
|
|
1560
|
+
('if
|
|
1561
|
+
(when (and args (eliscript-analyzer--lint-constant-condition-p (car args)))
|
|
1562
|
+
(eliscript-analyzer--lint-emit
|
|
1563
|
+
state "ELI-L0005" form-span "constant condition in if expression"))
|
|
1564
|
+
(when args
|
|
1565
|
+
(eliscript-analyzer--lint-expression (car args) scope nil state)
|
|
1566
|
+
(dolist (branch (cdr args))
|
|
1567
|
+
(eliscript-analyzer--lint-expression branch scope tail state))))
|
|
1568
|
+
((or 'when 'unless)
|
|
1569
|
+
(when args
|
|
1570
|
+
(eliscript-analyzer--lint-expression (car args) scope nil state)
|
|
1571
|
+
(eliscript-analyzer--lint-sequence (cdr args) scope tail state)))
|
|
1572
|
+
((or 'progn 'do)
|
|
1573
|
+
(if (null args)
|
|
1574
|
+
(eliscript-analyzer--lint-emit
|
|
1575
|
+
state "ELI-L0008" form-span "empty progn/do expression")
|
|
1576
|
+
(eliscript-analyzer--lint-sequence args scope tail state)))
|
|
1577
|
+
((or 'and 'or)
|
|
1578
|
+
(eliscript-analyzer--lint-sequence args scope tail state))
|
|
1579
|
+
('cond
|
|
1580
|
+
(dolist (clause args)
|
|
1581
|
+
(let ((cval (eliscript-form-value clause)))
|
|
1582
|
+
(when (and (proper-list-p cval) cval)
|
|
1583
|
+
(eliscript-analyzer--lint-expression (car cval) scope nil state)
|
|
1584
|
+
(eliscript-analyzer--lint-sequence (cdr cval) scope tail state)))))
|
|
1585
|
+
('try
|
|
1586
|
+
(dolist (arg args)
|
|
1587
|
+
(let ((aop (eliscript-analyzer--clause-operator arg)))
|
|
1588
|
+
(cond
|
|
1589
|
+
((eq aop 'catch)
|
|
1590
|
+
(let* ((cval (eliscript-form-value arg))
|
|
1591
|
+
(pat (cadr cval))
|
|
1592
|
+
(child (eliscript-analyzer--lint-make-scope
|
|
1593
|
+
scope (eliscript-analyzer--lint-scope-fn-depth scope))))
|
|
1594
|
+
(eliscript-analyzer--lint-pattern-defaults pat scope state)
|
|
1595
|
+
(eliscript-analyzer--lint-declare-pattern
|
|
1596
|
+
child pat 'catch (eliscript-analyzer--lint-scope-fn-depth child)
|
|
1597
|
+
t state t nil)
|
|
1598
|
+
(eliscript-analyzer--lint-sequence (cddr cval) child tail state)
|
|
1599
|
+
(eliscript-analyzer--lint-finalize-scope child state)))
|
|
1600
|
+
((eq aop 'finally)
|
|
1601
|
+
(eliscript-analyzer--lint-sequence
|
|
1602
|
+
(cdr (eliscript-form-value arg)) scope nil state))
|
|
1603
|
+
(t
|
|
1604
|
+
(eliscript-analyzer--lint-expression arg scope tail state))))))
|
|
1605
|
+
('hash-map
|
|
1606
|
+
(let ((seen (make-hash-table :test #'equal))
|
|
1607
|
+
(rest args))
|
|
1608
|
+
(while rest
|
|
1609
|
+
(let ((k (pop rest))
|
|
1610
|
+
(v (pop rest)))
|
|
1611
|
+
(when k
|
|
1612
|
+
(let ((canon (eliscript-analyzer--lint-literal-key k)))
|
|
1613
|
+
(when canon
|
|
1614
|
+
(if (gethash canon seen)
|
|
1615
|
+
(eliscript-analyzer--lint-emit
|
|
1616
|
+
state "ELI-L0007"
|
|
1617
|
+
(or (eliscript-form-span k) form-span)
|
|
1618
|
+
"duplicate map literal key: %s"
|
|
1619
|
+
(eliscript-analyzer--lint-key-display k))
|
|
1620
|
+
(puthash canon t seen))))
|
|
1621
|
+
(eliscript-analyzer--lint-expression k scope nil state))
|
|
1622
|
+
(when v
|
|
1623
|
+
(eliscript-analyzer--lint-expression v scope nil state))))))
|
|
1624
|
+
('hash-set
|
|
1625
|
+
(let ((seen (make-hash-table :test #'equal)))
|
|
1626
|
+
(dolist (elem args)
|
|
1627
|
+
(let ((canon (eliscript-analyzer--lint-literal-key elem)))
|
|
1628
|
+
(when canon
|
|
1629
|
+
(if (gethash canon seen)
|
|
1630
|
+
(eliscript-analyzer--lint-emit
|
|
1631
|
+
state "ELI-L0007"
|
|
1632
|
+
(or (eliscript-form-span elem) form-span)
|
|
1633
|
+
"duplicate set literal element: %s"
|
|
1634
|
+
(eliscript-analyzer--lint-key-display elem))
|
|
1635
|
+
(puthash canon t seen))))
|
|
1636
|
+
(eliscript-analyzer--lint-expression elem scope nil state))))
|
|
1637
|
+
('js-object
|
|
1638
|
+
(let ((rest args))
|
|
1639
|
+
(while rest
|
|
1640
|
+
(let ((k (pop rest))
|
|
1641
|
+
(v (pop rest)))
|
|
1642
|
+
(when k
|
|
1643
|
+
(let ((kv (eliscript-form-value k)))
|
|
1644
|
+
(unless (or (keywordp kv) (stringp kv) (symbolp kv))
|
|
1645
|
+
(eliscript-analyzer--lint-expression k scope nil state))))
|
|
1646
|
+
(when v
|
|
1647
|
+
(eliscript-analyzer--lint-expression v scope nil state))))))
|
|
1648
|
+
((or 'get 'put 'js-call)
|
|
1649
|
+
(when args
|
|
1650
|
+
(eliscript-analyzer--lint-expression (car args) scope nil state)
|
|
1651
|
+
(when (cadr args)
|
|
1652
|
+
(let ((kv (eliscript-form-value (cadr args))))
|
|
1653
|
+
(unless (or (keywordp kv) (stringp kv))
|
|
1654
|
+
(eliscript-analyzer--lint-expression (cadr args) scope nil state))))
|
|
1655
|
+
(dolist (extra (nthcdr 2 args))
|
|
1656
|
+
(eliscript-analyzer--lint-expression extra scope nil state))))
|
|
1657
|
+
((or 'quote 'js*) nil)
|
|
1658
|
+
(_
|
|
1659
|
+
(let ((is-builtin (and (symbolp op)
|
|
1660
|
+
(memq op eliscript-analyzer--builtin-operators))))
|
|
1661
|
+
(unless is-builtin
|
|
1662
|
+
(eliscript-analyzer--lint-expression op-form scope nil state))
|
|
1663
|
+
(when (and (symbolp op) (not is-builtin))
|
|
1664
|
+
(let* ((binding (eliscript-analyzer--lint-lookup scope op))
|
|
1665
|
+
(sig (and binding
|
|
1666
|
+
(eq (eliscript-analyzer--lint-binding-kind binding) 'function)
|
|
1667
|
+
(= (eliscript-analyzer--lint-binding-fn-depth binding) 0)
|
|
1668
|
+
(gethash op (plist-get state :arities)))))
|
|
1669
|
+
(when sig
|
|
1670
|
+
(let ((min-a (car sig))
|
|
1671
|
+
(max-a (cdr sig))
|
|
1672
|
+
(argc (length args)))
|
|
1673
|
+
(when (or (< argc min-a) (and max-a (> argc max-a)))
|
|
1674
|
+
(eliscript-analyzer--lint-emit
|
|
1675
|
+
state "ELI-L0004" form-span
|
|
1676
|
+
"function %s expects %s arguments, got %d"
|
|
1677
|
+
(symbol-name op)
|
|
1678
|
+
(cond
|
|
1679
|
+
((null max-a) (format "at least %d" min-a))
|
|
1680
|
+
((= min-a max-a) (number-to-string min-a))
|
|
1681
|
+
(t (format "%d..%d" min-a max-a)))
|
|
1682
|
+
argc))))))
|
|
1683
|
+
(when (and (symbolp op)
|
|
1684
|
+
(memq op eliscript-analyzer--lint-transient-finalizers)
|
|
1685
|
+
args)
|
|
1686
|
+
(eliscript-analyzer--lint-mark-finalized-transient (car args) scope state))
|
|
1687
|
+
(dolist (arg args)
|
|
1688
|
+
(eliscript-analyzer--lint-expression arg scope nil state)))))))
|
|
1689
|
+
|
|
1690
|
+
(defun eliscript-analyzer--lint-expression (form scope tail state)
|
|
1691
|
+
"Lint expression FORM in SCOPE with TAIL status using STATE."
|
|
1692
|
+
(when form
|
|
1693
|
+
(let* ((prev-span (plist-get state :current-span))
|
|
1694
|
+
(span (or (eliscript-form-span form) prev-span))
|
|
1695
|
+
(value (eliscript-form-value form)))
|
|
1696
|
+
(plist-put state :current-span span)
|
|
1697
|
+
(cond
|
|
1698
|
+
((or (null value) (eq value t) (numberp value) (stringp value)
|
|
1699
|
+
(keywordp value) (eq value 'false) (eq value 'undefined))
|
|
1700
|
+
nil)
|
|
1701
|
+
((symbolp value)
|
|
1702
|
+
(unless (eliscript-analyzer--qualified-symbol-p value)
|
|
1703
|
+
(let ((binding (eliscript-analyzer--lint-lookup scope value)))
|
|
1704
|
+
(when binding
|
|
1705
|
+
(setf (eliscript-analyzer--lint-binding-used binding) t)
|
|
1706
|
+
(when (eliscript-analyzer--lint-binding-is-transient binding)
|
|
1707
|
+
(cond
|
|
1708
|
+
((> (eliscript-analyzer--lint-scope-fn-depth scope)
|
|
1709
|
+
(eliscript-analyzer--lint-binding-fn-depth binding))
|
|
1710
|
+
(setf (eliscript-analyzer--lint-binding-transient-escaped binding) t)
|
|
1711
|
+
(unless (eliscript-analyzer--lint-binding-transient-escape-span binding)
|
|
1712
|
+
(setf (eliscript-analyzer--lint-binding-transient-escape-span binding) span)))
|
|
1713
|
+
(tail
|
|
1714
|
+
(setf (eliscript-analyzer--lint-binding-transient-escaped binding) t)
|
|
1715
|
+
(unless (eliscript-analyzer--lint-binding-transient-escape-span binding)
|
|
1716
|
+
(setf (eliscript-analyzer--lint-binding-transient-escape-span binding) span)))))))))
|
|
1717
|
+
((vectorp value)
|
|
1718
|
+
(dolist (elem (append value nil))
|
|
1719
|
+
(eliscript-analyzer--lint-expression elem scope nil state)))
|
|
1720
|
+
((consp value)
|
|
1721
|
+
(when (proper-list-p value)
|
|
1722
|
+
(eliscript-analyzer--lint-call form scope tail state))))
|
|
1723
|
+
(plist-put state :current-span prev-span))))
|
|
1724
|
+
|
|
1725
|
+
(defun eliscript-analyzer--lint-sort-key (diag)
|
|
1726
|
+
"Return deterministic sort key for lint diagnostic DIAG."
|
|
1727
|
+
(let ((span (eliscript-diagnostic-span diag)))
|
|
1728
|
+
(list (if span (eliscript-source-span-start span) 0)
|
|
1729
|
+
(eliscript-diagnostic-code diag)
|
|
1730
|
+
(eliscript-diagnostic-message diag))))
|
|
1731
|
+
|
|
1732
|
+
(defun eliscript-lint-module (forms &optional filename options)
|
|
1733
|
+
"Run static lint rules ELI-L0001..ELI-L0009 on expanded FORMS.
|
|
1734
|
+
|
|
1735
|
+
Return a deterministically sorted list of `eliscript-diagnostic' structs."
|
|
1736
|
+
(let* ((flattened (eliscript-analyzer--flatten-modules forms))
|
|
1737
|
+
(scope (eliscript-analyzer--lint-make-scope nil 0))
|
|
1738
|
+
(arities (eliscript-analyzer--lint-collect-arities flattened))
|
|
1739
|
+
(state (list :filename filename
|
|
1740
|
+
:options options
|
|
1741
|
+
:arities arities
|
|
1742
|
+
:current-span nil
|
|
1743
|
+
:diagnostics nil)))
|
|
1744
|
+
(dolist (form flattened)
|
|
1745
|
+
(let ((value (eliscript-form-value form)))
|
|
1746
|
+
(when (consp value)
|
|
1747
|
+
(pcase (eliscript-form-value (car value))
|
|
1748
|
+
((or 'import 'import-portable)
|
|
1749
|
+
(dolist (name (eliscript-analyzer--import-bindings
|
|
1750
|
+
(cdr value)
|
|
1751
|
+
(eq (eliscript-form-value (car value))
|
|
1752
|
+
'import-portable)))
|
|
1753
|
+
(eliscript-analyzer--lint-declare
|
|
1754
|
+
scope name 'import 0 nil state)))
|
|
1755
|
+
('defvar
|
|
1756
|
+
(eliscript-analyzer--lint-declare
|
|
1757
|
+
scope (cadr value) 'variable 0 t state))
|
|
1758
|
+
('defconst
|
|
1759
|
+
(eliscript-analyzer--lint-declare
|
|
1760
|
+
scope (cadr value) 'constant 0 nil state))
|
|
1761
|
+
((or 'defun 'defn 'defportable 'defasync)
|
|
1762
|
+
(eliscript-analyzer--lint-declare
|
|
1763
|
+
scope (cadr value) 'function 0 nil state))))))
|
|
1764
|
+
(dolist (form flattened)
|
|
1765
|
+
(let* ((value (eliscript-form-value form))
|
|
1766
|
+
(prev-span (plist-get state :current-span))
|
|
1767
|
+
(form-span (or (eliscript-form-span form) prev-span)))
|
|
1768
|
+
(plist-put state :current-span form-span)
|
|
1769
|
+
(if (not (consp value))
|
|
1770
|
+
(eliscript-analyzer--lint-expression form scope nil state)
|
|
1771
|
+
(let ((op (eliscript-form-value (car value)))
|
|
1772
|
+
(args (cdr value)))
|
|
1773
|
+
(pcase op
|
|
1774
|
+
((or 'import 'import-portable) nil)
|
|
1775
|
+
((or 'defvar 'defconst)
|
|
1776
|
+
(when (cadr args)
|
|
1777
|
+
(eliscript-analyzer--lint-expression (cadr args) scope nil state)))
|
|
1778
|
+
((or 'defun 'defn 'defportable 'defasync)
|
|
1779
|
+
(when (>= (length args) 2)
|
|
1780
|
+
(eliscript-analyzer--lint-function
|
|
1781
|
+
(cadr args) (cddr args) scope (eq op 'defasync) state)))
|
|
1782
|
+
('export
|
|
1783
|
+
(dolist (name args)
|
|
1784
|
+
(let ((sym (eliscript-form-value name)))
|
|
1785
|
+
(when (symbolp sym)
|
|
1786
|
+
(let ((binding (eliscript-analyzer--lint-lookup scope sym)))
|
|
1787
|
+
(when binding
|
|
1788
|
+
(setf (eliscript-analyzer--lint-binding-used binding) t)))))))
|
|
1789
|
+
('export-default
|
|
1790
|
+
(when (car args)
|
|
1791
|
+
(eliscript-analyzer--lint-expression (car args) scope nil state)))
|
|
1792
|
+
(_
|
|
1793
|
+
(eliscript-analyzer--lint-expression form scope nil state)))))
|
|
1794
|
+
(plist-put state :current-span prev-span)))
|
|
1795
|
+
(dolist (binding (reverse (eliscript-analyzer--lint-scope-order scope)))
|
|
1796
|
+
(when (eq (eliscript-analyzer--lint-binding-kind binding) 'import)
|
|
1797
|
+
(let ((name (eliscript-analyzer--lint-binding-name binding)))
|
|
1798
|
+
(when (and (not (eliscript-analyzer--lint-binding-used binding))
|
|
1799
|
+
(not (eliscript-analyzer--lint-ignored-name-p name)))
|
|
1800
|
+
(eliscript-analyzer--lint-emit
|
|
1801
|
+
state "ELI-L0002"
|
|
1802
|
+
(eliscript-analyzer--lint-binding-span binding)
|
|
1803
|
+
"unused import binding: %s" (symbol-name name))))))
|
|
1804
|
+
(sort (nreverse (plist-get state :diagnostics))
|
|
1805
|
+
(lambda (left right)
|
|
1806
|
+
(let ((kl (eliscript-analyzer--lint-sort-key left))
|
|
1807
|
+
(kr (eliscript-analyzer--lint-sort-key right)))
|
|
1808
|
+
(cond
|
|
1809
|
+
((/= (nth 0 kl) (nth 0 kr)) (< (nth 0 kl) (nth 0 kr)))
|
|
1810
|
+
((not (string= (nth 1 kl) (nth 1 kr)))
|
|
1811
|
+
(string< (nth 1 kl) (nth 1 kr)))
|
|
1812
|
+
(t (string< (nth 2 kl) (nth 2 kr)))))))))
|
|
1813
|
+
|
|
1120
1814
|
(provide 'eliscript-analyzer)
|
|
1121
1815
|
|
|
1122
1816
|
;;; eliscript-analyzer.el ends here
|