@nudojs/core 1.1.3 → 1.2.0
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-TEOZ4cPZ.d.ts} +1 -1
- package/dist/{chunk-T5VWMEJN.js → chunk-GD5XIQQK.js} +34 -34
- package/dist/{chunk-6DOKR7BM.js → chunk-WB565PQK.js} +246 -187
- package/dist/exec.d.ts +2 -2
- package/dist/exec.js +25 -25
- package/dist/{hof-types-tAeoYvzY.d.ts → hof-types-COqDeD5F.d.ts} +3 -3
- package/dist/{index-D4rnOHre.d.ts → index-DMjMPLV0.d.ts} +39 -39
- package/dist/index.d.ts +17 -17
- package/dist/index.js +48 -48
- package/dist/internal.d.ts +26 -26
- package/dist/internal.js +16 -16
- package/package.json +1 -1
|
@@ -1803,10 +1803,10 @@ function tryPromoteDirectCall(env, calleeName, args, loc) {
|
|
|
1803
1803
|
});
|
|
1804
1804
|
return env.vars.get(calleeName);
|
|
1805
1805
|
}
|
|
1806
|
-
function tryPromoteHofCallback(env,
|
|
1806
|
+
function tryPromoteHofCallback(env, cevalName, method, argAbses, loc) {
|
|
1807
1807
|
const hc = env.hofCollect;
|
|
1808
|
-
if (!hc || !hc.paramNames.has(
|
|
1809
|
-
const prev = env.vars.get(
|
|
1808
|
+
if (!hc || !hc.paramNames.has(cevalName)) return void 0;
|
|
1809
|
+
const prev = env.vars.get(cevalName);
|
|
1810
1810
|
if (!prev) return void 0;
|
|
1811
1811
|
if (prev.shape.k !== "any" && prev.shape.k !== "unknown") return void 0;
|
|
1812
1812
|
let paramTypes;
|
|
@@ -1820,12 +1820,12 @@ function tryPromoteHofCallback(env, cbName, method, argAbses, loc) {
|
|
|
1820
1820
|
paramTypes = argAbses.map(
|
|
1821
1821
|
(a) => abs({ k: "any" }, alphaOf(a, hc), void 0, "path")
|
|
1822
1822
|
);
|
|
1823
|
-
returnType = abs({ k: "any" }, betaOf(
|
|
1823
|
+
returnType = abs({ k: "any" }, betaOf(cevalName), void 0, "path");
|
|
1824
1824
|
} else {
|
|
1825
1825
|
paramTypes = argAbses.map(
|
|
1826
1826
|
(a) => abs({ k: "any" }, alphaOf(a, hc), void 0, "path")
|
|
1827
1827
|
);
|
|
1828
|
-
returnType = abs({ k: "any" }, betaOf(
|
|
1828
|
+
returnType = abs({ k: "any" }, betaOf(cevalName), void 0, "path");
|
|
1829
1829
|
}
|
|
1830
1830
|
const fnShape = {
|
|
1831
1831
|
k: "fn",
|
|
@@ -1833,14 +1833,14 @@ function tryPromoteHofCallback(env, cbName, method, argAbses, loc) {
|
|
|
1833
1833
|
paramTypes,
|
|
1834
1834
|
returnType
|
|
1835
1835
|
};
|
|
1836
|
-
promoteParamShape(env,
|
|
1836
|
+
promoteParamShape(env, cevalName, fnShape, { loc, recordSite: false });
|
|
1837
1837
|
hc.sites.push({
|
|
1838
|
-
param:
|
|
1838
|
+
param: cevalName,
|
|
1839
1839
|
argTerms: argAbses.map((a) => a.term ?? { op: "var", id: "_" }),
|
|
1840
1840
|
result: returnType,
|
|
1841
1841
|
loc
|
|
1842
1842
|
});
|
|
1843
|
-
return env.vars.get(
|
|
1843
|
+
return env.vars.get(cevalName);
|
|
1844
1844
|
}
|
|
1845
1845
|
function snapshotAbs(a) {
|
|
1846
1846
|
const shape = a.shape;
|
|
@@ -2465,22 +2465,56 @@ function concatString(a, b) {
|
|
|
2465
2465
|
);
|
|
2466
2466
|
}
|
|
2467
2467
|
const aParts = coerceToStringParts(a);
|
|
2468
|
-
const
|
|
2469
|
-
if (!aParts || !
|
|
2470
|
-
return createTemplateAbs([...aParts, ...
|
|
2468
|
+
const evalParts = coerceToStringParts(b);
|
|
2469
|
+
if (!aParts || !evalParts) return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
2470
|
+
return createTemplateAbs([...aParts, ...evalParts]);
|
|
2471
2471
|
}
|
|
2472
2472
|
function coerceToStringParts(a) {
|
|
2473
2473
|
if (isTemplateAbs(a) || isStrPrim2(a)) return templatePartsOf(a);
|
|
2474
2474
|
if (isStrLit(a)) return [a];
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2475
|
+
if (a.term?.op === "lit") {
|
|
2476
|
+
const v2 = a.term.value;
|
|
2477
|
+
if (typeof v2 === "symbol") return void 0;
|
|
2478
|
+
return [abs({ k: "prim", type: "string" }, lit(String(v2)), void 0, "exact")];
|
|
2478
2479
|
}
|
|
2479
2480
|
if (a.shape.k === "prim" && a.shape.type === "number") {
|
|
2480
2481
|
return [a];
|
|
2481
2482
|
}
|
|
2483
|
+
if (a.shape.k === "tuple" || a.shape.k === "arr") {
|
|
2484
|
+
return [arrayToPrimitiveString(a)];
|
|
2485
|
+
}
|
|
2486
|
+
if (a.shape.k === "obj" && !a.shape.open && !a.shape.index && !isNullProtoObj(a)) {
|
|
2487
|
+
const slots = a.shape.slots;
|
|
2488
|
+
if (!Object.hasOwn(slots, "toString") && !Object.hasOwn(slots, "valueOf")) {
|
|
2489
|
+
return [
|
|
2490
|
+
abs({ k: "prim", type: "string" }, lit("[object Object]"), void 0, "exact")
|
|
2491
|
+
];
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2482
2494
|
return void 0;
|
|
2483
2495
|
}
|
|
2496
|
+
function arrayToPrimitiveString(a) {
|
|
2497
|
+
const s = a.shape;
|
|
2498
|
+
const strPrimPart = () => abs({ k: "prim", type: "string" }, void 0, void 0, "path");
|
|
2499
|
+
if (s.k === "arr") return strPrimPart();
|
|
2500
|
+
if (s.k !== "tuple") return strPrimPart();
|
|
2501
|
+
const holes = s.holes ?? [];
|
|
2502
|
+
const parts = [];
|
|
2503
|
+
for (let i = 0; i < s.elements.length; i++) {
|
|
2504
|
+
if (holes.includes(i)) {
|
|
2505
|
+
parts.push("");
|
|
2506
|
+
continue;
|
|
2507
|
+
}
|
|
2508
|
+
const el = s.elements[i];
|
|
2509
|
+
if (el.term?.op !== "lit") return strPrimPart();
|
|
2510
|
+
const v2 = el.term.value;
|
|
2511
|
+
if (typeof v2 === "symbol") return strPrimPart();
|
|
2512
|
+
if (v2 === null || v2 === void 0) parts.push("");
|
|
2513
|
+
else if (typeof v2 === "object") return strPrimPart();
|
|
2514
|
+
else parts.push(String(v2));
|
|
2515
|
+
}
|
|
2516
|
+
return abs({ k: "prim", type: "string" }, lit(parts.join(",")), void 0, "exact");
|
|
2517
|
+
}
|
|
2484
2518
|
|
|
2485
2519
|
// src/algebra/symbol-id.ts
|
|
2486
2520
|
var symbolMeta = /* @__PURE__ */ new WeakMap();
|
|
@@ -2701,6 +2735,9 @@ function add(a, b, phi2 = pTrue) {
|
|
|
2701
2735
|
if (isStrPrim(a) || isStrPrim(b) || isTemplateLike(a) || isTemplateLike(b)) {
|
|
2702
2736
|
return concatString(a, b);
|
|
2703
2737
|
}
|
|
2738
|
+
if (a.shape.k === "tuple" || a.shape.k === "arr" || b.shape.k === "tuple" || b.shape.k === "arr") {
|
|
2739
|
+
return concatString(a, b);
|
|
2740
|
+
}
|
|
2704
2741
|
if (isNumPrim(a) && isNumPrim(b)) {
|
|
2705
2742
|
if (!a.term || !b.term) {
|
|
2706
2743
|
return abs(num().shape, void 0, void 0, confJoin(a.conf, "widened"));
|
|
@@ -2806,17 +2843,17 @@ function isNumericLike(a) {
|
|
|
2806
2843
|
}
|
|
2807
2844
|
function addPred(a, b, sumTerm, phi2) {
|
|
2808
2845
|
const aBounds = numericBounds(a, phi2);
|
|
2809
|
-
const
|
|
2810
|
-
if (!aBounds && !
|
|
2846
|
+
const evalBounds = numericBounds(b, phi2);
|
|
2847
|
+
if (!aBounds && !evalBounds) return void 0;
|
|
2811
2848
|
const facts = [];
|
|
2812
|
-
if (aBounds?.lo !== void 0 &&
|
|
2813
|
-
const loSum = aBounds.lo.value +
|
|
2814
|
-
const strict = aBounds.lo.strict ||
|
|
2849
|
+
if (aBounds?.lo !== void 0 && evalBounds?.lo !== void 0) {
|
|
2850
|
+
const loSum = aBounds.lo.value + evalBounds.lo.value;
|
|
2851
|
+
const strict = aBounds.lo.strict || evalBounds.lo.strict;
|
|
2815
2852
|
facts.push(strict ? gt(sumTerm, lit(loSum)) : ge(sumTerm, lit(loSum)));
|
|
2816
2853
|
}
|
|
2817
|
-
if (aBounds?.hi !== void 0 &&
|
|
2818
|
-
const hiSum = aBounds.hi.value +
|
|
2819
|
-
const strict = aBounds.hi.strict ||
|
|
2854
|
+
if (aBounds?.hi !== void 0 && evalBounds?.hi !== void 0) {
|
|
2855
|
+
const hiSum = aBounds.hi.value + evalBounds.hi.value;
|
|
2856
|
+
const strict = aBounds.hi.strict || evalBounds.hi.strict;
|
|
2820
2857
|
facts.push(strict ? lt(sumTerm, lit(hiSum)) : le(sumTerm, lit(hiSum)));
|
|
2821
2858
|
}
|
|
2822
2859
|
if (facts.length === 0) return void 0;
|
|
@@ -4808,7 +4845,12 @@ function evalArrayStatic(name, args) {
|
|
|
4808
4845
|
return boolLit(false);
|
|
4809
4846
|
}
|
|
4810
4847
|
case "of":
|
|
4811
|
-
return abs(
|
|
4848
|
+
return abs(
|
|
4849
|
+
{ k: "tuple", elements: args.map((a) => asAbs(a) ?? unknown) },
|
|
4850
|
+
void 0,
|
|
4851
|
+
void 0,
|
|
4852
|
+
"exact"
|
|
4853
|
+
);
|
|
4812
4854
|
case "from": {
|
|
4813
4855
|
const mapFn = args[1];
|
|
4814
4856
|
const hasMapFn = mapFn !== void 0 && mapFn !== null;
|
|
@@ -5984,8 +6026,8 @@ function strictEqAbs(a, b) {
|
|
|
5984
6026
|
if (an !== void 0 && bn !== void 0) return an === bn;
|
|
5985
6027
|
}
|
|
5986
6028
|
const aIsAbs = !!(a && typeof a === "object" && "shape" in a);
|
|
5987
|
-
const
|
|
5988
|
-
if (!aIsAbs || !
|
|
6029
|
+
const evalIsAbs = !!(b && typeof b === "object" && "shape" in b);
|
|
6030
|
+
if (!aIsAbs || !evalIsAbs) {
|
|
5989
6031
|
return a === b ? true : void 0;
|
|
5990
6032
|
}
|
|
5991
6033
|
if (a.term?.op === "lit" && b.term?.op === "lit") {
|
|
@@ -6011,8 +6053,8 @@ function strictEqAbs(a, b) {
|
|
|
6011
6053
|
const vb = litValue(b);
|
|
6012
6054
|
if (va !== void 0 && vb !== void 0) return va === vb;
|
|
6013
6055
|
const aNullish = va === null || a.term?.op === "lit" && a.term.value === void 0;
|
|
6014
|
-
const
|
|
6015
|
-
if (
|
|
6056
|
+
const evalNullish = vb === null || b.term?.op === "lit" && b.term.value === void 0;
|
|
6057
|
+
if (evalNullish && definitelyNotNullishShape(a.shape)) return false;
|
|
6016
6058
|
if (aNullish && definitelyNotNullishShape(b.shape)) return false;
|
|
6017
6059
|
if (a.term && b.term && a.term.op === "var" && b.term.op === "var" && a.term.id === b.term.id) {
|
|
6018
6060
|
const k = a.shape.k;
|
|
@@ -6090,6 +6132,18 @@ function isFoldableIndexArg(x) {
|
|
|
6090
6132
|
const v2 = x.term.value;
|
|
6091
6133
|
return v2 === void 0 || typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null;
|
|
6092
6134
|
}
|
|
6135
|
+
function toIntegerOrInfinityLit(x) {
|
|
6136
|
+
if (x === void 0) return 0;
|
|
6137
|
+
if (x.term?.op !== "lit") return void 0;
|
|
6138
|
+
const v2 = x.term.value;
|
|
6139
|
+
if (typeof v2 === "symbol" || typeof v2 === "bigint") return void 0;
|
|
6140
|
+
if (v2 === void 0) return 0;
|
|
6141
|
+
const n = Number(v2);
|
|
6142
|
+
if (Number.isNaN(n)) return 0;
|
|
6143
|
+
if (n === Infinity) return Infinity;
|
|
6144
|
+
if (n === -Infinity) return -Infinity;
|
|
6145
|
+
return Math.trunc(n);
|
|
6146
|
+
}
|
|
6093
6147
|
function toStringArg(x) {
|
|
6094
6148
|
if (x === void 0) return "undefined";
|
|
6095
6149
|
if (x.term?.op !== "lit") return void 0;
|
|
@@ -6180,6 +6234,14 @@ function callAbsMethod(recv, name, args) {
|
|
|
6180
6234
|
if (!isFoldableIndexArg(args[0])) return strPrim("path");
|
|
6181
6235
|
return strLit(lit3.charAt(Number(a0 ?? 0)));
|
|
6182
6236
|
}
|
|
6237
|
+
case "at": {
|
|
6238
|
+
if (lit3 === void 0) return strPrim("path");
|
|
6239
|
+
const iv = toIntegerOrInfinityLit(args[0]);
|
|
6240
|
+
if (iv === void 0) return strPrim("path");
|
|
6241
|
+
const idx = iv < 0 ? lit3.length + iv : iv;
|
|
6242
|
+
if (idx >= 0 && idx < lit3.length) return strLit(lit3[idx]);
|
|
6243
|
+
return undefAbs();
|
|
6244
|
+
}
|
|
6183
6245
|
case "toString":
|
|
6184
6246
|
case "valueOf":
|
|
6185
6247
|
return lit3 !== void 0 ? strLit(lit3) : strPrim("path");
|
|
@@ -8415,10 +8477,7 @@ function emitArrMutatorRebinds(expr, opts, pad) {
|
|
|
8415
8477
|
if (node.type === "UpdateExpression" && node.argument) {
|
|
8416
8478
|
const arg = node.argument;
|
|
8417
8479
|
const fn = node.operator === "++" ? "$add" : "$sub";
|
|
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") {
|
|
8480
|
+
if (arg.type === "MemberExpression") {
|
|
8422
8481
|
const path = memberPathOf(
|
|
8423
8482
|
arg,
|
|
8424
8483
|
opts
|
|
@@ -10012,9 +10071,10 @@ function transpileExpression(expr, opts = {}) {
|
|
|
10012
10071
|
case "UpdateExpression": {
|
|
10013
10072
|
const arg = expr.argument;
|
|
10014
10073
|
const fn = expr.operator === "++" ? "$add" : "$sub";
|
|
10074
|
+
const undo = expr.operator === "++" ? "$sub" : "$add";
|
|
10015
10075
|
if (arg.type === "Identifier") {
|
|
10016
10076
|
if (expr.prefix) return `${arg.name} = ${fn}(${arg.name}, $lit(1))`;
|
|
10017
|
-
return arg.name
|
|
10077
|
+
return `(${arg.name} = ${fn}(${arg.name}, $lit(1)), ${undo}(${arg.name}, $lit(1)))`;
|
|
10018
10078
|
}
|
|
10019
10079
|
if (arg.type === "MemberExpression") {
|
|
10020
10080
|
const m = arg;
|
|
@@ -10526,7 +10586,7 @@ function runtimeImportOf(runtime) {
|
|
|
10526
10586
|
function transpileFile(file, opts = {}) {
|
|
10527
10587
|
const runtime = opts.runtimeImport ?? "@nudojs/core/exec";
|
|
10528
10588
|
const lines = [
|
|
10529
|
-
`// nudo
|
|
10589
|
+
`// nudo evaluator transpile \u2014 values are Abs; operators are overloaded calls`,
|
|
10530
10590
|
`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)};`,
|
|
10531
10591
|
``
|
|
10532
10592
|
];
|
|
@@ -10552,11 +10612,11 @@ function getAbsCallBudgetStats() {
|
|
|
10552
10612
|
return {
|
|
10553
10613
|
calls: _absTotalCalls,
|
|
10554
10614
|
maxCalls: MAX_TOTAL_CALLS,
|
|
10555
|
-
forks:
|
|
10556
|
-
maxForks:
|
|
10615
|
+
forks: _evalForkCount,
|
|
10616
|
+
maxForks: _evalForkBudgetLimit,
|
|
10557
10617
|
callTruncated: _callTruncated,
|
|
10558
|
-
forkTruncated:
|
|
10559
|
-
truncated: _callTruncated ||
|
|
10618
|
+
forkTruncated: _evalForkTruncNoted,
|
|
10619
|
+
truncated: _callTruncated || _evalForkTruncNoted
|
|
10560
10620
|
};
|
|
10561
10621
|
}
|
|
10562
10622
|
function resetAbsCallBudget() {
|
|
@@ -10564,7 +10624,7 @@ function resetAbsCallBudget() {
|
|
|
10564
10624
|
_absTotalCalls = 0;
|
|
10565
10625
|
_activeCallKeys = [];
|
|
10566
10626
|
_callTruncated = false;
|
|
10567
|
-
|
|
10627
|
+
resetEvalForkBudget();
|
|
10568
10628
|
}
|
|
10569
10629
|
function stableCallId(obj2) {
|
|
10570
10630
|
let id = _fnCallIds.get(obj2);
|
|
@@ -10614,41 +10674,41 @@ function exitCall() {
|
|
|
10614
10674
|
_absCallDepth--;
|
|
10615
10675
|
_activeCallKeys.pop();
|
|
10616
10676
|
}
|
|
10617
|
-
var
|
|
10618
|
-
var
|
|
10619
|
-
var
|
|
10620
|
-
var
|
|
10677
|
+
var MAX_EVAL_TOTAL_FORKS = 5e3;
|
|
10678
|
+
var _evalForkBudgetLimit = MAX_EVAL_TOTAL_FORKS;
|
|
10679
|
+
var _evalForkCount = 0;
|
|
10680
|
+
var _evalForkTruncNoted = false;
|
|
10621
10681
|
var FORK_TRUNCATION_LABEL = "#fork-budget";
|
|
10622
10682
|
var HOST_EFFECT_LABEL_PREFIX = "#host-effect:";
|
|
10623
10683
|
function noteHostEffectBlocked(name) {
|
|
10624
10684
|
noteAbsTruncation(`${HOST_EFFECT_LABEL_PREFIX}${name}`);
|
|
10625
10685
|
}
|
|
10626
|
-
function
|
|
10686
|
+
function noteEvalForkTruncation() {
|
|
10627
10687
|
noteAbsTruncation(FORK_TRUNCATION_LABEL);
|
|
10628
10688
|
}
|
|
10629
|
-
function
|
|
10689
|
+
function setEvalForkBudgetLimit(n) {
|
|
10630
10690
|
if (typeof n === "number" && Number.isFinite(n) && n >= 1) {
|
|
10631
|
-
|
|
10691
|
+
_evalForkBudgetLimit = Math.floor(n);
|
|
10632
10692
|
} else {
|
|
10633
|
-
|
|
10693
|
+
_evalForkBudgetLimit = MAX_EVAL_TOTAL_FORKS;
|
|
10634
10694
|
}
|
|
10635
|
-
return
|
|
10695
|
+
return _evalForkBudgetLimit;
|
|
10636
10696
|
}
|
|
10637
|
-
function
|
|
10638
|
-
return
|
|
10697
|
+
function getEvalForkBudgetLimit() {
|
|
10698
|
+
return _evalForkBudgetLimit;
|
|
10639
10699
|
}
|
|
10640
|
-
function
|
|
10641
|
-
return
|
|
10700
|
+
function getEvalForkCount() {
|
|
10701
|
+
return _evalForkCount;
|
|
10642
10702
|
}
|
|
10643
|
-
function
|
|
10644
|
-
|
|
10645
|
-
|
|
10703
|
+
function resetEvalForkBudget() {
|
|
10704
|
+
_evalForkCount = 0;
|
|
10705
|
+
_evalForkTruncNoted = false;
|
|
10646
10706
|
}
|
|
10647
|
-
function
|
|
10648
|
-
if (++
|
|
10649
|
-
if (!
|
|
10650
|
-
|
|
10651
|
-
|
|
10707
|
+
function bumpEvalForkBudget() {
|
|
10708
|
+
if (++_evalForkCount <= _evalForkBudgetLimit) return true;
|
|
10709
|
+
if (!_evalForkTruncNoted) {
|
|
10710
|
+
_evalForkTruncNoted = true;
|
|
10711
|
+
noteEvalForkTruncation();
|
|
10652
10712
|
}
|
|
10653
10713
|
return false;
|
|
10654
10714
|
}
|
|
@@ -10775,10 +10835,10 @@ __export(runtime_exports, {
|
|
|
10775
10835
|
|
|
10776
10836
|
// src/algebra/exec/class-registry.ts
|
|
10777
10837
|
var classRegistry = /* @__PURE__ */ new Map();
|
|
10778
|
-
function
|
|
10838
|
+
function registerEvalClass(spec) {
|
|
10779
10839
|
classRegistry.set(spec.name, spec);
|
|
10780
10840
|
}
|
|
10781
|
-
function
|
|
10841
|
+
function getEvalClass(name) {
|
|
10782
10842
|
return classRegistry.get(name);
|
|
10783
10843
|
}
|
|
10784
10844
|
function clearBClasses() {
|
|
@@ -10821,9 +10881,9 @@ function findClassAccessor(startName, key) {
|
|
|
10821
10881
|
const seen = /* @__PURE__ */ new Set();
|
|
10822
10882
|
while (cur && !seen.has(cur)) {
|
|
10823
10883
|
seen.add(cur);
|
|
10824
|
-
const acc =
|
|
10884
|
+
const acc = getEvalClass(cur)?.accessors?.[key];
|
|
10825
10885
|
if (acc) return acc;
|
|
10826
|
-
cur =
|
|
10886
|
+
cur = getEvalClass(cur)?.superName;
|
|
10827
10887
|
}
|
|
10828
10888
|
return void 0;
|
|
10829
10889
|
}
|
|
@@ -10832,9 +10892,9 @@ function findStaticClassAccessor(startName, key) {
|
|
|
10832
10892
|
const seen = /* @__PURE__ */ new Set();
|
|
10833
10893
|
while (cur && !seen.has(cur)) {
|
|
10834
10894
|
seen.add(cur);
|
|
10835
|
-
const acc =
|
|
10895
|
+
const acc = getEvalClass(cur)?.staticAccessors?.[key];
|
|
10836
10896
|
if (acc) return acc;
|
|
10837
|
-
cur =
|
|
10897
|
+
cur = getEvalClass(cur)?.superName;
|
|
10838
10898
|
}
|
|
10839
10899
|
return void 0;
|
|
10840
10900
|
}
|
|
@@ -10897,8 +10957,8 @@ var BUILTIN_BRAND_METHODS = {
|
|
|
10897
10957
|
Promise: /* @__PURE__ */ new Set(["then", "catch", "finally"])
|
|
10898
10958
|
};
|
|
10899
10959
|
function brandHasProtoMember(brandName, key) {
|
|
10900
|
-
for (const name of
|
|
10901
|
-
const spec =
|
|
10960
|
+
for (const name of evalClassChain(brandName)) {
|
|
10961
|
+
const spec = getEvalClass(name);
|
|
10902
10962
|
if (spec?.methods?.[key]) return true;
|
|
10903
10963
|
if (spec?.accessors?.[key]) return true;
|
|
10904
10964
|
const builtin = BUILTIN_BRAND_METHODS[name];
|
|
@@ -10916,12 +10976,12 @@ var BUILTIN_ERROR_SUPER2 = {
|
|
|
10916
10976
|
EvalError: "Error",
|
|
10917
10977
|
AggregateError: "Error"
|
|
10918
10978
|
};
|
|
10919
|
-
function
|
|
10979
|
+
function evalClassChain(name) {
|
|
10920
10980
|
const out = [name];
|
|
10921
10981
|
let cur = name;
|
|
10922
10982
|
let depth = 0;
|
|
10923
10983
|
while (cur && depth++ < 32) {
|
|
10924
|
-
const spec =
|
|
10984
|
+
const spec = getEvalClass(cur);
|
|
10925
10985
|
const parent = spec?.superName ?? BUILTIN_ERROR_SUPER2[cur];
|
|
10926
10986
|
if (!parent || out.includes(parent)) break;
|
|
10927
10987
|
out.push(parent);
|
|
@@ -10978,7 +11038,7 @@ function $instanceof(left, rightName, rightVal) {
|
|
|
10978
11038
|
return boolLit(rightName === "Function" || rightName === "Object");
|
|
10979
11039
|
}
|
|
10980
11040
|
return boolLit(
|
|
10981
|
-
rightName === "Object" ||
|
|
11041
|
+
rightName === "Object" || evalClassChain(left.shape.name).includes(rightName)
|
|
10982
11042
|
);
|
|
10983
11043
|
case "arr":
|
|
10984
11044
|
case "tuple":
|
|
@@ -11549,7 +11609,7 @@ function $idxSet(a, i, value) {
|
|
|
11549
11609
|
}
|
|
11550
11610
|
if (sk === "brand") {
|
|
11551
11611
|
if (iv === void 0) return a;
|
|
11552
|
-
if (
|
|
11612
|
+
if (getEvalClass(a.shape.name)) return $set(a, String(iv), value);
|
|
11553
11613
|
return a;
|
|
11554
11614
|
}
|
|
11555
11615
|
if (sk === "tuple") {
|
|
@@ -11944,8 +12004,8 @@ function $get(o, key, opts) {
|
|
|
11944
12004
|
const sacc = findStaticClassAccessor(o.shape.name, key);
|
|
11945
12005
|
if (sacc) return sacc.get ? sacc.get(o) : undef();
|
|
11946
12006
|
if (findClassAccessor(o.shape.name, key)) return undef();
|
|
11947
|
-
for (const n of
|
|
11948
|
-
const spec =
|
|
12007
|
+
for (const n of evalClassChain(o.shape.name)) {
|
|
12008
|
+
const spec = getEvalClass(n);
|
|
11949
12009
|
if (spec?.staticMethods?.[key]) {
|
|
11950
12010
|
return absFunction(spec.staticMethodParams?.[key] ?? [], { body: noBody2 });
|
|
11951
12011
|
}
|
|
@@ -11960,8 +12020,8 @@ function $get(o, key, opts) {
|
|
|
11960
12020
|
const acc = findClassAccessor(o.shape.name, key);
|
|
11961
12021
|
if (acc) return acc.get ? acc.get(o) : undef();
|
|
11962
12022
|
if (findStaticClassAccessor(o.shape.name, key)) return undef();
|
|
11963
|
-
for (const n of
|
|
11964
|
-
const spec =
|
|
12023
|
+
for (const n of evalClassChain(o.shape.name)) {
|
|
12024
|
+
const spec = getEvalClass(n);
|
|
11965
12025
|
if (spec?.methods?.[key]) {
|
|
11966
12026
|
return absFunction(spec.methodParams?.[key] ?? [], { body: noBody2 });
|
|
11967
12027
|
}
|
|
@@ -11987,7 +12047,7 @@ function $get(o, key, opts) {
|
|
|
11987
12047
|
return arrayMethodAbs(key === "join" ? "join" : key);
|
|
11988
12048
|
}
|
|
11989
12049
|
if (o.shape.k !== "prim" && (ARRAY_PROTO_METHOD_NAMES.has(key) || key === "@@iterator")) {
|
|
11990
|
-
return
|
|
12050
|
+
return { shape: { k: "fn", params: [] }, conf: "path" };
|
|
11991
12051
|
}
|
|
11992
12052
|
return objectProtoMethodAbs(key);
|
|
11993
12053
|
}
|
|
@@ -12240,8 +12300,8 @@ function runForkArm(arm, exits) {
|
|
|
12240
12300
|
}
|
|
12241
12301
|
function settleForkArms(a, b, exits) {
|
|
12242
12302
|
const aThrow = a.kind === "throw";
|
|
12243
|
-
const
|
|
12244
|
-
if (aThrow &&
|
|
12303
|
+
const evalThrow = b.kind === "throw";
|
|
12304
|
+
if (aThrow && evalThrow) {
|
|
12245
12305
|
throw new NudoThrow(joinAbs(a.v, b.v));
|
|
12246
12306
|
}
|
|
12247
12307
|
const first = aThrow ? b : a;
|
|
@@ -12249,7 +12309,7 @@ function settleForkArms(a, b, exits) {
|
|
|
12249
12309
|
if (first.kind === "ret" && second.kind === "ret") {
|
|
12250
12310
|
throw new NudoReturn(joinAbs(first.v, second.v));
|
|
12251
12311
|
}
|
|
12252
|
-
if (aThrow !==
|
|
12312
|
+
if (aThrow !== evalThrow) {
|
|
12253
12313
|
if (first.kind === "ret") {
|
|
12254
12314
|
if (!exits) throw new NudoReturn(first.v);
|
|
12255
12315
|
return undef();
|
|
@@ -12289,7 +12349,7 @@ function boundedPhi(p, q) {
|
|
|
12289
12349
|
function $fork(test, consequent, alternate) {
|
|
12290
12350
|
notePromiseExecutorFork();
|
|
12291
12351
|
const testAbs = asAbsVal(test);
|
|
12292
|
-
if (!
|
|
12352
|
+
if (!bumpEvalForkBudget()) return unknown;
|
|
12293
12353
|
const truth = litTruth(testAbs);
|
|
12294
12354
|
const p = currentExecPhi();
|
|
12295
12355
|
const tCons = testAbs.pred;
|
|
@@ -12687,10 +12747,10 @@ __export(class_exports, {
|
|
|
12687
12747
|
$thisSet: () => $thisSet,
|
|
12688
12748
|
clearBClasses: () => clearBClasses,
|
|
12689
12749
|
execRegexBrand: () => execRegexBrand,
|
|
12690
|
-
|
|
12750
|
+
getEvalClass: () => getEvalClass,
|
|
12691
12751
|
regexExecWithState: () => regexExecWithState,
|
|
12692
12752
|
regexParts: () => regexParts,
|
|
12693
|
-
|
|
12753
|
+
registerEvalClass: () => registerEvalClass,
|
|
12694
12754
|
stringRegexMethod: () => stringRegexMethod
|
|
12695
12755
|
});
|
|
12696
12756
|
|
|
@@ -12700,29 +12760,29 @@ __export(calls_exports, {
|
|
|
12700
12760
|
$assignRecord: () => $assignRecord,
|
|
12701
12761
|
$callNamed: () => $callNamed,
|
|
12702
12762
|
$recordBinding: () => $recordBinding,
|
|
12703
|
-
|
|
12704
|
-
|
|
12763
|
+
MAX_EVAL_CALL_DEPTH: () => MAX_EVAL_CALL_DEPTH,
|
|
12764
|
+
MAX_EVAL_TOTAL_CALLS: () => MAX_EVAL_TOTAL_CALLS,
|
|
12705
12765
|
blockHostSideEffect: () => blockHostSideEffect,
|
|
12706
|
-
|
|
12766
|
+
getEvalCallCollector: () => getEvalCallCollector,
|
|
12707
12767
|
neverExecHostName: () => neverExecHostName,
|
|
12708
|
-
|
|
12709
|
-
|
|
12710
|
-
|
|
12711
|
-
|
|
12712
|
-
|
|
12768
|
+
noteEvalCallRecord: () => noteEvalCallRecord,
|
|
12769
|
+
resetEvalCallBudget: () => resetEvalCallBudget,
|
|
12770
|
+
setEvalAssignCollector: () => setEvalAssignCollector,
|
|
12771
|
+
setEvalBindingSink: () => setEvalBindingSink,
|
|
12772
|
+
setEvalCallCollector: () => setEvalCallCollector
|
|
12713
12773
|
});
|
|
12714
12774
|
var pureCallMemo = /* @__PURE__ */ new WeakMap();
|
|
12715
|
-
var
|
|
12716
|
-
var
|
|
12717
|
-
function
|
|
12718
|
-
const prev =
|
|
12719
|
-
|
|
12775
|
+
var evalCallCollector = null;
|
|
12776
|
+
var evalAssignCollector = null;
|
|
12777
|
+
function setEvalAssignCollector(collector2) {
|
|
12778
|
+
const prev = evalAssignCollector;
|
|
12779
|
+
evalAssignCollector = collector2;
|
|
12720
12780
|
return prev;
|
|
12721
12781
|
}
|
|
12722
12782
|
function $assignRecord(name, prev, next, line, column, conditional) {
|
|
12723
|
-
if (!
|
|
12783
|
+
if (!evalAssignCollector) return;
|
|
12724
12784
|
try {
|
|
12725
|
-
|
|
12785
|
+
evalAssignCollector({
|
|
12726
12786
|
name,
|
|
12727
12787
|
prev,
|
|
12728
12788
|
next,
|
|
@@ -12734,7 +12794,7 @@ function $assignRecord(name, prev, next, line, column, conditional) {
|
|
|
12734
12794
|
}
|
|
12735
12795
|
}
|
|
12736
12796
|
var bindingSink = null;
|
|
12737
|
-
function
|
|
12797
|
+
function setEvalBindingSink(sink) {
|
|
12738
12798
|
bindingSink = sink;
|
|
12739
12799
|
}
|
|
12740
12800
|
function $recordBinding(name, value) {
|
|
@@ -12779,63 +12839,63 @@ function blockHostSideEffect(fn) {
|
|
|
12779
12839
|
noteHostEffectBlocked(hostName);
|
|
12780
12840
|
return abs({ k: "unknown" }, void 0, void 0, "opaque");
|
|
12781
12841
|
}
|
|
12782
|
-
function
|
|
12783
|
-
if (!
|
|
12842
|
+
function noteEvalCallRecord(r) {
|
|
12843
|
+
if (!evalCallCollector) return;
|
|
12784
12844
|
try {
|
|
12785
|
-
|
|
12845
|
+
evalCallCollector(r);
|
|
12786
12846
|
} catch {
|
|
12787
12847
|
}
|
|
12788
12848
|
}
|
|
12789
|
-
function
|
|
12790
|
-
const prev =
|
|
12791
|
-
|
|
12849
|
+
function setEvalCallCollector(collector2) {
|
|
12850
|
+
const prev = evalCallCollector;
|
|
12851
|
+
evalCallCollector = collector2;
|
|
12792
12852
|
return prev;
|
|
12793
12853
|
}
|
|
12794
|
-
function
|
|
12795
|
-
return
|
|
12796
|
-
}
|
|
12797
|
-
var
|
|
12798
|
-
var
|
|
12799
|
-
var
|
|
12800
|
-
var
|
|
12801
|
-
var
|
|
12802
|
-
var
|
|
12803
|
-
var
|
|
12804
|
-
function
|
|
12805
|
-
let id =
|
|
12854
|
+
function getEvalCallCollector() {
|
|
12855
|
+
return evalCallCollector;
|
|
12856
|
+
}
|
|
12857
|
+
var MAX_EVAL_CALL_DEPTH = 64;
|
|
12858
|
+
var MAX_EVAL_TOTAL_CALLS = 2e4;
|
|
12859
|
+
var evalCallDepth = 0;
|
|
12860
|
+
var evalTotalCalls = 0;
|
|
12861
|
+
var evalActiveCallKeys = [];
|
|
12862
|
+
var evalFnCallIds = /* @__PURE__ */ new WeakMap();
|
|
12863
|
+
var evalFnCallIdSeq = 0;
|
|
12864
|
+
function evalStableId(obj2) {
|
|
12865
|
+
let id = evalFnCallIds.get(obj2);
|
|
12806
12866
|
if (id === void 0) {
|
|
12807
|
-
id = `#${++
|
|
12808
|
-
|
|
12867
|
+
id = `#${++evalFnCallIdSeq}`;
|
|
12868
|
+
evalFnCallIds.set(obj2, id);
|
|
12809
12869
|
}
|
|
12810
12870
|
return id;
|
|
12811
12871
|
}
|
|
12812
|
-
function
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12872
|
+
function resetEvalCallBudget() {
|
|
12873
|
+
evalCallDepth = 0;
|
|
12874
|
+
evalTotalCalls = 0;
|
|
12875
|
+
evalActiveCallKeys = [];
|
|
12876
|
+
resetEvalForkBudget();
|
|
12817
12877
|
}
|
|
12818
|
-
function
|
|
12878
|
+
function evalTruncatedAbs() {
|
|
12819
12879
|
return abs({ k: "unknown" }, void 0, void 0, "opaque");
|
|
12820
12880
|
}
|
|
12821
|
-
function
|
|
12822
|
-
const id = fn && typeof fn === "object" ?
|
|
12881
|
+
function evalCallBudgetKey(name, fn, args) {
|
|
12882
|
+
const id = fn && typeof fn === "object" ? evalStableId(fn) : "prim";
|
|
12823
12883
|
return callBudgetKey(name, id, args);
|
|
12824
12884
|
}
|
|
12825
|
-
function
|
|
12826
|
-
const key =
|
|
12827
|
-
if (
|
|
12885
|
+
function evalEnterCall(name, fn, args) {
|
|
12886
|
+
const key = evalCallBudgetKey(name, fn, args);
|
|
12887
|
+
if (evalActiveCallKeys.includes(key) || evalCallDepth >= MAX_EVAL_CALL_DEPTH || evalTotalCalls >= MAX_EVAL_TOTAL_CALLS) {
|
|
12828
12888
|
noteAbsTruncation(name);
|
|
12829
12889
|
return { ok: false };
|
|
12830
12890
|
}
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12891
|
+
evalActiveCallKeys.push(key);
|
|
12892
|
+
evalCallDepth++;
|
|
12893
|
+
evalTotalCalls++;
|
|
12834
12894
|
return { ok: true, key };
|
|
12835
12895
|
}
|
|
12836
|
-
function
|
|
12837
|
-
|
|
12838
|
-
|
|
12896
|
+
function evalExitCall() {
|
|
12897
|
+
evalCallDepth--;
|
|
12898
|
+
evalActiveCallKeys.pop();
|
|
12839
12899
|
}
|
|
12840
12900
|
function $callNamed(name, fn, args, loc, argLocs) {
|
|
12841
12901
|
const pureName = pureFnNameOf(fn);
|
|
@@ -12866,26 +12926,26 @@ function $callNamed(name, fn, args, loc, argLocs) {
|
|
|
12866
12926
|
} else if (blockedHost !== null) {
|
|
12867
12927
|
result = blockedHost;
|
|
12868
12928
|
} else {
|
|
12869
|
-
const entered =
|
|
12929
|
+
const entered = evalEnterCall(name, fn, args);
|
|
12870
12930
|
if (!entered.ok) {
|
|
12871
|
-
result =
|
|
12931
|
+
result = evalTruncatedAbs();
|
|
12872
12932
|
} else {
|
|
12873
12933
|
try {
|
|
12874
12934
|
result = callAtFunctionBoundary(() => fn(...args));
|
|
12875
12935
|
} finally {
|
|
12876
|
-
|
|
12936
|
+
evalExitCall();
|
|
12877
12937
|
}
|
|
12878
12938
|
}
|
|
12879
12939
|
}
|
|
12880
12940
|
} else if (fn && typeof fn === "object" && "shape" in fn) {
|
|
12881
|
-
const entered =
|
|
12941
|
+
const entered = evalEnterCall(name, fn, args);
|
|
12882
12942
|
if (!entered.ok) {
|
|
12883
|
-
result =
|
|
12943
|
+
result = evalTruncatedAbs();
|
|
12884
12944
|
} else {
|
|
12885
12945
|
try {
|
|
12886
12946
|
result = $call(fn, args);
|
|
12887
12947
|
} finally {
|
|
12888
|
-
|
|
12948
|
+
evalExitCall();
|
|
12889
12949
|
}
|
|
12890
12950
|
}
|
|
12891
12951
|
}
|
|
@@ -12902,9 +12962,9 @@ function $callNamed(name, fn, args, loc, argLocs) {
|
|
|
12902
12962
|
}
|
|
12903
12963
|
m.set(pk, result);
|
|
12904
12964
|
}
|
|
12905
|
-
if (
|
|
12965
|
+
if (evalCallCollector) {
|
|
12906
12966
|
try {
|
|
12907
|
-
|
|
12967
|
+
evalCallCollector({
|
|
12908
12968
|
fnName: name,
|
|
12909
12969
|
args: argsSnapshot,
|
|
12910
12970
|
result: threw ? unknown : result,
|
|
@@ -13080,7 +13140,7 @@ function $class(name, spec) {
|
|
|
13080
13140
|
accessors: spec.accessors,
|
|
13081
13141
|
staticAccessors: spec.staticAccessors
|
|
13082
13142
|
};
|
|
13083
|
-
|
|
13143
|
+
registerEvalClass(full);
|
|
13084
13144
|
const slots = {};
|
|
13085
13145
|
if (spec.statics) {
|
|
13086
13146
|
for (const [k, v2] of Object.entries(spec.statics)) slots[k] = { value: asAbsVal(v2) };
|
|
@@ -13098,7 +13158,7 @@ function $class(name, spec) {
|
|
|
13098
13158
|
}
|
|
13099
13159
|
function specOf(cls) {
|
|
13100
13160
|
if (classImpl.has(cls)) return classImpl.get(cls);
|
|
13101
|
-
if (cls.shape.k === "brand") return
|
|
13161
|
+
if (cls.shape.k === "brand") return getEvalClass(cls.shape.name);
|
|
13102
13162
|
return void 0;
|
|
13103
13163
|
}
|
|
13104
13164
|
function findMethod(startName, method) {
|
|
@@ -13106,7 +13166,7 @@ function findMethod(startName, method) {
|
|
|
13106
13166
|
const seen = /* @__PURE__ */ new Set();
|
|
13107
13167
|
while (cur && !seen.has(cur)) {
|
|
13108
13168
|
seen.add(cur);
|
|
13109
|
-
const spec =
|
|
13169
|
+
const spec = getEvalClass(cur);
|
|
13110
13170
|
if (spec?.methods?.[method]) return spec.methods[method];
|
|
13111
13171
|
cur = spec?.superName;
|
|
13112
13172
|
}
|
|
@@ -13117,7 +13177,7 @@ function findCtor(startName) {
|
|
|
13117
13177
|
const seen = /* @__PURE__ */ new Set();
|
|
13118
13178
|
while (cur && !seen.has(cur)) {
|
|
13119
13179
|
seen.add(cur);
|
|
13120
|
-
const spec =
|
|
13180
|
+
const spec = getEvalClass(cur);
|
|
13121
13181
|
if (spec?.ctor) return { ctor: spec.ctor, className: cur };
|
|
13122
13182
|
cur = spec?.superName;
|
|
13123
13183
|
}
|
|
@@ -13212,7 +13272,7 @@ function $new(cls, args) {
|
|
|
13212
13272
|
return thisVal;
|
|
13213
13273
|
}
|
|
13214
13274
|
function $super(thisVal, childName, args) {
|
|
13215
|
-
const child =
|
|
13275
|
+
const child = getEvalClass(childName);
|
|
13216
13276
|
const parentName = child?.superName;
|
|
13217
13277
|
if (!parentName) return thisVal;
|
|
13218
13278
|
const found = findCtor(parentName);
|
|
@@ -13449,7 +13509,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13449
13509
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
13450
13510
|
throw e;
|
|
13451
13511
|
} finally {
|
|
13452
|
-
|
|
13512
|
+
noteEvalCallRecord({
|
|
13453
13513
|
fnName: `${brandName}.${method}`,
|
|
13454
13514
|
args,
|
|
13455
13515
|
result,
|
|
@@ -13458,7 +13518,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13458
13518
|
});
|
|
13459
13519
|
}
|
|
13460
13520
|
}
|
|
13461
|
-
const spec =
|
|
13521
|
+
const spec = getEvalClass(brandName);
|
|
13462
13522
|
const sm = spec?.staticMethods?.[method];
|
|
13463
13523
|
if (sm) {
|
|
13464
13524
|
let result = unknown;
|
|
@@ -13471,7 +13531,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13471
13531
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
13472
13532
|
throw e;
|
|
13473
13533
|
} finally {
|
|
13474
|
-
|
|
13534
|
+
noteEvalCallRecord({
|
|
13475
13535
|
fnName: `${brandName}.${method}`,
|
|
13476
13536
|
args,
|
|
13477
13537
|
result,
|
|
@@ -13576,7 +13636,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
13576
13636
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
13577
13637
|
throw e;
|
|
13578
13638
|
} finally {
|
|
13579
|
-
|
|
13639
|
+
noteEvalCallRecord({
|
|
13580
13640
|
fnName: recordName,
|
|
13581
13641
|
args,
|
|
13582
13642
|
result,
|
|
@@ -13904,8 +13964,7 @@ function invokeArrMethod(arr, method, args) {
|
|
|
13904
13964
|
if (shape.k === "arr") return joinAbs(shape.element, undefAbs());
|
|
13905
13965
|
}
|
|
13906
13966
|
if (method === "at") {
|
|
13907
|
-
const
|
|
13908
|
-
const iv = typeof raw === "number" && Number.isInteger(raw) ? raw : void 0;
|
|
13967
|
+
const iv = toIntegerOrInfinityLit(args[0]);
|
|
13909
13968
|
if (shape.k === "tuple") {
|
|
13910
13969
|
const els = shape.elements;
|
|
13911
13970
|
if (iv === void 0) {
|
|
@@ -13921,7 +13980,7 @@ function invokeArrMethod(arr, method, args) {
|
|
|
13921
13980
|
return void 0;
|
|
13922
13981
|
}
|
|
13923
13982
|
function $invokeSuper(thisVal, childName, method, args) {
|
|
13924
|
-
const child =
|
|
13983
|
+
const child = getEvalClass(childName);
|
|
13925
13984
|
const parentName = child?.superName;
|
|
13926
13985
|
if (!parentName) return unknown;
|
|
13927
13986
|
const m = findMethod(parentName, method);
|
|
@@ -14027,7 +14086,7 @@ function $staticInvoke(cls, method, args) {
|
|
|
14027
14086
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
14028
14087
|
throw e;
|
|
14029
14088
|
} finally {
|
|
14030
|
-
|
|
14089
|
+
noteEvalCallRecord({ fnName: recordName, args, result, threw });
|
|
14031
14090
|
}
|
|
14032
14091
|
}
|
|
14033
14092
|
function $setKey(o, key, value) {
|
|
@@ -14301,7 +14360,7 @@ function bindingsOf(run) {
|
|
|
14301
14360
|
return runBindings.get(run);
|
|
14302
14361
|
}
|
|
14303
14362
|
function runTranspiled(source, opts = {}) {
|
|
14304
|
-
|
|
14363
|
+
resetEvalCallBudget();
|
|
14305
14364
|
const modules = opts.modules ?? {};
|
|
14306
14365
|
let js = transpile(source, {
|
|
14307
14366
|
runtimeImport: "@nudojs/core/exec",
|
|
@@ -14394,18 +14453,18 @@ ${js}`;
|
|
|
14394
14453
|
const ret = `return { ...__nudoExports, ...${cjsMerge}, ${names.join(", ")} };`;
|
|
14395
14454
|
const fn = new Function(...argNames, `${js}
|
|
14396
14455
|
${ret}`);
|
|
14397
|
-
|
|
14456
|
+
setEvalBindingSink(bindings);
|
|
14398
14457
|
try {
|
|
14399
14458
|
const result = fn(...args);
|
|
14400
14459
|
runBindings.set(result, bindings);
|
|
14401
14460
|
return result;
|
|
14402
14461
|
} finally {
|
|
14403
|
-
|
|
14462
|
+
setEvalBindingSink(null);
|
|
14404
14463
|
}
|
|
14405
14464
|
}
|
|
14406
|
-
var
|
|
14407
|
-
function
|
|
14408
|
-
|
|
14465
|
+
var evalFallbackCollector = null;
|
|
14466
|
+
function setEvalFallbackCollector(collector2) {
|
|
14467
|
+
evalFallbackCollector = collector2;
|
|
14409
14468
|
}
|
|
14410
14469
|
function evalExprAbs(expr, bindings = {}) {
|
|
14411
14470
|
const src = transpileExpression(expr, {});
|
|
@@ -14418,15 +14477,15 @@ function evalExprAbs(expr, bindings = {}) {
|
|
|
14418
14477
|
const factory = new Function(...names, cleaned);
|
|
14419
14478
|
return factory(...Object.values(rtAllBindings()), ...Object.values(bindings));
|
|
14420
14479
|
}
|
|
14421
|
-
function
|
|
14422
|
-
if (!
|
|
14480
|
+
function noteEvalFallback(e) {
|
|
14481
|
+
if (!evalFallbackCollector) return;
|
|
14423
14482
|
const f = e instanceof NudoUnsupportedError ? { reason: `unsupported:${e.reason}`, message: e.message, ...e.loc ? { loc: e.loc } : {} } : isNudoThrow(e) ? (
|
|
14424
14483
|
// NudoThrow:程序自身的抛(如顶层 this 写 / strict 写 TypeError)——
|
|
14425
14484
|
// 模块装载失败,不是 B 能力边界也不是 B 缺陷(catch 可吸收)
|
|
14426
14485
|
{ reason: "module-throw", message: e instanceof Error ? e.message : String(e) }
|
|
14427
14486
|
) : { reason: "internal", message: e instanceof Error ? e.message : String(e) };
|
|
14428
14487
|
try {
|
|
14429
|
-
|
|
14488
|
+
evalFallbackCollector(f);
|
|
14430
14489
|
} catch {
|
|
14431
14490
|
}
|
|
14432
14491
|
}
|
|
@@ -14434,7 +14493,7 @@ function tryRunTranspiled(source, opts = {}) {
|
|
|
14434
14493
|
try {
|
|
14435
14494
|
return runTranspiled(source, opts);
|
|
14436
14495
|
} catch (e) {
|
|
14437
|
-
|
|
14496
|
+
noteEvalFallback(e);
|
|
14438
14497
|
return void 0;
|
|
14439
14498
|
}
|
|
14440
14499
|
}
|
|
@@ -14444,7 +14503,7 @@ function isAbsVal(v2) {
|
|
|
14444
14503
|
function callTranspiledExportFull(exports, name, args, opts) {
|
|
14445
14504
|
const fn = exports[name];
|
|
14446
14505
|
if (typeof fn === "function") {
|
|
14447
|
-
|
|
14506
|
+
resetEvalCallBudget();
|
|
14448
14507
|
const callArgs = args.map(
|
|
14449
14508
|
(a) => a && typeof a === "object" && "shape" in a ? $copy(a) : a
|
|
14450
14509
|
);
|
|
@@ -14637,7 +14696,7 @@ function compiledBodyOf(impl) {
|
|
|
14637
14696
|
runner = (args) => bodyFn(...args);
|
|
14638
14697
|
compiledByImpl.set(implKey, runner);
|
|
14639
14698
|
} catch (e) {
|
|
14640
|
-
|
|
14699
|
+
noteEvalFallback(e);
|
|
14641
14700
|
return void 0;
|
|
14642
14701
|
}
|
|
14643
14702
|
return runner;
|
|
@@ -15144,19 +15203,19 @@ export {
|
|
|
15144
15203
|
noteAbsTruncation,
|
|
15145
15204
|
enterCall,
|
|
15146
15205
|
exitCall,
|
|
15147
|
-
|
|
15206
|
+
MAX_EVAL_TOTAL_FORKS,
|
|
15148
15207
|
FORK_TRUNCATION_LABEL,
|
|
15149
15208
|
HOST_EFFECT_LABEL_PREFIX,
|
|
15150
15209
|
noteHostEffectBlocked,
|
|
15151
|
-
|
|
15152
|
-
|
|
15153
|
-
|
|
15154
|
-
|
|
15155
|
-
|
|
15156
|
-
|
|
15210
|
+
noteEvalForkTruncation,
|
|
15211
|
+
setEvalForkBudgetLimit,
|
|
15212
|
+
getEvalForkBudgetLimit,
|
|
15213
|
+
getEvalForkCount,
|
|
15214
|
+
resetEvalForkBudget,
|
|
15215
|
+
bumpEvalForkBudget,
|
|
15157
15216
|
$call,
|
|
15158
|
-
|
|
15159
|
-
|
|
15217
|
+
registerEvalClass,
|
|
15218
|
+
getEvalClass,
|
|
15160
15219
|
clearBClasses,
|
|
15161
15220
|
$objAccessor,
|
|
15162
15221
|
lookupObjAccessor,
|
|
@@ -15205,16 +15264,16 @@ export {
|
|
|
15205
15264
|
$gen,
|
|
15206
15265
|
$yield,
|
|
15207
15266
|
$nullishTest,
|
|
15208
|
-
|
|
15267
|
+
setEvalAssignCollector,
|
|
15209
15268
|
$assignRecord,
|
|
15210
|
-
|
|
15269
|
+
setEvalBindingSink,
|
|
15211
15270
|
$recordBinding,
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15271
|
+
noteEvalCallRecord,
|
|
15272
|
+
setEvalCallCollector,
|
|
15273
|
+
getEvalCallCollector,
|
|
15274
|
+
MAX_EVAL_CALL_DEPTH,
|
|
15275
|
+
MAX_EVAL_TOTAL_CALLS,
|
|
15276
|
+
resetEvalCallBudget,
|
|
15218
15277
|
$callNamed,
|
|
15219
15278
|
$reStateCall,
|
|
15220
15279
|
$class,
|
|
@@ -15233,9 +15292,9 @@ export {
|
|
|
15233
15292
|
RUNTIME_IMPORT_RE,
|
|
15234
15293
|
bindingsOf,
|
|
15235
15294
|
runTranspiled,
|
|
15236
|
-
|
|
15295
|
+
setEvalFallbackCollector,
|
|
15237
15296
|
evalExprAbs,
|
|
15238
|
-
|
|
15297
|
+
noteEvalFallback,
|
|
15239
15298
|
tryRunTranspiled,
|
|
15240
15299
|
callTranspiledExportFull,
|
|
15241
15300
|
callTranspiledExport
|