@calcit/procs 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/install-state.gz +0 -0
- package/editing-history/202608061340-release-0.13.1.md +6 -0
- package/editing-history/202608061714-struct-enum-data-model-v2.md +39 -0
- package/editing-history/202608061731-release-0.13.2.md +18 -0
- package/history/202608061335-recursive-nominal-display.md +28 -0
- package/history/202608061433-required-record-field-access.md +32 -0
- package/lib/calcit-data.mjs +24 -24
- package/lib/calcit.procs.d.mts +43 -43
- package/lib/calcit.procs.mjs +165 -168
- package/lib/custom-formatter.mjs +38 -27
- package/lib/js-cirru.mjs +25 -25
- package/lib/js-enum-def.d.mts +11 -0
- package/lib/{js-enum.mjs → js-enum-def.mjs} +3 -3
- package/lib/{js-tuple.d.mts → js-enum-value.d.mts} +6 -7
- package/lib/{js-tuple.mjs → js-enum-value.mjs} +8 -15
- package/lib/js-list.mjs +6 -6
- package/lib/js-primes.d.mts +5 -5
- package/lib/js-primes.mjs +16 -16
- package/lib/{js-struct.d.mts → js-struct-def.d.mts} +2 -2
- package/lib/{js-struct.mjs → js-struct-def.mjs} +6 -6
- package/lib/{js-record.d.mts → js-struct-value.d.mts} +16 -15
- package/lib/{js-record.mjs → js-struct-value.mjs} +67 -59
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/ts-src/calcit-data.mts +24 -24
- package/ts-src/calcit.procs.mts +165 -168
- package/ts-src/custom-formatter.mts +65 -40
- package/ts-src/js-cirru.mts +26 -26
- package/ts-src/{js-enum.mts → js-enum-def.mts} +7 -7
- package/ts-src/{js-tuple.mts → js-enum-value.mts} +12 -19
- package/ts-src/js-list.mts +6 -6
- package/ts-src/js-primes.mts +16 -16
- package/ts-src/{js-struct.mts → js-struct-def.mts} +7 -7
- package/ts-src/{js-record.mts → js-struct-value.mts} +72 -66
- package/lib/js-enum.d.mts +0 -11
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CalcitImpl } from "./js-impl.mjs";
|
|
2
2
|
import { newTag, castTag, toString, getStringName, findInFields } from "./calcit-data.mjs";
|
|
3
3
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
4
|
-
import {
|
|
5
|
-
export class
|
|
4
|
+
import { CalcitStructDef } from "./js-struct-def.mjs";
|
|
5
|
+
export class CalcitStructValue {
|
|
6
6
|
constructor(name, fields, values, structRef) {
|
|
7
7
|
this.name = name;
|
|
8
8
|
let fieldNames = fields.map(castTag);
|
|
@@ -17,7 +17,7 @@ export class CalcitRecord {
|
|
|
17
17
|
this.values = new Array(fieldNames.length);
|
|
18
18
|
}
|
|
19
19
|
this.cachedHash = null;
|
|
20
|
-
this.structRef = structRef || new
|
|
20
|
+
this.structRef = structRef || new CalcitStructDef(name, fields, new Array(fields.length).fill(null));
|
|
21
21
|
}
|
|
22
22
|
get(k) {
|
|
23
23
|
let field = castTag(k);
|
|
@@ -29,6 +29,12 @@ export class CalcitRecord {
|
|
|
29
29
|
return undefined;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
getRequired(k) {
|
|
33
|
+
const value = this.get(k);
|
|
34
|
+
if (value !== undefined)
|
|
35
|
+
return value;
|
|
36
|
+
throw new Error(`struct '${this.name.value}' does not define field ${castTag(k).toString()}`);
|
|
37
|
+
}
|
|
32
38
|
getOrNil(k) {
|
|
33
39
|
let field = castTag(k);
|
|
34
40
|
let idx = findInFields(this.fields, field);
|
|
@@ -50,7 +56,7 @@ export class CalcitRecord {
|
|
|
50
56
|
values[idx] = this.values[idx];
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
|
-
return new
|
|
59
|
+
return new CalcitStructValue(this.name, this.fields, values, this.structRef);
|
|
54
60
|
}
|
|
55
61
|
/** return -1 for missing */
|
|
56
62
|
findIndex(k) {
|
|
@@ -64,7 +70,7 @@ export class CalcitRecord {
|
|
|
64
70
|
}
|
|
65
71
|
toString(disableJsDataWarning = false) {
|
|
66
72
|
// Optimize string building using array join instead of concatenation
|
|
67
|
-
const parts = ["(%{} ", this.name.
|
|
73
|
+
const parts = this.name.value === "_" ? ["(%{} _"] : ["(%{} '", this.name.value];
|
|
68
74
|
for (let idx = 0; idx < this.fields.length; idx++) {
|
|
69
75
|
parts.push(" (", this.fields[idx].toString(), " ", toString(this.values[idx], true, disableJsDataWarning), ")");
|
|
70
76
|
}
|
|
@@ -82,11 +88,11 @@ export class CalcitRecord {
|
|
|
82
88
|
else {
|
|
83
89
|
throw new Error("Expected an impl or array of impls");
|
|
84
90
|
}
|
|
85
|
-
let nextStruct = new
|
|
86
|
-
return new
|
|
91
|
+
let nextStruct = new CalcitStructDef(this.name, this.fields, this.structRef.fieldTypes, this.structRef.impls.concat(nextImpls));
|
|
92
|
+
return new CalcitStructValue(this.name, this.fields, this.values, nextStruct);
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
|
-
export let
|
|
95
|
+
export let new_struct_value = (name, ...fields) => {
|
|
90
96
|
let fieldNames = fields.map(castTag).sort((x, y) => {
|
|
91
97
|
if (x.idx < y.idx) {
|
|
92
98
|
return -1;
|
|
@@ -95,12 +101,12 @@ export let new_record = (name, ...fields) => {
|
|
|
95
101
|
return 1;
|
|
96
102
|
}
|
|
97
103
|
else {
|
|
98
|
-
throw new Error(`Unexpected duplication in
|
|
104
|
+
throw new Error(`Unexpected duplication in struct fields: ${x.toString()}`);
|
|
99
105
|
}
|
|
100
106
|
});
|
|
101
|
-
return new
|
|
107
|
+
return new CalcitStructValue(castTag(name), fieldNames);
|
|
102
108
|
};
|
|
103
|
-
export let
|
|
109
|
+
export let new_impl_struct_value = (impl, name, ...fields) => {
|
|
104
110
|
let fieldNames = fields.map(castTag).sort((x, y) => {
|
|
105
111
|
if (x.idx < y.idx) {
|
|
106
112
|
return -1;
|
|
@@ -109,12 +115,12 @@ export let new_impl_record = (impl, name, ...fields) => {
|
|
|
109
115
|
return 1;
|
|
110
116
|
}
|
|
111
117
|
else {
|
|
112
|
-
throw new Error(`Unexpected duplication in
|
|
118
|
+
throw new Error(`Unexpected duplication in struct fields: ${x.toString()}`);
|
|
113
119
|
}
|
|
114
120
|
});
|
|
115
121
|
let nameTag = castTag(name);
|
|
116
|
-
let structRef = new
|
|
117
|
-
return new
|
|
122
|
+
let structRef = new CalcitStructDef(nameTag, fieldNames, new Array(fieldNames.length).fill(null), [impl]);
|
|
123
|
+
return new CalcitStructValue(nameTag, fieldNames, undefined, structRef);
|
|
118
124
|
};
|
|
119
125
|
/** Loose record: `?{} :field1 val1 :field2 val2` – record without a declared struct.
|
|
120
126
|
* Fields are sorted by tag index. The record name is "?" (sentinel). */
|
|
@@ -135,8 +141,8 @@ export let _$q__$M_ = (...xs) => {
|
|
|
135
141
|
}
|
|
136
142
|
let fieldNames = pairs.map((p) => p[0]);
|
|
137
143
|
let values = pairs.map((p) => p[1]);
|
|
138
|
-
let looseTag = newTag("
|
|
139
|
-
return new
|
|
144
|
+
let looseTag = newTag("_");
|
|
145
|
+
return new CalcitStructValue(looseTag, fieldNames, values);
|
|
140
146
|
};
|
|
141
147
|
export let fieldsEqual = (xs, ys) => {
|
|
142
148
|
if (xs === ys) {
|
|
@@ -154,14 +160,14 @@ export let fieldsEqual = (xs, ys) => {
|
|
|
154
160
|
};
|
|
155
161
|
export let _$n__PCT__$M_ = (proto, ...xs) => {
|
|
156
162
|
let recordProto;
|
|
157
|
-
if (proto instanceof
|
|
163
|
+
if (proto instanceof CalcitStructValue) {
|
|
158
164
|
recordProto = proto;
|
|
159
165
|
}
|
|
160
|
-
else if (proto instanceof
|
|
161
|
-
recordProto = new
|
|
166
|
+
else if (proto instanceof CalcitStructDef) {
|
|
167
|
+
recordProto = new CalcitStructValue(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
|
|
162
168
|
}
|
|
163
169
|
else {
|
|
164
|
-
throw new Error("Expected prototype to be a
|
|
170
|
+
throw new Error("Expected prototype to be a StructDef");
|
|
165
171
|
}
|
|
166
172
|
{
|
|
167
173
|
if (xs.length % 2 !== 0) {
|
|
@@ -181,21 +187,21 @@ export let _$n__PCT__$M_ = (proto, ...xs) => {
|
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
189
|
if (idx < 0) {
|
|
184
|
-
throw new Error("invalid field name for this
|
|
190
|
+
throw new Error("invalid field name for this struct");
|
|
185
191
|
}
|
|
186
192
|
if (values[i] != null) {
|
|
187
|
-
throw new Error("
|
|
193
|
+
throw new Error("struct field already has value, probably duplicated key");
|
|
188
194
|
}
|
|
189
195
|
values[i] = xs[idx * 2 + 1];
|
|
190
196
|
}
|
|
191
|
-
return new
|
|
197
|
+
return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
|
|
192
198
|
}
|
|
193
199
|
};
|
|
194
200
|
export let _$n__PCT__$M__$q_ = (proto, ...xs) => {
|
|
195
201
|
let recordProto;
|
|
196
202
|
let values;
|
|
197
|
-
if (proto instanceof
|
|
198
|
-
recordProto = new
|
|
203
|
+
if (proto instanceof CalcitStructDef) {
|
|
204
|
+
recordProto = new CalcitStructValue(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
|
|
199
205
|
values = recordProto.values.slice();
|
|
200
206
|
}
|
|
201
207
|
else {
|
|
@@ -212,16 +218,16 @@ export let _$n__PCT__$M__$q_ = (proto, ...xs) => {
|
|
|
212
218
|
throw new Error(`Cannot find field ${k} among ${recordProto.fields}`);
|
|
213
219
|
}
|
|
214
220
|
if (touched.has(idx)) {
|
|
215
|
-
throw new Error(`
|
|
221
|
+
throw new Error(`struct field already has value, probably duplicated key: ${k}`);
|
|
216
222
|
}
|
|
217
223
|
touched.add(idx);
|
|
218
224
|
values[idx] = xs[i + 1];
|
|
219
225
|
}
|
|
220
|
-
return new
|
|
226
|
+
return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
|
|
221
227
|
};
|
|
222
228
|
/// update record with new values
|
|
223
|
-
export let _$
|
|
224
|
-
if (proto instanceof
|
|
229
|
+
export let _$n_struct_$o_with = (proto, ...xs) => {
|
|
230
|
+
if (proto instanceof CalcitStructValue) {
|
|
225
231
|
if (xs.length % 2 !== 0) {
|
|
226
232
|
throw new Error("Expected even number of key/value");
|
|
227
233
|
}
|
|
@@ -235,39 +241,41 @@ export let _$n_record_$o_with = (proto, ...xs) => {
|
|
|
235
241
|
}
|
|
236
242
|
values[idx] = v;
|
|
237
243
|
}
|
|
238
|
-
return new
|
|
244
|
+
return new CalcitStructValue(proto.name, proto.fields, values, proto.structRef);
|
|
239
245
|
}
|
|
240
246
|
else {
|
|
241
|
-
throw new Error("Expected prototype to be a
|
|
247
|
+
throw new Error("Expected prototype to be a StructDef");
|
|
242
248
|
}
|
|
243
249
|
};
|
|
244
|
-
export let _$
|
|
245
|
-
if (x instanceof
|
|
250
|
+
export let _$n_struct_$o_get_name = (x) => {
|
|
251
|
+
if (x instanceof CalcitStructValue) {
|
|
246
252
|
return x.name;
|
|
247
253
|
}
|
|
248
254
|
else {
|
|
249
|
-
throw new Error("Expected a
|
|
255
|
+
throw new Error("Expected a struct value");
|
|
250
256
|
}
|
|
251
257
|
};
|
|
252
|
-
export let _$
|
|
253
|
-
if (x instanceof
|
|
258
|
+
export let _$n_struct_$o_definition = (x) => {
|
|
259
|
+
if (x instanceof CalcitStructValue) {
|
|
260
|
+
if (x.name.value === "_")
|
|
261
|
+
return null;
|
|
254
262
|
return x.structRef ?? null;
|
|
255
263
|
}
|
|
256
264
|
else {
|
|
257
|
-
throw new Error("Expected a
|
|
265
|
+
throw new Error("Expected a struct value");
|
|
258
266
|
}
|
|
259
267
|
};
|
|
260
|
-
export let _$
|
|
268
|
+
export let _$n_struct_$o_from_map = (proto, data) => {
|
|
261
269
|
let recordProto;
|
|
262
|
-
if (proto instanceof
|
|
263
|
-
recordProto = new
|
|
270
|
+
if (proto instanceof CalcitStructDef) {
|
|
271
|
+
recordProto = new CalcitStructValue(proto.name, proto.fields, new Array(proto.fields.length).fill(null), proto);
|
|
264
272
|
}
|
|
265
273
|
else {
|
|
266
274
|
throw new Error("Expected prototype to be struct");
|
|
267
275
|
}
|
|
268
|
-
if (data instanceof
|
|
276
|
+
if (data instanceof CalcitStructValue) {
|
|
269
277
|
if (fieldsEqual(recordProto.fields, data.fields)) {
|
|
270
|
-
return new
|
|
278
|
+
return new CalcitStructValue(recordProto.name, recordProto.fields, data.values, recordProto.structRef);
|
|
271
279
|
}
|
|
272
280
|
else {
|
|
273
281
|
let values = [];
|
|
@@ -279,7 +287,7 @@ export let _$n_record_$o_from_map = (proto, data) => {
|
|
|
279
287
|
}
|
|
280
288
|
values.push(data.values[idx]);
|
|
281
289
|
}
|
|
282
|
-
return new
|
|
290
|
+
return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
|
|
283
291
|
}
|
|
284
292
|
}
|
|
285
293
|
else if (data instanceof CalcitMap || data instanceof CalcitSliceMap) {
|
|
@@ -304,14 +312,14 @@ export let _$n_record_$o_from_map = (proto, data) => {
|
|
|
304
312
|
}
|
|
305
313
|
throw new Error(`Cannot find field ${field} among ${pairs_buffer}`);
|
|
306
314
|
}
|
|
307
|
-
return new
|
|
315
|
+
return new CalcitStructValue(recordProto.name, recordProto.fields, values, recordProto.structRef);
|
|
308
316
|
}
|
|
309
317
|
else {
|
|
310
|
-
throw new Error("Expected
|
|
318
|
+
throw new Error("Expected a struct value or data for making a struct");
|
|
311
319
|
}
|
|
312
320
|
};
|
|
313
|
-
export let _$
|
|
314
|
-
if (x instanceof
|
|
321
|
+
export let _$n_struct_$o_to_map = (x) => {
|
|
322
|
+
if (x instanceof CalcitStructValue) {
|
|
315
323
|
var dict = [];
|
|
316
324
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
317
325
|
dict.push(x.fields[idx], x.values[idx]);
|
|
@@ -319,35 +327,35 @@ export let _$n_record_$o_to_map = (x) => {
|
|
|
319
327
|
return new CalcitSliceMap(dict);
|
|
320
328
|
}
|
|
321
329
|
else {
|
|
322
|
-
throw new Error("Expected
|
|
330
|
+
throw new Error("Expected a struct value");
|
|
323
331
|
}
|
|
324
332
|
};
|
|
325
|
-
export let _$
|
|
333
|
+
export let _$n_struct_$o_matches_$q_ = (x, y) => {
|
|
326
334
|
let targetStruct;
|
|
327
|
-
if (y instanceof
|
|
335
|
+
if (y instanceof CalcitStructValue) {
|
|
328
336
|
targetStruct = y.structRef;
|
|
329
337
|
}
|
|
330
|
-
else if (y instanceof
|
|
338
|
+
else if (y instanceof CalcitStructDef) {
|
|
331
339
|
targetStruct = y;
|
|
332
340
|
}
|
|
333
341
|
else {
|
|
334
|
-
throw new Error("Expected second argument to be
|
|
342
|
+
throw new Error("Expected second argument to be a struct value or StructDef");
|
|
335
343
|
}
|
|
336
|
-
if (x instanceof
|
|
344
|
+
if (x instanceof CalcitStructValue) {
|
|
337
345
|
if (x.name !== targetStruct.name) {
|
|
338
346
|
return false;
|
|
339
347
|
}
|
|
340
348
|
return fieldsEqual(x.fields, targetStruct.fields);
|
|
341
349
|
}
|
|
342
350
|
else {
|
|
343
|
-
throw new Error("Expected first argument to be
|
|
351
|
+
throw new Error("Expected first argument to be a struct value");
|
|
344
352
|
}
|
|
345
353
|
};
|
|
346
|
-
export function _$
|
|
354
|
+
export function _$n_struct_$o_extend_as(obj, new_name, new_key, new_value) {
|
|
347
355
|
if (arguments.length !== 4)
|
|
348
356
|
throw new Error(`Expected 4 arguments, got ${arguments.length}`);
|
|
349
|
-
if (!(obj instanceof
|
|
350
|
-
throw new Error("Expected
|
|
357
|
+
if (!(obj instanceof CalcitStructValue))
|
|
358
|
+
throw new Error("Expected a struct value");
|
|
351
359
|
let field = castTag(new_key);
|
|
352
360
|
let new_name_tag = castTag(new_name);
|
|
353
361
|
let new_fields = [];
|
|
@@ -372,7 +380,7 @@ export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
|
|
|
372
380
|
new_values.push(obj.values[i]);
|
|
373
381
|
}
|
|
374
382
|
else {
|
|
375
|
-
throw new Error("
|
|
383
|
+
throw new Error("Cannot extend an existing struct field");
|
|
376
384
|
}
|
|
377
385
|
}
|
|
378
386
|
}
|
|
@@ -380,5 +388,5 @@ export function _$n_record_$o_extend_as(obj, new_name, new_key, new_value) {
|
|
|
380
388
|
new_fields.push(field);
|
|
381
389
|
new_values.push(new_value);
|
|
382
390
|
}
|
|
383
|
-
return new
|
|
391
|
+
return new CalcitStructValue(new_name_tag, new_fields, new_values);
|
|
384
392
|
}
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
package/ts-src/calcit-data.mts
CHANGED
|
@@ -3,16 +3,16 @@ import { overwriteComparator, initTernaryTreeMap } from "@calcit/ternary-tree";
|
|
|
3
3
|
import { overwriteMapComparator } from "./js-map.mjs";
|
|
4
4
|
import { disableListStructureCheck } from "@calcit/ternary-tree";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { CalcitStructValue, fieldsEqual } from "./js-struct-value.mjs";
|
|
7
7
|
import { CalcitImpl } from "./js-impl.mjs";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { CalcitStructDef } from "./js-struct-def.mjs";
|
|
9
|
+
import { CalcitEnumDef } from "./js-enum-def.mjs";
|
|
10
10
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
11
11
|
|
|
12
12
|
import { CalcitValue, _$n_compare } from "./js-primes.mjs";
|
|
13
13
|
import { CalcitList, CalcitSliceList } from "./js-list.mjs";
|
|
14
14
|
import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
|
|
15
|
-
import {
|
|
15
|
+
import { CalcitEnumValue } from "./js-enum-value.mjs";
|
|
16
16
|
import { CalcitTrait } from "./js-trait.mjs";
|
|
17
17
|
import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
|
|
18
18
|
import { CirruWriterNode } from "@cirru/writer.ts";
|
|
@@ -80,7 +80,7 @@ export let isNestedCalcitData = (x: CalcitValue): boolean => {
|
|
|
80
80
|
if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
|
|
81
81
|
return x.len() > 0;
|
|
82
82
|
}
|
|
83
|
-
if (x instanceof
|
|
83
|
+
if (x instanceof CalcitStructValue) {
|
|
84
84
|
return x.fields.length > 0;
|
|
85
85
|
}
|
|
86
86
|
if (x instanceof CalcitImpl) {
|
|
@@ -99,7 +99,7 @@ export let tipNestedCalcitData = (x: CalcitValue): string => {
|
|
|
99
99
|
if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
|
|
100
100
|
return "'{}...";
|
|
101
101
|
}
|
|
102
|
-
if (x instanceof
|
|
102
|
+
if (x instanceof CalcitStructValue) {
|
|
103
103
|
return "'%{}...";
|
|
104
104
|
}
|
|
105
105
|
if (x instanceof CalcitImpl) {
|
|
@@ -256,7 +256,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
256
256
|
x.cachedHash = h;
|
|
257
257
|
return h;
|
|
258
258
|
}
|
|
259
|
-
if (x instanceof
|
|
259
|
+
if (x instanceof CalcitEnumValue) {
|
|
260
260
|
let base = defaultHash_tuple;
|
|
261
261
|
base = mergeValueHash(base, hashFunction(x.tag));
|
|
262
262
|
for (let idx = 0; idx < x.extra.length; idx++) {
|
|
@@ -322,7 +322,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
322
322
|
x.cachedHash = base;
|
|
323
323
|
return base;
|
|
324
324
|
}
|
|
325
|
-
if (x instanceof
|
|
325
|
+
if (x instanceof CalcitStructValue) {
|
|
326
326
|
let base = defaultHash_record;
|
|
327
327
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
328
328
|
base = mergeValueHash(base, hashFunction(x.fields[idx]));
|
|
@@ -344,7 +344,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
344
344
|
x.cachedHash = base;
|
|
345
345
|
return base;
|
|
346
346
|
}
|
|
347
|
-
if (x instanceof
|
|
347
|
+
if (x instanceof CalcitStructDef) {
|
|
348
348
|
let base = defaultHash_struct;
|
|
349
349
|
base = mergeValueHash(base, hashFunction(x.name));
|
|
350
350
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
@@ -357,7 +357,7 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
357
357
|
x.cachedHash = base;
|
|
358
358
|
return base;
|
|
359
359
|
}
|
|
360
|
-
if (x instanceof
|
|
360
|
+
if (x instanceof CalcitEnumDef) {
|
|
361
361
|
let base = defaultHash_enum;
|
|
362
362
|
base = mergeValueHash(base, hashFunction(x.prototype));
|
|
363
363
|
for (let impl of x.impls) {
|
|
@@ -441,16 +441,16 @@ export let toString = (x: CalcitValue, escaped: boolean, disableJsDataWarning: b
|
|
|
441
441
|
if (x instanceof CalcitSet) {
|
|
442
442
|
return x.toString(disableJsDataWarning);
|
|
443
443
|
}
|
|
444
|
-
if (x instanceof
|
|
444
|
+
if (x instanceof CalcitStructValue) {
|
|
445
445
|
return x.toString(disableJsDataWarning);
|
|
446
446
|
}
|
|
447
447
|
if (x instanceof CalcitImpl) {
|
|
448
448
|
return x.toString(disableJsDataWarning);
|
|
449
449
|
}
|
|
450
|
-
if (x instanceof
|
|
450
|
+
if (x instanceof CalcitStructDef) {
|
|
451
451
|
return x.toString(disableJsDataWarning);
|
|
452
452
|
}
|
|
453
|
-
if (x instanceof
|
|
453
|
+
if (x instanceof CalcitEnumDef) {
|
|
454
454
|
return x.toString();
|
|
455
455
|
}
|
|
456
456
|
if (x instanceof CalcitTrait) {
|
|
@@ -459,7 +459,7 @@ export let toString = (x: CalcitValue, escaped: boolean, disableJsDataWarning: b
|
|
|
459
459
|
if (x instanceof CalcitRef) {
|
|
460
460
|
return x.toString();
|
|
461
461
|
}
|
|
462
|
-
if (x instanceof
|
|
462
|
+
if (x instanceof CalcitEnumValue) {
|
|
463
463
|
return x.toString(disableJsDataWarning);
|
|
464
464
|
}
|
|
465
465
|
if (x instanceof CalcitCirruQuote) {
|
|
@@ -532,7 +532,7 @@ let to_js_data_inner = (x: CalcitValue, addColon: boolean): any => {
|
|
|
532
532
|
}
|
|
533
533
|
return Symbol(x.value);
|
|
534
534
|
}
|
|
535
|
-
if (x instanceof
|
|
535
|
+
if (x instanceof CalcitEnumValue) {
|
|
536
536
|
var result: any[] = [to_js_data_inner(x.tag, false)];
|
|
537
537
|
for (let i = 0; i < x.extra.length; i++) {
|
|
538
538
|
let item = x.extra[i];
|
|
@@ -565,7 +565,7 @@ let to_js_data_inner = (x: CalcitValue, addColon: boolean): any => {
|
|
|
565
565
|
});
|
|
566
566
|
return result;
|
|
567
567
|
}
|
|
568
|
-
if (x instanceof
|
|
568
|
+
if (x instanceof CalcitStructValue) {
|
|
569
569
|
let result: Record<string, CalcitValue> = {};
|
|
570
570
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
571
571
|
result[x.fields[idx].value] = to_js_data_inner(x.values[idx], false);
|
|
@@ -693,8 +693,8 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
|
|
|
693
693
|
}
|
|
694
694
|
return false;
|
|
695
695
|
}
|
|
696
|
-
if (x instanceof
|
|
697
|
-
if (y instanceof
|
|
696
|
+
if (x instanceof CalcitEnumValue) {
|
|
697
|
+
if (y instanceof CalcitEnumValue) {
|
|
698
698
|
return x.eq(y);
|
|
699
699
|
}
|
|
700
700
|
return false;
|
|
@@ -743,8 +743,8 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
|
|
|
743
743
|
}
|
|
744
744
|
return false;
|
|
745
745
|
}
|
|
746
|
-
if (x instanceof
|
|
747
|
-
if (y instanceof
|
|
746
|
+
if (x instanceof CalcitStructValue) {
|
|
747
|
+
if (y instanceof CalcitStructValue) {
|
|
748
748
|
if (x.name !== y.name) {
|
|
749
749
|
return false;
|
|
750
750
|
}
|
|
@@ -789,14 +789,14 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
|
|
|
789
789
|
}
|
|
790
790
|
return false;
|
|
791
791
|
}
|
|
792
|
-
if (x instanceof
|
|
793
|
-
if (y instanceof
|
|
792
|
+
if (x instanceof CalcitStructDef) {
|
|
793
|
+
if (y instanceof CalcitStructDef) {
|
|
794
794
|
return x.name === y.name && fieldsEqual(x.fields, y.fields);
|
|
795
795
|
}
|
|
796
796
|
return false;
|
|
797
797
|
}
|
|
798
|
-
if (x instanceof
|
|
799
|
-
if (y instanceof
|
|
798
|
+
if (x instanceof CalcitEnumDef) {
|
|
799
|
+
if (y instanceof CalcitEnumDef) {
|
|
800
800
|
return x.name === y.name;
|
|
801
801
|
}
|
|
802
802
|
return false;
|