@elaraai/east 1.0.97 → 1.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/src/builtins.d.ts +1 -1
- package/dist/src/builtins.d.ts.map +1 -1
- package/dist/src/builtins.js +14 -0
- package/dist/src/builtins.js.map +1 -1
- package/dist/src/codegen/spellings.d.ts.map +1 -1
- package/dist/src/codegen/spellings.js +2 -0
- package/dist/src/codegen/spellings.js.map +1 -1
- package/dist/src/comparison.d.ts +6 -5
- package/dist/src/comparison.d.ts.map +1 -1
- package/dist/src/comparison.js +6 -5
- package/dist/src/comparison.js.map +1 -1
- package/dist/src/compile/builtins/array.d.ts +4 -0
- package/dist/src/compile/builtins/array.d.ts.map +1 -1
- package/dist/src/compile/builtins/array.js +15 -1
- package/dist/src/compile/builtins/array.js.map +1 -1
- package/dist/src/compile/builtins/dict.d.ts +4 -0
- package/dist/src/compile/builtins/dict.d.ts.map +1 -1
- package/dist/src/compile/builtins/dict.js +14 -1
- package/dist/src/compile/builtins/dict.js.map +1 -1
- package/dist/src/compile/builtins/tree.d.ts +13 -0
- package/dist/src/compile/builtins/tree.d.ts.map +1 -1
- package/dist/src/compile/builtins/tree.js +27 -1
- package/dist/src/compile/builtins/tree.js.map +1 -1
- package/dist/src/compile/builtins/vector.d.ts +2 -2
- package/dist/src/compile/constructors.d.ts +6 -1
- package/dist/src/compile/constructors.d.ts.map +1 -1
- package/dist/src/compile/constructors.js +21 -11
- package/dist/src/compile/constructors.js.map +1 -1
- package/dist/src/compile/control.d.ts +7 -1
- package/dist/src/compile/control.d.ts.map +1 -1
- package/dist/src/compile/control.js +228 -146
- package/dist/src/compile/control.js.map +1 -1
- package/dist/src/compile/flow.d.ts +138 -0
- package/dist/src/compile/flow.d.ts.map +1 -0
- package/dist/src/compile/flow.js +358 -0
- package/dist/src/compile/flow.js.map +1 -0
- package/dist/src/compile/functions.d.ts +9 -1
- package/dist/src/compile/functions.d.ts.map +1 -1
- package/dist/src/compile/functions.js +62 -69
- package/dist/src/compile/functions.js.map +1 -1
- package/dist/src/compile/ir.d.ts +12 -0
- package/dist/src/compile/ir.d.ts.map +1 -1
- package/dist/src/compile/ir.js +164 -40
- package/dist/src/compile/ir.js.map +1 -1
- package/dist/src/compile/runtime.d.ts +2 -16
- package/dist/src/compile/runtime.d.ts.map +1 -1
- package/dist/src/compile/runtime.js +5 -40
- package/dist/src/compile/runtime.js.map +1 -1
- package/dist/src/compile.control_flow.spec.d.ts +6 -0
- package/dist/src/compile.control_flow.spec.d.ts.map +1 -0
- package/dist/src/compile.control_flow.spec.js +219 -0
- package/dist/src/compile.control_flow.spec.js.map +1 -0
- package/dist/src/compile.d.ts +1 -1
- package/dist/src/compile.d.ts.map +1 -1
- package/dist/src/compile.js +1 -1
- package/dist/src/compile.js.map +1 -1
- package/dist/src/eastir.d.ts.map +1 -1
- package/dist/src/eastir.js +8 -30
- package/dist/src/eastir.js.map +1 -1
- package/dist/src/expr/array.d.ts +39 -0
- package/dist/src/expr/array.d.ts.map +1 -1
- package/dist/src/expr/array.js +47 -0
- package/dist/src/expr/array.js.map +1 -1
- package/dist/src/expr/dict.d.ts +44 -1
- package/dist/src/expr/dict.d.ts.map +1 -1
- package/dist/src/expr/dict.js +54 -2
- package/dist/src/expr/dict.js.map +1 -1
- package/dist/src/expr/index.d.ts +130 -0
- package/dist/src/expr/index.d.ts.map +1 -1
- package/dist/src/expr/index.js +133 -0
- package/dist/src/expr/index.js.map +1 -1
- package/dist/src/expr/named.d.ts +100 -0
- package/dist/src/expr/named.d.ts.map +1 -0
- package/dist/src/expr/named.js +182 -0
- package/dist/src/expr/named.js.map +1 -0
- package/dist/src/functions.d.ts +21 -0
- package/dist/src/functions.d.ts.map +1 -1
- package/dist/src/functions.js +22 -41
- package/dist/src/functions.js.map +1 -1
- package/dist/src/internal.d.ts +1 -0
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +4 -0
- package/dist/src/internal.js.map +1 -1
- package/dist/src/ir_locations.d.ts +24 -0
- package/dist/src/ir_locations.d.ts.map +1 -0
- package/dist/src/ir_locations.js +58 -0
- package/dist/src/ir_locations.js.map +1 -0
- package/dist/src/location.d.ts +10 -0
- package/dist/src/location.d.ts.map +1 -1
- package/dist/src/location.js +19 -1
- package/dist/src/location.js.map +1 -1
- package/dist/src/query/jq/catalog.js +1 -1
- package/dist/src/query/jq/catalog.js.map +1 -1
- package/dist/src/query/jq/translate-builtins.d.ts.map +1 -1
- package/dist/src/query/jq/translate-builtins.js +11 -2
- package/dist/src/query/jq/translate-builtins.js.map +1 -1
- package/dist/src/query/jq/translate.d.ts +12 -0
- package/dist/src/query/jq/translate.d.ts.map +1 -1
- package/dist/src/query/jq/translate.js +40 -0
- package/dist/src/query/jq/translate.js.map +1 -1
- package/dist/src/runner_exec.d.ts +4 -1
- package/dist/src/runner_exec.d.ts.map +1 -1
- package/dist/src/runner_exec.js +24 -12
- package/dist/src/runner_exec.js.map +1 -1
- package/dist/src/runner_merge.d.ts +18 -0
- package/dist/src/runner_merge.d.ts.map +1 -1
- package/dist/src/runner_merge.js +36 -2
- package/dist/src/runner_merge.js.map +1 -1
- package/dist/src/serialization/beast2/decoded-function.spec.js +7 -4
- package/dist/src/serialization/beast2/decoded-function.spec.js.map +1 -1
- package/dist/src/serialization/beast2/shared.d.ts.map +1 -1
- package/dist/src/serialization/beast2/shared.js +6 -21
- package/dist/src/serialization/beast2/shared.js.map +1 -1
- package/dist/src/serialization/beast2/v4/container.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v4/container.js +3 -4
- package/dist/src/serialization/beast2/v4/container.js.map +1 -1
- package/dist/src/serialization/beast2/v4/type-table.d.ts +42 -14
- package/dist/src/serialization/beast2/v4/type-table.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v4/type-table.js +139 -53
- package/dist/src/serialization/beast2/v4/type-table.js.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.d.ts +29 -2
- package/dist/src/serialization/beast2/v5/codec.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/codec.js +153 -27
- package/dist/src/serialization/beast2/v5/codec.js.map +1 -1
- package/dist/src/serialization/beast2/v5/manifest.d.ts +3 -3
- package/dist/src/serialization/beast2/v5/manifest.js +3 -3
- package/dist/src/serialization/beast2/v5/runs.d.ts.map +1 -1
- package/dist/src/serialization/beast2/v5/runs.js +16 -4
- package/dist/src/serialization/beast2/v5/runs.js.map +1 -1
- package/dist/src/serialization/beast2/v5/source-maps.spec.d.ts +6 -0
- package/dist/src/serialization/beast2/v5/source-maps.spec.d.ts.map +1 -0
- package/dist/src/serialization/beast2/v5/source-maps.spec.js +81 -0
- package/dist/src/serialization/beast2/v5/source-maps.spec.js.map +1 -0
- package/dist/src/serialization/beast2/v5/type-section.js +1 -1
- package/dist/src/serialization/beast2/v5/type-section.js.map +1 -1
- package/dist/src/type_of_type.d.ts +12 -33
- package/dist/src/type_of_type.d.ts.map +1 -1
- package/dist/src/type_of_type.js +46 -174
- package/dist/src/type_of_type.js.map +1 -1
- package/dist/src/type_of_type.recursive_id.spec.d.ts +6 -0
- package/dist/src/type_of_type.recursive_id.spec.d.ts.map +1 -0
- package/dist/src/type_of_type.recursive_id.spec.js +86 -0
- package/dist/src/type_of_type.recursive_id.spec.js.map +1 -0
- package/dist/src/type_of_type.to_etv.spec.js +9 -9
- package/dist/src/type_of_type.to_etv.spec.js.map +1 -1
- package/dist/src/type_value_equal.d.ts +31 -0
- package/dist/src/type_value_equal.d.ts.map +1 -0
- package/dist/src/type_value_equal.js +170 -0
- package/dist/src/type_value_equal.js.map +1 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +3 -1
- package/dist/src/types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/runs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;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,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-maps.spec.d.ts","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/source-maps.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A closure keeps the lines it was written at, in whatever blob it is
|
|
7
|
+
* written. It carries its IR and its program's source map; a blob has one
|
|
8
|
+
* map — its header's stacks, then each closure's delta — which every closure
|
|
9
|
+
* decoded from it resolves against. A closure of another program adds the
|
|
10
|
+
* stacks the blob lacks, and is written with its locations where they stand
|
|
11
|
+
* in the blob's map. A self-contained stream writes its header before its
|
|
12
|
+
* elements, so a closure whose stacks the header lacks is written with no
|
|
13
|
+
* location — never another program's.
|
|
14
|
+
*/
|
|
15
|
+
import { describe, test } from "node:test";
|
|
16
|
+
import assert from "node:assert/strict";
|
|
17
|
+
import { ArrayType, FunctionType, IntegerType } from "../../../types.js";
|
|
18
|
+
import { East } from "../../../index.js";
|
|
19
|
+
import { EastError } from "../../../error.js";
|
|
20
|
+
import { EastIR } from "../../../eastir.js";
|
|
21
|
+
import { decodeBeast2For, encodeBeast2For, encodeBeast2PagedFor, encodeBeast2SegmentsFor } from "../index.js";
|
|
22
|
+
const Lookup = FunctionType([IntegerType], IntegerType);
|
|
23
|
+
const Lookups = ArrayType(Lookup);
|
|
24
|
+
/** Two programs, each returning a closure written on its own line. */
|
|
25
|
+
const programA = East.function([], Lookup, (_$) => East.function([IntegerType], IntegerType, (_$, x) => East.value([10n]).get(x))).toIR();
|
|
26
|
+
const programB = East.function([], Lookup, (_$) => East.function([IntegerType], IntegerType, (_$, x) => East.value([20n, 30n]).get(x))).toIR();
|
|
27
|
+
const a = programA.compile([])();
|
|
28
|
+
const b = programB.compile([])();
|
|
29
|
+
/** A closure whose program carries no map: its IR names locations nothing resolves. */
|
|
30
|
+
const bare = new EastIR(East.function([IntegerType], IntegerType, (_$, x) => East.value([40n]).get(x)).toIR().ir).compile([]);
|
|
31
|
+
/** Where the error a closure raises says it is. */
|
|
32
|
+
function raisedAt(fn) {
|
|
33
|
+
try {
|
|
34
|
+
fn(5n);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
if (err instanceof EastError)
|
|
38
|
+
return err.location;
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
throw new Error("expected the call to raise");
|
|
42
|
+
}
|
|
43
|
+
describe("a closure keeps the lines it was written at", () => {
|
|
44
|
+
test("closures of two programs in one value each keep their own, either way round", () => {
|
|
45
|
+
assert.ok(raisedAt(a).length > 0, "A's closure has a location");
|
|
46
|
+
assert.notDeepEqual(raisedAt(a), raisedAt(b), "two lines");
|
|
47
|
+
for (const value of [[a, b], [b, a], [a, b, b, a]]) {
|
|
48
|
+
const decoded = decodeBeast2For(Lookups)(encodeBeast2For(Lookups)(value));
|
|
49
|
+
decoded.forEach((fn, i) => assert.deepEqual(raisedAt(fn), raisedAt(value[i]), `closure ${i}`));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
test("a closure with no map is written with no location, whatever closure is beside it", () => {
|
|
53
|
+
for (const value of [[bare, a], [a, bare], [bare]]) {
|
|
54
|
+
const decoded = decodeBeast2For(Lookups)(encodeBeast2For(Lookups)(value));
|
|
55
|
+
decoded.forEach((fn, i) => assert.deepEqual(raisedAt(fn), value[i] === bare ? [] : raisedAt(a), `closure ${i}`));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
test("a decode then an encode gives back the bytes read", () => {
|
|
59
|
+
for (const value of [[a, a], [a, b], [bare, a], [bare]]) {
|
|
60
|
+
const blob = encodeBeast2For(Lookups)(value);
|
|
61
|
+
assert.deepEqual(encodeBeast2For(Lookups)(decodeBeast2For(Lookups)(blob)), blob);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
test("a stream of closures under their program's map keeps their lines, and without it writes none", () => {
|
|
65
|
+
const under = decodeBeast2For(Lookups)(encodeBeast2PagedFor(Lookups, { sourceMap: programA.source_map })([a, a]));
|
|
66
|
+
under.forEach((fn) => assert.deepEqual(raisedAt(fn), raisedAt(a)));
|
|
67
|
+
const without = decodeBeast2For(Lookups)(encodeBeast2PagedFor(Lookups)([a, a]));
|
|
68
|
+
without.forEach((fn) => assert.deepEqual(raisedAt(fn), []));
|
|
69
|
+
});
|
|
70
|
+
test("a stream writes a closure whose stacks its header lacks with no location, never the header program's", () => {
|
|
71
|
+
const decoded = decodeBeast2For(Lookups)(encodeBeast2PagedFor(Lookups, { sourceMap: programA.source_map })([a, b]));
|
|
72
|
+
assert.deepEqual(raisedAt(decoded[0]), raisedAt(a));
|
|
73
|
+
assert.deepEqual(raisedAt(decoded[1]), []);
|
|
74
|
+
});
|
|
75
|
+
test("a stream that is not self-contained writes a closure's missing stacks as its own", () => {
|
|
76
|
+
const blob = encodeBeast2SegmentsFor(Lookups, { selfContained: false, sourceMap: programA.source_map })([[a, b], [b]]);
|
|
77
|
+
const decoded = decodeBeast2For(Lookups)(blob);
|
|
78
|
+
assert.deepEqual(decoded.map(raisedAt), [raisedAt(a), raisedAt(b), raisedAt(b)]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=source-maps.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-maps.spec.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/source-maps.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,MAAM,M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,CAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,kFAAkF,EAAE,GAAG,EAAE;QAC5F,MAAM,IAAI,GAAG,uBAAuB,CAAC,OAAO,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvH,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -94,7 +94,7 @@ function structuralBytes(type) {
|
|
|
94
94
|
if (cached)
|
|
95
95
|
return cached;
|
|
96
96
|
const builder = new TypeTableBuilder();
|
|
97
|
-
const rootIdx = builder.add(type);
|
|
97
|
+
const rootIdx = builder.add(asTypeValue(type));
|
|
98
98
|
const writer = new BufferWriter();
|
|
99
99
|
writeTypeTableSection(rootIdx, builder.entries, writer);
|
|
100
100
|
const bytes = writer.toUint8Array();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-section.js","sourceRoot":"","sources":["../../../../../src/serialization/beast2/v5/type-section.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAsB,MAAM,0BAA0B,CAAC;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,YA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AK,CAAC,IAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,uDAAuD;gBACjG,GAAG,KAAK,CAAC,IAAI,8EAA8E,CAC5F,CAAC;QACJ,CAAC;QACD,uEAAuE;QACvE,oEAAoE;IACtE,CAAC;SAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,yCAAyC,EAAE,8CAA8C;YACzF,iGAAiG,CAClG,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,EAAE,QAAQ,EAAE,CAAC;AACtB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAA8B;IACxD,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAqB,CAAC,CAAC,CAAC,eAAe,CAAC,IAAgB,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ArrayType, BlobType, BooleanType, DateTimeType, FloatType, IntegerType, NullType, RecursiveType, StringType, StructType, VariantType, type EastType } from "./types.js";
|
|
6
6
|
import { variant } from "./containers/variant.js";
|
|
7
|
+
import { isTypeValueEqual } from "./type_value_equal.js";
|
|
8
|
+
export { isTypeValueEqual };
|
|
7
9
|
/** The type of primitive literal values in IR.
|
|
8
10
|
* Used to represent the values in ValueIR nodes.
|
|
9
11
|
*/
|
|
@@ -127,33 +129,6 @@ export declare const EastTypeValueType: EastTypeValue;
|
|
|
127
129
|
* the input.
|
|
128
130
|
*/
|
|
129
131
|
export declare function fromEastTypeValue(t: EastTypeValue): EastType;
|
|
130
|
-
/**
|
|
131
|
-
* Compares two EastTypeValue instances for type equality.
|
|
132
|
-
*
|
|
133
|
-
* @param t1 - First type value to compare
|
|
134
|
-
* @param t2 - Second type value to compare
|
|
135
|
-
* @returns `true` if the types are equal, `false` otherwise
|
|
136
|
-
*
|
|
137
|
-
* @remarks
|
|
138
|
-
* This is the {@link EastTypeValue} version of {@link isTypeEqual}.
|
|
139
|
-
*
|
|
140
|
-
* Recursive types compare up to the naming of their wrappers. A wrapper's
|
|
141
|
-
* `id` is a runtime artefact — a type id in the process that built the type,
|
|
142
|
-
* a table index for a type read back off the wire — and is not part of the
|
|
143
|
-
* type, so `wrapper({id: a, inner: A})` equals `wrapper({id: b, inner: B})`
|
|
144
|
-
* when `A` equals `B` with `ref(a)` standing for `ref(b)`. Within one scope
|
|
145
|
-
* `ref(N)` equals `ref(N)` and `wrapper({id: N})`: the same recursive type
|
|
146
|
-
* seen from inside and from outside its wrapper.
|
|
147
|
-
*
|
|
148
|
-
* Two recursive types with one id are one type, and their bodies are not
|
|
149
|
-
* read: within one build, its process numbers each recursive type once, by its
|
|
150
|
-
* structure, and the type checker compares types as large as a UI component's
|
|
151
|
-
* at every node. Two builds number theirs by their own counters, so a
|
|
152
|
-
* recursive type edited between two exports can keep its id. Compare types two
|
|
153
|
-
* builds made, as a deploy compares a package's with the one deployed before
|
|
154
|
-
* it, with {@link isTypeValueStructurallyEqual}.
|
|
155
|
-
*/
|
|
156
|
-
export declare function isTypeValueEqual(t1: EastTypeValue, t2: EastTypeValue): boolean;
|
|
157
132
|
/**
|
|
158
133
|
* Renames a type value's recursive types canonically: each `wrapper` is
|
|
159
134
|
* numbered in preorder from 0, and each `ref` takes the number of the
|
|
@@ -164,15 +139,19 @@ export declare function isTypeValueEqual(t1: EastTypeValue, t2: EastTypeValue):
|
|
|
164
139
|
* recursive ids depend on the type alone
|
|
165
140
|
*
|
|
166
141
|
* @remarks
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* segment manifest stores its collection's type, is
|
|
170
|
-
* equal types encode to equal bytes
|
|
171
|
-
*
|
|
142
|
+
* Every runtime writes a recursive type under a hash of its structure, but a
|
|
143
|
+
* type value read off the wire carries whatever ids its writer gave it. A type
|
|
144
|
+
* value stored as data, as a segment manifest stores its collection's type, is
|
|
145
|
+
* renamed first, so that equal types encode to equal bytes whichever runtime,
|
|
146
|
+
* or release, wrote the type it was read from. The numbering is the one
|
|
147
|
+
* east-c's IR normalizer gives a type.
|
|
172
148
|
*/
|
|
173
149
|
export declare function canonicalTypeValue(type: EastTypeValue): EastTypeValue;
|
|
174
150
|
export declare function isSubtypeValue(t1: EastTypeValue | string, t2: EastTypeValue | string, stack1?: EastTypeValue[], stack2?: EastTypeValue[]): boolean;
|
|
175
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* A copy of a type value. A `ref` names its wrapper by id wherever it sits, so
|
|
153
|
+
* a type read out of a recursive type's body needs no unfolding.
|
|
154
|
+
*/
|
|
176
155
|
export declare function expandTypeValue(type: EastTypeValue, root?: EastTypeValue, depth?: bigint): EastTypeValue;
|
|
177
156
|
/**
|
|
178
157
|
* Checks if an EastTypeValue represents a data type (serializable, no functions).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type_of_type.d.ts","sourceRoot":"","sources":["../../src/type_of_type.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAwB,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAuF,KAAK,QAAQ,EAA8C,MAAM,YAAY,CAAA;AACvU,OAAO,EAAa,OAAO,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"type_of_type.d.ts","sourceRoot":"","sources":["../../src/type_of_type.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAwB,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAuF,KAAK,QAAQ,EAA8C,MAAM,YAAY,CAAA;AACvU,OAAO,EAAa,OAAO,EAAE,MAAM,yBAA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Type, StringType, StructType, VariantType, RefType, SetType, DictType, FunctionType, AsyncFunctionType, VectorType, MatrixType, type_id_symbol, getTypeId, isPrimitiveType } from "./types.js";
|
|
6
6
|
import { isVariant, variant } from "./containers/variant.js";
|
|
7
|
+
import { isTypeValueEqual } from "./type_value_equal.js";
|
|
8
|
+
import { recursiveTypeId } from "./serialization/beast2/v4/type-table.js";
|
|
9
|
+
export { isTypeValueEqual };
|
|
7
10
|
/** The type of primitive literal values in IR.
|
|
8
11
|
* Used to represent the values in ValueIR nodes.
|
|
9
12
|
*/
|
|
@@ -52,6 +55,36 @@ export const EastTypeType = RecursiveType(type => VariantType({
|
|
|
52
55
|
// With type interning in types.ts, structurally identical EastType objects share
|
|
53
56
|
// the same type_id, so this cache ensures identity-based dedup of EastTypeValues.
|
|
54
57
|
const toEastTypeValueCache = new Map();
|
|
58
|
+
/** Each recursive type's id, by its type_id. Interning gives one recursive
|
|
59
|
+
* structure one type_id, so it is computed once per process. */
|
|
60
|
+
const recursiveIds = new Map();
|
|
61
|
+
/**
|
|
62
|
+
* The id a recursive type is written under: the hash of its type table
|
|
63
|
+
* (`recursiveTypeId`), so the same type has the same id in every process and
|
|
64
|
+
* runtime, whatever the process built before it.
|
|
65
|
+
*
|
|
66
|
+
* The table writes no id, so the type value hashed may name the type by
|
|
67
|
+
* anything. While its id is computed, its self-references name it by a
|
|
68
|
+
* negative number, which no hash is.
|
|
69
|
+
*/
|
|
70
|
+
function recursiveIdOf(type) {
|
|
71
|
+
const tid = getTypeId(type);
|
|
72
|
+
const known = recursiveIds.get(tid);
|
|
73
|
+
if (known !== undefined)
|
|
74
|
+
return known;
|
|
75
|
+
const provisional = -1n - BigInt(tid);
|
|
76
|
+
recursiveIds.set(tid, provisional);
|
|
77
|
+
try {
|
|
78
|
+
const inner = toEastTypeValueImpl(type.node, [type], false);
|
|
79
|
+
const id = recursiveTypeId(variant("Recursive", variant("wrapper", { id: provisional, inner })));
|
|
80
|
+
recursiveIds.set(tid, id);
|
|
81
|
+
return id;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
recursiveIds.delete(tid);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
55
88
|
export function toEastTypeValue(type, stack = [], is_recursive = false) {
|
|
56
89
|
if (typeof type === "string") {
|
|
57
90
|
return type;
|
|
@@ -149,16 +182,16 @@ function toEastTypeValueImpl(type, stack, _is_recursive) {
|
|
|
149
182
|
return ret;
|
|
150
183
|
}
|
|
151
184
|
else if (type.type === "Recursive") {
|
|
152
|
-
const
|
|
185
|
+
const id = recursiveIdOf(type);
|
|
153
186
|
// Self-reference: this RecursiveType is already on the stack.
|
|
154
187
|
if (stack.indexOf(type) !== -1) {
|
|
155
|
-
return variant("Recursive", variant("ref",
|
|
188
|
+
return variant("Recursive", variant("ref", id));
|
|
156
189
|
}
|
|
157
190
|
// First encounter: push, recurse into inner, produce wrapper.
|
|
158
191
|
stack.push(type);
|
|
159
192
|
const inner = toEastTypeValueImpl(type.node, stack, false);
|
|
160
193
|
stack.pop();
|
|
161
|
-
return variant("Recursive", variant("wrapper", { id
|
|
194
|
+
return variant("Recursive", variant("wrapper", { id, inner }));
|
|
162
195
|
}
|
|
163
196
|
else if (type.type === "Function") {
|
|
164
197
|
stack.push(type);
|
|
@@ -292,167 +325,6 @@ function fromImpl(t, ctx) {
|
|
|
292
325
|
}
|
|
293
326
|
throw new Error(`fromEastTypeValue: unhandled tag "${tag}"`);
|
|
294
327
|
}
|
|
295
|
-
const isTypeValueEqualCache = new Map();
|
|
296
|
-
/**
|
|
297
|
-
* Compares two EastTypeValue instances for type equality.
|
|
298
|
-
*
|
|
299
|
-
* @param t1 - First type value to compare
|
|
300
|
-
* @param t2 - Second type value to compare
|
|
301
|
-
* @returns `true` if the types are equal, `false` otherwise
|
|
302
|
-
*
|
|
303
|
-
* @remarks
|
|
304
|
-
* This is the {@link EastTypeValue} version of {@link isTypeEqual}.
|
|
305
|
-
*
|
|
306
|
-
* Recursive types compare up to the naming of their wrappers. A wrapper's
|
|
307
|
-
* `id` is a runtime artefact — a type id in the process that built the type,
|
|
308
|
-
* a table index for a type read back off the wire — and is not part of the
|
|
309
|
-
* type, so `wrapper({id: a, inner: A})` equals `wrapper({id: b, inner: B})`
|
|
310
|
-
* when `A` equals `B` with `ref(a)` standing for `ref(b)`. Within one scope
|
|
311
|
-
* `ref(N)` equals `ref(N)` and `wrapper({id: N})`: the same recursive type
|
|
312
|
-
* seen from inside and from outside its wrapper.
|
|
313
|
-
*
|
|
314
|
-
* Two recursive types with one id are one type, and their bodies are not
|
|
315
|
-
* read: within one build, its process numbers each recursive type once, by its
|
|
316
|
-
* structure, and the type checker compares types as large as a UI component's
|
|
317
|
-
* at every node. Two builds number theirs by their own counters, so a
|
|
318
|
-
* recursive type edited between two exports can keep its id. Compare types two
|
|
319
|
-
* builds made, as a deploy compares a package's with the one deployed before
|
|
320
|
-
* it, with {@link isTypeValueStructurallyEqual}.
|
|
321
|
-
*/
|
|
322
|
-
export function isTypeValueEqual(t1, t2) {
|
|
323
|
-
return typeValueEqual(t1, t2, []);
|
|
324
|
-
}
|
|
325
|
-
/** The id a `Recursive` payload names — the wrapper's own id, or a ref's. */
|
|
326
|
-
function recursiveId(payload) {
|
|
327
|
-
return payload.type === "ref" ? payload.value : payload.value.id;
|
|
328
|
-
}
|
|
329
|
-
function typeValueEqual(t1, t2, env) {
|
|
330
|
-
// Fast path: reference equality
|
|
331
|
-
if (t1 === t2)
|
|
332
|
-
return true;
|
|
333
|
-
// Fast path: type_id equality
|
|
334
|
-
const tid1 = getTypeId(t1);
|
|
335
|
-
const tid2 = getTypeId(t2);
|
|
336
|
-
if (tid1 !== undefined && tid1 === tid2)
|
|
337
|
-
return true;
|
|
338
|
-
// Recursive ref/wrapper equivalence: ref(N) and wrapper({id: N, inner})
|
|
339
|
-
// denote the same recursive type when the ids match, or when the ids are a
|
|
340
|
-
// pair of wrappers this comparison has already entered (alpha-equivalence).
|
|
341
|
-
if (t1.type === "Recursive" && t2.type === "Recursive") {
|
|
342
|
-
const id1 = recursiveId(t1.value);
|
|
343
|
-
const id2 = recursiveId(t2.value);
|
|
344
|
-
if (id1 === id2)
|
|
345
|
-
return true;
|
|
346
|
-
for (const [left, right] of env) {
|
|
347
|
-
if (left === id1 && right === id2)
|
|
348
|
-
return true;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
// Check cache. Stamped values carry this process's type ids, under which
|
|
352
|
-
// structurally equal recursive types share one id, so their answer does not
|
|
353
|
-
// depend on `env`.
|
|
354
|
-
if (tid1 !== undefined && tid2 !== undefined) {
|
|
355
|
-
const innerCache = isTypeValueEqualCache.get(tid1);
|
|
356
|
-
if (innerCache) {
|
|
357
|
-
const cached = innerCache.get(tid2);
|
|
358
|
-
if (cached !== undefined)
|
|
359
|
-
return cached;
|
|
360
|
-
}
|
|
361
|
-
const result = typeValueEqualImpl(t1, t2, env);
|
|
362
|
-
let cache = isTypeValueEqualCache.get(tid1);
|
|
363
|
-
if (!cache) {
|
|
364
|
-
cache = new Map();
|
|
365
|
-
isTypeValueEqualCache.set(tid1, cache);
|
|
366
|
-
}
|
|
367
|
-
cache.set(tid2, result);
|
|
368
|
-
return result;
|
|
369
|
-
}
|
|
370
|
-
return typeValueEqualImpl(t1, t2, env);
|
|
371
|
-
}
|
|
372
|
-
/** Structural comparison that uses typeValueEqual for children (handles ref/wrapper). */
|
|
373
|
-
function typeValueEqualImpl(t1, t2, env) {
|
|
374
|
-
if (t1.type !== t2.type)
|
|
375
|
-
return false;
|
|
376
|
-
switch (t1.type) {
|
|
377
|
-
case "Never":
|
|
378
|
-
case "Null":
|
|
379
|
-
case "Boolean":
|
|
380
|
-
case "Integer":
|
|
381
|
-
case "Float":
|
|
382
|
-
case "String":
|
|
383
|
-
case "DateTime":
|
|
384
|
-
case "Blob":
|
|
385
|
-
return true;
|
|
386
|
-
case "Ref":
|
|
387
|
-
case "Array":
|
|
388
|
-
case "Vector":
|
|
389
|
-
case "Matrix":
|
|
390
|
-
return typeValueEqual(t1.value, t2.value, env);
|
|
391
|
-
case "Set":
|
|
392
|
-
return typeValueEqual(t1.value, t2.value, env);
|
|
393
|
-
case "Dict":
|
|
394
|
-
return typeValueEqual(t1.value.key, t2.value.key, env) &&
|
|
395
|
-
typeValueEqual(t1.value.value, t2.value.value, env);
|
|
396
|
-
case "Struct": {
|
|
397
|
-
const f1 = t1.value;
|
|
398
|
-
const f2 = t2.value;
|
|
399
|
-
if (f1.length !== f2.length)
|
|
400
|
-
return false;
|
|
401
|
-
for (let i = 0; i < f1.length; i++) {
|
|
402
|
-
if (f1[i].name !== f2[i].name)
|
|
403
|
-
return false;
|
|
404
|
-
if (!typeValueEqual(f1[i].type, f2[i].type, env))
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
return true;
|
|
408
|
-
}
|
|
409
|
-
case "Variant": {
|
|
410
|
-
const c1 = t1.value;
|
|
411
|
-
const c2 = t2.value;
|
|
412
|
-
if (c1.length !== c2.length)
|
|
413
|
-
return false;
|
|
414
|
-
for (let i = 0; i < c1.length; i++) {
|
|
415
|
-
if (c1[i].name !== c2[i].name)
|
|
416
|
-
return false;
|
|
417
|
-
if (!typeValueEqual(c1[i].type, c2[i].type, env))
|
|
418
|
-
return false;
|
|
419
|
-
}
|
|
420
|
-
return true;
|
|
421
|
-
}
|
|
422
|
-
case "Function":
|
|
423
|
-
case "AsyncFunction": {
|
|
424
|
-
const fn1 = t1.value;
|
|
425
|
-
const fn2 = t2.value;
|
|
426
|
-
if (fn1.inputs.length !== fn2.inputs.length)
|
|
427
|
-
return false;
|
|
428
|
-
for (let i = 0; i < fn1.inputs.length; i++) {
|
|
429
|
-
if (!typeValueEqual(fn1.inputs[i], fn2.inputs[i], env))
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
return typeValueEqual(fn1.output, fn2.output, env);
|
|
433
|
-
}
|
|
434
|
-
case "Recursive": {
|
|
435
|
-
const v1 = t1.value;
|
|
436
|
-
const v2 = t2.value;
|
|
437
|
-
// Same or paired ids were answered by typeValueEqual. Two wrappers
|
|
438
|
-
// with different ids are equal when their bodies are, with each body's
|
|
439
|
-
// refs standing for its own wrapper; a ref and a wrapper of different
|
|
440
|
-
// ids, or two refs of different ids, are different scopes.
|
|
441
|
-
if (v1.type === "wrapper" && v2.type === "wrapper") {
|
|
442
|
-
env.push([v1.value.id, v2.value.id]);
|
|
443
|
-
try {
|
|
444
|
-
return typeValueEqual(v1.value.inner, v2.value.inner, env);
|
|
445
|
-
}
|
|
446
|
-
finally {
|
|
447
|
-
env.pop();
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
return false;
|
|
451
|
-
}
|
|
452
|
-
default:
|
|
453
|
-
return false;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
328
|
/**
|
|
457
329
|
* Renames a type value's recursive types canonically: each `wrapper` is
|
|
458
330
|
* numbered in preorder from 0, and each `ref` takes the number of the
|
|
@@ -463,11 +335,12 @@ function typeValueEqualImpl(t1, t2, env) {
|
|
|
463
335
|
* recursive ids depend on the type alone
|
|
464
336
|
*
|
|
465
337
|
* @remarks
|
|
466
|
-
*
|
|
467
|
-
*
|
|
468
|
-
* segment manifest stores its collection's type, is
|
|
469
|
-
* equal types encode to equal bytes
|
|
470
|
-
*
|
|
338
|
+
* Every runtime writes a recursive type under a hash of its structure, but a
|
|
339
|
+
* type value read off the wire carries whatever ids its writer gave it. A type
|
|
340
|
+
* value stored as data, as a segment manifest stores its collection's type, is
|
|
341
|
+
* renamed first, so that equal types encode to equal bytes whichever runtime,
|
|
342
|
+
* or release, wrote the type it was read from. The numbering is the one
|
|
343
|
+
* east-c's IR normalizer gives a type.
|
|
471
344
|
*/
|
|
472
345
|
export function canonicalTypeValue(type) {
|
|
473
346
|
let next = 0n;
|
|
@@ -738,7 +611,10 @@ function isSubtypeValueImpl(t1, t2, stack1, stack2) {
|
|
|
738
611
|
}
|
|
739
612
|
// Cache for memoizing expandTypeValue results (top-level calls only)
|
|
740
613
|
const expandTypeValueCache = new Map();
|
|
741
|
-
/**
|
|
614
|
+
/**
|
|
615
|
+
* A copy of a type value. A `ref` names its wrapper by id wherever it sits, so
|
|
616
|
+
* a type read out of a recursive type's body needs no unfolding.
|
|
617
|
+
*/
|
|
742
618
|
export function expandTypeValue(type, root = type, depth = 0n) {
|
|
743
619
|
// Fast path: primitive types cannot contain recursive references
|
|
744
620
|
if (type.type === "Never" || type.type === "Null" || type.type === "Boolean" ||
|
|
@@ -805,10 +681,6 @@ function expandTypeValueImpl(type, root, depth) {
|
|
|
805
681
|
output: expandTypeValue(type.value.output, root, depth + 1n),
|
|
806
682
|
});
|
|
807
683
|
}
|
|
808
|
-
else if (type.type === "Recursive" && type.value.type === "ref" && depth === type.value.value) {
|
|
809
|
-
// Unfold once (self-reference at matching depth)
|
|
810
|
-
return root;
|
|
811
|
-
}
|
|
812
684
|
else if (type.type === "Recursive" && type.value.type === "wrapper") {
|
|
813
685
|
// Recursive wrapper: expand the inner type
|
|
814
686
|
return variant("Recursive", variant("wrapper", { id: type.value.value.id, inner: expandTypeValue(type.value.value.inner, root, depth) }));
|