@calcit/procs 0.7.0-a1 → 0.7.0-a2
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/lib/calcit-data.mjs +3 -3
- package/lib/calcit.procs.mjs +31 -27
- package/lib/js-cirru.mjs +7 -6
- package/lib/js-tuple.mjs +5 -4
- package/package.json +1 -1
- package/ts-src/calcit-data.mts +3 -3
- package/ts-src/calcit.procs.mts +32 -27
- package/ts-src/js-cirru.mts +7 -6
- package/ts-src/js-record.mts +1 -1
- package/ts-src/js-tuple.mts +8 -5
package/lib/calcit-data.mjs
CHANGED
|
@@ -128,7 +128,7 @@ export function findInFields(xs, y) {
|
|
|
128
128
|
return -1;
|
|
129
129
|
}
|
|
130
130
|
var tagRegistery = {};
|
|
131
|
-
export let
|
|
131
|
+
export let newTag = (content) => {
|
|
132
132
|
let item = tagRegistery[content];
|
|
133
133
|
if (item != null) {
|
|
134
134
|
return item;
|
|
@@ -144,10 +144,10 @@ export let castTag = (x) => {
|
|
|
144
144
|
return x;
|
|
145
145
|
}
|
|
146
146
|
if (typeof x === "string") {
|
|
147
|
-
return
|
|
147
|
+
return newTag(x);
|
|
148
148
|
}
|
|
149
149
|
if (x instanceof CalcitSymbol) {
|
|
150
|
-
return
|
|
150
|
+
return newTag(x.value);
|
|
151
151
|
}
|
|
152
152
|
throw new Error(`Cannot cast this to tag: ${x}`);
|
|
153
153
|
};
|
package/lib/calcit.procs.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
// CALCIT VERSION
|
|
3
|
-
export const calcit_version = "0.7.0-
|
|
3
|
+
export const calcit_version = "0.7.0-a2";
|
|
4
4
|
import { parse } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
6
|
-
import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur,
|
|
6
|
+
import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
|
|
7
7
|
import { CalcitRecord } from "./js-record.mjs";
|
|
8
8
|
export * from "./calcit-data.mjs";
|
|
9
9
|
export * from "./js-record.mjs";
|
|
@@ -23,53 +23,53 @@ import { to_calcit_data, extract_cirru_edn, CalcitCirruQuote } from "./js-cirru.
|
|
|
23
23
|
let inNodeJs = typeof process !== "undefined" && ((_a = process === null || process === void 0 ? void 0 : process.release) === null || _a === void 0 ? void 0 : _a.name) === "node";
|
|
24
24
|
export let type_of = (x) => {
|
|
25
25
|
if (typeof x === "string") {
|
|
26
|
-
return
|
|
26
|
+
return newTag("string");
|
|
27
27
|
}
|
|
28
28
|
if (typeof x === "number") {
|
|
29
|
-
return
|
|
29
|
+
return newTag("number");
|
|
30
30
|
}
|
|
31
31
|
if (x instanceof CalcitTag) {
|
|
32
|
-
return
|
|
32
|
+
return newTag("tag");
|
|
33
33
|
}
|
|
34
34
|
if (x instanceof CalcitList || x instanceof CalcitSliceList) {
|
|
35
|
-
return
|
|
35
|
+
return newTag("list");
|
|
36
36
|
}
|
|
37
37
|
if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
|
|
38
|
-
return
|
|
38
|
+
return newTag("map");
|
|
39
39
|
}
|
|
40
40
|
if (x == null) {
|
|
41
|
-
return
|
|
41
|
+
return newTag("nil");
|
|
42
42
|
}
|
|
43
43
|
if (x instanceof CalcitRef) {
|
|
44
|
-
return
|
|
44
|
+
return newTag("ref");
|
|
45
45
|
}
|
|
46
46
|
if (x instanceof CalcitTuple) {
|
|
47
|
-
return
|
|
47
|
+
return newTag("tuple");
|
|
48
48
|
}
|
|
49
49
|
if (x instanceof CalcitSymbol) {
|
|
50
|
-
return
|
|
50
|
+
return newTag("symbol");
|
|
51
51
|
}
|
|
52
52
|
if (x instanceof CalcitSet) {
|
|
53
|
-
return
|
|
53
|
+
return newTag("set");
|
|
54
54
|
}
|
|
55
55
|
if (x instanceof CalcitRecord) {
|
|
56
|
-
return
|
|
56
|
+
return newTag("record");
|
|
57
57
|
}
|
|
58
58
|
if (x instanceof CalcitCirruQuote) {
|
|
59
|
-
return
|
|
59
|
+
return newTag("cirru-quote");
|
|
60
60
|
}
|
|
61
61
|
if (x === true || x === false) {
|
|
62
|
-
return
|
|
62
|
+
return newTag("bool");
|
|
63
63
|
}
|
|
64
64
|
if (typeof x === "function") {
|
|
65
65
|
if (x.isMacro) {
|
|
66
66
|
// this is faked...
|
|
67
|
-
return
|
|
67
|
+
return newTag("macro");
|
|
68
68
|
}
|
|
69
|
-
return
|
|
69
|
+
return newTag("fn");
|
|
70
70
|
}
|
|
71
71
|
if (typeof x === "object") {
|
|
72
|
-
return
|
|
72
|
+
return newTag("js-object");
|
|
73
73
|
}
|
|
74
74
|
throw new Error(`Unknown data ${x}`);
|
|
75
75
|
};
|
|
@@ -492,7 +492,7 @@ export let recur = (...xs) => {
|
|
|
492
492
|
return new CalcitRecur(xs);
|
|
493
493
|
};
|
|
494
494
|
export let _$n_get_calcit_backend = () => {
|
|
495
|
-
return
|
|
495
|
+
return newTag("js");
|
|
496
496
|
};
|
|
497
497
|
export let not = (x) => {
|
|
498
498
|
return !x;
|
|
@@ -674,7 +674,7 @@ export let _$n_merge = (a, b) => {
|
|
|
674
674
|
field = k;
|
|
675
675
|
}
|
|
676
676
|
else {
|
|
677
|
-
field =
|
|
677
|
+
field = newTag(getStringName(k));
|
|
678
678
|
}
|
|
679
679
|
let position = a.findIndex(field);
|
|
680
680
|
if (position >= 0) {
|
|
@@ -894,13 +894,13 @@ export let get_env = (name, v0) => {
|
|
|
894
894
|
};
|
|
895
895
|
export let turn_tag = (x) => {
|
|
896
896
|
if (typeof x === "string") {
|
|
897
|
-
return
|
|
897
|
+
return newTag(x);
|
|
898
898
|
}
|
|
899
899
|
if (x instanceof CalcitTag) {
|
|
900
900
|
return x;
|
|
901
901
|
}
|
|
902
902
|
if (x instanceof CalcitSymbol) {
|
|
903
|
-
return
|
|
903
|
+
return newTag(x.value);
|
|
904
904
|
}
|
|
905
905
|
console.error(x);
|
|
906
906
|
throw new Error("Unexpected data for tag");
|
|
@@ -1161,8 +1161,12 @@ export let _$n_js_object = (...xs) => {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
return ret;
|
|
1163
1163
|
};
|
|
1164
|
-
export let _$o__$o_ = (
|
|
1165
|
-
|
|
1164
|
+
export let _$o__$o_ = (tagName, ...extra) => {
|
|
1165
|
+
let klass = new CalcitRecord(newTag("base-class"), [], []);
|
|
1166
|
+
return new CalcitTuple(tagName, extra, klass);
|
|
1167
|
+
};
|
|
1168
|
+
export let _PCT__$o__$o_ = (klass, tag, ...extra) => {
|
|
1169
|
+
return new CalcitTuple(tag, extra, klass);
|
|
1166
1170
|
};
|
|
1167
1171
|
// mutable place for core to register
|
|
1168
1172
|
let calcit_builtin_classes = {
|
|
@@ -1192,8 +1196,8 @@ export function invoke_method(p, obj, ...args) {
|
|
|
1192
1196
|
klass = calcit_builtin_classes.nil;
|
|
1193
1197
|
}
|
|
1194
1198
|
else if (obj instanceof CalcitTuple) {
|
|
1195
|
-
if (obj.
|
|
1196
|
-
klass = obj.
|
|
1199
|
+
if (obj.klass instanceof CalcitRecord) {
|
|
1200
|
+
klass = obj.klass;
|
|
1197
1201
|
}
|
|
1198
1202
|
else {
|
|
1199
1203
|
throw new Error("Method invoking expected a record as class");
|
|
@@ -1322,7 +1326,7 @@ export let _$n_str_$o_pad_right = (s, size, pattern) => {
|
|
|
1322
1326
|
return s.padEnd(size, pattern);
|
|
1323
1327
|
};
|
|
1324
1328
|
export let _$n_get_os = () => {
|
|
1325
|
-
return
|
|
1329
|
+
return newTag("js-engine");
|
|
1326
1330
|
};
|
|
1327
1331
|
export let _$n_buffer = (...xs) => {
|
|
1328
1332
|
let buf = new Uint8Array(xs.length);
|
package/lib/js-cirru.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
|
|
|
4
4
|
import { CalcitRecord } from "./js-record.mjs";
|
|
5
5
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
6
6
|
import { CalcitSet } from "./js-set.mjs";
|
|
7
|
-
import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef,
|
|
7
|
+
import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef, newTag } from "./calcit-data.mjs";
|
|
8
8
|
import { CalcitTuple } from "./js-tuple.mjs";
|
|
9
9
|
export class CalcitCirruQuote {
|
|
10
10
|
constructor(value) {
|
|
@@ -140,10 +140,10 @@ export let to_cirru_edn = (x) => {
|
|
|
140
140
|
/** makes sure we got string */
|
|
141
141
|
let extractFieldTag = (x) => {
|
|
142
142
|
if (x[0] === ":") {
|
|
143
|
-
return
|
|
143
|
+
return newTag(x.slice(1));
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
|
-
return
|
|
146
|
+
return newTag(x);
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
export let extract_cirru_edn = (x) => {
|
|
@@ -164,7 +164,7 @@ export let extract_cirru_edn = (x) => {
|
|
|
164
164
|
return x.slice(1);
|
|
165
165
|
}
|
|
166
166
|
if (x[0] === ":") {
|
|
167
|
-
return
|
|
167
|
+
return newTag(x.slice(1));
|
|
168
168
|
}
|
|
169
169
|
if (x[0] === "'") {
|
|
170
170
|
return new CalcitSymbol(x.slice(1));
|
|
@@ -248,7 +248,8 @@ export let extract_cirru_edn = (x) => {
|
|
|
248
248
|
if (x.length < 3) {
|
|
249
249
|
throw new Error("tuple expects at least 2 values");
|
|
250
250
|
}
|
|
251
|
-
|
|
251
|
+
let baseClass = new CalcitRecord(newTag("base-class"), [], []);
|
|
252
|
+
return new CalcitTuple(extract_cirru_edn(x[1]), x.slice(2).map(extract_cirru_edn), baseClass);
|
|
252
253
|
}
|
|
253
254
|
}
|
|
254
255
|
console.error(x);
|
|
@@ -282,7 +283,7 @@ export let to_calcit_data = (x, noKeyword = false) => {
|
|
|
282
283
|
return x;
|
|
283
284
|
if (typeof x === "string") {
|
|
284
285
|
if (!noKeyword && x[0] === ":" && x.slice(1).match(/^[\w\d_\?\!\-]+$/)) {
|
|
285
|
-
return
|
|
286
|
+
return newTag(x.slice(1));
|
|
286
287
|
}
|
|
287
288
|
return x;
|
|
288
289
|
}
|
package/lib/js-tuple.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { toString } from "./calcit-data.mjs";
|
|
2
2
|
export class CalcitTuple {
|
|
3
|
-
constructor(
|
|
4
|
-
this.tag =
|
|
3
|
+
constructor(tagName, extra, klass) {
|
|
4
|
+
this.tag = tagName;
|
|
5
5
|
this.extra = extra;
|
|
6
|
+
this.klass = klass;
|
|
6
7
|
this.cachedHash = null;
|
|
7
8
|
}
|
|
8
9
|
get(n) {
|
|
@@ -18,12 +19,12 @@ export class CalcitTuple {
|
|
|
18
19
|
}
|
|
19
20
|
assoc(n, v) {
|
|
20
21
|
if (n === 0) {
|
|
21
|
-
return new CalcitTuple(v, this.extra);
|
|
22
|
+
return new CalcitTuple(v, this.extra, this.klass);
|
|
22
23
|
}
|
|
23
24
|
else if (n - 1 < this.extra.length) {
|
|
24
25
|
let next_extra = this.extra.slice();
|
|
25
26
|
next_extra[n - 1] = v;
|
|
26
|
-
return new CalcitTuple(this.tag, next_extra);
|
|
27
|
+
return new CalcitTuple(this.tag, next_extra, this.klass);
|
|
27
28
|
}
|
|
28
29
|
else {
|
|
29
30
|
throw new Error(`Tuple only have ${this.extra.length} elements`);
|
package/package.json
CHANGED
package/ts-src/calcit-data.mts
CHANGED
|
@@ -154,7 +154,7 @@ export function findInFields(xs: Array<CalcitTag>, y: CalcitTag): number {
|
|
|
154
154
|
|
|
155
155
|
var tagRegistery: Record<string, CalcitTag> = {};
|
|
156
156
|
|
|
157
|
-
export let
|
|
157
|
+
export let newTag = (content: string) => {
|
|
158
158
|
let item = tagRegistery[content];
|
|
159
159
|
if (item != null) {
|
|
160
160
|
return item;
|
|
@@ -170,10 +170,10 @@ export let castTag = (x: CalcitValue): CalcitTag => {
|
|
|
170
170
|
return x;
|
|
171
171
|
}
|
|
172
172
|
if (typeof x === "string") {
|
|
173
|
-
return
|
|
173
|
+
return newTag(x);
|
|
174
174
|
}
|
|
175
175
|
if (x instanceof CalcitSymbol) {
|
|
176
|
-
return
|
|
176
|
+
return newTag(x.value);
|
|
177
177
|
}
|
|
178
178
|
throw new Error(`Cannot cast this to tag: ${x}`);
|
|
179
179
|
};
|
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// CALCIT VERSION
|
|
2
|
-
export const calcit_version = "0.7.0-
|
|
2
|
+
export const calcit_version = "0.7.0-a2";
|
|
3
3
|
|
|
4
4
|
import { parse, ICirruNode } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
CalcitRef,
|
|
12
12
|
CalcitFn,
|
|
13
13
|
CalcitRecur,
|
|
14
|
-
|
|
14
|
+
newTag,
|
|
15
15
|
refsRegistry,
|
|
16
16
|
toString,
|
|
17
17
|
getStringName,
|
|
@@ -43,53 +43,53 @@ let inNodeJs = typeof process !== "undefined" && process?.release?.name === "nod
|
|
|
43
43
|
|
|
44
44
|
export let type_of = (x: any): CalcitTag => {
|
|
45
45
|
if (typeof x === "string") {
|
|
46
|
-
return
|
|
46
|
+
return newTag("string");
|
|
47
47
|
}
|
|
48
48
|
if (typeof x === "number") {
|
|
49
|
-
return
|
|
49
|
+
return newTag("number");
|
|
50
50
|
}
|
|
51
51
|
if (x instanceof CalcitTag) {
|
|
52
|
-
return
|
|
52
|
+
return newTag("tag");
|
|
53
53
|
}
|
|
54
54
|
if (x instanceof CalcitList || x instanceof CalcitSliceList) {
|
|
55
|
-
return
|
|
55
|
+
return newTag("list");
|
|
56
56
|
}
|
|
57
57
|
if (x instanceof CalcitMap || x instanceof CalcitSliceMap) {
|
|
58
|
-
return
|
|
58
|
+
return newTag("map");
|
|
59
59
|
}
|
|
60
60
|
if (x == null) {
|
|
61
|
-
return
|
|
61
|
+
return newTag("nil");
|
|
62
62
|
}
|
|
63
63
|
if (x instanceof CalcitRef) {
|
|
64
|
-
return
|
|
64
|
+
return newTag("ref");
|
|
65
65
|
}
|
|
66
66
|
if (x instanceof CalcitTuple) {
|
|
67
|
-
return
|
|
67
|
+
return newTag("tuple");
|
|
68
68
|
}
|
|
69
69
|
if (x instanceof CalcitSymbol) {
|
|
70
|
-
return
|
|
70
|
+
return newTag("symbol");
|
|
71
71
|
}
|
|
72
72
|
if (x instanceof CalcitSet) {
|
|
73
|
-
return
|
|
73
|
+
return newTag("set");
|
|
74
74
|
}
|
|
75
75
|
if (x instanceof CalcitRecord) {
|
|
76
|
-
return
|
|
76
|
+
return newTag("record");
|
|
77
77
|
}
|
|
78
78
|
if (x instanceof CalcitCirruQuote) {
|
|
79
|
-
return
|
|
79
|
+
return newTag("cirru-quote");
|
|
80
80
|
}
|
|
81
81
|
if (x === true || x === false) {
|
|
82
|
-
return
|
|
82
|
+
return newTag("bool");
|
|
83
83
|
}
|
|
84
84
|
if (typeof x === "function") {
|
|
85
85
|
if (x.isMacro) {
|
|
86
86
|
// this is faked...
|
|
87
|
-
return
|
|
87
|
+
return newTag("macro");
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return newTag("fn");
|
|
90
90
|
}
|
|
91
91
|
if (typeof x === "object") {
|
|
92
|
-
return
|
|
92
|
+
return newTag("js-object");
|
|
93
93
|
}
|
|
94
94
|
throw new Error(`Unknown data ${x}`);
|
|
95
95
|
};
|
|
@@ -554,7 +554,7 @@ export let recur = (...xs: CalcitValue[]): CalcitRecur => {
|
|
|
554
554
|
};
|
|
555
555
|
|
|
556
556
|
export let _$n_get_calcit_backend = () => {
|
|
557
|
-
return
|
|
557
|
+
return newTag("js");
|
|
558
558
|
};
|
|
559
559
|
|
|
560
560
|
export let not = (x: boolean): boolean => {
|
|
@@ -747,7 +747,7 @@ export let _$n_merge = (a: CalcitValue, b: CalcitMap | CalcitSliceMap): CalcitVa
|
|
|
747
747
|
if (k instanceof CalcitTag) {
|
|
748
748
|
field = k;
|
|
749
749
|
} else {
|
|
750
|
-
field =
|
|
750
|
+
field = newTag(getStringName(k));
|
|
751
751
|
}
|
|
752
752
|
let position = a.findIndex(field);
|
|
753
753
|
if (position >= 0) {
|
|
@@ -985,13 +985,13 @@ export let get_env = (name: string, v0: string): string => {
|
|
|
985
985
|
|
|
986
986
|
export let turn_tag = (x: CalcitValue): CalcitTag => {
|
|
987
987
|
if (typeof x === "string") {
|
|
988
|
-
return
|
|
988
|
+
return newTag(x);
|
|
989
989
|
}
|
|
990
990
|
if (x instanceof CalcitTag) {
|
|
991
991
|
return x;
|
|
992
992
|
}
|
|
993
993
|
if (x instanceof CalcitSymbol) {
|
|
994
|
-
return
|
|
994
|
+
return newTag(x.value);
|
|
995
995
|
}
|
|
996
996
|
console.error(x);
|
|
997
997
|
throw new Error("Unexpected data for tag");
|
|
@@ -1260,8 +1260,13 @@ export let _$n_js_object = (...xs: CalcitValue[]): Record<string, CalcitValue> =
|
|
|
1260
1260
|
return ret;
|
|
1261
1261
|
};
|
|
1262
1262
|
|
|
1263
|
-
export let _$o__$o_ = (
|
|
1264
|
-
|
|
1263
|
+
export let _$o__$o_ = (tagName: CalcitValue, ...extra: CalcitValue[]): CalcitTuple => {
|
|
1264
|
+
let klass = new CalcitRecord(newTag("base-class"), [], []);
|
|
1265
|
+
return new CalcitTuple(tagName, extra, klass);
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
export let _PCT__$o__$o_ = (klass: CalcitRecord, tag: CalcitValue, ...extra: CalcitValue[]): CalcitTuple => {
|
|
1269
|
+
return new CalcitTuple(tag, extra, klass);
|
|
1265
1270
|
};
|
|
1266
1271
|
|
|
1267
1272
|
// mutable place for core to register
|
|
@@ -1294,8 +1299,8 @@ export function invoke_method(p: string, obj: CalcitValue, ...args: CalcitValue[
|
|
|
1294
1299
|
if (obj == null) {
|
|
1295
1300
|
klass = calcit_builtin_classes.nil;
|
|
1296
1301
|
} else if (obj instanceof CalcitTuple) {
|
|
1297
|
-
if (obj.
|
|
1298
|
-
klass = obj.
|
|
1302
|
+
if (obj.klass instanceof CalcitRecord) {
|
|
1303
|
+
klass = obj.klass;
|
|
1299
1304
|
} else {
|
|
1300
1305
|
throw new Error("Method invoking expected a record as class");
|
|
1301
1306
|
}
|
|
@@ -1420,7 +1425,7 @@ export let _$n_str_$o_pad_right = (s: string, size: number, pattern: string): st
|
|
|
1420
1425
|
};
|
|
1421
1426
|
|
|
1422
1427
|
export let _$n_get_os = (): CalcitTag => {
|
|
1423
|
-
return
|
|
1428
|
+
return newTag("js-engine");
|
|
1424
1429
|
};
|
|
1425
1430
|
|
|
1426
1431
|
export let _$n_buffer = (...xs: CalcitValue[]): Uint8Array => {
|
package/ts-src/js-cirru.mts
CHANGED
|
@@ -6,7 +6,7 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
|
|
|
6
6
|
import { CalcitRecord } from "./js-record.mjs";
|
|
7
7
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
8
8
|
import { CalcitSet } from "./js-set.mjs";
|
|
9
|
-
import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef,
|
|
9
|
+
import { CalcitTag, CalcitSymbol, CalcitRecur, CalcitRef, newTag } from "./calcit-data.mjs";
|
|
10
10
|
import { CalcitTuple } from "./js-tuple.mjs";
|
|
11
11
|
|
|
12
12
|
type CirruEdnFormat = string | CirruEdnFormat[];
|
|
@@ -142,9 +142,9 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
|
|
|
142
142
|
/** makes sure we got string */
|
|
143
143
|
let extractFieldTag = (x: string) => {
|
|
144
144
|
if (x[0] === ":") {
|
|
145
|
-
return
|
|
145
|
+
return newTag(x.slice(1));
|
|
146
146
|
} else {
|
|
147
|
-
return
|
|
147
|
+
return newTag(x);
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
|
|
@@ -166,7 +166,7 @@ export let extract_cirru_edn = (x: CirruEdnFormat): CalcitValue => {
|
|
|
166
166
|
return x.slice(1);
|
|
167
167
|
}
|
|
168
168
|
if (x[0] === ":") {
|
|
169
|
-
return
|
|
169
|
+
return newTag(x.slice(1));
|
|
170
170
|
}
|
|
171
171
|
if (x[0] === "'") {
|
|
172
172
|
return new CalcitSymbol(x.slice(1));
|
|
@@ -249,7 +249,8 @@ export let extract_cirru_edn = (x: CirruEdnFormat): CalcitValue => {
|
|
|
249
249
|
if (x.length < 3) {
|
|
250
250
|
throw new Error("tuple expects at least 2 values");
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
let baseClass = new CalcitRecord(newTag("base-class"), [], []);
|
|
253
|
+
return new CalcitTuple(extract_cirru_edn(x[1]), x.slice(2).map(extract_cirru_edn), baseClass);
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
console.error(x);
|
|
@@ -285,7 +286,7 @@ export let to_calcit_data = (x: any, noKeyword: boolean = false): CalcitValue =>
|
|
|
285
286
|
|
|
286
287
|
if (typeof x === "string") {
|
|
287
288
|
if (!noKeyword && x[0] === ":" && x.slice(1).match(/^[\w\d_\?\!\-]+$/)) {
|
|
288
|
-
return
|
|
289
|
+
return newTag(x.slice(1));
|
|
289
290
|
}
|
|
290
291
|
return x;
|
|
291
292
|
}
|
package/ts-src/js-record.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { initTernaryTreeMap, Hash, insert } from "@calcit/ternary-tree";
|
|
2
2
|
import { CalcitValue } from "./js-primes.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { newTag, castTag, toString, CalcitTag, getStringName, findInFields } from "./calcit-data.mjs";
|
|
4
4
|
|
|
5
5
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
6
6
|
|
package/ts-src/js-tuple.mts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Hash } from "@calcit/ternary-tree";
|
|
2
2
|
|
|
3
3
|
import { CalcitValue } from "./js-primes.mjs";
|
|
4
|
-
import { toString } from "./calcit-data.mjs";
|
|
4
|
+
import { newTag, toString } from "./calcit-data.mjs";
|
|
5
|
+
import { CalcitRecord } from "./js-record.mjs";
|
|
5
6
|
|
|
6
7
|
export class CalcitTuple {
|
|
7
8
|
tag: CalcitValue;
|
|
8
9
|
extra: CalcitValue[];
|
|
10
|
+
klass: CalcitRecord;
|
|
9
11
|
cachedHash: Hash;
|
|
10
|
-
constructor(
|
|
11
|
-
this.tag =
|
|
12
|
+
constructor(tagName: CalcitValue, extra: CalcitValue[], klass: CalcitRecord) {
|
|
13
|
+
this.tag = tagName;
|
|
12
14
|
this.extra = extra;
|
|
15
|
+
this.klass = klass;
|
|
13
16
|
this.cachedHash = null;
|
|
14
17
|
}
|
|
15
18
|
get(n: number) {
|
|
@@ -23,11 +26,11 @@ export class CalcitTuple {
|
|
|
23
26
|
}
|
|
24
27
|
assoc(n: number, v: CalcitValue) {
|
|
25
28
|
if (n === 0) {
|
|
26
|
-
return new CalcitTuple(v, this.extra);
|
|
29
|
+
return new CalcitTuple(v, this.extra, this.klass);
|
|
27
30
|
} else if (n - 1 < this.extra.length) {
|
|
28
31
|
let next_extra = this.extra.slice();
|
|
29
32
|
next_extra[n - 1] = v;
|
|
30
|
-
return new CalcitTuple(this.tag, next_extra);
|
|
33
|
+
return new CalcitTuple(this.tag, next_extra, this.klass);
|
|
31
34
|
} else {
|
|
32
35
|
throw new Error(`Tuple only have ${this.extra.length} elements`);
|
|
33
36
|
}
|