eliscript 0.0.1
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/LICENSE +674 -0
- package/README.md +135 -0
- package/bin/eliscript +16 -0
- package/bin/eliscript-bootstrap +15 -0
- package/bin/eliscript-build +15 -0
- package/bin/eliscript-check +15 -0
- package/bin/eliscript-eval +15 -0
- package/bin/eliscript-format +15 -0
- package/bin/eliscript-org +10 -0
- package/bin/eliscript-portable +17 -0
- package/bin/eliscript-seed +10 -0
- package/bin/eliscript-seed-build +10 -0
- package/bin/eliscript-watch +15 -0
- package/bootstrap/README.md +100 -0
- package/bootstrap/compiler/analyzer.eli +1426 -0
- package/bootstrap/compiler/compiler.eli +472 -0
- package/bootstrap/compiler/emitter.eli +1745 -0
- package/bootstrap/compiler/expander.eli +2522 -0
- package/bootstrap/compiler/formatter.eli +359 -0
- package/bootstrap/compiler/ir.eli +297 -0
- package/bootstrap/compiler/lower.eli +661 -0
- package/bootstrap/compiler/project.eli +1120 -0
- package/bootstrap/compiler/reader.eli +321 -0
- package/bootstrap/compiler/source-map.eli +165 -0
- package/bootstrap/compiler/symbol.eli +92 -0
- package/bootstrap/compiler/syntax.eli +54 -0
- package/bootstrap/compiler/transient-analysis.eli +825 -0
- package/bootstrap/host/build.mjs +28 -0
- package/bootstrap/host/bun.mjs +282 -0
- package/bootstrap/host/check-cli.mjs +163 -0
- package/bootstrap/host/eliscript-cli.mjs +36 -0
- package/bootstrap/host/evaluation-cli.mjs +401 -0
- package/bootstrap/host/evaluation.mjs +560 -0
- package/bootstrap/host/format-cli.mjs +139 -0
- package/bootstrap/host/project-cli.mjs +295 -0
- package/bootstrap/host/project.mjs +1080 -0
- package/bootstrap/host/watch-cli.mjs +129 -0
- package/bootstrap/host/watch.mjs +267 -0
- package/browser/host.mjs +357 -0
- package/browser/worker.mjs +60 -0
- package/compiler/README.md +118 -0
- package/compiler/eliscript-analyzer.el +716 -0
- package/compiler/eliscript-cli.el +108 -0
- package/compiler/eliscript-diagnostic.el +158 -0
- package/compiler/eliscript-emitter.el +1351 -0
- package/compiler/eliscript-evaluation.el +259 -0
- package/compiler/eliscript-expander.el +1630 -0
- package/compiler/eliscript-form.el +79 -0
- package/compiler/eliscript-ir-emitter.el +1460 -0
- package/compiler/eliscript-ir.el +356 -0
- package/compiler/eliscript-lower.el +463 -0
- package/compiler/eliscript-macro-eval.el +811 -0
- package/compiler/eliscript-parameters.el +324 -0
- package/compiler/eliscript-portable.el +492 -0
- package/compiler/eliscript-project-cli.el +156 -0
- package/compiler/eliscript-project.el +1676 -0
- package/compiler/eliscript-reader.el +421 -0
- package/compiler/eliscript-source-map.el +192 -0
- package/compiler/eliscript-symbol.el +101 -0
- package/compiler/eliscript-transient-analysis.el +817 -0
- package/compiler/eliscript.el +239 -0
- package/dist/bootstrap/analyzer.mjs +968 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -0
- package/dist/bootstrap/compiler.mjs +228 -0
- package/dist/bootstrap/compiler.mjs.map +1 -0
- package/dist/bootstrap/emitter.mjs +1173 -0
- package/dist/bootstrap/emitter.mjs.map +1 -0
- package/dist/bootstrap/expander.mjs +1469 -0
- package/dist/bootstrap/expander.mjs.map +1 -0
- package/dist/bootstrap/formatter.mjs +304 -0
- package/dist/bootstrap/formatter.mjs.map +1 -0
- package/dist/bootstrap/ir.mjs +193 -0
- package/dist/bootstrap/ir.mjs.map +1 -0
- package/dist/bootstrap/lower.mjs +344 -0
- package/dist/bootstrap/lower.mjs.map +1 -0
- package/dist/bootstrap/project.mjs +585 -0
- package/dist/bootstrap/project.mjs.map +1 -0
- package/dist/bootstrap/reader.mjs +259 -0
- package/dist/bootstrap/reader.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +154 -0
- package/dist/bootstrap/source-map.mjs.map +1 -0
- package/dist/bootstrap/symbol.mjs +74 -0
- package/dist/bootstrap/symbol.mjs.map +1 -0
- package/dist/bootstrap/syntax.mjs +38 -0
- package/dist/bootstrap/syntax.mjs.map +1 -0
- package/dist/bootstrap/transient-analysis.mjs +660 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -0
- package/dist/browser/compiler.js +6491 -0
- package/editor/README.md +83 -0
- package/editor/eliscript-mode.el +878 -0
- package/editor/eliscript-repl.el +501 -0
- package/package.json +163 -0
- package/platform/README.md +48 -0
- package/platform/browser.mjs +204 -0
- package/platform/worker.mjs +166 -0
- package/runtime/README.md +296 -0
- package/runtime/core/collection-internals.mjs +512 -0
- package/runtime/core/collection.mjs +645 -0
- package/runtime/core/data-text.mjs +532 -0
- package/runtime/core/data.mjs +268 -0
- package/runtime/core/identifier.mjs +314 -0
- package/runtime/core/lazy-sequence.mjs +244 -0
- package/runtime/core/list-internals.mjs +18 -0
- package/runtime/core/list.mjs +273 -0
- package/runtime/core/map-internals.mjs +793 -0
- package/runtime/core/map.mjs +394 -0
- package/runtime/core/metadata-internals.mjs +14 -0
- package/runtime/core/metadata.mjs +44 -0
- package/runtime/core/object-impl.mjs +65 -0
- package/runtime/core/object-impl.mjs.map +1 -0
- package/runtime/core/object.mjs +13 -0
- package/runtime/core/order.mjs +234 -0
- package/runtime/core/persistent-kind.mjs +43 -0
- package/runtime/core/protocol-error.mjs +36 -0
- package/runtime/core/protocol-impl.mjs +326 -0
- package/runtime/core/protocol-impl.mjs.map +1 -0
- package/runtime/core/protocol.mjs +14 -0
- package/runtime/core/queue-internals.mjs +27 -0
- package/runtime/core/queue.mjs +238 -0
- package/runtime/core/record.mjs +346 -0
- package/runtime/core/regex.mjs +184 -0
- package/runtime/core/sequence.mjs +632 -0
- package/runtime/core/set-algebra.mjs +287 -0
- package/runtime/core/set-internals.mjs +33 -0
- package/runtime/core/set.mjs +378 -0
- package/runtime/core/sorted-internals.mjs +215 -0
- package/runtime/core/sorted.mjs +598 -0
- package/runtime/core/text-impl.mjs +95 -0
- package/runtime/core/text-impl.mjs.map +1 -0
- package/runtime/core/text.mjs +15 -0
- package/runtime/core/transducer.mjs +668 -0
- package/runtime/core/transient-internals.mjs +38 -0
- package/runtime/core/transient.mjs +53 -0
- package/runtime/core/truth.mjs +3 -0
- package/runtime/core/type.mjs +262 -0
- package/runtime/core/value-internals.mjs +188 -0
- package/runtime/core/value.mjs +93 -0
- package/runtime/core/vector-internals.mjs +102 -0
- package/runtime/core/vector.mjs +951 -0
- package/runtime/literals.mjs +34 -0
- package/runtime/source-mapping.mjs +220 -0
- package/runtime/testing/list.mjs +52 -0
- package/runtime/testing/map.mjs +145 -0
- package/runtime/testing/queue.mjs +49 -0
- package/runtime/testing/set.mjs +61 -0
- package/runtime/testing/sorted.mjs +105 -0
- package/runtime/testing/value.mjs +17 -0
- package/runtime/testing/vector.mjs +102 -0
- package/runtime/worker-value-codec.mjs +565 -0
- package/runtime/worker-value-stream.mjs +786 -0
- package/runtime/worker.mjs +975 -0
- package/stdlib/README.md +774 -0
- package/stdlib/bit.eli +36 -0
- package/stdlib/core/collection.eli +134 -0
- package/stdlib/core/data-text.eli +16 -0
- package/stdlib/core/data.eli +306 -0
- package/stdlib/core/identifier.eli +32 -0
- package/stdlib/core/lazy-sequence.eli +63 -0
- package/stdlib/core/metadata.eli +20 -0
- package/stdlib/core/object.eli +89 -0
- package/stdlib/core/order.eli +133 -0
- package/stdlib/core/protocol.eli +387 -0
- package/stdlib/core/record.eli +16 -0
- package/stdlib/core/regex.eli +17 -0
- package/stdlib/core/seq.eli +701 -0
- package/stdlib/core/set.eli +312 -0
- package/stdlib/core/sorted.eli +53 -0
- package/stdlib/core/text.eli +103 -0
- package/stdlib/core/transducer.eli +59 -0
- package/stdlib/core/transient.eli +24 -0
- package/stdlib/core/type.eli +19 -0
- package/stdlib/core/walk.eli +195 -0
- package/stdlib/core/zipper.eli +508 -0
- package/stdlib/data-text.eli +1092 -0
- package/stdlib/data.eli +42 -0
- package/stdlib/deferred.eli +70 -0
- package/stdlib/function.eli +120 -0
- package/stdlib/hierarchy.eli +245 -0
- package/stdlib/identifier.eli +147 -0
- package/stdlib/interop/js.eli +616 -0
- package/stdlib/json.eli +870 -0
- package/stdlib/metadata.eli +56 -0
- package/stdlib/multimethod.eli +464 -0
- package/stdlib/numeric.eli +193 -0
- package/stdlib/object.eli +96 -0
- package/stdlib/persistent-list.eli +145 -0
- package/stdlib/persistent-map.eli +724 -0
- package/stdlib/persistent-queue.eli +32 -0
- package/stdlib/persistent-set.eli +236 -0
- package/stdlib/persistent-vector.eli +342 -0
- package/stdlib/result.eli +141 -0
- package/stdlib/sequence.eli +106 -0
- package/stdlib/state/atom.eli +265 -0
- package/stdlib/text.eli +88 -0
- package/stdlib/value.eli +325 -0
package/stdlib/value.eli
ADDED
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
(module eliscript.value
|
|
2
|
+
(import-portable "./bit.eli" rotate-left)
|
|
3
|
+
(import-portable "./persistent-list.eli"
|
|
4
|
+
persistent-list?
|
|
5
|
+
persistent-list-empty?
|
|
6
|
+
persistent-list-first
|
|
7
|
+
persistent-list-rest)
|
|
8
|
+
(import-portable "./persistent-vector.eli"
|
|
9
|
+
persistent-vector?
|
|
10
|
+
persistent-vector-count
|
|
11
|
+
persistent-vector-nth)
|
|
12
|
+
(import-portable "./persistent-map.eli"
|
|
13
|
+
empty-persistent-map
|
|
14
|
+
persistent-map?
|
|
15
|
+
persistent-map-count
|
|
16
|
+
persistent-map-has?
|
|
17
|
+
persistent-map-get
|
|
18
|
+
persistent-map-reduce
|
|
19
|
+
persistent-map-from-entries)
|
|
20
|
+
(import-portable "./persistent-set.eli"
|
|
21
|
+
empty-persistent-set
|
|
22
|
+
persistent-set?
|
|
23
|
+
persistent-set-count
|
|
24
|
+
persistent-set-has?
|
|
25
|
+
persistent-set-reduce
|
|
26
|
+
persistent-set-from-array)
|
|
27
|
+
|
|
28
|
+
(defconst value-boolean-tag 1260232563)
|
|
29
|
+
(defconst value-number-tag 374761393)
|
|
30
|
+
(defconst value-string-tag 1831565813)
|
|
31
|
+
(defconst value-host-tag 762272397)
|
|
32
|
+
(defconst value-list-tag 793406745)
|
|
33
|
+
(defconst value-vector-tag 1327180861)
|
|
34
|
+
(defconst value-map-tag 1821285621)
|
|
35
|
+
(defconst value-map-entry-tag 982610667)
|
|
36
|
+
(defconst value-set-tag 1374139181)
|
|
37
|
+
(defconst value-keyword-tag 795685287)
|
|
38
|
+
(defconst value-symbol-tag 1908952723)
|
|
39
|
+
(defconst value-unqualified-hash 1251063421)
|
|
40
|
+
|
|
41
|
+
(defconst value-false-hash 423263297)
|
|
42
|
+
(defconst value-true-hash 1911856395)
|
|
43
|
+
(defconst value-null-hash 1108378657)
|
|
44
|
+
(defconst value-undefined-hash 2135587861)
|
|
45
|
+
(defconst value-nan-hash 1490037359)
|
|
46
|
+
|
|
47
|
+
(defportable value-avalanche-hash (value)
|
|
48
|
+
(let ((hash (uint32 value)))
|
|
49
|
+
(setq hash (bit-xor hash (unsigned-bit-shift-right hash 16)))
|
|
50
|
+
(setq hash (imul32 hash 2246822507))
|
|
51
|
+
(setq hash (bit-xor hash (unsigned-bit-shift-right hash 13)))
|
|
52
|
+
(setq hash (imul32 hash 3266489909))
|
|
53
|
+
(setq hash (bit-xor hash (unsigned-bit-shift-right hash 16)))
|
|
54
|
+
(uint32 hash)))
|
|
55
|
+
|
|
56
|
+
(defportable value-mix-hash (hash value)
|
|
57
|
+
(let ((mixed (uint32 (bit-xor hash value))))
|
|
58
|
+
(setq mixed (imul32 mixed 1540483477))
|
|
59
|
+
(setq mixed
|
|
60
|
+
(bit-xor mixed (unsigned-bit-shift-right mixed 15)))
|
|
61
|
+
(uint32 mixed)))
|
|
62
|
+
|
|
63
|
+
(defportable value-finish-hash (hash count)
|
|
64
|
+
(value-avalanche-hash
|
|
65
|
+
(value-mix-hash hash (uint32 count))))
|
|
66
|
+
|
|
67
|
+
(defportable value-hash-string-with-tag (value tag)
|
|
68
|
+
(let ((hash (value-mix-hash tag (js-length value)))
|
|
69
|
+
(index 0))
|
|
70
|
+
(while (< index (js-length value))
|
|
71
|
+
(setq hash
|
|
72
|
+
(value-mix-hash
|
|
73
|
+
hash
|
|
74
|
+
(string-code-unit-at value index))
|
|
75
|
+
index (1+ index)))
|
|
76
|
+
(value-finish-hash hash (js-length value))))
|
|
77
|
+
|
|
78
|
+
(defportable value-hash-number (value)
|
|
79
|
+
(if (not (= value value))
|
|
80
|
+
value-nan-hash
|
|
81
|
+
(let ((words (number-float64-words value)))
|
|
82
|
+
(value-finish-hash
|
|
83
|
+
(value-mix-hash
|
|
84
|
+
(value-mix-hash value-number-tag (js-nth 0 words))
|
|
85
|
+
(js-nth 1 words))
|
|
86
|
+
2))))
|
|
87
|
+
|
|
88
|
+
(defportable value-list-equal? (left right)
|
|
89
|
+
(let ((left-node left)
|
|
90
|
+
(right-node right)
|
|
91
|
+
(result t))
|
|
92
|
+
(while (and result
|
|
93
|
+
(not (persistent-list-empty? left-node))
|
|
94
|
+
(not (persistent-list-empty? right-node)))
|
|
95
|
+
(setq result
|
|
96
|
+
(value-equal?
|
|
97
|
+
(persistent-list-first left-node nil)
|
|
98
|
+
(persistent-list-first right-node nil)))
|
|
99
|
+
(setq left-node (persistent-list-rest left-node nil)
|
|
100
|
+
right-node (persistent-list-rest right-node nil)))
|
|
101
|
+
(and result
|
|
102
|
+
(persistent-list-empty? left-node)
|
|
103
|
+
(persistent-list-empty? right-node))))
|
|
104
|
+
|
|
105
|
+
(defportable value-vector-equal? (left right)
|
|
106
|
+
(if (not (= (persistent-vector-count left)
|
|
107
|
+
(persistent-vector-count right)))
|
|
108
|
+
false
|
|
109
|
+
(let ((index 0)
|
|
110
|
+
(result t))
|
|
111
|
+
(while (and result (< index (persistent-vector-count left)))
|
|
112
|
+
(setq result
|
|
113
|
+
(value-equal?
|
|
114
|
+
(persistent-vector-nth left index nil)
|
|
115
|
+
(persistent-vector-nth right index nil))
|
|
116
|
+
index (1+ index)))
|
|
117
|
+
result)))
|
|
118
|
+
|
|
119
|
+
(defportable value-identifier-equal? (left right)
|
|
120
|
+
(and (= (get left :namespace) (get right :namespace))
|
|
121
|
+
(= (get left :name) (get right :name))))
|
|
122
|
+
|
|
123
|
+
(defportable value-logical-identifier? (value)
|
|
124
|
+
(let ((namespace (get value :namespace nil))
|
|
125
|
+
(name (get value :name nil)))
|
|
126
|
+
(and (= (value-type name) "string")
|
|
127
|
+
(or (nil? namespace)
|
|
128
|
+
(= (value-type namespace) "string")))))
|
|
129
|
+
|
|
130
|
+
(defportable value-map-equal? (left right)
|
|
131
|
+
(and (= (persistent-map-count left) (persistent-map-count right))
|
|
132
|
+
(persistent-map-reduce
|
|
133
|
+
(lambda (result key value)
|
|
134
|
+
(and result
|
|
135
|
+
(persistent-map-has? right key)
|
|
136
|
+
(value-equal?
|
|
137
|
+
value
|
|
138
|
+
(persistent-map-get right key nil))))
|
|
139
|
+
t
|
|
140
|
+
left)))
|
|
141
|
+
|
|
142
|
+
(defportable value-set-equal? (left right)
|
|
143
|
+
(and (= (persistent-set-count left) (persistent-set-count right))
|
|
144
|
+
(persistent-set-reduce
|
|
145
|
+
(lambda (result value)
|
|
146
|
+
(and result (persistent-set-has? right value)))
|
|
147
|
+
t
|
|
148
|
+
left)))
|
|
149
|
+
|
|
150
|
+
(defportable value-equal? (left right)
|
|
151
|
+
(if (= left right)
|
|
152
|
+
t
|
|
153
|
+
(let ((left-type (value-type left))
|
|
154
|
+
(right-type (value-type right)))
|
|
155
|
+
(if (not (= left-type right-type))
|
|
156
|
+
false
|
|
157
|
+
(cond
|
|
158
|
+
((= left-type "number")
|
|
159
|
+
(and (not (= left left)) (not (= right right))))
|
|
160
|
+
((or (= left-type "keyword") (= left-type "symbol"))
|
|
161
|
+
(and (value-logical-identifier? left)
|
|
162
|
+
(value-logical-identifier? right)
|
|
163
|
+
(value-identifier-equal? left right)))
|
|
164
|
+
((persistent-list? left)
|
|
165
|
+
(and (persistent-list? right)
|
|
166
|
+
(value-list-equal? left right)))
|
|
167
|
+
((persistent-vector? left)
|
|
168
|
+
(and (persistent-vector? right)
|
|
169
|
+
(value-vector-equal? left right)))
|
|
170
|
+
((persistent-map? left)
|
|
171
|
+
(and (persistent-map? right)
|
|
172
|
+
(value-map-equal? left right)))
|
|
173
|
+
((persistent-set? left)
|
|
174
|
+
(and (persistent-set? right)
|
|
175
|
+
(value-set-equal? left right)))
|
|
176
|
+
(t false))))))
|
|
177
|
+
|
|
178
|
+
(defportable value-list-hash (value)
|
|
179
|
+
(let ((hash value-list-tag)
|
|
180
|
+
(count 0)
|
|
181
|
+
(node value))
|
|
182
|
+
(while (not (persistent-list-empty? node))
|
|
183
|
+
(setq hash
|
|
184
|
+
(value-mix-hash
|
|
185
|
+
hash
|
|
186
|
+
(value-hash (persistent-list-first node nil)))
|
|
187
|
+
count (1+ count)
|
|
188
|
+
node (persistent-list-rest node nil)))
|
|
189
|
+
(value-finish-hash hash count)))
|
|
190
|
+
|
|
191
|
+
(defportable value-vector-hash (value)
|
|
192
|
+
(let ((hash value-vector-tag)
|
|
193
|
+
(index 0))
|
|
194
|
+
(while (< index (persistent-vector-count value))
|
|
195
|
+
(setq hash
|
|
196
|
+
(value-mix-hash
|
|
197
|
+
hash
|
|
198
|
+
(value-hash (persistent-vector-nth value index nil)))
|
|
199
|
+
index (1+ index)))
|
|
200
|
+
(value-finish-hash hash index)))
|
|
201
|
+
|
|
202
|
+
(defportable value-identifier-hash (value tag)
|
|
203
|
+
(value-finish-hash
|
|
204
|
+
(value-mix-hash
|
|
205
|
+
(value-mix-hash
|
|
206
|
+
tag
|
|
207
|
+
(if (= (get value :namespace) nil)
|
|
208
|
+
value-unqualified-hash
|
|
209
|
+
(value-hash-string-with-tag
|
|
210
|
+
(get value :namespace)
|
|
211
|
+
value-string-tag)))
|
|
212
|
+
(value-hash-string-with-tag (get value :name) value-string-tag))
|
|
213
|
+
2))
|
|
214
|
+
|
|
215
|
+
(defportable value-map-entry-hash (key value)
|
|
216
|
+
(value-finish-hash
|
|
217
|
+
(value-mix-hash
|
|
218
|
+
(value-mix-hash value-map-entry-tag (value-hash key))
|
|
219
|
+
(value-hash value))
|
|
220
|
+
2))
|
|
221
|
+
|
|
222
|
+
(defportable value-map-hash (value)
|
|
223
|
+
(let ((sum 0)
|
|
224
|
+
(xor 0)
|
|
225
|
+
(product 1)
|
|
226
|
+
(count 0))
|
|
227
|
+
(persistent-map-reduce
|
|
228
|
+
(lambda (_result key item-value)
|
|
229
|
+
(let ((hash (value-map-entry-hash key item-value)))
|
|
230
|
+
(setq sum (uint32 (+ sum hash))
|
|
231
|
+
xor
|
|
232
|
+
(uint32
|
|
233
|
+
(bit-xor xor (rotate-left hash (bit-and hash 31))))
|
|
234
|
+
product
|
|
235
|
+
(uint32 (imul32 product (bit-or hash 1)))
|
|
236
|
+
count (1+ count)))
|
|
237
|
+
nil)
|
|
238
|
+
nil
|
|
239
|
+
value)
|
|
240
|
+
(value-finish-hash
|
|
241
|
+
(value-mix-hash
|
|
242
|
+
(value-mix-hash
|
|
243
|
+
(value-mix-hash value-map-tag sum)
|
|
244
|
+
xor)
|
|
245
|
+
product)
|
|
246
|
+
count)))
|
|
247
|
+
|
|
248
|
+
(defportable value-set-hash (value)
|
|
249
|
+
(let ((sum 0)
|
|
250
|
+
(xor 0)
|
|
251
|
+
(product 1)
|
|
252
|
+
(count 0))
|
|
253
|
+
(persistent-set-reduce
|
|
254
|
+
(lambda (_result item-value)
|
|
255
|
+
(let ((hash (value-hash item-value)))
|
|
256
|
+
(setq sum (uint32 (+ sum hash))
|
|
257
|
+
xor
|
|
258
|
+
(uint32
|
|
259
|
+
(bit-xor xor (rotate-left hash (bit-and hash 31))))
|
|
260
|
+
product
|
|
261
|
+
(uint32 (imul32 product (bit-or hash 1)))
|
|
262
|
+
count (1+ count)))
|
|
263
|
+
nil)
|
|
264
|
+
nil
|
|
265
|
+
value)
|
|
266
|
+
(value-finish-hash
|
|
267
|
+
(value-mix-hash
|
|
268
|
+
(value-mix-hash
|
|
269
|
+
(value-mix-hash value-set-tag sum)
|
|
270
|
+
xor)
|
|
271
|
+
product)
|
|
272
|
+
count)))
|
|
273
|
+
|
|
274
|
+
(defportable value-hash-host (value)
|
|
275
|
+
(value-finish-hash
|
|
276
|
+
value-host-tag
|
|
277
|
+
(uint32 (host-identity-token value))))
|
|
278
|
+
|
|
279
|
+
(defportable value-hash (value)
|
|
280
|
+
(let ((type (value-type value)))
|
|
281
|
+
(cond
|
|
282
|
+
((= type "null") value-null-hash)
|
|
283
|
+
((= type "undefined") value-undefined-hash)
|
|
284
|
+
((= type "boolean")
|
|
285
|
+
(value-mix-hash
|
|
286
|
+
value-boolean-tag
|
|
287
|
+
(if value value-true-hash value-false-hash)))
|
|
288
|
+
((= type "number") (value-hash-number value))
|
|
289
|
+
((= type "string")
|
|
290
|
+
(value-hash-string-with-tag value value-string-tag))
|
|
291
|
+
((= type "keyword")
|
|
292
|
+
(if (value-logical-identifier? value)
|
|
293
|
+
(value-identifier-hash value value-keyword-tag)
|
|
294
|
+
(value-hash-host value)))
|
|
295
|
+
((= type "symbol")
|
|
296
|
+
(if (value-logical-identifier? value)
|
|
297
|
+
(value-identifier-hash value value-symbol-tag)
|
|
298
|
+
(value-hash-host value)))
|
|
299
|
+
((persistent-list? value) (value-list-hash value))
|
|
300
|
+
((persistent-vector? value) (value-vector-hash value))
|
|
301
|
+
((persistent-map? value) (value-map-hash value))
|
|
302
|
+
((persistent-set? value) (value-set-hash value))
|
|
303
|
+
((= type "bigint")
|
|
304
|
+
(value-hash-string-with-tag (str value) value-host-tag))
|
|
305
|
+
(t (value-hash-host value)))))
|
|
306
|
+
|
|
307
|
+
(defportable empty-value-map ()
|
|
308
|
+
(empty-persistent-map value-hash value-equal? value-equal?))
|
|
309
|
+
|
|
310
|
+
(defportable value-map-from-entries (entries)
|
|
311
|
+
(persistent-map-from-entries
|
|
312
|
+
value-hash value-equal? value-equal? entries))
|
|
313
|
+
|
|
314
|
+
(defportable empty-value-set ()
|
|
315
|
+
(empty-persistent-set value-hash value-equal?))
|
|
316
|
+
|
|
317
|
+
(defportable value-set-from-array (values)
|
|
318
|
+
(persistent-set-from-array value-hash value-equal? values))
|
|
319
|
+
|
|
320
|
+
(export value-equal?
|
|
321
|
+
value-hash
|
|
322
|
+
empty-value-map
|
|
323
|
+
value-map-from-entries
|
|
324
|
+
empty-value-set
|
|
325
|
+
value-set-from-array))
|