nudojs 1.0.3 → 1.0.5
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/index.js +590 -533
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -16264,10 +16264,10 @@ function tryPromoteDirectCall(env2, calleeName, args, loc) {
|
|
|
16264
16264
|
});
|
|
16265
16265
|
return env2.vars.get(calleeName);
|
|
16266
16266
|
}
|
|
16267
|
-
function tryPromoteHofCallback(env2,
|
|
16267
|
+
function tryPromoteHofCallback(env2, cevalName, method, argAbses, loc) {
|
|
16268
16268
|
const hc = env2.hofCollect;
|
|
16269
|
-
if (!hc || !hc.paramNames.has(
|
|
16270
|
-
const prev = env2.vars.get(
|
|
16269
|
+
if (!hc || !hc.paramNames.has(cevalName)) return void 0;
|
|
16270
|
+
const prev = env2.vars.get(cevalName);
|
|
16271
16271
|
if (!prev) return void 0;
|
|
16272
16272
|
if (prev.shape.k !== "any" && prev.shape.k !== "unknown") return void 0;
|
|
16273
16273
|
let paramTypes;
|
|
@@ -16281,12 +16281,12 @@ function tryPromoteHofCallback(env2, cbName, method, argAbses, loc) {
|
|
|
16281
16281
|
paramTypes = argAbses.map(
|
|
16282
16282
|
(a) => abs({ k: "any" }, alphaOf(a, hc), void 0, "path")
|
|
16283
16283
|
);
|
|
16284
|
-
returnType = abs({ k: "any" }, betaOf(
|
|
16284
|
+
returnType = abs({ k: "any" }, betaOf(cevalName), void 0, "path");
|
|
16285
16285
|
} else {
|
|
16286
16286
|
paramTypes = argAbses.map(
|
|
16287
16287
|
(a) => abs({ k: "any" }, alphaOf(a, hc), void 0, "path")
|
|
16288
16288
|
);
|
|
16289
|
-
returnType = abs({ k: "any" }, betaOf(
|
|
16289
|
+
returnType = abs({ k: "any" }, betaOf(cevalName), void 0, "path");
|
|
16290
16290
|
}
|
|
16291
16291
|
const fnShape = {
|
|
16292
16292
|
k: "fn",
|
|
@@ -16294,14 +16294,14 @@ function tryPromoteHofCallback(env2, cbName, method, argAbses, loc) {
|
|
|
16294
16294
|
paramTypes,
|
|
16295
16295
|
returnType
|
|
16296
16296
|
};
|
|
16297
|
-
promoteParamShape(env2,
|
|
16297
|
+
promoteParamShape(env2, cevalName, fnShape, { loc, recordSite: false });
|
|
16298
16298
|
hc.sites.push({
|
|
16299
|
-
param:
|
|
16299
|
+
param: cevalName,
|
|
16300
16300
|
argTerms: argAbses.map((a) => a.term ?? { op: "var", id: "_" }),
|
|
16301
16301
|
result: returnType,
|
|
16302
16302
|
loc
|
|
16303
16303
|
});
|
|
16304
|
-
return env2.vars.get(
|
|
16304
|
+
return env2.vars.get(cevalName);
|
|
16305
16305
|
}
|
|
16306
16306
|
function snapshotAbs(a) {
|
|
16307
16307
|
const shape2 = a.shape;
|
|
@@ -16937,27 +16937,62 @@ function concatString(a, b) {
|
|
|
16937
16937
|
);
|
|
16938
16938
|
}
|
|
16939
16939
|
const aParts = coerceToStringParts(a);
|
|
16940
|
-
const
|
|
16941
|
-
if (!aParts || !
|
|
16942
|
-
return createTemplateAbs([...aParts, ...
|
|
16940
|
+
const evalParts = coerceToStringParts(b);
|
|
16941
|
+
if (!aParts || !evalParts) return abs({ k: "unknown" }, void 0, void 0, "partial");
|
|
16942
|
+
return createTemplateAbs([...aParts, ...evalParts]);
|
|
16943
16943
|
}
|
|
16944
16944
|
function coerceToStringParts(a) {
|
|
16945
16945
|
if (isTemplateAbs(a) || isStrPrim2(a)) return templatePartsOf(a);
|
|
16946
16946
|
if (isStrLit(a)) return [a];
|
|
16947
|
-
|
|
16948
|
-
|
|
16949
|
-
|
|
16947
|
+
if (a.term?.op === "lit") {
|
|
16948
|
+
const v2 = a.term.value;
|
|
16949
|
+
if (typeof v2 === "symbol") return void 0;
|
|
16950
|
+
return [abs({ k: "prim", type: "string" }, lit(String(v2)), void 0, "exact")];
|
|
16950
16951
|
}
|
|
16951
16952
|
if (a.shape.k === "prim" && a.shape.type === "number") {
|
|
16952
16953
|
return [a];
|
|
16953
16954
|
}
|
|
16955
|
+
if (a.shape.k === "tuple" || a.shape.k === "arr") {
|
|
16956
|
+
return [arrayToPrimitiveString(a)];
|
|
16957
|
+
}
|
|
16958
|
+
if (a.shape.k === "obj" && !a.shape.open && !a.shape.index && !isNullProtoObj(a)) {
|
|
16959
|
+
const slots = a.shape.slots;
|
|
16960
|
+
if (!Object.hasOwn(slots, "toString") && !Object.hasOwn(slots, "valueOf")) {
|
|
16961
|
+
return [
|
|
16962
|
+
abs({ k: "prim", type: "string" }, lit("[object Object]"), void 0, "exact")
|
|
16963
|
+
];
|
|
16964
|
+
}
|
|
16965
|
+
}
|
|
16954
16966
|
return void 0;
|
|
16955
16967
|
}
|
|
16968
|
+
function arrayToPrimitiveString(a) {
|
|
16969
|
+
const s = a.shape;
|
|
16970
|
+
const strPrimPart = () => abs({ k: "prim", type: "string" }, void 0, void 0, "path");
|
|
16971
|
+
if (s.k === "arr") return strPrimPart();
|
|
16972
|
+
if (s.k !== "tuple") return strPrimPart();
|
|
16973
|
+
const holes = s.holes ?? [];
|
|
16974
|
+
const parts = [];
|
|
16975
|
+
for (let i = 0; i < s.elements.length; i++) {
|
|
16976
|
+
if (holes.includes(i)) {
|
|
16977
|
+
parts.push("");
|
|
16978
|
+
continue;
|
|
16979
|
+
}
|
|
16980
|
+
const el = s.elements[i];
|
|
16981
|
+
if (el.term?.op !== "lit") return strPrimPart();
|
|
16982
|
+
const v2 = el.term.value;
|
|
16983
|
+
if (typeof v2 === "symbol") return strPrimPart();
|
|
16984
|
+
if (v2 === null || v2 === void 0) parts.push("");
|
|
16985
|
+
else if (typeof v2 === "object") return strPrimPart();
|
|
16986
|
+
else parts.push(String(v2));
|
|
16987
|
+
}
|
|
16988
|
+
return abs({ k: "prim", type: "string" }, lit(parts.join(",")), void 0, "exact");
|
|
16989
|
+
}
|
|
16956
16990
|
var init_template = __esm({
|
|
16957
16991
|
"../core/src/algebra/template.ts"() {
|
|
16958
16992
|
"use strict";
|
|
16959
16993
|
init_abs();
|
|
16960
16994
|
init_term();
|
|
16995
|
+
init_objects();
|
|
16961
16996
|
}
|
|
16962
16997
|
});
|
|
16963
16998
|
|
|
@@ -17199,6 +17234,9 @@ function add(a, b, phi2 = pTrue) {
|
|
|
17199
17234
|
if (isStrPrim(a) || isStrPrim(b) || isTemplateLike(a) || isTemplateLike(b)) {
|
|
17200
17235
|
return concatString(a, b);
|
|
17201
17236
|
}
|
|
17237
|
+
if (a.shape.k === "tuple" || a.shape.k === "arr" || b.shape.k === "tuple" || b.shape.k === "arr") {
|
|
17238
|
+
return concatString(a, b);
|
|
17239
|
+
}
|
|
17202
17240
|
if (isNumPrim(a) && isNumPrim(b)) {
|
|
17203
17241
|
if (!a.term || !b.term) {
|
|
17204
17242
|
return abs(num().shape, void 0, void 0, confJoin(a.conf, "widened"));
|
|
@@ -17304,17 +17342,17 @@ function isNumericLike(a) {
|
|
|
17304
17342
|
}
|
|
17305
17343
|
function addPred(a, b, sumTerm, phi2) {
|
|
17306
17344
|
const aBounds = numericBounds(a, phi2);
|
|
17307
|
-
const
|
|
17308
|
-
if (!aBounds && !
|
|
17345
|
+
const evalBounds = numericBounds(b, phi2);
|
|
17346
|
+
if (!aBounds && !evalBounds) return void 0;
|
|
17309
17347
|
const facts = [];
|
|
17310
|
-
if (aBounds?.lo !== void 0 &&
|
|
17311
|
-
const loSum = aBounds.lo.value +
|
|
17312
|
-
const strict = aBounds.lo.strict ||
|
|
17348
|
+
if (aBounds?.lo !== void 0 && evalBounds?.lo !== void 0) {
|
|
17349
|
+
const loSum = aBounds.lo.value + evalBounds.lo.value;
|
|
17350
|
+
const strict = aBounds.lo.strict || evalBounds.lo.strict;
|
|
17313
17351
|
facts.push(strict ? gt(sumTerm, lit(loSum)) : ge(sumTerm, lit(loSum)));
|
|
17314
17352
|
}
|
|
17315
|
-
if (aBounds?.hi !== void 0 &&
|
|
17316
|
-
const hiSum = aBounds.hi.value +
|
|
17317
|
-
const strict = aBounds.hi.strict ||
|
|
17353
|
+
if (aBounds?.hi !== void 0 && evalBounds?.hi !== void 0) {
|
|
17354
|
+
const hiSum = aBounds.hi.value + evalBounds.hi.value;
|
|
17355
|
+
const strict = aBounds.hi.strict || evalBounds.hi.strict;
|
|
17318
17356
|
facts.push(strict ? lt(sumTerm, lit(hiSum)) : le(sumTerm, lit(hiSum)));
|
|
17319
17357
|
}
|
|
17320
17358
|
if (facts.length === 0) return void 0;
|
|
@@ -19439,7 +19477,12 @@ function evalArrayStatic(name, args) {
|
|
|
19439
19477
|
return boolLit(false);
|
|
19440
19478
|
}
|
|
19441
19479
|
case "of":
|
|
19442
|
-
return abs(
|
|
19480
|
+
return abs(
|
|
19481
|
+
{ k: "tuple", elements: args.map((a) => asAbs(a) ?? unknown) },
|
|
19482
|
+
void 0,
|
|
19483
|
+
void 0,
|
|
19484
|
+
"exact"
|
|
19485
|
+
);
|
|
19443
19486
|
case "from": {
|
|
19444
19487
|
const mapFn = args[1];
|
|
19445
19488
|
const hasMapFn = mapFn !== void 0 && mapFn !== null;
|
|
@@ -20749,8 +20792,8 @@ function strictEqAbs(a, b) {
|
|
|
20749
20792
|
if (an !== void 0 && bn !== void 0) return an === bn;
|
|
20750
20793
|
}
|
|
20751
20794
|
const aIsAbs = !!(a && typeof a === "object" && "shape" in a);
|
|
20752
|
-
const
|
|
20753
|
-
if (!aIsAbs || !
|
|
20795
|
+
const evalIsAbs = !!(b && typeof b === "object" && "shape" in b);
|
|
20796
|
+
if (!aIsAbs || !evalIsAbs) {
|
|
20754
20797
|
return a === b ? true : void 0;
|
|
20755
20798
|
}
|
|
20756
20799
|
if (a.term?.op === "lit" && b.term?.op === "lit") {
|
|
@@ -20776,8 +20819,8 @@ function strictEqAbs(a, b) {
|
|
|
20776
20819
|
const vb = litValue(b);
|
|
20777
20820
|
if (va !== void 0 && vb !== void 0) return va === vb;
|
|
20778
20821
|
const aNullish = va === null || a.term?.op === "lit" && a.term.value === void 0;
|
|
20779
|
-
const
|
|
20780
|
-
if (
|
|
20822
|
+
const evalNullish = vb === null || b.term?.op === "lit" && b.term.value === void 0;
|
|
20823
|
+
if (evalNullish && definitelyNotNullishShape(a.shape)) return false;
|
|
20781
20824
|
if (aNullish && definitelyNotNullishShape(b.shape)) return false;
|
|
20782
20825
|
if (a.term && b.term && a.term.op === "var" && b.term.op === "var" && a.term.id === b.term.id) {
|
|
20783
20826
|
const k = a.shape.k;
|
|
@@ -20866,6 +20909,18 @@ function isFoldableIndexArg(x) {
|
|
|
20866
20909
|
const v2 = x.term.value;
|
|
20867
20910
|
return v2 === void 0 || typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null;
|
|
20868
20911
|
}
|
|
20912
|
+
function toIntegerOrInfinityLit(x) {
|
|
20913
|
+
if (x === void 0) return 0;
|
|
20914
|
+
if (x.term?.op !== "lit") return void 0;
|
|
20915
|
+
const v2 = x.term.value;
|
|
20916
|
+
if (typeof v2 === "symbol" || typeof v2 === "bigint") return void 0;
|
|
20917
|
+
if (v2 === void 0) return 0;
|
|
20918
|
+
const n = Number(v2);
|
|
20919
|
+
if (Number.isNaN(n)) return 0;
|
|
20920
|
+
if (n === Infinity) return Infinity;
|
|
20921
|
+
if (n === -Infinity) return -Infinity;
|
|
20922
|
+
return Math.trunc(n);
|
|
20923
|
+
}
|
|
20869
20924
|
function toStringArg(x) {
|
|
20870
20925
|
if (x === void 0) return "undefined";
|
|
20871
20926
|
if (x.term?.op !== "lit") return void 0;
|
|
@@ -20956,6 +21011,14 @@ function callAbsMethod(recv, name, args) {
|
|
|
20956
21011
|
if (!isFoldableIndexArg(args[0])) return strPrim("path");
|
|
20957
21012
|
return strLit(lit3.charAt(Number(a0 ?? 0)));
|
|
20958
21013
|
}
|
|
21014
|
+
case "at": {
|
|
21015
|
+
if (lit3 === void 0) return strPrim("path");
|
|
21016
|
+
const iv = toIntegerOrInfinityLit(args[0]);
|
|
21017
|
+
if (iv === void 0) return strPrim("path");
|
|
21018
|
+
const idx = iv < 0 ? lit3.length + iv : iv;
|
|
21019
|
+
if (idx >= 0 && idx < lit3.length) return strLit(lit3[idx]);
|
|
21020
|
+
return undefAbs();
|
|
21021
|
+
}
|
|
20959
21022
|
case "toString":
|
|
20960
21023
|
case "valueOf":
|
|
20961
21024
|
return lit3 !== void 0 ? strLit(lit3) : strPrim("path");
|
|
@@ -24250,9 +24313,9 @@ function promoteAsFn(ctx2, name, args, loc) {
|
|
|
24250
24313
|
loc
|
|
24251
24314
|
});
|
|
24252
24315
|
}
|
|
24253
|
-
function promoteCb(ctx2,
|
|
24254
|
-
if (!ctx2.params.has(
|
|
24255
|
-
const prev = ctx2.shapes.get(
|
|
24316
|
+
function promoteCb(ctx2, cevalName, method, argTerms, loc) {
|
|
24317
|
+
if (!ctx2.params.has(cevalName)) return;
|
|
24318
|
+
const prev = ctx2.shapes.get(cevalName);
|
|
24256
24319
|
if (!prev) return;
|
|
24257
24320
|
if (prev.shape.k !== "any" && prev.shape.k !== "unknown") return;
|
|
24258
24321
|
let paramTypes;
|
|
@@ -24262,7 +24325,7 @@ function promoteCb(ctx2, cbName, method, argTerms, loc) {
|
|
|
24262
24325
|
returnType = abs({ k: "prim", type: "boolean" }, void 0, void 0, "path");
|
|
24263
24326
|
} else {
|
|
24264
24327
|
paramTypes = argTerms.map((t) => abs({ k: "any" }, t, void 0, "path"));
|
|
24265
|
-
returnType = abs({ k: "any" }, v(`B:${
|
|
24328
|
+
returnType = abs({ k: "any" }, v(`B:${cevalName}`), void 0, "path");
|
|
24266
24329
|
}
|
|
24267
24330
|
const fnShape = {
|
|
24268
24331
|
k: "fn",
|
|
@@ -24270,9 +24333,9 @@ function promoteCb(ctx2, cbName, method, argTerms, loc) {
|
|
|
24270
24333
|
paramTypes,
|
|
24271
24334
|
returnType
|
|
24272
24335
|
};
|
|
24273
|
-
promoteShape(ctx2,
|
|
24336
|
+
promoteShape(ctx2, cevalName, fnShape, loc, false);
|
|
24274
24337
|
ctx2.sites.push({
|
|
24275
|
-
param:
|
|
24338
|
+
param: cevalName,
|
|
24276
24339
|
argTerms,
|
|
24277
24340
|
result: returnType,
|
|
24278
24341
|
loc
|
|
@@ -25729,10 +25792,7 @@ function emitArrMutatorRebinds(expr, opts, pad) {
|
|
|
25729
25792
|
if (node.type === "UpdateExpression" && node.argument) {
|
|
25730
25793
|
const arg = node.argument;
|
|
25731
25794
|
const fn2 = node.operator === "++" ? "$add" : "$sub";
|
|
25732
|
-
|
|
25733
|
-
if (arg.type === "Identifier" && arg.name) {
|
|
25734
|
-
if (isPostfix) lines.push(`${pad}${arg.name} = ${fn2}(${arg.name}, $lit(1));`);
|
|
25735
|
-
} else if (arg.type === "MemberExpression") {
|
|
25795
|
+
if (arg.type === "MemberExpression") {
|
|
25736
25796
|
const path = memberPathOf(
|
|
25737
25797
|
arg,
|
|
25738
25798
|
opts
|
|
@@ -27354,9 +27414,10 @@ function transpileExpression(expr, opts = {}) {
|
|
|
27354
27414
|
case "UpdateExpression": {
|
|
27355
27415
|
const arg = expr.argument;
|
|
27356
27416
|
const fn2 = expr.operator === "++" ? "$add" : "$sub";
|
|
27417
|
+
const undo = expr.operator === "++" ? "$sub" : "$add";
|
|
27357
27418
|
if (arg.type === "Identifier") {
|
|
27358
27419
|
if (expr.prefix) return `${arg.name} = ${fn2}(${arg.name}, $lit(1))`;
|
|
27359
|
-
return arg.name
|
|
27420
|
+
return `(${arg.name} = ${fn2}(${arg.name}, $lit(1)), ${undo}(${arg.name}, $lit(1)))`;
|
|
27360
27421
|
}
|
|
27361
27422
|
if (arg.type === "MemberExpression") {
|
|
27362
27423
|
const m = arg;
|
|
@@ -27880,7 +27941,7 @@ function runtimeImportOf(runtime) {
|
|
|
27880
27941
|
function transpileFile(file, opts = {}) {
|
|
27881
27942
|
const runtime = opts.runtimeImport ?? "@nudojs/core/exec";
|
|
27882
27943
|
const lines = [
|
|
27883
|
-
`// nudo
|
|
27944
|
+
`// nudo evaluator transpile \u2014 values are Abs; operators are overloaded calls`,
|
|
27884
27945
|
`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)};`,
|
|
27885
27946
|
``
|
|
27886
27947
|
];
|
|
@@ -28023,7 +28084,7 @@ function compiledBodyOf(impl) {
|
|
|
28023
28084
|
runner = (args) => bodyFn(...args);
|
|
28024
28085
|
compiledByImpl.set(implKey, runner);
|
|
28025
28086
|
} catch (e) {
|
|
28026
|
-
|
|
28087
|
+
noteEvalFallback(e);
|
|
28027
28088
|
return void 0;
|
|
28028
28089
|
}
|
|
28029
28090
|
return runner;
|
|
@@ -28047,11 +28108,11 @@ function getAbsCallBudgetStats() {
|
|
|
28047
28108
|
return {
|
|
28048
28109
|
calls: _absTotalCalls,
|
|
28049
28110
|
maxCalls: MAX_TOTAL_CALLS,
|
|
28050
|
-
forks:
|
|
28051
|
-
maxForks:
|
|
28111
|
+
forks: _evalForkCount,
|
|
28112
|
+
maxForks: _evalForkBudgetLimit,
|
|
28052
28113
|
callTruncated: _callTruncated,
|
|
28053
|
-
forkTruncated:
|
|
28054
|
-
truncated: _callTruncated ||
|
|
28114
|
+
forkTruncated: _evalForkTruncNoted,
|
|
28115
|
+
truncated: _callTruncated || _evalForkTruncNoted
|
|
28055
28116
|
};
|
|
28056
28117
|
}
|
|
28057
28118
|
function resetAbsCallBudget() {
|
|
@@ -28059,7 +28120,7 @@ function resetAbsCallBudget() {
|
|
|
28059
28120
|
_absTotalCalls = 0;
|
|
28060
28121
|
_activeCallKeys = [];
|
|
28061
28122
|
_callTruncated = false;
|
|
28062
|
-
|
|
28123
|
+
resetEvalForkBudget();
|
|
28063
28124
|
}
|
|
28064
28125
|
function stableCallId(obj2) {
|
|
28065
28126
|
let id = _fnCallIds.get(obj2);
|
|
@@ -28111,36 +28172,36 @@ function exitCall() {
|
|
|
28111
28172
|
function noteHostEffectBlocked(name) {
|
|
28112
28173
|
noteAbsTruncation(`${HOST_EFFECT_LABEL_PREFIX}${name}`);
|
|
28113
28174
|
}
|
|
28114
|
-
function
|
|
28175
|
+
function noteEvalForkTruncation() {
|
|
28115
28176
|
noteAbsTruncation(FORK_TRUNCATION_LABEL);
|
|
28116
28177
|
}
|
|
28117
|
-
function
|
|
28178
|
+
function setEvalForkBudgetLimit(n) {
|
|
28118
28179
|
if (typeof n === "number" && Number.isFinite(n) && n >= 1) {
|
|
28119
|
-
|
|
28180
|
+
_evalForkBudgetLimit = Math.floor(n);
|
|
28120
28181
|
} else {
|
|
28121
|
-
|
|
28182
|
+
_evalForkBudgetLimit = MAX_EVAL_TOTAL_FORKS;
|
|
28122
28183
|
}
|
|
28123
|
-
return
|
|
28184
|
+
return _evalForkBudgetLimit;
|
|
28124
28185
|
}
|
|
28125
|
-
function
|
|
28126
|
-
return
|
|
28186
|
+
function getEvalForkBudgetLimit() {
|
|
28187
|
+
return _evalForkBudgetLimit;
|
|
28127
28188
|
}
|
|
28128
|
-
function
|
|
28129
|
-
return
|
|
28189
|
+
function getEvalForkCount() {
|
|
28190
|
+
return _evalForkCount;
|
|
28130
28191
|
}
|
|
28131
|
-
function
|
|
28132
|
-
|
|
28133
|
-
|
|
28192
|
+
function resetEvalForkBudget() {
|
|
28193
|
+
_evalForkCount = 0;
|
|
28194
|
+
_evalForkTruncNoted = false;
|
|
28134
28195
|
}
|
|
28135
|
-
function
|
|
28136
|
-
if (++
|
|
28137
|
-
if (!
|
|
28138
|
-
|
|
28139
|
-
|
|
28196
|
+
function bumpEvalForkBudget() {
|
|
28197
|
+
if (++_evalForkCount <= _evalForkBudgetLimit) return true;
|
|
28198
|
+
if (!_evalForkTruncNoted) {
|
|
28199
|
+
_evalForkTruncNoted = true;
|
|
28200
|
+
noteEvalForkTruncation();
|
|
28140
28201
|
}
|
|
28141
28202
|
return false;
|
|
28142
28203
|
}
|
|
28143
|
-
var MAX_CALL_DEPTH, MAX_TOTAL_CALLS, _absCallDepth, _absTotalCalls, _activeCallKeys, _fnCallIds, _fnCallIdSeq, _callTruncated, absTruncCollector,
|
|
28204
|
+
var MAX_CALL_DEPTH, MAX_TOTAL_CALLS, _absCallDepth, _absTotalCalls, _activeCallKeys, _fnCallIds, _fnCallIdSeq, _callTruncated, absTruncCollector, MAX_EVAL_TOTAL_FORKS, _evalForkBudgetLimit, _evalForkCount, _evalForkTruncNoted, FORK_TRUNCATION_LABEL, HOST_EFFECT_LABEL_PREFIX;
|
|
28144
28205
|
var init_call_budget = __esm({
|
|
28145
28206
|
"../core/src/algebra/call-budget.ts"() {
|
|
28146
28207
|
"use strict";
|
|
@@ -28155,10 +28216,10 @@ var init_call_budget = __esm({
|
|
|
28155
28216
|
_fnCallIdSeq = 0;
|
|
28156
28217
|
_callTruncated = false;
|
|
28157
28218
|
absTruncCollector = null;
|
|
28158
|
-
|
|
28159
|
-
|
|
28160
|
-
|
|
28161
|
-
|
|
28219
|
+
MAX_EVAL_TOTAL_FORKS = 5e3;
|
|
28220
|
+
_evalForkBudgetLimit = MAX_EVAL_TOTAL_FORKS;
|
|
28221
|
+
_evalForkCount = 0;
|
|
28222
|
+
_evalForkTruncNoted = false;
|
|
28162
28223
|
FORK_TRUNCATION_LABEL = "#fork-budget";
|
|
28163
28224
|
HOST_EFFECT_LABEL_PREFIX = "#host-effect:";
|
|
28164
28225
|
}
|
|
@@ -28275,10 +28336,10 @@ var init_call = __esm({
|
|
|
28275
28336
|
});
|
|
28276
28337
|
|
|
28277
28338
|
// ../core/src/algebra/exec/class-registry.ts
|
|
28278
|
-
function
|
|
28339
|
+
function registerEvalClass(spec) {
|
|
28279
28340
|
classRegistry.set(spec.name, spec);
|
|
28280
28341
|
}
|
|
28281
|
-
function
|
|
28342
|
+
function getEvalClass(name) {
|
|
28282
28343
|
return classRegistry.get(name);
|
|
28283
28344
|
}
|
|
28284
28345
|
function clearBClasses() {
|
|
@@ -28328,9 +28389,9 @@ function findClassAccessor(startName, key) {
|
|
|
28328
28389
|
const seen = /* @__PURE__ */ new Set();
|
|
28329
28390
|
while (cur && !seen.has(cur)) {
|
|
28330
28391
|
seen.add(cur);
|
|
28331
|
-
const acc =
|
|
28392
|
+
const acc = getEvalClass(cur)?.accessors?.[key];
|
|
28332
28393
|
if (acc) return acc;
|
|
28333
|
-
cur =
|
|
28394
|
+
cur = getEvalClass(cur)?.superName;
|
|
28334
28395
|
}
|
|
28335
28396
|
return void 0;
|
|
28336
28397
|
}
|
|
@@ -28339,9 +28400,9 @@ function findStaticClassAccessor(startName, key) {
|
|
|
28339
28400
|
const seen = /* @__PURE__ */ new Set();
|
|
28340
28401
|
while (cur && !seen.has(cur)) {
|
|
28341
28402
|
seen.add(cur);
|
|
28342
|
-
const acc =
|
|
28403
|
+
const acc = getEvalClass(cur)?.staticAccessors?.[key];
|
|
28343
28404
|
if (acc) return acc;
|
|
28344
|
-
cur =
|
|
28405
|
+
cur = getEvalClass(cur)?.superName;
|
|
28345
28406
|
}
|
|
28346
28407
|
return void 0;
|
|
28347
28408
|
}
|
|
@@ -28394,8 +28455,8 @@ function $in(key, o) {
|
|
|
28394
28455
|
return boolLit(OBJECT_PROTO_NAMES.has(keyStr));
|
|
28395
28456
|
}
|
|
28396
28457
|
function brandHasProtoMember(brandName, key) {
|
|
28397
|
-
for (const name of
|
|
28398
|
-
const spec =
|
|
28458
|
+
for (const name of evalClassChain(brandName)) {
|
|
28459
|
+
const spec = getEvalClass(name);
|
|
28399
28460
|
if (spec?.methods?.[key]) return true;
|
|
28400
28461
|
if (spec?.accessors?.[key]) return true;
|
|
28401
28462
|
const builtin = BUILTIN_BRAND_METHODS[name];
|
|
@@ -28403,12 +28464,12 @@ function brandHasProtoMember(brandName, key) {
|
|
|
28403
28464
|
}
|
|
28404
28465
|
return false;
|
|
28405
28466
|
}
|
|
28406
|
-
function
|
|
28467
|
+
function evalClassChain(name) {
|
|
28407
28468
|
const out = [name];
|
|
28408
28469
|
let cur = name;
|
|
28409
28470
|
let depth = 0;
|
|
28410
28471
|
while (cur && depth++ < 32) {
|
|
28411
|
-
const spec =
|
|
28472
|
+
const spec = getEvalClass(cur);
|
|
28412
28473
|
const parent = spec?.superName ?? BUILTIN_ERROR_SUPER2[cur];
|
|
28413
28474
|
if (!parent || out.includes(parent)) break;
|
|
28414
28475
|
out.push(parent);
|
|
@@ -28439,7 +28500,7 @@ function $instanceof(left, rightName, rightVal) {
|
|
|
28439
28500
|
return boolLit(rightName === "Function" || rightName === "Object");
|
|
28440
28501
|
}
|
|
28441
28502
|
return boolLit(
|
|
28442
|
-
rightName === "Object" ||
|
|
28503
|
+
rightName === "Object" || evalClassChain(left.shape.name).includes(rightName)
|
|
28443
28504
|
);
|
|
28444
28505
|
case "arr":
|
|
28445
28506
|
case "tuple":
|
|
@@ -29070,7 +29131,7 @@ function $idxSet(a, i, value) {
|
|
|
29070
29131
|
}
|
|
29071
29132
|
if (sk === "brand") {
|
|
29072
29133
|
if (iv === void 0) return a;
|
|
29073
|
-
if (
|
|
29134
|
+
if (getEvalClass(a.shape.name)) return $set(a, String(iv), value);
|
|
29074
29135
|
return a;
|
|
29075
29136
|
}
|
|
29076
29137
|
if (sk === "tuple") {
|
|
@@ -29428,8 +29489,8 @@ function $get(o, key, opts) {
|
|
|
29428
29489
|
const sacc = findStaticClassAccessor(o.shape.name, key);
|
|
29429
29490
|
if (sacc) return sacc.get ? sacc.get(o) : undef();
|
|
29430
29491
|
if (findClassAccessor(o.shape.name, key)) return undef();
|
|
29431
|
-
for (const n of
|
|
29432
|
-
const spec =
|
|
29492
|
+
for (const n of evalClassChain(o.shape.name)) {
|
|
29493
|
+
const spec = getEvalClass(n);
|
|
29433
29494
|
if (spec?.staticMethods?.[key]) {
|
|
29434
29495
|
return absFunction(spec.staticMethodParams?.[key] ?? [], { body: noBody2 });
|
|
29435
29496
|
}
|
|
@@ -29444,8 +29505,8 @@ function $get(o, key, opts) {
|
|
|
29444
29505
|
const acc = findClassAccessor(o.shape.name, key);
|
|
29445
29506
|
if (acc) return acc.get ? acc.get(o) : undef();
|
|
29446
29507
|
if (findStaticClassAccessor(o.shape.name, key)) return undef();
|
|
29447
|
-
for (const n of
|
|
29448
|
-
const spec =
|
|
29508
|
+
for (const n of evalClassChain(o.shape.name)) {
|
|
29509
|
+
const spec = getEvalClass(n);
|
|
29449
29510
|
if (spec?.methods?.[key]) {
|
|
29450
29511
|
return absFunction(spec.methodParams?.[key] ?? [], { body: noBody2 });
|
|
29451
29512
|
}
|
|
@@ -29471,7 +29532,7 @@ function $get(o, key, opts) {
|
|
|
29471
29532
|
return arrayMethodAbs(key === "join" ? "join" : key);
|
|
29472
29533
|
}
|
|
29473
29534
|
if (o.shape.k !== "prim" && (ARRAY_PROTO_METHOD_NAMES.has(key) || key === "@@iterator")) {
|
|
29474
|
-
return
|
|
29535
|
+
return { shape: { k: "fn", params: [] }, conf: "path" };
|
|
29475
29536
|
}
|
|
29476
29537
|
return objectProtoMethodAbs(key);
|
|
29477
29538
|
}
|
|
@@ -29793,8 +29854,8 @@ function runForkArm(arm, exits) {
|
|
|
29793
29854
|
}
|
|
29794
29855
|
function settleForkArms(a, b, exits) {
|
|
29795
29856
|
const aThrow = a.kind === "throw";
|
|
29796
|
-
const
|
|
29797
|
-
if (aThrow &&
|
|
29857
|
+
const evalThrow = b.kind === "throw";
|
|
29858
|
+
if (aThrow && evalThrow) {
|
|
29798
29859
|
throw new NudoThrow(joinAbs(a.v, b.v));
|
|
29799
29860
|
}
|
|
29800
29861
|
const first = aThrow ? b : a;
|
|
@@ -29802,7 +29863,7 @@ function settleForkArms(a, b, exits) {
|
|
|
29802
29863
|
if (first.kind === "ret" && second.kind === "ret") {
|
|
29803
29864
|
throw new NudoReturn(joinAbs(first.v, second.v));
|
|
29804
29865
|
}
|
|
29805
|
-
if (aThrow !==
|
|
29866
|
+
if (aThrow !== evalThrow) {
|
|
29806
29867
|
if (first.kind === "ret") {
|
|
29807
29868
|
if (!exits) throw new NudoReturn(first.v);
|
|
29808
29869
|
return undef();
|
|
@@ -29841,7 +29902,7 @@ function boundedPhi(p, q) {
|
|
|
29841
29902
|
function $fork(test, consequent, alternate) {
|
|
29842
29903
|
notePromiseExecutorFork();
|
|
29843
29904
|
const testAbs = asAbsVal(test);
|
|
29844
|
-
if (!
|
|
29905
|
+
if (!bumpEvalForkBudget()) return unknown;
|
|
29845
29906
|
const truth = litTruth(testAbs);
|
|
29846
29907
|
const p = currentExecPhi();
|
|
29847
29908
|
const tCons = testAbs.pred;
|
|
@@ -30390,26 +30451,26 @@ __export(calls_exports, {
|
|
|
30390
30451
|
$assignRecord: () => $assignRecord,
|
|
30391
30452
|
$callNamed: () => $callNamed,
|
|
30392
30453
|
$recordBinding: () => $recordBinding,
|
|
30393
|
-
|
|
30394
|
-
|
|
30454
|
+
MAX_EVAL_CALL_DEPTH: () => MAX_EVAL_CALL_DEPTH,
|
|
30455
|
+
MAX_EVAL_TOTAL_CALLS: () => MAX_EVAL_TOTAL_CALLS,
|
|
30395
30456
|
blockHostSideEffect: () => blockHostSideEffect,
|
|
30396
|
-
|
|
30457
|
+
getEvalCallCollector: () => getEvalCallCollector,
|
|
30397
30458
|
neverExecHostName: () => neverExecHostName,
|
|
30398
|
-
|
|
30399
|
-
|
|
30400
|
-
|
|
30401
|
-
|
|
30402
|
-
|
|
30459
|
+
noteEvalCallRecord: () => noteEvalCallRecord,
|
|
30460
|
+
resetEvalCallBudget: () => resetEvalCallBudget,
|
|
30461
|
+
setEvalAssignCollector: () => setEvalAssignCollector,
|
|
30462
|
+
setEvalBindingSink: () => setEvalBindingSink,
|
|
30463
|
+
setEvalCallCollector: () => setEvalCallCollector
|
|
30403
30464
|
});
|
|
30404
|
-
function
|
|
30405
|
-
const prev =
|
|
30406
|
-
|
|
30465
|
+
function setEvalAssignCollector(collector2) {
|
|
30466
|
+
const prev = evalAssignCollector;
|
|
30467
|
+
evalAssignCollector = collector2;
|
|
30407
30468
|
return prev;
|
|
30408
30469
|
}
|
|
30409
30470
|
function $assignRecord(name, prev, next, line, column, conditional) {
|
|
30410
|
-
if (!
|
|
30471
|
+
if (!evalAssignCollector) return;
|
|
30411
30472
|
try {
|
|
30412
|
-
|
|
30473
|
+
evalAssignCollector({
|
|
30413
30474
|
name,
|
|
30414
30475
|
prev,
|
|
30415
30476
|
next,
|
|
@@ -30420,7 +30481,7 @@ function $assignRecord(name, prev, next, line, column, conditional) {
|
|
|
30420
30481
|
} catch {
|
|
30421
30482
|
}
|
|
30422
30483
|
}
|
|
30423
|
-
function
|
|
30484
|
+
function setEvalBindingSink(sink) {
|
|
30424
30485
|
bindingSink = sink;
|
|
30425
30486
|
}
|
|
30426
30487
|
function $recordBinding(name, value) {
|
|
@@ -30440,56 +30501,56 @@ function blockHostSideEffect(fn2) {
|
|
|
30440
30501
|
noteHostEffectBlocked(hostName);
|
|
30441
30502
|
return abs({ k: "unknown" }, void 0, void 0, "opaque");
|
|
30442
30503
|
}
|
|
30443
|
-
function
|
|
30444
|
-
if (!
|
|
30504
|
+
function noteEvalCallRecord(r) {
|
|
30505
|
+
if (!evalCallCollector) return;
|
|
30445
30506
|
try {
|
|
30446
|
-
|
|
30507
|
+
evalCallCollector(r);
|
|
30447
30508
|
} catch {
|
|
30448
30509
|
}
|
|
30449
30510
|
}
|
|
30450
|
-
function
|
|
30451
|
-
const prev =
|
|
30452
|
-
|
|
30511
|
+
function setEvalCallCollector(collector2) {
|
|
30512
|
+
const prev = evalCallCollector;
|
|
30513
|
+
evalCallCollector = collector2;
|
|
30453
30514
|
return prev;
|
|
30454
30515
|
}
|
|
30455
|
-
function
|
|
30456
|
-
return
|
|
30516
|
+
function getEvalCallCollector() {
|
|
30517
|
+
return evalCallCollector;
|
|
30457
30518
|
}
|
|
30458
|
-
function
|
|
30459
|
-
let id =
|
|
30519
|
+
function evalStableId(obj2) {
|
|
30520
|
+
let id = evalFnCallIds.get(obj2);
|
|
30460
30521
|
if (id === void 0) {
|
|
30461
|
-
id = `#${++
|
|
30462
|
-
|
|
30522
|
+
id = `#${++evalFnCallIdSeq}`;
|
|
30523
|
+
evalFnCallIds.set(obj2, id);
|
|
30463
30524
|
}
|
|
30464
30525
|
return id;
|
|
30465
30526
|
}
|
|
30466
|
-
function
|
|
30467
|
-
|
|
30468
|
-
|
|
30469
|
-
|
|
30470
|
-
|
|
30527
|
+
function resetEvalCallBudget() {
|
|
30528
|
+
evalCallDepth = 0;
|
|
30529
|
+
evalTotalCalls = 0;
|
|
30530
|
+
evalActiveCallKeys = [];
|
|
30531
|
+
resetEvalForkBudget();
|
|
30471
30532
|
}
|
|
30472
|
-
function
|
|
30533
|
+
function evalTruncatedAbs() {
|
|
30473
30534
|
return abs({ k: "unknown" }, void 0, void 0, "opaque");
|
|
30474
30535
|
}
|
|
30475
|
-
function
|
|
30476
|
-
const id = fn2 && typeof fn2 === "object" ?
|
|
30536
|
+
function evalCallBudgetKey(name, fn2, args) {
|
|
30537
|
+
const id = fn2 && typeof fn2 === "object" ? evalStableId(fn2) : "prim";
|
|
30477
30538
|
return callBudgetKey(name, id, args);
|
|
30478
30539
|
}
|
|
30479
|
-
function
|
|
30480
|
-
const key =
|
|
30481
|
-
if (
|
|
30540
|
+
function evalEnterCall(name, fn2, args) {
|
|
30541
|
+
const key = evalCallBudgetKey(name, fn2, args);
|
|
30542
|
+
if (evalActiveCallKeys.includes(key) || evalCallDepth >= MAX_EVAL_CALL_DEPTH || evalTotalCalls >= MAX_EVAL_TOTAL_CALLS) {
|
|
30482
30543
|
noteAbsTruncation(name);
|
|
30483
30544
|
return { ok: false };
|
|
30484
30545
|
}
|
|
30485
|
-
|
|
30486
|
-
|
|
30487
|
-
|
|
30546
|
+
evalActiveCallKeys.push(key);
|
|
30547
|
+
evalCallDepth++;
|
|
30548
|
+
evalTotalCalls++;
|
|
30488
30549
|
return { ok: true, key };
|
|
30489
30550
|
}
|
|
30490
|
-
function
|
|
30491
|
-
|
|
30492
|
-
|
|
30551
|
+
function evalExitCall() {
|
|
30552
|
+
evalCallDepth--;
|
|
30553
|
+
evalActiveCallKeys.pop();
|
|
30493
30554
|
}
|
|
30494
30555
|
function $callNamed(name, fn2, args, loc, argLocs) {
|
|
30495
30556
|
const pureName = pureFnNameOf(fn2);
|
|
@@ -30520,26 +30581,26 @@ function $callNamed(name, fn2, args, loc, argLocs) {
|
|
|
30520
30581
|
} else if (blockedHost !== null) {
|
|
30521
30582
|
result = blockedHost;
|
|
30522
30583
|
} else {
|
|
30523
|
-
const entered =
|
|
30584
|
+
const entered = evalEnterCall(name, fn2, args);
|
|
30524
30585
|
if (!entered.ok) {
|
|
30525
|
-
result =
|
|
30586
|
+
result = evalTruncatedAbs();
|
|
30526
30587
|
} else {
|
|
30527
30588
|
try {
|
|
30528
30589
|
result = callAtFunctionBoundary(() => fn2(...args));
|
|
30529
30590
|
} finally {
|
|
30530
|
-
|
|
30591
|
+
evalExitCall();
|
|
30531
30592
|
}
|
|
30532
30593
|
}
|
|
30533
30594
|
}
|
|
30534
30595
|
} else if (fn2 && typeof fn2 === "object" && "shape" in fn2) {
|
|
30535
|
-
const entered =
|
|
30596
|
+
const entered = evalEnterCall(name, fn2, args);
|
|
30536
30597
|
if (!entered.ok) {
|
|
30537
|
-
result =
|
|
30598
|
+
result = evalTruncatedAbs();
|
|
30538
30599
|
} else {
|
|
30539
30600
|
try {
|
|
30540
30601
|
result = $call(fn2, args);
|
|
30541
30602
|
} finally {
|
|
30542
|
-
|
|
30603
|
+
evalExitCall();
|
|
30543
30604
|
}
|
|
30544
30605
|
}
|
|
30545
30606
|
}
|
|
@@ -30556,9 +30617,9 @@ function $callNamed(name, fn2, args, loc, argLocs) {
|
|
|
30556
30617
|
}
|
|
30557
30618
|
m.set(pk, result);
|
|
30558
30619
|
}
|
|
30559
|
-
if (
|
|
30620
|
+
if (evalCallCollector) {
|
|
30560
30621
|
try {
|
|
30561
|
-
|
|
30622
|
+
evalCallCollector({
|
|
30562
30623
|
fnName: name,
|
|
30563
30624
|
args: argsSnapshot,
|
|
30564
30625
|
result: threw ? unknown : result,
|
|
@@ -30571,7 +30632,7 @@ function $callNamed(name, fn2, args, loc, argLocs) {
|
|
|
30571
30632
|
}
|
|
30572
30633
|
return result;
|
|
30573
30634
|
}
|
|
30574
|
-
var pureCallMemo,
|
|
30635
|
+
var pureCallMemo, evalCallCollector, evalAssignCollector, bindingSink, GLOBAL_FNS, NEVER_EXEC_HOST_FN_NAMES, MAX_EVAL_CALL_DEPTH, MAX_EVAL_TOTAL_CALLS, evalCallDepth, evalTotalCalls, evalActiveCallKeys, evalFnCallIds, evalFnCallIdSeq;
|
|
30575
30636
|
var init_calls = __esm({
|
|
30576
30637
|
"../core/src/algebra/exec/calls.ts"() {
|
|
30577
30638
|
"use strict";
|
|
@@ -30583,8 +30644,8 @@ var init_calls = __esm({
|
|
|
30583
30644
|
init_call_budget();
|
|
30584
30645
|
init_member_diag();
|
|
30585
30646
|
pureCallMemo = /* @__PURE__ */ new WeakMap();
|
|
30586
|
-
|
|
30587
|
-
|
|
30647
|
+
evalCallCollector = null;
|
|
30648
|
+
evalAssignCollector = null;
|
|
30588
30649
|
bindingSink = null;
|
|
30589
30650
|
GLOBAL_FNS = /* @__PURE__ */ new Set([
|
|
30590
30651
|
"parseInt",
|
|
@@ -30611,13 +30672,13 @@ var init_calls = __esm({
|
|
|
30611
30672
|
"requestAnimationFrame",
|
|
30612
30673
|
"requestIdleCallback"
|
|
30613
30674
|
];
|
|
30614
|
-
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30675
|
+
MAX_EVAL_CALL_DEPTH = 64;
|
|
30676
|
+
MAX_EVAL_TOTAL_CALLS = 2e4;
|
|
30677
|
+
evalCallDepth = 0;
|
|
30678
|
+
evalTotalCalls = 0;
|
|
30679
|
+
evalActiveCallKeys = [];
|
|
30680
|
+
evalFnCallIds = /* @__PURE__ */ new WeakMap();
|
|
30681
|
+
evalFnCallIdSeq = 0;
|
|
30621
30682
|
}
|
|
30622
30683
|
});
|
|
30623
30684
|
|
|
@@ -30788,10 +30849,10 @@ __export(class_exports, {
|
|
|
30788
30849
|
$thisSet: () => $thisSet,
|
|
30789
30850
|
clearBClasses: () => clearBClasses,
|
|
30790
30851
|
execRegexBrand: () => execRegexBrand,
|
|
30791
|
-
|
|
30852
|
+
getEvalClass: () => getEvalClass,
|
|
30792
30853
|
regexExecWithState: () => regexExecWithState,
|
|
30793
30854
|
regexParts: () => regexParts,
|
|
30794
|
-
|
|
30855
|
+
registerEvalClass: () => registerEvalClass,
|
|
30795
30856
|
stringRegexMethod: () => stringRegexMethod
|
|
30796
30857
|
});
|
|
30797
30858
|
function $class(name, spec) {
|
|
@@ -30816,7 +30877,7 @@ function $class(name, spec) {
|
|
|
30816
30877
|
accessors: spec.accessors,
|
|
30817
30878
|
staticAccessors: spec.staticAccessors
|
|
30818
30879
|
};
|
|
30819
|
-
|
|
30880
|
+
registerEvalClass(full);
|
|
30820
30881
|
const slots = {};
|
|
30821
30882
|
if (spec.statics) {
|
|
30822
30883
|
for (const [k, v2] of Object.entries(spec.statics)) slots[k] = { value: asAbsVal(v2) };
|
|
@@ -30834,7 +30895,7 @@ function $class(name, spec) {
|
|
|
30834
30895
|
}
|
|
30835
30896
|
function specOf(cls) {
|
|
30836
30897
|
if (classImpl.has(cls)) return classImpl.get(cls);
|
|
30837
|
-
if (cls.shape.k === "brand") return
|
|
30898
|
+
if (cls.shape.k === "brand") return getEvalClass(cls.shape.name);
|
|
30838
30899
|
return void 0;
|
|
30839
30900
|
}
|
|
30840
30901
|
function findMethod(startName, method) {
|
|
@@ -30842,7 +30903,7 @@ function findMethod(startName, method) {
|
|
|
30842
30903
|
const seen = /* @__PURE__ */ new Set();
|
|
30843
30904
|
while (cur && !seen.has(cur)) {
|
|
30844
30905
|
seen.add(cur);
|
|
30845
|
-
const spec =
|
|
30906
|
+
const spec = getEvalClass(cur);
|
|
30846
30907
|
if (spec?.methods?.[method]) return spec.methods[method];
|
|
30847
30908
|
cur = spec?.superName;
|
|
30848
30909
|
}
|
|
@@ -30853,7 +30914,7 @@ function findCtor(startName) {
|
|
|
30853
30914
|
const seen = /* @__PURE__ */ new Set();
|
|
30854
30915
|
while (cur && !seen.has(cur)) {
|
|
30855
30916
|
seen.add(cur);
|
|
30856
|
-
const spec =
|
|
30917
|
+
const spec = getEvalClass(cur);
|
|
30857
30918
|
if (spec?.ctor) return { ctor: spec.ctor, className: cur };
|
|
30858
30919
|
cur = spec?.superName;
|
|
30859
30920
|
}
|
|
@@ -30948,7 +31009,7 @@ function $new(cls, args) {
|
|
|
30948
31009
|
return thisVal;
|
|
30949
31010
|
}
|
|
30950
31011
|
function $super(thisVal, childName, args) {
|
|
30951
|
-
const child =
|
|
31012
|
+
const child = getEvalClass(childName);
|
|
30952
31013
|
const parentName = child?.superName;
|
|
30953
31014
|
if (!parentName) return thisVal;
|
|
30954
31015
|
const found = findCtor(parentName);
|
|
@@ -31185,7 +31246,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
31185
31246
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
31186
31247
|
throw e;
|
|
31187
31248
|
} finally {
|
|
31188
|
-
|
|
31249
|
+
noteEvalCallRecord({
|
|
31189
31250
|
fnName: `${brandName}.${method}`,
|
|
31190
31251
|
args,
|
|
31191
31252
|
result,
|
|
@@ -31194,7 +31255,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
31194
31255
|
});
|
|
31195
31256
|
}
|
|
31196
31257
|
}
|
|
31197
|
-
const spec =
|
|
31258
|
+
const spec = getEvalClass(brandName);
|
|
31198
31259
|
const sm = spec?.staticMethods?.[method];
|
|
31199
31260
|
if (sm) {
|
|
31200
31261
|
let result = unknown;
|
|
@@ -31207,7 +31268,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
31207
31268
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
31208
31269
|
throw e;
|
|
31209
31270
|
} finally {
|
|
31210
|
-
|
|
31271
|
+
noteEvalCallRecord({
|
|
31211
31272
|
fnName: `${brandName}.${method}`,
|
|
31212
31273
|
args,
|
|
31213
31274
|
result,
|
|
@@ -31312,7 +31373,7 @@ function $invoke(thisVal, method, args, loc) {
|
|
|
31312
31373
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
31313
31374
|
throw e;
|
|
31314
31375
|
} finally {
|
|
31315
|
-
|
|
31376
|
+
noteEvalCallRecord({
|
|
31316
31377
|
fnName: recordName,
|
|
31317
31378
|
args,
|
|
31318
31379
|
result,
|
|
@@ -31640,8 +31701,7 @@ function invokeArrMethod(arr, method, args) {
|
|
|
31640
31701
|
if (shape2.k === "arr") return joinAbs(shape2.element, undefAbs());
|
|
31641
31702
|
}
|
|
31642
31703
|
if (method === "at") {
|
|
31643
|
-
const
|
|
31644
|
-
const iv = typeof raw === "number" && Number.isInteger(raw) ? raw : void 0;
|
|
31704
|
+
const iv = toIntegerOrInfinityLit(args[0]);
|
|
31645
31705
|
if (shape2.k === "tuple") {
|
|
31646
31706
|
const els = shape2.elements;
|
|
31647
31707
|
if (iv === void 0) {
|
|
@@ -31657,7 +31717,7 @@ function invokeArrMethod(arr, method, args) {
|
|
|
31657
31717
|
return void 0;
|
|
31658
31718
|
}
|
|
31659
31719
|
function $invokeSuper(thisVal, childName, method, args) {
|
|
31660
|
-
const child =
|
|
31720
|
+
const child = getEvalClass(childName);
|
|
31661
31721
|
const parentName = child?.superName;
|
|
31662
31722
|
if (!parentName) return unknown;
|
|
31663
31723
|
const m = findMethod(parentName, method);
|
|
@@ -31763,7 +31823,7 @@ function $staticInvoke(cls, method, args) {
|
|
|
31763
31823
|
result = e && typeof e === "object" && "absValue" in e ? e.absValue : unknown;
|
|
31764
31824
|
throw e;
|
|
31765
31825
|
} finally {
|
|
31766
|
-
|
|
31826
|
+
noteEvalCallRecord({ fnName: recordName, args, result, threw });
|
|
31767
31827
|
}
|
|
31768
31828
|
}
|
|
31769
31829
|
function $setKey(o, key, value) {
|
|
@@ -32079,7 +32139,7 @@ function bindingsOf(run) {
|
|
|
32079
32139
|
return runBindings.get(run);
|
|
32080
32140
|
}
|
|
32081
32141
|
function runTranspiled(source, opts = {}) {
|
|
32082
|
-
|
|
32142
|
+
resetEvalCallBudget();
|
|
32083
32143
|
const modules = opts.modules ?? {};
|
|
32084
32144
|
let js = transpile(source, {
|
|
32085
32145
|
runtimeImport: "@nudojs/core/exec",
|
|
@@ -32172,17 +32232,17 @@ ${js}`;
|
|
|
32172
32232
|
const ret = `return { ...__nudoExports, ...${cjsMerge}, ${names2.join(", ")} };`;
|
|
32173
32233
|
const fn2 = new Function(...argNames, `${js}
|
|
32174
32234
|
${ret}`);
|
|
32175
|
-
|
|
32235
|
+
setEvalBindingSink(bindings);
|
|
32176
32236
|
try {
|
|
32177
32237
|
const result = fn2(...args);
|
|
32178
32238
|
runBindings.set(result, bindings);
|
|
32179
32239
|
return result;
|
|
32180
32240
|
} finally {
|
|
32181
|
-
|
|
32241
|
+
setEvalBindingSink(null);
|
|
32182
32242
|
}
|
|
32183
32243
|
}
|
|
32184
|
-
function
|
|
32185
|
-
|
|
32244
|
+
function setEvalFallbackCollector(collector2) {
|
|
32245
|
+
evalFallbackCollector = collector2;
|
|
32186
32246
|
}
|
|
32187
32247
|
function evalExprAbs(expr, bindings = {}) {
|
|
32188
32248
|
const src = transpileExpression(expr, {});
|
|
@@ -32195,15 +32255,15 @@ function evalExprAbs(expr, bindings = {}) {
|
|
|
32195
32255
|
const factory = new Function(...names2, cleaned);
|
|
32196
32256
|
return factory(...Object.values(rtAllBindings()), ...Object.values(bindings));
|
|
32197
32257
|
}
|
|
32198
|
-
function
|
|
32199
|
-
if (!
|
|
32258
|
+
function noteEvalFallback(e) {
|
|
32259
|
+
if (!evalFallbackCollector) return;
|
|
32200
32260
|
const f = e instanceof NudoUnsupportedError ? { reason: `unsupported:${e.reason}`, message: e.message, ...e.loc ? { loc: e.loc } : {} } : isNudoThrow(e) ? (
|
|
32201
32261
|
// NudoThrow:程序自身的抛(如顶层 this 写 / strict 写 TypeError)——
|
|
32202
32262
|
// 模块装载失败,不是 B 能力边界也不是 B 缺陷(catch 可吸收)
|
|
32203
32263
|
{ reason: "module-throw", message: e instanceof Error ? e.message : String(e) }
|
|
32204
32264
|
) : { reason: "internal", message: e instanceof Error ? e.message : String(e) };
|
|
32205
32265
|
try {
|
|
32206
|
-
|
|
32266
|
+
evalFallbackCollector(f);
|
|
32207
32267
|
} catch {
|
|
32208
32268
|
}
|
|
32209
32269
|
}
|
|
@@ -32211,7 +32271,7 @@ function tryRunTranspiled(source, opts = {}) {
|
|
|
32211
32271
|
try {
|
|
32212
32272
|
return runTranspiled(source, opts);
|
|
32213
32273
|
} catch (e) {
|
|
32214
|
-
|
|
32274
|
+
noteEvalFallback(e);
|
|
32215
32275
|
return void 0;
|
|
32216
32276
|
}
|
|
32217
32277
|
}
|
|
@@ -32221,7 +32281,7 @@ function isAbsVal(v2) {
|
|
|
32221
32281
|
function callTranspiledExportFull(exports, name, args, opts) {
|
|
32222
32282
|
const fn2 = exports[name];
|
|
32223
32283
|
if (typeof fn2 === "function") {
|
|
32224
|
-
|
|
32284
|
+
resetEvalCallBudget();
|
|
32225
32285
|
const callArgs = args.map(
|
|
32226
32286
|
(a) => a && typeof a === "object" && "shape" in a ? $copy(a) : a
|
|
32227
32287
|
);
|
|
@@ -32290,7 +32350,7 @@ function joinControlExits(normal) {
|
|
|
32290
32350
|
function callTranspiledExport(exports, name, args) {
|
|
32291
32351
|
return callTranspiledExportFull(exports, name, args).result;
|
|
32292
32352
|
}
|
|
32293
|
-
var RUNTIME_IMPORT_RE2, runBindings,
|
|
32353
|
+
var RUNTIME_IMPORT_RE2, runBindings, evalFallbackCollector;
|
|
32294
32354
|
var init_run = __esm({
|
|
32295
32355
|
"../core/src/algebra/exec/run.ts"() {
|
|
32296
32356
|
"use strict";
|
|
@@ -32310,7 +32370,7 @@ var init_run = __esm({
|
|
|
32310
32370
|
init_call();
|
|
32311
32371
|
RUNTIME_IMPORT_RE2 = /^import\s*\{[^}]+\}\s*from\s*"[^"]+";\s*$/m;
|
|
32312
32372
|
runBindings = /* @__PURE__ */ new WeakMap();
|
|
32313
|
-
|
|
32373
|
+
evalFallbackCollector = null;
|
|
32314
32374
|
}
|
|
32315
32375
|
});
|
|
32316
32376
|
|
|
@@ -32589,13 +32649,13 @@ var init_generalize_key = __esm({
|
|
|
32589
32649
|
});
|
|
32590
32650
|
|
|
32591
32651
|
// ../core/src/algebra/generalize.ts
|
|
32592
|
-
function
|
|
32652
|
+
function evalRunOf(source, modules, inject) {
|
|
32593
32653
|
const mKey = `${source}|${runTranspiledOptionsMemoKey({ ...inject ?? {}, ...modules ? { modules } : {} })}`;
|
|
32594
|
-
if (
|
|
32595
|
-
const oldest =
|
|
32596
|
-
if (oldest !== void 0)
|
|
32654
|
+
if (evalRunMemo.size >= 256) {
|
|
32655
|
+
const oldest = evalRunMemo.keys().next().value;
|
|
32656
|
+
if (oldest !== void 0) evalRunMemo.delete(oldest);
|
|
32597
32657
|
}
|
|
32598
|
-
let run =
|
|
32658
|
+
let run = evalRunMemo.get(mKey);
|
|
32599
32659
|
if (run === void 0) {
|
|
32600
32660
|
const merged = modules ?? inject?.modules;
|
|
32601
32661
|
const r = tryRunTranspiled(source, {
|
|
@@ -32605,7 +32665,7 @@ function bPathRunOf(source, modules, inject) {
|
|
|
32605
32665
|
});
|
|
32606
32666
|
if (r === void 0) return void 0;
|
|
32607
32667
|
run = r;
|
|
32608
|
-
|
|
32668
|
+
evalRunMemo.set(mKey, run);
|
|
32609
32669
|
}
|
|
32610
32670
|
return run;
|
|
32611
32671
|
}
|
|
@@ -32995,7 +33055,7 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
32995
33055
|
);
|
|
32996
33056
|
const envGated = envGatedSource && freeIdentifiers(body, boundNames).size > 0;
|
|
32997
33057
|
const replaceGated = /@nudo:replace\b/.test(source) && !hasReps;
|
|
32998
|
-
const
|
|
33058
|
+
const evalEligible = !unresolvableImports && !mockGated && !envGated && !replaceGated;
|
|
32999
33059
|
const run = (args, phi2 = pTrue) => {
|
|
33000
33060
|
const { key, varOrder } = instantiateMemoKey(args, phi2);
|
|
33001
33061
|
const hit = instMemo.get(key);
|
|
@@ -33003,27 +33063,27 @@ function generalizeFromAstUncached(fnName, source, opts = {}) {
|
|
|
33003
33063
|
return alphaRenameResult(hit.result, hit.varOrder, varOrder);
|
|
33004
33064
|
}
|
|
33005
33065
|
let result;
|
|
33006
|
-
if (
|
|
33066
|
+
if (evalEligible) {
|
|
33007
33067
|
try {
|
|
33008
|
-
const
|
|
33009
|
-
if (!
|
|
33068
|
+
const evalRun = evalRunOf(source, opts.modules, opts.inject);
|
|
33069
|
+
if (!evalRun) {
|
|
33010
33070
|
} else if (fnName.includes(".")) {
|
|
33011
33071
|
const [clsName, methodName] = fnName.split(".", 2);
|
|
33012
|
-
const clsAbs =
|
|
33072
|
+
const clsAbs = evalRun[clsName ?? ""];
|
|
33013
33073
|
if (clsAbs && typeof clsAbs === "object" && "shape" in clsAbs) {
|
|
33014
33074
|
const nCtor = ctorParamCountOf(fileAst, clsName ?? "");
|
|
33015
33075
|
const inst = $new(clsAbs, Array.from({ length: nCtor }, () => abs({ k: "any" }, void 0, pTrue, "path")));
|
|
33016
33076
|
result = withExecPhi(phi2, () => $invoke(inst, methodName ?? "", args));
|
|
33017
33077
|
}
|
|
33018
|
-
} else if (fnName in
|
|
33019
|
-
const
|
|
33078
|
+
} else if (fnName in evalRun) {
|
|
33079
|
+
const evalArgs = args.map((a, i) => {
|
|
33020
33080
|
const shape2 = promoteScan.promotedShapes.get(params[i]);
|
|
33021
33081
|
if (shape2 && (a.shape.k === "any" || a.shape.k === "unknown")) {
|
|
33022
33082
|
return { shape: shape2, term: a.term, pred: a.pred, conf: "path" };
|
|
33023
33083
|
}
|
|
33024
33084
|
return a;
|
|
33025
33085
|
});
|
|
33026
|
-
result = callTranspiledExportFull(
|
|
33086
|
+
result = callTranspiledExportFull(evalRun, fnName, evalArgs, { phi: phi2 }).result;
|
|
33027
33087
|
}
|
|
33028
33088
|
} catch {
|
|
33029
33089
|
}
|
|
@@ -33187,7 +33247,7 @@ function buildArgsFromAssume(source, fnName, assumeIds) {
|
|
|
33187
33247
|
return abs({ k: "any" }, void 0, void 0, "path");
|
|
33188
33248
|
});
|
|
33189
33249
|
}
|
|
33190
|
-
var
|
|
33250
|
+
var evalRunMemo, generalizeMemo, memoKeyDeps, memoDepIndex, loadModuleIds, nextLoadModuleId, MAX_GENERALIZE_MEMO, moduleMapIds, moduleMapIdSeq;
|
|
33191
33251
|
var init_generalize = __esm({
|
|
33192
33252
|
"../core/src/algebra/generalize.ts"() {
|
|
33193
33253
|
"use strict";
|
|
@@ -33212,7 +33272,7 @@ var init_generalize = __esm({
|
|
|
33212
33272
|
init_class();
|
|
33213
33273
|
init_generalize_key();
|
|
33214
33274
|
init_generalize_key();
|
|
33215
|
-
|
|
33275
|
+
evalRunMemo = /* @__PURE__ */ new Map();
|
|
33216
33276
|
generalizeMemo = /* @__PURE__ */ new Map();
|
|
33217
33277
|
memoKeyDeps = /* @__PURE__ */ new Map();
|
|
33218
33278
|
memoDepIndex = /* @__PURE__ */ new Map();
|
|
@@ -34130,17 +34190,17 @@ function scanLiteralCalls(source, knownFns, phi2, opts) {
|
|
|
34130
34190
|
const resolve25 = collectCallResolvers(source, knownFns, opts);
|
|
34131
34191
|
const forwards = collectForwarders(source, knownSet, resolve25, file);
|
|
34132
34192
|
const varAbs = opts?.varAbs ?? /* @__PURE__ */ new Map();
|
|
34133
|
-
const
|
|
34193
|
+
const evalCallIndex = /* @__PURE__ */ new Map();
|
|
34134
34194
|
for (const r of opts?.bCalls ?? []) {
|
|
34135
34195
|
if (!r.callLoc) continue;
|
|
34136
34196
|
const key = `${r.fnName}\0${r.callLoc.line}`;
|
|
34137
|
-
const list =
|
|
34197
|
+
const list = evalCallIndex.get(key) ?? [];
|
|
34138
34198
|
list.push(r.args);
|
|
34139
|
-
|
|
34199
|
+
evalCallIndex.set(key, list);
|
|
34140
34200
|
}
|
|
34141
34201
|
const takeBCallArgs = (fnName, line) => {
|
|
34142
34202
|
if (line === void 0) return void 0;
|
|
34143
|
-
const list =
|
|
34203
|
+
const list = evalCallIndex.get(`${fnName}\0${line}`);
|
|
34144
34204
|
if (!list || list.length === 0) return void 0;
|
|
34145
34205
|
return list.shift();
|
|
34146
34206
|
};
|
|
@@ -34733,10 +34793,10 @@ function scanLiteralCalls(source, knownFns, phi2, opts) {
|
|
|
34733
34793
|
let absArgs = parsed.absArgs;
|
|
34734
34794
|
let hasInfo = parsed.hasInfo;
|
|
34735
34795
|
if (!hasInfo) {
|
|
34736
|
-
const
|
|
34737
|
-
if (
|
|
34738
|
-
absArgs =
|
|
34739
|
-
hasInfo =
|
|
34796
|
+
const evalArgs = takeBCallArgs(fnName, loc?.start.line);
|
|
34797
|
+
if (evalArgs && evalArgs.length > 0) {
|
|
34798
|
+
absArgs = evalArgs;
|
|
34799
|
+
hasInfo = evalArgs.some(isInformativeArg);
|
|
34740
34800
|
}
|
|
34741
34801
|
}
|
|
34742
34802
|
if (!hasInfo || absArgs.length === 0) return;
|
|
@@ -34799,10 +34859,10 @@ function scanLiteralCalls(source, knownFns, phi2, opts) {
|
|
|
34799
34859
|
let absArgs = parsedExt.absArgs;
|
|
34800
34860
|
let hasInfo = parsedExt.hasInfo;
|
|
34801
34861
|
if (!hasInfo) {
|
|
34802
|
-
const
|
|
34803
|
-
if (
|
|
34804
|
-
absArgs =
|
|
34805
|
-
hasInfo =
|
|
34862
|
+
const evalArgs = takeBCallArgs(ext.fnName, loc?.start.line);
|
|
34863
|
+
if (evalArgs && evalArgs.length > 0) {
|
|
34864
|
+
absArgs = evalArgs;
|
|
34865
|
+
hasInfo = evalArgs.some(isInformativeArg);
|
|
34806
34866
|
}
|
|
34807
34867
|
}
|
|
34808
34868
|
if (!hasInfo || absArgs.length === 0) return;
|
|
@@ -35659,7 +35719,7 @@ function collectEntryMayThrows(source, fnName, g, file, phi2, opts = {}) {
|
|
|
35659
35719
|
return runWithMayThrowSession(() => {
|
|
35660
35720
|
setMayThrowCollector((e) => effects.push(e));
|
|
35661
35721
|
try {
|
|
35662
|
-
const full =
|
|
35722
|
+
const full = evalThrowsOf(source, fnName, entryArgs, opts, phi2);
|
|
35663
35723
|
if (!full) return effects;
|
|
35664
35724
|
if (full.throws && full.throws.shape.k !== "never") {
|
|
35665
35725
|
for (const tName of throwAbsToKinds(full.throws)) {
|
|
@@ -35678,7 +35738,7 @@ function collectEntryMayThrows(source, fnName, g, file, phi2, opts = {}) {
|
|
|
35678
35738
|
return effects;
|
|
35679
35739
|
});
|
|
35680
35740
|
}
|
|
35681
|
-
function
|
|
35741
|
+
function evalAnalyzeOpts(opts) {
|
|
35682
35742
|
const inject = opts.inject ?? {};
|
|
35683
35743
|
const modules = opts.modules ?? inject.modules;
|
|
35684
35744
|
return {
|
|
@@ -35701,18 +35761,18 @@ function invokeAsThrows(fn2, phi2 = pTrue) {
|
|
|
35701
35761
|
throw e;
|
|
35702
35762
|
}
|
|
35703
35763
|
}
|
|
35704
|
-
function
|
|
35764
|
+
function evalThrowsOf(source, fnName, args, opts = {}, phi2 = pTrue) {
|
|
35705
35765
|
const runKey = `${source}|${runTranspiledOptionsMemoKey(opts.inject)}|${runTranspiledOptionsMemoKey(opts.modules ? { modules: opts.modules } : void 0)}`;
|
|
35706
|
-
if (
|
|
35707
|
-
const oldest =
|
|
35708
|
-
if (oldest !== void 0)
|
|
35766
|
+
if (evalRunMemo2.size >= MAX_CHECK_MEMO) {
|
|
35767
|
+
const oldest = evalRunMemo2.keys().next().value;
|
|
35768
|
+
if (oldest !== void 0) evalRunMemo2.delete(oldest);
|
|
35709
35769
|
}
|
|
35710
|
-
let exports =
|
|
35770
|
+
let exports = evalRunMemo2.get(runKey);
|
|
35711
35771
|
if (exports === void 0) {
|
|
35712
|
-
const run = tryRunTranspiled(source,
|
|
35772
|
+
const run = tryRunTranspiled(source, evalAnalyzeOpts(opts));
|
|
35713
35773
|
if (run === void 0) return void 0;
|
|
35714
35774
|
exports = run;
|
|
35715
|
-
|
|
35775
|
+
evalRunMemo2.set(runKey, exports);
|
|
35716
35776
|
}
|
|
35717
35777
|
const isAbsVal5 = (v2) => !!v2 && typeof v2 === "object" && "shape" in v2 && "conf" in v2;
|
|
35718
35778
|
const call = (name, callArgs) => {
|
|
@@ -35747,7 +35807,7 @@ function bPathThrowsOf(source, fnName, args, opts = {}, phi2 = pTrue) {
|
|
|
35747
35807
|
return void 0;
|
|
35748
35808
|
}
|
|
35749
35809
|
}
|
|
35750
|
-
var
|
|
35810
|
+
var evalRunMemo2;
|
|
35751
35811
|
var init_check_may_throw = __esm({
|
|
35752
35812
|
"../core/src/algebra/check-may-throw.ts"() {
|
|
35753
35813
|
"use strict";
|
|
@@ -35759,7 +35819,7 @@ var init_check_may_throw = __esm({
|
|
|
35759
35819
|
init_nudo_throw();
|
|
35760
35820
|
init_may_throw();
|
|
35761
35821
|
init_check_memo();
|
|
35762
|
-
|
|
35822
|
+
evalRunMemo2 = /* @__PURE__ */ new Map();
|
|
35763
35823
|
}
|
|
35764
35824
|
});
|
|
35765
35825
|
|
|
@@ -36482,15 +36542,15 @@ function checkSourceInner(filePath, source, file, phi2, opts, issues, signatures
|
|
|
36482
36542
|
const varAbs = /* @__PURE__ */ new Map();
|
|
36483
36543
|
const callRecords = [];
|
|
36484
36544
|
const bCalls = [];
|
|
36485
|
-
const prevAssign =
|
|
36486
|
-
const prevCall =
|
|
36487
|
-
let
|
|
36488
|
-
const
|
|
36545
|
+
const prevAssign = setEvalAssignCollector((r) => records.push(r));
|
|
36546
|
+
const prevCall = setEvalCallCollector((r) => bCalls.push(r));
|
|
36547
|
+
let evalBindings;
|
|
36548
|
+
const evalAnalyze = evalAnalyzeOpts(opts);
|
|
36489
36549
|
try {
|
|
36490
|
-
const
|
|
36491
|
-
|
|
36492
|
-
if (
|
|
36493
|
-
for (const [k, v2] of
|
|
36550
|
+
const evalRun = tryRunTranspiled(source, evalAnalyze);
|
|
36551
|
+
evalBindings = evalRun ? bindingsOf(evalRun) : void 0;
|
|
36552
|
+
if (evalBindings) {
|
|
36553
|
+
for (const [k, v2] of evalBindings) {
|
|
36494
36554
|
if (v2 && typeof v2 === "object" && "shape" in v2 && "conf" in v2) {
|
|
36495
36555
|
varAbs.set(k, v2);
|
|
36496
36556
|
}
|
|
@@ -36506,10 +36566,10 @@ function checkSourceInner(filePath, source, file, phi2, opts, issues, signatures
|
|
|
36506
36566
|
}
|
|
36507
36567
|
} catch {
|
|
36508
36568
|
} finally {
|
|
36509
|
-
|
|
36510
|
-
|
|
36569
|
+
setEvalAssignCollector(prevAssign);
|
|
36570
|
+
setEvalCallCollector(prevCall);
|
|
36511
36571
|
}
|
|
36512
|
-
void
|
|
36572
|
+
void evalBindings;
|
|
36513
36573
|
const callIssues = canSkipLiteralCallScan(source, file) ? [] : scanLiteralCalls(source, names2, phi2, {
|
|
36514
36574
|
loadModule: opts.loadModule,
|
|
36515
36575
|
// 与 generalize / 返回后置同一 fromFile 口径:ambient 侧车按真实
|
|
@@ -36549,7 +36609,7 @@ function checkSourceInner(filePath, source, file, phi2, opts, issues, signatures
|
|
|
36549
36609
|
return (fnName, args) => {
|
|
36550
36610
|
try {
|
|
36551
36611
|
if (!driftInit) {
|
|
36552
|
-
driftRun = tryRunTranspiled(source,
|
|
36612
|
+
driftRun = tryRunTranspiled(source, evalAnalyze);
|
|
36553
36613
|
driftInit = true;
|
|
36554
36614
|
}
|
|
36555
36615
|
if (!driftRun || !(fnName in driftRun)) return void 0;
|
|
@@ -37306,8 +37366,8 @@ __export(src_exports, {
|
|
|
37306
37366
|
$whileSeq: () => $whileSeq,
|
|
37307
37367
|
$yield: () => $yield,
|
|
37308
37368
|
DEFAULT_MAX_LOOP_ITERS: () => DEFAULT_MAX_LOOP_ITERS,
|
|
37309
|
-
|
|
37310
|
-
|
|
37369
|
+
MAX_EVAL_CALL_DEPTH: () => MAX_EVAL_CALL_DEPTH,
|
|
37370
|
+
MAX_EVAL_TOTAL_CALLS: () => MAX_EVAL_TOTAL_CALLS,
|
|
37311
37371
|
NudoLoopSignal: () => NudoLoopSignal,
|
|
37312
37372
|
NudoReturn: () => NudoReturn,
|
|
37313
37373
|
NudoSidecarError: () => NudoSidecarError,
|
|
@@ -37445,8 +37505,8 @@ __export(src_exports, {
|
|
|
37445
37505
|
generalizeFromAst: () => generalizeFromAst,
|
|
37446
37506
|
generatedExportNames: () => generatedExportNames,
|
|
37447
37507
|
getAbsProperty: () => getAbsProperty,
|
|
37448
|
-
|
|
37449
|
-
|
|
37508
|
+
getEvalCallCollector: () => getEvalCallCollector,
|
|
37509
|
+
getEvalClass: () => getEvalClass,
|
|
37450
37510
|
getFnImpl: () => getFnImpl,
|
|
37451
37511
|
getGeneralizeMemoSize: () => getGeneralizeMemoSize,
|
|
37452
37512
|
getImplicationOracle: () => getImplicationOracle,
|
|
@@ -37539,9 +37599,9 @@ __export(src_exports, {
|
|
|
37539
37599
|
never: () => never,
|
|
37540
37600
|
not: () => not,
|
|
37541
37601
|
notAbs: () => notAbs,
|
|
37542
|
-
noteBCallRecord: () => noteBCallRecord,
|
|
37543
|
-
noteBPathFallback: () => noteBPathFallback,
|
|
37544
37602
|
noteCollectionWrite: () => noteCollectionWrite,
|
|
37603
|
+
noteEvalCallRecord: () => noteEvalCallRecord,
|
|
37604
|
+
noteEvalFallback: () => noteEvalFallback,
|
|
37545
37605
|
notePromiseExecutorFork: () => notePromiseExecutorFork,
|
|
37546
37606
|
num: () => num,
|
|
37547
37607
|
numLit: () => numLit,
|
|
@@ -37581,12 +37641,12 @@ __export(src_exports, {
|
|
|
37581
37641
|
refineDiagCount: () => refineDiagCount,
|
|
37582
37642
|
refineToIndexedFull: () => refineToIndexedFull,
|
|
37583
37643
|
regexBrandAbsFrom: () => regexBrandAbsFrom,
|
|
37584
|
-
|
|
37644
|
+
registerEvalClass: () => registerEvalClass,
|
|
37585
37645
|
relationFingerprint: () => relationFingerprint,
|
|
37586
37646
|
relationFn: () => relationFn,
|
|
37587
37647
|
requiredFnArity: () => requiredFnArity,
|
|
37588
|
-
resetBCallBudget: () => resetBCallBudget,
|
|
37589
37648
|
resetCheckSourceMemo: () => resetCheckSourceMemo,
|
|
37649
|
+
resetEvalCallBudget: () => resetEvalCallBudget,
|
|
37590
37650
|
resetGeneralizeMemo: () => resetGeneralizeMemo,
|
|
37591
37651
|
resetNudoModuleExecCache: () => resetNudoModuleExecCache,
|
|
37592
37652
|
resetParseSourceCache: () => resetParseSourceCache,
|
|
@@ -37599,13 +37659,13 @@ __export(src_exports, {
|
|
|
37599
37659
|
serializeCheckJsonMulti: () => serializeCheckJsonMulti,
|
|
37600
37660
|
setAddEntry: () => setAddEntry,
|
|
37601
37661
|
setApplyCallbackHost: () => setApplyCallbackHost,
|
|
37602
|
-
setBAssignCollector: () => setBAssignCollector,
|
|
37603
|
-
setBBindingSink: () => setBBindingSink,
|
|
37604
|
-
setBCallCollector: () => setBCallCollector,
|
|
37605
|
-
setBPathFallbackCollector: () => setBPathFallbackCollector,
|
|
37606
37662
|
setClearEntries: () => setClearEntries,
|
|
37607
37663
|
setDeleteEntry: () => setDeleteEntry,
|
|
37608
37664
|
setElementsAbs: () => setElementsAbs,
|
|
37665
|
+
setEvalAssignCollector: () => setEvalAssignCollector,
|
|
37666
|
+
setEvalBindingSink: () => setEvalBindingSink,
|
|
37667
|
+
setEvalCallCollector: () => setEvalCallCollector,
|
|
37668
|
+
setEvalFallbackCollector: () => setEvalFallbackCollector,
|
|
37609
37669
|
setHasEntry: () => setHasEntry,
|
|
37610
37670
|
setImplicationOracle: () => setImplicationOracle,
|
|
37611
37671
|
setInterfaceDiagCollector: () => setInterfaceDiagCollector,
|
|
@@ -46355,8 +46415,8 @@ __export(internal_exports, {
|
|
|
46355
46415
|
ERROR_FAMILY: () => ERROR_FAMILY,
|
|
46356
46416
|
FORK_TRUNCATION_LABEL: () => FORK_TRUNCATION_LABEL,
|
|
46357
46417
|
HOST_EFFECT_LABEL_PREFIX: () => HOST_EFFECT_LABEL_PREFIX,
|
|
46358
|
-
MAX_B_TOTAL_FORKS: () => MAX_B_TOTAL_FORKS,
|
|
46359
46418
|
MAX_CALL_DEPTH: () => MAX_CALL_DEPTH,
|
|
46419
|
+
MAX_EVAL_TOTAL_FORKS: () => MAX_EVAL_TOTAL_FORKS,
|
|
46360
46420
|
MAX_TOTAL_CALLS: () => MAX_TOTAL_CALLS,
|
|
46361
46421
|
OBJECT_PROTO_NAMES: () => OBJECT_PROTO_NAMES,
|
|
46362
46422
|
abortDerivationSession: () => abortDerivationSession,
|
|
@@ -46365,7 +46425,7 @@ __export(internal_exports, {
|
|
|
46365
46425
|
anyMemberResult: () => anyMemberResult,
|
|
46366
46426
|
awaitAbs: () => awaitAbs,
|
|
46367
46427
|
beginDerivationSession: () => beginDerivationSession,
|
|
46368
|
-
|
|
46428
|
+
bumpEvalForkBudget: () => bumpEvalForkBudget,
|
|
46369
46429
|
callBudgetKey: () => callBudgetKey,
|
|
46370
46430
|
canSkipLiteralCallScan: () => canSkipLiteralCallScan,
|
|
46371
46431
|
checkInjectedDomainEvidence: () => checkInjectedDomainEvidence,
|
|
@@ -46400,11 +46460,11 @@ __export(internal_exports, {
|
|
|
46400
46460
|
generalizeSourceKeyPart: () => generalizeSourceKeyPart,
|
|
46401
46461
|
getAbsCallBudgetStats: () => getAbsCallBudgetStats,
|
|
46402
46462
|
getAbsOrigin: () => getAbsOrigin,
|
|
46403
|
-
getBForkBudgetLimit: () => getBForkBudgetLimit,
|
|
46404
|
-
getBForkCount: () => getBForkCount,
|
|
46405
46463
|
getClass: () => getClass,
|
|
46406
46464
|
getClassChain: () => getClassChain,
|
|
46407
46465
|
getDerivation: () => getDerivation,
|
|
46466
|
+
getEvalForkBudgetLimit: () => getEvalForkBudgetLimit,
|
|
46467
|
+
getEvalForkCount: () => getEvalForkCount,
|
|
46408
46468
|
getFnNameAndBodies: () => getFnNameAndBodies,
|
|
46409
46469
|
getMayThrowCollector: () => getMayThrowCollector,
|
|
46410
46470
|
hasDerivationSession: () => hasDerivationSession,
|
|
@@ -46429,9 +46489,9 @@ __export(internal_exports, {
|
|
|
46429
46489
|
normPath: () => normPath,
|
|
46430
46490
|
noteAbsTruncation: () => noteAbsTruncation,
|
|
46431
46491
|
noteAnyMemberMayThrow: () => noteAnyMemberMayThrow,
|
|
46432
|
-
noteBForkTruncation: () => noteBForkTruncation,
|
|
46433
46492
|
noteDerivationAdd: () => noteDerivationAdd,
|
|
46434
46493
|
noteDerivationJoin: () => noteDerivationJoin,
|
|
46494
|
+
noteEvalForkTruncation: () => noteEvalForkTruncation,
|
|
46435
46495
|
noteHostEffectBlocked: () => noteHostEffectBlocked,
|
|
46436
46496
|
noteMemberDispatchMiss: () => noteMemberDispatchMiss,
|
|
46437
46497
|
noteNullishMemberThrows: () => noteNullishMemberThrows,
|
|
@@ -46448,7 +46508,7 @@ __export(internal_exports, {
|
|
|
46448
46508
|
recordMayThrow: () => recordMayThrow,
|
|
46449
46509
|
recordMemberDiag: () => recordMemberDiag,
|
|
46450
46510
|
resetAbsCallBudget: () => resetAbsCallBudget,
|
|
46451
|
-
|
|
46511
|
+
resetEvalForkBudget: () => resetEvalForkBudget,
|
|
46452
46512
|
resetFnFpCache: () => resetFnFpCache,
|
|
46453
46513
|
resetHashSourceCache: () => resetHashSourceCache,
|
|
46454
46514
|
resetLeakCounter: () => resetLeakCounter,
|
|
@@ -46456,9 +46516,9 @@ __export(internal_exports, {
|
|
|
46456
46516
|
runWithEvalMissingSlot: () => runWithEvalMissingSlot,
|
|
46457
46517
|
runWithMayThrowSession: () => runWithMayThrowSession,
|
|
46458
46518
|
setAbsTruncationCollector: () => setAbsTruncationCollector,
|
|
46459
|
-
setBForkBudgetLimit: () => setBForkBudgetLimit,
|
|
46460
46519
|
setDerivation: () => setDerivation,
|
|
46461
46520
|
setDerivationCollector: () => setDerivationCollector,
|
|
46521
|
+
setEvalForkBudgetLimit: () => setEvalForkBudgetLimit,
|
|
46462
46522
|
setEvalMissingSlotEnabled: () => setEvalMissingSlotEnabled,
|
|
46463
46523
|
setMayThrowCollector: () => setMayThrowCollector,
|
|
46464
46524
|
setMemberDiagCollector: () => setMemberDiagCollector,
|
|
@@ -48996,7 +49056,7 @@ function envLimits(env2) {
|
|
|
48996
49056
|
return {
|
|
48997
49057
|
maxFiles: parseLimit(env2.NUDO_CACHE_MAX_FILES, NaN),
|
|
48998
49058
|
maxFns: parseLimit(env2.NUDO_CACHE_MAX_FNS, NaN),
|
|
48999
|
-
|
|
49059
|
+
maxEvalRuns: parseLimit(env2.NUDO_CACHE_MAX_EVALRUNS, NaN)
|
|
49000
49060
|
};
|
|
49001
49061
|
}
|
|
49002
49062
|
function pick2(key, env2, fallback) {
|
|
@@ -49013,7 +49073,7 @@ function getSessionCacheLimits(env2 = process.env) {
|
|
|
49013
49073
|
return {
|
|
49014
49074
|
maxFiles: pick2("maxFiles", envCache, DEFAULT_SESSION_CACHE_LIMITS.maxFiles),
|
|
49015
49075
|
maxFns: pick2("maxFns", envCache, DEFAULT_SESSION_CACHE_LIMITS.maxFns),
|
|
49016
|
-
|
|
49076
|
+
maxEvalRuns: pick2("maxEvalRuns", envCache, DEFAULT_SESSION_CACHE_LIMITS.maxEvalRuns)
|
|
49017
49077
|
};
|
|
49018
49078
|
}
|
|
49019
49079
|
function setSessionCacheLimits(partial2) {
|
|
@@ -49035,7 +49095,7 @@ var init_session_cache_limits = __esm({
|
|
|
49035
49095
|
DEFAULT_SESSION_CACHE_LIMITS = {
|
|
49036
49096
|
maxFiles: 64,
|
|
49037
49097
|
maxFns: 1024,
|
|
49038
|
-
|
|
49098
|
+
maxEvalRuns: 32
|
|
49039
49099
|
};
|
|
49040
49100
|
HARD_CAP = 65536;
|
|
49041
49101
|
explicit = {};
|
|
@@ -49092,7 +49152,7 @@ function analysisConfig(config) {
|
|
|
49092
49152
|
diagnostics,
|
|
49093
49153
|
callSiteBudget,
|
|
49094
49154
|
evalMissingSlot: raw?.evalMissingSlot === "warning" ? "warning" : "off",
|
|
49095
|
-
maxForks: parseMaxForks(raw?.maxForks) ??
|
|
49155
|
+
maxForks: parseMaxForks(raw?.maxForks) ?? MAX_EVAL_TOTAL_FORKS
|
|
49096
49156
|
};
|
|
49097
49157
|
}
|
|
49098
49158
|
function parseMaxForks(raw) {
|
|
@@ -49104,10 +49164,10 @@ function applyBForkBudgetFromConfig(config, env2 = process.env) {
|
|
|
49104
49164
|
env2.NUDO_MAX_FORKS === void 0 ? void 0 : Number(env2.NUDO_MAX_FORKS)
|
|
49105
49165
|
);
|
|
49106
49166
|
const fromCfg = parseMaxForks(config?.analysis?.maxForks);
|
|
49107
|
-
return
|
|
49167
|
+
return setEvalForkBudgetLimit(fromEnv ?? fromCfg ?? MAX_EVAL_TOTAL_FORKS);
|
|
49108
49168
|
}
|
|
49109
49169
|
function currentBForkBudgetLimit() {
|
|
49110
|
-
return
|
|
49170
|
+
return getEvalForkBudgetLimit();
|
|
49111
49171
|
}
|
|
49112
49172
|
function diskCacheRoot(config, projectDir) {
|
|
49113
49173
|
const raw = config?.cache;
|
|
@@ -265584,7 +265644,7 @@ function topLevelFnParams(file) {
|
|
|
265584
265644
|
}
|
|
265585
265645
|
return out;
|
|
265586
265646
|
}
|
|
265587
|
-
function
|
|
265647
|
+
function evalExportsToModuleExports(run, file, fingerprintPrefix) {
|
|
265588
265648
|
const named = {};
|
|
265589
265649
|
let def;
|
|
265590
265650
|
const paramTable = topLevelFnParams(file);
|
|
@@ -265597,7 +265657,7 @@ function bPathExportsToModuleExports(run, file, fingerprintPrefix) {
|
|
|
265597
265657
|
const params = paramTable.get(k) ?? Array.from({ length: v2.length ?? 0 }, (_, i) => `arg${i}`);
|
|
265598
265658
|
absVal = absFunction(params, {
|
|
265599
265659
|
apply: (args) => callTranspiledExportFull(run, k, args).result,
|
|
265600
|
-
kind: "
|
|
265660
|
+
kind: "eval-export",
|
|
265601
265661
|
// 无 body 的桥接 fn 预算键 = fingerprint ?? anon#N——缺省会让所有
|
|
265602
265662
|
// 桥接导出共享 anon#1,嵌套跨模块调用(a 调 b 调 a')撞
|
|
265603
265663
|
// _activeCallKeys 递归守卫被误截断为 opaque。按 模块#导出 唯一化。
|
|
@@ -265699,9 +265759,9 @@ function evalAbsModuleGraph(entrySource, entryFile, opts = {}) {
|
|
|
265699
265759
|
}
|
|
265700
265760
|
);
|
|
265701
265761
|
let exports;
|
|
265702
|
-
const
|
|
265703
|
-
if (
|
|
265704
|
-
exports =
|
|
265762
|
+
const evalRun = tryRunTranspiled(source, { mode: "analyze", modules: modules2 });
|
|
265763
|
+
if (evalRun) {
|
|
265764
|
+
exports = evalExportsToModuleExports(evalRun, parse2(source), `eval:${absPath}`);
|
|
265705
265765
|
} else {
|
|
265706
265766
|
exports = { named: {} };
|
|
265707
265767
|
}
|
|
@@ -265789,7 +265849,7 @@ function collectAbsBindingsFromGraph(source, filePath, opts = {}) {
|
|
|
265789
265849
|
if (isAbsVal2(v2)) out.set(name, v2);
|
|
265790
265850
|
}
|
|
265791
265851
|
}
|
|
265792
|
-
const exports =
|
|
265852
|
+
const exports = evalExportsToModuleExports(run, parse2(source), `eval:bindings:${filePath}`);
|
|
265793
265853
|
for (const [name, v2] of Object.entries(exports.named)) {
|
|
265794
265854
|
if (!out.has(name)) out.set(name, v2);
|
|
265795
265855
|
}
|
|
@@ -265949,7 +266009,7 @@ function loadMockModuleExports(fromPath, fromFile, loadModule) {
|
|
|
265949
266009
|
error: evaled.error.includes("not found") ? `Mock module not found (from "${fromPath}")` : evaled.error
|
|
265950
266010
|
};
|
|
265951
266011
|
}
|
|
265952
|
-
const exports =
|
|
266012
|
+
const exports = evalExportsToModuleExports(evaled.run, parse2(evaled.source), `mock-module:${fromPath}`);
|
|
265953
266013
|
if (exports.default === void 0 && Object.keys(exports.named).length > 0) {
|
|
265954
266014
|
const slots = {};
|
|
265955
266015
|
for (const [k, v2] of Object.entries(exports.named)) slots[k] = { value: v2 };
|
|
@@ -266142,7 +266202,7 @@ var init_fn_analysis_cache = __esm({
|
|
|
266142
266202
|
}
|
|
266143
266203
|
});
|
|
266144
266204
|
|
|
266145
|
-
// ../service/src/
|
|
266205
|
+
// ../service/src/eval-run.ts
|
|
266146
266206
|
function absSeedPart(a) {
|
|
266147
266207
|
const impl = getFnImpl(a);
|
|
266148
266208
|
if (impl?.fingerprint) return impl.fingerprint;
|
|
@@ -266249,7 +266309,7 @@ function mergeHarvestUnderEnv(harvestModules, envModules, opts) {
|
|
|
266249
266309
|
}
|
|
266250
266310
|
return out;
|
|
266251
266311
|
}
|
|
266252
|
-
function
|
|
266312
|
+
function collectEvalReplacements(source) {
|
|
266253
266313
|
const targets = [];
|
|
266254
266314
|
const values = {};
|
|
266255
266315
|
const asTargets = [];
|
|
@@ -266301,12 +266361,12 @@ function collectBPathReplacements(source) {
|
|
|
266301
266361
|
}
|
|
266302
266362
|
return { targets, values, asTargets, asValues };
|
|
266303
266363
|
}
|
|
266304
|
-
function
|
|
266364
|
+
function isEvalCapable(source, envNames = []) {
|
|
266305
266365
|
void envNames;
|
|
266306
266366
|
void source;
|
|
266307
266367
|
return true;
|
|
266308
266368
|
}
|
|
266309
|
-
function
|
|
266369
|
+
function evalDepKey(source, filePath) {
|
|
266310
266370
|
try {
|
|
266311
266371
|
const fp = loadModuleDepsFingerprint(source, defaultLoadModule, filePath);
|
|
266312
266372
|
if (fp.truncated) return null;
|
|
@@ -266315,52 +266375,52 @@ function bPathDepKey(source, filePath) {
|
|
|
266315
266375
|
return null;
|
|
266316
266376
|
}
|
|
266317
266377
|
}
|
|
266318
|
-
function
|
|
266319
|
-
|
|
266378
|
+
function clearEvalCache() {
|
|
266379
|
+
evalRunByFile.clear();
|
|
266320
266380
|
clearAnalysisFileCache();
|
|
266321
266381
|
clearFnAnalysisCache();
|
|
266322
266382
|
}
|
|
266323
|
-
function
|
|
266324
|
-
return
|
|
266383
|
+
function getEvalCacheSize() {
|
|
266384
|
+
return evalRunByFile.size;
|
|
266325
266385
|
}
|
|
266326
|
-
function
|
|
266386
|
+
function evictEvalCacheForFiles(files) {
|
|
266327
266387
|
let n = 0;
|
|
266328
266388
|
for (const f of files) {
|
|
266329
|
-
if (
|
|
266389
|
+
if (evalRunByFile.delete(f)) n++;
|
|
266330
266390
|
}
|
|
266331
266391
|
return n;
|
|
266332
266392
|
}
|
|
266333
|
-
function
|
|
266334
|
-
const max = getSessionCacheLimits().
|
|
266393
|
+
function evalCacheSet(filePath, stableSource, mode, envKey, mockKey, depKey, value) {
|
|
266394
|
+
const max = getSessionCacheLimits().maxEvalRuns;
|
|
266335
266395
|
if (max <= 0) return;
|
|
266336
|
-
while (
|
|
266337
|
-
const oldest =
|
|
266396
|
+
while (evalRunByFile.size >= max && !evalRunByFile.has(filePath)) {
|
|
266397
|
+
const oldest = evalRunByFile.keys().next().value;
|
|
266338
266398
|
if (oldest === void 0) break;
|
|
266339
|
-
|
|
266399
|
+
evalRunByFile.delete(oldest);
|
|
266340
266400
|
}
|
|
266341
|
-
|
|
266401
|
+
evalRunByFile.set(filePath, { stableSource, mode, envKey, mockKey, depKey, value });
|
|
266342
266402
|
}
|
|
266343
|
-
function
|
|
266344
|
-
const max = getSessionCacheLimits().
|
|
266345
|
-
while (
|
|
266346
|
-
const oldest =
|
|
266403
|
+
function trimEvalCache() {
|
|
266404
|
+
const max = getSessionCacheLimits().maxEvalRuns;
|
|
266405
|
+
while (evalRunByFile.size > max) {
|
|
266406
|
+
const oldest = evalRunByFile.keys().next().value;
|
|
266347
266407
|
if (oldest === void 0) break;
|
|
266348
|
-
|
|
266408
|
+
evalRunByFile.delete(oldest);
|
|
266349
266409
|
}
|
|
266350
266410
|
}
|
|
266351
|
-
function
|
|
266352
|
-
if (!
|
|
266411
|
+
function tryRunEval(source, filePath, opts = {}) {
|
|
266412
|
+
if (!isEvalCapable(source, opts.envNames ?? [])) return void 0;
|
|
266353
266413
|
const mode = opts.mode ?? "analyze";
|
|
266354
266414
|
const envKey = (opts.envNames ?? []).join(",");
|
|
266355
266415
|
const mockKey = mockSeedFingerprint(opts.mocks);
|
|
266356
266416
|
const stable = stableAnalyzeKeySource(source);
|
|
266357
|
-
const depKey =
|
|
266417
|
+
const depKey = evalDepKey(source, filePath);
|
|
266358
266418
|
const canCache = depKey !== null;
|
|
266359
266419
|
if (canCache) {
|
|
266360
|
-
const cached2 =
|
|
266420
|
+
const cached2 = evalRunByFile.get(filePath);
|
|
266361
266421
|
if (cached2 && cached2.stableSource === stable && cached2.mode === mode && cached2.envKey === envKey && cached2.mockKey === mockKey && cached2.depKey === depKey) {
|
|
266362
|
-
|
|
266363
|
-
|
|
266422
|
+
evalRunByFile.delete(filePath);
|
|
266423
|
+
evalRunByFile.set(filePath, cached2);
|
|
266364
266424
|
return cached2.value ?? void 0;
|
|
266365
266425
|
}
|
|
266366
266426
|
}
|
|
@@ -266371,14 +266431,14 @@ function tryRunBPath(source, filePath, opts = {}) {
|
|
|
266371
266431
|
const topCalls = [];
|
|
266372
266432
|
const prevMember = setMemberDiagCollector((d) => memberDiags.push(d));
|
|
266373
266433
|
const prevTrunc = setAbsTruncationCollector((label) => truncated.add(label));
|
|
266374
|
-
const prevCall =
|
|
266434
|
+
const prevCall = setEvalCallCollector((r) => topCalls.push(r));
|
|
266375
266435
|
try {
|
|
266376
266436
|
const { modules: graphMods, issues } = evalAbsModuleGraph(source, filePath);
|
|
266377
266437
|
const envMods = collectEnvModules(opts.envNames ?? []);
|
|
266378
266438
|
let modules = mergeHarvestUnderEnv(graphMods, envMods);
|
|
266379
266439
|
const mm = applyMockModuleDirectivesFromSource(source, modules, { fromFile: filePath });
|
|
266380
266440
|
modules = mm.modules;
|
|
266381
|
-
const { targets, values, asTargets, asValues } =
|
|
266441
|
+
const { targets, values, asTargets, asValues } = collectEvalReplacements(source);
|
|
266382
266442
|
const envGlobals = {
|
|
266383
266443
|
...collectEnvGlobals(opts.envNames ?? []),
|
|
266384
266444
|
...opts.mocks ?? {}
|
|
@@ -266405,23 +266465,23 @@ function tryRunBPath(source, filePath, opts = {}) {
|
|
|
266405
266465
|
} finally {
|
|
266406
266466
|
setMemberDiagCollector(prevMember);
|
|
266407
266467
|
setAbsTruncationCollector(prevTrunc);
|
|
266408
|
-
|
|
266468
|
+
setEvalCallCollector(prevCall);
|
|
266409
266469
|
}
|
|
266410
266470
|
} catch {
|
|
266411
266471
|
out = null;
|
|
266412
266472
|
}
|
|
266413
266473
|
if (canCache && depKey !== null) {
|
|
266414
|
-
|
|
266474
|
+
evalCacheSet(filePath, stable, mode, envKey, mockKey, depKey, out);
|
|
266415
266475
|
}
|
|
266416
266476
|
return out ?? void 0;
|
|
266417
266477
|
}
|
|
266418
|
-
function
|
|
266419
|
-
const run =
|
|
266478
|
+
function tryEvalCallFull(source, filePath, fnName, args, opts = {}) {
|
|
266479
|
+
const run = tryRunEval(source, filePath, { envNames: opts.envNames, mocks: opts.mocks });
|
|
266420
266480
|
if (!run) return void 0;
|
|
266421
266481
|
if (!(fnName in run.exports)) return void 0;
|
|
266422
266482
|
const collected = [];
|
|
266423
266483
|
const memberDiags = [];
|
|
266424
|
-
const prevCall = opts.collectCalls ?
|
|
266484
|
+
const prevCall = opts.collectCalls ? setEvalCallCollector((r) => collected.push(r)) : void 0;
|
|
266425
266485
|
const wantMember = opts.collectMemberDiags ?? true;
|
|
266426
266486
|
const prevMember = wantMember ? setMemberDiagCollector((d) => memberDiags.push(d)) : void 0;
|
|
266427
266487
|
try {
|
|
@@ -266435,12 +266495,12 @@ function tryBPathCallFull(source, filePath, fnName, args, opts = {}) {
|
|
|
266435
266495
|
truncatedFns: run.truncatedFns
|
|
266436
266496
|
};
|
|
266437
266497
|
} finally {
|
|
266438
|
-
if (opts.collectCalls)
|
|
266498
|
+
if (opts.collectCalls) setEvalCallCollector(prevCall ?? null);
|
|
266439
266499
|
if (wantMember) setMemberDiagCollector(prevMember ?? null);
|
|
266440
266500
|
}
|
|
266441
266501
|
}
|
|
266442
|
-
function
|
|
266443
|
-
const full =
|
|
266502
|
+
function tryEvalCall(source, filePath, fnName, args, opts = {}) {
|
|
266503
|
+
const full = tryEvalCallFull(source, filePath, fnName, args, opts);
|
|
266444
266504
|
if (!full) return void 0;
|
|
266445
266505
|
const r = full.result;
|
|
266446
266506
|
if (!r) return void 0;
|
|
@@ -266450,9 +266510,9 @@ function tryBPathCall(source, filePath, fnName, args, opts = {}) {
|
|
|
266450
266510
|
if (r.shape.k === "unknown" && !r.term) return void 0;
|
|
266451
266511
|
return r;
|
|
266452
266512
|
}
|
|
266453
|
-
var envHarvestConflictCollector,
|
|
266454
|
-
var
|
|
266455
|
-
"../service/src/
|
|
266513
|
+
var envHarvestConflictCollector, evalRunByFile;
|
|
266514
|
+
var init_eval_run = __esm({
|
|
266515
|
+
"../service/src/eval-run.ts"() {
|
|
266456
266516
|
"use strict";
|
|
266457
266517
|
init_src();
|
|
266458
266518
|
init_internal();
|
|
@@ -266465,7 +266525,7 @@ var init_bpath_run = __esm({
|
|
|
266465
266525
|
init_fn_analysis_cache();
|
|
266466
266526
|
init_load_module();
|
|
266467
266527
|
envHarvestConflictCollector = null;
|
|
266468
|
-
|
|
266528
|
+
evalRunByFile = /* @__PURE__ */ new Map();
|
|
266469
266529
|
}
|
|
266470
266530
|
});
|
|
266471
266531
|
|
|
@@ -266564,7 +266624,7 @@ function tryEvalAbsFull(source, fnName, args, filePath, mocks, assignedName) {
|
|
|
266564
266624
|
if (/\brequire\s*\(/.test(source)) return void 0;
|
|
266565
266625
|
try {
|
|
266566
266626
|
if (filePath) {
|
|
266567
|
-
const viaB =
|
|
266627
|
+
const viaB = tryEvalCallFull(source, filePath, fnName, args, { mocks }) ?? (assignedName ? tryEvalCallFull(source, filePath, assignedName, args, { mocks }) : void 0);
|
|
266568
266628
|
if (viaB) {
|
|
266569
266629
|
const r = viaB.result;
|
|
266570
266630
|
if (r && !(r.shape.k === "unknown" && !r.term)) {
|
|
@@ -266685,7 +266745,7 @@ var init_analyzer_abs_eval = __esm({
|
|
|
266685
266745
|
init_src();
|
|
266686
266746
|
init_src2();
|
|
266687
266747
|
init_call_record();
|
|
266688
|
-
|
|
266748
|
+
init_eval_run();
|
|
266689
266749
|
}
|
|
266690
266750
|
});
|
|
266691
266751
|
|
|
@@ -266874,7 +266934,7 @@ function loadFromMockBinding(name, fromPath, fromFile, loadModule) {
|
|
|
266874
266934
|
const params = Array.from({ length: fn2.length ?? 0 }, (_, i) => `arg${i}`);
|
|
266875
266935
|
absVal = absFunction(params, {
|
|
266876
266936
|
apply: (args) => callTranspiledExportFull(run, name, args).result,
|
|
266877
|
-
kind: "
|
|
266937
|
+
kind: "eval-export",
|
|
266878
266938
|
fingerprint: `from-mock=${fromPath}#${name}`
|
|
266879
266939
|
});
|
|
266880
266940
|
} else {
|
|
@@ -266963,7 +267023,7 @@ function collectCallRecords(filePath, source) {
|
|
|
266963
267023
|
const mocks = mockSeedsForSource(source, {
|
|
266964
267024
|
fromFile: filePath || void 0
|
|
266965
267025
|
});
|
|
266966
|
-
const run =
|
|
267026
|
+
const run = tryRunEval(source, filePath, {
|
|
266967
267027
|
mode: "exec",
|
|
266968
267028
|
lenientGlobals: true,
|
|
266969
267029
|
...Object.keys(mocks).length > 0 ? { mocks } : {}
|
|
@@ -266996,13 +267056,13 @@ function expandTestCallbacks(calls) {
|
|
|
266996
267056
|
const impl = getFnImpl(abs2);
|
|
266997
267057
|
const params = impl?.params ?? [];
|
|
266998
267058
|
const collected = [];
|
|
266999
|
-
const prev =
|
|
267000
|
-
|
|
267059
|
+
const prev = getEvalCallCollector();
|
|
267060
|
+
setEvalCallCollector((r) => collected.push(r));
|
|
267001
267061
|
try {
|
|
267002
267062
|
$call(abs2, params.map(() => unknown));
|
|
267003
267063
|
} catch {
|
|
267004
267064
|
} finally {
|
|
267005
|
-
|
|
267065
|
+
setEvalCallCollector(prev);
|
|
267006
267066
|
}
|
|
267007
267067
|
out.push(...collected);
|
|
267008
267068
|
expanded++;
|
|
@@ -267017,12 +267077,12 @@ var init_analyzer_orchestrate_calls = __esm({
|
|
|
267017
267077
|
init_src2();
|
|
267018
267078
|
init_mock_abs();
|
|
267019
267079
|
init_config();
|
|
267020
|
-
|
|
267080
|
+
init_eval_run();
|
|
267021
267081
|
init_analyzer_abs_eval();
|
|
267022
267082
|
}
|
|
267023
267083
|
});
|
|
267024
267084
|
|
|
267025
|
-
// ../service/src/
|
|
267085
|
+
// ../service/src/eval-diagnostics.ts
|
|
267026
267086
|
function locOf2(node) {
|
|
267027
267087
|
if (!node.loc) return null;
|
|
267028
267088
|
return {
|
|
@@ -267194,7 +267254,7 @@ function walkBuiltinUnknown(node, declared, out, seen, known, parentKey) {
|
|
|
267194
267254
|
}
|
|
267195
267255
|
}
|
|
267196
267256
|
}
|
|
267197
|
-
function
|
|
267257
|
+
function collectEvalDiagnostics(source, extraKnown) {
|
|
267198
267258
|
let file;
|
|
267199
267259
|
try {
|
|
267200
267260
|
file = parseSource(source);
|
|
@@ -267214,8 +267274,8 @@ function collectBPathDiagnostics(source, extraKnown) {
|
|
|
267214
267274
|
return { unreachable, builtinUnknown };
|
|
267215
267275
|
}
|
|
267216
267276
|
var KNOWN_GLOBALS;
|
|
267217
|
-
var
|
|
267218
|
-
"../service/src/
|
|
267277
|
+
var init_eval_diagnostics = __esm({
|
|
267278
|
+
"../service/src/eval-diagnostics.ts"() {
|
|
267219
267279
|
"use strict";
|
|
267220
267280
|
init_src();
|
|
267221
267281
|
KNOWN_GLOBALS = /* @__PURE__ */ new Set([
|
|
@@ -267289,13 +267349,13 @@ function detectEntryVariantsFromPackageJson(pkg) {
|
|
|
267289
267349
|
const browser = [];
|
|
267290
267350
|
const node = [];
|
|
267291
267351
|
collectExportFaces(p.exports, browser, node);
|
|
267292
|
-
const
|
|
267293
|
-
if (typeof
|
|
267294
|
-
else if (
|
|
267295
|
-
for (const v2 of Object.values(
|
|
267352
|
+
const evalField = p.browser;
|
|
267353
|
+
if (typeof evalField === "string") browser.push(evalField);
|
|
267354
|
+
else if (evalField && typeof evalField === "object") {
|
|
267355
|
+
for (const v2 of Object.values(evalField)) {
|
|
267296
267356
|
if (typeof v2 === "string") browser.push(v2);
|
|
267297
267357
|
}
|
|
267298
|
-
for (const k of Object.keys(
|
|
267358
|
+
for (const k of Object.keys(evalField)) {
|
|
267299
267359
|
if (k.startsWith(".")) node.push(k);
|
|
267300
267360
|
}
|
|
267301
267361
|
}
|
|
@@ -267457,13 +267517,13 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267457
267517
|
const callSiteBudget = analysisCfg.callSiteBudget;
|
|
267458
267518
|
const callRecords = [];
|
|
267459
267519
|
const globalEnv = createEnvironment();
|
|
267460
|
-
const
|
|
267461
|
-
const
|
|
267520
|
+
const evalMemberDiagNames = /* @__PURE__ */ new Set();
|
|
267521
|
+
const evalMemberDiagSeen = /* @__PURE__ */ new Set();
|
|
267462
267522
|
const pushBMemberDiag = (d, fallbackLine) => {
|
|
267463
|
-
|
|
267523
|
+
evalMemberDiagNames.add(d.name);
|
|
267464
267524
|
const key = `${d.kind}:${d.name}:${d.receiver}:${d.line ?? fallbackLine}:${d.column ?? 0}:${d.code ?? ""}`;
|
|
267465
|
-
if (
|
|
267466
|
-
|
|
267525
|
+
if (evalMemberDiagSeen.has(key)) return;
|
|
267526
|
+
evalMemberDiagSeen.add(key);
|
|
267467
267527
|
if (d.code === "nudo:missing-slot") {
|
|
267468
267528
|
diagnostics.push({
|
|
267469
267529
|
range: {
|
|
@@ -267506,15 +267566,15 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267506
267566
|
}
|
|
267507
267567
|
const selfContained = isSelfContainedSource(source, envNames);
|
|
267508
267568
|
const canAbsModules = absModulesOk(source, envNames);
|
|
267509
|
-
const
|
|
267510
|
-
const
|
|
267511
|
-
const
|
|
267512
|
-
const
|
|
267513
|
-
let
|
|
267569
|
+
const evalCapable = isEvalCapable(source, envNames);
|
|
267570
|
+
const evalModuleIssueKinds = /* @__PURE__ */ new Set();
|
|
267571
|
+
const evalTruncatedFns = /* @__PURE__ */ new Set();
|
|
267572
|
+
const evalBuiltinUnknownNames = /* @__PURE__ */ new Set();
|
|
267573
|
+
let evalHosted = false;
|
|
267514
267574
|
const pushBModuleIssues = (issues) => {
|
|
267515
267575
|
if (!issues) return;
|
|
267516
267576
|
for (const iss of issues) {
|
|
267517
|
-
|
|
267577
|
+
evalModuleIssueKinds.add(iss.kind);
|
|
267518
267578
|
const code2 = iss.kind === "cycle" ? "nudo:module-cycle" : iss.kind === "depth" ? "nudo:module-depth" : "nudo:module-missing";
|
|
267519
267579
|
diagnostics.push({
|
|
267520
267580
|
range: { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
@@ -267541,11 +267601,11 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267541
267601
|
});
|
|
267542
267602
|
}
|
|
267543
267603
|
let absCallRecords = [];
|
|
267544
|
-
let
|
|
267604
|
+
let evalTopCallRecords = [];
|
|
267545
267605
|
let absGraphModules;
|
|
267546
267606
|
let absBindsShared;
|
|
267547
267607
|
let absNodesShared;
|
|
267548
|
-
if (
|
|
267608
|
+
if (evalCapable && filePath) {
|
|
267549
267609
|
try {
|
|
267550
267610
|
const g = evalAbsModuleGraph(source, filePath, {
|
|
267551
267611
|
seedVars: seeds.seedVars,
|
|
@@ -267569,46 +267629,46 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267569
267629
|
pushBModuleIssues(g.issues);
|
|
267570
267630
|
} catch {
|
|
267571
267631
|
}
|
|
267572
|
-
const
|
|
267632
|
+
const evalRun = tryRunEval(source, filePath, {
|
|
267573
267633
|
envNames,
|
|
267574
267634
|
mocks: mockSeedsToAbsMocks(seeds)
|
|
267575
267635
|
});
|
|
267576
|
-
if (
|
|
267577
|
-
|
|
267578
|
-
if (
|
|
267579
|
-
for (const d of
|
|
267636
|
+
if (evalRun) {
|
|
267637
|
+
evalHosted = true;
|
|
267638
|
+
if (evalRun.memberDiags?.length) {
|
|
267639
|
+
for (const d of evalRun.memberDiags) {
|
|
267580
267640
|
pushBMemberDiag(d, 1);
|
|
267581
267641
|
}
|
|
267582
267642
|
}
|
|
267583
|
-
if (
|
|
267584
|
-
for (const fn2 of
|
|
267643
|
+
if (evalRun.truncatedFns) {
|
|
267644
|
+
for (const fn2 of evalRun.truncatedFns) evalTruncatedFns.add(fn2);
|
|
267585
267645
|
}
|
|
267586
|
-
if (
|
|
267646
|
+
if (evalRun.calls?.length) {
|
|
267587
267647
|
const impMap = buildAbsImportLocalMap(source, filePath);
|
|
267588
|
-
for (const c of
|
|
267589
|
-
|
|
267648
|
+
for (const c of evalRun.calls) {
|
|
267649
|
+
evalTopCallRecords.push(callRecordFromAbsCall(c, impMap));
|
|
267590
267650
|
}
|
|
267591
267651
|
}
|
|
267592
267652
|
}
|
|
267593
267653
|
}
|
|
267594
|
-
if (
|
|
267654
|
+
if (evalHosted && evalTopCallRecords.length > 0) {
|
|
267595
267655
|
callRecords.length = 0;
|
|
267596
|
-
callRecords.push(...
|
|
267656
|
+
callRecords.push(...evalTopCallRecords);
|
|
267597
267657
|
} else if ((selfContained || canAbsModules) && absCallRecords.length > 0) {
|
|
267598
267658
|
callRecords.length = 0;
|
|
267599
267659
|
callRecords.push(...absCallRecords);
|
|
267600
|
-
} else if (
|
|
267660
|
+
} else if (evalTopCallRecords.length > 0) {
|
|
267601
267661
|
callRecords.length = 0;
|
|
267602
|
-
callRecords.push(...
|
|
267662
|
+
callRecords.push(...evalTopCallRecords);
|
|
267603
267663
|
}
|
|
267604
267664
|
const unreachableRanges = [];
|
|
267605
|
-
if (
|
|
267606
|
-
const
|
|
267665
|
+
if (evalCapable) {
|
|
267666
|
+
const evalKnownGlobals = /* @__PURE__ */ new Set([
|
|
267607
267667
|
...Object.keys(collectEnvGlobals(envNames)),
|
|
267608
267668
|
...Object.keys(mockSeedsToAbsMocks(seeds))
|
|
267609
267669
|
]);
|
|
267610
|
-
const
|
|
267611
|
-
for (const ur of
|
|
267670
|
+
const evalDiag = collectEvalDiagnostics(source, evalKnownGlobals);
|
|
267671
|
+
for (const ur of evalDiag.unreachable) {
|
|
267612
267672
|
diagnostics.push({
|
|
267613
267673
|
range: ur.range,
|
|
267614
267674
|
severity: "info",
|
|
@@ -267618,8 +267678,8 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267618
267678
|
suggestions: ["Remove the unreachable code after the return/throw statement"]
|
|
267619
267679
|
});
|
|
267620
267680
|
}
|
|
267621
|
-
for (const b of
|
|
267622
|
-
|
|
267681
|
+
for (const b of evalDiag.builtinUnknown) {
|
|
267682
|
+
evalBuiltinUnknownNames.add(b.name);
|
|
267623
267683
|
diagnostics.push({
|
|
267624
267684
|
range: b.range,
|
|
267625
267685
|
severity: "warning",
|
|
@@ -267643,7 +267703,7 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267643
267703
|
});
|
|
267644
267704
|
}
|
|
267645
267705
|
}
|
|
267646
|
-
if (!absNodesShared && !
|
|
267706
|
+
if (!absNodesShared && !evalHosted && (selfContained || canAbsModules)) {
|
|
267647
267707
|
try {
|
|
267648
267708
|
const collected = { binds: /* @__PURE__ */ new Map(), nodes: /* @__PURE__ */ new Map() };
|
|
267649
267709
|
if (!absBindsShared) absBindsShared = collected.binds;
|
|
@@ -267652,7 +267712,7 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267652
267712
|
}
|
|
267653
267713
|
}
|
|
267654
267714
|
collectBindings(ast, globalEnv, bindings, absBindsShared);
|
|
267655
|
-
if (
|
|
267715
|
+
if (isEvalCapable(source, envNames)) {
|
|
267656
267716
|
try {
|
|
267657
267717
|
const absBinds = absBindsShared ?? collectAbsBindingsFromGraph(source, filePath, {
|
|
267658
267718
|
seedVars: seeds.seedVars,
|
|
@@ -267783,36 +267843,36 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267783
267843
|
let caseThrowsAbs;
|
|
267784
267844
|
let caseThrowLoc;
|
|
267785
267845
|
let caseUnreachable = [];
|
|
267786
|
-
const
|
|
267787
|
-
const
|
|
267788
|
-
if (
|
|
267846
|
+
const evalCapable2 = isEvalCapable(source, envNames);
|
|
267847
|
+
const evalPrimary = evalCapable2;
|
|
267848
|
+
if (evalCapable2 && filePath) {
|
|
267789
267849
|
const caseArgsAbs = directive.argsAbs;
|
|
267790
|
-
const
|
|
267850
|
+
const evalFull = tryEvalCallFull(
|
|
267791
267851
|
source,
|
|
267792
267852
|
filePath,
|
|
267793
267853
|
fn2.name,
|
|
267794
267854
|
caseArgsAbs,
|
|
267795
267855
|
{ collectCalls: true, envNames, mocks: mockSeedsToAbsMocks(seeds) }
|
|
267796
267856
|
);
|
|
267797
|
-
const res =
|
|
267857
|
+
const res = evalFull?.result;
|
|
267798
267858
|
const weakUnknown = !!res && res.shape.k === "unknown" && (!res.term || res.term.op === "lit" && res.term.value === void 0);
|
|
267799
|
-
const
|
|
267800
|
-
if (
|
|
267801
|
-
caseAbs =
|
|
267802
|
-
caseThrowsAbs =
|
|
267803
|
-
for (const d of
|
|
267859
|
+
const evalOk = !!res && (evalHosted || !weakUnknown && res.conf !== "opaque");
|
|
267860
|
+
if (evalOk && evalFull && evalPrimary) {
|
|
267861
|
+
caseAbs = evalFull.result;
|
|
267862
|
+
caseThrowsAbs = evalFull.throws;
|
|
267863
|
+
for (const d of evalFull.memberDiags ?? []) {
|
|
267804
267864
|
pushBMemberDiag(d, fnLoc.start.line);
|
|
267805
267865
|
}
|
|
267806
|
-
if (
|
|
267866
|
+
if (evalFull.calls?.length) {
|
|
267807
267867
|
const impMap = buildAbsImportLocalMap(source, filePath);
|
|
267808
|
-
for (const c of
|
|
267868
|
+
for (const c of evalFull.calls) {
|
|
267809
267869
|
callRecords.push(callRecordFromAbsCall(c, impMap));
|
|
267810
267870
|
}
|
|
267811
267871
|
}
|
|
267812
267872
|
}
|
|
267813
267873
|
}
|
|
267814
267874
|
if (!caseAbs) {
|
|
267815
|
-
if (
|
|
267875
|
+
if (evalHosted) {
|
|
267816
267876
|
caseAbs = unknown;
|
|
267817
267877
|
caseThrowsAbs = neverAbs;
|
|
267818
267878
|
} else {
|
|
@@ -267885,7 +267945,7 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
267885
267945
|
code: "nudo:may-throw"
|
|
267886
267946
|
});
|
|
267887
267947
|
}
|
|
267888
|
-
if (!
|
|
267948
|
+
if (!isEvalCapable(source, envNames)) {
|
|
267889
267949
|
for (const ur of caseUnreachable) {
|
|
267890
267950
|
diagnostics.push({
|
|
267891
267951
|
range: ur,
|
|
@@ -268047,19 +268107,19 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
268047
268107
|
)
|
|
268048
268108
|
);
|
|
268049
268109
|
let symAbs;
|
|
268050
|
-
if (
|
|
268051
|
-
const
|
|
268110
|
+
if (isEvalCapable(source, envNames) && filePath) {
|
|
268111
|
+
const evalSym = tryEvalCall(
|
|
268052
268112
|
source,
|
|
268053
268113
|
filePath,
|
|
268054
268114
|
candidate.name,
|
|
268055
268115
|
widenedArgsAbs,
|
|
268056
268116
|
{ envNames, mocks: mockSeedsToAbsMocks(seeds) }
|
|
268057
268117
|
);
|
|
268058
|
-
if (
|
|
268059
|
-
symAbs =
|
|
268118
|
+
if (evalSym && (evalHosted || !(evalSym.shape.k === "unknown" && !evalSym.term))) {
|
|
268119
|
+
symAbs = evalSym;
|
|
268060
268120
|
}
|
|
268061
268121
|
}
|
|
268062
|
-
if (!symAbs && !
|
|
268122
|
+
if (!symAbs && !evalHosted) {
|
|
268063
268123
|
const absTry = tryEvalAbsRaw(
|
|
268064
268124
|
source,
|
|
268065
268125
|
candidate.name,
|
|
@@ -268098,30 +268158,30 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
268098
268158
|
const entryEffects = [];
|
|
268099
268159
|
setMayThrowCollector((e) => entryEffects.push(e));
|
|
268100
268160
|
try {
|
|
268101
|
-
if (
|
|
268102
|
-
const
|
|
268161
|
+
if (isEvalCapable(source, envNames) && filePath) {
|
|
268162
|
+
const evalEntryFull = tryEvalCallFull(
|
|
268103
268163
|
source,
|
|
268104
268164
|
filePath,
|
|
268105
268165
|
candidate.analysis.name,
|
|
268106
268166
|
argAbsEntry,
|
|
268107
268167
|
{ envNames, mocks: mockSeedsToAbsMocks(seeds), collectMemberDiags: true }
|
|
268108
|
-
) ?? (candidate.assignedName ?
|
|
268168
|
+
) ?? (candidate.assignedName ? tryEvalCallFull(source, filePath, candidate.assignedName, argAbsEntry, {
|
|
268109
268169
|
envNames,
|
|
268110
268170
|
mocks: mockSeedsToAbsMocks(seeds)
|
|
268111
268171
|
}) : void 0);
|
|
268112
|
-
if (
|
|
268113
|
-
for (const d of
|
|
268172
|
+
if (evalEntryFull?.memberDiags?.length) {
|
|
268173
|
+
for (const d of evalEntryFull.memberDiags) {
|
|
268114
268174
|
pushBMemberDiag(d, candidate.analysis.loc.start.line);
|
|
268115
268175
|
}
|
|
268116
268176
|
}
|
|
268117
|
-
const
|
|
268118
|
-
if (
|
|
268119
|
-
entryAbs =
|
|
268120
|
-
if (
|
|
268177
|
+
const evalEntry = evalEntryFull?.result;
|
|
268178
|
+
if (evalEntry && (evalHosted || !(evalEntry.shape.k === "unknown" && !evalEntry.term))) {
|
|
268179
|
+
entryAbs = evalEntry;
|
|
268180
|
+
if (evalEntryFull?.throws) entryThrowsAbs = evalEntryFull.throws;
|
|
268121
268181
|
}
|
|
268122
268182
|
}
|
|
268123
268183
|
if (!entryAbs) {
|
|
268124
|
-
if (
|
|
268184
|
+
if (evalHosted) {
|
|
268125
268185
|
entryAbs = unknown;
|
|
268126
268186
|
entryThrowsAbs = abs({ k: "never" }, void 0, void 0, "exact");
|
|
268127
268187
|
} else {
|
|
@@ -268192,7 +268252,7 @@ function analyzeFileUncachedInner(filePath, source, activeCases, externalCallRec
|
|
|
268192
268252
|
} catch {
|
|
268193
268253
|
}
|
|
268194
268254
|
}
|
|
268195
|
-
if (!
|
|
268255
|
+
if (!evalHosted) {
|
|
268196
268256
|
buildNodeTypeMap(ast, globalEnv, nodeAbsMap);
|
|
268197
268257
|
}
|
|
268198
268258
|
const externalFunctions = synthesizeExternalFunctions(
|
|
@@ -268252,8 +268312,8 @@ var init_analyzer_orchestrate_uncached = __esm({
|
|
|
268252
268312
|
init_mock_module();
|
|
268253
268313
|
init_load_module();
|
|
268254
268314
|
init_abs_modules_graph();
|
|
268255
|
-
|
|
268256
|
-
|
|
268315
|
+
init_eval_run();
|
|
268316
|
+
init_eval_diagnostics();
|
|
268257
268317
|
init_entry_variants();
|
|
268258
268318
|
init_fn_analysis_cache();
|
|
268259
268319
|
init_analyzer_ast();
|
|
@@ -268725,14 +268785,14 @@ var init_dep_contents = __esm({
|
|
|
268725
268785
|
// ../service/src/session-cache.ts
|
|
268726
268786
|
function evictAnalysisCachesForFiles(files) {
|
|
268727
268787
|
if (files.length === 0) return;
|
|
268728
|
-
|
|
268788
|
+
evictEvalCacheForFiles(files);
|
|
268729
268789
|
evictAnalysisFileCacheForFiles(files);
|
|
268730
268790
|
evictFnAnalysisCacheForFiles(files);
|
|
268731
268791
|
evictAbsModuleCacheFiles(files);
|
|
268732
268792
|
clearPathEnvCaches();
|
|
268733
268793
|
}
|
|
268734
268794
|
function clearAnalysisSessionCaches() {
|
|
268735
|
-
|
|
268795
|
+
clearEvalCache();
|
|
268736
268796
|
clearAbsModuleCache();
|
|
268737
268797
|
clearPathEnvCaches();
|
|
268738
268798
|
resetGeneralizeMemo();
|
|
@@ -268744,7 +268804,7 @@ function applySessionCacheConfig(config) {
|
|
|
268744
268804
|
const limits = getSessionCacheLimits();
|
|
268745
268805
|
trimAnalysisFileCache();
|
|
268746
268806
|
trimFnAnalysisCache();
|
|
268747
|
-
|
|
268807
|
+
trimEvalCache();
|
|
268748
268808
|
return limits;
|
|
268749
268809
|
}
|
|
268750
268810
|
function resetAllAnalysisCaches() {
|
|
@@ -268756,7 +268816,7 @@ var init_session_cache = __esm({
|
|
|
268756
268816
|
"use strict";
|
|
268757
268817
|
init_src();
|
|
268758
268818
|
init_abs_modules_graph();
|
|
268759
|
-
|
|
268819
|
+
init_eval_run();
|
|
268760
268820
|
init_analysis_file_cache();
|
|
268761
268821
|
init_fn_analysis_cache();
|
|
268762
268822
|
init_env_loader();
|
|
@@ -269005,18 +269065,18 @@ __export(src_exports4, {
|
|
|
269005
269065
|
clearAbsModuleCache: () => clearAbsModuleCache,
|
|
269006
269066
|
clearAnalysisFileCache: () => clearAnalysisFileCache,
|
|
269007
269067
|
clearAnalysisSessionCaches: () => clearAnalysisSessionCaches,
|
|
269008
|
-
clearBPathCache: () => clearBPathCache,
|
|
269009
269068
|
clearEnvPathDeps: () => clearEnvPathDeps,
|
|
269069
|
+
clearEvalCache: () => clearEvalCache,
|
|
269010
269070
|
clearFnAnalysisCache: () => clearFnAnalysisCache,
|
|
269011
269071
|
clearPathEnvCaches: () => clearPathEnvCaches,
|
|
269012
269072
|
collectAbsBindingsFromGraph: () => collectAbsBindingsFromGraph,
|
|
269013
|
-
collectBPathDiagnostics: () => collectBPathDiagnostics,
|
|
269014
|
-
collectBPathReplacements: () => collectBPathReplacements,
|
|
269015
269073
|
collectCallRecords: () => collectCallRecords,
|
|
269016
269074
|
collectDependencySpecs: () => collectDependencySpecs2,
|
|
269017
269075
|
collectEnvGlobals: () => collectEnvGlobals,
|
|
269018
269076
|
collectEnvModules: () => collectEnvModules,
|
|
269019
269077
|
collectEnvNames: () => collectEnvNames,
|
|
269078
|
+
collectEvalDiagnostics: () => collectEvalDiagnostics,
|
|
269079
|
+
collectEvalReplacements: () => collectEvalReplacements,
|
|
269020
269080
|
collectLoadDepContents: () => collectLoadDepContents,
|
|
269021
269081
|
collectSkipReturns: () => collectSkipReturns,
|
|
269022
269082
|
collectStaticImports: () => collectStaticImports,
|
|
@@ -269034,7 +269094,7 @@ __export(src_exports4, {
|
|
|
269034
269094
|
evictAbsModuleCacheFiles: () => evictAbsModuleCacheFiles,
|
|
269035
269095
|
evictAnalysisCachesForFiles: () => evictAnalysisCachesForFiles,
|
|
269036
269096
|
evictAnalysisFileCacheForFiles: () => evictAnalysisFileCacheForFiles,
|
|
269037
|
-
|
|
269097
|
+
evictEvalCacheForFiles: () => evictEvalCacheForFiles,
|
|
269038
269098
|
evictFnAnalysisCacheForFiles: () => evictFnAnalysisCacheForFiles,
|
|
269039
269099
|
extractNudoImportSpecs: () => extractNudoImportSpecs,
|
|
269040
269100
|
filterDiagnosticsByLevel: () => filterDiagnosticsByLevel,
|
|
@@ -269043,17 +269103,17 @@ __export(src_exports4, {
|
|
|
269043
269103
|
getAbsModuleCacheSize: () => getAbsModuleCacheSize,
|
|
269044
269104
|
getAnalysisFileCacheSize: () => getAnalysisFileCacheSize,
|
|
269045
269105
|
getAnalysisSession: () => getAnalysisSession,
|
|
269046
|
-
getBPathCacheSize: () => getBPathCacheSize,
|
|
269047
269106
|
getEnvHarvestConflictCollector: () => getEnvHarvestConflictCollector,
|
|
269048
269107
|
getEnvPathDepsSize: () => getEnvPathDepsSize,
|
|
269108
|
+
getEvalCacheSize: () => getEvalCacheSize,
|
|
269049
269109
|
getFnAnalysisCacheSize: () => getFnAnalysisCacheSize,
|
|
269050
269110
|
getPathEnvCacheSizes: () => getPathEnvCacheSizes,
|
|
269051
269111
|
getSessionCacheLimits: () => getSessionCacheLimits,
|
|
269052
269112
|
ifaceCacheKey: () => ifaceCacheKey,
|
|
269053
269113
|
injectBindings: () => injectBindings,
|
|
269054
269114
|
interfaceConfig: () => interfaceConfig,
|
|
269055
|
-
isBPathCapable: () => isBPathCapable,
|
|
269056
269115
|
isEnvTemplatePath: () => isEnvTemplatePath,
|
|
269116
|
+
isEvalCapable: () => isEvalCapable,
|
|
269057
269117
|
isNudoTargetPath: () => isNudoTargetPath,
|
|
269058
269118
|
isProjectConfigPath: () => isProjectConfigPath,
|
|
269059
269119
|
isSidecarPath: () => isSidecarPath,
|
|
@@ -269078,11 +269138,11 @@ __export(src_exports4, {
|
|
|
269078
269138
|
sourceHasNudoDirectives: () => hasNudoDirectives,
|
|
269079
269139
|
topoSortDirty: () => topoSortDirty,
|
|
269080
269140
|
trimAnalysisFileCache: () => trimAnalysisFileCache,
|
|
269081
|
-
|
|
269141
|
+
trimEvalCache: () => trimEvalCache,
|
|
269082
269142
|
trimFnAnalysisCache: () => trimFnAnalysisCache,
|
|
269083
|
-
|
|
269084
|
-
|
|
269085
|
-
|
|
269143
|
+
tryEvalCall: () => tryEvalCall,
|
|
269144
|
+
tryEvalCallFull: () => tryEvalCallFull,
|
|
269145
|
+
tryRunEval: () => tryRunEval,
|
|
269086
269146
|
typeExprToDirective: () => typeExprToDirective
|
|
269087
269147
|
});
|
|
269088
269148
|
var init_src4 = __esm({
|
|
@@ -269097,8 +269157,8 @@ var init_src4 = __esm({
|
|
|
269097
269157
|
init_load_module();
|
|
269098
269158
|
init_dep_contents();
|
|
269099
269159
|
init_abs_modules_graph();
|
|
269100
|
-
|
|
269101
|
-
|
|
269160
|
+
init_eval_run();
|
|
269161
|
+
init_eval_diagnostics();
|
|
269102
269162
|
init_mock_abs();
|
|
269103
269163
|
init_mock_module();
|
|
269104
269164
|
init_config();
|
|
@@ -269310,7 +269370,7 @@ var init_chunk_J2PUE4NV = __esm({
|
|
|
269310
269370
|
}
|
|
269311
269371
|
});
|
|
269312
269372
|
|
|
269313
|
-
// ../service/dist/chunk-
|
|
269373
|
+
// ../service/dist/chunk-3RCHDTBX.js
|
|
269314
269374
|
import { readFileSync as readFileSync17, existsSync as existsSync18, statSync as statSync12, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
|
|
269315
269375
|
import { resolve as resolvePath2, join as joinPath2 } from "path";
|
|
269316
269376
|
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
@@ -269487,7 +269547,7 @@ function envLimits2(env2) {
|
|
|
269487
269547
|
return {
|
|
269488
269548
|
maxFiles: parseLimit2(env2.NUDO_CACHE_MAX_FILES, NaN),
|
|
269489
269549
|
maxFns: parseLimit2(env2.NUDO_CACHE_MAX_FNS, NaN),
|
|
269490
|
-
|
|
269550
|
+
maxEvalRuns: parseLimit2(env2.NUDO_CACHE_MAX_EVALRUNS, NaN)
|
|
269491
269551
|
};
|
|
269492
269552
|
}
|
|
269493
269553
|
function pick3(key, env2, fallback) {
|
|
@@ -269504,7 +269564,7 @@ function getSessionCacheLimits2(env2 = process.env) {
|
|
|
269504
269564
|
return {
|
|
269505
269565
|
maxFiles: pick3("maxFiles", envCache2, DEFAULT_SESSION_CACHE_LIMITS2.maxFiles),
|
|
269506
269566
|
maxFns: pick3("maxFns", envCache2, DEFAULT_SESSION_CACHE_LIMITS2.maxFns),
|
|
269507
|
-
|
|
269567
|
+
maxEvalRuns: pick3("maxEvalRuns", envCache2, DEFAULT_SESSION_CACHE_LIMITS2.maxEvalRuns)
|
|
269508
269568
|
};
|
|
269509
269569
|
}
|
|
269510
269570
|
function setSessionCacheFromProject2(partial2) {
|
|
@@ -269533,7 +269593,7 @@ function analysisConfig2(config) {
|
|
|
269533
269593
|
diagnostics,
|
|
269534
269594
|
callSiteBudget,
|
|
269535
269595
|
evalMissingSlot: raw?.evalMissingSlot === "warning" ? "warning" : "off",
|
|
269536
|
-
maxForks: parseMaxForks2(raw?.maxForks) ??
|
|
269596
|
+
maxForks: parseMaxForks2(raw?.maxForks) ?? MAX_EVAL_TOTAL_FORKS
|
|
269537
269597
|
};
|
|
269538
269598
|
}
|
|
269539
269599
|
function parseMaxForks2(raw) {
|
|
@@ -269545,7 +269605,7 @@ function applyBForkBudgetFromConfig2(config, env2 = process.env) {
|
|
|
269545
269605
|
env2.NUDO_MAX_FORKS === void 0 ? void 0 : Number(env2.NUDO_MAX_FORKS)
|
|
269546
269606
|
);
|
|
269547
269607
|
const fromCfg = parseMaxForks2(config?.analysis?.maxForks);
|
|
269548
|
-
return
|
|
269608
|
+
return setEvalForkBudgetLimit(fromEnv ?? fromCfg ?? MAX_EVAL_TOTAL_FORKS);
|
|
269549
269609
|
}
|
|
269550
269610
|
function diskCacheRoot2(config, projectDir) {
|
|
269551
269611
|
const raw = config?.cache;
|
|
@@ -269710,8 +269770,8 @@ function resolveNpmJsEntry2(source, fromDir) {
|
|
|
269710
269770
|
return tryFile(resolve22(pkgDir, subpath));
|
|
269711
269771
|
}
|
|
269712
269772
|
var BUILTIN_ERROR_CLASSES2, BUILTIN_PROTOTYPE_CLASSES2, numA2, strA2, boolA2, unkA2, undefA2, nullA2, OBJECT_PROTOTYPE_METHODS2, BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS2, BoundedLruMap3, envFactories2, impliedDeps2, PATH_ENV_CACHE_MAX2, PATH_ENV_BY_PATH_MAX2, PATH_ENV_BASE_DIRS_MAX2, pathEnvCache2, pathEnvByPath2, pathEnvBaseDirs2, DEFAULT_SESSION_CACHE_LIMITS2, HARD_CAP2, explicit2, fromProject2, envCache2, DEFAULT_ANALYSIS_EXCLUDE2, DEFAULT_ANALYSIS_MODE2;
|
|
269713
|
-
var
|
|
269714
|
-
"../service/dist/chunk-
|
|
269773
|
+
var init_chunk_3RCHDTBX = __esm({
|
|
269774
|
+
"../service/dist/chunk-3RCHDTBX.js"() {
|
|
269715
269775
|
"use strict";
|
|
269716
269776
|
init_src();
|
|
269717
269777
|
init_es();
|
|
@@ -269972,7 +270032,7 @@ var init_chunk_COMUCF3K = __esm({
|
|
|
269972
270032
|
DEFAULT_SESSION_CACHE_LIMITS2 = {
|
|
269973
270033
|
maxFiles: 64,
|
|
269974
270034
|
maxFns: 1024,
|
|
269975
|
-
|
|
270035
|
+
maxEvalRuns: 32
|
|
269976
270036
|
};
|
|
269977
270037
|
HARD_CAP2 = 65536;
|
|
269978
270038
|
explicit2 = {};
|
|
@@ -269987,7 +270047,7 @@ var init_chunk_COMUCF3K = __esm({
|
|
|
269987
270047
|
}
|
|
269988
270048
|
});
|
|
269989
270049
|
|
|
269990
|
-
// ../service/dist/chunk-
|
|
270050
|
+
// ../service/dist/chunk-3IM6NXIF.js
|
|
269991
270051
|
import { existsSync as existsSync23, statSync as statSync23, readFileSync as readFileSync23 } from "fs";
|
|
269992
270052
|
import { dirname as dirname23, resolve as resolve23, join as join14 } from "path";
|
|
269993
270053
|
import { readFileSync as readFileSync33, statSync as statSync32 } from "fs";
|
|
@@ -270537,7 +270597,7 @@ function topLevelFnParams2(file) {
|
|
|
270537
270597
|
}
|
|
270538
270598
|
return out;
|
|
270539
270599
|
}
|
|
270540
|
-
function
|
|
270600
|
+
function evalExportsToModuleExports2(run, file, fingerprintPrefix) {
|
|
270541
270601
|
const named = {};
|
|
270542
270602
|
let def;
|
|
270543
270603
|
const paramTable = topLevelFnParams2(file);
|
|
@@ -270550,7 +270610,7 @@ function bPathExportsToModuleExports2(run, file, fingerprintPrefix) {
|
|
|
270550
270610
|
const params = paramTable.get(k) ?? Array.from({ length: v2.length ?? 0 }, (_, i) => `arg${i}`);
|
|
270551
270611
|
absVal = absFunction(params, {
|
|
270552
270612
|
apply: (args) => callTranspiledExportFull(run, k, args).result,
|
|
270553
|
-
kind: "
|
|
270613
|
+
kind: "eval-export",
|
|
270554
270614
|
// 无 body 的桥接 fn 预算键 = fingerprint ?? anon#N——缺省会让所有
|
|
270555
270615
|
// 桥接导出共享 anon#1,嵌套跨模块调用(a 调 b 调 a')撞
|
|
270556
270616
|
// _activeCallKeys 递归守卫被误截断为 opaque。按 模块#导出 唯一化。
|
|
@@ -270652,9 +270712,9 @@ function evalAbsModuleGraph2(entrySource, entryFile, opts = {}) {
|
|
|
270652
270712
|
}
|
|
270653
270713
|
);
|
|
270654
270714
|
let exports;
|
|
270655
|
-
const
|
|
270656
|
-
if (
|
|
270657
|
-
exports =
|
|
270715
|
+
const evalRun = tryRunTranspiled(source, { mode: "analyze", modules: modules2 });
|
|
270716
|
+
if (evalRun) {
|
|
270717
|
+
exports = evalExportsToModuleExports2(evalRun, parse2(source), `eval:${absPath}`);
|
|
270658
270718
|
} else {
|
|
270659
270719
|
exports = { named: {} };
|
|
270660
270720
|
}
|
|
@@ -270742,7 +270802,7 @@ function collectAbsBindingsFromGraph2(source, filePath, opts = {}) {
|
|
|
270742
270802
|
if (isAbsVal4(v2)) out.set(name, v2);
|
|
270743
270803
|
}
|
|
270744
270804
|
}
|
|
270745
|
-
const exports =
|
|
270805
|
+
const exports = evalExportsToModuleExports2(run, parse2(source), `eval:bindings:${filePath}`);
|
|
270746
270806
|
for (const [name, v2] of Object.entries(exports.named)) {
|
|
270747
270807
|
if (!out.has(name)) out.set(name, v2);
|
|
270748
270808
|
}
|
|
@@ -270848,7 +270908,7 @@ function loadMockModuleExports2(fromPath, fromFile, loadModule) {
|
|
|
270848
270908
|
error: evaled.error.includes("not found") ? `Mock module not found (from "${fromPath}")` : evaled.error
|
|
270849
270909
|
};
|
|
270850
270910
|
}
|
|
270851
|
-
const exports =
|
|
270911
|
+
const exports = evalExportsToModuleExports2(evaled.run, parse2(evaled.source), `mock-module:${fromPath}`);
|
|
270852
270912
|
if (exports.default === void 0 && Object.keys(exports.named).length > 0) {
|
|
270853
270913
|
const slots = {};
|
|
270854
270914
|
for (const [k, v2] of Object.entries(exports.named)) slots[k] = { value: v2 };
|
|
@@ -271067,7 +271127,7 @@ function mergeHarvestUnderEnv2(harvestModules, envModules, opts) {
|
|
|
271067
271127
|
}
|
|
271068
271128
|
return out;
|
|
271069
271129
|
}
|
|
271070
|
-
function
|
|
271130
|
+
function collectEvalReplacements2(source) {
|
|
271071
271131
|
const targets = [];
|
|
271072
271132
|
const values = {};
|
|
271073
271133
|
const asTargets = [];
|
|
@@ -271119,12 +271179,12 @@ function collectBPathReplacements2(source) {
|
|
|
271119
271179
|
}
|
|
271120
271180
|
return { targets, values, asTargets, asValues };
|
|
271121
271181
|
}
|
|
271122
|
-
function
|
|
271182
|
+
function isEvalCapable2(source, envNames = []) {
|
|
271123
271183
|
void envNames;
|
|
271124
271184
|
void source;
|
|
271125
271185
|
return true;
|
|
271126
271186
|
}
|
|
271127
|
-
function
|
|
271187
|
+
function evalDepKey2(source, filePath) {
|
|
271128
271188
|
try {
|
|
271129
271189
|
const fp = loadModuleDepsFingerprint(source, defaultLoadModule2, filePath);
|
|
271130
271190
|
if (fp.truncated) return null;
|
|
@@ -271133,29 +271193,29 @@ function bPathDepKey2(source, filePath) {
|
|
|
271133
271193
|
return null;
|
|
271134
271194
|
}
|
|
271135
271195
|
}
|
|
271136
|
-
function
|
|
271137
|
-
const max = getSessionCacheLimits2().
|
|
271196
|
+
function evalCacheSet2(filePath, stableSource, mode, envKey, mockKey, depKey, value) {
|
|
271197
|
+
const max = getSessionCacheLimits2().maxEvalRuns;
|
|
271138
271198
|
if (max <= 0) return;
|
|
271139
|
-
while (
|
|
271140
|
-
const oldest =
|
|
271199
|
+
while (evalRunByFile2.size >= max && !evalRunByFile2.has(filePath)) {
|
|
271200
|
+
const oldest = evalRunByFile2.keys().next().value;
|
|
271141
271201
|
if (oldest === void 0) break;
|
|
271142
|
-
|
|
271202
|
+
evalRunByFile2.delete(oldest);
|
|
271143
271203
|
}
|
|
271144
|
-
|
|
271204
|
+
evalRunByFile2.set(filePath, { stableSource, mode, envKey, mockKey, depKey, value });
|
|
271145
271205
|
}
|
|
271146
|
-
function
|
|
271147
|
-
if (!
|
|
271206
|
+
function tryRunEval2(source, filePath, opts = {}) {
|
|
271207
|
+
if (!isEvalCapable2(source, opts.envNames ?? [])) return void 0;
|
|
271148
271208
|
const mode = opts.mode ?? "analyze";
|
|
271149
271209
|
const envKey = (opts.envNames ?? []).join(",");
|
|
271150
271210
|
const mockKey = mockSeedFingerprint2(opts.mocks);
|
|
271151
271211
|
const stable = stableAnalyzeKeySource(source);
|
|
271152
|
-
const depKey =
|
|
271212
|
+
const depKey = evalDepKey2(source, filePath);
|
|
271153
271213
|
const canCache = depKey !== null;
|
|
271154
271214
|
if (canCache) {
|
|
271155
|
-
const cached2 =
|
|
271215
|
+
const cached2 = evalRunByFile2.get(filePath);
|
|
271156
271216
|
if (cached2 && cached2.stableSource === stable && cached2.mode === mode && cached2.envKey === envKey && cached2.mockKey === mockKey && cached2.depKey === depKey) {
|
|
271157
|
-
|
|
271158
|
-
|
|
271217
|
+
evalRunByFile2.delete(filePath);
|
|
271218
|
+
evalRunByFile2.set(filePath, cached2);
|
|
271159
271219
|
return cached2.value ?? void 0;
|
|
271160
271220
|
}
|
|
271161
271221
|
}
|
|
@@ -271166,14 +271226,14 @@ function tryRunBPath2(source, filePath, opts = {}) {
|
|
|
271166
271226
|
const topCalls = [];
|
|
271167
271227
|
const prevMember = setMemberDiagCollector((d) => memberDiags.push(d));
|
|
271168
271228
|
const prevTrunc = setAbsTruncationCollector((label) => truncated.add(label));
|
|
271169
|
-
const prevCall =
|
|
271229
|
+
const prevCall = setEvalCallCollector((r) => topCalls.push(r));
|
|
271170
271230
|
try {
|
|
271171
271231
|
const { modules: graphMods, issues } = evalAbsModuleGraph2(source, filePath);
|
|
271172
271232
|
const envMods = collectEnvModules2(opts.envNames ?? []);
|
|
271173
271233
|
let modules = mergeHarvestUnderEnv2(graphMods, envMods);
|
|
271174
271234
|
const mm = applyMockModuleDirectivesFromSource2(source, modules, { fromFile: filePath });
|
|
271175
271235
|
modules = mm.modules;
|
|
271176
|
-
const { targets, values, asTargets, asValues } =
|
|
271236
|
+
const { targets, values, asTargets, asValues } = collectEvalReplacements2(source);
|
|
271177
271237
|
const envGlobals = {
|
|
271178
271238
|
...collectEnvGlobals2(opts.envNames ?? []),
|
|
271179
271239
|
...opts.mocks ?? {}
|
|
@@ -271200,23 +271260,23 @@ function tryRunBPath2(source, filePath, opts = {}) {
|
|
|
271200
271260
|
} finally {
|
|
271201
271261
|
setMemberDiagCollector(prevMember);
|
|
271202
271262
|
setAbsTruncationCollector(prevTrunc);
|
|
271203
|
-
|
|
271263
|
+
setEvalCallCollector(prevCall);
|
|
271204
271264
|
}
|
|
271205
271265
|
} catch {
|
|
271206
271266
|
out = null;
|
|
271207
271267
|
}
|
|
271208
271268
|
if (canCache && depKey !== null) {
|
|
271209
|
-
|
|
271269
|
+
evalCacheSet2(filePath, stable, mode, envKey, mockKey, depKey, out);
|
|
271210
271270
|
}
|
|
271211
271271
|
return out ?? void 0;
|
|
271212
271272
|
}
|
|
271213
|
-
function
|
|
271214
|
-
const run =
|
|
271273
|
+
function tryEvalCallFull2(source, filePath, fnName, args, opts = {}) {
|
|
271274
|
+
const run = tryRunEval2(source, filePath, { envNames: opts.envNames, mocks: opts.mocks });
|
|
271215
271275
|
if (!run) return void 0;
|
|
271216
271276
|
if (!(fnName in run.exports)) return void 0;
|
|
271217
271277
|
const collected = [];
|
|
271218
271278
|
const memberDiags = [];
|
|
271219
|
-
const prevCall = opts.collectCalls ?
|
|
271279
|
+
const prevCall = opts.collectCalls ? setEvalCallCollector((r) => collected.push(r)) : void 0;
|
|
271220
271280
|
const wantMember = opts.collectMemberDiags ?? true;
|
|
271221
271281
|
const prevMember = wantMember ? setMemberDiagCollector((d) => memberDiags.push(d)) : void 0;
|
|
271222
271282
|
try {
|
|
@@ -271230,12 +271290,12 @@ function tryBPathCallFull2(source, filePath, fnName, args, opts = {}) {
|
|
|
271230
271290
|
truncatedFns: run.truncatedFns
|
|
271231
271291
|
};
|
|
271232
271292
|
} finally {
|
|
271233
|
-
if (opts.collectCalls)
|
|
271293
|
+
if (opts.collectCalls) setEvalCallCollector(prevCall ?? null);
|
|
271234
271294
|
if (wantMember) setMemberDiagCollector(prevMember ?? null);
|
|
271235
271295
|
}
|
|
271236
271296
|
}
|
|
271237
|
-
function
|
|
271238
|
-
const full =
|
|
271297
|
+
function tryEvalCall2(source, filePath, fnName, args, opts = {}) {
|
|
271298
|
+
const full = tryEvalCallFull2(source, filePath, fnName, args, opts);
|
|
271239
271299
|
if (!full) return void 0;
|
|
271240
271300
|
const r = full.result;
|
|
271241
271301
|
if (!r) return void 0;
|
|
@@ -271429,7 +271489,7 @@ function loadFromMockBinding2(name, fromPath, fromFile, loadModule) {
|
|
|
271429
271489
|
const params = Array.from({ length: fn2.length ?? 0 }, (_, i) => `arg${i}`);
|
|
271430
271490
|
absVal = absFunction(params, {
|
|
271431
271491
|
apply: (args) => callTranspiledExportFull(run, name, args).result,
|
|
271432
|
-
kind: "
|
|
271492
|
+
kind: "eval-export",
|
|
271433
271493
|
fingerprint: `from-mock=${fromPath}#${name}`
|
|
271434
271494
|
});
|
|
271435
271495
|
} else {
|
|
@@ -271683,7 +271743,7 @@ function tryEvalAbsFull2(source, fnName, args, filePath, mocks, assignedName) {
|
|
|
271683
271743
|
if (/\brequire\s*\(/.test(source)) return void 0;
|
|
271684
271744
|
try {
|
|
271685
271745
|
if (filePath) {
|
|
271686
|
-
const viaB =
|
|
271746
|
+
const viaB = tryEvalCallFull2(source, filePath, fnName, args, { mocks }) ?? (assignedName ? tryEvalCallFull2(source, filePath, assignedName, args, { mocks }) : void 0);
|
|
271687
271747
|
if (viaB) {
|
|
271688
271748
|
const r = viaB.result;
|
|
271689
271749
|
if (r && !(r.shape.k === "unknown" && !r.term)) {
|
|
@@ -271978,7 +272038,7 @@ function walkBuiltinUnknown2(node, declared, out, seen, known, parentKey) {
|
|
|
271978
272038
|
}
|
|
271979
272039
|
}
|
|
271980
272040
|
}
|
|
271981
|
-
function
|
|
272041
|
+
function collectEvalDiagnostics2(source, extraKnown) {
|
|
271982
272042
|
let file;
|
|
271983
272043
|
try {
|
|
271984
272044
|
file = parseSource(source);
|
|
@@ -272032,13 +272092,13 @@ function detectEntryVariantsFromPackageJson2(pkg) {
|
|
|
272032
272092
|
const browser = [];
|
|
272033
272093
|
const node = [];
|
|
272034
272094
|
collectExportFaces2(p.exports, browser, node);
|
|
272035
|
-
const
|
|
272036
|
-
if (typeof
|
|
272037
|
-
else if (
|
|
272038
|
-
for (const v2 of Object.values(
|
|
272095
|
+
const evalField = p.browser;
|
|
272096
|
+
if (typeof evalField === "string") browser.push(evalField);
|
|
272097
|
+
else if (evalField && typeof evalField === "object") {
|
|
272098
|
+
for (const v2 of Object.values(evalField)) {
|
|
272039
272099
|
if (typeof v2 === "string") browser.push(v2);
|
|
272040
272100
|
}
|
|
272041
|
-
for (const k of Object.keys(
|
|
272101
|
+
for (const k of Object.keys(evalField)) {
|
|
272042
272102
|
if (k.startsWith(".")) node.push(k);
|
|
272043
272103
|
}
|
|
272044
272104
|
}
|
|
@@ -272305,13 +272365,13 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272305
272365
|
const callSiteBudget = analysisCfg.callSiteBudget;
|
|
272306
272366
|
const callRecords = [];
|
|
272307
272367
|
const globalEnv = createEnvironment();
|
|
272308
|
-
const
|
|
272309
|
-
const
|
|
272368
|
+
const evalMemberDiagNames = /* @__PURE__ */ new Set();
|
|
272369
|
+
const evalMemberDiagSeen = /* @__PURE__ */ new Set();
|
|
272310
272370
|
const pushBMemberDiag = (d, fallbackLine) => {
|
|
272311
|
-
|
|
272371
|
+
evalMemberDiagNames.add(d.name);
|
|
272312
272372
|
const key = `${d.kind}:${d.name}:${d.receiver}:${d.line ?? fallbackLine}:${d.column ?? 0}:${d.code ?? ""}`;
|
|
272313
|
-
if (
|
|
272314
|
-
|
|
272373
|
+
if (evalMemberDiagSeen.has(key)) return;
|
|
272374
|
+
evalMemberDiagSeen.add(key);
|
|
272315
272375
|
if (d.code === "nudo:missing-slot") {
|
|
272316
272376
|
diagnostics.push({
|
|
272317
272377
|
range: {
|
|
@@ -272354,15 +272414,15 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272354
272414
|
}
|
|
272355
272415
|
const selfContained = isSelfContainedSource2(source, envNames);
|
|
272356
272416
|
const canAbsModules = absModulesOk2(source, envNames);
|
|
272357
|
-
const
|
|
272358
|
-
const
|
|
272359
|
-
const
|
|
272360
|
-
const
|
|
272361
|
-
let
|
|
272417
|
+
const evalCapable = isEvalCapable2(source, envNames);
|
|
272418
|
+
const evalModuleIssueKinds = /* @__PURE__ */ new Set();
|
|
272419
|
+
const evalTruncatedFns = /* @__PURE__ */ new Set();
|
|
272420
|
+
const evalBuiltinUnknownNames = /* @__PURE__ */ new Set();
|
|
272421
|
+
let evalHosted = false;
|
|
272362
272422
|
const pushBModuleIssues = (issues) => {
|
|
272363
272423
|
if (!issues) return;
|
|
272364
272424
|
for (const iss of issues) {
|
|
272365
|
-
|
|
272425
|
+
evalModuleIssueKinds.add(iss.kind);
|
|
272366
272426
|
const code2 = iss.kind === "cycle" ? "nudo:module-cycle" : iss.kind === "depth" ? "nudo:module-depth" : "nudo:module-missing";
|
|
272367
272427
|
diagnostics.push({
|
|
272368
272428
|
range: { start: { line: 1, column: 0 }, end: { line: 1, column: 0 } },
|
|
@@ -272389,11 +272449,11 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272389
272449
|
});
|
|
272390
272450
|
}
|
|
272391
272451
|
let absCallRecords = [];
|
|
272392
|
-
let
|
|
272452
|
+
let evalTopCallRecords = [];
|
|
272393
272453
|
let absGraphModules;
|
|
272394
272454
|
let absBindsShared;
|
|
272395
272455
|
let absNodesShared;
|
|
272396
|
-
if (
|
|
272456
|
+
if (evalCapable && filePath) {
|
|
272397
272457
|
try {
|
|
272398
272458
|
const g = evalAbsModuleGraph2(source, filePath, {
|
|
272399
272459
|
seedVars: seeds.seedVars,
|
|
@@ -272417,46 +272477,46 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272417
272477
|
pushBModuleIssues(g.issues);
|
|
272418
272478
|
} catch {
|
|
272419
272479
|
}
|
|
272420
|
-
const
|
|
272480
|
+
const evalRun = tryRunEval2(source, filePath, {
|
|
272421
272481
|
envNames,
|
|
272422
272482
|
mocks: mockSeedsToAbsMocks2(seeds)
|
|
272423
272483
|
});
|
|
272424
|
-
if (
|
|
272425
|
-
|
|
272426
|
-
if (
|
|
272427
|
-
for (const d of
|
|
272484
|
+
if (evalRun) {
|
|
272485
|
+
evalHosted = true;
|
|
272486
|
+
if (evalRun.memberDiags?.length) {
|
|
272487
|
+
for (const d of evalRun.memberDiags) {
|
|
272428
272488
|
pushBMemberDiag(d, 1);
|
|
272429
272489
|
}
|
|
272430
272490
|
}
|
|
272431
|
-
if (
|
|
272432
|
-
for (const fn2 of
|
|
272491
|
+
if (evalRun.truncatedFns) {
|
|
272492
|
+
for (const fn2 of evalRun.truncatedFns) evalTruncatedFns.add(fn2);
|
|
272433
272493
|
}
|
|
272434
|
-
if (
|
|
272494
|
+
if (evalRun.calls?.length) {
|
|
272435
272495
|
const impMap = buildAbsImportLocalMap2(source, filePath);
|
|
272436
|
-
for (const c of
|
|
272437
|
-
|
|
272496
|
+
for (const c of evalRun.calls) {
|
|
272497
|
+
evalTopCallRecords.push(callRecordFromAbsCall2(c, impMap));
|
|
272438
272498
|
}
|
|
272439
272499
|
}
|
|
272440
272500
|
}
|
|
272441
272501
|
}
|
|
272442
|
-
if (
|
|
272502
|
+
if (evalHosted && evalTopCallRecords.length > 0) {
|
|
272443
272503
|
callRecords.length = 0;
|
|
272444
|
-
callRecords.push(...
|
|
272504
|
+
callRecords.push(...evalTopCallRecords);
|
|
272445
272505
|
} else if ((selfContained || canAbsModules) && absCallRecords.length > 0) {
|
|
272446
272506
|
callRecords.length = 0;
|
|
272447
272507
|
callRecords.push(...absCallRecords);
|
|
272448
|
-
} else if (
|
|
272508
|
+
} else if (evalTopCallRecords.length > 0) {
|
|
272449
272509
|
callRecords.length = 0;
|
|
272450
|
-
callRecords.push(...
|
|
272510
|
+
callRecords.push(...evalTopCallRecords);
|
|
272451
272511
|
}
|
|
272452
272512
|
const unreachableRanges = [];
|
|
272453
|
-
if (
|
|
272454
|
-
const
|
|
272513
|
+
if (evalCapable) {
|
|
272514
|
+
const evalKnownGlobals = /* @__PURE__ */ new Set([
|
|
272455
272515
|
...Object.keys(collectEnvGlobals2(envNames)),
|
|
272456
272516
|
...Object.keys(mockSeedsToAbsMocks2(seeds))
|
|
272457
272517
|
]);
|
|
272458
|
-
const
|
|
272459
|
-
for (const ur of
|
|
272518
|
+
const evalDiag = collectEvalDiagnostics2(source, evalKnownGlobals);
|
|
272519
|
+
for (const ur of evalDiag.unreachable) {
|
|
272460
272520
|
diagnostics.push({
|
|
272461
272521
|
range: ur.range,
|
|
272462
272522
|
severity: "info",
|
|
@@ -272466,8 +272526,8 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272466
272526
|
suggestions: ["Remove the unreachable code after the return/throw statement"]
|
|
272467
272527
|
});
|
|
272468
272528
|
}
|
|
272469
|
-
for (const b of
|
|
272470
|
-
|
|
272529
|
+
for (const b of evalDiag.builtinUnknown) {
|
|
272530
|
+
evalBuiltinUnknownNames.add(b.name);
|
|
272471
272531
|
diagnostics.push({
|
|
272472
272532
|
range: b.range,
|
|
272473
272533
|
severity: "warning",
|
|
@@ -272491,7 +272551,7 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272491
272551
|
});
|
|
272492
272552
|
}
|
|
272493
272553
|
}
|
|
272494
|
-
if (!absNodesShared && !
|
|
272554
|
+
if (!absNodesShared && !evalHosted && (selfContained || canAbsModules)) {
|
|
272495
272555
|
try {
|
|
272496
272556
|
const collected = { binds: /* @__PURE__ */ new Map(), nodes: /* @__PURE__ */ new Map() };
|
|
272497
272557
|
if (!absBindsShared) absBindsShared = collected.binds;
|
|
@@ -272500,7 +272560,7 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272500
272560
|
}
|
|
272501
272561
|
}
|
|
272502
272562
|
collectBindings2(ast, globalEnv, bindings, absBindsShared);
|
|
272503
|
-
if (
|
|
272563
|
+
if (isEvalCapable2(source, envNames)) {
|
|
272504
272564
|
try {
|
|
272505
272565
|
const absBinds = absBindsShared ?? collectAbsBindingsFromGraph2(source, filePath, {
|
|
272506
272566
|
seedVars: seeds.seedVars,
|
|
@@ -272631,36 +272691,36 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272631
272691
|
let caseThrowsAbs;
|
|
272632
272692
|
let caseThrowLoc;
|
|
272633
272693
|
let caseUnreachable = [];
|
|
272634
|
-
const
|
|
272635
|
-
const
|
|
272636
|
-
if (
|
|
272694
|
+
const evalCapable2 = isEvalCapable2(source, envNames);
|
|
272695
|
+
const evalPrimary = evalCapable2;
|
|
272696
|
+
if (evalCapable2 && filePath) {
|
|
272637
272697
|
const caseArgsAbs = directive.argsAbs;
|
|
272638
|
-
const
|
|
272698
|
+
const evalFull = tryEvalCallFull2(
|
|
272639
272699
|
source,
|
|
272640
272700
|
filePath,
|
|
272641
272701
|
fn2.name,
|
|
272642
272702
|
caseArgsAbs,
|
|
272643
272703
|
{ collectCalls: true, envNames, mocks: mockSeedsToAbsMocks2(seeds) }
|
|
272644
272704
|
);
|
|
272645
|
-
const res =
|
|
272705
|
+
const res = evalFull?.result;
|
|
272646
272706
|
const weakUnknown = !!res && res.shape.k === "unknown" && (!res.term || res.term.op === "lit" && res.term.value === void 0);
|
|
272647
|
-
const
|
|
272648
|
-
if (
|
|
272649
|
-
caseAbs =
|
|
272650
|
-
caseThrowsAbs =
|
|
272651
|
-
for (const d of
|
|
272707
|
+
const evalOk = !!res && (evalHosted || !weakUnknown && res.conf !== "opaque");
|
|
272708
|
+
if (evalOk && evalFull && evalPrimary) {
|
|
272709
|
+
caseAbs = evalFull.result;
|
|
272710
|
+
caseThrowsAbs = evalFull.throws;
|
|
272711
|
+
for (const d of evalFull.memberDiags ?? []) {
|
|
272652
272712
|
pushBMemberDiag(d, fnLoc.start.line);
|
|
272653
272713
|
}
|
|
272654
|
-
if (
|
|
272714
|
+
if (evalFull.calls?.length) {
|
|
272655
272715
|
const impMap = buildAbsImportLocalMap2(source, filePath);
|
|
272656
|
-
for (const c of
|
|
272716
|
+
for (const c of evalFull.calls) {
|
|
272657
272717
|
callRecords.push(callRecordFromAbsCall2(c, impMap));
|
|
272658
272718
|
}
|
|
272659
272719
|
}
|
|
272660
272720
|
}
|
|
272661
272721
|
}
|
|
272662
272722
|
if (!caseAbs) {
|
|
272663
|
-
if (
|
|
272723
|
+
if (evalHosted) {
|
|
272664
272724
|
caseAbs = unknown;
|
|
272665
272725
|
caseThrowsAbs = neverAbs2;
|
|
272666
272726
|
} else {
|
|
@@ -272733,7 +272793,7 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272733
272793
|
code: "nudo:may-throw"
|
|
272734
272794
|
});
|
|
272735
272795
|
}
|
|
272736
|
-
if (!
|
|
272796
|
+
if (!isEvalCapable2(source, envNames)) {
|
|
272737
272797
|
for (const ur of caseUnreachable) {
|
|
272738
272798
|
diagnostics.push({
|
|
272739
272799
|
range: ur,
|
|
@@ -272895,19 +272955,19 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272895
272955
|
)
|
|
272896
272956
|
);
|
|
272897
272957
|
let symAbs;
|
|
272898
|
-
if (
|
|
272899
|
-
const
|
|
272958
|
+
if (isEvalCapable2(source, envNames) && filePath) {
|
|
272959
|
+
const evalSym = tryEvalCall2(
|
|
272900
272960
|
source,
|
|
272901
272961
|
filePath,
|
|
272902
272962
|
candidate.name,
|
|
272903
272963
|
widenedArgsAbs,
|
|
272904
272964
|
{ envNames, mocks: mockSeedsToAbsMocks2(seeds) }
|
|
272905
272965
|
);
|
|
272906
|
-
if (
|
|
272907
|
-
symAbs =
|
|
272966
|
+
if (evalSym && (evalHosted || !(evalSym.shape.k === "unknown" && !evalSym.term))) {
|
|
272967
|
+
symAbs = evalSym;
|
|
272908
272968
|
}
|
|
272909
272969
|
}
|
|
272910
|
-
if (!symAbs && !
|
|
272970
|
+
if (!symAbs && !evalHosted) {
|
|
272911
272971
|
const absTry = tryEvalAbsRaw2(
|
|
272912
272972
|
source,
|
|
272913
272973
|
candidate.name,
|
|
@@ -272946,30 +273006,30 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
272946
273006
|
const entryEffects = [];
|
|
272947
273007
|
setMayThrowCollector((e) => entryEffects.push(e));
|
|
272948
273008
|
try {
|
|
272949
|
-
if (
|
|
272950
|
-
const
|
|
273009
|
+
if (isEvalCapable2(source, envNames) && filePath) {
|
|
273010
|
+
const evalEntryFull = tryEvalCallFull2(
|
|
272951
273011
|
source,
|
|
272952
273012
|
filePath,
|
|
272953
273013
|
candidate.analysis.name,
|
|
272954
273014
|
argAbsEntry,
|
|
272955
273015
|
{ envNames, mocks: mockSeedsToAbsMocks2(seeds), collectMemberDiags: true }
|
|
272956
|
-
) ?? (candidate.assignedName ?
|
|
273016
|
+
) ?? (candidate.assignedName ? tryEvalCallFull2(source, filePath, candidate.assignedName, argAbsEntry, {
|
|
272957
273017
|
envNames,
|
|
272958
273018
|
mocks: mockSeedsToAbsMocks2(seeds)
|
|
272959
273019
|
}) : void 0);
|
|
272960
|
-
if (
|
|
272961
|
-
for (const d of
|
|
273020
|
+
if (evalEntryFull?.memberDiags?.length) {
|
|
273021
|
+
for (const d of evalEntryFull.memberDiags) {
|
|
272962
273022
|
pushBMemberDiag(d, candidate.analysis.loc.start.line);
|
|
272963
273023
|
}
|
|
272964
273024
|
}
|
|
272965
|
-
const
|
|
272966
|
-
if (
|
|
272967
|
-
entryAbs =
|
|
272968
|
-
if (
|
|
273025
|
+
const evalEntry = evalEntryFull?.result;
|
|
273026
|
+
if (evalEntry && (evalHosted || !(evalEntry.shape.k === "unknown" && !evalEntry.term))) {
|
|
273027
|
+
entryAbs = evalEntry;
|
|
273028
|
+
if (evalEntryFull?.throws) entryThrowsAbs = evalEntryFull.throws;
|
|
272969
273029
|
}
|
|
272970
273030
|
}
|
|
272971
273031
|
if (!entryAbs) {
|
|
272972
|
-
if (
|
|
273032
|
+
if (evalHosted) {
|
|
272973
273033
|
entryAbs = unknown;
|
|
272974
273034
|
entryThrowsAbs = abs({ k: "never" }, void 0, void 0, "exact");
|
|
272975
273035
|
} else {
|
|
@@ -273040,7 +273100,7 @@ function analyzeFileUncachedInner2(filePath, source, activeCases, externalCallRe
|
|
|
273040
273100
|
} catch {
|
|
273041
273101
|
}
|
|
273042
273102
|
}
|
|
273043
|
-
if (!
|
|
273103
|
+
if (!evalHosted) {
|
|
273044
273104
|
buildNodeTypeMap2(ast, globalEnv, nodeAbsMap);
|
|
273045
273105
|
}
|
|
273046
273106
|
const externalFunctions = synthesizeExternalFunctions2(
|
|
@@ -273131,11 +273191,11 @@ function analyzeFile2(filePath, source, activeCases, externalCallRecords, loadMo
|
|
|
273131
273191
|
}
|
|
273132
273192
|
return cloneAnalysisResult2(result);
|
|
273133
273193
|
}
|
|
273134
|
-
var externalRecordIds2, nextExternalRecordId2, ABS_MODULE_CACHE_MAX2, absModuleCache2, ENV_DEPENDENTS_MAX2, ENV_DEPENDENTS_PER_KEY_MAX2, envDependents2, analysisByFile2, fnAnalysisCache2, envHarvestConflictCollector2,
|
|
273135
|
-
var
|
|
273136
|
-
"../service/dist/chunk-
|
|
273194
|
+
var externalRecordIds2, nextExternalRecordId2, ABS_MODULE_CACHE_MAX2, absModuleCache2, ENV_DEPENDENTS_MAX2, ENV_DEPENDENTS_PER_KEY_MAX2, envDependents2, analysisByFile2, fnAnalysisCache2, envHarvestConflictCollector2, evalRunByFile2, neverAbs2, undefAbs4, MAX_RECORD_TYPE_NODES2, KNOWN_GLOBALS2, DEFAULT_CALLSITE_BUDGET3, COLLAPSE_LITERAL_THRESHOLD2;
|
|
273195
|
+
var init_chunk_3IM6NXIF = __esm({
|
|
273196
|
+
"../service/dist/chunk-3IM6NXIF.js"() {
|
|
273137
273197
|
"use strict";
|
|
273138
|
-
|
|
273198
|
+
init_chunk_3RCHDTBX();
|
|
273139
273199
|
init_src2();
|
|
273140
273200
|
init_lib5();
|
|
273141
273201
|
init_src();
|
|
@@ -273173,7 +273233,7 @@ var init_chunk_H2LVQGKH = __esm({
|
|
|
273173
273233
|
analysisByFile2 = /* @__PURE__ */ new Map();
|
|
273174
273234
|
fnAnalysisCache2 = /* @__PURE__ */ new Map();
|
|
273175
273235
|
envHarvestConflictCollector2 = null;
|
|
273176
|
-
|
|
273236
|
+
evalRunByFile2 = /* @__PURE__ */ new Map();
|
|
273177
273237
|
neverAbs2 = { shape: { k: "never" }, conf: "exact" };
|
|
273178
273238
|
undefAbs4 = {
|
|
273179
273239
|
shape: { k: "unknown" },
|
|
@@ -275072,7 +275132,7 @@ function deriveOneRoot(plan, source, file, modules, importLocals, label) {
|
|
|
275072
275132
|
}
|
|
275073
275133
|
const calls = [];
|
|
275074
275134
|
const bCalls = [];
|
|
275075
|
-
const prevCall =
|
|
275135
|
+
const prevCall = setEvalCallCollector((r) => bCalls.push(r));
|
|
275076
275136
|
try {
|
|
275077
275137
|
{
|
|
275078
275138
|
const run = runTranspiled(source, { mode: "analyze", modules });
|
|
@@ -275099,7 +275159,7 @@ function deriveOneRoot(plan, source, file, modules, importLocals, label) {
|
|
|
275099
275159
|
} catch {
|
|
275100
275160
|
return [];
|
|
275101
275161
|
} finally {
|
|
275102
|
-
|
|
275162
|
+
setEvalCallCollector(prevCall);
|
|
275103
275163
|
}
|
|
275104
275164
|
const byCallee = /* @__PURE__ */ new Map();
|
|
275105
275165
|
for (const call of calls) {
|
|
@@ -276079,10 +276139,10 @@ function litOf(t) {
|
|
|
276079
276139
|
function eqLitValue(p) {
|
|
276080
276140
|
if (p.op !== "eq") return "unanchored";
|
|
276081
276141
|
const aLit = litOf(p.a);
|
|
276082
|
-
const
|
|
276142
|
+
const evalLit = litOf(p.b);
|
|
276083
276143
|
if (aLit !== void 0 && (isSelfVar2(p.b) || p.b.op === "app")) return aLit;
|
|
276084
|
-
if (
|
|
276085
|
-
if (aLit !== void 0 &&
|
|
276144
|
+
if (evalLit !== void 0 && (isSelfVar2(p.a) || p.a.op === "app")) return evalLit;
|
|
276145
|
+
if (aLit !== void 0 && evalLit !== void 0) return aLit === evalLit ? aLit : "unanchored";
|
|
276086
276146
|
return "unanchored";
|
|
276087
276147
|
}
|
|
276088
276148
|
function isIntModOne(p) {
|
|
@@ -276545,9 +276605,6 @@ function checkNode(node, value, path, issues) {
|
|
|
276545
276605
|
);
|
|
276546
276606
|
return;
|
|
276547
276607
|
}
|
|
276548
|
-
case "promise": {
|
|
276549
|
-
return;
|
|
276550
|
-
}
|
|
276551
276608
|
default:
|
|
276552
276609
|
return;
|
|
276553
276610
|
}
|
|
@@ -276690,8 +276747,8 @@ var init_emit2 = __esm({
|
|
|
276690
276747
|
"../service/dist/emit/index.js"() {
|
|
276691
276748
|
"use strict";
|
|
276692
276749
|
init_chunk_J2PUE4NV();
|
|
276693
|
-
|
|
276694
|
-
|
|
276750
|
+
init_chunk_3IM6NXIF();
|
|
276751
|
+
init_chunk_3RCHDTBX();
|
|
276695
276752
|
init_src();
|
|
276696
276753
|
init_src();
|
|
276697
276754
|
init_src2();
|
|
@@ -277671,7 +277728,7 @@ async function runAbsView(filePath, opts) {
|
|
|
277671
277728
|
process.exitCode = 1;
|
|
277672
277729
|
return;
|
|
277673
277730
|
}
|
|
277674
|
-
const { defaultLoadModule: loadModule,
|
|
277731
|
+
const { defaultLoadModule: loadModule, tryEvalCall: tryEvalCall3 } = await Promise.resolve().then(() => (init_src4(), src_exports4));
|
|
277675
277732
|
console.log(`nudo check --abs ${basename5(filePath)}`);
|
|
277676
277733
|
if (assumeLines.length > 0) {
|
|
277677
277734
|
console.log(`assume: ${assumeLines.join(", ")}`);
|
|
@@ -277689,8 +277746,8 @@ async function runAbsView(filePath, opts) {
|
|
|
277689
277746
|
continue;
|
|
277690
277747
|
}
|
|
277691
277748
|
const args = algebra.buildArgsFromAssume(source, name, assumeIds);
|
|
277692
|
-
const
|
|
277693
|
-
const result =
|
|
277749
|
+
const evalResult = tryEvalCall3(source, filePath, name, args, { phi: phi2 });
|
|
277750
|
+
const result = evalResult ?? algebra.unknown;
|
|
277694
277751
|
const label = `${name}(${args.map((a) => algebra.formatShape(a)).join(", ")})`;
|
|
277695
277752
|
console.log(algebra.formatAbsMultiline(result, label));
|
|
277696
277753
|
console.log("");
|
|
@@ -277957,7 +278014,7 @@ async function runCheck(file, opts = {}) {
|
|
|
277957
278014
|
let inject;
|
|
277958
278015
|
try {
|
|
277959
278016
|
const graph = evalAbsModuleGraph(source, filePath);
|
|
277960
|
-
const reps =
|
|
278017
|
+
const reps = collectEvalReplacements(source);
|
|
277961
278018
|
const { mockDirectivesToAbsSeeds: mockDirectivesToAbsSeeds3, mockSeedsToAbsMocks: mockSeedsToAbsMocks3 } = await Promise.resolve().then(() => (init_src4(), src_exports4));
|
|
277962
278019
|
const { extractDirectives: extractDirectives2 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|
|
277963
278020
|
const { parse: parse3 } = await Promise.resolve().then(() => (init_src2(), src_exports2));
|