@nudojs/core 1.0.1 → 2.0.1
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/{chunk-P3G2TODS.js → chunk-6REHMIAE.js} +3331 -441
- package/dist/exec.d.ts +1 -1
- package/dist/exec.js +55 -1
- package/dist/{index-FITqyJ8v.d.ts → index-DxjxtxOJ.d.ts} +112 -18
- package/dist/index.d.ts +241 -14
- package/dist/index.js +819 -257
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Abs, P as Phi, a as AstEnv, C as Confidence, b as Pred, S as Shape, T as Term, c as AbsModuleExports, d as PrimName, R as RelSource, H as HofSite } from './index-
|
|
2
|
-
export { $ as $add, e as $arr, f as $
|
|
1
|
+
import { A as Abs, P as Phi, a as AstEnv, C as Confidence, b as Pred, S as Shape, T as Term, c as AbsModuleExports, d as PrimName, R as RelSource, H as HofSite } from './index-DxjxtxOJ.js';
|
|
2
|
+
export { $ as $add, e as $arr, f as $arrMutContainer, g as $arrRest, h as $async, i as $asyncReturn, j as $await, k as $call, l as $callNamed, m as $catchVal, n as $class, o as $concat, p as $div, q as $elems, r as $eq, s as $eqLoose, t as $fnVal, u as $for, v as $forIter, w as $forOf, x as $fork, y as $ge, z as $gen, B as $get, D as $gt, E as $idx, F as $idxSet, G as $invoke, I as $invokeSuper, J as $isForkExit, K as $join, L as $le, M as $len, N as $lit, O as $loopReturn, Q as $lt, U as $mod, V as $mul, W as $ne, X as $neLoose, Y as $neg, Z as $new, _ as $not, a0 as $nullishTest, a1 as $obj, a2 as $objRest, a3 as $optionalGet, a4 as $optionalInvoke, a5 as $orDefault, a6 as $pushLoopExit, a7 as $regex, a8 as $rethrowIfNudoReturn, a9 as $set, aa as $setKey, ab as $spread, ac as $staticInvoke, ad as $sub, ae as $super, af as $switch, ag as $thisGet, ah as $thisSet, ai as $throw, aj as $tryCurrentMark, ak as $tryMark, al as $tryPopMark, am as $tryTakeSince, an as $typeof, ao as $while, ap as $whileSeq, aq as $yield, ar as BCallRecord, as as BClassSpec, at as BMemberDiag, au as DEFAULT_MAX_LOOP_ITERS, av as HofCollectCtx, aw as LiteralValue, ax as NudoReturn, ay as NudoThrow, az as RunTranspiledOptions, aA as TranspileOptions, aB as TranspiledCallResult, aC as abs, aD as absToString, aE as alphaOf, aF as and, aG as anyVar, aH as app, aI as applyCallbackAbs, aJ as asAbs, aK as asAbsVal, aL as betaOf, aM as bindImports, aN as bool, aO as boolLit, aP as callAtFunctionBoundary, aQ as callTranspiledExport, aR as callTranspiledExportFull, aS as clearBClasses, aT as collectAbsExports, aU as confJoin, aV as createHofCollectCtx, aW as currentExecPhi, aX as emptyPhi, aY as eq, aZ as ge, a_ as geNum, a$ as getAbsOrigin, b0 as getBCallCollector, b1 as getBClass, b2 as gt, b3 as gtNum, b4 as implies, b5 as instantiateReturn, b6 as isArrMutator, b7 as isDefinitelyFalse, b8 as isDefinitelyTrue, b9 as isEvalMissingSlotEnabled, ba as isExactLit, bb as isNudoReturn, bc as isNudoThrow, bd as isNumPrim, be as isRelFn, bf as isStrPrim, bg as le, bh as leNum, bi as lit, bj as litTruth, bk as litValue, bl as lt, bm as ltNum, bn as mapElementFallback, bo as namespaceNameOf, bp as ne, bq as never, br as not, bs as noteMemberDispatchMiss, bt as noteObjSlotMissing, bu as notePrimMemberMissing, bv as noteUnknownMemberMissing, bw as num, bx as numLit, by as numVar, bz as obj, bA as or, bB as pFalse, bC as pTrue, bD as phiAnd, bE as predEquals, bF as predToString, bG as predVars, bH as projectFlatMapResult, bI as promoteParamShape, bJ as ptypeof, bK as pushLoopExit, bL as pushThrowExit, bM as recordMemberDiag, bN as registerBClass, bO as runTranspiled, bP as runWithEvalMissingSlot, bQ as runWithLoopExits, bR as setApplyCallbackHost, bS as setBCallCollector, bT as setEvalMissingSlotEnabled, bU as setMemberDiagCollector, bV as shapeOfTerm, bW as shapeToString, bX as simplifyTerm, bY as snapshotAbs, bZ as str, b_ as strLit, b$ as substAbs, c0 as substPred, c1 as substPredAbs, c2 as tagAbsOrigin, c3 as takeLoopExits, c4 as takeThrowExits, c5 as termEquals, c6 as termToString, c7 as transpile, c8 as transpileExpression, c9 as transpileFile, ca as transpileSource, cb as tryPromoteDirectCall, cc as tryPromoteForOfIteratee, cd as tryPromoteHofCallback, ce as tryPromoteReceiverAsArr, cf as undefAbs, cg as unknown, ch as v, ci as withExecPhi } from './index-DxjxtxOJ.js';
|
|
3
3
|
import { Node, File } from '@babel/types';
|
|
4
4
|
|
|
5
5
|
type Environment = {
|
|
@@ -117,6 +117,12 @@ type AbsFnImpl = {
|
|
|
117
117
|
kind?: string;
|
|
118
118
|
/** 调用时直接派发(mock withArgs 等),优先于 body */
|
|
119
119
|
apply?: (args: Abs[]) => Abs;
|
|
120
|
+
/**
|
|
121
|
+
* 对象方法(ObjectMethod / 方法型 FunctionExpression):$invoke 时把
|
|
122
|
+
* receiver 作为 apply 的**首参**注入。shape.params 仍是用户可见形参
|
|
123
|
+
* (不含 receiver),自由调用不注入 → this 为 unbound(JS 语义)。
|
|
124
|
+
*/
|
|
125
|
+
bindThis?: boolean;
|
|
120
126
|
/**
|
|
121
127
|
* Optional content key for cache fingerprints. formatAbs cannot see
|
|
122
128
|
* WeakMap-side mock semantics (returns/withArgs/callsFake), so hosts that
|
|
@@ -223,12 +229,18 @@ declare function negAbs(a: Abs, _phi?: Phi): Abs;
|
|
|
223
229
|
declare function notAbs(a: Abs): Abs;
|
|
224
230
|
/** 该 shape 在 JS 上一定不是 null/undefined */
|
|
225
231
|
declare function definitelyNotNullishShape(s: Shape): boolean;
|
|
232
|
+
/** 仅当 term 确为 lit null/undefined 时为 true;非 lit 的 litValue===undefined 不得当 nullish */
|
|
226
233
|
declare function isNullishLitAbs(a: Abs): boolean;
|
|
227
234
|
/**
|
|
228
235
|
* 严格相等(Abs):双字面量折叠;nullish 与 definitely-not-nullish → false。
|
|
229
236
|
* 返回 undefined = 无法判定(交给 boolean + 调用方)。
|
|
230
237
|
*/
|
|
231
238
|
declare function strictEqAbs(a: Abs, b: Abs): boolean | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* 宽松相等 `==`(C2.3):双 lit 走 Abstract Equality;否则回落严格相等判定。
|
|
241
|
+
* 返回 undefined = 无法判定。
|
|
242
|
+
*/
|
|
243
|
+
declare function looseEqAbs(a: Abs, b: Abs): boolean | undefined;
|
|
232
244
|
|
|
233
245
|
/**
|
|
234
246
|
* Abs 侧常用 builtin:shape 级运算,不依赖 TypeValue host 库。
|
|
@@ -259,6 +271,12 @@ declare function evalPromiseCtor(_args: Abs[]): Abs;
|
|
|
259
271
|
declare function evalPromiseStatic(name: string, args: Abs[]): Abs | undefined;
|
|
260
272
|
/** 命名空间分派入口 */
|
|
261
273
|
declare function evalNamespaceCall(ns: string, method: string, args: Abs[]): Abs | undefined;
|
|
274
|
+
declare function isErrorCtorName(name: string | undefined): boolean;
|
|
275
|
+
/**
|
|
276
|
+
* Error brand:shape 带 name/message(字面量 message 保精确)。
|
|
277
|
+
* $new 与 ast-eval 的 new Error 共用——catch 形参成员访问可解。
|
|
278
|
+
*/
|
|
279
|
+
declare function errorBrandAbs(name: string, messageArg?: Abs): Abs;
|
|
262
280
|
/** new X(...) */
|
|
263
281
|
declare function evalBuiltinNew(className: string, args: Abs[]): Abs | undefined;
|
|
264
282
|
/** brand 实例方法(Date/RegExp/Map/Set) */
|
|
@@ -349,7 +367,7 @@ declare function spread(base: Abs, over: Abs): Abs;
|
|
|
349
367
|
* 同 key 集:槽位级 join(字面量并);异 key 集:保持 sum。
|
|
350
368
|
*/
|
|
351
369
|
declare function joinObjects(a: Abs, b: Abs): Abs;
|
|
352
|
-
/** 值级 join
|
|
370
|
+
/** 值级 join:同型双字面量保留为枚举 sum;其余 prim 同型收成 path */
|
|
353
371
|
declare function joinValues(a: Abs, b: Abs): Abs;
|
|
354
372
|
declare function makeSum(a: Abs, b: Abs): Abs;
|
|
355
373
|
declare function absShapeKey(a: Abs, seen?: Set<object>): string;
|
|
@@ -372,6 +390,86 @@ declare function joinFunctions(a: Abs, b: Abs): Abs;
|
|
|
372
390
|
/** 通用 join:分派到对象/函数/值 */
|
|
373
391
|
declare function joinAbs(a: Abs, b: Abs): Abs;
|
|
374
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Map / Set 字面量条目追踪(C1.1 / C1.2)。
|
|
395
|
+
* 按 Abs 对象身份挂 side table:`m.set("k", v)` 后同 identity 的 `m.get("k")`
|
|
396
|
+
* 可回查。非字面量 key 不入表;get/has 对未知 key 保守回落。
|
|
397
|
+
*/
|
|
398
|
+
|
|
399
|
+
type LitKey = string | number | boolean | null | undefined;
|
|
400
|
+
type MapTable = {
|
|
401
|
+
byLit: Map<LitKey, Abs>;
|
|
402
|
+
/** 非字面量 key 写入的值(get 未知 key 时 join 用) */
|
|
403
|
+
shadowValues: Abs[];
|
|
404
|
+
/** 抽象分支并入后「可能不存在」的字面量键(get/has 需保守) */
|
|
405
|
+
maybeAbsent?: Set<LitKey>;
|
|
406
|
+
};
|
|
407
|
+
type SetTable = {
|
|
408
|
+
elements: Abs[];
|
|
409
|
+
/**
|
|
410
|
+
* fork 后 membership 不确定。
|
|
411
|
+
* - `true`:整表不确定(未知 delete / 非字面量元素混杂)
|
|
412
|
+
* - `Set<LitKey>`:这些字面 key 可能在部分臂缺失(跨臂 delete 不同元素时,长度启发式不够)
|
|
413
|
+
*/
|
|
414
|
+
maybeAbsent?: true | Set<LitKey>;
|
|
415
|
+
};
|
|
416
|
+
/** $fork 抽象分支:每侧独立 overlay,避免身份表被另一侧 set 污染 */
|
|
417
|
+
type ArmOverlay = WeakMap<object, {
|
|
418
|
+
map?: MapTable;
|
|
419
|
+
set?: SetTable;
|
|
420
|
+
}>;
|
|
421
|
+
declare function pushCollectionArm(): void;
|
|
422
|
+
declare function popCollectionArm(): ArmOverlay | undefined;
|
|
423
|
+
/**
|
|
424
|
+
* 合并 fork 各臂 overlay → 全局表(由 endCollectionFork 实现)。
|
|
425
|
+
* 保留导出名以免外部测试/调用点漂移。
|
|
426
|
+
*/
|
|
427
|
+
declare function mergeCollectionArms(arms: Array<ArmOverlay | undefined>): void;
|
|
428
|
+
declare function beginCollectionFork(): void;
|
|
429
|
+
declare function noteCollectionWrite(id: object): void;
|
|
430
|
+
declare function endCollectionFork(arms: Array<ArmOverlay | undefined>): void;
|
|
431
|
+
declare function isMapAbs(a: Abs | undefined): boolean;
|
|
432
|
+
declare function isSetAbs(a: Abs | undefined): boolean;
|
|
433
|
+
declare function makeMapAbs(iterable?: Abs): Abs;
|
|
434
|
+
declare function makeSetAbs(iterable?: Abs): Abs;
|
|
435
|
+
/** Map#set:fork 内写 overlay;否则原地。返回同一 Abs(JS 可变语义) */
|
|
436
|
+
declare function mapSetEntry(mapAbs: Abs, key: Abs | undefined, value: Abs): Abs;
|
|
437
|
+
/** Map#delete:fork overlay 内移除字面量键;未知 key 仅标 shadow 不确定 */
|
|
438
|
+
declare function mapDeleteEntry(mapAbs: Abs, key: Abs | undefined): Abs;
|
|
439
|
+
/** Map#clear:清空条目;fork 下仍走 overlay */
|
|
440
|
+
declare function mapClearEntries(mapAbs: Abs): Abs;
|
|
441
|
+
/** Map#get:命中字面量 key → 精确;miss / 未知 key / maybeAbsent / shadow 并 undefined */
|
|
442
|
+
declare function mapGetEntry(mapAbs: Abs, key: Abs | undefined): Abs;
|
|
443
|
+
/** Map#has:字面量 miss 折 exact false 时,get 必须是 undefined(不可再并 value) */
|
|
444
|
+
declare function mapHasEntry(mapAbs: Abs, key: Abs | undefined): Abs;
|
|
445
|
+
declare function mapSizeAbs(mapAbs: Abs): Abs;
|
|
446
|
+
declare function mapValuesAbs(mapAbs: Abs): Abs[];
|
|
447
|
+
/**
|
|
448
|
+
* Map 迭代条目:JS `for (const [k,v] of map)` / `Array.from(map)` 产出
|
|
449
|
+
* `[key, value]` 元组 Abs。字面量 key 精确;shadow 写入 key 为 unknown。
|
|
450
|
+
*/
|
|
451
|
+
declare function mapEntriesAbs(mapAbs: Abs): Abs[];
|
|
452
|
+
/** Set#add:fork 内写 overlay;返回同一 Abs */
|
|
453
|
+
declare function setAddEntry(setAbs: Abs, value: Abs): Abs;
|
|
454
|
+
/** Set#delete:按字面量元素移除;fork overlay 内生效。
|
|
455
|
+
* 字面量删除且无残留非字面量元素 → 该臂可精确 miss;
|
|
456
|
+
* 臂间分歧由 endCollectionFork 按元素数差标 maybeAbsent。 */
|
|
457
|
+
declare function setDeleteEntry(setAbs: Abs, value: Abs): Abs;
|
|
458
|
+
/** Set#clear */
|
|
459
|
+
declare function setClearEntries(setAbs: Abs): Abs;
|
|
460
|
+
declare function setHasEntry(setAbs: Abs, value: Abs): Abs;
|
|
461
|
+
declare function setSizeAbs(setAbs: Abs): Abs;
|
|
462
|
+
declare function setElementsAbs(setAbs: Abs): Abs[];
|
|
463
|
+
/**
|
|
464
|
+
* 确切条目数:Set 无 maybeAbsent / Map 无 shadow+maybeAbsent 时返回长度;
|
|
465
|
+
* 否则 undefined(for-of 不得假装有界)。
|
|
466
|
+
*/
|
|
467
|
+
declare function collectionExactLen(c: Abs): number | undefined;
|
|
468
|
+
/** 元素联合(for-of / Array.from);无表 → unknown。
|
|
469
|
+
* Map 语义是 entry `[k,v]` 元组联合,不是裸 value。 */
|
|
470
|
+
declare function collectionElementJoin(c: Abs): Abs;
|
|
471
|
+
declare function clearCollectionTables(): void;
|
|
472
|
+
|
|
375
473
|
/**
|
|
376
474
|
* 结构可赋值:src ≤ tgt(Abs 上的 leq)。
|
|
377
475
|
*
|
|
@@ -392,6 +490,8 @@ type LeqResult = {
|
|
|
392
490
|
* src 可赋给 tgt。
|
|
393
491
|
* phi:路径前提(可选);env:用于 brand 继承链。
|
|
394
492
|
*/
|
|
493
|
+
/** Required arity from fn param labels — skips rest (`...`) and optional (`?`). */
|
|
494
|
+
declare function requiredFnArity(params: readonly string[] | undefined): number;
|
|
395
495
|
declare function leqAbs(src: Abs, tgt: Abs, opts?: {
|
|
396
496
|
phi?: Phi;
|
|
397
497
|
env?: AstEnv;
|
|
@@ -472,6 +572,9 @@ type EvalResult = {
|
|
|
472
572
|
* 假分支 fall-through 仍可能走后续语句。evalBlock 需与后续结果 join。
|
|
473
573
|
*/
|
|
474
574
|
partialReturn?: boolean;
|
|
575
|
+
/** 抽象分支可能 throw(另一侧继续)— try 需并 catch 路径 */
|
|
576
|
+
partialThrow?: boolean;
|
|
577
|
+
throwValue?: Abs;
|
|
475
578
|
};
|
|
476
579
|
/**
|
|
477
580
|
* 分析一段 JS 源码。
|
|
@@ -694,6 +797,8 @@ declare function isIntFlag(c: NudoConstraint): boolean;
|
|
|
694
797
|
declare function number(): ConstraintBuilder;
|
|
695
798
|
declare function string(): ConstraintBuilder;
|
|
696
799
|
declare function boolean(): ConstraintBuilder;
|
|
800
|
+
/** any() —— 无约束;formatConstraint / draft import 与显示同源 */
|
|
801
|
+
declare function any(): ConstraintBuilder;
|
|
697
802
|
/** array(item) —— 数组,元素满足 item */
|
|
698
803
|
declare function array(item: NudoConstraint | ConstraintBuilder): ConstraintBuilder;
|
|
699
804
|
/**
|
|
@@ -865,11 +970,15 @@ declare function takeInterfaceDiagsSince(since: number): InterfaceDiag[];
|
|
|
865
970
|
/** 有效契约来源:手写(源码 refine ∪ 侧车手写绑定)> 生成段 > 隐式 */
|
|
866
971
|
type InterfaceSource = "handwritten" | "generated" | "implicit";
|
|
867
972
|
/**
|
|
868
|
-
*
|
|
869
|
-
*
|
|
870
|
-
*
|
|
871
|
-
*
|
|
872
|
-
*
|
|
973
|
+
* 源文件本地导出名表(侧车自动绑定边界):
|
|
974
|
+
* - ESM:`export function/const/let/var/class` 与本地 `export { x }` /
|
|
975
|
+
* `export { local as exported }`(按**导出名**绑定);
|
|
976
|
+
* - `export default function add` / `const add = …; export default add`:
|
|
977
|
+
* 按**本地名** `add` 绑定(侧车可 `export const add = fn(…)`);
|
|
978
|
+
* 同时登记 `"default"`,供侧车 `export default fn(…)` 对齐;
|
|
979
|
+
* - CJS(C4.3):`module.exports = { a, b }`、`module.exports.a = …`、
|
|
980
|
+
* `exports.a = …`、`module.exports = localFn`(登记 localFn 名)。
|
|
981
|
+
* 排除 re-export(`export {x} from` / `export *`)。
|
|
873
982
|
*/
|
|
874
983
|
declare function localNamedExports(source: string): Set<string>;
|
|
875
984
|
/**
|
|
@@ -917,10 +1026,109 @@ declare function effectiveInterface(source: string, fnName: string, opts?: Effec
|
|
|
917
1026
|
declare function sidecarClosureFingerprint(fromFile: string, opts: EffectiveInterfaceOpts): string | undefined;
|
|
918
1027
|
/** 组合式显示:重建构建器调用形态(number().gt(0) / union(…) / fn(…)) */
|
|
919
1028
|
declare function formatConstraint(c: NudoConstraint): string;
|
|
1029
|
+
/** EffectiveInterface → 契约展示串(与 CLI interface 打印同口径,不含函数名) */
|
|
1030
|
+
declare function formatEffectiveInterfaceDisplay(eff: EffectiveInterface): string;
|
|
1031
|
+
/** CodeLens / hover 首行标题(design-refine-derivation §8):`● interface / <source>` */
|
|
1032
|
+
declare function formatInterfaceTierLine(source: InterfaceSource): string;
|
|
1033
|
+
type InterfaceTierInfo = {
|
|
1034
|
+
source: InterfaceSource;
|
|
1035
|
+
/** handwritten/generated 时的契约展示;implicit 为 undefined */
|
|
1036
|
+
display?: string;
|
|
1037
|
+
};
|
|
1038
|
+
type InterfaceTierOpts = EffectiveInterfaceOpts;
|
|
1039
|
+
/**
|
|
1040
|
+
* interface 档单一读取口(A7):CodeLens `● interface`、hover、inlay、
|
|
1041
|
+
* semantic tokens 共用本函数,保证「同源」。
|
|
1042
|
+
*
|
|
1043
|
+
* 与 computeInterfaceLenses 同口径:仅源文件 **本地 named export** 进档;
|
|
1044
|
+
* 私有名 / 非导出 → undefined(不进 interface 档,不假装 implicit 契约)。
|
|
1045
|
+
*/
|
|
1046
|
+
declare function interfaceTierOf(source: string, fnName: string, fromFile: string, opts?: InterfaceTierOpts): InterfaceTierInfo | undefined;
|
|
1047
|
+
/** interfaceTierOf 的来源投影;非导出 → undefined */
|
|
1048
|
+
declare function interfaceSourceOf(source: string, fnName: string, fromFile: string, opts?: InterfaceTierOpts): InterfaceSource | undefined;
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* C4.1:函数形参表面(contract surface)——
|
|
1052
|
+
* 侧车 `fn({…})` / `@nudo:refine` 参数名与求值形参的对齐基线。
|
|
1053
|
+
*
|
|
1054
|
+
* - Identifier / 默认参(AssignmentPattern left)→ 绑定名
|
|
1055
|
+
* - RestElement → 契约名用裸名(`args`),展示名 `...args`
|
|
1056
|
+
* - ObjectPattern / ArrayPattern → 求值占位 `_p{i}`;契约面 = 顶层绑定名
|
|
1057
|
+
* (对象属性 / 数组元素 Identifier)。嵌套 pattern 的绑定名标 `nested`,
|
|
1058
|
+
* 消费方可显式降级(C4.5 param-mismatch / 不执法)。
|
|
1059
|
+
*/
|
|
1060
|
+
type FormalParam = {
|
|
1061
|
+
kind: "id";
|
|
1062
|
+
name: string;
|
|
1063
|
+
index: number;
|
|
1064
|
+
} | {
|
|
1065
|
+
kind: "default";
|
|
1066
|
+
name: string;
|
|
1067
|
+
index: number;
|
|
1068
|
+
} | {
|
|
1069
|
+
kind: "rest";
|
|
1070
|
+
name: string;
|
|
1071
|
+
display: string;
|
|
1072
|
+
index: number;
|
|
1073
|
+
} | {
|
|
1074
|
+
kind: "pattern";
|
|
1075
|
+
/** 求值/签名占位名(generalize 与 dts 用) */
|
|
1076
|
+
placeholder: string;
|
|
1077
|
+
/** 顶层可表达绑定名(侧车契约面) */
|
|
1078
|
+
bound: string[];
|
|
1079
|
+
/**
|
|
1080
|
+
* 契约名 → 对象属性键。rename `{a: b}` 时契约可写 a 或 b,
|
|
1081
|
+
* 投影必须用属性键 a(Abs 对象只有 slot a)。
|
|
1082
|
+
*/
|
|
1083
|
+
propKey: Record<string, string>;
|
|
1084
|
+
/** 仅嵌套内出现、顶层不可单独表达的名(降级用) */
|
|
1085
|
+
nested: string[];
|
|
1086
|
+
index: number;
|
|
1087
|
+
};
|
|
1088
|
+
type AstParam = {
|
|
1089
|
+
type: string;
|
|
1090
|
+
name?: string;
|
|
1091
|
+
left?: AstParam;
|
|
1092
|
+
right?: unknown;
|
|
1093
|
+
argument?: AstParam;
|
|
1094
|
+
properties?: Array<{
|
|
1095
|
+
key?: AstParam;
|
|
1096
|
+
value?: AstParam;
|
|
1097
|
+
type?: string;
|
|
1098
|
+
argument?: AstParam;
|
|
1099
|
+
}>;
|
|
1100
|
+
elements?: Array<AstParam | null | undefined>;
|
|
1101
|
+
};
|
|
1102
|
+
declare function formalParamsFromNodes(params: AstParam[] | undefined | null): FormalParam[];
|
|
1103
|
+
/** 求值/签名用形参名(与 analyzer extractParamNames / dts 对齐) */
|
|
1104
|
+
declare function formalParamDisplayNames(formals: FormalParam[]): string[];
|
|
1105
|
+
/** 侧车契约可绑定的参数名全集 */
|
|
1106
|
+
declare function contractParamNameSet(formals: FormalParam[]): Set<string>;
|
|
1107
|
+
/**
|
|
1108
|
+
* 契约参数名 → 形参定位。
|
|
1109
|
+
* - 命中 id/default/rest → 该 index(执法按整参)
|
|
1110
|
+
* - 命中 pattern 顶层 bound 名 → 该 pattern index + field
|
|
1111
|
+
* - 命中 placeholder / `_` → pattern index(整对象)
|
|
1112
|
+
* - 未命中 → undefined(C4.5 param-mismatch)
|
|
1113
|
+
*/
|
|
1114
|
+
declare function locateContractParam(formals: FormalParam[], contractName: string): {
|
|
1115
|
+
index: number;
|
|
1116
|
+
field?: string;
|
|
1117
|
+
rest?: boolean;
|
|
1118
|
+
} | undefined;
|
|
920
1119
|
|
|
921
1120
|
type LoadDepsFingerprint = {
|
|
922
1121
|
fp: string;
|
|
923
1122
|
paths: string[];
|
|
1123
|
+
/**
|
|
1124
|
+
* path + loadModule-resolved content(miss → null)。调用方(磁盘缓存键)
|
|
1125
|
+
* 必须优先用这里的 content,不得回读磁盘——否则 buffer-aware loadModule
|
|
1126
|
+
* 与磁盘不一致时键会分叉。
|
|
1127
|
+
*/
|
|
1128
|
+
contents: Array<{
|
|
1129
|
+
path: string;
|
|
1130
|
+
content: string | null;
|
|
1131
|
+
}>;
|
|
924
1132
|
/** BFS 撞到节点上限:剩余 dep 未进指纹,键不可信 */
|
|
925
1133
|
truncated: boolean;
|
|
926
1134
|
};
|
|
@@ -958,6 +1166,8 @@ declare function getGeneralizeMemoSize(): number;
|
|
|
958
1166
|
* 返回删除的条目数。路径需与 generalize 时 resolveDepPath 形态一致(建议先 norm)。
|
|
959
1167
|
*/
|
|
960
1168
|
declare function evictGeneralizeMemoForPaths(paths: string[]): number;
|
|
1169
|
+
/** 公开:收集 Abs 自由 term 变元(dts 泛型投影 / α 作用域判定复用 L2 基建)。 */
|
|
1170
|
+
declare function collectAbsFreeVars(a: Abs): Set<string>;
|
|
961
1171
|
type TypeParam = {
|
|
962
1172
|
id: string;
|
|
963
1173
|
value: Abs;
|
|
@@ -974,6 +1184,11 @@ type PolyFn = {
|
|
|
974
1184
|
param: string;
|
|
975
1185
|
pred: Pred;
|
|
976
1186
|
}>;
|
|
1187
|
+
/**
|
|
1188
|
+
* 形参表面(C4.1):默认/rest/解构的契约可绑定名。
|
|
1189
|
+
* 与 params(求值展示名)并列;检查/侧车匹配走 formals。
|
|
1190
|
+
*/
|
|
1191
|
+
formals?: FormalParam[];
|
|
977
1192
|
/**
|
|
978
1193
|
* 函数形参的符号外延(与 typeParams 同 α 空间)。
|
|
979
1194
|
* symbolic 一次跑正常结束时从 env 快照拷出;instantiate 重跑不写。
|
|
@@ -996,6 +1211,7 @@ declare function extractFn(source: string, fnName: string, fileAst?: ReturnType<
|
|
|
996
1211
|
params: string[];
|
|
997
1212
|
body: Node;
|
|
998
1213
|
env: AstEnv;
|
|
1214
|
+
formals: FormalParam[];
|
|
999
1215
|
} | undefined;
|
|
1000
1216
|
declare function generalizeFromAst(fnName: string, source: string, opts?: {
|
|
1001
1217
|
budget?: LeakBudget;
|
|
@@ -1356,7 +1572,12 @@ declare function literalMeetsConstraint(lv: number | string | boolean | null, c:
|
|
|
1356
1572
|
*
|
|
1357
1573
|
* 参数侧只展示显式 `@nudo:refine` 契约(entryReqs)——
|
|
1358
1574
|
* 不从函数体 `if` 反推前置条件(那是控制流,不是对外契约)。
|
|
1575
|
+
*
|
|
1576
|
+
* A7(design-refine-derivation §8):default 走 symbolic + entryReqs;
|
|
1577
|
+
* 与 CodeLens `● interface` 同源——interfaceTierOf 标注来源;
|
|
1578
|
+
* implicit 导出的返回 inlay 标明 `derived`(展示档,非义务契约)。
|
|
1359
1579
|
*/
|
|
1580
|
+
|
|
1360
1581
|
type AbsInlay = {
|
|
1361
1582
|
/** 1-based 行号 */
|
|
1362
1583
|
line: number;
|
|
@@ -1364,16 +1585,22 @@ type AbsInlay = {
|
|
|
1364
1585
|
character: number;
|
|
1365
1586
|
label: string;
|
|
1366
1587
|
kind: "type" | "parameter";
|
|
1588
|
+
/** interface 档来源(与 CodeLens `● interface` 同源);非导出缺省 */
|
|
1589
|
+
interfaceSource?: InterfaceSource;
|
|
1590
|
+
/** true = 隐式推导展示(非义务契约),label 已带 `· derived` */
|
|
1591
|
+
derived?: boolean;
|
|
1592
|
+
};
|
|
1593
|
+
type CollectAbsInlaysOpts = InterfaceTierOpts & {
|
|
1594
|
+
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
1595
|
+
fromFile?: string;
|
|
1367
1596
|
};
|
|
1368
1597
|
/**
|
|
1369
1598
|
* 收集源码中函数签名的 Abs inlay:
|
|
1370
|
-
* - 参数后:仅 `@nudo:refine`
|
|
1599
|
+
* - 参数后:仅 `@nudo:refine` / 侧车显式契约(entryReqs)
|
|
1371
1600
|
* - `{` 前:返回计算形(`x | x * 2`),无 term 时退回 shape
|
|
1601
|
+
* - interface 档:导出函数带 `interfaceSource`;implicit 返回标 `derived`
|
|
1372
1602
|
*/
|
|
1373
|
-
declare function collectAbsInlays(source: string,
|
|
1374
|
-
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
1375
|
-
fromFile?: string;
|
|
1376
|
-
}): AbsInlay[];
|
|
1603
|
+
declare function collectAbsInlays(source: string, opts?: CollectAbsInlaysOpts): AbsInlay[];
|
|
1377
1604
|
|
|
1378
1605
|
/**
|
|
1379
1606
|
* 指称:Abs → 运行时谓词(设计 §2.7)。
|
|
@@ -1568,4 +1795,4 @@ type InjectedDomainEvidenceOpts = {
|
|
|
1568
1795
|
*/
|
|
1569
1796
|
declare function checkInjectedDomainEvidence(fnName: string, source: string, records: InjectedDomainRecord[], opts: InjectedDomainEvidenceOpts): CheckIssue[];
|
|
1570
1797
|
|
|
1571
|
-
export { Abs, type AbsAssignRecord, type AbsCallRecord, type AbsFnImpl, type AbsInlay, AbsModuleExports, type AbsSigImpl, type ArgDerivation, AstEnv, type CheckIssue, type CheckJson, type CheckOptions, type CheckReport, type ClassDef, Confidence, type ConstraintBuilder, type DerivationNode, type Diagnostic, type EffectiveInterface, type EffectiveInterfaceOpts, type Environment, type EvalOptions, type EvalResult, type FnAbs, type FnFp, type FormatOptions, HofSite, type InjectedDomainRecord, type InterfaceDiag, type InterfaceSource, type LeakBudget, type LeqResult, type LoadDepsFingerprint, MAX_CALL_DEPTH, MAX_TOTAL_CALLS, type MethodDef, type MockHelper, type NamedImport, type NudoConstraint, type NudoField, type NudoFnConstraint, NudoSidecarError, type NudoSig, type ObjShape, Phi, type PolyFn, Pred, PrimName, type RefineDiag, type RefineEntry, type RefineResolveOpts, RelSource, SELF, Shape, type Slot, type TemplateMeta, type TemplatePartDesc, type TemplatePartView, type TemplatePredicateDecision, Term, type TypeParam, abortDerivationSession, absFunction, absShapeKey, absTemplateViews, absToConstraint, add, allFixedTextOfViews, analyzeFn, analyzeFnFull, applyAbsFn, array, attachFnImpl, awaitAbs, beginDerivationSession, boolean, buildArgsFromAssume, callAbsMethod, callFunction, callFunctionFull, canSkipLiteralCallScan, checkArg, checkCall, checkInjectedDomainEvidence, checkSource, classFromMethods, cmp, coerceAsyncReturn, collectAbsInlays, collectAbsNodeTypes, concatString, constraintToEntryAbs, createEnvironment, createTemplateAbs, currentPhi, decideEndsWith, decideIncludes, decideStartsWith, defaultLeakBudget, defineClass, definitelyNotNullishShape, denoteGuard, derivationChain, describePhi, div, effectiveInterface, emptyEnv, endDerivationSession, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalMethodBody, evalNamespaceCall, evalNode, evalNumberStatic, evalObjectMethod, evalProgramAbs, evalPromiseCtor, evalPromiseStatic, evalRegExpCtor, evalRegExpMethod, evalSource, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, exceedsBudget, execNudoModule, extractAllLoadSpecs, extractFn, extractNudoImports, extractRefineReturnFromSource, extractRefinesFromSource, falseConstraint, findAbsAtPosition, fixedLengthOfViews, fn, fnConstraintToEntryReqs, fnFingerprints, fnOf, formatAbs, formatAbsMultiline, formatCheckReport, formatConstraint, formatDiagnostics, formatShape, formatShapeSlot, formatTemplateNameViews, generalizeAll, generalizeFromAst, generalizeSourceKeyPart, generatedExportNames, getAbsProperty, getClass, getClassChain, getDerivation, getFnImpl, getFnNameAndBodies, getGeneralizeMemoSize, getParseSourceCacheSize, getSlot, getTerm, hasDerivationSession, hashSource, instanceOf, instantiateClass, instantiateConstraint, interfaceDiagCount, isIntFlag, isNodeModulesPath, isNudoConstraint, isNullishLitAbs, isObj, isTemplateLike, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, knownPrefixOfViews, knownSuffixOfViews, leakIfNeeded, lenTerm, leqAbs, listFunctionNames, literalMeetsConstraint, loadModuleDepsFingerprint, localNamedExports, lookupMethod, lookupMethodWithOwner, lookupSuperMethod, makeSum, matchRelIdentLit, maybeLeak, mergeAdjacentFixedViews, mock, mod, mul, negAbs, normPath, notAbs, noteDerivationAdd, noteDerivationJoin, number, objOf, omit, parseSource, partial, pick, popPhi, projectBrand, projectDerivationDsl, pushPhi, refineAbsForRelTrue, refineDiagCount, refineToIndexedFull, relationFingerprint, relationFn, resetAbsCallBudget, resetCheckSourceMemo, resetFnFpCache, resetGeneralizeMemo, resetHashSourceCache, resetLeakCounter, resetNudoModuleExecCache, resetParseSourceCache, resetPhi, resolveDepPath, serializeCheckJson, setAbsAssignCollector, setAbsCallCollector, setAbsNodeCollector, setAbsTruncationCollector, setDerivation, setDerivationCollector, setInterfaceDiagCollector, setRefineDiagCollector, shape, shapeOnlyFn, sidecarClosureFingerprint, sidecarPathOf, sidecarSpecsOf, spread, spy, stableAnalyzeKeySource, strictEqAbs, string, stripTypes, stub, sub, superNameOf, tagDerivationRoot, takeInterfaceDiags, takeInterfaceDiagsSince, takeRefineDiags, takeRefineDiagsSince, templateMatchesValue, templatePartsOf, termDepth, termKey, termNodes, trueConstraint, typeofAbs, union, viewTemplateParts, withPhiConstraint, withVar, wrapPromise };
|
|
1798
|
+
export { Abs, type AbsAssignRecord, type AbsCallRecord, type AbsFnImpl, type AbsInlay, AbsModuleExports, type AbsSigImpl, type ArgDerivation, AstEnv, type CheckIssue, type CheckJson, type CheckOptions, type CheckReport, type ClassDef, type CollectAbsInlaysOpts, Confidence, type ConstraintBuilder, type DerivationNode, type Diagnostic, type EffectiveInterface, type EffectiveInterfaceOpts, type Environment, type EvalOptions, type EvalResult, type FnAbs, type FnFp, type FormalParam, type FormatOptions, HofSite, type InjectedDomainRecord, type InterfaceDiag, type InterfaceSource, type InterfaceTierInfo, type InterfaceTierOpts, type LeakBudget, type LeqResult, type LoadDepsFingerprint, MAX_CALL_DEPTH, MAX_TOTAL_CALLS, type MethodDef, type MockHelper, type NamedImport, type NudoConstraint, type NudoField, type NudoFnConstraint, NudoSidecarError, type NudoSig, type ObjShape, Phi, type PolyFn, Pred, PrimName, type RefineDiag, type RefineEntry, type RefineResolveOpts, RelSource, SELF, Shape, type Slot, type TemplateMeta, type TemplatePartDesc, type TemplatePartView, type TemplatePredicateDecision, Term, type TypeParam, abortDerivationSession, absFunction, absShapeKey, absTemplateViews, absToConstraint, add, allFixedTextOfViews, analyzeFn, analyzeFnFull, any, applyAbsFn, array, attachFnImpl, awaitAbs, beginCollectionFork, beginDerivationSession, boolean, buildArgsFromAssume, callAbsMethod, callFunction, callFunctionFull, canSkipLiteralCallScan, checkArg, checkCall, checkInjectedDomainEvidence, checkSource, classFromMethods, clearCollectionTables, cmp, coerceAsyncReturn, collectAbsFreeVars, collectAbsInlays, collectAbsNodeTypes, collectionElementJoin, collectionExactLen, concatString, constraintToEntryAbs, contractParamNameSet, createEnvironment, createTemplateAbs, currentPhi, decideEndsWith, decideIncludes, decideStartsWith, defaultLeakBudget, defineClass, definitelyNotNullishShape, denoteGuard, derivationChain, describePhi, div, effectiveInterface, emptyEnv, endCollectionFork, endDerivationSession, errorBrandAbs, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalMethodBody, evalNamespaceCall, evalNode, evalNumberStatic, evalObjectMethod, evalProgramAbs, evalPromiseCtor, evalPromiseStatic, evalRegExpCtor, evalRegExpMethod, evalSource, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, exceedsBudget, execNudoModule, extractAllLoadSpecs, extractFn, extractNudoImports, extractRefineReturnFromSource, extractRefinesFromSource, falseConstraint, findAbsAtPosition, fixedLengthOfViews, fn, fnConstraintToEntryReqs, fnFingerprints, fnOf, formalParamDisplayNames, formalParamsFromNodes, formatAbs, formatAbsMultiline, formatCheckReport, formatConstraint, formatDiagnostics, formatEffectiveInterfaceDisplay, formatInterfaceTierLine, formatShape, formatShapeSlot, formatTemplateNameViews, generalizeAll, generalizeFromAst, generalizeSourceKeyPart, generatedExportNames, getAbsProperty, getClass, getClassChain, getDerivation, getFnImpl, getFnNameAndBodies, getGeneralizeMemoSize, getParseSourceCacheSize, getSlot, getTerm, hasDerivationSession, hashSource, instanceOf, instantiateClass, instantiateConstraint, interfaceDiagCount, interfaceSourceOf, interfaceTierOf, isErrorCtorName, isIntFlag, isMapAbs, isNodeModulesPath, isNudoConstraint, isNullishLitAbs, isObj, isSetAbs, isTemplateLike, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, knownPrefixOfViews, knownSuffixOfViews, leakIfNeeded, lenTerm, leqAbs, listFunctionNames, literalMeetsConstraint, loadModuleDepsFingerprint, localNamedExports, locateContractParam, lookupMethod, lookupMethodWithOwner, lookupSuperMethod, looseEqAbs, makeMapAbs, makeSetAbs, makeSum, mapClearEntries, mapDeleteEntry, mapEntriesAbs, mapGetEntry, mapHasEntry, mapSetEntry, mapSizeAbs, mapValuesAbs, matchRelIdentLit, maybeLeak, mergeAdjacentFixedViews, mergeCollectionArms, mock, mod, mul, negAbs, normPath, notAbs, noteCollectionWrite, noteDerivationAdd, noteDerivationJoin, number, objOf, omit, parseSource, partial, pick, popCollectionArm, popPhi, projectBrand, projectDerivationDsl, pushCollectionArm, pushPhi, refineAbsForRelTrue, refineDiagCount, refineToIndexedFull, relationFingerprint, relationFn, requiredFnArity, resetAbsCallBudget, resetCheckSourceMemo, resetFnFpCache, resetGeneralizeMemo, resetHashSourceCache, resetLeakCounter, resetNudoModuleExecCache, resetParseSourceCache, resetPhi, resolveDepPath, serializeCheckJson, setAbsAssignCollector, setAbsCallCollector, setAbsNodeCollector, setAbsTruncationCollector, setAddEntry, setClearEntries, setDeleteEntry, setDerivation, setDerivationCollector, setElementsAbs, setHasEntry, setInterfaceDiagCollector, setRefineDiagCollector, setSizeAbs, shape, shapeOnlyFn, sidecarClosureFingerprint, sidecarPathOf, sidecarSpecsOf, spread, spy, stableAnalyzeKeySource, strictEqAbs, string, stripTypes, stub, sub, superNameOf, tagDerivationRoot, takeInterfaceDiags, takeInterfaceDiagsSince, takeRefineDiags, takeRefineDiagsSince, templateMatchesValue, templatePartsOf, termDepth, termKey, termNodes, trueConstraint, typeofAbs, union, viewTemplateParts, withPhiConstraint, withVar, wrapPromise };
|