@nudojs/core 1.1.4 → 1.2.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/dist/{check-report-AtnAfY9U.d.ts → check-report-0B9Z66n0.d.ts} +1 -1
- package/dist/{chunk-SQSO4NKT.js → chunk-4V3CRVSD.js} +931 -396
- package/dist/{chunk-XOHKHJHE.js → chunk-TOURNNEA.js} +34 -34
- package/dist/exec.d.ts +2 -2
- package/dist/exec.js +33 -25
- package/dist/{hof-types-tAeoYvzY.d.ts → hof-types-DqDpAxfh.d.ts} +17 -3
- package/dist/{index-D4rnOHre.d.ts → index-BNiZvVHw.d.ts} +53 -40
- package/dist/index.d.ts +37 -20
- package/dist/index.js +61 -50
- package/dist/internal.d.ts +26 -26
- package/dist/internal.js +16 -16
- package/package.json +1 -1
|
@@ -30,7 +30,9 @@ function termEquals(a, b) {
|
|
|
30
30
|
}
|
|
31
31
|
function termToString(t) {
|
|
32
32
|
if (t.op === "lit") {
|
|
33
|
-
|
|
33
|
+
if (typeof t.value === "string") return JSON.stringify(t.value);
|
|
34
|
+
if (typeof t.value === "number" && Object.is(t.value, -0)) return "-0";
|
|
35
|
+
return String(t.value);
|
|
34
36
|
}
|
|
35
37
|
if (t.op === "var") return t.id;
|
|
36
38
|
if (t.op === "app" && t.fn === "get" && t.args.length === 2) {
|
|
@@ -62,12 +64,22 @@ function simplifyTerm(t) {
|
|
|
62
64
|
}
|
|
63
65
|
if (fn === "*" && args.length === 2) {
|
|
64
66
|
const [a, b] = args;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
const one = (t2) => t2.op === "lit" && t2.value === 1;
|
|
68
|
+
const surviveMulOne = (t2) => {
|
|
69
|
+
if (t2.op !== "lit") return t2;
|
|
70
|
+
const v2 = t2.value;
|
|
71
|
+
if (typeof v2 === "number") return t2;
|
|
72
|
+
if (typeof v2 === "boolean") return lit(v2 ? 1 : 0);
|
|
73
|
+
if (v2 === null) return lit(0);
|
|
74
|
+
if (typeof v2 === "string") return lit(Number(v2));
|
|
75
|
+
return lit(NaN);
|
|
76
|
+
};
|
|
77
|
+
if (one(b)) return surviveMulOne(a);
|
|
78
|
+
if (one(a)) return surviveMulOne(b);
|
|
67
79
|
}
|
|
68
80
|
if (fn === "-" && args.length === 2) {
|
|
69
81
|
const [a, b] = args;
|
|
70
|
-
if (b.op === "lit" && b.value
|
|
82
|
+
if (b.op === "lit" && Object.is(b.value, 0)) return a;
|
|
71
83
|
}
|
|
72
84
|
return app(fn, args);
|
|
73
85
|
}
|
|
@@ -174,13 +186,10 @@ function negatePred(p) {
|
|
|
174
186
|
case "ne":
|
|
175
187
|
return eq(p.a, p.b);
|
|
176
188
|
case "lt":
|
|
177
|
-
return ge(p.a, p.b);
|
|
178
189
|
case "le":
|
|
179
|
-
return gt(p.a, p.b);
|
|
180
190
|
case "gt":
|
|
181
|
-
return le(p.a, p.b);
|
|
182
191
|
case "ge":
|
|
183
|
-
return
|
|
192
|
+
return { op: "not", arg: p };
|
|
184
193
|
case "and":
|
|
185
194
|
return or(...p.args.map(negatePred));
|
|
186
195
|
case "or":
|
|
@@ -193,6 +202,13 @@ function negatePred(p) {
|
|
|
193
202
|
);
|
|
194
203
|
}
|
|
195
204
|
}
|
|
205
|
+
function totalOrderDual(p) {
|
|
206
|
+
if (p.op === "lt") return ge(p.a, p.b);
|
|
207
|
+
if (p.op === "le") return gt(p.a, p.b);
|
|
208
|
+
if (p.op === "gt") return le(p.a, p.b);
|
|
209
|
+
if (p.op === "ge") return lt(p.a, p.b);
|
|
210
|
+
return void 0;
|
|
211
|
+
}
|
|
196
212
|
function predEquals(a, b) {
|
|
197
213
|
if (a === b) return true;
|
|
198
214
|
if (a.op !== b.op) return false;
|
|
@@ -332,14 +348,18 @@ function implies(phi2, pred) {
|
|
|
332
348
|
if (expanded.op !== "not") {
|
|
333
349
|
return implies(phi2, expanded);
|
|
334
350
|
}
|
|
351
|
+
const dual = totalOrderDual(pred.arg);
|
|
352
|
+
if (dual && implies(phi2, dual)) return true;
|
|
335
353
|
if (phi2.op === "not") {
|
|
336
354
|
return implies(pred.arg, phi2.arg);
|
|
337
355
|
}
|
|
338
356
|
if (phi2.op === "and") {
|
|
339
357
|
for (const c of phi2.args) {
|
|
340
358
|
if (c.op === "not" && implies(pred.arg, c.arg)) return true;
|
|
359
|
+
if (dual && predEquals(c, dual)) return true;
|
|
341
360
|
}
|
|
342
361
|
}
|
|
362
|
+
if (dual && predEquals(phi2, dual)) return true;
|
|
343
363
|
if (pred.arg.op === "typeof" && impliesNotTypeof(phi2, pred.arg)) return true;
|
|
344
364
|
return false;
|
|
345
365
|
}
|
|
@@ -1106,10 +1126,17 @@ function pureFnNameOf(fn) {
|
|
|
1106
1126
|
if (impl?.pureName) return impl.pureName;
|
|
1107
1127
|
return fn._memoize;
|
|
1108
1128
|
}
|
|
1109
|
-
function absFunction(params, impl) {
|
|
1129
|
+
function absFunction(params, impl, opts) {
|
|
1110
1130
|
const a = {
|
|
1111
|
-
shape: {
|
|
1112
|
-
|
|
1131
|
+
shape: {
|
|
1132
|
+
k: "fn",
|
|
1133
|
+
params,
|
|
1134
|
+
...opts?.name ? { name: opts.name } : {},
|
|
1135
|
+
...opts?.paramTypes ? { paramTypes: opts.paramTypes } : {},
|
|
1136
|
+
...opts?.returnType ? { returnType: opts.returnType } : {},
|
|
1137
|
+
...opts?.slots ? { slots: opts.slots } : {}
|
|
1138
|
+
},
|
|
1139
|
+
conf: opts?.conf ?? "exact"
|
|
1113
1140
|
};
|
|
1114
1141
|
attachFnImpl(a, { params, ...impl });
|
|
1115
1142
|
return a;
|
|
@@ -1164,7 +1191,8 @@ function shapeStableKey(s, seen) {
|
|
|
1164
1191
|
const pts = (s.paramTypes ?? []).map((t) => absStableKey(t, seen)).join(",");
|
|
1165
1192
|
const ret = s.returnType ? absStableKey(s.returnType, seen) : "?";
|
|
1166
1193
|
const name = s.name ? `#${s.name}` : "";
|
|
1167
|
-
|
|
1194
|
+
const slots = s.slots ? `{${Object.keys(s.slots).sort().map((k) => `${k}:${absStableKey(s.slots[k].value, seen)}`).join(",")}}` : "";
|
|
1195
|
+
return `fn${name}(${s.params.join(",")}|${pts})=>${ret}${slots}`;
|
|
1168
1196
|
}
|
|
1169
1197
|
case "sum":
|
|
1170
1198
|
return `sum(${s.members.map((m) => absStableKey(m, seen)).join("|")})`;
|
|
@@ -1370,6 +1398,13 @@ function canonicalArrayIndex(v2) {
|
|
|
1370
1398
|
}
|
|
1371
1399
|
return void 0;
|
|
1372
1400
|
}
|
|
1401
|
+
function propertyKeyOf(a) {
|
|
1402
|
+
if (a === void 0) return void 0;
|
|
1403
|
+
if (a.term?.op !== "lit") return void 0;
|
|
1404
|
+
const v2 = a.term.value;
|
|
1405
|
+
if (typeof v2 === "symbol") return void 0;
|
|
1406
|
+
return String(v2);
|
|
1407
|
+
}
|
|
1373
1408
|
function objOf(slots, opts) {
|
|
1374
1409
|
const shape = { k: "obj", slots };
|
|
1375
1410
|
if (opts?.index) shape.index = opts.index;
|
|
@@ -1382,6 +1417,25 @@ function isObj(a) {
|
|
|
1382
1417
|
function getSlot(slots, key) {
|
|
1383
1418
|
return Object.prototype.hasOwnProperty.call(slots, key) ? slots[key] : void 0;
|
|
1384
1419
|
}
|
|
1420
|
+
function setSlot(slots, key, slot) {
|
|
1421
|
+
Object.defineProperty(slots, key, {
|
|
1422
|
+
value: slot,
|
|
1423
|
+
enumerable: true,
|
|
1424
|
+
writable: true,
|
|
1425
|
+
configurable: true
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
function setProtoAbs(o, proto) {
|
|
1429
|
+
const pv = litValue(proto);
|
|
1430
|
+
if (pv === null) return markNullProtoObj(o);
|
|
1431
|
+
if (proto.term?.op === "lit" && (pv === void 0 || typeof pv !== "object")) {
|
|
1432
|
+
return o;
|
|
1433
|
+
}
|
|
1434
|
+
if (isObj(o)) {
|
|
1435
|
+
o.shape.open = true;
|
|
1436
|
+
}
|
|
1437
|
+
return o;
|
|
1438
|
+
}
|
|
1385
1439
|
function spread(base, over) {
|
|
1386
1440
|
if (!isObj(base) && !isObj(over)) {
|
|
1387
1441
|
if (isObj(over)) return { shape: { ...over.shape, open: true }, conf: confJoin(base.conf, over.conf) };
|
|
@@ -1400,7 +1454,7 @@ function spread(base, over) {
|
|
|
1400
1454
|
const indexSlots = spreadIndexSlots(over);
|
|
1401
1455
|
if (indexSlots && isObj(base)) {
|
|
1402
1456
|
const slots2 = { ...base.shape.slots };
|
|
1403
|
-
for (const [k, s] of Object.entries(indexSlots)) slots2
|
|
1457
|
+
for (const [k, s] of Object.entries(indexSlots)) setSlot(slots2, k, s);
|
|
1404
1458
|
const shape2 = { k: "obj", slots: slots2 };
|
|
1405
1459
|
if (base.shape.open) shape2.open = true;
|
|
1406
1460
|
return { shape: shape2, conf: confJoin(base.conf, over.conf) };
|
|
@@ -1416,7 +1470,7 @@ function spread(base, over) {
|
|
|
1416
1470
|
}
|
|
1417
1471
|
const slots = { ...base.shape.slots };
|
|
1418
1472
|
for (const [k, s] of Object.entries(over.shape.slots)) {
|
|
1419
|
-
slots
|
|
1473
|
+
setSlot(slots, k, s);
|
|
1420
1474
|
}
|
|
1421
1475
|
const open = base.shape.open || over.shape.open || false;
|
|
1422
1476
|
const shape = { k: "obj", slots };
|
|
@@ -1440,8 +1494,9 @@ function spreadIndexSlots(over) {
|
|
|
1440
1494
|
const sv = over.term?.op === "lit" && typeof over.term.value === "string" ? over.term.value : void 0;
|
|
1441
1495
|
if (sv !== void 0) {
|
|
1442
1496
|
const slots = {};
|
|
1443
|
-
let i = 0;
|
|
1444
|
-
|
|
1497
|
+
for (let i = 0; i < sv.length; i++) {
|
|
1498
|
+
slots[String(i)] = { value: strLit(sv[i]) };
|
|
1499
|
+
}
|
|
1445
1500
|
return slots;
|
|
1446
1501
|
}
|
|
1447
1502
|
return void 0;
|
|
@@ -1466,7 +1521,7 @@ function joinObjects(a, b) {
|
|
|
1466
1521
|
const optional = sa.optional || sb.optional;
|
|
1467
1522
|
const jv = joinValues(sa.value, sb.value);
|
|
1468
1523
|
conf = confJoin(conf, jv.conf);
|
|
1469
|
-
slots
|
|
1524
|
+
setSlot(slots, k, { value: jv, optional });
|
|
1470
1525
|
}
|
|
1471
1526
|
return { shape: { k: "obj", slots }, conf };
|
|
1472
1527
|
}
|
|
@@ -1803,10 +1858,10 @@ function tryPromoteDirectCall(env, calleeName, args, loc) {
|
|
|
1803
1858
|
});
|
|
1804
1859
|
return env.vars.get(calleeName);
|
|
1805
1860
|
}
|
|
1806
|
-
function tryPromoteHofCallback(env,
|
|
1861
|
+
function tryPromoteHofCallback(env, cevalName, method, argAbses, loc) {
|
|
1807
1862
|
const hc = env.hofCollect;
|
|
1808
|
-
if (!hc || !hc.paramNames.has(
|
|
1809
|
-
const prev = env.vars.get(
|
|
1863
|
+
if (!hc || !hc.paramNames.has(cevalName)) return void 0;
|
|
1864
|
+
const prev = env.vars.get(cevalName);
|
|
1810
1865
|
if (!prev) return void 0;
|
|
1811
1866
|
if (prev.shape.k !== "any" && prev.shape.k !== "unknown") return void 0;
|
|
1812
1867
|
let paramTypes;
|
|
@@ -1820,12 +1875,12 @@ function tryPromoteHofCallback(env, cbName, method, argAbses, loc) {
|
|
|
1820
1875
|
paramTypes = argAbses.map(
|
|
1821
1876
|
(a) => abs({ k: "any" }, alphaOf(a, hc), void 0, "path")
|
|
1822
1877
|
);
|
|
1823
|
-
returnType = abs({ k: "any" }, betaOf(
|
|
1878
|
+
returnType = abs({ k: "any" }, betaOf(cevalName), void 0, "path");
|
|
1824
1879
|
} else {
|
|
1825
1880
|
paramTypes = argAbses.map(
|
|
1826
1881
|
(a) => abs({ k: "any" }, alphaOf(a, hc), void 0, "path")
|
|
1827
1882
|
);
|
|
1828
|
-
returnType = abs({ k: "any" }, betaOf(
|
|
1883
|
+
returnType = abs({ k: "any" }, betaOf(cevalName), void 0, "path");
|
|
1829
1884
|
}
|
|
1830
1885
|
const fnShape = {
|
|
1831
1886
|
k: "fn",
|
|
@@ -1833,14 +1888,14 @@ function tryPromoteHofCallback(env, cbName, method, argAbses, loc) {
|
|
|
1833
1888
|
paramTypes,
|
|
1834
1889
|
returnType
|
|
1835
1890
|
};
|
|
1836
|
-
promoteParamShape(env,
|
|
1891
|
+
promoteParamShape(env, cevalName, fnShape, { loc, recordSite: false });
|
|
1837
1892
|
hc.sites.push({
|
|
1838
|
-
param:
|
|
1893
|
+
param: cevalName,
|
|
1839
1894
|
argTerms: argAbses.map((a) => a.term ?? { op: "var", id: "_" }),
|
|
1840
1895
|
result: returnType,
|
|
1841
1896
|
loc
|
|
1842
1897
|
});
|
|
1843
|
-
return env.vars.get(
|
|
1898
|
+
return env.vars.get(cevalName);
|
|
1844
1899
|
}
|
|
1845
1900
|
function snapshotAbs(a) {
|
|
1846
1901
|
const shape = a.shape;
|
|
@@ -1871,7 +1926,12 @@ function snapshotAbs(a) {
|
|
|
1871
1926
|
const nextSlot = { value: snapshotAbs(slot.value) };
|
|
1872
1927
|
if (slot.optional) nextSlot.optional = true;
|
|
1873
1928
|
if (slot.readonly) nextSlot.readonly = true;
|
|
1874
|
-
slots
|
|
1929
|
+
Object.defineProperty(slots, k, {
|
|
1930
|
+
value: nextSlot,
|
|
1931
|
+
enumerable: true,
|
|
1932
|
+
writable: true,
|
|
1933
|
+
configurable: true
|
|
1934
|
+
});
|
|
1875
1935
|
}
|
|
1876
1936
|
const next = { k: "obj", slots };
|
|
1877
1937
|
if (s.index) {
|
|
@@ -2117,7 +2177,12 @@ function substShape(s, map, cache, visiting) {
|
|
|
2117
2177
|
const nextSlot = { value: substAbsInner(slot.value, map, cache, visiting) };
|
|
2118
2178
|
if (slot.optional) nextSlot.optional = true;
|
|
2119
2179
|
if (slot.readonly) nextSlot.readonly = true;
|
|
2120
|
-
slots
|
|
2180
|
+
Object.defineProperty(slots, k, {
|
|
2181
|
+
value: nextSlot,
|
|
2182
|
+
enumerable: true,
|
|
2183
|
+
writable: true,
|
|
2184
|
+
configurable: true
|
|
2185
|
+
});
|
|
2121
2186
|
}
|
|
2122
2187
|
const next = { k: "obj", slots };
|
|
2123
2188
|
if (s.index) {
|
|
@@ -2466,21 +2531,60 @@ function concatString(a, b) {
|
|
|
2466
2531
|
}
|
|
2467
2532
|
const aParts = coerceToStringParts(a);
|
|
2468
2533
|
const bParts = coerceToStringParts(b);
|
|
2469
|
-
if (!aParts || !bParts)
|
|
2534
|
+
if (!aParts || !bParts) {
|
|
2535
|
+
if (isStrPrim2(a) || isStrPrim2(b)) {
|
|
2536
|
+
return abs({ k: "prim", type: "string" }, void 0, void 0, "path");
|
|
2537
|
+
}
|
|
2538
|
+
return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
2539
|
+
}
|
|
2470
2540
|
return createTemplateAbs([...aParts, ...bParts]);
|
|
2471
2541
|
}
|
|
2472
2542
|
function coerceToStringParts(a) {
|
|
2473
2543
|
if (isTemplateAbs(a) || isStrPrim2(a)) return templatePartsOf(a);
|
|
2474
2544
|
if (isStrLit(a)) return [a];
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2545
|
+
if (a.term?.op === "lit") {
|
|
2546
|
+
const v2 = a.term.value;
|
|
2547
|
+
if (typeof v2 === "symbol") return void 0;
|
|
2548
|
+
return [abs({ k: "prim", type: "string" }, lit(String(v2)), void 0, "exact")];
|
|
2478
2549
|
}
|
|
2479
2550
|
if (a.shape.k === "prim" && a.shape.type === "number") {
|
|
2480
2551
|
return [a];
|
|
2481
2552
|
}
|
|
2553
|
+
if (a.shape.k === "tuple" || a.shape.k === "arr") {
|
|
2554
|
+
return [arrayToPrimitiveString(a)];
|
|
2555
|
+
}
|
|
2556
|
+
if (a.shape.k === "obj" && !a.shape.open && !a.shape.index && !isNullProtoObj(a)) {
|
|
2557
|
+
const slots = a.shape.slots;
|
|
2558
|
+
if (!Object.hasOwn(slots, "toString") && !Object.hasOwn(slots, "valueOf")) {
|
|
2559
|
+
return [
|
|
2560
|
+
abs({ k: "prim", type: "string" }, lit("[object Object]"), void 0, "exact")
|
|
2561
|
+
];
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2482
2564
|
return void 0;
|
|
2483
2565
|
}
|
|
2566
|
+
function arrayToPrimitiveString(a) {
|
|
2567
|
+
const s = a.shape;
|
|
2568
|
+
const strPrimPart = () => abs({ k: "prim", type: "string" }, void 0, void 0, "path");
|
|
2569
|
+
if (s.k === "arr") return strPrimPart();
|
|
2570
|
+
if (s.k !== "tuple") return strPrimPart();
|
|
2571
|
+
const holes = s.holes ?? [];
|
|
2572
|
+
const parts = [];
|
|
2573
|
+
for (let i = 0; i < s.elements.length; i++) {
|
|
2574
|
+
if (holes.includes(i)) {
|
|
2575
|
+
parts.push("");
|
|
2576
|
+
continue;
|
|
2577
|
+
}
|
|
2578
|
+
const el = s.elements[i];
|
|
2579
|
+
if (el.term?.op !== "lit") return strPrimPart();
|
|
2580
|
+
const v2 = el.term.value;
|
|
2581
|
+
if (typeof v2 === "symbol") return strPrimPart();
|
|
2582
|
+
if (v2 === null || v2 === void 0) parts.push("");
|
|
2583
|
+
else if (typeof v2 === "object") return strPrimPart();
|
|
2584
|
+
else parts.push(String(v2));
|
|
2585
|
+
}
|
|
2586
|
+
return abs({ k: "prim", type: "string" }, lit(parts.join(",")), void 0, "exact");
|
|
2587
|
+
}
|
|
2484
2588
|
|
|
2485
2589
|
// src/algebra/symbol-id.ts
|
|
2486
2590
|
var symbolMeta = /* @__PURE__ */ new WeakMap();
|
|
@@ -2689,6 +2793,12 @@ function add(a, b, phi2 = pTrue) {
|
|
|
2689
2793
|
if (typeof va === "string" || typeof vb === "string") {
|
|
2690
2794
|
return strLitResult(String(va) + String(vb));
|
|
2691
2795
|
}
|
|
2796
|
+
if (typeof va === "bigint" && typeof vb !== "bigint" || typeof vb === "bigint" && typeof va !== "bigint") {
|
|
2797
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
if (isStrPrim(a) || isStrPrim(b) || isTemplateLike(a) || isTemplateLike(b)) {
|
|
2801
|
+
return concatString(a, b);
|
|
2692
2802
|
}
|
|
2693
2803
|
if (coercibleLit(va) && coercibleLit(vb)) {
|
|
2694
2804
|
return numLit(Number(va) + Number(vb));
|
|
@@ -2698,7 +2808,7 @@ function add(a, b, phi2 = pTrue) {
|
|
|
2698
2808
|
if (isBigPrim(a) && isBigPrim(b)) {
|
|
2699
2809
|
return abs({ k: "prim", type: "bigint" }, void 0, void 0, confJoin(a.conf, b.conf));
|
|
2700
2810
|
}
|
|
2701
|
-
if (
|
|
2811
|
+
if (a.shape.k === "tuple" || a.shape.k === "arr" || b.shape.k === "tuple" || b.shape.k === "arr") {
|
|
2702
2812
|
return concatString(a, b);
|
|
2703
2813
|
}
|
|
2704
2814
|
if (isNumPrim(a) && isNumPrim(b)) {
|
|
@@ -2714,8 +2824,12 @@ function add(a, b, phi2 = pTrue) {
|
|
|
2714
2824
|
}
|
|
2715
2825
|
if (isAnyLike(a) || isAnyLike(b)) {
|
|
2716
2826
|
const term = a.term && b.term ? simplifyTerm(app("+", [a.term, b.term])) : void 0;
|
|
2827
|
+
const bigFace = isBigPrim(a) || isBigPrim(b);
|
|
2717
2828
|
return abs(
|
|
2718
|
-
{
|
|
2829
|
+
{
|
|
2830
|
+
k: "sum",
|
|
2831
|
+
members: bigFace ? [abs({ k: "prim", type: "bigint" }, void 0, void 0, "exact"), str()] : [num(), str()]
|
|
2832
|
+
},
|
|
2719
2833
|
term,
|
|
2720
2834
|
void 0,
|
|
2721
2835
|
"partial"
|
|
@@ -2748,6 +2862,15 @@ function add(a, b, phi2 = pTrue) {
|
|
|
2748
2862
|
}
|
|
2749
2863
|
return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
2750
2864
|
}
|
|
2865
|
+
function isKnownNonBigintNumeric(a) {
|
|
2866
|
+
const va = litValue(a);
|
|
2867
|
+
if (typeof va === "number" || typeof va === "boolean" || va === null) return true;
|
|
2868
|
+
if (a.term?.op === "lit" && a.term.value === void 0) return true;
|
|
2869
|
+
return a.shape.k === "prim" && (a.shape.type === "number" || a.shape.type === "boolean");
|
|
2870
|
+
}
|
|
2871
|
+
function isMaybeBigintOperand(a) {
|
|
2872
|
+
return a.shape.k === "any" || a.shape.k === "unknown" || a.shape.k === "obj" || a.shape.k === "fn" || a.shape.k === "brand" || a.shape.k === "sum";
|
|
2873
|
+
}
|
|
2751
2874
|
function foldBigintBinOp(a, b, op) {
|
|
2752
2875
|
const va = litValue(a);
|
|
2753
2876
|
const vb = litValue(b);
|
|
@@ -2755,13 +2878,27 @@ function foldBigintBinOp(a, b, op) {
|
|
|
2755
2878
|
if (typeof va === "bigint" && typeof vb === "bigint") {
|
|
2756
2879
|
try {
|
|
2757
2880
|
return bigintLit(op(va, vb));
|
|
2758
|
-
} catch {
|
|
2759
|
-
|
|
2881
|
+
} catch (e) {
|
|
2882
|
+
if (e instanceof RangeError) throw new NudoThrow(errorTypeAbs("RangeError"));
|
|
2883
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
2760
2884
|
}
|
|
2761
2885
|
}
|
|
2762
2886
|
const other = typeof va === "bigint" ? b : a;
|
|
2763
2887
|
if (isBigPrim(other)) return void 0;
|
|
2764
|
-
|
|
2888
|
+
if (isKnownNonBigintNumeric(other)) {
|
|
2889
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
2890
|
+
}
|
|
2891
|
+
if (isStrPrim(other)) {
|
|
2892
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
2893
|
+
}
|
|
2894
|
+
if (isMaybeBigintOperand(other)) {
|
|
2895
|
+
recordMayThrow({
|
|
2896
|
+
kind: "TypeError",
|
|
2897
|
+
cause: "mixed bigint \u2297 abstract operand"
|
|
2898
|
+
});
|
|
2899
|
+
return void 0;
|
|
2900
|
+
}
|
|
2901
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
2765
2902
|
}
|
|
2766
2903
|
function dedupAbsMembers(ms) {
|
|
2767
2904
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2784,6 +2921,12 @@ function strLitResult(s) {
|
|
|
2784
2921
|
function normalizeNegZero(n) {
|
|
2785
2922
|
return n === 0 ? 0 : n;
|
|
2786
2923
|
}
|
|
2924
|
+
function ieeeBound(n, strict, strictZeroOk) {
|
|
2925
|
+
if (!Number.isFinite(n)) return void 0;
|
|
2926
|
+
const z = normalizeNegZero(n);
|
|
2927
|
+
if (z === 0 && strict && !strictZeroOk) return void 0;
|
|
2928
|
+
return z;
|
|
2929
|
+
}
|
|
2787
2930
|
function isAnyLike(a) {
|
|
2788
2931
|
if (a.shape.k === "any") return true;
|
|
2789
2932
|
if (a.shape.k === "unknown") return true;
|
|
@@ -2794,8 +2937,9 @@ function coercibleLit(v2) {
|
|
|
2794
2937
|
}
|
|
2795
2938
|
function toNumberResult(a, b, op) {
|
|
2796
2939
|
const term = a.term && b.term ? app(op, [a.term, b.term]) : void 0;
|
|
2940
|
+
const bigFace = isBigPrim(a) || isBigPrim(b);
|
|
2797
2941
|
return abs(
|
|
2798
|
-
{ k: "prim", type: "number" },
|
|
2942
|
+
bigFace ? { k: "prim", type: "bigint" } : { k: "prim", type: "number" },
|
|
2799
2943
|
term,
|
|
2800
2944
|
void 0,
|
|
2801
2945
|
term ? confJoin(confJoin(a.conf, b.conf), "partial") : "partial"
|
|
@@ -2806,18 +2950,22 @@ function isNumericLike(a) {
|
|
|
2806
2950
|
}
|
|
2807
2951
|
function addPred(a, b, sumTerm, phi2) {
|
|
2808
2952
|
const aBounds = numericBounds(a, phi2);
|
|
2809
|
-
const
|
|
2810
|
-
if (!aBounds && !
|
|
2953
|
+
const evalBounds = numericBounds(b, phi2);
|
|
2954
|
+
if (!aBounds && !evalBounds) return void 0;
|
|
2811
2955
|
const facts = [];
|
|
2812
|
-
if (aBounds?.lo !== void 0 &&
|
|
2813
|
-
const
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2956
|
+
if (aBounds?.lo !== void 0 && evalBounds?.lo !== void 0) {
|
|
2957
|
+
const strict = aBounds.lo.strict || evalBounds.lo.strict;
|
|
2958
|
+
const loSum = ieeeBound(aBounds.lo.value + evalBounds.lo.value, strict, true);
|
|
2959
|
+
if (loSum !== void 0) {
|
|
2960
|
+
facts.push(strict ? gt(sumTerm, lit(loSum)) : ge(sumTerm, lit(loSum)));
|
|
2961
|
+
}
|
|
2816
2962
|
}
|
|
2817
|
-
if (aBounds?.hi !== void 0 &&
|
|
2818
|
-
const
|
|
2819
|
-
const
|
|
2820
|
-
|
|
2963
|
+
if (aBounds?.hi !== void 0 && evalBounds?.hi !== void 0) {
|
|
2964
|
+
const strict = aBounds.hi.strict || evalBounds.hi.strict;
|
|
2965
|
+
const hiSum = ieeeBound(aBounds.hi.value + evalBounds.hi.value, strict, true);
|
|
2966
|
+
if (hiSum !== void 0) {
|
|
2967
|
+
facts.push(strict ? lt(sumTerm, lit(hiSum)) : le(sumTerm, lit(hiSum)));
|
|
2968
|
+
}
|
|
2821
2969
|
}
|
|
2822
2970
|
if (facts.length === 0) return void 0;
|
|
2823
2971
|
return and(...facts);
|
|
@@ -2831,77 +2979,57 @@ function numericBounds(a, phi2 = pTrue) {
|
|
|
2831
2979
|
if (a.term?.op === "var") {
|
|
2832
2980
|
collectBoundsFromPhi(phi2, a.term.id, result);
|
|
2833
2981
|
}
|
|
2834
|
-
if (a.term?.op === "lit" && typeof a.term.value === "number") {
|
|
2982
|
+
if (a.term?.op === "lit" && typeof a.term.value === "number" && !Number.isNaN(a.term.value)) {
|
|
2835
2983
|
result.lo = { value: a.term.value, strict: false };
|
|
2836
2984
|
result.hi = { value: a.term.value, strict: false };
|
|
2837
2985
|
}
|
|
2838
2986
|
if (result.lo === void 0 && result.hi === void 0) return void 0;
|
|
2839
2987
|
return result;
|
|
2840
2988
|
}
|
|
2989
|
+
function tightenLo2(acc, n, strict) {
|
|
2990
|
+
if (acc.lo === void 0 || n > acc.lo.value || n === acc.lo.value && strict && !acc.lo.strict) {
|
|
2991
|
+
acc.lo = { value: n, strict };
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
function tightenHi2(acc, n, strict) {
|
|
2995
|
+
if (acc.hi === void 0 || n < acc.hi.value || n === acc.hi.value && strict && !acc.hi.strict) {
|
|
2996
|
+
acc.hi = { value: n, strict };
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
function noteBoundFromRel(p, isTarget, acc) {
|
|
3000
|
+
if (p.op !== "gt" && p.op !== "ge" && p.op !== "lt" && p.op !== "le") return;
|
|
3001
|
+
let op = p.op;
|
|
3002
|
+
let litSide;
|
|
3003
|
+
if (isTarget(p.a) && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
3004
|
+
litSide = p.b;
|
|
3005
|
+
} else if (isTarget(p.b) && p.a.op === "lit" && typeof p.a.value === "number") {
|
|
3006
|
+
op = op === "gt" ? "lt" : op === "lt" ? "gt" : op === "ge" ? "le" : "ge";
|
|
3007
|
+
litSide = p.a;
|
|
3008
|
+
} else {
|
|
3009
|
+
return;
|
|
3010
|
+
}
|
|
3011
|
+
const n = litSide.value;
|
|
3012
|
+
if (op === "gt") tightenLo2(acc, n, true);
|
|
3013
|
+
else if (op === "ge") tightenLo2(acc, n, false);
|
|
3014
|
+
else if (op === "lt") tightenHi2(acc, n, true);
|
|
3015
|
+
else tightenHi2(acc, n, false);
|
|
3016
|
+
}
|
|
2841
3017
|
function collectBoundsFromPred(pred, term, acc) {
|
|
2842
|
-
const
|
|
3018
|
+
const isTarget = (t) => termToString(t) === termToString(term);
|
|
2843
3019
|
const apply = (p) => {
|
|
2844
3020
|
if (p.op === "and") {
|
|
2845
3021
|
p.args.forEach(apply);
|
|
2846
3022
|
return;
|
|
2847
3023
|
}
|
|
2848
|
-
|
|
2849
|
-
const n = p.b.value;
|
|
2850
|
-
if (acc.lo === void 0 || n > acc.lo.value || n === acc.lo.value && !acc.lo.strict) {
|
|
2851
|
-
acc.lo = { value: n, strict: true };
|
|
2852
|
-
}
|
|
2853
|
-
return;
|
|
2854
|
-
}
|
|
2855
|
-
if (p.op === "ge" && match(p.a) && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
2856
|
-
const n = p.b.value;
|
|
2857
|
-
if (acc.lo === void 0 || n > acc.lo.value) {
|
|
2858
|
-
acc.lo = { value: n, strict: false };
|
|
2859
|
-
}
|
|
2860
|
-
return;
|
|
2861
|
-
}
|
|
2862
|
-
if (p.op === "lt" && match(p.a) && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
2863
|
-
const n = p.b.value;
|
|
2864
|
-
if (acc.hi === void 0 || n < acc.hi.value || n === acc.hi.value && !acc.hi.strict) {
|
|
2865
|
-
acc.hi = { value: n, strict: true };
|
|
2866
|
-
}
|
|
2867
|
-
return;
|
|
2868
|
-
}
|
|
2869
|
-
if (p.op === "le" && match(p.a) && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
2870
|
-
const n = p.b.value;
|
|
2871
|
-
if (acc.hi === void 0 || n < acc.hi.value) {
|
|
2872
|
-
acc.hi = { value: n, strict: false };
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
3024
|
+
noteBoundFromRel(p, isTarget, acc);
|
|
2875
3025
|
};
|
|
2876
3026
|
apply(pred);
|
|
2877
3027
|
}
|
|
2878
3028
|
function collectBoundsFromPhi(phi2, id, acc) {
|
|
3029
|
+
const isTarget = (t) => t.op === "var" && t.id === id;
|
|
2879
3030
|
const conjs = phi2.op === "and" ? phi2.args : [phi2];
|
|
2880
3031
|
for (const p of conjs) {
|
|
2881
|
-
|
|
2882
|
-
const n = p.b.value;
|
|
2883
|
-
if (acc.lo === void 0 || n > acc.lo.value || n === acc.lo.value && !acc.lo.strict) {
|
|
2884
|
-
acc.lo = { value: n, strict: true };
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
if (p.op === "ge" && p.a.op === "var" && p.a.id === id && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
2888
|
-
const n = p.b.value;
|
|
2889
|
-
if (acc.lo === void 0 || n > acc.lo.value) {
|
|
2890
|
-
acc.lo = { value: n, strict: false };
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
if (p.op === "lt" && p.a.op === "var" && p.a.id === id && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
2894
|
-
const n = p.b.value;
|
|
2895
|
-
if (acc.hi === void 0 || n < acc.hi.value || n === acc.hi.value && !acc.hi.strict) {
|
|
2896
|
-
acc.hi = { value: n, strict: true };
|
|
2897
|
-
}
|
|
2898
|
-
}
|
|
2899
|
-
if (p.op === "le" && p.a.op === "var" && p.a.id === id && p.b.op === "lit" && typeof p.b.value === "number") {
|
|
2900
|
-
const n = p.b.value;
|
|
2901
|
-
if (acc.hi === void 0 || n < acc.hi.value) {
|
|
2902
|
-
acc.hi = { value: n, strict: false };
|
|
2903
|
-
}
|
|
2904
|
-
}
|
|
3032
|
+
noteBoundFromRel(p, isTarget, acc);
|
|
2905
3033
|
}
|
|
2906
3034
|
}
|
|
2907
3035
|
function sub(a, b, phi2 = pTrue) {
|
|
@@ -2924,14 +3052,18 @@ function sub(a, b, phi2 = pTrue) {
|
|
|
2924
3052
|
const bb = numericBounds(b, phi2);
|
|
2925
3053
|
const facts = [];
|
|
2926
3054
|
if (ab?.lo !== void 0 && bb?.hi !== void 0) {
|
|
2927
|
-
const lo = ab.lo.value - bb.hi.value;
|
|
2928
3055
|
const strict = ab.lo.strict || bb.hi.strict;
|
|
2929
|
-
|
|
3056
|
+
const lo = ieeeBound(ab.lo.value - bb.hi.value, strict, true);
|
|
3057
|
+
if (lo !== void 0) {
|
|
3058
|
+
facts.push(strict ? gt(term, lit(lo)) : ge(term, lit(lo)));
|
|
3059
|
+
}
|
|
2930
3060
|
}
|
|
2931
3061
|
if (ab?.hi !== void 0 && bb?.lo !== void 0) {
|
|
2932
|
-
const hi = ab.hi.value - bb.lo.value;
|
|
2933
3062
|
const strict = ab.hi.strict || bb.lo.strict;
|
|
2934
|
-
|
|
3063
|
+
const hi = ieeeBound(ab.hi.value - bb.lo.value, strict, true);
|
|
3064
|
+
if (hi !== void 0) {
|
|
3065
|
+
facts.push(strict ? lt(term, lit(hi)) : le(term, lit(hi)));
|
|
3066
|
+
}
|
|
2935
3067
|
}
|
|
2936
3068
|
const conf = term.op === "lit" ? "exact" : confJoin(confJoin(a.conf, b.conf), facts.length ? "path" : "path");
|
|
2937
3069
|
return abs({ k: "prim", type: "number" }, term, facts.length ? and(...facts) : void 0, conf);
|
|
@@ -2969,25 +3101,26 @@ function mul(a, b, phi2 = pTrue) {
|
|
|
2969
3101
|
k = a.term.value;
|
|
2970
3102
|
base = b;
|
|
2971
3103
|
}
|
|
2972
|
-
if (k !== void 0 && base !== void 0 && k !== 0) {
|
|
3104
|
+
if (k !== void 0 && base !== void 0 && k !== 0 && Number.isFinite(k)) {
|
|
3105
|
+
const strictZeroOk = Math.abs(k) >= 1;
|
|
2973
3106
|
const ab = numericBounds(base, phi2);
|
|
2974
3107
|
const facts = [];
|
|
2975
3108
|
if (ab?.lo !== void 0) {
|
|
2976
3109
|
if (k > 0) {
|
|
2977
|
-
const lo = ab.lo.value * k;
|
|
2978
|
-
facts.push(ab.lo.strict ? gt(term, lit(lo)) : ge(term, lit(lo)));
|
|
3110
|
+
const lo = ieeeBound(ab.lo.value * k, ab.lo.strict, strictZeroOk);
|
|
3111
|
+
if (lo !== void 0) facts.push(ab.lo.strict ? gt(term, lit(lo)) : ge(term, lit(lo)));
|
|
2979
3112
|
} else {
|
|
2980
|
-
const hi = ab.lo.value * k;
|
|
2981
|
-
facts.push(ab.lo.strict ? lt(term, lit(
|
|
3113
|
+
const hi = ieeeBound(ab.lo.value * k, ab.lo.strict, strictZeroOk);
|
|
3114
|
+
if (hi !== void 0) facts.push(ab.lo.strict ? lt(term, lit(hi)) : le(term, lit(hi)));
|
|
2982
3115
|
}
|
|
2983
3116
|
}
|
|
2984
3117
|
if (ab?.hi !== void 0) {
|
|
2985
3118
|
if (k > 0) {
|
|
2986
|
-
const hi = ab.hi.value * k;
|
|
2987
|
-
facts.push(ab.hi.strict ? lt(term, lit(hi)) : le(term, lit(hi)));
|
|
3119
|
+
const hi = ieeeBound(ab.hi.value * k, ab.hi.strict, strictZeroOk);
|
|
3120
|
+
if (hi !== void 0) facts.push(ab.hi.strict ? lt(term, lit(hi)) : le(term, lit(hi)));
|
|
2988
3121
|
} else {
|
|
2989
|
-
const lo = ab.hi.value * k;
|
|
2990
|
-
facts.push(ab.hi.strict ? gt(term, lit(
|
|
3122
|
+
const lo = ieeeBound(ab.hi.value * k, ab.hi.strict, strictZeroOk);
|
|
3123
|
+
if (lo !== void 0) facts.push(ab.hi.strict ? gt(term, lit(lo)) : ge(term, lit(lo)));
|
|
2991
3124
|
}
|
|
2992
3125
|
}
|
|
2993
3126
|
return abs(
|
|
@@ -3031,19 +3164,24 @@ function div(a, b, phi2 = pTrue) {
|
|
|
3031
3164
|
}
|
|
3032
3165
|
if (isNumericLike(a) && isNumericLike(b) && a.term && b.term) {
|
|
3033
3166
|
const term = simplifyTerm(app("/", [a.term, b.term]));
|
|
3034
|
-
if (b.term.op === "lit" && typeof b.term.value === "number" && b.term.value !== 0) {
|
|
3167
|
+
if (b.term.op === "lit" && typeof b.term.value === "number" && b.term.value !== 0 && Number.isFinite(b.term.value)) {
|
|
3035
3168
|
const k = b.term.value;
|
|
3169
|
+
const strictZeroOk = Math.abs(k) <= 1;
|
|
3036
3170
|
const ab = numericBounds(a, phi2);
|
|
3037
3171
|
const facts = [];
|
|
3038
3172
|
if (ab?.lo !== void 0) {
|
|
3039
|
-
const lo = ab.lo.value / k;
|
|
3040
|
-
if (
|
|
3041
|
-
|
|
3173
|
+
const lo = ieeeBound(ab.lo.value / k, ab.lo.strict, strictZeroOk);
|
|
3174
|
+
if (lo !== void 0) {
|
|
3175
|
+
if (k > 0) facts.push(ab.lo.strict ? gt(term, lit(lo)) : ge(term, lit(lo)));
|
|
3176
|
+
else facts.push(ab.lo.strict ? lt(term, lit(lo)) : le(term, lit(lo)));
|
|
3177
|
+
}
|
|
3042
3178
|
}
|
|
3043
3179
|
if (ab?.hi !== void 0) {
|
|
3044
|
-
const hi = ab.hi.value / k;
|
|
3045
|
-
if (
|
|
3046
|
-
|
|
3180
|
+
const hi = ieeeBound(ab.hi.value / k, ab.hi.strict, strictZeroOk);
|
|
3181
|
+
if (hi !== void 0) {
|
|
3182
|
+
if (k > 0) facts.push(ab.hi.strict ? lt(term, lit(hi)) : le(term, lit(hi)));
|
|
3183
|
+
else facts.push(ab.hi.strict ? gt(term, lit(hi)) : ge(term, lit(hi)));
|
|
3184
|
+
}
|
|
3047
3185
|
}
|
|
3048
3186
|
return abs(
|
|
3049
3187
|
num().shape,
|
|
@@ -3124,8 +3262,9 @@ function cmp(op, a, b, phi2 = pTrue) {
|
|
|
3124
3262
|
if (a.term && b.term) {
|
|
3125
3263
|
const pred = op === "lt" ? lt(a.term, b.term) : op === "le" ? le(a.term, b.term) : op === "gt" ? gt(a.term, b.term) : op === "ge" ? ge(a.term, b.term) : op === "eq" ? { op: "eq", a: a.term, b: b.term } : { op: "ne", a: a.term, b: b.term };
|
|
3126
3264
|
if (implies(phi2, pred)) return boolLit(true);
|
|
3127
|
-
|
|
3128
|
-
|
|
3265
|
+
if (implies(phi2, negatePred(pred))) return boolLit(false);
|
|
3266
|
+
const dual = totalOrderDual(pred) ?? (op === "eq" ? { op: "ne", a: a.term, b: b.term } : op === "ne" ? { op: "eq", a: a.term, b: b.term } : void 0);
|
|
3267
|
+
if (dual && implies(phi2, dual)) return boolLit(false);
|
|
3129
3268
|
const decided = decideByBounds(op, a, b, phi2);
|
|
3130
3269
|
if (decided !== void 0) return boolLit(decided);
|
|
3131
3270
|
return {
|
|
@@ -3189,24 +3328,26 @@ function decideByBounds(op, a, b, phi2) {
|
|
|
3189
3328
|
const aHi = aB?.hi;
|
|
3190
3329
|
const bLo = bB?.lo;
|
|
3191
3330
|
const bHi = bB?.hi;
|
|
3331
|
+
const tighterHi = (x, y) => x.value < y.value || x.value === y.value && (x.strict || y.strict);
|
|
3332
|
+
const tighterLo = (x, y) => x.value > y.value || x.value === y.value && (x.strict || y.strict);
|
|
3192
3333
|
if (op === "lt") {
|
|
3193
|
-
if (aHi && bLo && aHi
|
|
3334
|
+
if (aHi && bLo && tighterHi(aHi, bLo)) return true;
|
|
3194
3335
|
if (aLo && bHi && aLo.value >= bHi.value) return false;
|
|
3195
3336
|
return void 0;
|
|
3196
3337
|
}
|
|
3197
3338
|
if (op === "le") {
|
|
3198
|
-
if (aHi && bLo && aHi.value
|
|
3199
|
-
if (aLo && bHi && aLo
|
|
3339
|
+
if (aHi && bLo && aHi.value <= bLo.value) return true;
|
|
3340
|
+
if (aLo && bHi && tighterLo(aLo, bHi)) return false;
|
|
3200
3341
|
return void 0;
|
|
3201
3342
|
}
|
|
3202
3343
|
if (op === "gt") {
|
|
3203
|
-
if (aLo && bHi && aLo
|
|
3344
|
+
if (aLo && bHi && tighterLo(aLo, bHi)) return true;
|
|
3204
3345
|
if (aHi && bLo && aHi.value <= bLo.value) return false;
|
|
3205
3346
|
return void 0;
|
|
3206
3347
|
}
|
|
3207
3348
|
if (op === "ge") {
|
|
3208
3349
|
if (aLo && bHi && aLo.value >= bHi.value) return true;
|
|
3209
|
-
if (aHi && bLo && aHi
|
|
3350
|
+
if (aHi && bLo && tighterHi(aHi, bLo)) return false;
|
|
3210
3351
|
return void 0;
|
|
3211
3352
|
}
|
|
3212
3353
|
return void 0;
|
|
@@ -3264,6 +3405,13 @@ function extStateOf(o) {
|
|
|
3264
3405
|
function getPropFlags(o) {
|
|
3265
3406
|
return propFlagsTable.get(o);
|
|
3266
3407
|
}
|
|
3408
|
+
function enumOwnKeys(o, slots) {
|
|
3409
|
+
const flags = getPropFlags(o);
|
|
3410
|
+
return Object.keys(slots).filter((k) => flags?.get(k)?.enumerable !== false);
|
|
3411
|
+
}
|
|
3412
|
+
function isEnumerableView(o, key) {
|
|
3413
|
+
return getPropFlags(o)?.get(key)?.enumerable !== false;
|
|
3414
|
+
}
|
|
3267
3415
|
function setPropFlags(o, key, f) {
|
|
3268
3416
|
let m = propFlagsTable.get(o);
|
|
3269
3417
|
if (!m) {
|
|
@@ -3531,7 +3679,7 @@ function assignSourceSlots(src) {
|
|
|
3531
3679
|
const slots = {};
|
|
3532
3680
|
for (const [k, v2] of Object.entries(inner.shape.slots)) {
|
|
3533
3681
|
if (k === "length") continue;
|
|
3534
|
-
slots
|
|
3682
|
+
setSlot(slots, k, v2);
|
|
3535
3683
|
}
|
|
3536
3684
|
if (Object.keys(slots).length > 0 || !inner.shape.open) return slots;
|
|
3537
3685
|
}
|
|
@@ -3616,8 +3764,12 @@ function evalObjectMethod(name, args) {
|
|
|
3616
3764
|
);
|
|
3617
3765
|
}
|
|
3618
3766
|
if (a0?.term?.op === "lit" && typeof a0.term.value === "string") {
|
|
3767
|
+
const s = a0.term.value;
|
|
3619
3768
|
return abs(
|
|
3620
|
-
{
|
|
3769
|
+
{
|
|
3770
|
+
k: "tuple",
|
|
3771
|
+
elements: Array.from({ length: s.length }, (_, i) => strLit(s[i]))
|
|
3772
|
+
},
|
|
3621
3773
|
void 0,
|
|
3622
3774
|
void 0,
|
|
3623
3775
|
"exact"
|
|
@@ -3647,12 +3799,13 @@ function evalObjectMethod(name, args) {
|
|
|
3647
3799
|
return abs({ k: "tuple", elements: entries }, void 0, void 0, "exact");
|
|
3648
3800
|
}
|
|
3649
3801
|
if (a0?.term?.op === "lit" && typeof a0.term.value === "string") {
|
|
3802
|
+
const s = a0.term.value;
|
|
3650
3803
|
return abs(
|
|
3651
3804
|
{
|
|
3652
3805
|
k: "tuple",
|
|
3653
3806
|
elements: Array.from(
|
|
3654
|
-
|
|
3655
|
-
(
|
|
3807
|
+
{ length: s.length },
|
|
3808
|
+
(_, i) => abs({ k: "tuple", elements: [strLit(String(i)), strLit(s[i])] }, void 0, void 0, "exact")
|
|
3656
3809
|
)
|
|
3657
3810
|
},
|
|
3658
3811
|
void 0,
|
|
@@ -3687,6 +3840,21 @@ function evalObjectMethod(name, args) {
|
|
|
3687
3840
|
}
|
|
3688
3841
|
return protoOfRecv(a0);
|
|
3689
3842
|
}
|
|
3843
|
+
case "setPrototypeOf": {
|
|
3844
|
+
if (!args.length) {
|
|
3845
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
3846
|
+
}
|
|
3847
|
+
const t0 = args[0];
|
|
3848
|
+
const p0 = args[1];
|
|
3849
|
+
if (!t0 || !p0) {
|
|
3850
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
3851
|
+
}
|
|
3852
|
+
const pv = litValue(p0);
|
|
3853
|
+
if (p0.term?.op === "lit" && (pv === void 0 || pv !== null && typeof pv !== "object")) {
|
|
3854
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
3855
|
+
}
|
|
3856
|
+
return setProtoAbs(t0, p0);
|
|
3857
|
+
}
|
|
3690
3858
|
case "assign": {
|
|
3691
3859
|
if (!args.length) return unknown;
|
|
3692
3860
|
const t0 = args[0];
|
|
@@ -3703,7 +3871,11 @@ function evalObjectMethod(name, args) {
|
|
|
3703
3871
|
if (acc.shape.k === "obj" && src.shape.k === "obj") {
|
|
3704
3872
|
const base = acc.shape.slots;
|
|
3705
3873
|
const over = src.shape.slots;
|
|
3706
|
-
|
|
3874
|
+
const filtered = { ...base };
|
|
3875
|
+
for (const k of enumKeys(over, src)) {
|
|
3876
|
+
filtered[k] = over[k];
|
|
3877
|
+
}
|
|
3878
|
+
acc = abs({ k: "obj", slots: filtered }, void 0, void 0, confJoin(acc.conf, src.conf));
|
|
3707
3879
|
} else if (src.shape.k !== "obj") {
|
|
3708
3880
|
const srcSlots = assignSourceSlots(src);
|
|
3709
3881
|
if (srcSlots === void 0) {
|
|
@@ -3948,9 +4120,9 @@ function jsonValueToAbs(v2) {
|
|
|
3948
4120
|
if (Array.isArray(v2)) {
|
|
3949
4121
|
return abs({ k: "tuple", elements: v2.map(jsonValueToAbs) }, void 0, void 0, "exact");
|
|
3950
4122
|
}
|
|
3951
|
-
const slots =
|
|
4123
|
+
const slots = /* @__PURE__ */ Object.create(null);
|
|
3952
4124
|
for (const [k, sv] of Object.entries(v2)) {
|
|
3953
|
-
slots
|
|
4125
|
+
setSlot(slots, k, { value: jsonValueToAbs(sv) });
|
|
3954
4126
|
}
|
|
3955
4127
|
return abs({ k: "obj", slots }, void 0, void 0, "exact");
|
|
3956
4128
|
}
|
|
@@ -4004,9 +4176,7 @@ function evalJsonMethod(name, args) {
|
|
|
4004
4176
|
const t = spaceArg.term;
|
|
4005
4177
|
if (t?.op !== "lit") return str2("partial");
|
|
4006
4178
|
const sv = t.value;
|
|
4007
|
-
if (typeof sv === "number") {
|
|
4008
|
-
space = Number.isFinite(sv) ? Math.min(10, Math.max(0, Math.floor(sv))) : 0;
|
|
4009
|
-
} else if (typeof sv === "string") {
|
|
4179
|
+
if (typeof sv === "number" || typeof sv === "string") {
|
|
4010
4180
|
space = sv;
|
|
4011
4181
|
} else if (sv !== void 0 && sv !== null) {
|
|
4012
4182
|
return str2("partial");
|
|
@@ -4808,7 +4978,12 @@ function evalArrayStatic(name, args) {
|
|
|
4808
4978
|
return boolLit(false);
|
|
4809
4979
|
}
|
|
4810
4980
|
case "of":
|
|
4811
|
-
return abs(
|
|
4981
|
+
return abs(
|
|
4982
|
+
{ k: "tuple", elements: args.map((a) => asAbs(a) ?? unknown) },
|
|
4983
|
+
void 0,
|
|
4984
|
+
void 0,
|
|
4985
|
+
"exact"
|
|
4986
|
+
);
|
|
4812
4987
|
case "from": {
|
|
4813
4988
|
const mapFn = args[1];
|
|
4814
4989
|
const hasMapFn = mapFn !== void 0 && mapFn !== null;
|
|
@@ -5438,6 +5613,37 @@ function evalBuiltinNew(className, args) {
|
|
|
5438
5613
|
return evalPromiseCtor(args);
|
|
5439
5614
|
case "Array":
|
|
5440
5615
|
return makeArrayCtorAbs(args);
|
|
5616
|
+
case "Number":
|
|
5617
|
+
case "Boolean":
|
|
5618
|
+
return abs(
|
|
5619
|
+
{ k: "brand", name: className, shape: objOf({}) },
|
|
5620
|
+
void 0,
|
|
5621
|
+
void 0,
|
|
5622
|
+
"path"
|
|
5623
|
+
);
|
|
5624
|
+
case "String": {
|
|
5625
|
+
const a0 = args[0] ? litValue(args[0]) : void 0;
|
|
5626
|
+
if (typeof a0 === "string") {
|
|
5627
|
+
const slots = {
|
|
5628
|
+
length: { value: numLit(a0.length) }
|
|
5629
|
+
};
|
|
5630
|
+
for (let i = 0; i < a0.length; i++) {
|
|
5631
|
+
slots[String(i)] = { value: strLit(a0[i]) };
|
|
5632
|
+
}
|
|
5633
|
+
return abs(
|
|
5634
|
+
{ k: "brand", name: "String", shape: objOf(slots) },
|
|
5635
|
+
void 0,
|
|
5636
|
+
void 0,
|
|
5637
|
+
"exact"
|
|
5638
|
+
);
|
|
5639
|
+
}
|
|
5640
|
+
return abs(
|
|
5641
|
+
{ k: "brand", name: "String", shape: objOf({}, { open: true }) },
|
|
5642
|
+
void 0,
|
|
5643
|
+
void 0,
|
|
5644
|
+
"path"
|
|
5645
|
+
);
|
|
5646
|
+
}
|
|
5441
5647
|
case "Map":
|
|
5442
5648
|
if (ctorArgDefinitelyInvalid("Map", args[0])) {
|
|
5443
5649
|
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
@@ -5681,6 +5887,7 @@ function evalObjectProtoMethod(name, thisVal, args) {
|
|
|
5681
5887
|
if (!vObjLike && vk !== "sum" && vk !== "any" && vk !== "unknown") return boolLit(false);
|
|
5682
5888
|
if (vObjLike && isNullProtoObj(v2)) return boolLit(false);
|
|
5683
5889
|
if (isObjectProtoBrand(thisVal)) {
|
|
5890
|
+
if (isObjectProtoBrand(v2)) return boolLit(false);
|
|
5684
5891
|
return vObjLike ? boolLit(true) : boolPrimB();
|
|
5685
5892
|
}
|
|
5686
5893
|
return boolPrimB();
|
|
@@ -5714,27 +5921,50 @@ function objectProtoMethodAbs(name) {
|
|
|
5714
5921
|
function coercibleNumberLit(v2) {
|
|
5715
5922
|
return typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null;
|
|
5716
5923
|
}
|
|
5717
|
-
function
|
|
5718
|
-
|
|
5924
|
+
function isKnownNonBigintNumeric2(a) {
|
|
5925
|
+
const va = litValue(a);
|
|
5926
|
+
if (typeof va === "number" || typeof va === "boolean" || va === null) return true;
|
|
5927
|
+
if (a.term?.op === "lit" && a.term.value === void 0) return true;
|
|
5928
|
+
return a.shape.k === "prim" && (a.shape.type === "number" || a.shape.type === "boolean");
|
|
5929
|
+
}
|
|
5930
|
+
function isMaybeBigintOperand2(a) {
|
|
5931
|
+
return a.shape.k === "any" || a.shape.k === "unknown" || a.shape.k === "obj" || a.shape.k === "fn" || a.shape.k === "brand" || a.shape.k === "sum";
|
|
5719
5932
|
}
|
|
5720
5933
|
function foldNumericBinOp(a, b, numOp, bigOp) {
|
|
5721
5934
|
const va = litValue(a);
|
|
5722
5935
|
const vb = litValue(b);
|
|
5936
|
+
if (!bigOp && (typeof va === "bigint" || typeof vb === "bigint" || isBigPrim(a) || isBigPrim(b))) {
|
|
5937
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5938
|
+
}
|
|
5723
5939
|
if (typeof va === "bigint" || typeof vb === "bigint") {
|
|
5724
5940
|
if (typeof va === "bigint" && typeof vb === "bigint") {
|
|
5725
|
-
|
|
5941
|
+
const op = bigOp;
|
|
5726
5942
|
try {
|
|
5727
5943
|
return abs(
|
|
5728
5944
|
{ k: "prim", type: "bigint" },
|
|
5729
|
-
lit(
|
|
5945
|
+
lit(op(va, vb)),
|
|
5730
5946
|
pTrue,
|
|
5731
5947
|
"exact"
|
|
5732
5948
|
);
|
|
5733
|
-
} catch {
|
|
5734
|
-
|
|
5949
|
+
} catch (e) {
|
|
5950
|
+
if (e instanceof RangeError) throw new NudoThrow(errorTypeAbs("RangeError"));
|
|
5951
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5735
5952
|
}
|
|
5736
5953
|
}
|
|
5737
|
-
|
|
5954
|
+
const other = typeof va === "bigint" ? b : a;
|
|
5955
|
+
if (isBigPrim(other)) return void 0;
|
|
5956
|
+
if (!bigOp) throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5957
|
+
if (isKnownNonBigintNumeric2(other) || isStrPrim(other)) {
|
|
5958
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5959
|
+
}
|
|
5960
|
+
if (isMaybeBigintOperand2(other)) {
|
|
5961
|
+
recordMayThrow({
|
|
5962
|
+
kind: "TypeError",
|
|
5963
|
+
cause: "mixed bigint \u2297 abstract operand"
|
|
5964
|
+
});
|
|
5965
|
+
return void 0;
|
|
5966
|
+
}
|
|
5967
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5738
5968
|
}
|
|
5739
5969
|
if (coercibleNumberLit(va) && coercibleNumberLit(vb)) {
|
|
5740
5970
|
return abs(
|
|
@@ -5749,11 +5979,12 @@ function foldNumericBinOp(a, b, numOp, bigOp) {
|
|
|
5749
5979
|
function foldNumericUnOp(a, numOp, bigOp) {
|
|
5750
5980
|
const v2 = litValue(a);
|
|
5751
5981
|
if (typeof v2 === "bigint") {
|
|
5752
|
-
if (!bigOp)
|
|
5982
|
+
if (!bigOp) throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5753
5983
|
try {
|
|
5754
5984
|
return abs({ k: "prim", type: "bigint" }, lit(bigOp(v2)), pTrue, "exact");
|
|
5755
|
-
} catch {
|
|
5756
|
-
|
|
5985
|
+
} catch (e) {
|
|
5986
|
+
if (e instanceof RangeError) throw new NudoThrow(errorTypeAbs("RangeError"));
|
|
5987
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5757
5988
|
}
|
|
5758
5989
|
}
|
|
5759
5990
|
if (coercibleNumberLit(v2)) {
|
|
@@ -5806,10 +6037,65 @@ function ushrAbs(a, b) {
|
|
|
5806
6037
|
function powAbs(a, b) {
|
|
5807
6038
|
return foldNumericBinOp(a, b, (x, y) => x ** y, (x, y) => x ** y) ?? bitwiseResultShape(a, b);
|
|
5808
6039
|
}
|
|
6040
|
+
function toNumericAbs(a) {
|
|
6041
|
+
const v2 = litValue(a);
|
|
6042
|
+
if (typeof v2 === "bigint") return bigintLit(v2);
|
|
6043
|
+
if (isBigPrim(a)) return a;
|
|
6044
|
+
if (a.term?.op === "lit" && a.term.value === void 0) {
|
|
6045
|
+
return abs({ k: "prim", type: "number" }, lit(NaN), pTrue, "exact");
|
|
6046
|
+
}
|
|
6047
|
+
const n = toNumberAbs(a);
|
|
6048
|
+
if (n.shape.k === "unknown") {
|
|
6049
|
+
return abs({ k: "prim", type: "number" }, void 0, void 0, "partial");
|
|
6050
|
+
}
|
|
6051
|
+
return n;
|
|
6052
|
+
}
|
|
6053
|
+
function updateAddAbs(a) {
|
|
6054
|
+
const n = toNumericAbs(a);
|
|
6055
|
+
const one = n.shape.k === "prim" && n.shape.type === "bigint" ? bigintLit(1n) : numLit(1);
|
|
6056
|
+
if (n.shape.k === "prim" && n.shape.type === "bigint" && !n.term) {
|
|
6057
|
+
return abs({ k: "prim", type: "bigint" }, void 0, void 0, confJoin(n.conf, "exact"));
|
|
6058
|
+
}
|
|
6059
|
+
return addNumeric(n, one);
|
|
6060
|
+
}
|
|
6061
|
+
function updateSubAbs(a) {
|
|
6062
|
+
const n = toNumericAbs(a);
|
|
6063
|
+
const one = n.shape.k === "prim" && n.shape.type === "bigint" ? bigintLit(1n) : numLit(1);
|
|
6064
|
+
if (n.shape.k === "prim" && n.shape.type === "bigint" && !n.term) {
|
|
6065
|
+
return abs({ k: "prim", type: "bigint" }, void 0, void 0, confJoin(n.conf, "exact"));
|
|
6066
|
+
}
|
|
6067
|
+
return subNumeric(n, one);
|
|
6068
|
+
}
|
|
6069
|
+
function addNumeric(a, b) {
|
|
6070
|
+
const va = litValue(a);
|
|
6071
|
+
const vb = litValue(b);
|
|
6072
|
+
if (typeof va === "bigint" && typeof vb === "bigint") return bigintLit(va + vb);
|
|
6073
|
+
if (typeof va === "number" && typeof vb === "number") return numLit(va + vb);
|
|
6074
|
+
const big = a.shape.k === "prim" && a.shape.type === "bigint" || typeof va === "bigint";
|
|
6075
|
+
return abs(
|
|
6076
|
+
{ k: "prim", type: big ? "bigint" : "number" },
|
|
6077
|
+
void 0,
|
|
6078
|
+
void 0,
|
|
6079
|
+
confJoin(confJoin(a.conf, b.conf), "path")
|
|
6080
|
+
);
|
|
6081
|
+
}
|
|
6082
|
+
function subNumeric(a, b) {
|
|
6083
|
+
const va = litValue(a);
|
|
6084
|
+
const vb = litValue(b);
|
|
6085
|
+
if (typeof va === "bigint" && typeof vb === "bigint") return bigintLit(va - vb);
|
|
6086
|
+
if (typeof va === "number" && typeof vb === "number") return numLit(va - vb);
|
|
6087
|
+
const big = a.shape.k === "prim" && a.shape.type === "bigint" || typeof va === "bigint";
|
|
6088
|
+
return abs(
|
|
6089
|
+
{ k: "prim", type: big ? "bigint" : "number" },
|
|
6090
|
+
void 0,
|
|
6091
|
+
void 0,
|
|
6092
|
+
confJoin(confJoin(a.conf, b.conf), "path")
|
|
6093
|
+
);
|
|
6094
|
+
}
|
|
5809
6095
|
function toNumberAbs(a) {
|
|
5810
6096
|
const v2 = litValue(a);
|
|
5811
|
-
if (typeof v2 === "bigint") {
|
|
5812
|
-
|
|
6097
|
+
if (typeof v2 === "bigint" || isBigPrim(a)) {
|
|
6098
|
+
throw new NudoThrow(errorTypeAbs("TypeError"));
|
|
5813
6099
|
}
|
|
5814
6100
|
if (coercibleNumberLit(v2)) {
|
|
5815
6101
|
return abs({ k: "prim", type: "number" }, lit(Number(v2)), pTrue, "exact");
|
|
@@ -5984,8 +6270,8 @@ function strictEqAbs(a, b) {
|
|
|
5984
6270
|
if (an !== void 0 && bn !== void 0) return an === bn;
|
|
5985
6271
|
}
|
|
5986
6272
|
const aIsAbs = !!(a && typeof a === "object" && "shape" in a);
|
|
5987
|
-
const
|
|
5988
|
-
if (!aIsAbs || !
|
|
6273
|
+
const evalIsAbs = !!(b && typeof b === "object" && "shape" in b);
|
|
6274
|
+
if (!aIsAbs || !evalIsAbs) {
|
|
5989
6275
|
return a === b ? true : void 0;
|
|
5990
6276
|
}
|
|
5991
6277
|
if (a.term?.op === "lit" && b.term?.op === "lit") {
|
|
@@ -6011,8 +6297,8 @@ function strictEqAbs(a, b) {
|
|
|
6011
6297
|
const vb = litValue(b);
|
|
6012
6298
|
if (va !== void 0 && vb !== void 0) return va === vb;
|
|
6013
6299
|
const aNullish = va === null || a.term?.op === "lit" && a.term.value === void 0;
|
|
6014
|
-
const
|
|
6015
|
-
if (
|
|
6300
|
+
const evalNullish = vb === null || b.term?.op === "lit" && b.term.value === void 0;
|
|
6301
|
+
if (evalNullish && definitelyNotNullishShape(a.shape)) return false;
|
|
6016
6302
|
if (aNullish && definitelyNotNullishShape(b.shape)) return false;
|
|
6017
6303
|
if (a.term && b.term && a.term.op === "var" && b.term.op === "var" && a.term.id === b.term.id) {
|
|
6018
6304
|
const k = a.shape.k;
|
|
@@ -6090,6 +6376,18 @@ function isFoldableIndexArg(x) {
|
|
|
6090
6376
|
const v2 = x.term.value;
|
|
6091
6377
|
return v2 === void 0 || typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null;
|
|
6092
6378
|
}
|
|
6379
|
+
function toIntegerOrInfinityLit(x) {
|
|
6380
|
+
if (x === void 0) return 0;
|
|
6381
|
+
if (x.term?.op !== "lit") return void 0;
|
|
6382
|
+
const v2 = x.term.value;
|
|
6383
|
+
if (typeof v2 === "symbol" || typeof v2 === "bigint") return void 0;
|
|
6384
|
+
if (v2 === void 0) return 0;
|
|
6385
|
+
const n = Number(v2);
|
|
6386
|
+
if (Number.isNaN(n)) return 0;
|
|
6387
|
+
if (n === Infinity) return Infinity;
|
|
6388
|
+
if (n === -Infinity) return -Infinity;
|
|
6389
|
+
return Math.trunc(n);
|
|
6390
|
+
}
|
|
6093
6391
|
function toStringArg(x) {
|
|
6094
6392
|
if (x === void 0) return "undefined";
|
|
6095
6393
|
if (x.term?.op !== "lit") return void 0;
|
|
@@ -6100,6 +6398,14 @@ function toStringArg(x) {
|
|
|
6100
6398
|
function isUndefinedArg(x) {
|
|
6101
6399
|
return x === void 0 || x.term?.op === "lit" && x.term.value === void 0;
|
|
6102
6400
|
}
|
|
6401
|
+
function toUint32Limit(v2) {
|
|
6402
|
+
if (typeof v2 === "bigint" || typeof v2 === "symbol") return void 0;
|
|
6403
|
+
const n = Number(v2);
|
|
6404
|
+
if (!Number.isFinite(n) || n === 0) return 0;
|
|
6405
|
+
const int = Math.trunc(n);
|
|
6406
|
+
const mod2 = int % 4294967296;
|
|
6407
|
+
return mod2 < 0 ? mod2 + 4294967296 : mod2;
|
|
6408
|
+
}
|
|
6103
6409
|
function callAbsMethod(recv, name, args) {
|
|
6104
6410
|
if (!isStrRecv(recv)) return void 0;
|
|
6105
6411
|
const a0 = args[0] ? litValue(args[0]) : void 0;
|
|
@@ -6172,7 +6478,9 @@ function callAbsMethod(recv, name, args) {
|
|
|
6172
6478
|
if (name === "slice") {
|
|
6173
6479
|
return strLit(lit3.slice(a0, a1));
|
|
6174
6480
|
}
|
|
6175
|
-
|
|
6481
|
+
const start = toIntegerOrInfinityLit(args[0]) ?? 0;
|
|
6482
|
+
const end = isUndefinedArg(args[1]) ? lit3.length : toIntegerOrInfinityLit(args[1]) ?? 0;
|
|
6483
|
+
return strLit(lit3.substring(start, end));
|
|
6176
6484
|
}
|
|
6177
6485
|
return strPrim("path");
|
|
6178
6486
|
case "charAt": {
|
|
@@ -6180,6 +6488,14 @@ function callAbsMethod(recv, name, args) {
|
|
|
6180
6488
|
if (!isFoldableIndexArg(args[0])) return strPrim("path");
|
|
6181
6489
|
return strLit(lit3.charAt(Number(a0 ?? 0)));
|
|
6182
6490
|
}
|
|
6491
|
+
case "at": {
|
|
6492
|
+
if (lit3 === void 0) return strPrim("path");
|
|
6493
|
+
const iv = toIntegerOrInfinityLit(args[0]);
|
|
6494
|
+
if (iv === void 0) return strPrim("path");
|
|
6495
|
+
const idx = iv < 0 ? lit3.length + iv : iv;
|
|
6496
|
+
if (idx >= 0 && idx < lit3.length) return strLit(lit3[idx]);
|
|
6497
|
+
return undefAbs();
|
|
6498
|
+
}
|
|
6183
6499
|
case "toString":
|
|
6184
6500
|
case "valueOf":
|
|
6185
6501
|
return lit3 !== void 0 ? strLit(lit3) : strPrim("path");
|
|
@@ -6218,8 +6534,9 @@ function callAbsMethod(recv, name, args) {
|
|
|
6218
6534
|
if (isUndefinedArg(args[0])) {
|
|
6219
6535
|
const one = abs({ k: "tuple", elements: [strLit(lit3)] }, void 0, void 0, "exact");
|
|
6220
6536
|
if (lim === void 0) return one;
|
|
6221
|
-
const n =
|
|
6222
|
-
if (
|
|
6537
|
+
const n = toUint32Limit(lim);
|
|
6538
|
+
if (n === void 0) return strArr("path");
|
|
6539
|
+
if (n === 0) return abs({ k: "tuple", elements: [] }, void 0, void 0, "exact");
|
|
6223
6540
|
return one;
|
|
6224
6541
|
}
|
|
6225
6542
|
const sep = toStringArg(args[0]);
|
|
@@ -6417,7 +6734,12 @@ function mergeInstanceFields(instance, fields, className) {
|
|
|
6417
6734
|
const fieldObj = fields.shape.k === "brand" ? fields.shape.shape : fields;
|
|
6418
6735
|
if (fieldObj.shape.k === "obj") {
|
|
6419
6736
|
for (const [k, s] of Object.entries(fieldObj.shape.slots)) {
|
|
6420
|
-
slots
|
|
6737
|
+
Object.defineProperty(slots, k, {
|
|
6738
|
+
value: s,
|
|
6739
|
+
enumerable: true,
|
|
6740
|
+
writable: true,
|
|
6741
|
+
configurable: true
|
|
6742
|
+
});
|
|
6421
6743
|
}
|
|
6422
6744
|
}
|
|
6423
6745
|
return abs(
|
|
@@ -6612,15 +6934,23 @@ function classFromMethods(name, methods, superClass, superShape) {
|
|
|
6612
6934
|
const slots = {};
|
|
6613
6935
|
if (superShape?.shape.k === "obj") {
|
|
6614
6936
|
for (const [k, s] of Object.entries(superShape.shape.slots)) {
|
|
6615
|
-
slots
|
|
6937
|
+
Object.defineProperty(slots, k, {
|
|
6938
|
+
value: s,
|
|
6939
|
+
enumerable: true,
|
|
6940
|
+
writable: true,
|
|
6941
|
+
configurable: true
|
|
6942
|
+
});
|
|
6616
6943
|
}
|
|
6617
6944
|
}
|
|
6618
6945
|
for (const m of methods) {
|
|
6619
6946
|
methodMap.set(m.name, m);
|
|
6620
6947
|
if (m.kind !== "constructor") {
|
|
6621
|
-
slots
|
|
6622
|
-
value: abs({ k: "fn", params: m.params, name: m.name }, void 0, void 0, "exact")
|
|
6623
|
-
|
|
6948
|
+
Object.defineProperty(slots, m.name, {
|
|
6949
|
+
value: abs({ k: "fn", params: m.params, name: m.name }, void 0, void 0, "exact"),
|
|
6950
|
+
enumerable: true,
|
|
6951
|
+
writable: true,
|
|
6952
|
+
configurable: true
|
|
6953
|
+
});
|
|
6624
6954
|
}
|
|
6625
6955
|
}
|
|
6626
6956
|
return {
|
|
@@ -6655,21 +6985,21 @@ function leqAbs(src, tgt, opts = {}) {
|
|
|
6655
6985
|
function leqWithPred(src, tgt, phi2, env, depth) {
|
|
6656
6986
|
if (depth > 32) return fail("leq depth exceeded");
|
|
6657
6987
|
if (src.shape.k === "never") return ok();
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6988
|
+
const srcLitTerm = src.term?.op === "lit" ? src.term : void 0;
|
|
6989
|
+
const tgtLitTerm = tgt.term?.op === "lit" ? tgt.term : void 0;
|
|
6990
|
+
if (tgtLitTerm && srcLitTerm) {
|
|
6991
|
+
const sv = srcLitTerm.value;
|
|
6992
|
+
const tv = tgtLitTerm.value;
|
|
6993
|
+
const sameLit = sv === tv || typeof sv === "number" && typeof tv === "number" && Number.isNaN(sv) && Number.isNaN(tv);
|
|
6664
6994
|
if (sameLit) return ok();
|
|
6665
|
-
|
|
6666
|
-
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6670
|
-
return fail(`non-lit prim \u22AD lit ${String(tv)}`);
|
|
6671
|
-
}
|
|
6995
|
+
return fail(`lit ${String(sv)} \u22AD lit ${String(tv)}`);
|
|
6996
|
+
}
|
|
6997
|
+
if (tgtLitTerm && !srcLitTerm) {
|
|
6998
|
+
if (src.shape.k === "any") return ok();
|
|
6999
|
+
return fail(`non-lit \u22AD lit ${String(tgtLitTerm.value)}`);
|
|
6672
7000
|
}
|
|
7001
|
+
if (tgt.shape.k === "any" || tgt.shape.k === "unknown") return ok();
|
|
7002
|
+
if (src.shape.k === "any") return ok();
|
|
6673
7003
|
const shapeR = leqShape(src, tgt, phi2, env, depth);
|
|
6674
7004
|
if (!shapeR.ok) return shapeR;
|
|
6675
7005
|
return leqPred(src, tgt, phi2, depth);
|
|
@@ -6884,12 +7214,16 @@ function formatShape(a) {
|
|
|
6884
7214
|
case "any":
|
|
6885
7215
|
return "any";
|
|
6886
7216
|
case "unknown": {
|
|
6887
|
-
if (a.term?.op === "lit"
|
|
7217
|
+
if (a.term?.op === "lit") {
|
|
7218
|
+
if (a.term.value === void 0) return "undefined";
|
|
7219
|
+
if (a.term.value === null) return "null";
|
|
7220
|
+
}
|
|
6888
7221
|
return "unknown";
|
|
6889
7222
|
}
|
|
6890
7223
|
case "prim": {
|
|
6891
7224
|
const lv = litValue(a);
|
|
6892
7225
|
if (typeof lv === "number" && !Number.isFinite(lv)) return String(lv);
|
|
7226
|
+
if (typeof lv === "number" && Object.is(lv, -0)) return "-0";
|
|
6893
7227
|
if (typeof lv === "bigint") return `${String(lv)}n`;
|
|
6894
7228
|
if (lv !== void 0) return JSON.stringify(lv);
|
|
6895
7229
|
return s.type;
|
|
@@ -7247,7 +7581,12 @@ function litAbsFromJs(v2, depth = 0) {
|
|
|
7247
7581
|
if (proto === Object.prototype || proto === null) {
|
|
7248
7582
|
const slots = {};
|
|
7249
7583
|
for (const [k, val] of Object.entries(v2)) {
|
|
7250
|
-
slots
|
|
7584
|
+
Object.defineProperty(slots, k, {
|
|
7585
|
+
value: { value: litAbsFromJs(val, depth + 1) },
|
|
7586
|
+
enumerable: true,
|
|
7587
|
+
writable: true,
|
|
7588
|
+
configurable: true
|
|
7589
|
+
});
|
|
7251
7590
|
}
|
|
7252
7591
|
return objOf(slots);
|
|
7253
7592
|
}
|
|
@@ -7485,6 +7824,15 @@ function $pow(a, b) {
|
|
|
7485
7824
|
function $toNumber(a) {
|
|
7486
7825
|
return toNumberAbs(a);
|
|
7487
7826
|
}
|
|
7827
|
+
function $toNumeric(a) {
|
|
7828
|
+
return toNumericAbs(a);
|
|
7829
|
+
}
|
|
7830
|
+
function $updateAdd(a) {
|
|
7831
|
+
return updateAddAbs(a);
|
|
7832
|
+
}
|
|
7833
|
+
function $updateSub(a) {
|
|
7834
|
+
return updateSubAbs(a);
|
|
7835
|
+
}
|
|
7488
7836
|
function $neg(a) {
|
|
7489
7837
|
return negAbs(a);
|
|
7490
7838
|
}
|
|
@@ -8414,18 +8762,15 @@ function emitArrMutatorRebinds(expr, opts, pad) {
|
|
|
8414
8762
|
}
|
|
8415
8763
|
if (node.type === "UpdateExpression" && node.argument) {
|
|
8416
8764
|
const arg = node.argument;
|
|
8417
|
-
const fn = node.operator === "++" ? "$
|
|
8418
|
-
|
|
8419
|
-
if (arg.type === "Identifier" && arg.name) {
|
|
8420
|
-
if (isPostfix) lines.push(`${pad}${arg.name} = ${fn}(${arg.name}, $lit(1));`);
|
|
8421
|
-
} else if (arg.type === "MemberExpression") {
|
|
8765
|
+
const fn = node.operator === "++" ? "$updateAdd" : "$updateSub";
|
|
8766
|
+
if (arg.type === "MemberExpression") {
|
|
8422
8767
|
const path = memberPathOf(
|
|
8423
8768
|
arg,
|
|
8424
8769
|
opts
|
|
8425
8770
|
);
|
|
8426
8771
|
if (path) {
|
|
8427
8772
|
const readSrc = readPathSrc(path);
|
|
8428
|
-
lines.push(`${pad}${path.rootSrc} = ${setPathSrc(path, `${fn}(${readSrc}
|
|
8773
|
+
lines.push(`${pad}${path.rootSrc} = ${setPathSrc(path, `${fn}(${readSrc})`)};`);
|
|
8429
8774
|
}
|
|
8430
8775
|
}
|
|
8431
8776
|
}
|
|
@@ -9165,7 +9510,7 @@ ${pad}export default ${name};`;
|
|
|
9165
9510
|
const stepPart = (u) => {
|
|
9166
9511
|
const upd = u;
|
|
9167
9512
|
if (upd.type === "UpdateExpression" && upd.argument?.type === "Identifier" && upd.argument.name) {
|
|
9168
|
-
return `${upd.argument.name} = ${upd.operator === "++" ? "$
|
|
9513
|
+
return `${upd.argument.name} = ${upd.operator === "++" ? "$updateAdd" : "$updateSub"}(${upd.argument.name})`;
|
|
9169
9514
|
}
|
|
9170
9515
|
if (upd.type === "SequenceExpression") {
|
|
9171
9516
|
return (upd.expressions ?? []).map((e) => stepPart(e)).join(", ");
|
|
@@ -9884,6 +10229,128 @@ function transpileShortCircuitExpr(opts, parts) {
|
|
|
9884
10229
|
`})()`
|
|
9885
10230
|
].join("\n");
|
|
9886
10231
|
}
|
|
10232
|
+
function isChainLink(n) {
|
|
10233
|
+
return n.type === "MemberExpression" || n.type === "OptionalMemberExpression" || n.type === "CallExpression" || n.type === "OptionalCallExpression";
|
|
10234
|
+
}
|
|
10235
|
+
function linkIsOptional(n) {
|
|
10236
|
+
return n.optional === true;
|
|
10237
|
+
}
|
|
10238
|
+
function chainNeedsShortCircuit(n) {
|
|
10239
|
+
let cur = n;
|
|
10240
|
+
while (isChainLink(cur)) {
|
|
10241
|
+
if (linkIsOptional(cur)) return true;
|
|
10242
|
+
cur = cur.callee ?? cur.object;
|
|
10243
|
+
}
|
|
10244
|
+
return false;
|
|
10245
|
+
}
|
|
10246
|
+
function flattenChain(expr, opts) {
|
|
10247
|
+
const hops = [];
|
|
10248
|
+
let cur = expr;
|
|
10249
|
+
while (isChainLink(cur)) {
|
|
10250
|
+
const optional = linkIsOptional(cur);
|
|
10251
|
+
if (cur.type === "CallExpression" || cur.type === "OptionalCallExpression") {
|
|
10252
|
+
const args = (cur.arguments ?? []).map(
|
|
10253
|
+
(a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)
|
|
10254
|
+
).join(", ");
|
|
10255
|
+
const loc = cur.loc;
|
|
10256
|
+
const locArg = loc ? `, [${loc.start.line}, ${loc.start.column}]` : "";
|
|
10257
|
+
const callee = cur.callee;
|
|
10258
|
+
const calleeProp = callee?.property;
|
|
10259
|
+
const methodName = callee && (callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") ? !callee.computed && calleeProp?.type === "Identifier" ? calleeProp.name : callee.computed && calleeProp?.type === "StringLiteral" ? String(calleeProp.value) : void 0 : void 0;
|
|
10260
|
+
if (callee && methodName !== void 0) {
|
|
10261
|
+
const recvNode = callee.object;
|
|
10262
|
+
hops.unshift({
|
|
10263
|
+
kind: "invoke",
|
|
10264
|
+
method: JSON.stringify(methodName),
|
|
10265
|
+
argsSrc: `[${args}]`,
|
|
10266
|
+
locArg,
|
|
10267
|
+
recvOptional: linkIsOptional(callee),
|
|
10268
|
+
fnOptional: linkIsOptional(cur),
|
|
10269
|
+
recvName: recvNode?.type === "Identifier" && recvNode.name ? recvNode.name : void 0
|
|
10270
|
+
});
|
|
10271
|
+
cur = callee.object;
|
|
10272
|
+
continue;
|
|
10273
|
+
}
|
|
10274
|
+
hops.unshift({ kind: "call", argsSrc: `[${args}]`, optional: linkIsOptional(cur), locArg });
|
|
10275
|
+
cur = cur.callee ?? cur.object;
|
|
10276
|
+
continue;
|
|
10277
|
+
}
|
|
10278
|
+
const optionalM = optional;
|
|
10279
|
+
if (cur.computed) {
|
|
10280
|
+
const key = cur.property;
|
|
10281
|
+
if (key?.type === "StringLiteral") {
|
|
10282
|
+
hops.unshift({ kind: "get", key: JSON.stringify(key.value), optional: optionalM });
|
|
10283
|
+
} else if (key?.type === "NumericLiteral") {
|
|
10284
|
+
hops.unshift({ kind: "idx", keySrc: `$lit(${key.value})`, optional: optionalM });
|
|
10285
|
+
} else if (isExpression(cur.property)) {
|
|
10286
|
+
hops.unshift({
|
|
10287
|
+
kind: "idx",
|
|
10288
|
+
keySrc: transpileExpression(cur.property, opts),
|
|
10289
|
+
optional: optionalM
|
|
10290
|
+
});
|
|
10291
|
+
} else {
|
|
10292
|
+
return void 0;
|
|
10293
|
+
}
|
|
10294
|
+
cur = cur.object;
|
|
10295
|
+
continue;
|
|
10296
|
+
}
|
|
10297
|
+
const prop = cur.property;
|
|
10298
|
+
if (prop?.type !== "Identifier") return void 0;
|
|
10299
|
+
if (prop.name === "length") {
|
|
10300
|
+
hops.unshift({ kind: "len", optional: optionalM });
|
|
10301
|
+
} else {
|
|
10302
|
+
hops.unshift({ kind: "get", key: JSON.stringify(prop.name), optional: optionalM });
|
|
10303
|
+
}
|
|
10304
|
+
cur = cur.object;
|
|
10305
|
+
}
|
|
10306
|
+
if (cur.type === "Super") return void 0;
|
|
10307
|
+
const baseSrc = isExpression(cur) ? transpileExpression(cur, opts) : void 0;
|
|
10308
|
+
if (baseSrc === void 0) return void 0;
|
|
10309
|
+
return { baseSrc, hops };
|
|
10310
|
+
}
|
|
10311
|
+
function emitChainFrom(hops, i, valSrc) {
|
|
10312
|
+
if (i >= hops.length) return valSrc;
|
|
10313
|
+
const hop = hops[i];
|
|
10314
|
+
const rest = (recv) => emitChainFrom(hops, i + 1, recv);
|
|
10315
|
+
switch (hop.kind) {
|
|
10316
|
+
case "get":
|
|
10317
|
+
return hop.optional ? shortCircuitHop(valSrc, `$get($__oc, ${hop.key})`, hops, i) : rest(`$get(${valSrc}, ${hop.key})`);
|
|
10318
|
+
case "idx":
|
|
10319
|
+
return hop.optional ? shortCircuitHop(valSrc, `$idx($__oc, ${hop.keySrc})`, hops, i) : rest(`$idx(${valSrc}, ${hop.keySrc})`);
|
|
10320
|
+
case "len":
|
|
10321
|
+
return hop.optional ? shortCircuitHop(valSrc, `$len($__oc)`, hops, i) : rest(`$len(${valSrc})`);
|
|
10322
|
+
case "call":
|
|
10323
|
+
return hop.optional ? shortCircuitHop(valSrc, `$callNamed("call", $__oc, ${hop.argsSrc}${hop.locArg})`, hops, i) : rest(`$callNamed("call", ${valSrc}, ${hop.argsSrc}${hop.locArg})`);
|
|
10324
|
+
case "invoke": {
|
|
10325
|
+
const invokeOf = (recv, fnCheck) => {
|
|
10326
|
+
let call = `$invoke(${recv}, ${hop.method}, ${hop.argsSrc}${hop.locArg})`;
|
|
10327
|
+
const rawMethod = JSON.parse(hop.method);
|
|
10328
|
+
if (hop.recvName && REGEX_STATEFUL_NAMES.has(rawMethod)) {
|
|
10329
|
+
call = `(() => { const __v = ${call}; ${hop.recvName} = $reStateCall(${hop.recvName}, ${hop.method}, ${hop.argsSrc}); return __v; })()`;
|
|
10330
|
+
}
|
|
10331
|
+
if (!fnCheck) return call;
|
|
10332
|
+
return `(($__fn) => $fork($nullishTest($__fn), () => $lit(undefined), () => ${call}))($get(${recv}, ${hop.method}))`;
|
|
10333
|
+
};
|
|
10334
|
+
if (hop.recvOptional) {
|
|
10335
|
+
return shortCircuitHop(valSrc, invokeOf("$__oc", hop.fnOptional), hops, i);
|
|
10336
|
+
}
|
|
10337
|
+
return rest(invokeOf(valSrc, hop.fnOptional));
|
|
10338
|
+
}
|
|
10339
|
+
}
|
|
10340
|
+
}
|
|
10341
|
+
function shortCircuitHop(valSrc, appliedWithOc, hops, i) {
|
|
10342
|
+
return `(($__oc) => $fork($nullishTest($__oc), () => $lit(undefined), () => ${emitChainFrom(hops, i + 1, appliedWithOc)}))(${valSrc})`;
|
|
10343
|
+
}
|
|
10344
|
+
function tryTranspileOptionalChain(expr, opts) {
|
|
10345
|
+
const t = expr.type;
|
|
10346
|
+
if (t !== "MemberExpression" && t !== "OptionalMemberExpression" && t !== "CallExpression" && t !== "OptionalCallExpression") {
|
|
10347
|
+
return void 0;
|
|
10348
|
+
}
|
|
10349
|
+
if (!chainNeedsShortCircuit(expr)) return void 0;
|
|
10350
|
+
const flat = flattenChain(expr, opts);
|
|
10351
|
+
if (!flat) return void 0;
|
|
10352
|
+
return emitChainFrom(flat.hops, 0, flat.baseSrc);
|
|
10353
|
+
}
|
|
9887
10354
|
function transpileExpression(expr, opts = {}) {
|
|
9888
10355
|
const rep = matchReplacement(expr, opts);
|
|
9889
10356
|
if (rep) return rep;
|
|
@@ -9891,6 +10358,8 @@ function transpileExpression(expr, opts = {}) {
|
|
|
9891
10358
|
if (anyExpr.type === "ChainExpression" && anyExpr.expression) {
|
|
9892
10359
|
return transpileExpression(anyExpr.expression, opts);
|
|
9893
10360
|
}
|
|
10361
|
+
const chainSrc = tryTranspileOptionalChain(expr, opts);
|
|
10362
|
+
if (chainSrc !== void 0) return chainSrc;
|
|
9894
10363
|
if (anyExpr.type === "Super") {
|
|
9895
10364
|
return `/* super */`;
|
|
9896
10365
|
}
|
|
@@ -10011,18 +10480,18 @@ function transpileExpression(expr, opts = {}) {
|
|
|
10011
10480
|
}
|
|
10012
10481
|
case "UpdateExpression": {
|
|
10013
10482
|
const arg = expr.argument;
|
|
10014
|
-
const fn = expr.operator === "++" ? "$
|
|
10483
|
+
const fn = expr.operator === "++" ? "$updateAdd" : "$updateSub";
|
|
10015
10484
|
if (arg.type === "Identifier") {
|
|
10016
|
-
if (expr.prefix) return `${arg.name} = ${fn}(${arg.name}
|
|
10017
|
-
return arg.name
|
|
10485
|
+
if (expr.prefix) return `${arg.name} = ${fn}(${arg.name})`;
|
|
10486
|
+
return `((__old) => (${arg.name} = ${fn}(__old), __old))($toNumeric(${arg.name}))`;
|
|
10018
10487
|
}
|
|
10019
10488
|
if (arg.type === "MemberExpression") {
|
|
10020
10489
|
const m = arg;
|
|
10021
10490
|
const path = memberPathOf(m, opts);
|
|
10022
10491
|
if (path) {
|
|
10023
10492
|
const readSrc = readPathSrc(path);
|
|
10024
|
-
if (expr.prefix) return `${fn}(${readSrc}
|
|
10025
|
-
return readSrc
|
|
10493
|
+
if (expr.prefix) return `${fn}(${readSrc})`;
|
|
10494
|
+
return `$toNumeric(${readSrc})`;
|
|
10026
10495
|
}
|
|
10027
10496
|
}
|
|
10028
10497
|
return `/* update ${expr.operator} */ $lit(undefined)`;
|
|
@@ -10056,6 +10525,7 @@ function transpileExpression(expr, opts = {}) {
|
|
|
10056
10525
|
let acc = null;
|
|
10057
10526
|
const props = [];
|
|
10058
10527
|
const accRegs = [];
|
|
10528
|
+
let protoSet = null;
|
|
10059
10529
|
const flushProps = () => {
|
|
10060
10530
|
if (props.length === 0) return;
|
|
10061
10531
|
const obj2 = `$obj({ ${props.join(", ")} })`;
|
|
@@ -10077,6 +10547,7 @@ function transpileExpression(expr, opts = {}) {
|
|
|
10077
10547
|
return symbolKeyOf(prop.key);
|
|
10078
10548
|
})();
|
|
10079
10549
|
if (mkey === null) continue;
|
|
10550
|
+
const isProtoKey = mkey === '"__proto__"';
|
|
10080
10551
|
const displayNames = paramDisplayNames(prop.params);
|
|
10081
10552
|
const bindNames = methodBindNames(prop.params);
|
|
10082
10553
|
const mHasArgs = fnBodyHasOwnArguments({ body: prop.body });
|
|
@@ -10088,7 +10559,12 @@ function transpileExpression(expr, opts = {}) {
|
|
|
10088
10559
|
argsBinding: mHasArgs ? "__nudoArgs" : void 0
|
|
10089
10560
|
};
|
|
10090
10561
|
if (prop.kind === "get" || prop.kind === "set") {
|
|
10091
|
-
|
|
10562
|
+
const slotSrc = `${mkey}: $lit(undefined)`;
|
|
10563
|
+
if (isProtoKey) {
|
|
10564
|
+
acc = `$setKey(${acc ?? "$obj({})"}, $lit("__proto__"), $lit(undefined))`;
|
|
10565
|
+
} else {
|
|
10566
|
+
props.push(slotSrc);
|
|
10567
|
+
}
|
|
10092
10568
|
if (prop.kind === "get") {
|
|
10093
10569
|
const bodySrc2 = `{
|
|
10094
10570
|
${emitFnBlockBody(prop.body, 1, methodOpts)}
|
|
@@ -10121,7 +10597,11 @@ return __this;
|
|
|
10121
10597
|
${mBodyInner}
|
|
10122
10598
|
}`;
|
|
10123
10599
|
const fnValSrc = `$fnVal([${displayNames.map((p) => JSON.stringify(p)).join(", ")}], (${mParams.join(", ")}) => ${bodySrc}, { bindThis: true })`;
|
|
10124
|
-
|
|
10600
|
+
if (isProtoKey) {
|
|
10601
|
+
acc = `$setKey(${acc ?? "$obj({})"}, $lit("__proto__"), ${fnValSrc})`;
|
|
10602
|
+
} else {
|
|
10603
|
+
props.push(`${mkey}: ${fnValSrc}`);
|
|
10604
|
+
}
|
|
10125
10605
|
continue;
|
|
10126
10606
|
}
|
|
10127
10607
|
if (prop.type !== "ObjectProperty") continue;
|
|
@@ -10143,6 +10623,10 @@ ${mBodyInner}
|
|
|
10143
10623
|
return k === null ? null : JSON.stringify(k);
|
|
10144
10624
|
})();
|
|
10145
10625
|
if (key === null) continue;
|
|
10626
|
+
if (!prop.computed && key === '"__proto__"') {
|
|
10627
|
+
protoSet = transpileExpression(prop.value, opts);
|
|
10628
|
+
continue;
|
|
10629
|
+
}
|
|
10146
10630
|
if (prop.value.type === "FunctionExpression" && !prop.value.async) {
|
|
10147
10631
|
const fn = prop.value;
|
|
10148
10632
|
if (!fn.generator) {
|
|
@@ -10183,6 +10667,7 @@ ${mBodyInner}
|
|
|
10183
10667
|
for (const r of accRegs) {
|
|
10184
10668
|
result = `$objAccessor(${result}, ${r.key}, ${r.get ?? "null"}, ${r.set ?? "null"})`;
|
|
10185
10669
|
}
|
|
10670
|
+
if (protoSet !== null) result = `$setProto(${result}, ${protoSet})`;
|
|
10186
10671
|
return result;
|
|
10187
10672
|
}
|
|
10188
10673
|
case "MemberExpression":
|
|
@@ -10521,13 +11006,13 @@ function transpileSource(source, opts = {}) {
|
|
|
10521
11006
|
return transpileFile(file, { ...opts, source: opts.source ?? source });
|
|
10522
11007
|
}
|
|
10523
11008
|
function runtimeImportOf(runtime) {
|
|
10524
|
-
return `import { $add, $sub, $mul, $div, $mod, $bitand, $bitor, $bitxor, $bitnot, $shl, $shr, $ushr, $pow, $toNumber, $in, $instanceof, $instanceofNonIdent, $classExpr, $del, $delRes, $objAccessor, $neg, $typeof, $not, $eq, $ne, $eqLoose, $neLoose, $lt, $le, $gt, $ge, $join, $lit, $fork, $for, $forIter, $obj, $get, $set, $while, $whileSeq, $arr, $arrWithHoles, $arrMutContainer, $idx, $idxSet, $len, $call, $throw, $loopReturn, $loopBreak, $loopContinue, $class, $new, $invoke, $invokeSuper, $super, $async, $copy, $await, $asyncReturn, $orDefault, $callNamed, $optionalGet, $optionalInvoke, $spread, $concat, $forOf, $forInKeys, $catchVal, $switch, $staticInvoke, $setKey, $gen, $yield, $fnVal, $regex, $reStateCall, $rethrowIfNudoReturn, $nullishTest, $tryMark, $assignRecord, $recordBinding, $unknown, $importMeta, $dynamicImport, $tryTakeSince, $tryCurrentMark, $tryPopMark, $tryDigestSoftCatch, $tryReleaseSoftOut, $tryDetachSoftCatch, $tryDiscardSoft, $tryOrphanSoft, $pushLoopExit, $objRest, $arrRest, $arguments, $isForkExit, $rawThis, $isBreakTo } from ${JSON.stringify(runtime)};`;
|
|
11009
|
+
return `import { $add, $sub, $mul, $div, $mod, $bitand, $bitor, $bitxor, $bitnot, $shl, $shr, $ushr, $pow, $toNumber, $toNumeric, $updateAdd, $updateSub, $in, $instanceof, $instanceofNonIdent, $classExpr, $del, $delRes, $objAccessor, $neg, $typeof, $not, $eq, $ne, $eqLoose, $neLoose, $lt, $le, $gt, $ge, $join, $lit, $fork, $for, $forIter, $obj, $get, $set, $setProto, $while, $whileSeq, $arr, $arrWithHoles, $arrMutContainer, $idx, $idxSet, $len, $call, $throw, $loopReturn, $loopBreak, $loopContinue, $class, $new, $invoke, $invokeSuper, $super, $async, $copy, $await, $asyncReturn, $orDefault, $callNamed, $optionalGet, $optionalInvoke, $spread, $concat, $forOf, $forInKeys, $catchVal, $switch, $staticInvoke, $setKey, $gen, $yield, $fnVal, $regex, $reStateCall, $rethrowIfNudoReturn, $nullishTest, $tryMark, $assignRecord, $recordBinding, $unknown, $importMeta, $dynamicImport, $tryTakeSince, $tryCurrentMark, $tryPopMark, $tryDigestSoftCatch, $tryReleaseSoftOut, $tryDetachSoftCatch, $tryDiscardSoft, $tryOrphanSoft, $pushLoopExit, $objRest, $arrRest, $arguments, $isForkExit, $rawThis, $isBreakTo } from ${JSON.stringify(runtime)};`;
|
|
10525
11010
|
}
|
|
10526
11011
|
function transpileFile(file, opts = {}) {
|
|
10527
11012
|
const runtime = opts.runtimeImport ?? "@nudojs/core/exec";
|
|
10528
11013
|
const lines = [
|
|
10529
|
-
`// nudo
|
|
10530
|
-
`import { $add, $sub, $mul, $div, $mod, $bitand, $bitor, $bitxor, $bitnot, $shl, $shr, $ushr, $pow, $toNumber, $in, $instanceof, $instanceofNonIdent, $classExpr, $del, $delRes, $objAccessor, $neg, $typeof, $not, $eq, $ne, $eqLoose, $neLoose, $lt, $le, $gt, $ge, $join, $lit, $fork, $for, $forIter, $obj, $get, $set, $while, $whileSeq, $arr, $arrWithHoles, $arrMutContainer, $idx, $idxSet, $len, $call, $throw, $loopReturn, $loopBreak, $loopContinue, $class, $new, $invoke, $invokeSuper, $super, $async, $copy, $await, $asyncReturn, $orDefault, $callNamed, $optionalGet, $optionalInvoke, $spread, $concat, $forOf, $forInKeys, $catchVal, $switch, $staticInvoke, $setKey, $gen, $yield, $fnVal, $regex, $reStateCall, $rethrowIfNudoReturn, $nullishTest, $tryMark, $assignRecord, $recordBinding, $unknown, $importMeta, $dynamicImport, $tryTakeSince, $tryCurrentMark, $tryPopMark, $tryDigestSoftCatch, $tryReleaseSoftOut, $tryDetachSoftCatch, $tryDiscardSoft, $tryOrphanSoft, $pushLoopExit, $objRest, $arrRest, $arguments, $isForkExit, $rawThis, $isBreakTo } from ${JSON.stringify(runtime)};`,
|
|
11014
|
+
`// nudo evaluator transpile \u2014 values are Abs; operators are overloaded calls`,
|
|
11015
|
+
`import { $add, $sub, $mul, $div, $mod, $bitand, $bitor, $bitxor, $bitnot, $shl, $shr, $ushr, $pow, $toNumber, $toNumeric, $updateAdd, $updateSub, $in, $instanceof, $instanceofNonIdent, $classExpr, $del, $delRes, $objAccessor, $neg, $typeof, $not, $eq, $ne, $eqLoose, $neLoose, $lt, $le, $gt, $ge, $join, $lit, $fork, $for, $forIter, $obj, $get, $set, $setProto, $while, $whileSeq, $arr, $arrWithHoles, $arrMutContainer, $idx, $idxSet, $len, $call, $throw, $loopReturn, $loopBreak, $loopContinue, $class, $new, $invoke, $invokeSuper, $super, $async, $copy, $await, $asyncReturn, $orDefault, $callNamed, $optionalGet, $optionalInvoke, $spread, $concat, $forOf, $forInKeys, $catchVal, $switch, $staticInvoke, $setKey, $gen, $yield, $fnVal, $regex, $reStateCall, $rethrowIfNudoReturn, $nullishTest, $tryMark, $assignRecord, $recordBinding, $unknown, $importMeta, $dynamicImport, $tryTakeSince, $tryCurrentMark, $tryPopMark, $tryDigestSoftCatch, $tryReleaseSoftOut, $tryDetachSoftCatch, $tryDiscardSoft, $tryOrphanSoft, $pushLoopExit, $objRest, $arrRest, $arguments, $isForkExit, $rawThis, $isBreakTo } from ${JSON.stringify(runtime)};`,
|
|
10531
11016
|
``
|
|
10532
11017
|
];
|
|
10533
11018
|
for (const stmt of file.program.body) {
|
|
@@ -10552,11 +11037,11 @@ function getAbsCallBudgetStats() {
|
|
|
10552
11037
|
return {
|
|
10553
11038
|
calls: _absTotalCalls,
|
|
10554
11039
|
maxCalls: MAX_TOTAL_CALLS,
|
|
10555
|
-
forks:
|
|
10556
|
-
maxForks:
|
|
11040
|
+
forks: _evalForkCount,
|
|
11041
|
+
maxForks: _evalForkBudgetLimit,
|
|
10557
11042
|
callTruncated: _callTruncated,
|
|
10558
|
-
forkTruncated:
|
|
10559
|
-
truncated: _callTruncated ||
|
|
11043
|
+
forkTruncated: _evalForkTruncNoted,
|
|
11044
|
+
truncated: _callTruncated || _evalForkTruncNoted
|
|
10560
11045
|
};
|
|
10561
11046
|
}
|
|
10562
11047
|
function resetAbsCallBudget() {
|
|
@@ -10564,7 +11049,7 @@ function resetAbsCallBudget() {
|
|
|
10564
11049
|
_absTotalCalls = 0;
|
|
10565
11050
|
_activeCallKeys = [];
|
|
10566
11051
|
_callTruncated = false;
|
|
10567
|
-
|
|
11052
|
+
resetEvalForkBudget();
|
|
10568
11053
|
}
|
|
10569
11054
|
function stableCallId(obj2) {
|
|
10570
11055
|
let id = _fnCallIds.get(obj2);
|
|
@@ -10614,41 +11099,41 @@ function exitCall() {
|
|
|
10614
11099
|
_absCallDepth--;
|
|
10615
11100
|
_activeCallKeys.pop();
|
|
10616
11101
|
}
|
|
10617
|
-
var
|
|
10618
|
-
var
|
|
10619
|
-
var
|
|
10620
|
-
var
|
|
11102
|
+
var MAX_EVAL_TOTAL_FORKS = 5e3;
|
|
11103
|
+
var _evalForkBudgetLimit = MAX_EVAL_TOTAL_FORKS;
|
|
11104
|
+
var _evalForkCount = 0;
|
|
11105
|
+
var _evalForkTruncNoted = false;
|
|
10621
11106
|
var FORK_TRUNCATION_LABEL = "#fork-budget";
|
|
10622
11107
|
var HOST_EFFECT_LABEL_PREFIX = "#host-effect:";
|
|
10623
11108
|
function noteHostEffectBlocked(name) {
|
|
10624
11109
|
noteAbsTruncation(`${HOST_EFFECT_LABEL_PREFIX}${name}`);
|
|
10625
11110
|
}
|
|
10626
|
-
function
|
|
11111
|
+
function noteEvalForkTruncation() {
|
|
10627
11112
|
noteAbsTruncation(FORK_TRUNCATION_LABEL);
|
|
10628
11113
|
}
|
|
10629
|
-
function
|
|
11114
|
+
function setEvalForkBudgetLimit(n) {
|
|
10630
11115
|
if (typeof n === "number" && Number.isFinite(n) && n >= 1) {
|
|
10631
|
-
|
|
11116
|
+
_evalForkBudgetLimit = Math.floor(n);
|
|
10632
11117
|
} else {
|
|
10633
|
-
|
|
11118
|
+
_evalForkBudgetLimit = MAX_EVAL_TOTAL_FORKS;
|
|
10634
11119
|
}
|
|
10635
|
-
return
|
|
11120
|
+
return _evalForkBudgetLimit;
|
|
10636
11121
|
}
|
|
10637
|
-
function
|
|
10638
|
-
return
|
|
11122
|
+
function getEvalForkBudgetLimit() {
|
|
11123
|
+
return _evalForkBudgetLimit;
|
|
10639
11124
|
}
|
|
10640
|
-
function
|
|
10641
|
-
return
|
|
11125
|
+
function getEvalForkCount() {
|
|
11126
|
+
return _evalForkCount;
|
|
10642
11127
|
}
|
|
10643
|
-
function
|
|
10644
|
-
|
|
10645
|
-
|
|
11128
|
+
function resetEvalForkBudget() {
|
|
11129
|
+
_evalForkCount = 0;
|
|
11130
|
+
_evalForkTruncNoted = false;
|
|
10646
11131
|
}
|
|
10647
|
-
function
|
|
10648
|
-
if (++
|
|
10649
|
-
if (!
|
|
10650
|
-
|
|
10651
|
-
|
|
11132
|
+
function bumpEvalForkBudget() {
|
|
11133
|
+
if (++_evalForkCount <= _evalForkBudgetLimit) return true;
|
|
11134
|
+
if (!_evalForkTruncNoted) {
|
|
11135
|
+
_evalForkTruncNoted = true;
|
|
11136
|
+
noteEvalForkTruncation();
|
|
10652
11137
|
}
|
|
10653
11138
|
return false;
|
|
10654
11139
|
}
|
|
@@ -10723,6 +11208,7 @@ __export(runtime_exports, {
|
|
|
10723
11208
|
$regex: () => $regex,
|
|
10724
11209
|
$rethrowIfNudoReturn: () => $rethrowIfNudoReturn,
|
|
10725
11210
|
$set: () => $set,
|
|
11211
|
+
$setProto: () => $setProto,
|
|
10726
11212
|
$shl: () => $shl,
|
|
10727
11213
|
$shr: () => $shr,
|
|
10728
11214
|
$spread: () => $spread,
|
|
@@ -10730,6 +11216,7 @@ __export(runtime_exports, {
|
|
|
10730
11216
|
$switch: () => $switch,
|
|
10731
11217
|
$throw: () => $throw,
|
|
10732
11218
|
$toNumber: () => $toNumber,
|
|
11219
|
+
$toNumeric: () => $toNumeric,
|
|
10733
11220
|
$tryCurrentMark: () => $tryCurrentMark,
|
|
10734
11221
|
$tryDetachSoftCatch: () => $tryDetachSoftCatch,
|
|
10735
11222
|
$tryDigestSoftCatch: () => $tryDigestSoftCatch,
|
|
@@ -10742,6 +11229,8 @@ __export(runtime_exports, {
|
|
|
10742
11229
|
$tryTakeSince: () => $tryTakeSince,
|
|
10743
11230
|
$typeof: () => $typeof,
|
|
10744
11231
|
$unknown: () => $unknown,
|
|
11232
|
+
$updateAdd: () => $updateAdd,
|
|
11233
|
+
$updateSub: () => $updateSub,
|
|
10745
11234
|
$ushr: () => $ushr,
|
|
10746
11235
|
$while: () => $while,
|
|
10747
11236
|
$whileSeq: () => $whileSeq,
|
|
@@ -10775,10 +11264,10 @@ __export(runtime_exports, {
|
|
|
10775
11264
|
|
|
10776
11265
|
// src/algebra/exec/class-registry.ts
|
|
10777
11266
|
var classRegistry = /* @__PURE__ */ new Map();
|
|
10778
|
-
function
|
|
11267
|
+
function registerEvalClass(spec) {
|
|
10779
11268
|
classRegistry.set(spec.name, spec);
|
|
10780
11269
|
}
|
|
10781
|
-
function
|
|
11270
|
+
function getEvalClass(name) {
|
|
10782
11271
|
return classRegistry.get(name);
|
|
10783
11272
|
}
|
|
10784
11273
|
function clearBClasses() {
|
|
@@ -10821,9 +11310,9 @@ function findClassAccessor(startName, key) {
|
|
|
10821
11310
|
const seen = /* @__PURE__ */ new Set();
|
|
10822
11311
|
while (cur && !seen.has(cur)) {
|
|
10823
11312
|
seen.add(cur);
|
|
10824
|
-
const acc =
|
|
11313
|
+
const acc = getEvalClass(cur)?.accessors?.[key];
|
|
10825
11314
|
if (acc) return acc;
|
|
10826
|
-
cur =
|
|
11315
|
+
cur = getEvalClass(cur)?.superName;
|
|
10827
11316
|
}
|
|
10828
11317
|
return void 0;
|
|
10829
11318
|
}
|
|
@@ -10832,9 +11321,9 @@ function findStaticClassAccessor(startName, key) {
|
|
|
10832
11321
|
const seen = /* @__PURE__ */ new Set();
|
|
10833
11322
|
while (cur && !seen.has(cur)) {
|
|
10834
11323
|
seen.add(cur);
|
|
10835
|
-
const acc =
|
|
11324
|
+
const acc = getEvalClass(cur)?.staticAccessors?.[key];
|
|
10836
11325
|
if (acc) return acc;
|
|
10837
|
-
cur =
|
|
11326
|
+
cur = getEvalClass(cur)?.superName;
|
|
10838
11327
|
}
|
|
10839
11328
|
return void 0;
|
|
10840
11329
|
}
|
|
@@ -10845,10 +11334,11 @@ function $in(key, o) {
|
|
|
10845
11334
|
if (o.shape.k === "prim" || o.shape.k === "never" || isNullishLitAbs(o)) {
|
|
10846
11335
|
return unknown;
|
|
10847
11336
|
}
|
|
10848
|
-
const
|
|
10849
|
-
if (
|
|
10850
|
-
return
|
|
11337
|
+
const keyStr = propertyKeyOf(key);
|
|
11338
|
+
if (keyStr === void 0) {
|
|
11339
|
+
return bool();
|
|
10851
11340
|
}
|
|
11341
|
+
const kv = keyStr;
|
|
10852
11342
|
if (o.shape.k === "tuple") {
|
|
10853
11343
|
if (kv === "length") return boolLit(true);
|
|
10854
11344
|
const idx = canonicalArrayIndex(kv);
|
|
@@ -10859,8 +11349,6 @@ function $in(key, o) {
|
|
|
10859
11349
|
return boolLit(false);
|
|
10860
11350
|
}
|
|
10861
11351
|
if (o.shape.k === "arr") return bool();
|
|
10862
|
-
const keyStr = typeof kv === "number" ? String(kv) : typeof kv === "string" ? kv : void 0;
|
|
10863
|
-
if (keyStr === void 0) return bool();
|
|
10864
11352
|
if (o.shape.k === "obj" || o.shape.k === "brand") {
|
|
10865
11353
|
const objShape = o.shape.k === "brand" ? o.shape.shape.shape.k === "obj" ? o.shape.shape.shape : void 0 : o.shape;
|
|
10866
11354
|
if (!objShape) return bool();
|
|
@@ -10877,6 +11365,9 @@ function $in(key, o) {
|
|
|
10877
11365
|
return boolLit(OBJECT_PROTO_NAMES.has(keyStr));
|
|
10878
11366
|
}
|
|
10879
11367
|
if (o.shape.k === "fn") {
|
|
11368
|
+
if (o.shape.slots && getSlot(o.shape.slots, keyStr) && !o.shape.slots[keyStr].optional) {
|
|
11369
|
+
return boolLit(true);
|
|
11370
|
+
}
|
|
10880
11371
|
return boolLit(OBJECT_PROTO_NAMES.has(keyStr) || FUNCTION_PROTO_NAMES.has(keyStr));
|
|
10881
11372
|
}
|
|
10882
11373
|
if (o.shape.k === "eff") {
|
|
@@ -10897,8 +11388,8 @@ var BUILTIN_BRAND_METHODS = {
|
|
|
10897
11388
|
Promise: /* @__PURE__ */ new Set(["then", "catch", "finally"])
|
|
10898
11389
|
};
|
|
10899
11390
|
function brandHasProtoMember(brandName, key) {
|
|
10900
|
-
for (const name of
|
|
10901
|
-
const spec =
|
|
11391
|
+
for (const name of evalClassChain(brandName)) {
|
|
11392
|
+
const spec = getEvalClass(name);
|
|
10902
11393
|
if (spec?.methods?.[key]) return true;
|
|
10903
11394
|
if (spec?.accessors?.[key]) return true;
|
|
10904
11395
|
const builtin = BUILTIN_BRAND_METHODS[name];
|
|
@@ -10916,12 +11407,12 @@ var BUILTIN_ERROR_SUPER2 = {
|
|
|
10916
11407
|
EvalError: "Error",
|
|
10917
11408
|
AggregateError: "Error"
|
|
10918
11409
|
};
|
|
10919
|
-
function
|
|
11410
|
+
function evalClassChain(name) {
|
|
10920
11411
|
const out = [name];
|
|
10921
11412
|
let cur = name;
|
|
10922
11413
|
let depth = 0;
|
|
10923
11414
|
while (cur && depth++ < 32) {
|
|
10924
|
-
const spec =
|
|
11415
|
+
const spec = getEvalClass(cur);
|
|
10925
11416
|
const parent = spec?.superName ?? BUILTIN_ERROR_SUPER2[cur];
|
|
10926
11417
|
if (!parent || out.includes(parent)) break;
|
|
10927
11418
|
out.push(parent);
|
|
@@ -10978,7 +11469,7 @@ function $instanceof(left, rightName, rightVal) {
|
|
|
10978
11469
|
return boolLit(rightName === "Function" || rightName === "Object");
|
|
10979
11470
|
}
|
|
10980
11471
|
return boolLit(
|
|
10981
|
-
rightName === "Object" ||
|
|
11472
|
+
rightName === "Object" || evalClassChain(left.shape.name).includes(rightName)
|
|
10982
11473
|
);
|
|
10983
11474
|
case "arr":
|
|
10984
11475
|
case "tuple":
|
|
@@ -11064,7 +11555,7 @@ function $delRes(o, _key) {
|
|
|
11064
11555
|
return bool();
|
|
11065
11556
|
}
|
|
11066
11557
|
function $del(o, key) {
|
|
11067
|
-
const
|
|
11558
|
+
const keyStr = propertyKeyOf(key);
|
|
11068
11559
|
if (o.shape.k === "sum") {
|
|
11069
11560
|
return abs(
|
|
11070
11561
|
{ k: "sum", members: o.shape.members.map((m) => $del(m, key)) },
|
|
@@ -11083,7 +11574,6 @@ function $del(o, key) {
|
|
|
11083
11574
|
if (clsName) markClassValue(next, clsName);
|
|
11084
11575
|
return next;
|
|
11085
11576
|
}
|
|
11086
|
-
const keyStr = typeof kv === "number" ? String(kv) : typeof kv === "string" ? kv : void 0;
|
|
11087
11577
|
if (o.shape.k === "obj" && keyStr !== void 0) {
|
|
11088
11578
|
if (getPropFlags(o)?.get(keyStr)?.configurable === false) throwStrictWrite();
|
|
11089
11579
|
if (o.shape.open) return o;
|
|
@@ -11098,7 +11588,7 @@ function $del(o, key) {
|
|
|
11098
11588
|
return o;
|
|
11099
11589
|
}
|
|
11100
11590
|
if (o.shape.k === "tuple") {
|
|
11101
|
-
const idx = canonicalArrayIndex(
|
|
11591
|
+
const idx = canonicalArrayIndex(keyStr);
|
|
11102
11592
|
if (idx === void 0 || idx >= o.shape.elements.length) return o;
|
|
11103
11593
|
o.shape.elements[idx] = $lit(void 0);
|
|
11104
11594
|
if (!o.shape.holes) o.shape.holes = [];
|
|
@@ -11173,7 +11663,9 @@ function toIOI(v2) {
|
|
|
11173
11663
|
return Math.trunc(lv);
|
|
11174
11664
|
}
|
|
11175
11665
|
if (typeof lv === "string" || typeof lv === "boolean") {
|
|
11176
|
-
|
|
11666
|
+
const n = Number(lv);
|
|
11667
|
+
if (Number.isNaN(n)) return 0;
|
|
11668
|
+
return Math.trunc(n);
|
|
11177
11669
|
}
|
|
11178
11670
|
return null;
|
|
11179
11671
|
}
|
|
@@ -11201,7 +11693,7 @@ function copyWithinTuple(shape, vals) {
|
|
|
11201
11693
|
if (win) {
|
|
11202
11694
|
const els = [...shape.elements];
|
|
11203
11695
|
const holesSet = new Set(origHoles);
|
|
11204
|
-
const backwards =
|
|
11696
|
+
const backwards = win.s < win.t && win.s + (win.e - win.s) > win.t;
|
|
11205
11697
|
const count = win.e - win.s;
|
|
11206
11698
|
for (let kk = 0; kk < count; kk++) {
|
|
11207
11699
|
const k = backwards ? count - 1 - kk : kk;
|
|
@@ -11301,7 +11793,7 @@ function $copy(a) {
|
|
|
11301
11793
|
if (s.k === "obj") {
|
|
11302
11794
|
const slots = {};
|
|
11303
11795
|
for (const [k, v2] of Object.entries(s.slots)) {
|
|
11304
|
-
slots
|
|
11796
|
+
setSlot(slots, k, { ...v2, value: $copy(v2.value) });
|
|
11305
11797
|
}
|
|
11306
11798
|
const next = objOf(slots, {
|
|
11307
11799
|
index: s.index ? { key: $copy(s.index.key), value: $copy(s.index.value) } : void 0,
|
|
@@ -11441,7 +11933,8 @@ function $arrMutContainer(arr, method, args) {
|
|
|
11441
11933
|
}
|
|
11442
11934
|
function $idx(a, i) {
|
|
11443
11935
|
if (a?.shape?.k === "any") return anyMemberResult();
|
|
11444
|
-
const
|
|
11936
|
+
const keyStr = propertyKeyOf(i);
|
|
11937
|
+
const iv = keyStr !== void 0 ? keyStr : litValue(i);
|
|
11445
11938
|
const idx = iv !== void 0 ? canonicalArrayIndex(iv) : void 0;
|
|
11446
11939
|
if (a.shape.k === "tuple") {
|
|
11447
11940
|
const els = a.shape.elements;
|
|
@@ -11478,18 +11971,11 @@ function $idx(a, i) {
|
|
|
11478
11971
|
}
|
|
11479
11972
|
const sv = litValue(a);
|
|
11480
11973
|
if (typeof sv === "string") {
|
|
11481
|
-
if (
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
pTrue,
|
|
11487
|
-
"exact"
|
|
11488
|
-
);
|
|
11489
|
-
}
|
|
11490
|
-
return undef();
|
|
11491
|
-
}
|
|
11492
|
-
return unknown;
|
|
11974
|
+
if (i.term?.op !== "lit") return unknown;
|
|
11975
|
+
const idx2 = canonicalArrayIndex(i.term.value);
|
|
11976
|
+
if (idx2 === void 0) return undef();
|
|
11977
|
+
if (idx2 < sv.length) return $lit(sv[idx2]);
|
|
11978
|
+
return undef();
|
|
11493
11979
|
}
|
|
11494
11980
|
return unknown;
|
|
11495
11981
|
}
|
|
@@ -11500,20 +11986,26 @@ function widenTupleToArr(els, holes, value) {
|
|
|
11500
11986
|
return { k: "arr", element: joined };
|
|
11501
11987
|
}
|
|
11502
11988
|
function $idxSet(a, i, value) {
|
|
11503
|
-
const
|
|
11504
|
-
|
|
11989
|
+
const pk = propertyKeyOf(i);
|
|
11990
|
+
const raw = i.term?.op === "lit" ? i.term.value : litValue(i);
|
|
11991
|
+
let numIdx;
|
|
11992
|
+
if (typeof raw === "number") numIdx = raw;
|
|
11993
|
+
else if (typeof raw === "bigint") numIdx = Number(raw);
|
|
11994
|
+
else if (pk !== void 0) numIdx = canonicalArrayIndex(pk);
|
|
11995
|
+
const iv = pk !== void 0 ? pk : litValue(i);
|
|
11996
|
+
if (a.shape.k === "tuple" && numIdx !== void 0 && Number.isInteger(numIdx) && numIdx >= 0) {
|
|
11505
11997
|
const st = extStateOf(a);
|
|
11506
11998
|
if (st === "frozen") throwStrictWrite();
|
|
11507
|
-
if ((st === "sealed" || st === "nonext") &&
|
|
11999
|
+
if ((st === "sealed" || st === "nonext") && numIdx >= a.shape.elements.length) {
|
|
11508
12000
|
throwStrictWrite();
|
|
11509
12001
|
}
|
|
11510
|
-
if (
|
|
12002
|
+
if (numIdx >= 4294967295) {
|
|
11511
12003
|
a.shape = widenTupleToArr(a.shape.elements, a.shape.holes, value);
|
|
11512
12004
|
a.conf = confJoin(a.conf, "path");
|
|
11513
12005
|
clearStaleTermPred(a);
|
|
11514
12006
|
return a;
|
|
11515
12007
|
}
|
|
11516
|
-
if (
|
|
12008
|
+
if (numIdx + 1 > TUPLE_MATERIALIZE_CAP) {
|
|
11517
12009
|
a.shape = widenTupleToArr(a.shape.elements, a.shape.holes, value);
|
|
11518
12010
|
a.conf = confJoin(a.conf, "path");
|
|
11519
12011
|
clearStaleTermPred(a);
|
|
@@ -11521,12 +12013,12 @@ function $idxSet(a, i, value) {
|
|
|
11521
12013
|
}
|
|
11522
12014
|
const els = [...a.shape.elements];
|
|
11523
12015
|
const holes = [...a.shape.holes ?? []];
|
|
11524
|
-
while (els.length <
|
|
12016
|
+
while (els.length < numIdx) {
|
|
11525
12017
|
holes.push(els.length);
|
|
11526
12018
|
els.push(undef());
|
|
11527
12019
|
}
|
|
11528
|
-
els[
|
|
11529
|
-
const hi = holes.indexOf(
|
|
12020
|
+
els[numIdx] = asAbsVal(value);
|
|
12021
|
+
const hi = holes.indexOf(numIdx);
|
|
11530
12022
|
if (hi >= 0) holes.splice(hi, 1);
|
|
11531
12023
|
a.shape = { k: "tuple", elements: els, holes: holes.length > 0 ? holes : void 0 };
|
|
11532
12024
|
clearStaleTermPred(a);
|
|
@@ -11549,7 +12041,7 @@ function $idxSet(a, i, value) {
|
|
|
11549
12041
|
}
|
|
11550
12042
|
if (sk === "brand") {
|
|
11551
12043
|
if (iv === void 0) return a;
|
|
11552
|
-
if (
|
|
12044
|
+
if (getEvalClass(a.shape.name)) return $set(a, String(iv), value);
|
|
11553
12045
|
return a;
|
|
11554
12046
|
}
|
|
11555
12047
|
if (sk === "tuple") {
|
|
@@ -11590,6 +12082,9 @@ function $len(a) {
|
|
|
11590
12082
|
"exact"
|
|
11591
12083
|
);
|
|
11592
12084
|
}
|
|
12085
|
+
if (a.shape.k === "prim" && a.shape.type === "string") {
|
|
12086
|
+
return abs({ k: "prim", type: "number" }, void 0, void 0, "path");
|
|
12087
|
+
}
|
|
11593
12088
|
if (a.shape.k === "brand" && a.shape.name === "String") {
|
|
11594
12089
|
const inner = a.shape.shape;
|
|
11595
12090
|
if (inner.shape.k === "obj") {
|
|
@@ -11603,10 +12098,17 @@ function $len(a) {
|
|
|
11603
12098
|
return unknown;
|
|
11604
12099
|
}
|
|
11605
12100
|
function $obj(slots) {
|
|
11606
|
-
const s =
|
|
11607
|
-
for (const
|
|
12101
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
12102
|
+
for (const k of Object.keys(slots)) {
|
|
12103
|
+
setSlot(s, k, { value: asAbsVal(slots[k]) });
|
|
12104
|
+
}
|
|
11608
12105
|
return objOf(s);
|
|
11609
12106
|
}
|
|
12107
|
+
function $setProto(o, proto) {
|
|
12108
|
+
const next = setProtoAbs(o, proto);
|
|
12109
|
+
if (next !== o) clearStaleTermPred(o);
|
|
12110
|
+
return next;
|
|
12111
|
+
}
|
|
11610
12112
|
function $spread(a, b) {
|
|
11611
12113
|
let bb = asAbsVal(b);
|
|
11612
12114
|
const acc = bb && typeof bb === "object" ? accessorTable.get(bb) : void 0;
|
|
@@ -11615,7 +12117,7 @@ function $spread(a, b) {
|
|
|
11615
12117
|
const slots = { ...bb.shape.slots };
|
|
11616
12118
|
for (const [k, fn] of acc) {
|
|
11617
12119
|
if (fn.get) {
|
|
11618
|
-
slots
|
|
12120
|
+
setSlot(slots, k, { value: fn.get(bb) });
|
|
11619
12121
|
changed = true;
|
|
11620
12122
|
}
|
|
11621
12123
|
}
|
|
@@ -11651,7 +12153,7 @@ function $objRest(o, keys) {
|
|
|
11651
12153
|
let openRest = o.shape.open === true;
|
|
11652
12154
|
for (const [k, s] of Object.entries(o.shape.slots)) {
|
|
11653
12155
|
if (drop.has(k)) continue;
|
|
11654
|
-
slots
|
|
12156
|
+
setSlot(slots, k, s);
|
|
11655
12157
|
}
|
|
11656
12158
|
if (o.shape.open) openRest = true;
|
|
11657
12159
|
const shape = { k: "obj", slots };
|
|
@@ -11762,7 +12264,7 @@ function $forInKeys(o) {
|
|
|
11762
12264
|
return k !== "" && String(n) === k && Number.isInteger(n) && n >= 0 && n < 4294967295;
|
|
11763
12265
|
};
|
|
11764
12266
|
if (shape.k === "obj") {
|
|
11765
|
-
const keys =
|
|
12267
|
+
const keys = enumOwnKeys(o, shape.slots);
|
|
11766
12268
|
const intKeys = keys.filter(isArrayIndexKey).sort((a, b) => Number(a) - Number(b));
|
|
11767
12269
|
const strKeys = keys.filter((k) => !isArrayIndexKey(k));
|
|
11768
12270
|
return $arr([...intKeys, ...strKeys].map((k) => $lit(k)));
|
|
@@ -11944,8 +12446,8 @@ function $get(o, key, opts) {
|
|
|
11944
12446
|
const sacc = findStaticClassAccessor(o.shape.name, key);
|
|
11945
12447
|
if (sacc) return sacc.get ? sacc.get(o) : undef();
|
|
11946
12448
|
if (findClassAccessor(o.shape.name, key)) return undef();
|
|
11947
|
-
for (const n of
|
|
11948
|
-
const spec =
|
|
12449
|
+
for (const n of evalClassChain(o.shape.name)) {
|
|
12450
|
+
const spec = getEvalClass(n);
|
|
11949
12451
|
if (spec?.staticMethods?.[key]) {
|
|
11950
12452
|
return absFunction(spec.staticMethodParams?.[key] ?? [], { body: noBody2 });
|
|
11951
12453
|
}
|
|
@@ -11960,8 +12462,8 @@ function $get(o, key, opts) {
|
|
|
11960
12462
|
const acc = findClassAccessor(o.shape.name, key);
|
|
11961
12463
|
if (acc) return acc.get ? acc.get(o) : undef();
|
|
11962
12464
|
if (findStaticClassAccessor(o.shape.name, key)) return undef();
|
|
11963
|
-
for (const n of
|
|
11964
|
-
const spec =
|
|
12465
|
+
for (const n of evalClassChain(o.shape.name)) {
|
|
12466
|
+
const spec = getEvalClass(n);
|
|
11965
12467
|
if (spec?.methods?.[key]) {
|
|
11966
12468
|
return absFunction(spec.methodParams?.[key] ?? [], { body: noBody2 });
|
|
11967
12469
|
}
|
|
@@ -11973,6 +12475,13 @@ function $get(o, key, opts) {
|
|
|
11973
12475
|
}
|
|
11974
12476
|
return $get(inner, key, opts);
|
|
11975
12477
|
}
|
|
12478
|
+
if (o.shape.k === "fn" && o.shape.slots) {
|
|
12479
|
+
const slot = getSlot(o.shape.slots, key);
|
|
12480
|
+
if (slot) {
|
|
12481
|
+
if (slot.optional) return joinAbs(slot.value, undef());
|
|
12482
|
+
return slot.value;
|
|
12483
|
+
}
|
|
12484
|
+
}
|
|
11976
12485
|
if ((o.shape.k === "tuple" || o.shape.k === "arr") && key === "length") {
|
|
11977
12486
|
return $len(o);
|
|
11978
12487
|
}
|
|
@@ -11982,6 +12491,16 @@ function $get(o, key, opts) {
|
|
|
11982
12491
|
if (idx !== void 0) return idx < els.length ? els[idx] : undef();
|
|
11983
12492
|
if (!isPossiblyProtoMemberKey(key)) return undef();
|
|
11984
12493
|
}
|
|
12494
|
+
if (o.shape.k === "prim" && o.shape.type === "string") {
|
|
12495
|
+
const idx = canonicalArrayIndex(key);
|
|
12496
|
+
const sv = litValue(o);
|
|
12497
|
+
if (idx !== void 0) {
|
|
12498
|
+
if (typeof sv === "string") return idx < sv.length ? $lit(sv[idx]) : undef();
|
|
12499
|
+
return abs({ k: "prim", type: "string" }, void 0, void 0, "path");
|
|
12500
|
+
}
|
|
12501
|
+
if (key === "length" && typeof sv === "string") return numLit(sv.length);
|
|
12502
|
+
if (!isPossiblyProtoMemberKey(key) && key !== "length") return undef();
|
|
12503
|
+
}
|
|
11985
12504
|
if ((o.shape.k === "tuple" || o.shape.k === "arr" || o.shape.k === "prim") && (OBJECT_PROTO_METHOD_NAMES.has(key) || o.shape.k !== "prim" && ARRAY_PROTO_METHOD_NAMES.has(key)) && !(o.shape.k === "prim" && o.shape.type === "string" && key === "toString")) {
|
|
11986
12505
|
if ((o.shape.k === "tuple" || o.shape.k === "arr") && (key === "toString" || key === "toLocaleString" || key === "join")) {
|
|
11987
12506
|
return arrayMethodAbs(key === "join" ? "join" : key);
|
|
@@ -12087,7 +12606,7 @@ function $set(o, key, value) {
|
|
|
12087
12606
|
throwStrictWrite();
|
|
12088
12607
|
}
|
|
12089
12608
|
if (getPropFlags(o)?.get(key)?.writable === false) throwStrictWrite();
|
|
12090
|
-
inner2.shape.slots
|
|
12609
|
+
setSlot(inner2.shape.slots, key, { value: asAbsVal(value) });
|
|
12091
12610
|
clearStaleTermPred(o);
|
|
12092
12611
|
return o;
|
|
12093
12612
|
}
|
|
@@ -12182,7 +12701,10 @@ function $set(o, key, value) {
|
|
|
12182
12701
|
if (!acc.set) throwStrictWrite();
|
|
12183
12702
|
return acc.set(o, value);
|
|
12184
12703
|
}
|
|
12185
|
-
|
|
12704
|
+
if (key === "__proto__" && !isNullProtoObj(o)) {
|
|
12705
|
+
return $setProto(o, value);
|
|
12706
|
+
}
|
|
12707
|
+
setSlot(shape.slots, key, { value: asAbsVal(value) });
|
|
12186
12708
|
o.conf = confJoin(o.conf, value.conf);
|
|
12187
12709
|
clearStaleTermPred(o);
|
|
12188
12710
|
return o;
|
|
@@ -12240,8 +12762,8 @@ function runForkArm(arm, exits) {
|
|
|
12240
12762
|
}
|
|
12241
12763
|
function settleForkArms(a, b, exits) {
|
|
12242
12764
|
const aThrow = a.kind === "throw";
|
|
12243
|
-
const
|
|
12244
|
-
if (aThrow &&
|
|
12765
|
+
const evalThrow = b.kind === "throw";
|
|
12766
|
+
if (aThrow && evalThrow) {
|
|
12245
12767
|
throw new NudoThrow(joinAbs(a.v, b.v));
|
|
12246
12768
|
}
|
|
12247
12769
|
const first = aThrow ? b : a;
|
|
@@ -12249,7 +12771,7 @@ function settleForkArms(a, b, exits) {
|
|
|
12249
12771
|
if (first.kind === "ret" && second.kind === "ret") {
|
|
12250
12772
|
throw new NudoReturn(joinAbs(first.v, second.v));
|
|
12251
12773
|
}
|
|
12252
|
-
if (aThrow !==
|
|
12774
|
+
if (aThrow !== evalThrow) {
|
|
12253
12775
|
if (first.kind === "ret") {
|
|
12254
12776
|
if (!exits) throw new NudoReturn(first.v);
|
|
12255
12777
|
return undef();
|
|
@@ -12289,7 +12811,7 @@ function boundedPhi(p, q) {
|
|
|
12289
12811
|
function $fork(test, consequent, alternate) {
|
|
12290
12812
|
notePromiseExecutorFork();
|
|
12291
12813
|
const testAbs = asAbsVal(test);
|
|
12292
|
-
if (!
|
|
12814
|
+
if (!bumpEvalForkBudget()) return unknown;
|
|
12293
12815
|
const truth = litTruth(testAbs);
|
|
12294
12816
|
const p = currentExecPhi();
|
|
12295
12817
|
const tCons = testAbs.pred;
|
|
@@ -12687,10 +13209,10 @@ __export(class_exports, {
|
|
|
12687
13209
|
$thisSet: () => $thisSet,
|
|
12688
13210
|
clearBClasses: () => clearBClasses,
|
|
12689
13211
|
execRegexBrand: () => execRegexBrand,
|
|
12690
|
-
|
|
13212
|
+
getEvalClass: () => getEvalClass,
|
|
12691
13213
|
regexExecWithState: () => regexExecWithState,
|
|
12692
13214
|
regexParts: () => regexParts,
|
|
12693
|
-
|
|
13215
|
+
registerEvalClass: () => registerEvalClass,
|
|
12694
13216
|
stringRegexMethod: () => stringRegexMethod
|
|
12695
13217
|
});
|
|
12696
13218
|
|
|
@@ -12700,29 +13222,29 @@ __export(calls_exports, {
|
|
|
12700
13222
|
$assignRecord: () => $assignRecord,
|
|
12701
13223
|
$callNamed: () => $callNamed,
|
|
12702
13224
|
$recordBinding: () => $recordBinding,
|
|
12703
|
-
|
|
12704
|
-
|
|
13225
|
+
MAX_EVAL_CALL_DEPTH: () => MAX_EVAL_CALL_DEPTH,
|
|
13226
|
+
MAX_EVAL_TOTAL_CALLS: () => MAX_EVAL_TOTAL_CALLS,
|
|
12705
13227
|
blockHostSideEffect: () => blockHostSideEffect,
|
|
12706
|
-
|
|
13228
|
+
getEvalCallCollector: () => getEvalCallCollector,
|
|
12707
13229
|
neverExecHostName: () => neverExecHostName,
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
13230
|
+
noteEvalCallRecord: () => noteEvalCallRecord,
|
|
13231
|
+
resetEvalCallBudget: () => resetEvalCallBudget,
|
|
13232
|
+
setEvalAssignCollector: () => setEvalAssignCollector,
|
|
13233
|
+
setEvalBindingSink: () => setEvalBindingSink,
|
|
13234
|
+
setEvalCallCollector: () => setEvalCallCollector
|
|
12713
13235
|
});
|
|
12714
13236
|
var pureCallMemo = /* @__PURE__ */ new WeakMap();
|
|
12715
|
-
var
|
|
12716
|
-
var
|
|
12717
|
-
function
|
|
12718
|
-
const prev =
|
|
12719
|
-
|
|
13237
|
+
var evalCallCollector = null;
|
|
13238
|
+
var evalAssignCollector = null;
|
|
13239
|
+
function setEvalAssignCollector(collector2) {
|
|
13240
|
+
const prev = evalAssignCollector;
|
|
13241
|
+
evalAssignCollector = collector2;
|
|
12720
13242
|
return prev;
|
|
12721
13243
|
}
|
|
12722
13244
|
function $assignRecord(name, prev, next, line, column, conditional) {
|
|
12723
|
-
if (!
|
|
13245
|
+
if (!evalAssignCollector) return;
|
|
12724
13246
|
try {
|
|
12725
|
-
|
|
13247
|
+
evalAssignCollector({
|
|
12726
13248
|
name,
|
|
12727
13249
|
prev,
|
|
12728
13250
|
next,
|
|
@@ -12734,7 +13256,7 @@ function $assignRecord(name, prev, next, line, column, conditional) {
|
|
|
12734
13256
|
}
|
|
12735
13257
|
}
|
|
12736
13258
|
var bindingSink = null;
|
|
12737
|
-
function
|
|
13259
|
+
function setEvalBindingSink(sink) {
|
|
12738
13260
|
bindingSink = sink;
|
|
12739
13261
|
}
|
|
12740
13262
|
function $recordBinding(name, value) {
|
|
@@ -12779,63 +13301,63 @@ function blockHostSideEffect(fn) {
|
|
|
12779
13301
|
noteHostEffectBlocked(hostName);
|
|
12780
13302
|
return abs({ k: "unknown" }, void 0, void 0, "opaque");
|
|
12781
13303
|
}
|
|
12782
|
-
function
|
|
12783
|
-
if (!
|
|
13304
|
+
function noteEvalCallRecord(r) {
|
|
13305
|
+
if (!evalCallCollector) return;
|
|
12784
13306
|
try {
|
|
12785
|
-
|
|
13307
|
+
evalCallCollector(r);
|
|
12786
13308
|
} catch {
|
|
12787
13309
|
}
|
|
12788
13310
|
}
|
|
12789
|
-
function
|
|
12790
|
-
const prev =
|
|
12791
|
-
|
|
13311
|
+
function setEvalCallCollector(collector2) {
|
|
13312
|
+
const prev = evalCallCollector;
|
|
13313
|
+
evalCallCollector = collector2;
|
|
12792
13314
|
return prev;
|
|
12793
13315
|
}
|
|
12794
|
-
function
|
|
12795
|
-
return
|
|
12796
|
-
}
|
|
12797
|
-
var
|
|
12798
|
-
var
|
|
12799
|
-
var
|
|
12800
|
-
var
|
|
12801
|
-
var
|
|
12802
|
-
var
|
|
12803
|
-
var
|
|
12804
|
-
function
|
|
12805
|
-
let id =
|
|
13316
|
+
function getEvalCallCollector() {
|
|
13317
|
+
return evalCallCollector;
|
|
13318
|
+
}
|
|
13319
|
+
var MAX_EVAL_CALL_DEPTH = 64;
|
|
13320
|
+
var MAX_EVAL_TOTAL_CALLS = 2e4;
|
|
13321
|
+
var evalCallDepth = 0;
|
|
13322
|
+
var evalTotalCalls = 0;
|
|
13323
|
+
var evalActiveCallKeys = [];
|
|
13324
|
+
var evalFnCallIds = /* @__PURE__ */ new WeakMap();
|
|
13325
|
+
var evalFnCallIdSeq = 0;
|
|
13326
|
+
function evalStableId(obj2) {
|
|
13327
|
+
let id = evalFnCallIds.get(obj2);
|
|
12806
13328
|
if (id === void 0) {
|
|
12807
|
-
id = `#${++
|
|
12808
|
-
|
|
13329
|
+
id = `#${++evalFnCallIdSeq}`;
|
|
13330
|
+
evalFnCallIds.set(obj2, id);
|
|
12809
13331
|
}
|
|
12810
13332
|
return id;
|
|
12811
13333
|
}
|
|
12812
|
-
function
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
13334
|
+
function resetEvalCallBudget() {
|
|
13335
|
+
evalCallDepth = 0;
|
|
13336
|
+
evalTotalCalls = 0;
|
|
13337
|
+
evalActiveCallKeys = [];
|
|
13338
|
+
resetEvalForkBudget();
|
|
12817
13339
|
}
|
|
12818
|
-
function
|
|
13340
|
+
function evalTruncatedAbs() {
|
|
12819
13341
|
return abs({ k: "unknown" }, void 0, void 0, "opaque");
|
|
12820
13342
|
}
|
|
12821
|
-
function
|
|
12822
|
-
const id = fn && typeof fn === "object" ?
|
|
13343
|
+
function evalCallBudgetKey(name, fn, args) {
|
|
13344
|
+
const id = fn && typeof fn === "object" ? evalStableId(fn) : "prim";
|
|
12823
13345
|
return callBudgetKey(name, id, args);
|
|
12824
13346
|
}
|
|
12825
|
-
function
|
|
12826
|
-
const key =
|
|
12827
|
-
if (
|
|
13347
|
+
function evalEnterCall(name, fn, args) {
|
|
13348
|
+
const key = evalCallBudgetKey(name, fn, args);
|
|
13349
|
+
if (evalActiveCallKeys.includes(key) || evalCallDepth >= MAX_EVAL_CALL_DEPTH || evalTotalCalls >= MAX_EVAL_TOTAL_CALLS) {
|
|
12828
13350
|
noteAbsTruncation(name);
|
|
12829
13351
|
return { ok: false };
|
|
12830
13352
|
}
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
13353
|
+
evalActiveCallKeys.push(key);
|
|
13354
|
+
evalCallDepth++;
|
|
13355
|
+
evalTotalCalls++;
|
|
12834
13356
|
return { ok: true, key };
|
|
12835
13357
|
}
|
|
12836
|
-
function
|
|
12837
|
-
|
|
12838
|
-
|
|
13358
|
+
function evalExitCall() {
|
|
13359
|
+
evalCallDepth--;
|
|
13360
|
+
evalActiveCallKeys.pop();
|
|
12839
13361
|
}
|
|
12840
13362
|
function $callNamed(name, fn, args, loc, argLocs) {
|
|
12841
13363
|
const pureName = pureFnNameOf(fn);
|
|
@@ -12866,26 +13388,26 @@ function $callNamed(name, fn, args, loc, argLocs) {
|
|
|
12866
13388
|
} else if (blockedHost !== null) {
|
|
12867
13389
|
result = blockedHost;
|
|
12868
13390
|
} else {
|
|
12869
|
-
const entered =
|
|
13391
|
+
const entered = evalEnterCall(name, fn, args);
|
|
12870
13392
|
if (!entered.ok) {
|
|
12871
|
-
result =
|
|
13393
|
+
result = evalTruncatedAbs();
|
|
12872
13394
|
} else {
|
|
12873
13395
|
try {
|
|
12874
13396
|
result = callAtFunctionBoundary(() => fn(...args));
|
|
12875
13397
|
} finally {
|
|
12876
|
-
|
|
13398
|
+
evalExitCall();
|
|
12877
13399
|
}
|
|
12878
13400
|
}
|
|
12879
13401
|
}
|
|
12880
13402
|
} else if (fn && typeof fn === "object" && "shape" in fn) {
|
|
12881
|
-
const entered =
|
|
13403
|
+
const entered = evalEnterCall(name, fn, args);
|
|
12882
13404
|
if (!entered.ok) {
|
|
12883
|
-
result =
|
|
13405
|
+
result = evalTruncatedAbs();
|
|
12884
13406
|
} else {
|
|
12885
13407
|
try {
|
|
12886
13408
|
result = $call(fn, args);
|
|
12887
13409
|
} finally {
|
|
12888
|
-
|
|
13410
|
+
evalExitCall();
|
|
12889
13411
|
}
|
|
12890
13412
|
}
|
|
12891
13413
|
}
|
|
@@ -12902,9 +13424,9 @@ function $callNamed(name, fn, args, loc, argLocs) {
|
|
|
12902
13424
|
}
|
|
12903
13425
|
m.set(pk, result);
|
|
12904
13426
|
}
|
|
12905
|
-
if (
|
|
13427
|
+
if (evalCallCollector) {
|
|
12906
13428
|
try {
|
|
12907
|
-
|
|
13429
|
+
evalCallCollector({
|
|
12908
13430
|
fnName: name,
|
|
12909
13431
|
args: argsSnapshot,
|
|
12910
13432
|
result: threw ? unknown : result,
|
|
@@ -13080,12 +13602,12 @@ function $class(name, spec) {
|
|
|
13080
13602
|
accessors: spec.accessors,
|
|
13081
13603
|
staticAccessors: spec.staticAccessors
|
|
13082
13604
|
};
|
|
13083
|
-
|
|
13605
|
+
registerEvalClass(full);
|
|
13084
13606
|
const slots = {};
|
|
13085
13607
|
if (spec.statics) {
|
|
13086
|
-
for (const [k, v2] of Object.entries(spec.statics)) slots
|
|
13608
|
+
for (const [k, v2] of Object.entries(spec.statics)) setSlot(slots, k, { value: asAbsVal(v2) });
|
|
13087
13609
|
}
|
|
13088
|
-
slots
|
|
13610
|
+
setSlot(slots, "name", { value: strLit(name) });
|
|
13089
13611
|
const val = abs(
|
|
13090
13612
|
{ k: "brand", name, shape: objOf(slots) },
|
|
13091
13613
|
void 0,
|
|
@@ -13098,7 +13620,7 @@ function $class(name, spec) {
|
|
|
13098
13620
|
}
|
|
13099
13621
|
function specOf(cls) {
|
|
13100
13622
|
if (classImpl.has(cls)) return classImpl.get(cls);
|
|
13101
|
-
if (cls.shape.k === "brand") return
|
|
13623
|
+
if (cls.shape.k === "brand") return getEvalClass(cls.shape.name);
|
|
13102
13624
|
return void 0;
|
|
13103
13625
|
}
|
|
13104
13626
|
function findMethod(startName, method) {
|
|
@@ -13106,7 +13628,7 @@ function findMethod(startName, method) {
|
|
|
13106
13628
|
const seen = /* @__PURE__ */ new Set();
|
|
13107
13629
|
while (cur && !seen.has(cur)) {
|
|
13108
13630
|
seen.add(cur);
|
|
13109
|
-
const spec =
|
|
13631
|
+
const spec = getEvalClass(cur);
|
|
13110
13632
|
if (spec?.methods?.[method]) return spec.methods[method];
|
|
13111
13633
|
cur = spec?.superName;
|
|
13112
13634
|
}
|
|
@@ -13117,7 +13639,7 @@ function findCtor(startName) {
|
|
|
13117
13639
|
const seen = /* @__PURE__ */ new Set();
|
|
13118
13640
|
while (cur && !seen.has(cur)) {
|
|
13119
13641
|
seen.add(cur);
|
|
13120
|
-
const spec =
|
|
13642
|
+
const spec = getEvalClass(cur);
|
|
13121
13643
|
if (spec?.ctor) return { ctor: spec.ctor, className: cur };
|
|
13122
13644
|
cur = spec?.superName;
|
|
13123
13645
|
}
|
|
@@ -13127,11 +13649,9 @@ function $new(cls, args) {
|
|
|
13127
13649
|
if (cls && typeof cls === "object" && "shape" in cls) {
|
|
13128
13650
|
const cs = cls.shape;
|
|
13129
13651
|
const ctorName = cs.k === "brand" ? cs.name : builtinCtorNameOf(cls) ?? (cs.k === "fn" ? cs.name ?? void 0 : void 0);
|
|
13130
|
-
if (ctorName
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
if (ctorName === "Promise") {
|
|
13134
|
-
return evalPromiseCtor(args);
|
|
13652
|
+
if (ctorName) {
|
|
13653
|
+
const built = evalBuiltinNew(ctorName, args);
|
|
13654
|
+
if (built !== void 0) return built;
|
|
13135
13655
|
}
|
|
13136
13656
|
}
|
|
13137
13657
|
if (typeof cls === "function") {
|
|
@@ -13212,7 +13732,7 @@ function $new(cls, args) {
|
|
|
13212
13732
|
return thisVal;
|
|
13213
13733
|
}
|
|
13214
13734
|
function $super(thisVal, childName, args) {
|
|
13215
|
-
const child =
|
|
13735
|
+
const child = getEvalClass(childName);
|
|
13216
13736
|
const parentName = child?.superName;
|
|
13217
13737
|
if (!parentName) return thisVal;
|
|
13218
13738
|
const found = findCtor(parentName);
|
|
@@ -13244,6 +13764,7 @@ function runtimeAssignObject(args) {
|
|
|
13244
13764
|
const base = accObj.shape.slots;
|
|
13245
13765
|
const flags = getPropFlags(accObj);
|
|
13246
13766
|
for (const [k, s] of Object.entries(srcAbs.shape.slots)) {
|
|
13767
|
+
if (!isEnumerableView(srcAbs, k)) continue;
|
|
13247
13768
|
if ((st === "sealed" || st === "nonext") && !Object.prototype.hasOwnProperty.call(base, k)) {
|
|
13248
13769
|
throwStrictAssign();
|
|
13249
13770
|
}
|
|
@@ -13449,7 +13970,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13449
13970
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
13450
13971
|
throw e;
|
|
13451
13972
|
} finally {
|
|
13452
|
-
|
|
13973
|
+
noteEvalCallRecord({
|
|
13453
13974
|
fnName: `${brandName}.${method}`,
|
|
13454
13975
|
args,
|
|
13455
13976
|
result,
|
|
@@ -13458,7 +13979,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13458
13979
|
});
|
|
13459
13980
|
}
|
|
13460
13981
|
}
|
|
13461
|
-
const spec =
|
|
13982
|
+
const spec = getEvalClass(brandName);
|
|
13462
13983
|
const sm = spec?.staticMethods?.[method];
|
|
13463
13984
|
if (sm) {
|
|
13464
13985
|
let result = unknown;
|
|
@@ -13471,7 +13992,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13471
13992
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
13472
13993
|
throw e;
|
|
13473
13994
|
} finally {
|
|
13474
|
-
|
|
13995
|
+
noteEvalCallRecord({
|
|
13475
13996
|
fnName: `${brandName}.${method}`,
|
|
13476
13997
|
args,
|
|
13477
13998
|
result,
|
|
@@ -13576,7 +14097,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13576
14097
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
13577
14098
|
throw e;
|
|
13578
14099
|
} finally {
|
|
13579
|
-
|
|
14100
|
+
noteEvalCallRecord({
|
|
13580
14101
|
fnName: recordName,
|
|
13581
14102
|
args,
|
|
13582
14103
|
result,
|
|
@@ -13904,8 +14425,7 @@ function invokeArrMethod(arr, method, args) {
|
|
|
13904
14425
|
if (shape.k === "arr") return joinAbs(shape.element, undefAbs());
|
|
13905
14426
|
}
|
|
13906
14427
|
if (method === "at") {
|
|
13907
|
-
const
|
|
13908
|
-
const iv = typeof raw === "number" && Number.isInteger(raw) ? raw : void 0;
|
|
14428
|
+
const iv = toIntegerOrInfinityLit(args[0]);
|
|
13909
14429
|
if (shape.k === "tuple") {
|
|
13910
14430
|
const els = shape.elements;
|
|
13911
14431
|
if (iv === void 0) {
|
|
@@ -13921,7 +14441,7 @@ function invokeArrMethod(arr, method, args) {
|
|
|
13921
14441
|
return void 0;
|
|
13922
14442
|
}
|
|
13923
14443
|
function $invokeSuper(thisVal, childName, method, args) {
|
|
13924
|
-
const child =
|
|
14444
|
+
const child = getEvalClass(childName);
|
|
13925
14445
|
const parentName = child?.superName;
|
|
13926
14446
|
if (!parentName) return unknown;
|
|
13927
14447
|
const m = findMethod(parentName, method);
|
|
@@ -13942,7 +14462,7 @@ function $thisSet(thisVal, key, value) {
|
|
|
13942
14462
|
if (thisVal.shape.k === "brand") {
|
|
13943
14463
|
const inner = thisVal.shape.shape;
|
|
13944
14464
|
const slots = inner.shape.k === "obj" ? { ...inner.shape.slots } : {};
|
|
13945
|
-
slots
|
|
14465
|
+
setSlot(slots, key, { value: asAbsVal(value) });
|
|
13946
14466
|
return abs(
|
|
13947
14467
|
{
|
|
13948
14468
|
k: "brand",
|
|
@@ -14027,13 +14547,23 @@ function $staticInvoke(cls, method, args) {
|
|
|
14027
14547
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
14028
14548
|
throw e;
|
|
14029
14549
|
} finally {
|
|
14030
|
-
|
|
14550
|
+
noteEvalCallRecord({ fnName: recordName, args, result, threw });
|
|
14031
14551
|
}
|
|
14032
14552
|
}
|
|
14033
14553
|
function $setKey(o, key, value) {
|
|
14034
|
-
const
|
|
14554
|
+
const pk = propertyKeyOf(key);
|
|
14555
|
+
const k = pk !== void 0 ? pk : litValue(key);
|
|
14035
14556
|
if (typeof k === "string" || typeof k === "number") {
|
|
14036
|
-
|
|
14557
|
+
const ks = String(k);
|
|
14558
|
+
if (ks === "__proto__" && o.shape.k === "obj") {
|
|
14559
|
+
setSlot(o.shape.slots, ks, {
|
|
14560
|
+
value: asAbsVal(value)
|
|
14561
|
+
});
|
|
14562
|
+
o.conf = confJoin(o.conf, value.conf);
|
|
14563
|
+
clearStaleTermPred(o);
|
|
14564
|
+
return o;
|
|
14565
|
+
}
|
|
14566
|
+
return $set(o, ks, value);
|
|
14037
14567
|
}
|
|
14038
14568
|
const val = asAbsVal(value);
|
|
14039
14569
|
if (o.shape.k === "brand") {
|
|
@@ -14301,7 +14831,7 @@ function bindingsOf(run) {
|
|
|
14301
14831
|
return runBindings.get(run);
|
|
14302
14832
|
}
|
|
14303
14833
|
function runTranspiled(source, opts = {}) {
|
|
14304
|
-
|
|
14834
|
+
resetEvalCallBudget();
|
|
14305
14835
|
const modules = opts.modules ?? {};
|
|
14306
14836
|
let js = transpile(source, {
|
|
14307
14837
|
runtimeImport: "@nudojs/core/exec",
|
|
@@ -14394,18 +14924,18 @@ ${js}`;
|
|
|
14394
14924
|
const ret = `return { ...__nudoExports, ...${cjsMerge}, ${names.join(", ")} };`;
|
|
14395
14925
|
const fn = new Function(...argNames, `${js}
|
|
14396
14926
|
${ret}`);
|
|
14397
|
-
|
|
14927
|
+
setEvalBindingSink(bindings);
|
|
14398
14928
|
try {
|
|
14399
14929
|
const result = fn(...args);
|
|
14400
14930
|
runBindings.set(result, bindings);
|
|
14401
14931
|
return result;
|
|
14402
14932
|
} finally {
|
|
14403
|
-
|
|
14933
|
+
setEvalBindingSink(null);
|
|
14404
14934
|
}
|
|
14405
14935
|
}
|
|
14406
|
-
var
|
|
14407
|
-
function
|
|
14408
|
-
|
|
14936
|
+
var evalFallbackCollector = null;
|
|
14937
|
+
function setEvalFallbackCollector(collector2) {
|
|
14938
|
+
evalFallbackCollector = collector2;
|
|
14409
14939
|
}
|
|
14410
14940
|
function evalExprAbs(expr, bindings = {}) {
|
|
14411
14941
|
const src = transpileExpression(expr, {});
|
|
@@ -14418,15 +14948,15 @@ function evalExprAbs(expr, bindings = {}) {
|
|
|
14418
14948
|
const factory = new Function(...names, cleaned);
|
|
14419
14949
|
return factory(...Object.values(rtAllBindings()), ...Object.values(bindings));
|
|
14420
14950
|
}
|
|
14421
|
-
function
|
|
14422
|
-
if (!
|
|
14951
|
+
function noteEvalFallback(e) {
|
|
14952
|
+
if (!evalFallbackCollector) return;
|
|
14423
14953
|
const f = e instanceof NudoUnsupportedError ? { reason: `unsupported:${e.reason}`, message: e.message, ...e.loc ? { loc: e.loc } : {} } : isNudoThrow(e) ? (
|
|
14424
14954
|
// NudoThrow:程序自身的抛(如顶层 this 写 / strict 写 TypeError)——
|
|
14425
14955
|
// 模块装载失败,不是 B 能力边界也不是 B 缺陷(catch 可吸收)
|
|
14426
14956
|
{ reason: "module-throw", message: e instanceof Error ? e.message : String(e) }
|
|
14427
14957
|
) : { reason: "internal", message: e instanceof Error ? e.message : String(e) };
|
|
14428
14958
|
try {
|
|
14429
|
-
|
|
14959
|
+
evalFallbackCollector(f);
|
|
14430
14960
|
} catch {
|
|
14431
14961
|
}
|
|
14432
14962
|
}
|
|
@@ -14434,7 +14964,7 @@ function tryRunTranspiled(source, opts = {}) {
|
|
|
14434
14964
|
try {
|
|
14435
14965
|
return runTranspiled(source, opts);
|
|
14436
14966
|
} catch (e) {
|
|
14437
|
-
|
|
14967
|
+
noteEvalFallback(e);
|
|
14438
14968
|
return void 0;
|
|
14439
14969
|
}
|
|
14440
14970
|
}
|
|
@@ -14444,7 +14974,7 @@ function isAbsVal(v2) {
|
|
|
14444
14974
|
function callTranspiledExportFull(exports, name, args, opts) {
|
|
14445
14975
|
const fn = exports[name];
|
|
14446
14976
|
if (typeof fn === "function") {
|
|
14447
|
-
|
|
14977
|
+
resetEvalCallBudget();
|
|
14448
14978
|
const callArgs = args.map(
|
|
14449
14979
|
(a) => a && typeof a === "object" && "shape" in a ? $copy(a) : a
|
|
14450
14980
|
);
|
|
@@ -14637,7 +15167,7 @@ function compiledBodyOf(impl) {
|
|
|
14637
15167
|
runner = (args) => bodyFn(...args);
|
|
14638
15168
|
compiledByImpl.set(implKey, runner);
|
|
14639
15169
|
} catch (e) {
|
|
14640
|
-
|
|
15170
|
+
noteEvalFallback(e);
|
|
14641
15171
|
return void 0;
|
|
14642
15172
|
}
|
|
14643
15173
|
return runner;
|
|
@@ -14824,6 +15354,7 @@ export {
|
|
|
14824
15354
|
projectDerivationDsl,
|
|
14825
15355
|
termKey3 as termKey,
|
|
14826
15356
|
canonicalArrayIndex,
|
|
15357
|
+
propertyKeyOf,
|
|
14827
15358
|
objOf,
|
|
14828
15359
|
isObj,
|
|
14829
15360
|
getSlot,
|
|
@@ -15092,6 +15623,9 @@ export {
|
|
|
15092
15623
|
$ushr,
|
|
15093
15624
|
$pow,
|
|
15094
15625
|
$toNumber,
|
|
15626
|
+
$toNumeric,
|
|
15627
|
+
$updateAdd,
|
|
15628
|
+
$updateSub,
|
|
15095
15629
|
$neg,
|
|
15096
15630
|
$typeof,
|
|
15097
15631
|
$not,
|
|
@@ -15144,19 +15678,19 @@ export {
|
|
|
15144
15678
|
noteAbsTruncation,
|
|
15145
15679
|
enterCall,
|
|
15146
15680
|
exitCall,
|
|
15147
|
-
|
|
15681
|
+
MAX_EVAL_TOTAL_FORKS,
|
|
15148
15682
|
FORK_TRUNCATION_LABEL,
|
|
15149
15683
|
HOST_EFFECT_LABEL_PREFIX,
|
|
15150
15684
|
noteHostEffectBlocked,
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15685
|
+
noteEvalForkTruncation,
|
|
15686
|
+
setEvalForkBudgetLimit,
|
|
15687
|
+
getEvalForkBudgetLimit,
|
|
15688
|
+
getEvalForkCount,
|
|
15689
|
+
resetEvalForkBudget,
|
|
15690
|
+
bumpEvalForkBudget,
|
|
15157
15691
|
$call,
|
|
15158
|
-
|
|
15159
|
-
|
|
15692
|
+
registerEvalClass,
|
|
15693
|
+
getEvalClass,
|
|
15160
15694
|
clearBClasses,
|
|
15161
15695
|
$objAccessor,
|
|
15162
15696
|
lookupObjAccessor,
|
|
@@ -15178,6 +15712,7 @@ export {
|
|
|
15178
15712
|
$idxSet,
|
|
15179
15713
|
$len,
|
|
15180
15714
|
$obj,
|
|
15715
|
+
$setProto,
|
|
15181
15716
|
$spread,
|
|
15182
15717
|
$objRest,
|
|
15183
15718
|
$arrRest,
|
|
@@ -15205,16 +15740,16 @@ export {
|
|
|
15205
15740
|
$gen,
|
|
15206
15741
|
$yield,
|
|
15207
15742
|
$nullishTest,
|
|
15208
|
-
|
|
15743
|
+
setEvalAssignCollector,
|
|
15209
15744
|
$assignRecord,
|
|
15210
|
-
|
|
15745
|
+
setEvalBindingSink,
|
|
15211
15746
|
$recordBinding,
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15747
|
+
noteEvalCallRecord,
|
|
15748
|
+
setEvalCallCollector,
|
|
15749
|
+
getEvalCallCollector,
|
|
15750
|
+
MAX_EVAL_CALL_DEPTH,
|
|
15751
|
+
MAX_EVAL_TOTAL_CALLS,
|
|
15752
|
+
resetEvalCallBudget,
|
|
15218
15753
|
$callNamed,
|
|
15219
15754
|
$reStateCall,
|
|
15220
15755
|
$class,
|
|
@@ -15233,9 +15768,9 @@ export {
|
|
|
15233
15768
|
RUNTIME_IMPORT_RE,
|
|
15234
15769
|
bindingsOf,
|
|
15235
15770
|
runTranspiled,
|
|
15236
|
-
|
|
15771
|
+
setEvalFallbackCollector,
|
|
15237
15772
|
evalExprAbs,
|
|
15238
|
-
|
|
15773
|
+
noteEvalFallback,
|
|
15239
15774
|
tryRunTranspiled,
|
|
15240
15775
|
callTranspiledExportFull,
|
|
15241
15776
|
callTranspiledExport
|