@nudojs/core 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/check-report-AtnAfY9U.d.ts +661 -0
- package/dist/chunk-MA2QEIYC.js +15030 -0
- package/dist/chunk-US532PZA.js +0 -0
- package/dist/chunk-ZUQXJRJL.js +4923 -0
- package/dist/exec.d.ts +2 -1
- package/dist/exec.js +170 -15
- package/dist/hof-types-tAeoYvzY.d.ts +368 -0
- package/dist/index-B7Lb8FU6.d.ts +726 -0
- package/dist/index.d.ts +685 -1103
- package/dist/index.js +1751 -5753
- package/dist/internal.d.ts +541 -0
- package/dist/internal.js +583 -0
- package/package.json +13 -8
- package/dist/chunk-RZOQL6PT.js +0 -7369
- package/dist/index-OfNo5qlN.d.ts +0 -761
package/dist/index.d.ts
CHANGED
|
@@ -1,195 +1,59 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { c as AstEnv, A as Abs, b as Phi, C as Confidence, T as Term, H as HofCollectCtx, S as Shape, a as Pred, R as RelSource, w as HofSite } from './hof-types-tAeoYvzY.js';
|
|
2
|
+
export { I as ImplicationOracle, L as LiteralValue, P as PrimName, x as TYPEOF_NAMES, y as TypeofName, z as abs, B as absToString, D as and, F as anyAbs, G as anyVar, J as app, K as bigintLit, N as bool, O as boolLit, Q as confJoin, U as emptyPhi, V as eq, W as ge, X as geNum, Y as getImplicationOracle, Z as gt, _ as gtNum, a0 as implies, a1 as isBigPrim, a2 as isExactLit, a3 as isNumPrim, a4 as isStrPrim, a5 as le, a6 as leNum, a7 as lit, a8 as litValue, a9 as lt, aa as ltNum, ab as ne, ac as negatePred, ad as never, ae as not, af as num, ag as numLit, ah as numVar, ai as obj, aj as or, ak as pFalse, al as pTrue, am as phiAnd, an as predEquals, ao as predToString, ap as predVars, aq as primToTypeof, ar as ptypeof, as as setImplicationOracle, at as shapeOfTerm, au as shapeToString, av as simplifyTerm, aw as str, ax as strLit, ay as substPred, az as termEquals, aA as termToString, aB as unknown, aC as v } from './hof-types-tAeoYvzY.js';
|
|
3
|
+
import { Node } from '@babel/types';
|
|
4
|
+
import { p as parseSource, L as LeakBudget, E as EffectiveInterfaceOpts, b as LoadDepsFingerprint, i as CheckReport, N as NudoConstraint } from './check-report-AtnAfY9U.js';
|
|
5
|
+
export { j as CheckAction, C as CheckIssue, k as CheckJson, o as CheckJsonMulti, q as ConstraintBuilder, D as Diagnostic, u as EffectiveInterface, G as GitlabCodeQualityIssue, v as InterfaceDiag, I as InterfaceSource, w as InterfaceTierInfo, a as InterfaceTierOpts, x as NamedImport, y as NudoField, z as NudoFnConstraint, A as NudoSidecarError, B as NudoSig, R as RefineDiag, F as RefineEntry, H as RefineResolveOpts, S as SELF, J as actionsForIssue, K as andC, M as any, O as array, P as boolean, Q as checkArg, T as checkCall, U as constraintToEntryAbs, V as effectiveInterface, W as execNudoModule, X as extractDeclaredThrows, Y as extractNudoImports, Z as extractRefineReturnFromSource, _ as extractRefinesFromSource, $ as fn, a0 as fnConstraintToEntryReqs, a1 as formatCheckReport, a2 as formatConstraint, a3 as formatDiagnostics, a4 as formatEffectiveInterfaceDisplay, a5 as formatGithubAnnotations, a6 as formatGitlabCodeQuality, a7 as formatInterfaceTierLine, a8 as generatedExportNames, a9 as getParseSourceCacheSize, aa as getTerm, ab as instantiateConstraint, ac as interfaceDiagCount, ad as interfaceSourceOf, ae as interfaceTierOf, af as isIntFlag, ag as isNodeModulesPath, ah as isNudoConstraint, ai as lenTerm, aj as litC, ak as localNamedExports, al as number, am as omit, an as partial, ao as pick, ap as refineDiagCount, aq as refineToIndexedFull, ar as resetNudoModuleExecCache, as as resetParseSourceCache, at as serializeCheckJson, au as serializeCheckJsonMulti, av as setInterfaceDiagCollector, aw as setRefineDiagCollector, ax as shape, ay as sidecarClosureFingerprint, az as sidecarPathOf, aA as string, aB as takeInterfaceDiags, aC as takeInterfaceDiagsSince, aD as takeRefineDiags, aE as takeRefineDiagsSince, aF as throwConstraintToKinds, aG as union } from './check-report-AtnAfY9U.js';
|
|
6
|
+
import { A as AbsModuleExports, R as RunTranspiledOptions } from './index-B7Lb8FU6.js';
|
|
7
|
+
export { $ as $add, a as $arguments, b as $arr, c as $arrMutContainer, d as $arrRest, e as $arrWithHoles, f as $assignRecord, g as $async, h as $asyncReturn, i as $await, j as $bitand, k as $bitnot, l as $bitor, m as $bitxor, n as $call, o as $callNamed, p as $catchVal, q as $class, r as $classExpr, s as $collectionForEach, t as $concat, u as $copy, v as $del, w as $delRes, x as $div, y as $dynamicImport, z as $elems, B as $eq, C as $eqLoose, D as $fnVal, E as $for, F as $forInKeys, G as $forIter, H as $forOf, I as $fork, J as $ge, K as $gen, L as $get, M as $gt, N as $idx, O as $idxSet, P as $importMeta, Q as $in, S as $instanceof, T as $instanceofNonIdent, U as $invoke, V as $invokeSuper, W as $isBreakTo, X as $isForkExit, Y as $join, Z as $le, _ as $len, a0 as $lit, a1 as $loopBreak, a2 as $loopContinue, a3 as $loopReturn, a4 as $lt, a5 as $mod, a6 as $mul, a7 as $ne, a8 as $neLoose, a9 as $neg, aa as $new, ab as $not, ac as $nullishTest, ad as $obj, ae as $objAccessor, af as $objRest, ag as $optionalGet, ah as $optionalInvoke, ai as $orDefault, aj as $pow, ak as $pushLoopExit, al as $rawThis, am as $reStateCall, an as $recordBinding, ao as $regex, ap as $rethrowIfNudoReturn, aq as $set, ar as $setKey, as as $shl, at as $shr, au as $spread, av as $staticInvoke, aw as $sub, ax as $super, ay as $switch, az as $thisGet, aA as $thisSet, aB as $throw, aC as $toNumber, aD as $tryCurrentMark, aE as $tryDetachSoftCatch, aF as $tryDigestSoftCatch, aG as $tryDiscardSoft, aH as $tryMark, aI as $tryOrphanSoft, aJ as $tryPopMark, aK as $tryReleaseSoftCatch, aL as $tryReleaseSoftOut, aM as $tryTakeSince, aN as $typeof, aO as $unknown, aP as $ushr, aQ as $while, aR as $whileSeq, aS as $yield, aT as BAbsAssignRecord, aU as BCallRecord, aV as BClassSpec, aW as BPathFallback, aX as DEFAULT_MAX_LOOP_ITERS, aY as MAX_B_CALL_DEPTH, aZ as MAX_B_TOTAL_CALLS, a_ as NudoLoopSignal, a$ as NudoReturn, b0 as NudoThrow, b1 as NudoUnsupportedError, b2 as RUNTIME_IMPORT_RE, b3 as TranspileOptions, b4 as TranspiledCallResult, b5 as asAbsVal, b6 as bindImports, b7 as bindingsOf, b8 as callAtFunctionBoundary, b9 as callTranspiledExport, ba as callTranspiledExportFull, bb as clearBClasses, bc as clearStaleTermPred, bd as collectAbsExports, be as currentExecPhi, bf as evalExprAbs, bg as fillTuple, bh as foldRequireSpecArg, bi as foldStaticStringExpr, bj as getBCallCollector, bk as getBClass, bl as isArrMutator, bm as isDefinitelyFalse, bn as isDefinitelyTrue, bo as isNudoBreak, bp as isNudoContinue, bq as isNudoReturn, br as isNudoThrow, bs as litTruth, bt as lookupObjAccessor, bu as namespaceNameOf, bv as noteBCallRecord, bw as noteBPathFallback, bx as pushLoopExit, by as pushThrowExit, bz as registerBClass, bA as resetBCallBudget, bB as runTranspiled, bC as runTranspiledOptionsMemoKey, bD as runWithLoopExits, bE as runtimeImportOf, bF as setBAssignCollector, bG as setBBindingSink, bH as setBCallCollector, bI as setBPathFallbackCollector, bJ as takeLoopExits, bK as takeThrowExits, bL as transpile, bM as transpileBodyNode, bN as transpileExpression, bO as transpileFile, bP as transpileSource, bQ as tryRunTranspiled, bR as withExecPhi } from './index-B7Lb8FU6.js';
|
|
4
8
|
|
|
5
|
-
type Environment = {
|
|
6
|
-
lookup(name: string): TypeValue;
|
|
7
|
-
bind(name: string, value: TypeValue): Environment;
|
|
8
|
-
update(name: string, value: TypeValue): boolean;
|
|
9
|
-
extend(bindings: Record<string, TypeValue>): Environment;
|
|
10
|
-
fork(): Environment;
|
|
11
|
-
has(name: string): boolean;
|
|
12
|
-
snapshot(): Environment;
|
|
13
|
-
getOwnBindings(): Record<string, TypeValue>;
|
|
14
|
-
};
|
|
15
|
-
declare function createEnvironment(parent?: Environment, bindings?: Map<string, TypeValue>): Environment;
|
|
16
|
-
|
|
17
|
-
type LiteralValue = string | number | boolean | bigint | null | undefined;
|
|
18
|
-
type SigImpl = (args: TypeValue[], thisVal?: TypeValue) => TypeValue | undefined;
|
|
19
|
-
type FunctionSignature = {
|
|
20
|
-
paramTypes: TypeValue[];
|
|
21
|
-
returnType: TypeValue;
|
|
22
|
-
throwsType: TypeValue;
|
|
23
|
-
impl?: SigImpl;
|
|
24
|
-
};
|
|
25
|
-
type Refinement = {
|
|
26
|
-
name: string;
|
|
27
|
-
meta: Record<string, unknown>;
|
|
28
|
-
check?: (value: unknown) => boolean;
|
|
29
|
-
ops?: Record<string, (self: TypeValue, other: TypeValue) => TypeValue | undefined>;
|
|
30
|
-
methods?: Record<string, (self: TypeValue, args: TypeValue[]) => TypeValue | undefined>;
|
|
31
|
-
properties?: Record<string, (self: TypeValue) => TypeValue | undefined>;
|
|
32
|
-
};
|
|
33
|
-
type TypeValue = {
|
|
34
|
-
kind: "literal";
|
|
35
|
-
value: LiteralValue;
|
|
36
|
-
} | {
|
|
37
|
-
kind: "primitive";
|
|
38
|
-
type: "number" | "string" | "boolean" | "bigint" | "symbol";
|
|
39
|
-
} | {
|
|
40
|
-
kind: "refined";
|
|
41
|
-
base: TypeValue;
|
|
42
|
-
refinement: Refinement;
|
|
43
|
-
} | {
|
|
44
|
-
kind: "object";
|
|
45
|
-
properties: Record<string, TypeValue>;
|
|
46
|
-
id: symbol;
|
|
47
|
-
} | {
|
|
48
|
-
kind: "array";
|
|
49
|
-
element: TypeValue;
|
|
50
|
-
} | {
|
|
51
|
-
kind: "tuple";
|
|
52
|
-
elements: TypeValue[];
|
|
53
|
-
} | {
|
|
54
|
-
kind: "function";
|
|
55
|
-
params: string[];
|
|
56
|
-
body: Node;
|
|
57
|
-
closure: Environment;
|
|
58
|
-
} | {
|
|
59
|
-
kind: "promise";
|
|
60
|
-
value: TypeValue;
|
|
61
|
-
} | {
|
|
62
|
-
kind: "instance";
|
|
63
|
-
className: string;
|
|
64
|
-
properties: Record<string, TypeValue>;
|
|
65
|
-
} | {
|
|
66
|
-
kind: "union";
|
|
67
|
-
members: TypeValue[];
|
|
68
|
-
} | {
|
|
69
|
-
kind: "never";
|
|
70
|
-
} | {
|
|
71
|
-
kind: "unknown";
|
|
72
|
-
};
|
|
73
|
-
declare function createUnion(...members: TypeValue[]): TypeValue;
|
|
74
|
-
declare const T: {
|
|
75
|
-
readonly literal: (value: LiteralValue) => TypeValue;
|
|
76
|
-
readonly number: TypeValue;
|
|
77
|
-
readonly string: TypeValue;
|
|
78
|
-
readonly boolean: TypeValue;
|
|
79
|
-
readonly bigint: TypeValue;
|
|
80
|
-
readonly symbol: TypeValue;
|
|
81
|
-
readonly null: TypeValue;
|
|
82
|
-
readonly undefined: TypeValue;
|
|
83
|
-
readonly unknown: TypeValue;
|
|
84
|
-
readonly never: TypeValue;
|
|
85
|
-
readonly object: (properties: Record<string, TypeValue>) => TypeValue;
|
|
86
|
-
readonly array: (element: TypeValue) => TypeValue;
|
|
87
|
-
readonly tuple: (elements: TypeValue[]) => TypeValue;
|
|
88
|
-
readonly promise: (value: TypeValue) => TypeValue;
|
|
89
|
-
readonly instanceOf: (className: string, properties?: Record<string, TypeValue>) => TypeValue;
|
|
90
|
-
readonly union: typeof createUnion;
|
|
91
|
-
readonly fn: (params: string[], body: Node, closure: Environment) => TypeValue;
|
|
92
|
-
readonly refine: (base: TypeValue, refinement: Refinement) => TypeValue;
|
|
93
|
-
readonly fnSig: (paramTypes: TypeValue[], returnType: TypeValue, throwsType?: TypeValue, impl?: SigImpl) => TypeValue;
|
|
94
|
-
};
|
|
95
|
-
declare function typeValueEquals(a: TypeValue, b: TypeValue): boolean;
|
|
96
|
-
declare function simplifyUnion(members: TypeValue[]): TypeValue;
|
|
97
|
-
declare function widenLiteral(tv: TypeValue): TypeValue;
|
|
98
9
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* (3 | number → number),再对剩余的纯字面量联合做阈值坍缩(1|2|…|20 → number)。
|
|
104
|
-
* 两步不冲突也不重复:吸收只删基类型已在场的字面量,阈值坍缩只处理无基类型
|
|
105
|
-
* 在场的纯字面量联合。
|
|
106
|
-
*/
|
|
107
|
-
declare function collapseLiteralUnion(tv: TypeValue, maxLiterals: number): TypeValue;
|
|
108
|
-
declare function isSubtypeOf(a: TypeValue, b: TypeValue): boolean;
|
|
109
|
-
declare function deepCloneTypeValue(tv: TypeValue, idMap?: Map<symbol, symbol>): TypeValue;
|
|
110
|
-
declare function mergeObjectProperties(a: TypeValue & {
|
|
111
|
-
kind: "object";
|
|
112
|
-
}, b: TypeValue & {
|
|
113
|
-
kind: "object";
|
|
114
|
-
}): TypeValue;
|
|
115
|
-
declare function typeValueToString(tv: TypeValue): string;
|
|
116
|
-
declare function narrowType(tv: TypeValue, predicate: (member: TypeValue) => boolean): TypeValue;
|
|
117
|
-
declare function subtractType(tv: TypeValue, predicate: (member: TypeValue) => boolean): TypeValue;
|
|
118
|
-
declare function getPrimitiveTypeOf(tv: TypeValue): string | undefined;
|
|
119
|
-
declare function getRefinedBase(tv: TypeValue): TypeValue;
|
|
120
|
-
declare function isFnSig(tv: TypeValue): boolean;
|
|
121
|
-
declare function getFnSig(tv: TypeValue): FunctionSignature | undefined;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 残差 IR 兜底(不是类型运算真理源)。
|
|
125
|
-
*
|
|
126
|
-
* 真理在 algebra:算术/比较/相等/typeof/!/−/字符串词法序/nullish 均走 Abs。
|
|
127
|
-
* 这里只保留:
|
|
128
|
-
* - add:代数拒绝时的混合 `+`
|
|
129
|
-
* - 比较/相等:代数无法判定时的保守 boolean / 字面量折叠
|
|
130
|
-
* - dispatchMethod/Property:宿主 refined 扩展(startsWith、length…)
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
declare const Ops: {
|
|
134
|
-
readonly add: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
135
|
-
readonly strictEq: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
136
|
-
readonly strictNeq: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
137
|
-
readonly gt: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
138
|
-
readonly lt: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
139
|
-
readonly gte: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
140
|
-
readonly lte: (left: TypeValue, right: TypeValue) => TypeValue;
|
|
141
|
-
readonly not: (operand: TypeValue) => TypeValue;
|
|
142
|
-
};
|
|
143
|
-
declare function applyBinaryOp(op: string, left: TypeValue, right: TypeValue): TypeValue;
|
|
144
|
-
declare function dispatchBinaryOp(op: string, left: TypeValue, right: TypeValue): TypeValue;
|
|
145
|
-
declare function dispatchMethod(receiver: TypeValue, name: string, args: TypeValue[]): TypeValue | undefined;
|
|
146
|
-
declare function dispatchProperty(receiver: TypeValue, name: string): TypeValue | undefined;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 模板字面量谓词,独立于 template.ts 以断开运行时循环引用:
|
|
150
|
-
* type-value.ts(联合吸收律)与 template.ts 都依赖本模块,而本模块对
|
|
151
|
-
* type-value.ts 只有 `import type` 边(编译后消失),运行时依赖保持单向
|
|
152
|
-
* type-value.ts / template.ts -> template-predicates.ts。
|
|
10
|
+
* AstEnv:抽象求值环境类型面(ast-eval 删除后保留)。
|
|
11
|
+
* 类型定义在 hof-types.ts(打破 ast-env ↔ hof ↔ abs-fn 类型环);
|
|
12
|
+
* 本文件保留空环境 / withVar 的便捷构造并重导出 AstEnv 供稳定路径导入。
|
|
13
|
+
* 仍被 B 路径 check / leq / generalize / builtins 消费。
|
|
153
14
|
*/
|
|
154
|
-
declare function isTemplate(tv: TypeValue): boolean;
|
|
155
|
-
|
|
156
|
-
declare function createTemplate(parts: TypeValue[]): TypeValue;
|
|
157
15
|
|
|
158
|
-
|
|
159
|
-
declare function
|
|
16
|
+
/** 空求值环境(分析宿主用:不带任何绑定) */
|
|
17
|
+
declare function emptyEnv(): AstEnv;
|
|
18
|
+
declare function withVar(env: AstEnv, name: string, value: Abs): AstEnv;
|
|
160
19
|
|
|
161
|
-
type
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
20
|
+
type Environment = {
|
|
21
|
+
lookup(name: string): Abs;
|
|
22
|
+
bind(name: string, value: Abs): Environment;
|
|
23
|
+
update(name: string, value: Abs): boolean;
|
|
24
|
+
extend(bindings: Record<string, Abs>): Environment;
|
|
25
|
+
fork(): Environment;
|
|
26
|
+
has(name: string): boolean;
|
|
27
|
+
snapshot(): Environment;
|
|
28
|
+
getOwnBindings(): Record<string, Abs>;
|
|
169
29
|
};
|
|
170
|
-
declare function
|
|
171
|
-
declare function isRange(tv: TypeValue): boolean;
|
|
172
|
-
declare function getRangeMeta(tv: TypeValue): RangeMeta | undefined;
|
|
30
|
+
declare function createEnvironment(parent?: Environment, bindings?: Map<string, Abs>): Environment;
|
|
173
31
|
|
|
174
32
|
/**
|
|
175
33
|
* Nudo Mock 帮助函数
|
|
176
34
|
*
|
|
177
|
-
* 提供类型安全的 mock 创建,替代 sinon
|
|
35
|
+
* 提供类型安全的 mock 创建,替代 sinon 表达式。
|
|
36
|
+
* 值字段为 Abs(类型系统真理源)。
|
|
37
|
+
* Abs 路径经 mock-abs.ts / mockDirectivesToAbsSeeds 消费。
|
|
178
38
|
*/
|
|
179
39
|
|
|
180
40
|
type MockHelper = {
|
|
181
41
|
kind: "mock-helper";
|
|
182
|
-
returnValue?:
|
|
183
|
-
resolvedValue?:
|
|
184
|
-
rejectedValue?:
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
onSecondCallValue?: TypeValue;
|
|
42
|
+
returnValue?: Abs;
|
|
43
|
+
resolvedValue?: Abs;
|
|
44
|
+
rejectedValue?: Abs;
|
|
45
|
+
onFirstCallValue?: Abs;
|
|
46
|
+
onSecondCallValue?: Abs;
|
|
188
47
|
withArgsCases?: {
|
|
189
|
-
args:
|
|
190
|
-
returnValue:
|
|
48
|
+
args: Abs[];
|
|
49
|
+
returnValue: Abs;
|
|
191
50
|
}[];
|
|
192
|
-
|
|
51
|
+
/** callsFake 的函数体(AST);params 同步存下供 Abs absFunction */
|
|
52
|
+
callsFakeImpl?: {
|
|
53
|
+
params: string[];
|
|
54
|
+
body: Node;
|
|
55
|
+
async?: boolean;
|
|
56
|
+
};
|
|
193
57
|
};
|
|
194
58
|
/**
|
|
195
59
|
* 创建一个 stub mock
|
|
@@ -197,13 +61,17 @@ type MockHelper = {
|
|
|
197
61
|
*/
|
|
198
62
|
declare function stub(): MockHelper;
|
|
199
63
|
declare namespace stub {
|
|
200
|
-
var returns: (value:
|
|
201
|
-
var resolves: (value:
|
|
202
|
-
var rejects: (value:
|
|
203
|
-
var onFirstCall: (value:
|
|
204
|
-
var onSecondCall: (value:
|
|
205
|
-
var withArgs: (...args:
|
|
206
|
-
var callsFake: (fn:
|
|
64
|
+
var returns: (value: Abs) => MockHelper;
|
|
65
|
+
var resolves: (value: Abs) => MockHelper;
|
|
66
|
+
var rejects: (value: Abs) => MockHelper;
|
|
67
|
+
var onFirstCall: (value: Abs) => MockHelper;
|
|
68
|
+
var onSecondCall: (value: Abs) => MockHelper;
|
|
69
|
+
var withArgs: (...args: Abs[]) => MockHelper;
|
|
70
|
+
var callsFake: (fn: {
|
|
71
|
+
params: string[];
|
|
72
|
+
body: Node;
|
|
73
|
+
async?: boolean;
|
|
74
|
+
}) => MockHelper;
|
|
207
75
|
}
|
|
208
76
|
/**
|
|
209
77
|
* 创建一个 spy mock
|
|
@@ -211,17 +79,13 @@ declare namespace stub {
|
|
|
211
79
|
*/
|
|
212
80
|
declare function spy(): MockHelper;
|
|
213
81
|
declare namespace spy {
|
|
214
|
-
var returns: (value:
|
|
82
|
+
var returns: (value: Abs) => MockHelper;
|
|
215
83
|
}
|
|
216
84
|
/**
|
|
217
85
|
* 创建一个 mock
|
|
218
86
|
* 用法: @nudo:mock service = mock()
|
|
219
87
|
*/
|
|
220
88
|
declare function mock(): MockHelper;
|
|
221
|
-
/**
|
|
222
|
-
* 将 MockHelper 转换为 TypeValue
|
|
223
|
-
*/
|
|
224
|
-
declare function mockHelperToTypeValue(helper: MockHelper, env: Environment): TypeValue;
|
|
225
89
|
|
|
226
90
|
/**
|
|
227
91
|
* 原地剥除 AST 中的 TS-only 语法节点/字段,返回同一棵 AST(便于链式使用)。
|
|
@@ -229,13 +93,6 @@ declare function mockHelperToTypeValue(helper: MockHelper, env: Environment): Ty
|
|
|
229
93
|
*/
|
|
230
94
|
declare function stripTypes<T extends Node>(ast: T): T;
|
|
231
95
|
|
|
232
|
-
declare function resetParseSourceCache(): void;
|
|
233
|
-
declare function getParseSourceCacheSize(): number;
|
|
234
|
-
declare function parseSource(source: string, opts?: {
|
|
235
|
-
errorRecovery?: boolean;
|
|
236
|
-
keepTs?: boolean;
|
|
237
|
-
}): File;
|
|
238
|
-
|
|
239
96
|
/**
|
|
240
97
|
* 路径约束栈(Φ)。
|
|
241
98
|
*
|
|
@@ -256,6 +113,8 @@ declare function describePhi(): string;
|
|
|
256
113
|
* 与 term-registry 同一纪律:不给共享单例挂 impl。
|
|
257
114
|
*/
|
|
258
115
|
|
|
116
|
+
/** Abs 原生 env/builtin 实现(B-path 优先) */
|
|
117
|
+
type AbsSigImpl = (args: Abs[], thisVal?: Abs) => Abs | undefined;
|
|
259
118
|
type AbsFnImpl = {
|
|
260
119
|
params: string[];
|
|
261
120
|
/** 可选:无 body 时走 relation(纯关系 fn) */
|
|
@@ -265,7 +124,13 @@ type AbsFnImpl = {
|
|
|
265
124
|
env?: AstEnv;
|
|
266
125
|
kind?: string;
|
|
267
126
|
/** 调用时直接派发(mock withArgs 等),优先于 body */
|
|
268
|
-
apply?: (args: Abs[]) => Abs;
|
|
127
|
+
apply?: (args: Abs[], thisVal?: Abs) => Abs;
|
|
128
|
+
/**
|
|
129
|
+
* 对象方法(ObjectMethod / 方法型 FunctionExpression):$invoke 时把
|
|
130
|
+
* receiver 作为 apply 的**首参**注入。shape.params 仍是用户可见形参
|
|
131
|
+
* (不含 receiver),自由调用不注入 → this 为 unbound(JS 语义)。
|
|
132
|
+
*/
|
|
133
|
+
bindThis?: boolean;
|
|
269
134
|
/**
|
|
270
135
|
* Optional content key for cache fingerprints. formatAbs cannot see
|
|
271
136
|
* WeakMap-side mock semantics (returns/withArgs/callsFake), so hosts that
|
|
@@ -277,10 +142,27 @@ type AbsFnImpl = {
|
|
|
277
142
|
relation?: {
|
|
278
143
|
paramTypes: Abs[];
|
|
279
144
|
returnType: Abs;
|
|
145
|
+
/**
|
|
146
|
+
* 条件类型 infer:绑定 fromVar 后从 via 投出 inferVar
|
|
147
|
+
* (`T extends (infer E)[]` → via: "arr";`T extends Promise<infer U>` → "promise")。
|
|
148
|
+
*/
|
|
149
|
+
inferFrom?: {
|
|
150
|
+
fromVar: string;
|
|
151
|
+
via: "arr" | "promise";
|
|
152
|
+
inferVar: string;
|
|
153
|
+
};
|
|
154
|
+
/** extends 不成立时的假分支(如 never) */
|
|
155
|
+
condFallback?: Abs;
|
|
280
156
|
};
|
|
157
|
+
/** `@nudo:pure`:调用结果按实参记忆化(无副作用契约) */
|
|
158
|
+
pureName?: string;
|
|
281
159
|
};
|
|
282
160
|
declare function attachFnImpl(a: Abs, impl: AbsFnImpl): void;
|
|
283
161
|
declare function getFnImpl(a: Abs): AbsFnImpl | undefined;
|
|
162
|
+
/** 标记纯函数(@nudo:pure):调用结果可按实参记忆化 */
|
|
163
|
+
declare function markPureFn(target: object, name: string): void;
|
|
164
|
+
/** 读纯函数标记(Abs impl 或对象属性 `_memoize`) */
|
|
165
|
+
declare function pureFnNameOf(fn: unknown): string | undefined;
|
|
284
166
|
/** 造一个带实现的 Abs 函数值 */
|
|
285
167
|
declare function absFunction(params: string[], impl: Omit<AbsFnImpl, "params">): Abs;
|
|
286
168
|
/** relationFn 稳定 fingerprint(同签名共享,见 §3.3 已知限制) */
|
|
@@ -301,6 +183,12 @@ declare function relationFn(paramTypes: Abs[], returnType: Abs, opts?: {
|
|
|
301
183
|
params?: string[];
|
|
302
184
|
conf?: Confidence;
|
|
303
185
|
fingerprint?: string;
|
|
186
|
+
inferFrom?: {
|
|
187
|
+
fromVar: string;
|
|
188
|
+
via: "arr" | "promise";
|
|
189
|
+
inferVar: string;
|
|
190
|
+
};
|
|
191
|
+
condFallback?: Abs;
|
|
304
192
|
}): Abs;
|
|
305
193
|
/** 仅写 shape 槽(E 路径 / §5.2 提升产物);禁止 attachFnImpl */
|
|
306
194
|
declare function shapeOnlyFn(paramTypes: Abs[], returnType: Abs, opts?: {
|
|
@@ -308,6 +196,147 @@ declare function shapeOnlyFn(paramTypes: Abs[], returnType: Abs, opts?: {
|
|
|
308
196
|
conf?: Confidence;
|
|
309
197
|
}): Abs;
|
|
310
198
|
|
|
199
|
+
/**
|
|
200
|
+
* HOF 关系 Abs:无 body 的外延关系(paramTypes → returnType)的判定、
|
|
201
|
+
* α 替换与应用。类型变量仍是 term var;关系仍是 fn 形状上的外延槽。
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
declare function createHofCollectCtx(paramNames: ReadonlySet<string>, alphaIds: Iterable<string>): HofCollectCtx;
|
|
205
|
+
/**
|
|
206
|
+
* 仅当 term 是 var 且 id ∈ alphaIds(本次 typeParams)时复用;否则 fresh α。
|
|
207
|
+
* 绝不把调用点具体值/字面量冻进关系。
|
|
208
|
+
*/
|
|
209
|
+
declare function alphaOf(absOrTerm: Abs | Term | undefined, ctx: HofCollectCtx): Term;
|
|
210
|
+
/** 共享输出变量 B:${param}(§5.1 P2 钉死) */
|
|
211
|
+
declare function betaOf(param: string): Term;
|
|
212
|
+
/**
|
|
213
|
+
* 提升写入载体:替换 env.vars map 项,禁止 mutate 共享 Abs。
|
|
214
|
+
* arrival-first:已有 fn/arr 形状 → 拒绝新观测。
|
|
215
|
+
* 返回是否真正写入。
|
|
216
|
+
*/
|
|
217
|
+
declare function promoteParamShape(env: AstEnv, param: string, promotedShape: Shape, opts?: {
|
|
218
|
+
loc?: {
|
|
219
|
+
line: number;
|
|
220
|
+
column: number;
|
|
221
|
+
};
|
|
222
|
+
recordSite?: boolean;
|
|
223
|
+
}): boolean;
|
|
224
|
+
/**
|
|
225
|
+
* 挂载点①:方法派发 miss。receiver 是形参 Identifier 且 shape 为 any/未知,
|
|
226
|
+
* 方法名为 filter/map/reduce/flatMap → 提升为 arr(自身 var)。
|
|
227
|
+
*/
|
|
228
|
+
declare function tryPromoteReceiverAsArr(env: AstEnv, receiverName: string, method: string, loc?: {
|
|
229
|
+
line: number;
|
|
230
|
+
column: number;
|
|
231
|
+
}): Abs | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* for-of 迭代对象提升(applyEach 型):`for (const x of items)`,
|
|
234
|
+
* items 为形参且仍是 any/unknown → arr(自身 var)。不依赖方法名。
|
|
235
|
+
*/
|
|
236
|
+
declare function tryPromoteForOfIteratee(env: AstEnv, iterateeName: string, loc?: {
|
|
237
|
+
line: number;
|
|
238
|
+
column: number;
|
|
239
|
+
}): Abs | undefined;
|
|
240
|
+
/**
|
|
241
|
+
* 挂载点②:CallExpression callee = 形参 Identifier 直接调用 p(x) / p(a,b)。
|
|
242
|
+
* 提升为 fn(paramTypes=[αOf(args)], returnType=B:param)。
|
|
243
|
+
*/
|
|
244
|
+
declare function tryPromoteDirectCall(env: AstEnv, calleeName: string, args: Abs[], loc?: {
|
|
245
|
+
line: number;
|
|
246
|
+
column: number;
|
|
247
|
+
}): Abs | undefined;
|
|
248
|
+
/**
|
|
249
|
+
* 挂载点③:HOF 回调实参。回调是 Identifier ∈ paramNames 且尚未有 fn 形状。
|
|
250
|
+
* 按方法名提升:map/flatMap → fn([αOf(el)], B:param);filter → fn([αOf(el)], bool);
|
|
251
|
+
* reduce → fn([αOf(init), αOf(el)], B:param)。
|
|
252
|
+
*/
|
|
253
|
+
declare function tryPromoteHofCallback(env: AstEnv, cbName: string, method: string, argAbses: Abs[], loc?: {
|
|
254
|
+
line: number;
|
|
255
|
+
column: number;
|
|
256
|
+
}): Abs | undefined;
|
|
257
|
+
/** deep-ish copy for snapshot(新对象,不是 env.vars 同一引用) */
|
|
258
|
+
declare function snapshotAbs(a: Abs): Abs;
|
|
259
|
+
/**
|
|
260
|
+
* 「有可用外延签名」判定:唯一权威定义。
|
|
261
|
+
*
|
|
262
|
+
* 名实说明:isRelFn **不要求** term 是 var。完全单态的具体签名
|
|
263
|
+
* (paramTypes=[number], returnType=string)同样满足——map 有槽就用。
|
|
264
|
+
* 多态(term=var)只是其中一种形态;名字里的 Rel 指「关系槽可用」。
|
|
265
|
+
*
|
|
266
|
+
* 收紧条件——仅有 returnType 而 paramTypes 与 arity 不对齐时,不算 rel,
|
|
267
|
+
* 防止半截签名在 map 里冒充关系。
|
|
268
|
+
*/
|
|
269
|
+
declare function isRelFn(a: Abs | undefined | null): boolean;
|
|
270
|
+
/**
|
|
271
|
+
* pred 三条规则:
|
|
272
|
+
* 1. var ∈ map + 实参有 term → 换 term,可归约则归约,否则残余保留
|
|
273
|
+
* 2. var ∈ map + 实参无 term → pred → true(conf 由调用方降级)
|
|
274
|
+
* 3. var ∉ map(自由 α)→ 原样保留
|
|
275
|
+
*/
|
|
276
|
+
declare function substPredAbs(p: Pred, map: ReadonlyMap<string, Abs>): {
|
|
277
|
+
pred: Pred;
|
|
278
|
+
dropped: boolean;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* α 替换:map 的 key 是 term var id,value 是替换 Abs。
|
|
282
|
+
* var ∉ map 原样保留(含自由 α 上的 term/pred)。
|
|
283
|
+
*/
|
|
284
|
+
declare function substAbs(a: Abs, map: ReadonlyMap<string, Abs>): Abs;
|
|
285
|
+
/**
|
|
286
|
+
* relation-only / isRelFn 的应用:按 paramTypes 做 α 替换得到 returnType。
|
|
287
|
+
* impl.relation 槽优先于 shape.returnType。重复 α 先绑定保留。
|
|
288
|
+
* **深度合一**:`T[]` 形参可从 `number[]` 实参绑出 T=number(lodash 泛型)。
|
|
289
|
+
*/
|
|
290
|
+
declare function instantiateReturn(fn: Abs, args: Abs[]): Abs;
|
|
291
|
+
/**
|
|
292
|
+
* 回调统一入口(单点定义)。A–F + sum:
|
|
293
|
+
* A Node inline | B apply | C body | D relation | E isRelFn | F unknown
|
|
294
|
+
*
|
|
295
|
+
* 实现委托 applyAbsFn(已含 sum / D / E / body 优先)。
|
|
296
|
+
* Identifier 解析层:env.vars 有 Abs → B–E;env.fns 有 → callFunction;否则 unknown。
|
|
297
|
+
*
|
|
298
|
+
* 为避免 hof ↔ exec 循环依赖,本函数由宿主在运行时绑定。
|
|
299
|
+
*
|
|
300
|
+
* 依赖说明:宿主在 `exec/call.ts`(B-path `$call` 宿主)加载时注册(副作用)。
|
|
301
|
+
* 只 import hof.ts 而未加载 exec/call 时,fallback 仅认 relation/isRelFn。
|
|
302
|
+
* 与 §5.1 的「禁止全局 collector」不同——这里是无状态委托钩子,不是 run 局部状态。
|
|
303
|
+
*/
|
|
304
|
+
type ApplyCallbackHost = (cb: Abs | {
|
|
305
|
+
type: string;
|
|
306
|
+
}, args: Abs[], env: unknown, phi: unknown, budget: unknown) => Abs;
|
|
307
|
+
/**
|
|
308
|
+
* B-path 宿主 `exec/call.ts` 加载时注册(副作用)。
|
|
309
|
+
* 必须经 `exec/call.ts`(或其依赖方:exec/class、generalize)加载,
|
|
310
|
+
* 才能启用 Identifier/env.fns/inline body 路径;只 import hof.ts 时 fallback
|
|
311
|
+
* 仅认 relation/isRelFn。勿在多份实例下各写各的——双包/双副本会覆盖。
|
|
312
|
+
*/
|
|
313
|
+
declare function setApplyCallbackHost(fn: ApplyCallbackHost): void;
|
|
314
|
+
/**
|
|
315
|
+
* 通用回调实参调用(exec/class invokeArrMethod 与 builtins Array.from 共用):
|
|
316
|
+
* 原始 JS 函数直调(展开实参);Abs fn 走 applyCallbackAbs(sum 分发/宿主)。
|
|
317
|
+
* B 路径 transpile 的箭头回调是 $fnVal Abs——$fnVal.apply 自带调用边界。
|
|
318
|
+
*/
|
|
319
|
+
declare function applyCallbackValue(fn: unknown, args: Abs[], env: unknown, phi: unknown, budget: unknown): Abs;
|
|
320
|
+
declare function applyCallbackAbs(cb: Abs | {
|
|
321
|
+
type: string;
|
|
322
|
+
}, args: Abs[], env: unknown, phi: unknown, budget: unknown): Abs;
|
|
323
|
+
/** undefined 值的统一 Abs 表示(forEach/find 等) */
|
|
324
|
+
declare function undefAbs(): Abs;
|
|
325
|
+
/**
|
|
326
|
+
* map 元素投影:body 在符号实参上跑出 unknown 时,
|
|
327
|
+
* 用 shape.returnType 槽,conf 由调用方按 path/partial 处理。
|
|
328
|
+
* rel 回调不会走到这里(instantiateReturn 已给出结果)。
|
|
329
|
+
*/
|
|
330
|
+
declare function mapElementFallback(cbAbs: Abs | undefined, elem: Abs, out: Abs): Abs;
|
|
331
|
+
/**
|
|
332
|
+
* flatMap 统一结果:展开后的元素 join 成 arr(γ)。
|
|
333
|
+
* JS flatMap 永远返回 Array;双路径共用此投影,禁止一边 tuple 一边 arr。
|
|
334
|
+
* 同 term 元素 first-wins(joinAbs 会丢 β 身份,见 design §5.1)。
|
|
335
|
+
*/
|
|
336
|
+
declare function projectFlatMapResult(arrConf: Confidence, mapped: Abs[]): Abs;
|
|
337
|
+
/** 从 map/filter/reduce 回调实参里取出 Abs(Identifier 已绑定或直接 Abs) */
|
|
338
|
+
declare function asAbs(v: unknown): Abs | undefined;
|
|
339
|
+
|
|
311
340
|
/**
|
|
312
341
|
* 算术核:单调性 + 常量折叠 + 约束传播。
|
|
313
342
|
* 这是「类型即计算」的主武器——x>0 时 x+1 必须得到 >1。
|
|
@@ -364,6 +393,24 @@ declare function falseConstraint(c: Abs): Pred | undefined;
|
|
|
364
393
|
* 类型即计算——一元与控制流判定与二元算术同一运算域。
|
|
365
394
|
*/
|
|
366
395
|
|
|
396
|
+
/** & —— ToInt32 两侧后按位与 */
|
|
397
|
+
declare function bitandAbs(a: Abs, b: Abs): Abs;
|
|
398
|
+
/** | —— ToInt32 两侧后按位或 */
|
|
399
|
+
declare function bitorAbs(a: Abs, b: Abs): Abs;
|
|
400
|
+
/** ^ —— ToInt32 两侧后按位异或 */
|
|
401
|
+
declare function bitxorAbs(a: Abs, b: Abs): Abs;
|
|
402
|
+
/** ~ —— ToInt32 后按位取反(bigint 无符号截断) */
|
|
403
|
+
declare function bitnotAbs(a: Abs): Abs;
|
|
404
|
+
/** << —— 左移(rhs ToUint32 & 31;bigint 不限位宽) */
|
|
405
|
+
declare function shlAbs(a: Abs, b: Abs): Abs;
|
|
406
|
+
/** >> —— 算术右移(rhs ToUint32 & 31;bigint 不限位宽) */
|
|
407
|
+
declare function shrAbs(a: Abs, b: Abs): Abs;
|
|
408
|
+
/** >>> —— 逻辑右移(rhs ToUint32 & 31;bigint 无此运算符 → 不可折叠) */
|
|
409
|
+
declare function ushrAbs(a: Abs, b: Abs): Abs;
|
|
410
|
+
/** ** —— 幂(右结合由 AST 保证);负指数 bigint 原生 RangeError → 不可折叠 */
|
|
411
|
+
declare function powAbs(a: Abs, b: Abs): Abs;
|
|
412
|
+
/** 一元 + —— ToNumber 折叠;bigint 原生恒抛 TypeError → 不可折叠 */
|
|
413
|
+
declare function toNumberAbs(a: Abs): Abs;
|
|
367
414
|
/** JS typeof:结果域永远是 string */
|
|
368
415
|
declare function typeofAbs(a: Abs): Abs;
|
|
369
416
|
/** 一元负号:字面量折叠;符号数翻转不等式 */
|
|
@@ -372,83 +419,242 @@ declare function negAbs(a: Abs, _phi?: Phi): Abs;
|
|
|
372
419
|
declare function notAbs(a: Abs): Abs;
|
|
373
420
|
/** 该 shape 在 JS 上一定不是 null/undefined */
|
|
374
421
|
declare function definitelyNotNullishShape(s: Shape): boolean;
|
|
422
|
+
/** 仅当 term 确为 lit null/undefined 时为 true;非 lit 的 litValue===undefined 不得当 nullish */
|
|
375
423
|
declare function isNullishLitAbs(a: Abs): boolean;
|
|
376
424
|
/**
|
|
377
425
|
* 严格相等(Abs):双字面量折叠;nullish 与 definitely-not-nullish → false。
|
|
378
426
|
* 返回 undefined = 无法判定(交给 boolean + 调用方)。
|
|
379
427
|
*/
|
|
380
428
|
declare function strictEqAbs(a: Abs, b: Abs): boolean | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* 宽松相等 `==`(C2.3):双 lit 走 Abstract Equality;否则回落严格相等判定。
|
|
431
|
+
* 返回 undefined = 无法判定。
|
|
432
|
+
*/
|
|
433
|
+
declare function looseEqAbs(a: Abs, b: Abs): boolean | undefined;
|
|
381
434
|
|
|
382
435
|
/**
|
|
383
|
-
*
|
|
384
|
-
*
|
|
436
|
+
* 对象不变性侧表(freeze/seal/preventExtensions/defineProperty)。
|
|
437
|
+
* WeakMap 侧表:Abs 不可变,写路径读侧表复现 sloppy 静默失败。
|
|
438
|
+
*/
|
|
439
|
+
|
|
440
|
+
type ExtState = "nonext" | "sealed" | "frozen";
|
|
441
|
+
type PropFlags = {
|
|
442
|
+
writable?: boolean;
|
|
443
|
+
enumerable?: boolean;
|
|
444
|
+
configurable?: boolean;
|
|
445
|
+
};
|
|
446
|
+
declare function markExtState(o: Abs, s: ExtState): Abs;
|
|
447
|
+
declare function extStateOf(o: Abs): ExtState | undefined;
|
|
448
|
+
declare function getPropFlags(o: Abs): Map<string, PropFlags> | undefined;
|
|
449
|
+
declare function setPropFlags(o: Abs, key: string, f: PropFlags): void;
|
|
450
|
+
/** 写路径产生新副本时迁移不变性侧表(同 migrateAccessors 模式)。
|
|
451
|
+
* propFlags 深拷贝:fork/switch 的 $copy 副本不得与源共享可变 Map
|
|
452
|
+
* (一臂 defineProperty 不得污染另一臂)。 */
|
|
453
|
+
declare function migrateInvariants(from: Abs, to: Abs): void;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Math.* — 字面量可折叠的返回精确值,否则 number
|
|
385
457
|
*/
|
|
386
458
|
|
|
387
|
-
/** Math.* — 字面量可折叠的返回精确值,否则 number */
|
|
388
459
|
declare function evalMathMethod(name: string, args: Abs[]): Abs | undefined;
|
|
389
|
-
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Object.assign 非 obj 源键投影 + Object.* 静态方法
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
declare function assignSourceSlots(src: Abs): Record<string, {
|
|
466
|
+
value: Abs;
|
|
467
|
+
}> | undefined;
|
|
468
|
+
/** Object.keys/values/entries/assign + 不变性方法 */
|
|
390
469
|
declare function evalObjectMethod(name: string, args: Abs[]): Abs | undefined;
|
|
391
|
-
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* JSON.parse / JSON.stringify
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
/** JSON.parse / stringify:字面量实参真执行折叠;失败硬抛(catch 可吸收) */
|
|
392
476
|
declare function evalJsonMethod(name: string, args: Abs[]): Abs | undefined;
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Number.* 静态方法 + parseInt 折叠
|
|
480
|
+
*/
|
|
481
|
+
|
|
393
482
|
/** Number.isInteger / isNaN / parseFloat 等 */
|
|
394
483
|
declare function evalNumberStatic(name: string, args: Abs[]): Abs | undefined;
|
|
395
|
-
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* 全局转换函数(parseInt / Number / String / Boolean / Object / Array / Symbol …)
|
|
487
|
+
*/
|
|
488
|
+
|
|
396
489
|
declare function evalGlobalFn(name: string, args: Abs[]): Abs | undefined;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Array 构造 / Array.* 静态方法
|
|
493
|
+
*/
|
|
494
|
+
|
|
495
|
+
declare function makeArrayCtorAbs(args: Abs[]): Abs;
|
|
397
496
|
/** Array.isArray / Array.from / Array.of */
|
|
398
497
|
declare function evalArrayStatic(name: string, args: Abs[]): Abs | undefined;
|
|
399
|
-
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Date 构造 / Date.* / Date 实例方法(保守未建模)
|
|
501
|
+
*/
|
|
502
|
+
|
|
400
503
|
declare function evalDateCtor(args: Abs[]): Abs;
|
|
401
504
|
declare function evalDateStatic(name: string, _args: Abs[]): Abs | undefined;
|
|
402
505
|
declare function evalDateMethod(name: string, _recv: Abs, _args: Abs[]): Abs | undefined;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* RegExp 构造 / brand / 实例方法
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
declare function evalRegExpCtor(args: Abs[]): Abs;
|
|
512
|
+
/** RegExp brand:source/flags/lastIndex 进 slots(B-path evalRegExpCtor / $regex 共用) */
|
|
513
|
+
declare function regexBrandAbsFrom(pattern: string, flags: string): Abs;
|
|
514
|
+
/**
|
|
515
|
+
* new RegExp(pattern, flags) 字面量真构造验证($new 与 evalRegExpCtor 共用):
|
|
516
|
+
* - 无参 → /(?:)/(原生 source 归一)
|
|
517
|
+
* - pattern 非字面量(抽象/RegExp 实例)→ undefined(调用方保守)
|
|
518
|
+
* - symbol pattern / flags → TypeError(ToString 抛)
|
|
519
|
+
* - 非法 pattern / 非法 flags(含 number/null/boolean flags 的 ToString)
|
|
520
|
+
* → SyntaxError;合法 → 精确 brand(source/flags 取真构造结果)
|
|
521
|
+
*/
|
|
522
|
+
declare function tryMakeRegexAbs(args: Abs[]): Abs | undefined;
|
|
523
|
+
declare function evalRegExpMethod(name: string, recv: Abs, args: Abs[]): Abs | undefined;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* 内建构造器注册表 + prototype brand / constructor 解析 + Object.prototype 单例 brand
|
|
527
|
+
*/
|
|
528
|
+
|
|
529
|
+
declare function builtinCtorAbs(name: string): Abs;
|
|
530
|
+
/** Abs 侧内建构造器身份(与宿主构造器名对齐) */
|
|
531
|
+
declare function builtinCtorNameOf(v: unknown): string | undefined;
|
|
532
|
+
/** 宿主全局构造器身份(Number === (42).constructor 折叠用) */
|
|
533
|
+
declare function hostBuiltinCtorName(v: unknown): string | undefined;
|
|
534
|
+
/**
|
|
535
|
+
* 接收者 → 原型链 constructor 名(`.constructor` 折叠)。
|
|
536
|
+
* null-proto 无 Object.prototype.constructor → undefined(读侧走 undef)。
|
|
537
|
+
*/
|
|
538
|
+
declare function ctorNameOfRecv(recv: Abs): string | undefined;
|
|
539
|
+
/** `X.prototype` 形态(getPrototypeOf 结果;带 constructor 槽) */
|
|
540
|
+
declare function protoBrandAbs(ctorName: string): Abs;
|
|
541
|
+
/**
|
|
542
|
+
* Object.getPrototypeOf 的具体原型投影(constructor 链可解)。
|
|
543
|
+
* null-proto → null 字面量;不可判形态 → unknown(不假装精确原型)。
|
|
544
|
+
*/
|
|
545
|
+
declare function protoOfRecv(a: Abs): Abs;
|
|
546
|
+
declare const OBJECT_PROTO_METHOD_NAMES: Set<string>;
|
|
547
|
+
/** Object.prototype 单例($get(Object, "prototype") 与 host Object.prototype 共用)。
|
|
548
|
+
* 带 constructor 槽(不可枚举)供 `.constructor` / `.constructor.name` 链折叠。 */
|
|
549
|
+
declare function objectProtoBrand(): Abs;
|
|
550
|
+
declare function isObjectProtoBrand(a: Abs | undefined): boolean;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Promise 构造 / then 链 / 静态方法 + micro 队列
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
declare function enterPromiseExecutorScope(): void;
|
|
557
|
+
declare function leavePromiseExecutorScope(): number;
|
|
558
|
+
/** $fork 在 executor 内发生时打点(多臂 resolve 需 join,不得 first-wins 假精确) */
|
|
559
|
+
declare function notePromiseExecutorFork(): void;
|
|
560
|
+
declare function queuePromiseMicro(task: () => void): void;
|
|
561
|
+
declare function drainPromiseMicros(): void;
|
|
562
|
+
/**
|
|
563
|
+
* new Promise(executor):调用 executor(resolve, reject),收集 resolve 实参作为
|
|
564
|
+
* promise inner。原生只认第一次 settle——顺序双 resolve 取第一次;执行器内
|
|
565
|
+
* $fork 分叉时各臂 settle 值 join(路径敏感,不得 first-wins 假精确)。
|
|
566
|
+
* reject 不填 resolved 通道;永不 settle / 抽象 fn / 执行抛 → promise<unknown>。
|
|
567
|
+
*/
|
|
568
|
+
declare function evalPromiseCtor(args: Abs[]): Abs;
|
|
569
|
+
/** then/catch/finally:可映射回调 → 新 inner;做不到诚实 promise<unknown> */
|
|
570
|
+
declare function evalPromiseMethod(name: string, recv: Abs, args: Abs[]): Abs | undefined;
|
|
408
571
|
declare function evalPromiseStatic(name: string, args: Abs[]): Abs | undefined;
|
|
409
|
-
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* Error 家族 + evalBuiltinNew / evalBuiltinInstanceMethod + namespace 分派
|
|
575
|
+
*/
|
|
576
|
+
|
|
410
577
|
declare function evalNamespaceCall(ns: string, method: string, args: Abs[]): Abs | undefined;
|
|
578
|
+
declare function isErrorCtorName(name: string | undefined): boolean;
|
|
579
|
+
/**
|
|
580
|
+
* Error brand:shape 带 name/message(字面量 message 保精确)。
|
|
581
|
+
* AggregateError(errors, message[, options]):message 在第二实参,errors
|
|
582
|
+
* 挂 .errors(原生是实参数组副本);options.cause 挂 .cause(闭槽 miss
|
|
583
|
+
* 会折 undefined 假精确——原生 .cause 可能有值)。
|
|
584
|
+
* $new 的 new Error 路径共用——catch 形参成员访问可解。
|
|
585
|
+
*/
|
|
586
|
+
declare function errorBrandAbs(name: string, args: Abs[]): Abs;
|
|
411
587
|
/** new X(...) */
|
|
412
588
|
declare function evalBuiltinNew(className: string, args: Abs[]): Abs | undefined;
|
|
413
589
|
/** brand 实例方法(Date/RegExp/Map/Set) */
|
|
414
590
|
declare function evalBuiltinInstanceMethod(brandName: string, method: string, recv: Abs, args: Abs[]): Abs | undefined;
|
|
415
591
|
|
|
416
592
|
/**
|
|
417
|
-
*
|
|
418
|
-
* 类型即计算——方法结果仍是 Abs,可继续参与约束推理。
|
|
419
|
-
* 宿主 TypeValue 的 dispatchMethod 只服务 IR 兜底,不是真理源。
|
|
420
|
-
* 模板语义(前缀/后缀/固定文本/长度/谓词判定)统一在 template.ts。
|
|
593
|
+
* String.fromCharCode 等静态方法
|
|
421
594
|
*/
|
|
422
595
|
|
|
423
596
|
/**
|
|
424
|
-
*
|
|
597
|
+
* String.fromCharCode(...):
|
|
598
|
+
* - 全部字面量 → 按 ToUint16 折成精确字符串(含越界/非整数/数字字符串)
|
|
599
|
+
* - symbol 字面量 → TypeError(ToNumber 抛)
|
|
600
|
+
* - 任一抽象实参 → 抽象 string(不假精确)
|
|
425
601
|
*/
|
|
426
|
-
declare function
|
|
427
|
-
/** 属性读取:template/string.length 等 */
|
|
428
|
-
declare function getAbsProperty(recv: Abs, name: string): Abs | undefined;
|
|
602
|
+
declare function evalStringStatic(name: string, args: Abs[]): Abs | undefined;
|
|
429
603
|
|
|
430
604
|
/**
|
|
431
|
-
*
|
|
605
|
+
* Symbol 身份侧表:Symbol() 产生非具体 unique symbol(prim type=symbol,无 term)。
|
|
606
|
+
* === 按 Abs 引用 / 侧表 id 判定,不把 description 折成可比较字面量身份。
|
|
607
|
+
* 独立小模块:surface(strictEqAbs) 与 builtins(makeSymbolAbs) 共用,避免环。
|
|
608
|
+
*/
|
|
609
|
+
|
|
610
|
+
declare function symbolIdOf(a: Abs): number | undefined;
|
|
611
|
+
declare function symbolDescriptionAbs(a: Abs): Abs | undefined;
|
|
612
|
+
declare function isSymbolAbs$1(a: Abs | undefined): boolean;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Symbol 构造 / 描述 / 字符串化
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Symbol([description]):非具体 unique symbol(prim type=symbol,无 term)。
|
|
620
|
+
* - 身份:侧表 id(两个 Symbol() 的 === 为 false;同 Abs 引用为 true)
|
|
621
|
+
* - .description:字面量 string 或 undefined
|
|
622
|
+
* - 不折成可比较的字面量身份(description 不作 identity)
|
|
623
|
+
*/
|
|
624
|
+
declare function makeSymbolAbs(descArg?: Abs): Abs;
|
|
625
|
+
declare const isSymbolAbs: typeof isSymbolAbs$1;
|
|
626
|
+
|
|
627
|
+
/** 全局 Symbol([desc])($callNamed 身份校验后派发) */
|
|
628
|
+
declare function evalSymbolCtor(args: Abs[]): Abs;
|
|
629
|
+
/** String(sym) → SymbolDescriptiveString(原生不抛;隐式 ToString 才抛) */
|
|
630
|
+
declare function stringOfSymbol(a: Abs): Abs;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Object.prototype 成员(hasOwnProperty / isPrototypeOf / toString / …)
|
|
432
634
|
*/
|
|
433
635
|
|
|
434
|
-
type LeakBudget = {
|
|
435
|
-
maxDepth: number;
|
|
436
|
-
maxNodes: number;
|
|
437
|
-
};
|
|
438
|
-
declare const defaultLeakBudget: LeakBudget;
|
|
439
|
-
declare function termDepth(t: Term): number;
|
|
440
|
-
declare function termNodes(t: Term): number;
|
|
441
|
-
declare function exceedsBudget(t: Term, budget?: LeakBudget): boolean;
|
|
442
|
-
declare function resetLeakCounter(): void;
|
|
443
636
|
/**
|
|
444
|
-
*
|
|
445
|
-
*
|
|
637
|
+
* Object.prototype 方法语义(B-path $invoke 与 Object.prototype.X.call 共用)。
|
|
638
|
+
* null-proto 接收者无这些方法——返回 undefined(调用方走 TypeError 路径)。
|
|
639
|
+
* 返回 undefined = 未接管。
|
|
446
640
|
*/
|
|
447
|
-
declare function
|
|
641
|
+
declare function evalObjectProtoMethod(name: string, thisVal: Abs, args: Abs[]): Abs | undefined;
|
|
642
|
+
/** Object.prototype.X 一等函数(bindThis:call/apply 把 receiver 注入首参) */
|
|
643
|
+
declare function objectProtoMethodAbs(name: string): Abs;
|
|
644
|
+
|
|
448
645
|
/**
|
|
449
|
-
*
|
|
646
|
+
* Abs 方法表:模板字符串 / 结构值上的方法与属性。
|
|
647
|
+
* 类型即计算——方法结果仍是 Abs,可继续参与约束推理。
|
|
648
|
+
* 宿主 TypeValue 的 dispatchMethod 只服务 IR 兜底,不是真理源。
|
|
649
|
+
* 模板语义(前缀/后缀/固定文本/长度/谓词判定)统一在 template.ts。
|
|
450
650
|
*/
|
|
451
|
-
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* 调用 Abs 方法。返回 undefined = 未接管(调用方走其它路径)。
|
|
654
|
+
*/
|
|
655
|
+
declare function callAbsMethod(recv: Abs, name: string, args: Abs[]): Abs | undefined;
|
|
656
|
+
/** 属性读取:template/string.length 等 */
|
|
657
|
+
declare function getAbsProperty(recv: Abs, name: string): Abs | undefined;
|
|
452
658
|
|
|
453
659
|
/**
|
|
454
660
|
* 结构层:对象槽位、spread、函数重载并。
|
|
@@ -460,6 +666,8 @@ type Slot = {
|
|
|
460
666
|
optional?: boolean;
|
|
461
667
|
readonly?: boolean;
|
|
462
668
|
};
|
|
669
|
+
/** ES 规范数组下标(无前导零、< 2^32-1);非规范键返回 undefined */
|
|
670
|
+
declare function canonicalArrayIndex(v: unknown): number | undefined;
|
|
463
671
|
type ObjShape = {
|
|
464
672
|
k: "obj";
|
|
465
673
|
slots: Record<string, Slot>;
|
|
@@ -498,9 +706,10 @@ declare function spread(base: Abs, over: Abs): Abs;
|
|
|
498
706
|
* 同 key 集:槽位级 join(字面量并);异 key 集:保持 sum。
|
|
499
707
|
*/
|
|
500
708
|
declare function joinObjects(a: Abs, b: Abs): Abs;
|
|
501
|
-
/** 值级 join
|
|
709
|
+
/** 值级 join:同型双字面量保留为枚举 sum;其余 prim 同型收成 path */
|
|
502
710
|
declare function joinValues(a: Abs, b: Abs): Abs;
|
|
503
711
|
declare function makeSum(a: Abs, b: Abs): Abs;
|
|
712
|
+
declare function absShapeKey(a: Abs, seen?: Set<object>): string;
|
|
504
713
|
type FnAbs = Abs & {
|
|
505
714
|
shape: {
|
|
506
715
|
k: "fn";
|
|
@@ -519,6 +728,99 @@ declare function fnOf(params: string[], name?: string): Abs;
|
|
|
519
728
|
declare function joinFunctions(a: Abs, b: Abs): Abs;
|
|
520
729
|
/** 通用 join:分派到对象/函数/值 */
|
|
521
730
|
declare function joinAbs(a: Abs, b: Abs): Abs;
|
|
731
|
+
declare function markNullProtoObj(o: Abs): Abs;
|
|
732
|
+
declare function isNullProtoObj(o: Abs): boolean;
|
|
733
|
+
/** 同一对象的不可变更新($set/$del)迁移 nullProto 标记 */
|
|
734
|
+
declare function migrateNullProto(from: Abs, to: Abs): Abs;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Map / Set 字面量条目追踪(C1.1 / C1.2)。
|
|
738
|
+
* 按 Abs 对象身份挂 side table:`m.set("k", v)` 后同 identity 的 `m.get("k")`
|
|
739
|
+
* 可回查。非字面量 key 不入表;get/has 对未知 key 保守回落。
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
type LitKey = string | number | boolean | null | undefined;
|
|
743
|
+
type MapTable = {
|
|
744
|
+
byLit: Map<LitKey, Abs>;
|
|
745
|
+
/** 非字面量 key 写入的值(get 未知 key 时 join 用) */
|
|
746
|
+
shadowValues: Abs[];
|
|
747
|
+
/** 抽象分支并入后「可能不存在」的字面量键(get/has 需保守) */
|
|
748
|
+
maybeAbsent?: Set<LitKey>;
|
|
749
|
+
};
|
|
750
|
+
type SetTable = {
|
|
751
|
+
elements: Abs[];
|
|
752
|
+
/**
|
|
753
|
+
* fork 后 membership 不确定。
|
|
754
|
+
* - `true`:整表不确定(未知 delete / 非字面量元素混杂)
|
|
755
|
+
* - `Set<LitKey>`:这些字面 key 可能在部分臂缺失(跨臂 delete 不同元素时,长度启发式不够)
|
|
756
|
+
*/
|
|
757
|
+
maybeAbsent?: true | Set<LitKey>;
|
|
758
|
+
};
|
|
759
|
+
/** $fork 抽象分支:每侧独立 overlay,避免身份表被另一侧 set 污染。
|
|
760
|
+
* 惰性:无集合写入时不分配 WeakMap(fork 热路径上无 Map/Set 是常态)。 */
|
|
761
|
+
type ArmOverlay = WeakMap<object, {
|
|
762
|
+
map?: MapTable;
|
|
763
|
+
set?: SetTable;
|
|
764
|
+
}>;
|
|
765
|
+
declare function pushCollectionArm(): void;
|
|
766
|
+
declare function popCollectionArm(): ArmOverlay | undefined;
|
|
767
|
+
/**
|
|
768
|
+
* 合并 fork 各臂 overlay → 全局表(由 endCollectionFork 实现)。
|
|
769
|
+
* 保留导出名以免外部测试/调用点漂移。
|
|
770
|
+
*/
|
|
771
|
+
declare function mergeCollectionArms(arms: Array<ArmOverlay | undefined | null>): void;
|
|
772
|
+
declare function beginCollectionFork(): void;
|
|
773
|
+
declare function noteCollectionWrite(id: object): void;
|
|
774
|
+
declare function endCollectionFork(arms: Array<ArmOverlay | undefined | null>): void;
|
|
775
|
+
declare function isMapAbs(a: Abs | undefined): boolean;
|
|
776
|
+
declare function isSetAbs(a: Abs | undefined): boolean;
|
|
777
|
+
/**
|
|
778
|
+
* 构造器实参**确定**非法(原生 TypeError 域):
|
|
779
|
+
* - 非可迭代字面量(number/boolean/symbol/bigint、闭对象字面量)→ Set/Map 都抛
|
|
780
|
+
* - Map 条目必须是对象:外层 iterable 出现 lit prim 条目(含字符串实参的
|
|
781
|
+
* 每个字符、tuple/Set 元素)→ TypeError(空串例外:零条目合法)
|
|
782
|
+
* 抽象形态不确定 → false(保守)。
|
|
783
|
+
*/
|
|
784
|
+
declare function ctorArgDefinitelyInvalid(name: "Map" | "Set", iterable: Abs | undefined): boolean;
|
|
785
|
+
declare function makeMapAbs(iterable?: Abs): Abs;
|
|
786
|
+
declare function makeSetAbs(iterable?: Abs): Abs;
|
|
787
|
+
/** Map#set:fork 内写 overlay;否则原地。返回同一 Abs(JS 可变语义) */
|
|
788
|
+
declare function mapSetEntry(mapAbs: Abs, key: Abs | undefined, value: Abs): Abs;
|
|
789
|
+
/** Map#delete:fork overlay 内移除字面量键;未知 key 仅标 shadow 不确定 */
|
|
790
|
+
declare function mapDeleteEntry(mapAbs: Abs, key: Abs | undefined): Abs;
|
|
791
|
+
/** Map#clear:清空条目;fork 下仍走 overlay */
|
|
792
|
+
declare function mapClearEntries(mapAbs: Abs): Abs;
|
|
793
|
+
/** Map#get:命中字面量 key → 精确;miss / 未知 key / maybeAbsent / shadow 并 undefined */
|
|
794
|
+
declare function mapGetEntry(mapAbs: Abs, key: Abs | undefined): Abs;
|
|
795
|
+
/** Map#has:字面量 miss 折 exact false 时,get 必须是 undefined(不可再并 value) */
|
|
796
|
+
declare function mapHasEntry(mapAbs: Abs, key: Abs | undefined): Abs;
|
|
797
|
+
declare function mapSizeAbs(mapAbs: Abs): Abs;
|
|
798
|
+
declare function mapValuesAbs(mapAbs: Abs): Abs[];
|
|
799
|
+
/**
|
|
800
|
+
* Map 迭代条目:JS `for (const [k,v] of map)` / `Array.from(map)` 产出
|
|
801
|
+
* `[key, value]` 元组 Abs。字面量 key 精确;shadow 写入 key 为 unknown。
|
|
802
|
+
*/
|
|
803
|
+
declare function mapEntriesAbs(mapAbs: Abs): Abs[];
|
|
804
|
+
/** Set#add:fork 内写 overlay;返回同一 Abs */
|
|
805
|
+
declare function setAddEntry(setAbs: Abs, value: Abs): Abs;
|
|
806
|
+
/** Set#delete:按字面量元素移除;fork overlay 内生效。
|
|
807
|
+
* 字面量删除且无残留非字面量元素 → 该臂可精确 miss;
|
|
808
|
+
* 臂间分歧由 endCollectionFork 按元素数差标 maybeAbsent。 */
|
|
809
|
+
declare function setDeleteEntry(setAbs: Abs, value: Abs): Abs;
|
|
810
|
+
/** Set#clear */
|
|
811
|
+
declare function setClearEntries(setAbs: Abs): Abs;
|
|
812
|
+
declare function setHasEntry(setAbs: Abs, value: Abs): Abs;
|
|
813
|
+
declare function setSizeAbs(setAbs: Abs): Abs;
|
|
814
|
+
declare function setElementsAbs(setAbs: Abs): Abs[];
|
|
815
|
+
/**
|
|
816
|
+
* 确切条目数:Set 无 maybeAbsent / Map 无 shadow+maybeAbsent 时返回长度;
|
|
817
|
+
* 否则 undefined(for-of 不得假装有界)。
|
|
818
|
+
*/
|
|
819
|
+
declare function collectionExactLen(c: Abs): number | undefined;
|
|
820
|
+
/** 元素联合(for-of / Array.from);无表 → unknown。
|
|
821
|
+
* Map 语义是 entry `[k,v]` 元组联合,不是裸 value。 */
|
|
822
|
+
declare function collectionElementJoin(c: Abs): Abs;
|
|
823
|
+
declare function clearCollectionTables(): void;
|
|
522
824
|
|
|
523
825
|
/**
|
|
524
826
|
* 结构可赋值:src ≤ tgt(Abs 上的 leq)。
|
|
@@ -540,33 +842,20 @@ type LeqResult = {
|
|
|
540
842
|
* src 可赋给 tgt。
|
|
541
843
|
* phi:路径前提(可选);env:用于 brand 继承链。
|
|
542
844
|
*/
|
|
845
|
+
/** Required arity from fn param labels — skips rest (`...`) and optional (`?`). */
|
|
846
|
+
declare function requiredFnArity(params: readonly string[] | undefined): number;
|
|
543
847
|
declare function leqAbs(src: Abs, tgt: Abs, opts?: {
|
|
544
848
|
phi?: Phi;
|
|
545
849
|
env?: AstEnv;
|
|
546
850
|
}): LeqResult;
|
|
547
851
|
|
|
548
852
|
/**
|
|
549
|
-
*
|
|
550
|
-
*
|
|
853
|
+
* Abs 域记录类型面(ast-eval 执行器删除后保留)。
|
|
854
|
+
* 运行时记录由 B 通道(BCallRecord/$assignRecord)产生;此处的类型是
|
|
855
|
+
* checkSource drift / 结构赋值诊断的共享形状,仍被 check.ts 等消费。
|
|
551
856
|
*/
|
|
552
857
|
|
|
553
|
-
|
|
554
|
-
declare function withVar(env: AstEnv, name: string, value: Abs): AstEnv;
|
|
555
|
-
type EvalOptions = {
|
|
556
|
-
phi?: Phi;
|
|
557
|
-
budget?: LeakBudget;
|
|
558
|
-
/** 预解析 AST(check 等批量场景避免重复 parse) */
|
|
559
|
-
file?: File;
|
|
560
|
-
/** host 已求值的相对依赖导出表 */
|
|
561
|
-
modules?: Record<string, AbsModuleExports>;
|
|
562
|
-
};
|
|
563
|
-
declare const MAX_CALL_DEPTH = 64;
|
|
564
|
-
declare const MAX_TOTAL_CALLS = 200000;
|
|
565
|
-
/** 宿主入口(evalProgramAbs / analyzeFn / check)前重置 */
|
|
566
|
-
declare function resetAbsCallBudget(): void;
|
|
567
|
-
/** 记录被截断的递归(service 可映射为 nudo:recursion-truncated) */
|
|
568
|
-
declare function setAbsTruncationCollector(collector: ((fnLabel: string) => void) | null): void;
|
|
569
|
-
/** Abs 域调用记录(自包含程序可不经 TypeValue evaluator) */
|
|
858
|
+
/** Abs 域调用记录(B 通道 BCallRecord 的同形投影) */
|
|
570
859
|
type AbsCallRecord = {
|
|
571
860
|
fnName: string;
|
|
572
861
|
args: Abs[];
|
|
@@ -577,9 +866,7 @@ type AbsCallRecord = {
|
|
|
577
866
|
};
|
|
578
867
|
threw?: boolean;
|
|
579
868
|
};
|
|
580
|
-
|
|
581
|
-
declare function setAbsNodeCollector(collector: ((node: Node, value: Abs) => void) | null): void;
|
|
582
|
-
/** 赋值记录:结构可赋值检查用 */
|
|
869
|
+
/** Abs 域赋值记录(B 通道 $assignRecord 的同形投影) */
|
|
583
870
|
type AbsAssignRecord = {
|
|
584
871
|
name: string;
|
|
585
872
|
prev?: Abs;
|
|
@@ -589,98 +876,6 @@ type AbsAssignRecord = {
|
|
|
589
876
|
/** 分支/循环体内发生:可变绑定在路径上取并集是合法 JS,不参与结构检查 */
|
|
590
877
|
conditional?: boolean;
|
|
591
878
|
};
|
|
592
|
-
declare function setAbsAssignCollector(collector: ((r: AbsAssignRecord) => void) | null): void;
|
|
593
|
-
type EvalResult = {
|
|
594
|
-
value: Abs;
|
|
595
|
-
phi: Phi;
|
|
596
|
-
env: AstEnv;
|
|
597
|
-
/** 函数已通过 return 跳出,块内后续语句不可达 */
|
|
598
|
-
returned?: boolean;
|
|
599
|
-
/** break 跳出最近循环 */
|
|
600
|
-
brk?: boolean;
|
|
601
|
-
/** continue 进入下一轮 */
|
|
602
|
-
cont?: boolean;
|
|
603
|
-
/** throw 了 value(未捕获时向上传播) */
|
|
604
|
-
threw?: boolean;
|
|
605
|
-
/**
|
|
606
|
-
* if 无 else 且 consequent 已 return/throw:真分支已产出 value,
|
|
607
|
-
* 假分支 fall-through 仍可能走后续语句。evalBlock 需与后续结果 join。
|
|
608
|
-
*/
|
|
609
|
-
partialReturn?: boolean;
|
|
610
|
-
};
|
|
611
|
-
/**
|
|
612
|
-
* 分析一段 JS 源码。
|
|
613
|
-
* 若含多个顶层函数声明,先注册全部,再对 `main` 或最后一个有调用的函数求值。
|
|
614
|
-
* 更简单:提供 `analyzeFunction(source, fnName, args)`。
|
|
615
|
-
*/
|
|
616
|
-
declare function evalSource(source: string, entry: {
|
|
617
|
-
fn: string;
|
|
618
|
-
args: Abs[];
|
|
619
|
-
}, opts?: EvalOptions): EvalResult;
|
|
620
|
-
declare function callFunction(env: AstEnv, name: string, args: Abs[], phi?: Phi, budget?: LeakBudget): Abs;
|
|
621
|
-
/**
|
|
622
|
-
* 在 this=receiver 下求值方法体。
|
|
623
|
-
* constructor 无显式 return 时返回更新后的 this(字段写入已并入 env)。
|
|
624
|
-
*/
|
|
625
|
-
declare function evalMethodBody(method: {
|
|
626
|
-
params: string[];
|
|
627
|
-
body: Node;
|
|
628
|
-
async?: boolean;
|
|
629
|
-
kind?: string;
|
|
630
|
-
}, args: Abs[], thisVal: Abs, env: AstEnv, phi?: Phi, budget?: LeakBudget,
|
|
631
|
-
/** 方法定义所在类名(用于 super 派发) */
|
|
632
|
-
ownerClass?: string): Abs;
|
|
633
|
-
/** 对外入口:求值并记入节点表(Map<Node, Abs> 由 collector 消费) */
|
|
634
|
-
declare function evalNode(node: Node, env: AstEnv, phi: Phi, budget: LeakBudget): EvalResult;
|
|
635
|
-
/**
|
|
636
|
-
* 应用 Abs 一等函数。统一顺序:apply → body → relation → isRelFn。
|
|
637
|
-
* 调用门须扩为 `getFnImpl || isRelFn`,否则 E 路径永远进不来。
|
|
638
|
-
*/
|
|
639
|
-
declare function applyAbsFn(fnVal: Abs, args: Abs[], env: AstEnv, phi: Phi, budget: LeakBudget): Abs;
|
|
640
|
-
/**
|
|
641
|
-
* 从源码分析指定函数在给定实参下的抽象结果。
|
|
642
|
-
*
|
|
643
|
-
* @example
|
|
644
|
-
* analyzeFn(`
|
|
645
|
-
* const add = (a, b) => a + b;
|
|
646
|
-
* function scale(x) { return add(x, 1); }
|
|
647
|
-
* `, "scale", [numVar("x", gtNum(v("x"), 0))], gtNum(v("x"), 0))
|
|
648
|
-
*/
|
|
649
|
-
declare function analyzeFn(source: string, fnName: string, args: Abs[], phi?: Phi, budget?: LeakBudget, file?: File, modules?: Record<string, AbsModuleExports>): Abs;
|
|
650
|
-
/**
|
|
651
|
-
* 程序级 Abs 求值:注册全部顶层函数/class,再顺序执行语句。
|
|
652
|
-
* 返回最终 env(vars 含导出绑定)。TypeValue 仅在调用方 bridge 时出现。
|
|
653
|
-
*
|
|
654
|
-
* seedVars / seedFns:host 注入(@nudo:mock 等)在求值前绑定。
|
|
655
|
-
* modules:host 已求值的依赖导出表(specifier → AbsModuleExports)。
|
|
656
|
-
*/
|
|
657
|
-
declare function evalProgramAbs(source: string, opts?: EvalOptions & {
|
|
658
|
-
seedVars?: Record<string, Abs>;
|
|
659
|
-
seedFns?: Record<string, {
|
|
660
|
-
params: string[];
|
|
661
|
-
body: Node;
|
|
662
|
-
async?: boolean;
|
|
663
|
-
}>;
|
|
664
|
-
modules?: Record<string, AbsModuleExports>;
|
|
665
|
-
}): {
|
|
666
|
-
env: AstEnv;
|
|
667
|
-
last: Abs;
|
|
668
|
-
phi: Phi;
|
|
669
|
-
};
|
|
670
|
-
/**
|
|
671
|
-
* 收集整文件的节点 → Abs 表(LSP 无损信息源)。
|
|
672
|
-
* 自包含源码上一次 evalProgramAbs 即可;失败返回空表。
|
|
673
|
-
*/
|
|
674
|
-
declare function collectAbsNodeTypes(source: string, opts?: EvalOptions & {
|
|
675
|
-
seedVars?: Record<string, Abs>;
|
|
676
|
-
seedFns?: Record<string, {
|
|
677
|
-
params: string[];
|
|
678
|
-
body: Node;
|
|
679
|
-
async?: boolean;
|
|
680
|
-
}>;
|
|
681
|
-
}): Map<Node, Abs>;
|
|
682
|
-
/** 按 loc 找最紧的节点 Abs(hover 用) */
|
|
683
|
-
declare function findAbsAtPosition(nodeTypes: Map<Node, Abs>, line: number, column: number): Abs | undefined;
|
|
684
879
|
|
|
685
880
|
/**
|
|
686
881
|
* 格式化:把 Abs 渲染成人类可读 / CLI 友好的字符串。
|
|
@@ -701,366 +896,81 @@ declare function formatShape(a: Abs): string;
|
|
|
701
896
|
declare function formatAbsMultiline(a: Abs, label?: string): string;
|
|
702
897
|
|
|
703
898
|
/**
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*/
|
|
707
|
-
declare function normPath(p: string): string;
|
|
708
|
-
/** core 不引 path:相对 spec 纯字符串拼接(与 LSP resolve 对齐时双方 norm) */
|
|
709
|
-
declare function resolveDepPath(fromFile: string, spec: string): string;
|
|
710
|
-
/**
|
|
711
|
-
* 是否落在 node_modules 下(相对/绝对/盘符形态统一)。
|
|
712
|
-
* autoBind 永不 ambient 加载 node_modules 侧车(§2.2)——必须在 normPath
|
|
713
|
-
* 之后判定,否则 `node_modules/pkg/x.js`(无前导 `/`)会绕过守卫。
|
|
714
|
-
*/
|
|
715
|
-
declare function isNodeModulesPath(p: string): boolean;
|
|
716
|
-
/**
|
|
717
|
-
* 源文件的旁路侧车路径:.js/.mjs → 同名 .nudo.js;.ts/.mts → 同名 .nudo.ts。
|
|
718
|
-
* 其他扩展名(.cjs/.jsx/无扩展名…)不做替换,直接追加 .nudo.js——侧车约定
|
|
719
|
-
* 只覆盖四类入口;host loadModule 对不存在的路径返回 miss,自然无侧车来源。
|
|
720
|
-
*/
|
|
721
|
-
declare function sidecarPathOf(file: string): string;
|
|
722
|
-
|
|
723
|
-
/**
|
|
724
|
-
* 约束模板构建器(参数无关)。
|
|
725
|
-
*
|
|
726
|
-
* number().gt(0) → 占位项 self 上的 Pred
|
|
727
|
-
* number().int().ge(0) → 整数 + 下界
|
|
728
|
-
* string().min(1) → 非空串(长度)
|
|
729
|
-
* array(number().gt(0)) → 元素约束
|
|
730
|
-
* shape({ id: number().gt(0) }) → object 形状约束
|
|
731
|
-
* lit(42) → 字面量(prim + eq(self, 42))
|
|
732
|
-
* union(number().gt(0), lit(0)) → 成员析取(or / joinAbs)
|
|
733
|
-
* fn({ x: number().gt(0) }, number()) → 一等函数约束
|
|
734
|
-
* number().gt(0).shift(1) → 界平移(x>0 ⇒ x+n>1)
|
|
735
|
-
* instantiate("ms") → Pred ms > 0 / u.id > 0 ∧ …
|
|
899
|
+
* C4.1:函数形参表面(contract surface)——
|
|
900
|
+
* 侧车 `fn({…})` / `@nudo:contract` 参数名与求值形参的对齐基线。
|
|
736
901
|
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
readonly int?: boolean;
|
|
763
|
-
/** 该约束整体可选(shape 字段用;不用 optional 以免与链式方法撞名) */
|
|
764
|
-
readonly isOptional?: boolean;
|
|
765
|
-
/** union 成员(析取):instantiate 为 or(...),entry Abs 为成员 join */
|
|
766
|
-
readonly members?: NudoConstraint[];
|
|
767
|
-
/** 一等函数约束(fn() 构建器产出) */
|
|
768
|
-
readonly fn?: NudoFnConstraint;
|
|
769
|
-
};
|
|
770
|
-
/** fn(params, returns?, { throws? }) 的一等函数约束形态 */
|
|
771
|
-
type NudoFnConstraint = {
|
|
772
|
-
params: Record<string, NudoConstraint>;
|
|
773
|
-
returns?: NudoConstraint;
|
|
774
|
-
throws?: NudoConstraint;
|
|
775
|
-
};
|
|
776
|
-
declare function isNudoConstraint(x: unknown): x is NudoConstraint;
|
|
777
|
-
/** 链式约束:不可变,每次 .gt() 返回新对象 */
|
|
778
|
-
type ConstraintBuilder = NudoConstraint & {
|
|
779
|
-
gt(n: number): ConstraintBuilder;
|
|
780
|
-
ge(n: number): ConstraintBuilder;
|
|
781
|
-
lt(n: number): ConstraintBuilder;
|
|
782
|
-
le(n: number): ConstraintBuilder;
|
|
783
|
-
/** number:要求整数 */
|
|
784
|
-
int(): ConstraintBuilder;
|
|
785
|
-
/** string:长度下界 */
|
|
786
|
-
min(n: number): ConstraintBuilder;
|
|
787
|
-
/** string:长度上界 */
|
|
788
|
-
max(n: number): ConstraintBuilder;
|
|
789
|
-
/** string:精确长度 */
|
|
790
|
-
length(n: number): ConstraintBuilder;
|
|
902
|
+
* - Identifier / 默认参(AssignmentPattern left)→ 绑定名
|
|
903
|
+
* - RestElement → 契约名用裸名(`args`),展示名 `...args`
|
|
904
|
+
* - ObjectPattern / ArrayPattern → 求值占位 `_p{i}`;契约面 = 顶层绑定名
|
|
905
|
+
* (对象属性 / 数组元素 Identifier)。嵌套 pattern 的绑定名标 `nested`,
|
|
906
|
+
* 消费方可显式降级(C4.5 param-mismatch / 不执法)。
|
|
907
|
+
*/
|
|
908
|
+
type FormalParam = {
|
|
909
|
+
kind: "id";
|
|
910
|
+
name: string;
|
|
911
|
+
index: number;
|
|
912
|
+
} | {
|
|
913
|
+
kind: "default";
|
|
914
|
+
name: string;
|
|
915
|
+
index: number;
|
|
916
|
+
} | {
|
|
917
|
+
kind: "rest";
|
|
918
|
+
name: string;
|
|
919
|
+
display: string;
|
|
920
|
+
index: number;
|
|
921
|
+
} | {
|
|
922
|
+
kind: "pattern";
|
|
923
|
+
/** 求值/签名占位名(generalize 与 dts 用) */
|
|
924
|
+
placeholder: string;
|
|
925
|
+
/** 顶层可表达绑定名(侧车契约面) */
|
|
926
|
+
bound: string[];
|
|
791
927
|
/**
|
|
792
|
-
*
|
|
793
|
-
*
|
|
928
|
+
* 契约名 → 对象属性键。rename `{a: b}` 时契约可写 a 或 b,
|
|
929
|
+
* 投影必须用属性键 a(Abs 对象只有 slot a)。
|
|
794
930
|
*/
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
/**
|
|
800
|
-
* builder 与纯数据形态统一的 int 标志读取:纯数据看 `int === true`,
|
|
801
|
-
* builder(int 是链式方法)查 WeakSet。toPlainConstraint 归一化后只剩前者。
|
|
802
|
-
*/
|
|
803
|
-
declare function isIntFlag(c: NudoConstraint): boolean;
|
|
804
|
-
/** number() —— 约束 number 原语 + 后续链式界 */
|
|
805
|
-
declare function number(): ConstraintBuilder;
|
|
806
|
-
declare function string(): ConstraintBuilder;
|
|
807
|
-
declare function boolean(): ConstraintBuilder;
|
|
808
|
-
/** array(item) —— 数组,元素满足 item */
|
|
809
|
-
declare function array(item: NudoConstraint | ConstraintBuilder): ConstraintBuilder;
|
|
810
|
-
/**
|
|
811
|
-
* object 形状约束(契约规范形状,无需 interface):
|
|
812
|
-
*
|
|
813
|
-
* shape({ id: number().gt(0), name: string() })
|
|
814
|
-
*/
|
|
815
|
-
declare function shape(fields: Record<string, NudoConstraint | ConstraintBuilder>): ConstraintBuilder;
|
|
816
|
-
/** union(...cs):成员析取;instantiate 为 or(...),entry Abs 为成员 joinAbs。空参 throw */
|
|
817
|
-
declare function union(...cs: (NudoConstraint | ConstraintBuilder)[]): ConstraintBuilder;
|
|
818
|
-
/**
|
|
819
|
-
* fn(params, returns?, { throws? }):一等函数约束。
|
|
820
|
-
* Phase 1 只展示不执法:参数位 instantiate 恒真(pTrue),
|
|
821
|
-
* 逐参约束经 fnConstraintToEntryReqs 消费。
|
|
822
|
-
*/
|
|
823
|
-
declare function fn(params: Record<string, NudoConstraint | ConstraintBuilder>, returns?: NudoConstraint | ConstraintBuilder, opts?: {
|
|
824
|
-
throws?: NudoConstraint | ConstraintBuilder;
|
|
825
|
-
}): ConstraintBuilder;
|
|
826
|
-
/** partial(c):shape 全字段变可选;非 shape throw */
|
|
827
|
-
declare function partial(c: NudoConstraint | ConstraintBuilder): ConstraintBuilder;
|
|
828
|
-
/** pick(c, keys):shape 子形状(不存在的 key 忽略);非 shape throw */
|
|
829
|
-
declare function pick(c: NudoConstraint | ConstraintBuilder, keys: string[]): ConstraintBuilder;
|
|
830
|
-
/** omit(c, keys):shape 去字段;非 shape throw */
|
|
831
|
-
declare function omit(c: NudoConstraint | ConstraintBuilder, keys: string[]): ConstraintBuilder;
|
|
832
|
-
/** 把模板绑定到参数名:self → paramName;shape 展开为字段访问 Pred */
|
|
833
|
-
declare function instantiateConstraint(c: NudoConstraint, paramName: string): Pred;
|
|
834
|
-
/**
|
|
835
|
-
* 契约 → 函数入口 param Abs(infer/hover 用)。
|
|
836
|
-
* 标量:prim + pred;shape:obj slots 递归;union:成员 joinAbs;
|
|
837
|
-
* fn 形态:退化 unknown(不是参数位标量值),逐参约束由 fnConstraintToEntryReqs 消费。
|
|
838
|
-
*/
|
|
839
|
-
declare function constraintToEntryAbs(c: NudoConstraint, paramName: string): Abs;
|
|
840
|
-
/**
|
|
841
|
-
* fn 约束 → 逐参约束表(interface 推导 / 入口签名消费)。
|
|
842
|
-
* 非 fn() 形态 throw——调用方应先判 c.fn。
|
|
843
|
-
*/
|
|
844
|
-
declare function fnConstraintToEntryReqs(c: NudoConstraint): Array<{
|
|
845
|
-
param: string;
|
|
846
|
-
constraint: NudoConstraint;
|
|
847
|
-
}>;
|
|
848
|
-
|
|
849
|
-
/**
|
|
850
|
-
* 精化契约解析:唯一形态
|
|
851
|
-
*
|
|
852
|
-
* @nudo:refine <param> <constraint> 参数精化(挂入口 Abs,参与运算)
|
|
853
|
-
* @nudo:refine return <constraint> 返回精化(推断返回值 ⊭ 时红)
|
|
854
|
-
*
|
|
855
|
-
* 不叫 requires:那只是「校验挡板」。
|
|
856
|
-
* refine 表示约束是类型的一部分——Abs = shape × term × **pred** × conf,
|
|
857
|
-
* pred 会流入代数(x>0 ⇒ x+1>1),不只是调用点挡一下。
|
|
858
|
-
*
|
|
859
|
-
* constraint 来自 *.nudo.js 导出的模板(number().gt(0) 等),
|
|
860
|
-
* 由 /// @nudo:import { delay } from "./delay.nudo.js" 引入。
|
|
861
|
-
* 不支持写 `x > 0`(绑死参数名)。
|
|
862
|
-
* 不用 JSDoc @param/@return:那是类型注解语法。
|
|
863
|
-
*
|
|
864
|
-
* `@nudo:interface` 是 `@nudo:refine` 的等价别名(渐进迁移,§design-refine-derivation)。
|
|
865
|
-
* 侧车加载:Babel 语句级改写(多行 import / 注释与字符串里的同形文本不误伤)、
|
|
866
|
-
* 相对 .nudo.js/.nudo.ts 经 loadModule 递归求值、环检测、执行失败改诊断
|
|
867
|
-
* (nudo:interface-load / nudo:interface-cycle,不再静默吞错)。
|
|
868
|
-
*/
|
|
869
|
-
|
|
870
|
-
/** `/// @nudo:import { delay, percent } from "./delay.nudo.js"` */
|
|
871
|
-
type NamedImport = {
|
|
872
|
-
names: string[];
|
|
873
|
-
spec: string;
|
|
874
|
-
};
|
|
875
|
-
declare function extractNudoImports(source: string): NamedImport[];
|
|
876
|
-
/** refine 侧车加载诊断(severity 由消费方按 code 定档,形状对齐 Issue 子集) */
|
|
877
|
-
type RefineDiag = {
|
|
878
|
-
code: string;
|
|
879
|
-
message: string;
|
|
880
|
-
file?: string;
|
|
881
|
-
};
|
|
882
|
-
/** 设置诊断观察者(null 清除);缓冲照常累积,takeRefineDiags 取走 */
|
|
883
|
-
declare function setRefineDiagCollector(fn: ((d: RefineDiag) => void) | null): void;
|
|
884
|
-
/** 当前诊断累计序号(since 锚) */
|
|
885
|
-
declare function refineDiagCount(): number;
|
|
886
|
-
/** 取走已收集的诊断(收集即清空) */
|
|
887
|
-
declare function takeRefineDiags(): RefineDiag[];
|
|
888
|
-
/** 只取走 seq > since 的增量(工具面防窃取在途诊断;全量 take 的 since 版) */
|
|
889
|
-
declare function takeRefineDiagsSince(since: number): RefineDiag[];
|
|
890
|
-
/** 侧车模块错误:code ∈ nudo:interface-cycle | nudo:interface-load */
|
|
891
|
-
declare class NudoSidecarError extends Error {
|
|
892
|
-
readonly code: string;
|
|
893
|
-
constructor(code: string, message: string);
|
|
894
|
-
}
|
|
895
|
-
/**
|
|
896
|
-
* 执行 *.nudo.js(真实 JS + 我们的构建器)。import/export 由 Babel 语句级
|
|
897
|
-
* 改写:多行 named import、注释/字符串里的同形文本不误伤;相对 .nudo 递归
|
|
898
|
-
* 求值;环 → throw NudoSidecarError。结果进 exec 缓存(依赖闭包内容指纹键)。
|
|
899
|
-
*/
|
|
900
|
-
declare function execNudoModule(src: string, opts?: RefineResolveOpts): Record<string, unknown>;
|
|
901
|
-
type RefineResolveOpts = {
|
|
902
|
-
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
903
|
-
/** 侧车自身的路径(相对 spec 解析基准 + 环检测链起点) */
|
|
904
|
-
fromFile?: string;
|
|
931
|
+
propKey: Record<string, string>;
|
|
932
|
+
/** 仅嵌套内出现、顶层不可单独表达的名(降级用) */
|
|
933
|
+
nested: string[];
|
|
934
|
+
index: number;
|
|
905
935
|
};
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
936
|
+
type AstParam = {
|
|
937
|
+
type: string;
|
|
938
|
+
name?: string;
|
|
939
|
+
left?: AstParam;
|
|
940
|
+
right?: unknown;
|
|
941
|
+
argument?: AstParam;
|
|
942
|
+
properties?: Array<{
|
|
943
|
+
key?: AstParam;
|
|
944
|
+
value?: AstParam;
|
|
945
|
+
type?: string;
|
|
946
|
+
argument?: AstParam;
|
|
947
|
+
}>;
|
|
948
|
+
elements?: Array<AstParam | null | undefined>;
|
|
916
949
|
};
|
|
917
|
-
declare function
|
|
918
|
-
/**
|
|
919
|
-
declare function
|
|
920
|
-
/**
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
950
|
+
declare function formalParamsFromNodes(params: AstParam[] | undefined | null): FormalParam[];
|
|
951
|
+
/** 求值/签名用形参名(与 analyzer extractParamNames / dts 对齐) */
|
|
952
|
+
declare function formalParamDisplayNames(formals: FormalParam[]): string[];
|
|
953
|
+
/** 侧车契约可绑定的参数名全集 */
|
|
954
|
+
declare function contractParamNameSet(formals: FormalParam[]): Set<string>;
|
|
955
|
+
/**
|
|
956
|
+
* 契约参数名 → 形参定位。
|
|
957
|
+
* - 命中 id/default/rest → 该 index(执法按整参)
|
|
958
|
+
* - 命中 pattern 顶层 bound 名 → 该 pattern index + field
|
|
959
|
+
* - 命中 placeholder / `_` → pattern index(整对象)
|
|
960
|
+
* - 未命中 → undefined(C4.5 param-mismatch)
|
|
961
|
+
*/
|
|
962
|
+
declare function locateContractParam(formals: FormalParam[], contractName: string): {
|
|
963
|
+
index: number;
|
|
964
|
+
field?: string;
|
|
965
|
+
rest?: boolean;
|
|
927
966
|
} | undefined;
|
|
928
967
|
|
|
929
968
|
/**
|
|
930
|
-
*
|
|
931
|
-
*
|
|
932
|
-
* effectiveInterface(source, fnName) —— 手写 ∪ 侧车同名绑定 ∪ 生成段的
|
|
933
|
-
* 唯一读取口,来源标注(handwritten / generated / implicit)随值返回。
|
|
934
|
-
*
|
|
935
|
-
* 来源三层(合并序 handwritten > generated > implicit,§4/§11):
|
|
936
|
-
* - handwritten:源码 `@nudo:refine`/`@nudo:interface` 行(复用 refine.ts 的
|
|
937
|
-
* extractRefinesFromSource / extractRefineReturnFromSource)∪ 侧车同名**手写**
|
|
938
|
-
* fn() 绑定。同名同参取合取 and()(§2.1:侧车 x>0 + 源码 x>1 → 有效契约
|
|
939
|
-
* 取合取);常数界交叉矛盾(x>0 ∧ x<0)→ conflict 标记,由调用方报
|
|
940
|
-
* nudo:interface-conflict——本函数不 throw。
|
|
941
|
-
* - generated:侧车同名导出且声明上方注释块含 @generated 标记(emit 产物)。
|
|
942
|
-
* 与手写并存时整体降级忽略(手写为准;混排由 nudo:interface-name-clash /
|
|
943
|
-
* drift 在 emit/check 侧处理)。
|
|
944
|
-
* - implicit:无任何契约 → 返回 undefined(隐式推断是调用方的事)。
|
|
945
|
-
*
|
|
946
|
-
* 自动绑定边界(§2.2):只绑源文件**本地 named export**(re-export /
|
|
947
|
-
* export default / 私有名不绑);opts.autoBind === false 或侧车路径含
|
|
948
|
-
* /node_modules/ → 不 ambient 加载(只看源码 refine)。「项目根内」检查属
|
|
949
|
-
* 宿主层(core 无 projectDir 概念),Phase 1 不在此实现。
|
|
950
|
-
*
|
|
951
|
-
* 侧车绑定 Phase 1 只承诺 fn() 形态:非 fn 的标量/shape 绑定不消费,收集
|
|
952
|
-
* nudo:interface-load 诊断(后续 Phase 再放开单参形态)。
|
|
953
|
-
*
|
|
954
|
-
* 诊断走本文件独立 side-channel(先例 refine.ts 的 setRefineDiagCollector):
|
|
955
|
-
* 侧车加载/执行失败 → nudo:interface-cycle / nudo:interface-load。
|
|
956
|
-
*/
|
|
957
|
-
|
|
958
|
-
/** interface 推导诊断(severity 由消费方按 code 定档,形状对齐 Issue 子集) */
|
|
959
|
-
type InterfaceDiag = {
|
|
960
|
-
code: string;
|
|
961
|
-
message: string;
|
|
962
|
-
file?: string;
|
|
963
|
-
};
|
|
964
|
-
/** 设置诊断观察者(null 清除);缓冲照常累积,takeInterfaceDiags 取走 */
|
|
965
|
-
declare function setInterfaceDiagCollector(fn: ((d: InterfaceDiag) => void) | null): void;
|
|
966
|
-
/** 当前诊断累计序号(since 锚:工具面只排干自身探测产生的增量) */
|
|
967
|
-
declare function interfaceDiagCount(): number;
|
|
968
|
-
/** 取走已收集的诊断(收集即清空) */
|
|
969
|
-
declare function takeInterfaceDiags(): InterfaceDiag[];
|
|
970
|
-
/**
|
|
971
|
-
* 只取走 seq > since 的诊断(清空仅限增量)——LSP 长驻进程里 lens/打印/
|
|
972
|
-
* emit 工具用它排干**自身探测**产生的诊断,不窃取在途 validateText 待消费
|
|
973
|
-
* 的接口诊断(全量 take 曾在 await 窗口偷走 checkSource 的待收诊断)。
|
|
974
|
-
*/
|
|
975
|
-
declare function takeInterfaceDiagsSince(since: number): InterfaceDiag[];
|
|
976
|
-
/** 有效契约来源:手写(源码 refine ∪ 侧车手写绑定)> 生成段 > 隐式 */
|
|
977
|
-
type InterfaceSource = "handwritten" | "generated" | "implicit";
|
|
978
|
-
/**
|
|
979
|
-
* 源文件本地 named export 表:收集本文件声明并导出的名字——
|
|
980
|
-
* `export function/const/let/var/class` 声明形式,以及本地列表
|
|
981
|
-
* `export { x }` / `export { local as exported }`(按**导出名**绑定,
|
|
982
|
-
* 与侧车同名自动绑定口径一致)。
|
|
983
|
-
* 排除 re-export(`export {x} from` / `export *`)与 `export default`。
|
|
984
|
-
*/
|
|
985
|
-
declare function localNamedExports(source: string): Set<string>;
|
|
986
|
-
/**
|
|
987
|
-
* 侧车源码的生成段导出名:导出名所在声明的**前置注释块**含 `@generated`
|
|
988
|
-
* 标记(emit 产物 canonical 注释为 `@generated by nudo`)→ 该名为 generated。
|
|
989
|
-
* Phase 1 简化:只看紧邻声明上方的注释块(与 extractRefineLines 同款反向
|
|
990
|
-
* 行扫描,空行可跨);隔了代码行 / 无标记 / re-export 列表均不算。
|
|
991
|
-
*/
|
|
992
|
-
declare function generatedExportNames(sidecarSrc: string): Set<string>;
|
|
993
|
-
type EffectiveInterfaceOpts = RefineResolveOpts & {
|
|
994
|
-
/** false(或谓词返回 false)→ 不 ambient 加载侧车;默认 true */
|
|
995
|
-
autoBind?: boolean | ((sidecarPath: string) => boolean);
|
|
996
|
-
};
|
|
997
|
-
type EffectiveInterface = {
|
|
998
|
-
fnName: string;
|
|
999
|
-
params: Array<{
|
|
1000
|
-
param: string;
|
|
1001
|
-
constraint: NudoConstraint;
|
|
1002
|
-
}>;
|
|
1003
|
-
returns?: {
|
|
1004
|
-
constraint: NudoConstraint;
|
|
1005
|
-
};
|
|
1006
|
-
source: InterfaceSource;
|
|
1007
|
-
/**
|
|
1008
|
-
* 合取不可满足标记:params = 常数界交叉矛盾(或 prim 矛盾等 and() 不可
|
|
1009
|
-
* 合取形态)的参数名;returns = 返回位同样不可满足。调用方报
|
|
1010
|
-
* nudo:interface-conflict 并跳过对应位执法。
|
|
1011
|
-
*/
|
|
1012
|
-
conflict?: {
|
|
1013
|
-
params: string[];
|
|
1014
|
-
returns?: boolean;
|
|
1015
|
-
};
|
|
1016
|
-
};
|
|
1017
|
-
/**
|
|
1018
|
-
* 单点读取口:手写 ∪ 侧车同名 ∪ 生成段 → 有效契约(含来源标注)。
|
|
1019
|
-
* 无任何契约 → undefined(implicit 由调用方处理)。
|
|
969
|
+
* Abs 键 / α-rename(从 generalize.ts 拆出的纯结构变换)。
|
|
1020
970
|
*/
|
|
1021
|
-
declare function effectiveInterface(source: string, fnName: string, opts?: EffectiveInterfaceOpts): EffectiveInterface | undefined;
|
|
1022
|
-
/**
|
|
1023
|
-
* 侧车及递归 .nudo 依赖闭包的内容指纹:`${hashSource(侧车)}|路径=hash,…`。
|
|
1024
|
-
* 无 loadModule / autoBind 关闭 / node_modules / loadModule miss → undefined
|
|
1025
|
-
* (无侧车影响即无需指纹)。闭包截断 → `trunc:` 前缀,键不可信,调用方
|
|
1026
|
-
* fail-open(参照 loadModuleDepsFingerprint 的 truncated 契约)。
|
|
1027
|
-
*/
|
|
1028
|
-
declare function sidecarClosureFingerprint(fromFile: string, opts: EffectiveInterfaceOpts): string | undefined;
|
|
1029
|
-
/** 组合式显示:重建构建器调用形态(number().gt(0) / union(…) / fn(…)) */
|
|
1030
|
-
declare function formatConstraint(c: NudoConstraint): string;
|
|
1031
971
|
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
paths: string[];
|
|
1035
|
-
/** BFS 撞到节点上限:剩余 dep 未进指纹,键不可信 */
|
|
1036
|
-
truncated: boolean;
|
|
1037
|
-
};
|
|
1038
|
-
/**
|
|
1039
|
-
* All string module specs that analysis may resolve through loadModule.
|
|
1040
|
-
* Regex over-approximates (may hit comments) — extra dep fingerprint is safe
|
|
1041
|
-
* (more misses, never a stale hit).
|
|
1042
|
-
*/
|
|
1043
|
-
declare function extractAllLoadSpecs(source: string): string[];
|
|
1044
|
-
/**
|
|
1045
|
-
* 源里指向其他侧车的相对 spec(`.nudo.js`/`.nudo.ts`)。regex 过近似安全:
|
|
1046
|
-
* 多算的 dep 只带来额外 miss,绝不产生陈旧命中。LSP 隐式依赖登记共用。
|
|
1047
|
-
*/
|
|
1048
|
-
declare function sidecarSpecsOf(source: string): string[];
|
|
1049
|
-
/**
|
|
1050
|
-
* Fingerprint every loadModule-reachable dep (not only `*.nudo.js`), including
|
|
1051
|
-
* one hop of transitive specs from each dep source — plus the autoBind 侧车
|
|
1052
|
-
* 闭包(`sidecar:` 前缀条目)。
|
|
1053
|
-
*
|
|
1054
|
-
* 侧车吸收范围 = fromFile 自身 **与每一个成功加载的依赖文件**的旁路侧车及其
|
|
1055
|
-
* 递归 .nudo 依赖:跨文件被调(scan.ts checkExternalCall)会按定义文件路径
|
|
1056
|
-
* ambient 绑定其侧车,依赖侧车内容影响调用方报告——不进指纹则编辑后 memo
|
|
1057
|
-
* 陈旧命中(错诊断)。侧车 loadModule miss(无侧车文件)→ 不加任何条目。
|
|
1058
|
-
*
|
|
1059
|
-
* 注意:本扩展对 autoBind=false 与 /node_modules/ 均**不** gate(刻意过近似,
|
|
1060
|
-
* 只过度失效、绝不陈旧命中——安全方向);ambient 生效边界由
|
|
1061
|
-
* interface.ts 的 sidecarClosureFingerprint 负责,两者职责不同。
|
|
1062
|
-
*/
|
|
1063
|
-
declare function loadModuleDepsFingerprint(source: string, loadModule: (spec: string, fromFile: string) => string | undefined, fromFile: string): LoadDepsFingerprint;
|
|
972
|
+
/** 公开:收集 Abs 自由 term 变元(dts 泛型投影 / α 作用域判定复用 L2 基建)。 */
|
|
973
|
+
declare function collectAbsFreeVars(a: Abs): Set<string>;
|
|
1064
974
|
|
|
1065
975
|
declare function resetGeneralizeMemo(): void;
|
|
1066
976
|
declare function getGeneralizeMemoSize(): number;
|
|
@@ -1069,6 +979,7 @@ declare function getGeneralizeMemoSize(): number;
|
|
|
1069
979
|
* 返回删除的条目数。路径需与 generalize 时 resolveDepPath 形态一致(建议先 norm)。
|
|
1070
980
|
*/
|
|
1071
981
|
declare function evictGeneralizeMemoForPaths(paths: string[]): number;
|
|
982
|
+
|
|
1072
983
|
type TypeParam = {
|
|
1073
984
|
id: string;
|
|
1074
985
|
value: Abs;
|
|
@@ -1080,11 +991,16 @@ type PolyFn = {
|
|
|
1080
991
|
instantiate: (args: Abs[], phi?: Phi) => Abs;
|
|
1081
992
|
symbolic: Abs;
|
|
1082
993
|
display: string;
|
|
1083
|
-
/** 入口契约(@nudo:
|
|
994
|
+
/** 入口契约(@nudo:contract),供签名/inlay 展示 */
|
|
1084
995
|
entryReqs?: Array<{
|
|
1085
996
|
param: string;
|
|
1086
997
|
pred: Pred;
|
|
1087
998
|
}>;
|
|
999
|
+
/**
|
|
1000
|
+
* 形参表面(C4.1):默认/rest/解构的契约可绑定名。
|
|
1001
|
+
* 与 params(求值展示名)并列;检查/侧车匹配走 formals。
|
|
1002
|
+
*/
|
|
1003
|
+
formals?: FormalParam[];
|
|
1088
1004
|
/**
|
|
1089
1005
|
* 函数形参的符号外延(与 typeParams 同 α 空间)。
|
|
1090
1006
|
* symbolic 一次跑正常结束时从 env 快照拷出;instantiate 重跑不写。
|
|
@@ -1107,11 +1023,12 @@ declare function extractFn(source: string, fnName: string, fileAst?: ReturnType<
|
|
|
1107
1023
|
params: string[];
|
|
1108
1024
|
body: Node;
|
|
1109
1025
|
env: AstEnv;
|
|
1026
|
+
formals: FormalParam[];
|
|
1110
1027
|
} | undefined;
|
|
1111
1028
|
declare function generalizeFromAst(fnName: string, source: string, opts?: {
|
|
1112
1029
|
budget?: LeakBudget;
|
|
1113
1030
|
label?: string;
|
|
1114
|
-
/** 传入则把 @nudo:
|
|
1031
|
+
/** 传入则把 @nudo:contract 挂到入口 param Abs */
|
|
1115
1032
|
refine?: EffectiveInterfaceOpts;
|
|
1116
1033
|
/** 预解析 AST,避免 check 批量场景重复 parse */
|
|
1117
1034
|
file?: ReturnType<typeof parseSource>;
|
|
@@ -1119,318 +1036,99 @@ declare function generalizeFromAst(fnName: string, source: string, opts?: {
|
|
|
1119
1036
|
depsFp?: LoadDepsFingerprint;
|
|
1120
1037
|
/** 预计算 ambient 侧车闭包指纹(checkSource 整文件一次) */
|
|
1121
1038
|
sidecarFp?: string;
|
|
1039
|
+
/** 宿主已求值的依赖导出表(specifier → AbsModuleExports) */
|
|
1040
|
+
modules?: Record<string, AbsModuleExports | Record<string, unknown>>;
|
|
1041
|
+
/** B run 注入包(modules/mocks/envGlobals/replacements/as)——透传
|
|
1042
|
+
* runTranspiled;对象身份进 memo 键(调用方同文件内复用同一对象) */
|
|
1043
|
+
inject?: RunTranspiledOptions;
|
|
1122
1044
|
}): PolyFn | undefined;
|
|
1123
1045
|
declare function generalizeAll(source: string, opts?: {
|
|
1124
1046
|
budget?: LeakBudget;
|
|
1125
1047
|
}): PolyFn[];
|
|
1126
|
-
/** 列出源码中的顶层函数名 */
|
|
1127
|
-
declare function listFunctionNames(source: string): string[];
|
|
1128
|
-
/**
|
|
1129
|
-
* 按 assume 集合构造实参:被 assume 的参数给带约束的符号,其余 unknown。
|
|
1130
|
-
*/
|
|
1131
|
-
declare function buildArgsFromAssume(source: string, fnName: string, assumeIds: Set<string>): Abs[];
|
|
1132
|
-
|
|
1133
|
-
/**
|
|
1134
|
-
* 约束诊断:检查调用点实参是否满足函数的前置约束 / 参数 shape。
|
|
1135
|
-
* 输出可行动的建议,而不是 TS 式「类型不匹配」。
|
|
1136
|
-
*/
|
|
1137
|
-
|
|
1138
|
-
type Diagnostic = {
|
|
1139
|
-
severity: "error" | "warning" | "info";
|
|
1140
|
-
code: string;
|
|
1141
|
-
message: string;
|
|
1142
|
-
suggestion?: string;
|
|
1143
|
-
fn?: string;
|
|
1144
|
-
argIndex?: number;
|
|
1145
|
-
};
|
|
1146
|
-
/**
|
|
1147
|
-
* 检查实参是否满足「期望约束」。
|
|
1148
|
-
* expect: 相对参数 term 的 pred,例如 term > 0
|
|
1149
|
-
* arg: 实际实参 Abs
|
|
1150
|
-
*/
|
|
1151
|
-
declare function checkArg(arg: Abs, expect: Pred | undefined, phi?: Phi): Diagnostic | undefined;
|
|
1152
1048
|
/**
|
|
1153
|
-
*
|
|
1049
|
+
* 列出源码中的顶层函数名。
|
|
1050
|
+
* 与 scan.listTopFunctions 对齐:解 export default / export const 箭头与函数表达式。
|
|
1051
|
+
* (不 import scan:scan 依赖本文件,避免环。完整 CJS/class 面用 listTopFunctions。)
|
|
1154
1052
|
*/
|
|
1155
|
-
declare function
|
|
1156
|
-
declare function formatDiagnostics(diags: Diagnostic[]): string;
|
|
1157
|
-
|
|
1053
|
+
declare function listFunctionNames(source: string): string[];
|
|
1158
1054
|
/**
|
|
1159
|
-
*
|
|
1160
|
-
*
|
|
1161
|
-
* 与 core 的 createTemplate 对齐,使 `"x" + string + "!"` 得到 template refined。
|
|
1162
|
-
*
|
|
1163
|
-
* 本模块是模板语义的唯一真理源:前缀/后缀/固定文本/长度/匹配/名称渲染/
|
|
1164
|
-
* 相邻合并/谓词判定等纯计算以「中性 part 视图」(TemplatePartView)暴露;
|
|
1165
|
-
* TypeValue 侧(refinements/template.ts)与 Abs 方法表(methods.ts)只做薄适配。
|
|
1055
|
+
* 按 assume 集合构造实参:被 assume 的参数给带约束的符号,其余 any
|
|
1056
|
+
* (design-cli-semantics §2:入口无约束 = any,不是 unknown)。
|
|
1166
1057
|
*/
|
|
1167
|
-
|
|
1168
|
-
type TemplateMeta = {
|
|
1169
|
-
templateParts: Abs[];
|
|
1170
|
-
};
|
|
1171
|
-
/** 单个 part 的分类:固定文本,或抽象 part(携带展示文本) */
|
|
1172
|
-
type TemplatePartDesc = {
|
|
1173
|
-
fixed: string;
|
|
1174
|
-
} | {
|
|
1175
|
-
render: string;
|
|
1176
|
-
};
|
|
1177
|
-
/** 带原始 part 回引的视图:既喂语义计算,也用于重建合并结果 */
|
|
1178
|
-
type TemplatePartView<P = unknown> = {
|
|
1179
|
-
/** 固定文本;undefined = 抽象 part */
|
|
1180
|
-
fixed: string | undefined;
|
|
1181
|
-
/** 抽象 part 的展示文本(渲染 `${...}` 名时使用) */
|
|
1182
|
-
render: string;
|
|
1183
|
-
part: P;
|
|
1184
|
-
};
|
|
1185
|
-
declare function viewTemplateParts<P>(parts: P[], describe: (p: P) => TemplatePartDesc): TemplatePartView<P>[];
|
|
1186
|
-
/** 前导固定文本(遇到首个抽象 part 停止) */
|
|
1187
|
-
declare function knownPrefixOfViews(views: TemplatePartView[]): string;
|
|
1188
|
-
/** 尾部固定文本(从末尾遇到首个抽象 part 停止) */
|
|
1189
|
-
declare function knownSuffixOfViews(views: TemplatePartView[]): string;
|
|
1190
|
-
/** 全部固定文本按序拼接(跨抽象 part) */
|
|
1191
|
-
declare function allFixedTextOfViews(views: TemplatePartView[]): string;
|
|
1192
|
-
/** 全部 part 均为固定文本时的精确总长;含抽象 part 则 undefined */
|
|
1193
|
-
declare function fixedLengthOfViews(views: TemplatePartView[]): number | undefined;
|
|
1194
|
-
/** 渲染 `` `lit${render}` `` 形态的模板名 */
|
|
1195
|
-
declare function formatTemplateNameViews(views: TemplatePartView[]): string;
|
|
1196
|
-
/** 相邻固定文本合并;rebuildFixed 以合并文本重建视图(含原始 part) */
|
|
1197
|
-
declare function mergeAdjacentFixedViews<P>(views: TemplatePartView<P>[], rebuildFixed: (text: string) => TemplatePartView<P>): TemplatePartView<P>[];
|
|
1198
|
-
/** 具体字符串是否匹配模板(Refinement.check 的判定语义) */
|
|
1199
|
-
declare function templateMatchesValue(value: string, views: TemplatePartView[]): boolean;
|
|
1200
|
-
/** 三值判定;两侧分别把 "unknown" 适配为 boolPrim(Abs)或 undefined(TypeValue) */
|
|
1201
|
-
type TemplatePredicateDecision = boolean | "unknown";
|
|
1202
|
-
declare function decideStartsWith(prefix: string, search: string): TemplatePredicateDecision;
|
|
1203
|
-
declare function decideEndsWith(suffix: string, search: string): TemplatePredicateDecision;
|
|
1204
|
-
declare function decideIncludes(fixedText: string, search: string): TemplatePredicateDecision;
|
|
1205
|
-
declare function absTemplateViews(parts: Abs[]): TemplatePartView<Abs>[];
|
|
1206
|
-
/** 从 Abs 提取 template parts(已是 template 则展开,否则 [self]) */
|
|
1207
|
-
declare function templatePartsOf(a: Abs): Abs[];
|
|
1208
|
-
/**
|
|
1209
|
-
* 构造 template Abs。
|
|
1210
|
-
* - 全字面量 → exact lit
|
|
1211
|
-
* - 单 string prim → prim
|
|
1212
|
-
* - 否则 prim(string) + pred(name=template, meta.templateParts)
|
|
1213
|
-
*/
|
|
1214
|
-
declare function createTemplateAbs(parts: Abs[]): Abs;
|
|
1215
|
-
declare function isTemplateLike(a: Abs): boolean;
|
|
1216
|
-
/** 字符串拼接:字面量折叠 + template parts 合并 */
|
|
1217
|
-
declare function concatString(a: Abs, b: Abs): Abs;
|
|
1218
|
-
|
|
1219
|
-
/**
|
|
1220
|
-
* 语言覆盖:class / new / instanceof / this / async await。
|
|
1221
|
-
* brand 表示名义类;eff("promise") 表示异步效应。
|
|
1222
|
-
*
|
|
1223
|
-
* 方法体:ClassDef.methods 存 AST body,调用时在 this=receiver 下求值。
|
|
1224
|
-
*/
|
|
1225
|
-
|
|
1226
|
-
type MethodDef = {
|
|
1227
|
-
name: string;
|
|
1228
|
-
params: string[];
|
|
1229
|
-
body: Node;
|
|
1230
|
-
kind?: string;
|
|
1231
|
-
async?: boolean;
|
|
1232
|
-
};
|
|
1233
|
-
type ClassDef = {
|
|
1234
|
-
name: string;
|
|
1235
|
-
instanceShape: Abs;
|
|
1236
|
-
ctorParams: string[];
|
|
1237
|
-
methods: Map<string, MethodDef>;
|
|
1238
|
-
superClass?: string;
|
|
1239
|
-
};
|
|
1240
|
-
declare function defineClass(env: AstEnv, def: ClassDef): void;
|
|
1241
|
-
declare function getClass(env: AstEnv, name: string): ClassDef | undefined;
|
|
1242
|
-
/** 沿继承链找类 */
|
|
1243
|
-
declare function getClassChain(env: AstEnv, name: string): ClassDef[];
|
|
1244
|
-
/** new C(...) → brand 实例;并跑 constructor 以写入字段 */
|
|
1245
|
-
declare function instantiateClass(env: AstEnv, className: string, args: Abs[], evalBody?: (fn: {
|
|
1246
|
-
params: string[];
|
|
1247
|
-
body: Node;
|
|
1248
|
-
}, args: Abs[], thisVal: Abs, env: AstEnv) => Abs): Abs;
|
|
1249
|
-
/** 读取当前 this 所属类的父类名 */
|
|
1250
|
-
declare function superNameOf(env: AstEnv, className: string): string | undefined;
|
|
1251
|
-
/**
|
|
1252
|
-
* instanceof:沿继承链匹配 brand 名。
|
|
1253
|
-
*/
|
|
1254
|
-
declare function instanceOf(left: Abs, rightClassName: string, env?: AstEnv): Abs;
|
|
1255
|
-
declare function projectBrand(self: Abs, key: string): Abs;
|
|
1256
|
-
/** 在 brand 上查找方法定义(含继承) */
|
|
1257
|
-
declare function lookupMethod(env: AstEnv, receiver: Abs, methodName: string): MethodDef | undefined;
|
|
1258
|
-
/** 沿继承链查找方法,返回定义与所在类名 */
|
|
1259
|
-
declare function lookupMethodWithOwner(env: AstEnv, receiver: Abs, methodName: string): {
|
|
1260
|
-
def: MethodDef;
|
|
1261
|
-
owner: string;
|
|
1262
|
-
} | undefined;
|
|
1263
|
-
/** super.method():从父类开始找(跳过当前类) */
|
|
1264
|
-
declare function lookupSuperMethod(env: AstEnv, receiver: Abs, fromClass: string, methodName: string): {
|
|
1265
|
-
def: MethodDef;
|
|
1266
|
-
owner: string;
|
|
1267
|
-
} | undefined;
|
|
1268
|
-
declare function wrapPromise(inner: Abs): Abs;
|
|
1269
|
-
declare function awaitAbs(v: Abs): Abs;
|
|
1270
|
-
declare function coerceAsyncReturn(value: Abs): Abs;
|
|
1271
|
-
/** 从 ClassMethod 列表构造 methods map + instance shape */
|
|
1272
|
-
declare function classFromMethods(name: string, methods: MethodDef[], superClass?: string, superShape?: Abs): ClassDef;
|
|
1273
|
-
|
|
1274
|
-
declare function hashSource(s: string): string;
|
|
1275
|
-
declare function resetHashSourceCache(): void;
|
|
1058
|
+
declare function buildArgsFromAssume(source: string, fnName: string, assumeIds: Set<string>): Abs[];
|
|
1276
1059
|
|
|
1277
1060
|
/**
|
|
1278
|
-
*
|
|
1279
|
-
*
|
|
1280
|
-
*
|
|
1281
|
-
* Fast path: already-stable sources return the same string identity (O(1)
|
|
1282
|
-
* compare in B-path / analysis caches when the caller reuses the buffer).
|
|
1061
|
+
* CheckOptions — 从 check.ts 拆出的纯类型,打断 check ↔ check-memo/may-throw 环。
|
|
1062
|
+
* 实现不得 import check.ts;check.ts re-export 本类型以保持公共面。
|
|
1283
1063
|
*/
|
|
1284
|
-
declare function stableAnalyzeKeySource(source: string): string;
|
|
1285
1064
|
|
|
1286
1065
|
/**
|
|
1287
|
-
*
|
|
1288
|
-
*
|
|
1289
|
-
* - own: function declaration slice (incl. leading comments / refine)
|
|
1290
|
-
* - deps: transitively referenced sibling own hashes + non-fn top-level context
|
|
1291
|
-
* - context change (import/class/const...) -> all miss (conservative)
|
|
1292
|
-
*
|
|
1293
|
-
* Multi-declarator `const a = fn, b = fn` yields one fingerprint per function;
|
|
1294
|
-
* each own-slice is its own declarator (first also carries statement leading comments).
|
|
1066
|
+
* check 选项:core 不碰 fs;host 用 loadModule 喂 require 目标源码。
|
|
1295
1067
|
*/
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1068
|
+
type CheckOptions = {
|
|
1069
|
+
/** 相对/绝对 require 说明符 → 模块源码;undefined = 解析失败 */
|
|
1070
|
+
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
1071
|
+
/** 当前文件路径(供 loadModule 解析相对 spec) */
|
|
1072
|
+
fromFile?: string;
|
|
1073
|
+
/**
|
|
1074
|
+
* 侧车 ambient 绑定开关(host 从 package.json#nudo.contract.autoBind
|
|
1075
|
+
* 解析后下传;默认 true)。false = check/LSP 执法路径不自动加载侧车
|
|
1076
|
+
* (§2.2「整体关闭」承诺覆盖 CI 门禁,不只是打印路径)。
|
|
1077
|
+
*/
|
|
1078
|
+
autoBind?: boolean;
|
|
1079
|
+
/**
|
|
1080
|
+
* 项目根(host 从 findProjectConfig 下传):树外侧车不 ambient 绑定。
|
|
1081
|
+
* undefined = 不限(node_modules 仍拦)。
|
|
1082
|
+
*/
|
|
1083
|
+
projectDir?: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* L2 入口 may-throw 执法档(design-cli-semantics §3)。
|
|
1086
|
+
* error(默认)| warning | off。仅作用于 export/default/CJS 入口函数。
|
|
1087
|
+
*/
|
|
1088
|
+
entryThrows?: "error" | "warning" | "off";
|
|
1089
|
+
/** L2 --ignore-throws:按 throws 类型名过滤;不吞 L1 */
|
|
1090
|
+
ignoreThrows?: string[];
|
|
1091
|
+
/** 宿主已求值的依赖导出表(specifier → AbsModuleExports);
|
|
1092
|
+
* B 与解释路径共用——import/require 按表解析(CLI 经
|
|
1093
|
+
* evalAbsModuleGraph 计算后下传) */
|
|
1094
|
+
modules?: Record<string, AbsModuleExports | Record<string, unknown>>;
|
|
1095
|
+
/**
|
|
1096
|
+
* B run 注入包(modules/mocks/envGlobals/replacements/as)——透传
|
|
1097
|
+
* runTranspiled(generalize / L2 / 记录通道 / drift 同源)。memo 键按
|
|
1098
|
+
* 内容指纹(非对象身份)。
|
|
1099
|
+
*/
|
|
1100
|
+
inject?: RunTranspiledOptions;
|
|
1101
|
+
/**
|
|
1102
|
+
* `@nudo:skip [returnsExpr]`(host 用 parser 解析后下传):函数名 → 声明的
|
|
1103
|
+
* 返回 Abs(null = 未声明)。命中函数不评估 body:签名按声明返回上屏
|
|
1104
|
+
* (无声明 → any,不产生 unknown-inference 噪音);返回契约仍按声明执法;
|
|
1105
|
+
* 入口 may-throw(L2)不评估。调用点参数义务(scan)不受影响。
|
|
1106
|
+
*/
|
|
1107
|
+
skips?: ReadonlyMap<string, Abs | null>;
|
|
1312
1108
|
};
|
|
1313
|
-
/** Every top-level function binding in a declaration node (not just the first). */
|
|
1314
|
-
declare function getFnNameAndBodies(decl: Node): FnDeclInfo[];
|
|
1315
|
-
/** source -> (fnName -> own/deps); LRU */
|
|
1316
|
-
declare function fnFingerprints(source: string, file: File): Map<string, FnFp>;
|
|
1317
|
-
/** L0 source part: per-fn fingerprint when AST available; else full-file hash */
|
|
1318
|
-
declare function generalizeSourceKeyPart(source: string, fnName: string, file?: File): string;
|
|
1319
|
-
/**
|
|
1320
|
-
* 无 refine、无模块语法、无兄弟调用、无任何调用表达式 → scanLiteralCalls 可整段跳过。
|
|
1321
|
-
* 必须保守:`const x = f(-1)` / `if (f(-1))` / `require("x")` 都含 CallExpression,
|
|
1322
|
-
* 只认顶层 ExpressionStatement 会漏报约束违规。
|
|
1323
|
-
*/
|
|
1324
|
-
declare function canSkipLiteralCallScan(source: string, file: File): boolean;
|
|
1325
1109
|
|
|
1326
1110
|
/**
|
|
1327
|
-
* check
|
|
1111
|
+
* 整文件 CheckReport memo(LSP/CI 重复 check → O(1))。
|
|
1328
1112
|
*
|
|
1329
|
-
*
|
|
1330
|
-
* -
|
|
1331
|
-
*
|
|
1113
|
+
* 从 check.ts 拆出的缓存基建:键指纹 / 依赖索引 / 定向逐出 / LRU。
|
|
1114
|
+
* check.ts 通过 re-export 保持 resetCheckSourceMemo /
|
|
1115
|
+
* evictCheckSourceMemoForPaths 对外形状不变。
|
|
1332
1116
|
*/
|
|
1333
1117
|
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
params: string[];
|
|
1338
|
-
/** 符号 Abs 本体 */
|
|
1339
|
-
abs: Abs;
|
|
1340
|
-
/** formatAbs 单行 */
|
|
1341
|
-
display: string;
|
|
1342
|
-
/** formatAbsMultiline */
|
|
1343
|
-
detail: string;
|
|
1344
|
-
conf: Confidence;
|
|
1345
|
-
};
|
|
1346
|
-
type CheckIssue = Diagnostic & {
|
|
1347
|
-
fn?: string;
|
|
1348
|
-
line?: number;
|
|
1349
|
-
column?: number;
|
|
1350
|
-
/** 实参 / 实际值的 Abs 展示 */
|
|
1351
|
-
actual?: string;
|
|
1352
|
-
/** 期望约束(Pred 或 Abs 展示) */
|
|
1353
|
-
expected?: string;
|
|
1354
|
-
};
|
|
1355
|
-
type CheckReport = {
|
|
1356
|
-
file: string;
|
|
1357
|
-
issues: CheckIssue[];
|
|
1358
|
-
/** 有 error 则 CI 应失败 */
|
|
1359
|
-
ok: boolean;
|
|
1360
|
-
/** Abs 优先的签名表(替代 TS 式 display-only) */
|
|
1361
|
-
signatures: NudoSig[];
|
|
1362
|
-
summary: {
|
|
1363
|
-
errors: number;
|
|
1364
|
-
warnings: number;
|
|
1365
|
-
infos: number;
|
|
1366
|
-
functions: number;
|
|
1367
|
-
};
|
|
1368
|
-
};
|
|
1369
|
-
/**
|
|
1370
|
-
* `nudo check --json` 稳定契约(供 CI / Agent)。
|
|
1371
|
-
* 字段只增不改语义;Abs 以 formatAbs 字符串给出,不序列化内部 shape 图。
|
|
1372
|
-
*/
|
|
1373
|
-
type CheckJson = {
|
|
1374
|
-
version: 1;
|
|
1375
|
-
file: string;
|
|
1376
|
-
ok: boolean;
|
|
1377
|
-
summary: CheckReport["summary"];
|
|
1378
|
-
signatures: Array<{
|
|
1379
|
-
name: string;
|
|
1380
|
-
params: string[];
|
|
1381
|
-
display: string;
|
|
1382
|
-
detail: string;
|
|
1383
|
-
conf: string;
|
|
1384
|
-
abs: string;
|
|
1385
|
-
}>;
|
|
1386
|
-
issues: Array<{
|
|
1387
|
-
severity: string;
|
|
1388
|
-
code: string;
|
|
1389
|
-
message: string;
|
|
1390
|
-
fn?: string;
|
|
1391
|
-
line?: number;
|
|
1392
|
-
column?: number;
|
|
1393
|
-
actual?: string;
|
|
1394
|
-
expected?: string;
|
|
1395
|
-
suggestion?: string;
|
|
1396
|
-
}>;
|
|
1397
|
-
};
|
|
1398
|
-
declare function serializeCheckJson(r: CheckReport): CheckJson;
|
|
1399
|
-
/**
|
|
1400
|
-
* Nudo 原生报告:Abs 签名表 + actual ⊭ expected。
|
|
1401
|
-
* 不是 tsc 输出的换皮。
|
|
1402
|
-
*/
|
|
1403
|
-
declare function formatCheckReport(r: CheckReport, opts?: {
|
|
1404
|
-
verbose?: boolean;
|
|
1405
|
-
}): string;
|
|
1118
|
+
declare function resetCheckSourceMemo(): void;
|
|
1119
|
+
/** `*.nudo.js` 变更后定向逐出依赖它的整文件 check 缓存 */
|
|
1120
|
+
declare function evictCheckSourceMemoForPaths(paths: string[]): number;
|
|
1406
1121
|
|
|
1407
1122
|
/**
|
|
1408
1123
|
* nudo check 门禁:对源码跑代数分析,产出 error/warning。
|
|
1409
1124
|
*
|
|
1410
1125
|
* 报告是 **Nudo 原生格式**(Abs 优先),不是 TS 诊断的换皮:
|
|
1411
|
-
* - 签名表给出无损 Abs(shape/term/pred/conf
|
|
1412
|
-
* -
|
|
1413
|
-
* -
|
|
1126
|
+
* - 签名表给出无损 Abs(shape/term/pred/conf)+ throws 域
|
|
1127
|
+
* - L1:显式契约 / 调用点证据违例
|
|
1128
|
+
* - L2:export/default/CJS 入口未消化 may-throw → nudo:entry-may-throw
|
|
1129
|
+
* - 违例写清 actual ⊭ expected;成功也打印 signatures
|
|
1414
1130
|
*/
|
|
1415
1131
|
|
|
1416
|
-
declare function resetCheckSourceMemo(): void;
|
|
1417
|
-
/** `*.nudo.js` 变更后定向逐出依赖它的整文件 check 缓存 */
|
|
1418
|
-
declare function evictCheckSourceMemoForPaths(paths: string[]): number;
|
|
1419
|
-
/**
|
|
1420
|
-
* check 选项:core 不碰 fs;host 用 loadModule 喂 require 目标源码。
|
|
1421
|
-
*/
|
|
1422
|
-
type CheckOptions = {
|
|
1423
|
-
/** 相对/绝对 require 说明符 → 模块源码;undefined = 解析失败 */
|
|
1424
|
-
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
1425
|
-
/** 当前文件路径(供 loadModule 解析相对 spec) */
|
|
1426
|
-
fromFile?: string;
|
|
1427
|
-
/**
|
|
1428
|
-
* 侧车 ambient 绑定开关(host 从 package.json#nudo.interface.autoBind
|
|
1429
|
-
* 解析后下传;默认 true)。false = check/LSP 执法路径不自动加载侧车
|
|
1430
|
-
* (§2.2「整体关闭」承诺覆盖 CI 门禁,不只是打印路径)。
|
|
1431
|
-
*/
|
|
1432
|
-
autoBind?: boolean;
|
|
1433
|
-
};
|
|
1434
1132
|
/**
|
|
1435
1133
|
* 检查一个文件:
|
|
1436
1134
|
* - 每个顶层函数 generalize;无法得到任何签名 → warning
|
|
@@ -1461,63 +1159,6 @@ declare function checkSource(filePath: string, source: string, phi?: Phi, opts?:
|
|
|
1461
1159
|
/** 字面量 lv 是否落在约束 c 表达的域内(保守:判不了 → false)。 */
|
|
1462
1160
|
declare function literalMeetsConstraint(lv: number | string | boolean | null, c: NudoConstraint): boolean;
|
|
1463
1161
|
|
|
1464
|
-
/**
|
|
1465
|
-
* Abs inlay hint:把无损约束内联到源码位置。
|
|
1466
|
-
* 不是 TS 风格 type annotation 复读,而是 term/pred/conf 的计算结果。
|
|
1467
|
-
*
|
|
1468
|
-
* 参数侧只展示显式 `@nudo:refine` 契约(entryReqs)——
|
|
1469
|
-
* 不从函数体 `if` 反推前置条件(那是控制流,不是对外契约)。
|
|
1470
|
-
*/
|
|
1471
|
-
type AbsInlay = {
|
|
1472
|
-
/** 1-based 行号 */
|
|
1473
|
-
line: number;
|
|
1474
|
-
/** 0-based 列(label 插入点) */
|
|
1475
|
-
character: number;
|
|
1476
|
-
label: string;
|
|
1477
|
-
kind: "type" | "parameter";
|
|
1478
|
-
};
|
|
1479
|
-
/**
|
|
1480
|
-
* 收集源码中函数签名的 Abs inlay:
|
|
1481
|
-
* - 参数后:仅 `@nudo:refine` 声明的前置契约
|
|
1482
|
-
* - `{` 前:返回计算形(`x | x * 2`),无 term 时退回 shape
|
|
1483
|
-
*/
|
|
1484
|
-
declare function collectAbsInlays(source: string, refineOpts?: {
|
|
1485
|
-
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
1486
|
-
fromFile?: string;
|
|
1487
|
-
}): AbsInlay[];
|
|
1488
|
-
|
|
1489
|
-
/**
|
|
1490
|
-
* 指称:Abs → 运行时谓词(设计 §2.7)。
|
|
1491
|
-
* - 无 pred:按 shape 检查(typeof / 结构)
|
|
1492
|
-
* - 有 pred:在 `term ↦ v` 下检查可判定的数值比较
|
|
1493
|
-
* - sum:任一成员
|
|
1494
|
-
*/
|
|
1495
|
-
|
|
1496
|
-
/** Abs 上的运行时守卫表达式(JS boolean 布尔串) */
|
|
1497
|
-
declare function denoteGuard(a: Abs, v: string): string;
|
|
1498
|
-
|
|
1499
|
-
/**
|
|
1500
|
-
* Abs ⇄ TypeValue 桥。
|
|
1501
|
-
*
|
|
1502
|
-
* 纪律:
|
|
1503
|
-
* - absToTypeValue 有损:丢 term/pred 时 conf 降为 widened,禁止假装 exact
|
|
1504
|
-
* - typeValueToAbs 尽量恢复 term=lit
|
|
1505
|
-
* - 下游(dts/lsp/service)吃 TypeValue;代数运算吃 Abs
|
|
1506
|
-
*/
|
|
1507
|
-
|
|
1508
|
-
declare function setTvConfidence(tv: TypeValue, conf: Confidence): void;
|
|
1509
|
-
declare function getTvConfidence(tv: TypeValue): Confidence | undefined;
|
|
1510
|
-
/**
|
|
1511
|
-
* Abs → TypeValue(给下游)。
|
|
1512
|
-
* 有损:非 lit term 丢弃;pred 尽量 encode 成 refined,否则丢。
|
|
1513
|
-
*/
|
|
1514
|
-
declare function absToTypeValue(a: Abs): TypeValue;
|
|
1515
|
-
/**
|
|
1516
|
-
* TypeValue → Abs(给代数运算)。
|
|
1517
|
-
* 置信度:优先读 abs→tv 时挂上的 conf 旁路,避免 #widened 回升 #exact。
|
|
1518
|
-
*/
|
|
1519
|
-
declare function typeValueToAbs(tv: TypeValue): Abs;
|
|
1520
|
-
|
|
1521
1162
|
/**
|
|
1522
1163
|
* Abs → NudoConstraint 投影(Phase 1,interface 分层推导的生成侧半边)。
|
|
1523
1164
|
*
|
|
@@ -1539,8 +1180,8 @@ declare function typeValueToAbs(tv: TypeValue): Abs;
|
|
|
1539
1180
|
* 嵌套 or/not)→ undefined。bigint/symbol、tuple、fn、eff、brand、
|
|
1540
1181
|
* any(无 or-pred)、never、unknown → undefined。
|
|
1541
1182
|
*
|
|
1542
|
-
*
|
|
1543
|
-
*
|
|
1183
|
+
* 注意:约束构建器从 "./constraint.ts" 导入(litC/andC 与 term/pred 的
|
|
1184
|
+
* lit/and 已消歧;侧车注入键名仍为 lit/and)。
|
|
1544
1185
|
*/
|
|
1545
1186
|
|
|
1546
1187
|
/** Abs → 契约;不可表达 → undefined */
|
|
@@ -1556,63 +1197,4 @@ declare function absToConstraint(a: Abs): NudoConstraint | undefined;
|
|
|
1556
1197
|
*/
|
|
1557
1198
|
declare function joinThenProject(absList: Abs[]): NudoConstraint | undefined;
|
|
1558
1199
|
|
|
1559
|
-
|
|
1560
|
-
* 源码级调用图侦察:从 check 门禁拆出的 AST 扫描层。
|
|
1561
|
-
*
|
|
1562
|
-
* 职责:不做代数求值结论,只回答「谁在调用谁、实参长什么样」——
|
|
1563
|
-
* - listTopFunctions:顶层函数清单
|
|
1564
|
-
* - collectCallResolvers / resolveCalleeFn / collectForwarders:别名 / 对象属性 /
|
|
1565
|
-
* require / 动态 import / 无条件转发 的调用解析
|
|
1566
|
-
* - scanLiteralCalls:字面量调用点实参 vs 前置约束的违例收集
|
|
1567
|
-
*/
|
|
1568
|
-
|
|
1569
|
-
/**
|
|
1570
|
-
* 注入记录的最小结构面(service CallRecord 的成员子集——core 不反向依赖
|
|
1571
|
-
* service 的 CallRecord 声明,按结构兼容接收)。
|
|
1572
|
-
*/
|
|
1573
|
-
type InjectedDomainRecord = {
|
|
1574
|
-
argTypes: TypeValue[];
|
|
1575
|
-
resultType: TypeValue;
|
|
1576
|
-
throws: TypeValue;
|
|
1577
|
-
};
|
|
1578
|
-
type InjectedDomainEvidenceOpts = {
|
|
1579
|
-
/** 被调函数形参名(位置序);契约按参数名对齐证据位 */
|
|
1580
|
-
paramNames: string[];
|
|
1581
|
-
loadModule?: (spec: string, fromFile: string) => string | undefined;
|
|
1582
|
-
fromFile?: string;
|
|
1583
|
-
/** 侧车 ambient 绑定开关(host 配置下传;默认 true) */
|
|
1584
|
-
autoBind?: boolean;
|
|
1585
|
-
/** 报告定位:被调函数声明处。注入证据的 loc 在使用现场文件,不属于本文件 */
|
|
1586
|
-
loc?: {
|
|
1587
|
-
line: number;
|
|
1588
|
-
column: number;
|
|
1589
|
-
};
|
|
1590
|
-
};
|
|
1591
|
-
/**
|
|
1592
|
-
* 跨文件注入的调用点域证据 vs 手写契约(设计稿 §3.3/§6 对账矩阵第一行)。
|
|
1593
|
-
*
|
|
1594
|
-
* 来源分流铁律:写在被分析文件里的调用点违例(含 scanLiteralCalls 的
|
|
1595
|
-
* checkExternalCall 跨文件被调路径)维持 `nudo:constraint-violated` 原码
|
|
1596
|
-
* 原语义——本函数**只**消费经 externalCallRecords 注入的跨文件记录(analyzer
|
|
1597
|
-
* 消费区已做归属守卫),该路径此前不查契约,是纯增量。
|
|
1598
|
-
*
|
|
1599
|
-
* 证据门槛(§6):
|
|
1600
|
-
* - 只有 plain literal 实参构成证据:union/unknown/primitive/refined 形态
|
|
1601
|
-
* 无法归因到确定值,不参与(widened/partial conf 经 absToTypeValue 投影
|
|
1602
|
-
* 为非 literal 形态,天然被此条排除;getTvConfidence 再兜一道底);
|
|
1603
|
-
* - null 证据预过滤(T4 caveat:lit(null) 编码 prim undefined + eq(self,
|
|
1604
|
-
* null),对任何约束恒不满足,不过滤必 FP);undefined/bigint/symbol
|
|
1605
|
-
* 不在字面量证据域内,一并跳过;
|
|
1606
|
-
* - resultType=never ∧ throws=never 是求值中断泄漏(analyzer 注入消费区
|
|
1607
|
-
* 同款过滤)。CallRecord 上没有截断字段(查证于 evaluator.ts CallRecord
|
|
1608
|
-
* 声明:fnName/argTypes/resultType/throws/callLoc/targetModule/
|
|
1609
|
-
* targetExport/targetAliases/fnModule 十项,无截断标记)——递归截断走
|
|
1610
|
-
* nudo:recursion-truncated 诊断通道且只 widen 结果,不产生新字面量证据;
|
|
1611
|
-
* - fn/shape/array 参数位 Phase 1 不执法(§3.3 HOF 豁免:
|
|
1612
|
-
* literalMeetsConstraint 对这些形态恒 false,直接查必 FP)。
|
|
1613
|
-
*
|
|
1614
|
-
* 每函数每参数位最多一条 issue(多证据并列在 actual 里,去重)。
|
|
1615
|
-
*/
|
|
1616
|
-
declare function checkInjectedDomainEvidence(fnName: string, source: string, records: InjectedDomainRecord[], opts: InjectedDomainEvidenceOpts): CheckIssue[];
|
|
1617
|
-
|
|
1618
|
-
export { Abs, type AbsAssignRecord, type AbsCallRecord, type AbsFnImpl, type AbsInlay, AbsModuleExports, AstEnv, type CheckIssue, type CheckJson, type CheckOptions, type CheckReport, type ClassDef, Confidence, type ConstraintBuilder, type Diagnostic, type EffectiveInterface, type EffectiveInterfaceOpts, type Environment, type EvalOptions, type EvalResult, type FnAbs, type FnFp, type FormatOptions, type FunctionSignature, HofSite, type InjectedDomainRecord, type InterfaceDiag, type InterfaceSource, type LeakBudget, type LeqResult, type LiteralValue, 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, Ops, Phi, type PolyFn, Pred, PrimName, type RangeMeta, type RefineDiag, type RefineEntry, type RefineResolveOpts, type Refinement, RelSource, SELF, Shape, type SigImpl, type Slot, T, type TemplateMeta, type TemplatePartDesc, type TemplatePartView, type TemplatePredicateDecision, Term, type TypeParam, type TypeValue, absFunction, absTemplateViews, absToConstraint, absToTypeValue, add, allFixedTextOfViews, analyzeFn, applyAbsFn, applyBinaryOp, array, attachFnImpl, awaitAbs, boolean, buildArgsFromAssume, callAbsMethod, callFunction, canSkipLiteralCallScan, checkArg, checkCall, checkInjectedDomainEvidence, checkSource, classFromMethods, cmp, coerceAsyncReturn, collapseLiteralUnion, collectAbsInlays, collectAbsNodeTypes, concatString, concatTemplates, constraintToEntryAbs, createEnvironment, createRange, createTemplate, createTemplateAbs, currentPhi, decideEndsWith, decideIncludes, decideStartsWith, deepCloneTypeValue, defaultLeakBudget, defineClass, definitelyNotNullishShape, denoteGuard, describePhi, dispatchBinaryOp, dispatchMethod, dispatchProperty, div, effectiveInterface, emptyEnv, 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, getFnImpl, getFnNameAndBodies, getFnSig, getGeneralizeMemoSize, getParseSourceCacheSize, getPrimitiveTypeOf, getRangeMeta, getRefinedBase, getSlot, getTemplateParts, getTerm, getTvConfidence, hashSource, instanceOf, instantiateClass, instantiateConstraint, interfaceDiagCount, isFnSig, isIntFlag, isNodeModulesPath, isNudoConstraint, isNullishLitAbs, isObj, isRange, isSubtypeOf, isTemplate, isTemplateLike, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, knownPrefixOfViews, knownSuffixOfViews, leakIfNeeded, lenTerm, leqAbs, listFunctionNames, literalMeetsConstraint, loadModuleDepsFingerprint, localNamedExports, lookupMethod, lookupMethodWithOwner, lookupSuperMethod, makeSum, matchRelIdentLit, maybeLeak, mergeAdjacentFixedViews, mergeObjectProperties, mock, mockHelperToTypeValue, mod, mul, narrowType, negAbs, normPath, notAbs, number, objOf, omit, parseSource, partial, pick, popPhi, projectBrand, pushPhi, refineAbsForRelTrue, refineDiagCount, refineToIndexedFull, relationFingerprint, relationFn, resetAbsCallBudget, resetCheckSourceMemo, resetFnFpCache, resetGeneralizeMemo, resetHashSourceCache, resetLeakCounter, resetNudoModuleExecCache, resetParseSourceCache, resetPhi, resolveDepPath, serializeCheckJson, setAbsAssignCollector, setAbsCallCollector, setAbsNodeCollector, setAbsTruncationCollector, setInterfaceDiagCollector, setRefineDiagCollector, setTvConfidence, shape, shapeOnlyFn, sidecarClosureFingerprint, sidecarPathOf, sidecarSpecsOf, simplifyUnion, spread, spy, stableAnalyzeKeySource, strictEqAbs, string, stripTypes, stub, sub, subtractType, superNameOf, takeInterfaceDiags, takeInterfaceDiagsSince, takeRefineDiags, takeRefineDiagsSince, templateMatchesValue, templatePartsOf, termDepth, termNodes, trueConstraint, typeValueEquals, typeValueToAbs, typeValueToString, typeofAbs, union, viewTemplateParts, widenLiteral, withPhiConstraint, withVar, wrapPromise };
|
|
1200
|
+
export { Abs, type AbsAssignRecord, type AbsCallRecord, type AbsFnImpl, AbsModuleExports, type AbsSigImpl, AstEnv, type CheckOptions, CheckReport, Confidence, EffectiveInterfaceOpts, type Environment, type ExtState, type FnAbs, type FormalParam, type FormatOptions, HofCollectCtx, HofSite, type LeqResult, type MockHelper, NudoConstraint, OBJECT_PROTO_METHOD_NAMES, type ObjShape, Phi, type PolyFn, Pred, type PropFlags, RelSource, RunTranspiledOptions, Shape, type Slot, Term, type TypeParam, absFunction, absShapeKey, absToConstraint, add, alphaOf, applyCallbackAbs, applyCallbackValue, asAbs, assignSourceSlots, attachFnImpl, beginCollectionFork, betaOf, bitandAbs, bitnotAbs, bitorAbs, bitxorAbs, buildArgsFromAssume, builtinCtorAbs, builtinCtorNameOf, callAbsMethod, canonicalArrayIndex, checkSource, clearCollectionTables, cmp, collectAbsFreeVars, collectionElementJoin, collectionExactLen, contractParamNameSet, createEnvironment, createHofCollectCtx, ctorArgDefinitelyInvalid, ctorNameOfRecv, currentPhi, definitelyNotNullishShape, describePhi, div, drainPromiseMicros, emptyEnv, endCollectionFork, enterPromiseExecutorScope, errorBrandAbs, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalNamespaceCall, evalNumberStatic, evalObjectMethod, evalObjectProtoMethod, evalPromiseCtor, evalPromiseMethod, evalPromiseStatic, evalRegExpCtor, evalRegExpMethod, evalStringStatic, evalSymbolCtor, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, extStateOf, extractFn, falseConstraint, fnOf, formalParamDisplayNames, formalParamsFromNodes, formatAbs, formatAbsMultiline, formatShape, formatShapeSlot, generalizeAll, generalizeFromAst, getAbsProperty, getFnImpl, getGeneralizeMemoSize, getPropFlags, getSlot, hostBuiltinCtorName, instantiateReturn, isErrorCtorName, isMapAbs, isNullProtoObj, isNullishLitAbs, isObj, isObjectProtoBrand, isRelFn, isSetAbs, isSymbolAbs, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, leavePromiseExecutorScope, leqAbs, listFunctionNames, literalMeetsConstraint, locateContractParam, looseEqAbs, makeArrayCtorAbs, makeMapAbs, makeSetAbs, makeSum, makeSymbolAbs, mapClearEntries, mapDeleteEntry, mapElementFallback, mapEntriesAbs, mapGetEntry, mapHasEntry, mapSetEntry, mapSizeAbs, mapValuesAbs, markExtState, markNullProtoObj, markPureFn, matchRelIdentLit, mergeCollectionArms, migrateInvariants, migrateNullProto, mock, mod, mul, negAbs, notAbs, noteCollectionWrite, notePromiseExecutorFork, objOf, objectProtoBrand, objectProtoMethodAbs, parseSource, popCollectionArm, popPhi, powAbs, projectFlatMapResult, promoteParamShape, protoBrandAbs, protoOfRecv, pureFnNameOf, pushCollectionArm, pushPhi, queuePromiseMicro, refineAbsForRelTrue, regexBrandAbsFrom, relationFingerprint, relationFn, requiredFnArity, resetCheckSourceMemo, resetGeneralizeMemo, resetPhi, setAddEntry, setApplyCallbackHost, setClearEntries, setDeleteEntry, setElementsAbs, setHasEntry, setPropFlags, setSizeAbs, shapeOnlyFn, shlAbs, shrAbs, snapshotAbs, spread, spy, strictEqAbs, stringOfSymbol, stripTypes, stub, sub, substAbs, substPredAbs, symbolDescriptionAbs, symbolIdOf, toNumberAbs, trueConstraint, tryMakeRegexAbs, tryPromoteDirectCall, tryPromoteForOfIteratee, tryPromoteHofCallback, tryPromoteReceiverAsArr, typeofAbs, undefAbs, ushrAbs, withPhiConstraint, withVar };
|