@nudojs/core 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{check-report-BWmfy810.d.ts → check-report-Ci1dDysO.d.ts} +52 -27
- package/dist/{chunk-CKH6GQAI.js → chunk-W2MP6REI.js} +2351 -1896
- package/dist/{chunk-5YNR4Q7E.js → chunk-YO4GKCNE.js} +817 -169
- package/dist/exec.d.ts +8 -16
- package/dist/exec.js +9 -1
- package/dist/index.d.ts +125 -110
- package/dist/index.js +174 -94
- package/dist/internal.d.ts +4 -4
- package/dist/internal.js +39 -27
- package/dist/{run-Dk08Q5zl.d.ts → run-WJfj477N.d.ts} +186 -3
- package/package.json +1 -1
package/dist/exec.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as Abs, M as MayThrowEffect, b as Phi } from './run-
|
|
2
|
-
export {
|
|
1
|
+
import { A as Abs, M as MayThrowEffect, b as Phi } from './run-WJfj477N.js';
|
|
2
|
+
export { O as $assignRecord, Q as $call, U as $callNamed, V as $recordBinding, a1 as EvalAbsAssignRecord, a2 as EvalCallRecord, a3 as EvalFallback, f as EvalFallbackStats, a6 as MAX_EVAL_CALL_DEPTH, a7 as MAX_EVAL_TOTAL_CALLS, a8 as RUNTIME_IMPORT_RE, N as RunTranspiledOptions, aa as TranspiledCallResult, ao as bindingsOf, ar as callTranspiledExport, as as callTranspiledExportApply, at as callTranspiledExportFull, g as clearPureCallMemo, h as clearPureMemo, i as enterEvalCallBudgetSession, ay as evalExprAbs, k as exitEvalCallBudgetSession, q as getEvalCallBudgetState, aB as getEvalCallCollector, r as getEvalFallbackStats, aZ as noteEvalCallRecord, a_ as noteEvalFallback, bf as resetEvalCallBudget, z as resetEvalFallbackStats, bz as routeApplyThrows, bg as runTranspiled, bh as runTranspiledOptionsMemoKey, bi as setEvalAssignCollector, bj as setEvalBindingSink, bk as setEvalCallCollector, bl as setEvalFallbackCollector, bw as tryRunTranspiled, H as withEvalBudgetOverride } from './run-WJfj477N.js';
|
|
3
3
|
import { Node, Expression, File } from '@babel/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -37,6 +37,11 @@ declare function asAbsVal(v: unknown): Abs;
|
|
|
37
37
|
/**
|
|
38
38
|
* 函数调用边界:callee 的 loop/early-return 不得冒泡成 caller 结果。
|
|
39
39
|
* 每个 求值引擎调用帧独立 ALS;NudoReturn 收成该调用的返回值。
|
|
40
|
+
*
|
|
41
|
+
* throws 面(H1):嵌套帧的 may-throw(pushThrowExit)必须上浮到调用方帧,
|
|
42
|
+
* 不得在边界丢弃——否则跨 callAtFunctionBoundary 的 apply 桥 may-throw
|
|
43
|
+
* 静默消失(与 BUG-006 同类丢失,但发生在帧边界而非桥内)。
|
|
44
|
+
* always-throw 走 NudoThrow 异常原样 rethrow(不经此转发)。
|
|
40
45
|
*/
|
|
41
46
|
declare function callAtFunctionBoundary<T>(body: () => T): T;
|
|
42
47
|
/** 函数表达式 → 一等 fn Abs(transpile 侧带真实参数名;异步 body 包 $async)
|
|
@@ -490,19 +495,6 @@ declare function transpileFile(file: File, opts?: TranspileOptions): string;
|
|
|
490
495
|
/** 解析 + transpile */
|
|
491
496
|
declare function transpile(source: string, opts?: TranspileOptions): string;
|
|
492
497
|
|
|
493
|
-
/**
|
|
494
|
-
* 调用 Abs 一等函数(absFunction impl)或 mock apply。
|
|
495
|
-
* 供 求值引擎 import 绑定包装:`(...args) => $call(absFn, args)`。
|
|
496
|
-
*
|
|
497
|
-
* 统一顺序:apply → body → relation → isRelFn(委托 applyAbsFn)。
|
|
498
|
-
* 行为对齐说明(与旧 $call 的差异,均属刻意):
|
|
499
|
-
* 1. 带 body 的函数也进 call-budget(递归会 truncated 而非爆栈)
|
|
500
|
-
* 2. body 抛错与 apply 同径 rethrow(不吞成 never 返回,调用边界决定吸收)
|
|
501
|
-
* 3. 无 impl 时 isRelFn 可走 E 路径(旧版恒 unknown)
|
|
502
|
-
*/
|
|
503
|
-
|
|
504
|
-
declare function $call(fn: Abs, args: Abs[], thisVal?: Abs): Abs;
|
|
505
|
-
|
|
506
498
|
/**
|
|
507
499
|
* B class 规格表(无 call 依赖,避免循环)。
|
|
508
500
|
* Abs-eval registerClassDecl 与 transpile $class 共用。
|
|
@@ -595,4 +587,4 @@ declare class NudoUnsupportedError extends Error {
|
|
|
595
587
|
});
|
|
596
588
|
}
|
|
597
589
|
|
|
598
|
-
export { $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $asyncReturn, $await, $bitand, $bitnot, $bitor, $bitxor, $
|
|
590
|
+
export { $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $asyncReturn, $await, $bitand, $bitnot, $bitor, $bitxor, $catchVal, $class, $classExpr, $collectionForEach, $concat, $copy, $del, $delRes, $div, $dynamicImport, $elems, $eq, $eqLoose, $fnVal, $for, $forInKeys, $forIter, $forOf, $fork, $ge, $gen, $get, $gt, $idx, $idxSet, $importMeta, $in, $instanceof, $instanceofNonIdent, $invoke, $invokeSuper, $isBreakTo, $isForkExit, $join, $le, $len, $lit, $loopBreak, $loopContinue, $loopReturn, $lt, $mod, $mul, $ne, $neLoose, $neg, $new, $not, $nullishTest, $obj, $objAccessor, $objRest, $optionalGet, $optionalInvoke, $orDefault, $pow, $pushLoopExit, $rawThis, $reStateCall, $regex, $rethrowIfNudoReturn, $set, $setKey, $setProto, $shl, $shr, $spread, $staticInvoke, $sub, $super, $switch, $thisGet, $thisSet, $throw, $toNumber, $toNumeric, $tryCurrentMark, $tryDetachSoftCatch, $tryDigestSoftCatch, $tryDiscardSoft, $tryMark, $tryOrphanSoft, $tryPopMark, $tryReleaseSoftCatch, $tryReleaseSoftOut, $tryTakeSince, $typeof, $unknown, $updateAdd, $updateSub, $ushr, $while, $whileSeq, $yield, DEFAULT_MAX_LOOP_ITERS, type EvalClassSpec, NudoLoopSignal, NudoReturn, NudoThrow, NudoUnsupportedError, type TranspileOptions, asAbsVal, callAtFunctionBoundary, clearBClasses, clearStaleTermPred, currentExecPhi, fillTuple, foldRequireSpecArg, foldStaticStringExpr, getEvalClass, isArrMutator, isDefinitelyFalse, isDefinitelyTrue, isNudoBreak, isNudoContinue, isNudoReturn, isNudoThrow, litTruth, lookupObjAccessor, namespaceNameOf, pushLoopExit, pushThrowExit, registerEvalClass, runWithLoopExits, runtimeImportOf, takeLoopExits, takeThrowExits, transpile, transpileBodyNode, transpileExpression, transpileFile, transpileSource, withExecPhi };
|
package/dist/exec.js
CHANGED
|
@@ -123,8 +123,11 @@ import {
|
|
|
123
123
|
bindingsOf,
|
|
124
124
|
callAtFunctionBoundary,
|
|
125
125
|
callTranspiledExport,
|
|
126
|
+
callTranspiledExportApply,
|
|
126
127
|
callTranspiledExportFull,
|
|
127
128
|
clearBClasses,
|
|
129
|
+
clearPureCallMemo,
|
|
130
|
+
clearPureMemo,
|
|
128
131
|
clearStaleTermPred,
|
|
129
132
|
currentExecPhi,
|
|
130
133
|
enterEvalCallBudgetSession,
|
|
@@ -154,6 +157,7 @@ import {
|
|
|
154
157
|
registerEvalClass,
|
|
155
158
|
resetEvalCallBudget,
|
|
156
159
|
resetEvalFallbackStats,
|
|
160
|
+
routeApplyThrows,
|
|
157
161
|
runTranspiled,
|
|
158
162
|
runTranspiledOptionsMemoKey,
|
|
159
163
|
runWithLoopExits,
|
|
@@ -172,7 +176,7 @@ import {
|
|
|
172
176
|
tryRunTranspiled,
|
|
173
177
|
withEvalBudgetOverride,
|
|
174
178
|
withExecPhi
|
|
175
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-W2MP6REI.js";
|
|
176
180
|
export {
|
|
177
181
|
$add,
|
|
178
182
|
$arguments,
|
|
@@ -297,8 +301,11 @@ export {
|
|
|
297
301
|
bindingsOf,
|
|
298
302
|
callAtFunctionBoundary,
|
|
299
303
|
callTranspiledExport,
|
|
304
|
+
callTranspiledExportApply,
|
|
300
305
|
callTranspiledExportFull,
|
|
301
306
|
clearBClasses,
|
|
307
|
+
clearPureCallMemo,
|
|
308
|
+
clearPureMemo,
|
|
302
309
|
clearStaleTermPred,
|
|
303
310
|
currentExecPhi,
|
|
304
311
|
enterEvalCallBudgetSession,
|
|
@@ -328,6 +335,7 @@ export {
|
|
|
328
335
|
registerEvalClass,
|
|
329
336
|
resetEvalCallBudget,
|
|
330
337
|
resetEvalFallbackStats,
|
|
338
|
+
routeApplyThrows,
|
|
331
339
|
runTranspiled,
|
|
332
340
|
runTranspiledOptionsMemoKey,
|
|
333
341
|
runWithLoopExits,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as AstEnv, A as Abs, b as Phi,
|
|
2
|
-
export {
|
|
3
|
-
import { Node } from '@babel/types';
|
|
4
|
-
import { p as parseSource, L as LeakBudget, E as EffectiveInterfaceOpts, b as LoadDepsFingerprint,
|
|
5
|
-
export {
|
|
6
|
-
export { $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $asyncReturn, $await, $bitand, $bitnot, $bitor, $bitxor, $
|
|
1
|
+
import { c as AstEnv, A as Abs, b as Phi, T as Term, I as HofCollectCtx, C as Confidence, S as Shape, a as Pred, R as RelSource, J as HofSite, K as AbsModuleExports, N as RunTranspiledOptions } from './run-WJfj477N.js';
|
|
2
|
+
export { O as $assignRecord, Q as $call, U as $callNamed, V as $recordBinding, W as AbsApplyNoThrow, X as AbsApplyNoThrowFn, Y as AbsApplyResult, Z as AbsApplyReturn, _ as AbsFnImpl, a0 as AbsSigImpl, a1 as EvalAbsAssignRecord, a2 as EvalCallRecord, a3 as EvalFallback, a4 as ImplicationOracle, a5 as LitValueResult, L as LiteralValue, a6 as MAX_EVAL_CALL_DEPTH, a7 as MAX_EVAL_TOTAL_CALLS, P as PrimName, a8 as RUNTIME_IMPORT_RE, a9 as TYPEOF_NAMES, aa as TranspiledCallResult, ab as TypeofName, ac as abs, ad as absFunction, ae as absOnly, af as absToString, ag as and, ah as anyAbs, ai as anyVar, aj as app, ak as assumeFinite, al as attachFnImpl, am as bigintLit, an as bindImports, ao as bindingsOf, ap as bool, aq as boolLit, ar as callTranspiledExport, as as callTranspiledExportApply, at as callTranspiledExportFull, au as collectAbsExports, av as confJoin, aw as emptyPhi, ax as eq, ay as evalExprAbs, az as ge, aA as geNum, aB as getEvalCallCollector, aC as getFnImpl, aD as getImplicationOracle, aE as gt, aF as gtNum, aG as implies, aH as isAbsApplyResult, aI as isBigPrim, aJ as isExactLit, aK as isNumPrim, aL as isStrPrim, aM as le, aN as leNum, aO as lit, aP as litValue, aQ as lt, aR as ltNum, aS as makeAbsApplyResult, aT as markPureFn, aU as namespaceAbsOf, aV as ne, aW as negatePred, aX as never, aY as not, aZ as noteEvalCallRecord, a_ as noteEvalFallback, a$ as num, b0 as numLit, b1 as numVar, b2 as obj, b3 as or, b4 as pFalse, b5 as pTrue, b6 as phiAnd, b7 as predEquals, b8 as predToString, b9 as predVars, ba as primToTypeof, bb as ptypeof, bc as pureFnNameOf, bd as relationFingerprint, be as relationFn, bf as resetEvalCallBudget, bg as runTranspiled, bh as runTranspiledOptionsMemoKey, bi as setEvalAssignCollector, bj as setEvalBindingSink, bk as setEvalCallCollector, bl as setEvalFallbackCollector, bm as setImplicationOracle, bn as shapeOfTerm, bo as shapeOnlyFn, bp as shapeToString, bq as simplifyTerm, br as str, bs as strLit, bt as substPred, bu as termEquals, bv as termToString, bw as tryRunTranspiled, bx as unknown, by as v } from './run-WJfj477N.js';
|
|
3
|
+
import { Node, File } from '@babel/types';
|
|
4
|
+
import { p as parseSource, L as LeakBudget, E as EffectiveInterfaceOpts, b as LoadDepsFingerprint, o as CheckReport, N as NudoConstraint } from './check-report-Ci1dDysO.js';
|
|
5
|
+
export { q as CONSTRAINT_BUILDERS, u as CONSTRAINT_BUILDER_NAMES, v as CONSTRAINT_EXPR_RE, w as CheckAction, C as CheckIssue, x as CheckJson, y as CheckJsonMulti, z as ConstraintBuilder, D as Diagnostic, A as EffectiveInterface, G as GitlabCodeQualityIssue, B as InterfaceDiag, I as InterfaceSource, F as InterfaceTierInfo, a as InterfaceTierOpts, H as NamedImport, J as NudoField, K as NudoFnConstraint, O as NudoSidecarError, P as NudoSig, R as RefineDiag, Q as RefineEntry, S as RefineResolveOpts, T as SELF, U as actionsForIssue, V as andC, W as any, X as array, Y as boolean, Z as checkArg, _ as checkCall, $ as constraintAdmitsNullish, a0 as constraintToEntryAbs, a1 as drainPromiseMicros, a2 as effectiveInterface, a3 as enterPromiseExecutorScope, a4 as evalPromiseCtor, a5 as evalPromiseMethod, a6 as evalPromiseStatic, a7 as execNudoModule, a8 as extractDeclaredThrows, a9 as extractFnBudget, aa as extractNudoImports, ab as extractRefineReturnFromSource, ac as extractRefinesFromSource, ad as fn, ae as fnConstraintToEntryReqs, af as formatCheckReport, ag as formatConstraint, ah as formatDiagnostics, ai as formatEffectiveInterfaceDisplay, aj as formatGithubAnnotations, ak as formatGitlabCodeQuality, al as formatInterfaceTierLine, am as generatedExportNames, an as getParseSourceCacheSize, ao as getTerm, ap as instantiateConstraint, aq as interfaceDiagCount, ar as interfaceSourceOf, as as interfaceTierOf, at as isIntFlag, au as isNodeModulesPath, av as isNudoConstraint, aw as leavePromiseExecutorScope, ax as lenTerm, ay as litC, az as localNamedExports, aA as notePromiseExecutorFork, aB as nullable, aC as number, aD as omit, aE as partial, aF as pick, aG as queuePromiseMicro, aH as refineDiagCount, aI as refineToIndexedFull, aJ as resetNudoModuleExecCache, aK as resetParseSourceCache, aL as resetSidecarLoadFailureCache, aM as serializeCheckJson, aN as serializeCheckJsonMulti, aO as setInterfaceDiagCollector, aP as setRefineDiagCollector, aQ as shape, aR as sidecarClosureFingerprint, aS as sidecarPathOf, aT as string, aU as takeInterfaceDiags, aV as takeInterfaceDiagsSince, aW as takeRefineDiags, aX as takeRefineDiagsSince, aY as throwConstraintToKinds, aZ as union } from './check-report-Ci1dDysO.js';
|
|
6
|
+
export { $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $asyncReturn, $await, $bitand, $bitnot, $bitor, $bitxor, $catchVal, $class, $classExpr, $collectionForEach, $concat, $copy, $del, $delRes, $div, $dynamicImport, $elems, $eq, $eqLoose, $fnVal, $for, $forInKeys, $forIter, $forOf, $fork, $ge, $gen, $get, $gt, $idx, $idxSet, $importMeta, $in, $instanceof, $instanceofNonIdent, $invoke, $invokeSuper, $isBreakTo, $isForkExit, $join, $le, $len, $lit, $loopBreak, $loopContinue, $loopReturn, $lt, $mod, $mul, $ne, $neLoose, $neg, $new, $not, $nullishTest, $obj, $objAccessor, $objRest, $optionalGet, $optionalInvoke, $orDefault, $pow, $pushLoopExit, $rawThis, $reStateCall, $regex, $rethrowIfNudoReturn, $set, $setKey, $shl, $shr, $spread, $staticInvoke, $sub, $super, $switch, $thisGet, $thisSet, $throw, $toNumber, $toNumeric, $tryCurrentMark, $tryDetachSoftCatch, $tryDigestSoftCatch, $tryDiscardSoft, $tryMark, $tryOrphanSoft, $tryPopMark, $tryReleaseSoftCatch, $tryReleaseSoftOut, $tryTakeSince, $typeof, $unknown, $updateAdd, $updateSub, $ushr, $while, $whileSeq, $yield, DEFAULT_MAX_LOOP_ITERS, EvalClassSpec, NudoLoopSignal, NudoReturn, NudoThrow, NudoUnsupportedError, TranspileOptions, asAbsVal, callAtFunctionBoundary, clearBClasses, clearStaleTermPred, currentExecPhi, fillTuple, foldRequireSpecArg, foldStaticStringExpr, getEvalClass, isArrMutator, isDefinitelyFalse, isDefinitelyTrue, isNudoBreak, isNudoContinue, isNudoReturn, isNudoThrow, litTruth, lookupObjAccessor, namespaceNameOf, pushLoopExit, pushThrowExit, registerEvalClass, runWithLoopExits, runtimeImportOf, takeLoopExits, takeThrowExits, transpile, transpileBodyNode, transpileExpression, transpileFile, transpileSource, withExecPhi } from './exec.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* AstEnv:抽象求值环境类型面(ast-eval 删除后保留)。
|
|
@@ -107,104 +107,6 @@ declare function resetPhi(): void;
|
|
|
107
107
|
declare function withPhiConstraint(extra: Phi, body: () => void): void;
|
|
108
108
|
declare function describePhi(): string;
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* Abs 上的一等函数:shape 是 fn,实现在旁路(不污染 Shape)。
|
|
112
|
-
* 与 term-registry 同一纪律:不给共享单例挂 impl。
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/** Abs 原生 env/builtin 实现(evaluator 优先) */
|
|
116
|
-
type AbsSigImpl = (args: Abs[], thisVal?: Abs) => Abs | undefined;
|
|
117
|
-
type AbsFnImpl = {
|
|
118
|
-
params: string[];
|
|
119
|
-
/** 可选:无 body 时走 relation(纯关系 fn) */
|
|
120
|
-
body?: Node;
|
|
121
|
-
async?: boolean;
|
|
122
|
-
/** 声明时捕获的环境(闭包) */
|
|
123
|
-
env?: AstEnv;
|
|
124
|
-
kind?: string;
|
|
125
|
-
/** 调用时直接派发(mock withArgs 等),优先于 body */
|
|
126
|
-
apply?: (args: Abs[], thisVal?: Abs) => Abs;
|
|
127
|
-
/**
|
|
128
|
-
* 对象方法(ObjectMethod / 方法型 FunctionExpression):$invoke 时把
|
|
129
|
-
* receiver 作为 apply 的**首参**注入。shape.params 仍是用户可见形参
|
|
130
|
-
* (不含 receiver),自由调用不注入 → this 为 unbound(JS 语义)。
|
|
131
|
-
*/
|
|
132
|
-
bindThis?: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Optional content key for cache fingerprints. formatAbs cannot see
|
|
135
|
-
* WeakMap-side mock semantics (returns/withArgs/callsFake), so hosts that
|
|
136
|
-
* build mocks should stamp a stable fingerprint here.
|
|
137
|
-
* relation-only 必填(未传时 relationFn 自动生成)。
|
|
138
|
-
*/
|
|
139
|
-
fingerprint?: string;
|
|
140
|
-
/** 无 body 时,按 paramTypes 做 α 替换得到返回 */
|
|
141
|
-
relation?: {
|
|
142
|
-
paramTypes: Abs[];
|
|
143
|
-
returnType: Abs;
|
|
144
|
-
/**
|
|
145
|
-
* 条件类型 infer:绑定 fromVar 后从 via 投出 inferVar
|
|
146
|
-
* (`T extends (infer E)[]` → via: "arr";`T extends Promise<infer U>` → "promise")。
|
|
147
|
-
*/
|
|
148
|
-
inferFrom?: {
|
|
149
|
-
fromVar: string;
|
|
150
|
-
via: "arr" | "promise";
|
|
151
|
-
inferVar: string;
|
|
152
|
-
};
|
|
153
|
-
/** extends 不成立时的假分支(如 never) */
|
|
154
|
-
condFallback?: Abs;
|
|
155
|
-
};
|
|
156
|
-
/** `@nudo:pure`:调用结果按实参记忆化(无副作用契约) */
|
|
157
|
-
pureName?: string;
|
|
158
|
-
};
|
|
159
|
-
declare function attachFnImpl(a: Abs, impl: AbsFnImpl): void;
|
|
160
|
-
declare function getFnImpl(a: Abs): AbsFnImpl | undefined;
|
|
161
|
-
/** 标记纯函数(@nudo:pure):调用结果可按实参记忆化 */
|
|
162
|
-
declare function markPureFn(target: object, name: string): void;
|
|
163
|
-
/** 读纯函数标记(Abs impl 或对象属性 `_memoize`) */
|
|
164
|
-
declare function pureFnNameOf(fn: unknown): string | undefined;
|
|
165
|
-
/** 造一个带实现的 Abs 函数值 */
|
|
166
|
-
declare function absFunction(params: string[], impl: Omit<AbsFnImpl, "params">, opts?: {
|
|
167
|
-
name?: string;
|
|
168
|
-
paramTypes?: Abs[];
|
|
169
|
-
returnType?: Abs;
|
|
170
|
-
slots?: Record<string, {
|
|
171
|
-
value: Abs;
|
|
172
|
-
optional?: boolean;
|
|
173
|
-
readonly?: boolean;
|
|
174
|
-
}>;
|
|
175
|
-
conf?: Confidence;
|
|
176
|
-
}): Abs;
|
|
177
|
-
/** relationFn 稳定 fingerprint(同签名共享,见 §3.3 已知限制) */
|
|
178
|
-
declare function relationFingerprint(paramTypes: Abs[], returnType: Abs): string;
|
|
179
|
-
/**
|
|
180
|
-
* 无 body、纯关系的 fn Abs。params 仅记 arity。
|
|
181
|
-
*
|
|
182
|
-
* **双写纪律:** 同一份关系数据必须同时写到——
|
|
183
|
-
* 1. `shape.paramTypes` / `shape.returnType` —— format / leq / 展示读这里
|
|
184
|
-
* 2. `impl.relation` —— D 路径应用读这里
|
|
185
|
-
* 两槽共享同一数组/对象引用(防内容分叉);构造后请勿原地 mutate。
|
|
186
|
-
*
|
|
187
|
-
* 默认 conf="path"(与提升产物一致)。禁止静默对齐 absFunction 的 "exact"。
|
|
188
|
-
* fingerprint 必填(call-budget);未传时由 paramTypes+returnType 稳定序列化生成。
|
|
189
|
-
* 同签名 relationFn 共享 fingerprint → 共享 budget 键(见 design §3.3 已知限制)。
|
|
190
|
-
*/
|
|
191
|
-
declare function relationFn(paramTypes: Abs[], returnType: Abs, opts?: {
|
|
192
|
-
params?: string[];
|
|
193
|
-
conf?: Confidence;
|
|
194
|
-
fingerprint?: string;
|
|
195
|
-
inferFrom?: {
|
|
196
|
-
fromVar: string;
|
|
197
|
-
via: "arr" | "promise";
|
|
198
|
-
inferVar: string;
|
|
199
|
-
};
|
|
200
|
-
condFallback?: Abs;
|
|
201
|
-
}): Abs;
|
|
202
|
-
/** 仅写 shape 槽(E 路径 / §5.2 提升产物);禁止 attachFnImpl */
|
|
203
|
-
declare function shapeOnlyFn(paramTypes: Abs[], returnType: Abs, opts?: {
|
|
204
|
-
params?: string[];
|
|
205
|
-
conf?: Confidence;
|
|
206
|
-
}): Abs;
|
|
207
|
-
|
|
208
110
|
/**
|
|
209
111
|
* HOF 关系 Abs:无 body 的外延关系(paramTypes → returnType)的判定、
|
|
210
112
|
* α 替换与应用。类型变量仍是 term var;关系仍是 fn 形状上的外延槽。
|
|
@@ -463,7 +365,12 @@ declare function setPropFlags(o: Abs, key: string, f: PropFlags): void;
|
|
|
463
365
|
declare function migrateInvariants(from: Abs, to: Abs): void;
|
|
464
366
|
|
|
465
367
|
/**
|
|
466
|
-
* Math.* — 字面量实参走 ToNumber/ToInt32
|
|
368
|
+
* Math.* — 字面量实参走 ToNumber/ToInt32 后调用原生折叠;非字面量对
|
|
369
|
+
* min/max/round/floor/ceil/trunc 透传数值区间(#68)。
|
|
370
|
+
*
|
|
371
|
+
* NaN 策略(DEC:显式 NaN 臂):操作数可能为 NaN 时结果为
|
|
372
|
+
* `NaN | number@bounds`。契约 `ge(0).le(100)` 对 NaN 臂诚实报违例;
|
|
373
|
+
* `if (Number.isNaN(n)) return …` 假臂的 `ne(n, NaN)` 事实可排除 NaN 臂。
|
|
467
374
|
*/
|
|
468
375
|
|
|
469
376
|
declare function evalMathMethod(name: string, args: Abs[]): Abs | undefined;
|
|
@@ -979,7 +886,7 @@ declare function resetGeneralizeMemo(): void;
|
|
|
979
886
|
declare function getGeneralizeMemoSize(): number;
|
|
980
887
|
/**
|
|
981
888
|
* LSP/宿主:`*.nudo.js` 变更后按路径定向逐出依赖它的 L0 条目。
|
|
982
|
-
*
|
|
889
|
+
* 返回删除的条目数。查找与索引同走 stablePathKey——跨 Windows 盘符形态命中。
|
|
983
890
|
*/
|
|
984
891
|
declare function evictGeneralizeMemoForPaths(paths: string[]): number;
|
|
985
892
|
|
|
@@ -1119,7 +1026,7 @@ type CheckOptions = {
|
|
|
1119
1026
|
*/
|
|
1120
1027
|
|
|
1121
1028
|
declare function resetCheckSourceMemo(): void;
|
|
1122
|
-
/** `*.nudo.js` 变更后定向逐出依赖它的整文件 check
|
|
1029
|
+
/** `*.nudo.js` 变更后定向逐出依赖它的整文件 check 缓存。查找与索引同走 stablePathKey */
|
|
1123
1030
|
declare function evictCheckSourceMemoForPaths(paths: string[]): number;
|
|
1124
1031
|
|
|
1125
1032
|
/**
|
|
@@ -1142,6 +1049,114 @@ declare function evictCheckSourceMemoForPaths(paths: string[]): number;
|
|
|
1142
1049
|
*/
|
|
1143
1050
|
declare function checkSource(filePath: string, source: string, phi?: Phi, opts?: CheckOptions): CheckReport;
|
|
1144
1051
|
|
|
1052
|
+
/**
|
|
1053
|
+
* 单源 `@nudo:` 指令文法 + G2 作用域绑定(D5=F1, D6=G2)。
|
|
1054
|
+
*
|
|
1055
|
+
* 作用域契约(G2):函数级指令绑定 **AST 最近 Function** —— FunctionDeclaration /
|
|
1056
|
+
* VariableDeclarator 函数初始化 / FunctionExpression / ArrowFunctionExpression /
|
|
1057
|
+
* ClassMethod / ObjectMethod,含 nested function 与 class method。
|
|
1058
|
+
* 同一函数的 `@nudo:case` 与 `@nudo:contract` 必须同时可见(共用本模块的 scope 绑定)。
|
|
1059
|
+
*
|
|
1060
|
+
* 文法契约(前缀):`//` 与 `///` 等价;只认行注释与 JSDoc 块注释;
|
|
1061
|
+
* 字符串/模板/块注释正文里的同形文本不是指令。文件级(env / mock-module / import)
|
|
1062
|
+
* 不绑函数;其余标签绑最近 Function。
|
|
1063
|
+
*
|
|
1064
|
+
* 抽取单源:实现住在 core(parser 依赖 core,反向会成包环);`@nudojs/parser`
|
|
1065
|
+
* re-export 本模块的文本级 API 作为产品面。core refine / load-deps / check-case-scan
|
|
1066
|
+
* 与 nudojs CLI 只消费,不得再自带正则文法。
|
|
1067
|
+
*/
|
|
1068
|
+
|
|
1069
|
+
type FnDirectiveScope = {
|
|
1070
|
+
/** 绑定名:`f` / `C.m` / `default` / `<anonymous>` */
|
|
1071
|
+
name: string;
|
|
1072
|
+
node: Node;
|
|
1073
|
+
/** 该函数的前导注释块(comment.value 原文,文档序) */
|
|
1074
|
+
commentTexts: string[];
|
|
1075
|
+
/** commentTexts 清洗后的行 */
|
|
1076
|
+
commentLines: string[];
|
|
1077
|
+
/** 与 commentTexts 对齐的注释起始行号 */
|
|
1078
|
+
commentStartLines: number[];
|
|
1079
|
+
startLine: number;
|
|
1080
|
+
};
|
|
1081
|
+
/**
|
|
1082
|
+
* 全量 Function 站点:nested function、class method、object method 均可见。
|
|
1083
|
+
* 函数级指令绑「其前导注释块」;注释若带在非函数语句上则不绑(不留孤儿指令)。
|
|
1084
|
+
*/
|
|
1085
|
+
declare function listFnDirectiveScopes(file: File): FnDirectiveScope[];
|
|
1086
|
+
/** 按绑定名找函数 scope(文档序第一个命中) */
|
|
1087
|
+
declare function findFnDirectiveScope(file: File, fnName: string): FnDirectiveScope | undefined;
|
|
1088
|
+
/**
|
|
1089
|
+
* 源文本级函数前导指令行(refine / throws / budget 的消费口)。
|
|
1090
|
+
* 与 case 扫描共用同一 scope 绑定,保证 case+contract 同时可见。
|
|
1091
|
+
*/
|
|
1092
|
+
declare function fnDirectiveCommentLines(source: string, fnName: string): string[];
|
|
1093
|
+
/**
|
|
1094
|
+
* `@nudo:env` 载荷 → 命名 env token。只收 `\w+` 或 path-like
|
|
1095
|
+
* (拒绝 `node";` 这类截断捕获)。
|
|
1096
|
+
*/
|
|
1097
|
+
declare function parseEnvPayload(payload: string): string[];
|
|
1098
|
+
type MockModuleRecord = {
|
|
1099
|
+
source: string;
|
|
1100
|
+
names?: string[];
|
|
1101
|
+
fromPath: string;
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* `@nudo:mock-module "src" [ { a, b } ] from "path"` 载荷解析。
|
|
1105
|
+
* 名表 `{ … }` 可选;单源文法(parser / load-deps 共用)。
|
|
1106
|
+
*/
|
|
1107
|
+
declare function parseMockModulePayload(payload: string): MockModuleRecord | undefined;
|
|
1108
|
+
type NudoImportRecord = {
|
|
1109
|
+
names: string[];
|
|
1110
|
+
spec: string;
|
|
1111
|
+
};
|
|
1112
|
+
/**
|
|
1113
|
+
* `@nudo:import` 载荷:named `{ a, b as c }` / namespace `* as ns`。
|
|
1114
|
+
* default 等未识别形态返回 `malformed`(由消费方发诊断)。
|
|
1115
|
+
*/
|
|
1116
|
+
declare function parseNudoImportPayload(payload: string): NudoImportRecord | "malformed-default" | "malformed" | undefined;
|
|
1117
|
+
declare function extractFileEnvNames(source: string): string[];
|
|
1118
|
+
declare function extractMockModuleRecords(source: string): MockModuleRecord[];
|
|
1119
|
+
/** `@nudo:import` 命名/namespace 记录(refine 与 load-deps 共用单源) */
|
|
1120
|
+
declare function extractNudoImportRecords(source: string): NudoImportRecord[];
|
|
1121
|
+
/**
|
|
1122
|
+
* 平衡括号摘取(字符串感知;`\` 不是转义——与 case 实参原样 slice 一致)。
|
|
1123
|
+
* 返回括号内文本;无平衡括号 → null。
|
|
1124
|
+
*/
|
|
1125
|
+
declare function extractBalancedParens(text: string, startIdx: number): string | null;
|
|
1126
|
+
type CaseTag = {
|
|
1127
|
+
name: string;
|
|
1128
|
+
/** 括号内实参原文(未清洗续行 `*`) */
|
|
1129
|
+
argsText: string;
|
|
1130
|
+
/** `=> expected` 表达式原文(同行/续行 `=>`) */
|
|
1131
|
+
expectedText?: string;
|
|
1132
|
+
/** 标签在 comment.value 中的下标 */
|
|
1133
|
+
tagOffset: number;
|
|
1134
|
+
};
|
|
1135
|
+
/**
|
|
1136
|
+
* `@nudo:case` 标签扫描(单源):多行实参、实参区间遮罩、`=> expected`。
|
|
1137
|
+
* 供 parser(Abs 解释)与 check-case-scan(见证检查)共用。
|
|
1138
|
+
* 非法名形态由消费方用 `scanMalformedCaseTagRests` 诊断。
|
|
1139
|
+
*/
|
|
1140
|
+
declare function scanCaseTags(text: string): CaseTag[];
|
|
1141
|
+
/** case 实参区间(供其它标签做遮罩) */
|
|
1142
|
+
declare function scanCaseArgSpans(text: string): [number, number][];
|
|
1143
|
+
/**
|
|
1144
|
+
* `@nudo:contract <param> <name>` / `@nudo:contract return <name>` 行。
|
|
1145
|
+
* 支持 `&&` / 逗号连接的多段;返回原始段文本。
|
|
1146
|
+
*/
|
|
1147
|
+
declare function scanContractSegments(lines: string[]): string[];
|
|
1148
|
+
/**
|
|
1149
|
+
* `@nudo:throws …` / case 行 `!! throws …`。
|
|
1150
|
+
* 返回 `*` = 申报任意;字符串 = 逗号/空白分隔的 kind 列表;undefined = 无申报。
|
|
1151
|
+
*/
|
|
1152
|
+
declare function scanThrowsDecl(lines: string[]): string | undefined;
|
|
1153
|
+
/** `@nudo:budget forks=… calls=… depth=…` → 声明的维度 */
|
|
1154
|
+
declare function scanBudgetDecl(lines: string[]): {
|
|
1155
|
+
forks?: number;
|
|
1156
|
+
calls?: number;
|
|
1157
|
+
depth?: number;
|
|
1158
|
+
} | undefined;
|
|
1159
|
+
|
|
1145
1160
|
/**
|
|
1146
1161
|
* 字面量域隶属判定(Phase 1)。
|
|
1147
1162
|
*
|
|
@@ -1149,7 +1164,7 @@ declare function checkSource(filePath: string, source: string, phi?: Phi, opts?:
|
|
|
1149
1164
|
* NudoConstraint 表达的域内。只覆盖可判定的标量子集:
|
|
1150
1165
|
*
|
|
1151
1166
|
* - prim 门(prim 缺失或不匹配字面量类型 → false)
|
|
1152
|
-
* - eq(self, lit v) 字面量等值(
|
|
1167
|
+
* - eq(self, lit v) 字面量等值(SameValue:含 undefined/NaN;与 leq 同口径)
|
|
1153
1168
|
* - gt/ge/lt/le 数值常数界(self op n)
|
|
1154
1169
|
* - 字符串长度界(length(self) op n,即 min/max/length 链)
|
|
1155
1170
|
* - int(整数性)
|
|
@@ -1160,7 +1175,7 @@ declare function checkSource(filePath: string, source: string, phi?: Phi, opts?:
|
|
|
1160
1175
|
*/
|
|
1161
1176
|
|
|
1162
1177
|
/** 字面量 lv 是否落在约束 c 表达的域内(保守:判不了 → false)。 */
|
|
1163
|
-
declare function literalMeetsConstraint(lv: number | string | boolean | null, c: NudoConstraint): boolean;
|
|
1178
|
+
declare function literalMeetsConstraint(lv: number | string | boolean | null | undefined, c: NudoConstraint): boolean;
|
|
1164
1179
|
|
|
1165
1180
|
/**
|
|
1166
1181
|
* Abs → NudoConstraint 投影(Phase 1,interface 分层推导的生成侧半边)。
|
|
@@ -1200,4 +1215,4 @@ declare function absToConstraint(a: Abs): NudoConstraint | undefined;
|
|
|
1200
1215
|
*/
|
|
1201
1216
|
declare function joinThenProject(absList: Abs[]): NudoConstraint | undefined;
|
|
1202
1217
|
|
|
1203
|
-
export { Abs, type AbsAssignRecord, type AbsCallRecord,
|
|
1218
|
+
export { Abs, type AbsAssignRecord, type AbsCallRecord, AbsModuleExports, AstEnv, type CaseTag, type CheckOptions, CheckReport, Confidence, EffectiveInterfaceOpts, type Environment, type ExtState, type FnAbs, type FnDirectiveScope, type FormalParam, type FormatOptions, HofCollectCtx, HofSite, type LeqResult, type MockHelper, type MockModuleRecord, NudoConstraint, type NudoImportRecord, OBJECT_PROTO_METHOD_NAMES, type ObjShape, Phi, type PolyFn, Pred, type PropFlags, RelSource, RunTranspiledOptions, Shape, type Slot, Term, type TypeParam, absShapeKey, absToConstraint, add, alphaOf, applyCallbackAbs, applyCallbackValue, asAbs, assignSourceSlots, 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, emptyEnv, endCollectionFork, errorBrandAbs, evalArrayStatic, evalBuiltinInstanceMethod, evalBuiltinNew, evalDateCtor, evalDateMethod, evalDateStatic, evalGlobalFn, evalJsonMethod, evalMathMethod, evalNamespaceCall, evalNumberStatic, evalObjectMethod, evalObjectProtoMethod, evalRegExpCtor, evalRegExpMethod, evalStringStatic, evalSymbolCtor, evictCheckSourceMemoForPaths, evictGeneralizeMemoForPaths, extStateOf, extractBalancedParens, extractFileEnvNames, extractFn, extractMockModuleRecords, extractNudoImportRecords, falseConstraint, findFnDirectiveScope, fnDirectiveCommentLines, fnOf, formalParamDisplayNames, formalParamSignatureNames, formalParamsFromNodes, formatAbs, formatAbsMultiline, formatShape, formatShapeSlot, generalizeAll, generalizeFromAst, getAbsProperty, getGeneralizeMemoSize, getPropFlags, getSlot, hostBuiltinCtorName, instantiateReturn, isErrorCtorName, isMapAbs, isNullProtoObj, isNullishLitAbs, isObj, isObjectProtoBrand, isRelFn, isSetAbs, isSymbolAbs, joinAbs, joinFunctions, joinObjects, joinThenProject, joinValues, leqAbs, listFnDirectiveScopes, listFunctionNames, literalMeetsConstraint, locateContractParam, looseEqAbs, makeArrayCtorAbs, makeMapAbs, makeSetAbs, makeSum, makeSymbolAbs, mapClearEntries, mapDeleteEntry, mapElementFallback, mapEntriesAbs, mapGetEntry, mapHasEntry, mapSetEntry, mapSizeAbs, mapValuesAbs, markExtState, markNullProtoObj, matchRelIdentLit, mergeCollectionArms, migrateInvariants, migrateNullProto, mock, mod, mul, negAbs, notAbs, noteCollectionWrite, objOf, objectProtoBrand, objectProtoMethodAbs, parseEnvPayload, parseMockModulePayload, parseNudoImportPayload, parseSource, popCollectionArm, popPhi, powAbs, projectFlatMapResult, promoteParamShape, propertyKeyOf, protoBrandAbs, protoOfRecv, pushCollectionArm, pushPhi, refineAbsForRelTrue, regexBrandAbsFrom, requiredFnArity, resetCheckSourceMemo, resetGeneralizeMemo, resetPhi, scanBudgetDecl, scanCaseArgSpans, scanCaseTags, scanContractSegments, scanThrowsDecl, setAddEntry, setApplyCallbackHost, setClearEntries, setDeleteEntry, setElementsAbs, setHasEntry, setPropFlags, setSizeAbs, 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 };
|