@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
|
@@ -0,0 +1,726 @@
|
|
|
1
|
+
import { A as Abs, M as MayThrowEffect, b as Phi, c as AstEnv } from './hof-types-tAeoYvzY.js';
|
|
2
|
+
import * as _babel_types from '@babel/types';
|
|
3
|
+
import { Node, Expression, File, ImportDeclaration } from '@babel/types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* B 路径 throw 载荷(独立叶子模块):
|
|
7
|
+
* builtins.ts(evalJsonMethod 等 Abs builtin)需要硬抛 TypeError/SyntaxError,
|
|
8
|
+
* 而 exec/runtime.ts 又 import builtins.ts(evalNamespaceCall 等)——
|
|
9
|
+
* 直接互引成环。NudoThrow 无依赖(仅 Abs 类型 + Error),抽成叶子,
|
|
10
|
+
* runtime.ts re-export 保持既有 import 面不变。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** B 路径 throw 载荷:携带 Abs 抛出值 */
|
|
14
|
+
declare class NudoThrow extends Error {
|
|
15
|
+
readonly absValue: Abs;
|
|
16
|
+
constructor(absValue: Abs);
|
|
17
|
+
}
|
|
18
|
+
declare function isNudoThrow(e: unknown): e is NudoThrow;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* B 路径运行时共享状态:phi、就地写、字面量 Abs、真值、循环信号。
|
|
22
|
+
* 叶子模块——不依赖 runtime 其它文件(tuple/obj 字面量就地构造,避免 state↔containers 环)。
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** 调用方已直接改 shape 时的 term/pred 清理 */
|
|
26
|
+
declare function clearStaleTermPred(v: Abs): void;
|
|
27
|
+
declare function currentExecPhi(): Phi;
|
|
28
|
+
declare function withExecPhi<T>(p: Phi, body: () => T): T;
|
|
29
|
+
/**
|
|
30
|
+
* transpile 泄漏的 JS 函数值 → 一等 fn Abs。
|
|
31
|
+
* B 路径把函数声明/表达式编译成真实 JS 函数;它们流进对象槽、
|
|
32
|
+
* 元组、join 等 Abs 结构时不能裸存——下游(bridge/leq/join)读 `.shape`。
|
|
33
|
+
* 参数名无法从运行时函数恢复(用 fn.length → argN,与 analyzer 的
|
|
34
|
+
* extractParamNames 回退口径一致);带真实参数名走 $fnVal(transpile 侧)。
|
|
35
|
+
*/
|
|
36
|
+
declare function asAbsVal(v: unknown): Abs;
|
|
37
|
+
/**
|
|
38
|
+
* 函数调用边界:callee 的 loop/early-return 不得冒泡成 caller 结果。
|
|
39
|
+
* 每个 B 路径调用帧独立 ALS;NudoReturn 收成该调用的返回值。
|
|
40
|
+
*/
|
|
41
|
+
declare function callAtFunctionBoundary<T>(body: () => T): T;
|
|
42
|
+
/** 函数表达式 → 一等 fn Abs(transpile 侧带真实参数名;异步 body 包 $async)
|
|
43
|
+
* opts.bindThis:对象方法——$invoke 会把 receiver 作为 impl 首参注入。 */
|
|
44
|
+
declare function $fnVal(params: string[], impl: (...args: Abs[]) => Abs, opts?: {
|
|
45
|
+
bindThis?: boolean;
|
|
46
|
+
}): Abs;
|
|
47
|
+
/**
|
|
48
|
+
* 宿主 this → Abs:函数体 prologue 用它承接 call/apply/bind 传入的 thisArg。
|
|
49
|
+
* Abs 原样返回;宿主 undefined(普通调用/call 缺 thisArg)→ $lit(undefined)。
|
|
50
|
+
* B 路径产物是 new Function 拼接(sloppy),裸调用的宿主 this 泄漏为
|
|
51
|
+
* globalThis——归一到 $lit(undefined)(strict 模块语义下的 this)。
|
|
52
|
+
*/
|
|
53
|
+
declare function $rawThis(v: unknown): Abs;
|
|
54
|
+
/** 字面量 → Abs(transpile 侧数字/字符串/布尔/null/undefined) */
|
|
55
|
+
declare function $lit(v: unknown): Abs;
|
|
56
|
+
/** JS 真值:字面量按 Boolean(v);对象形恒真;不可判 → undefined */
|
|
57
|
+
declare function litTruth(a: Abs): boolean | undefined;
|
|
58
|
+
declare function isDefinitelyTrue(a: Abs): boolean;
|
|
59
|
+
declare function isDefinitelyFalse(a: Abs): boolean;
|
|
60
|
+
/** 函数求值作用域:收集抽象分支上的 early-return / throw 值;try 标记栈同边界 */
|
|
61
|
+
declare function runWithLoopExits<T>(body: () => T): T;
|
|
62
|
+
declare function takeLoopExits(): Abs[];
|
|
63
|
+
declare function takeThrowExits(): Abs[];
|
|
64
|
+
declare function pushLoopExit(v: Abs): void;
|
|
65
|
+
declare function pushThrowExit(v: Abs): void;
|
|
66
|
+
/** transpile 生成代码用:`$pushLoopExit` */
|
|
67
|
+
declare function $pushLoopExit(v: Abs): void;
|
|
68
|
+
/** try 块开始:压栈 hard/soft 标记 */
|
|
69
|
+
declare function $tryMark(): number;
|
|
70
|
+
/** 当前最内层 try 的 mark(return 时 drain 用;嵌套调用不串栈) */
|
|
71
|
+
declare function $tryCurrentMark(): number;
|
|
72
|
+
declare function $tryPopMark(): void;
|
|
73
|
+
/** 取出 mark 之后新记录的 throw(try 吸收 / catch 合并) */
|
|
74
|
+
declare function $tryTakeSince(mark: number): Abs[];
|
|
75
|
+
/** catch 入口消化 try 内 soft may-throw(幂等;design §3.3) */
|
|
76
|
+
declare function $tryDigestSoftCatch(): void;
|
|
77
|
+
/**
|
|
78
|
+
* 正常完成路径 + catch 可能 rethrow:soft 效果不得消化——假想 soft throw
|
|
79
|
+
* 经 catch rethrow 逃逸(try { u.name } catch (e) { throw e; } 的 L2)。
|
|
80
|
+
* 摘帧上浮(collector / 外层 try 帧可再消化),并清 soft 标记防二次释放。
|
|
81
|
+
*/
|
|
82
|
+
declare function $tryReleaseSoftCatch(): void;
|
|
83
|
+
/**
|
|
84
|
+
* catch 入口摘下 soft 效果(不消化)。catch 正常落出口再 discard;
|
|
85
|
+
* catch rethrow 时 orphan 上浮(外层 try 可再消化)。
|
|
86
|
+
*/
|
|
87
|
+
declare function $tryDetachSoftCatch(): MayThrowEffect[];
|
|
88
|
+
/** catch 无 rethrow 落出口:丢弃已摘下的 soft(design:catch 消化) */
|
|
89
|
+
declare function $tryDiscardSoft(_effects: MayThrowEffect[]): void;
|
|
90
|
+
/** catch rethrow:摘下的 soft 上浮(嵌套 try 归外层帧) */
|
|
91
|
+
declare function $tryOrphanSoft(effects: MayThrowEffect[]): void;
|
|
92
|
+
/** 无 handler / 出口:上浮未消化 soft may-throw(幂等) */
|
|
93
|
+
declare function $tryReleaseSoftOut(): void;
|
|
94
|
+
/** B 路径「函数提前 return」信号(区别于 throw) */
|
|
95
|
+
declare class NudoReturn extends Error {
|
|
96
|
+
readonly absValue: Abs;
|
|
97
|
+
constructor(absValue: Abs);
|
|
98
|
+
}
|
|
99
|
+
declare function isNudoReturn(e: unknown): e is NudoReturn;
|
|
100
|
+
/** transpile `return x` inside for/while → `$loopReturn(x)` */
|
|
101
|
+
declare function $loopReturn(v: Abs): never;
|
|
102
|
+
/**
|
|
103
|
+
* break/continue 信号:transpile 在循环体内生成 $loopBreak/$loopContinue,
|
|
104
|
+
* $for/$whileSeq/$forOf 在 body 调用点捕获。带标签信号只被同标签循环吸收,
|
|
105
|
+
* 不匹配继续冒泡到外层循环(`break outer` / `continue outer` 语义)。
|
|
106
|
+
*/
|
|
107
|
+
declare class NudoLoopSignal extends Error {
|
|
108
|
+
readonly kind: "break" | "continue";
|
|
109
|
+
readonly label: string | undefined;
|
|
110
|
+
constructor(kind: "break" | "continue", label?: string);
|
|
111
|
+
}
|
|
112
|
+
declare function $loopBreak(label?: string): never;
|
|
113
|
+
declare function $loopContinue(label?: string): never;
|
|
114
|
+
declare function isNudoBreak(e: unknown, label?: string): boolean;
|
|
115
|
+
declare function isNudoContinue(e: unknown, label?: string): boolean;
|
|
116
|
+
/** 非循环 labeled block:判断 break 信号是否指向本标签(transpile 生成代码用) */
|
|
117
|
+
declare function $isBreakTo(e: unknown, label: string): boolean;
|
|
118
|
+
/** catch 转译辅助:控制流信号透传(生成代码只注入 `$` 前缀符号) */
|
|
119
|
+
declare function $rethrowIfNudoReturn(e: unknown): void;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* 运算符重载面(transpile 目标):$add/$sub/…、比较/位运算。
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
declare function $unknown(): Abs;
|
|
126
|
+
/** `import.meta` → `{ url: string }`(宿主 URL 非字面量,不假精确) */
|
|
127
|
+
declare function $importMeta(): Abs;
|
|
128
|
+
/** `import(spec)` → Promise<开放模块命名空间>(动态模块图不静态解析) */
|
|
129
|
+
declare function $dynamicImport(_spec: Abs): Abs;
|
|
130
|
+
declare function $add(a: Abs, b: Abs): Abs;
|
|
131
|
+
declare function $sub(a: Abs, b: Abs): Abs;
|
|
132
|
+
declare function $mul(a: Abs, b: Abs): Abs;
|
|
133
|
+
declare function $div(a: Abs, b: Abs): Abs;
|
|
134
|
+
declare function $mod(a: Abs, b: Abs): Abs;
|
|
135
|
+
declare function $bitand(a: Abs, b: Abs): Abs;
|
|
136
|
+
declare function $bitor(a: Abs, b: Abs): Abs;
|
|
137
|
+
declare function $bitxor(a: Abs, b: Abs): Abs;
|
|
138
|
+
declare function $bitnot(a: Abs): Abs;
|
|
139
|
+
declare function $shl(a: Abs, b: Abs): Abs;
|
|
140
|
+
declare function $shr(a: Abs, b: Abs): Abs;
|
|
141
|
+
declare function $ushr(a: Abs, b: Abs): Abs;
|
|
142
|
+
declare function $pow(a: Abs, b: Abs): Abs;
|
|
143
|
+
declare function $toNumber(a: Abs): Abs;
|
|
144
|
+
declare function $neg(a: Abs): Abs;
|
|
145
|
+
declare function $typeof(a: Abs): Abs;
|
|
146
|
+
declare function $not(a: Abs): Abs;
|
|
147
|
+
declare function $eq(a: Abs, b: Abs): Abs;
|
|
148
|
+
declare function $ne(a: Abs, b: Abs): Abs;
|
|
149
|
+
/** `==` / `!=`(C2.3):双字面量 Abstract Equality,否则回落严格判定 */
|
|
150
|
+
declare function $eqLoose(a: Abs, b: Abs): Abs;
|
|
151
|
+
declare function $neLoose(a: Abs, b: Abs): Abs;
|
|
152
|
+
declare function $lt(a: Abs, b: Abs): Abs;
|
|
153
|
+
declare function $le(a: Abs, b: Abs): Abs;
|
|
154
|
+
declare function $gt(a: Abs, b: Abs): Abs;
|
|
155
|
+
declare function $ge(a: Abs, b: Abs): Abs;
|
|
156
|
+
declare function $join(a: Abs, b: Abs): Abs;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 访问器(get/set)侧表、in / instanceof / delete 路由。
|
|
160
|
+
*/
|
|
161
|
+
|
|
162
|
+
/** 注册对象字面量访问器(transpile 调用;返回原 obj 以便链式包裹) */
|
|
163
|
+
declare function $objAccessor(o: Abs, key: string, get: ((t: Abs) => Abs) | null, set: ((t: Abs, v: Abs) => Abs) | null): Abs;
|
|
164
|
+
/** 对象字面量访问器查询(供 $get/$set/$spread/Object.assign 共用) */
|
|
165
|
+
declare function lookupObjAccessor(o: Abs, key: string): {
|
|
166
|
+
get?: (t: Abs) => Abs;
|
|
167
|
+
set?: (t: Abs, v: Abs) => Abs;
|
|
168
|
+
} | undefined;
|
|
169
|
+
/**
|
|
170
|
+
* `key in obj`:闭形状精确判定(含 Object.prototype 名、数组下标/length、
|
|
171
|
+
* class 方法/访问器与内建 brand 方法);prim/nullish 接收者原生抛 TypeError →
|
|
172
|
+
* unknown;抽象键/开形状 → boolean。
|
|
173
|
+
*/
|
|
174
|
+
declare function $in(key: Abs, o: Abs): Abs;
|
|
175
|
+
/**
|
|
176
|
+
* `x instanceof Right`(Right 为标识符名):按左值形状精确判定。
|
|
177
|
+
* nullish 左侧原生抛 TypeError → unknown;未知用户构造器名 → boolean(不得 exact false)。
|
|
178
|
+
*/
|
|
179
|
+
declare function $instanceof(left: Abs, rightName: string, rightVal?: Abs): Abs;
|
|
180
|
+
/** instanceof 右操作数非标识符(表达式/成员路径):构造器值未知 → 抽象 boolean */
|
|
181
|
+
declare function $instanceofNonIdent(_left: Abs): Abs;
|
|
182
|
+
/** ClassExpression 值:构造器函数形状,不得折成精确 undefined */
|
|
183
|
+
declare function $classExpr(): Abs;
|
|
184
|
+
/**
|
|
185
|
+
* `delete obj[key]` 的结果判定(只读,不写回)。
|
|
186
|
+
* frozen/sealed 或 configurable:false 键 → false;preventExtensions 可删;
|
|
187
|
+
* closed 目标恒 true(其余 non-configurable 形态不建模);
|
|
188
|
+
* prim/nullish 接收者原生抛 TypeError → unknown。
|
|
189
|
+
*/
|
|
190
|
+
declare function $delRes(o: Abs, _key: Abs): Abs;
|
|
191
|
+
/**
|
|
192
|
+
* `delete obj[key]` 的写入(不可变更新):返回删键后的新容器。
|
|
193
|
+
* 闭对象删自有槽;tuple 规范下标置 undefined(对齐原生空洞读值);
|
|
194
|
+
* 抽象 arr 元素并入 undefined;无法表达的形态原样返回。
|
|
195
|
+
*/
|
|
196
|
+
declare function $del(o: Abs, key: Abs): Abs;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 循环展开上限(leaf)—— 从 control.ts 拆出,打断 control ↔ containers 环。
|
|
200
|
+
*/
|
|
201
|
+
declare const DEFAULT_MAX_LOOP_ITERS = 8;
|
|
202
|
+
|
|
203
|
+
declare function $fork(test: Abs, consequent: () => Abs, alternate?: () => Abs): Abs;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* for 的惰性展开:生成器只负责「按上限吐状态」。
|
|
207
|
+
* 抽象条件无法诚实终止——消费者必须自带 maxIters。
|
|
208
|
+
*/
|
|
209
|
+
declare function $forIter(init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, body: (s: Abs) => Abs, maxIters?: number): Generator<{
|
|
210
|
+
state: Abs;
|
|
211
|
+
test: Abs;
|
|
212
|
+
afterBody: Abs;
|
|
213
|
+
}, void, void>;
|
|
214
|
+
/**
|
|
215
|
+
* 有界 for:unroll ≤ maxIters,每步「可能退出」的态 join;
|
|
216
|
+
* 相邻态 leq 视为不动点提前停。
|
|
217
|
+
*/
|
|
218
|
+
declare function $for(init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, body: (s: Abs) => Abs, maxIters?: number, opts?: {
|
|
219
|
+
pack?: () => Abs;
|
|
220
|
+
unpack?: (s: Abs) => void;
|
|
221
|
+
/** 标签循环(`outer: for …`):仅吸收同标签 break/continue 信号 */
|
|
222
|
+
label?: string;
|
|
223
|
+
}): Abs;
|
|
224
|
+
/**
|
|
225
|
+
* 有界 while:state 线程穿 test/step(与 $for 同折叠语义)。
|
|
226
|
+
* 抽象条件无法诚实终止——必须 maxIters。
|
|
227
|
+
*/
|
|
228
|
+
declare function $while(init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, maxIters?: number): Abs;
|
|
229
|
+
/**
|
|
230
|
+
* 顺序 while(具体/可变闭包):body 内对 JS 变量赋值。
|
|
231
|
+
* 提供 pack/unpack 时,抽象条件的可能出口会 join 回绑定(P0 健全);
|
|
232
|
+
* 未 instrument 的调用保持旧语义(预算截断,文档已声明)。
|
|
233
|
+
*/
|
|
234
|
+
declare function $whileSeq(test: () => Abs, body: () => void, maxIters?: number, opts?: {
|
|
235
|
+
/** 把当前绑定收成 Abs 状态(transpile 注入) */
|
|
236
|
+
pack?: () => Abs;
|
|
237
|
+
/** 把 join 后的状态写回绑定 */
|
|
238
|
+
unpack?: (s: Abs) => void;
|
|
239
|
+
/** 标签循环:仅吸收同标签 break/continue 信号 */
|
|
240
|
+
label?: string;
|
|
241
|
+
}): void;
|
|
242
|
+
declare function $switch(disc: Abs, cases: Array<{
|
|
243
|
+
test: Abs;
|
|
244
|
+
run: () => Abs;
|
|
245
|
+
}>, dflt?: () => Abs): Abs;
|
|
246
|
+
/** transpile `throw x` → `$throw(x)` */
|
|
247
|
+
declare function $throw(v: Abs): never;
|
|
248
|
+
/**
|
|
249
|
+
* fork 臂是否以控制流退出(return / throw)。
|
|
250
|
+
* 生成代码用此决定 continue-path free-write 标志:退出臂的写
|
|
251
|
+
* 不得污染 join 后的 continue 绑定。
|
|
252
|
+
*/
|
|
253
|
+
declare function $isForkExit(e: unknown): boolean;
|
|
254
|
+
/** catch 参数:从 NudoThrow 取出 Abs;宿主 Error 补 name/message;否则 unknown */
|
|
255
|
+
declare function $catchVal(e: unknown): Abs;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 数组 / 对象运行时:$arr/$idx/$len/$arrMutContainer 与 $obj/$get/$set/$spread。
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
/** 数组字面量 → ≤cap tuple(逐元素精确)/ >cap arr;策略与 containers.ts 同源 */
|
|
262
|
+
declare function $arr(items: Abs[]): Abs;
|
|
263
|
+
/**
|
|
264
|
+
* `arguments` 对象 → 类数组 tuple($len/$idx 投影 length/下标;typeof 为 "object")。
|
|
265
|
+
* strict/ESM 与形参**独立映射**:写 `arguments[i]` 不改形参,写形参不改 `arguments`。
|
|
266
|
+
* (sloppy 非严格是 mapped arguments object,二者互相写回——Nudo 分析按 ESM/strict。)
|
|
267
|
+
* 与 rest 绑定解耦:rest 仍从真实 `arguments`/rest 形参收集,本对象只服务用户写的 `arguments`。
|
|
268
|
+
*/
|
|
269
|
+
declare function $arguments(items: ArrayLike<unknown>): Abs;
|
|
270
|
+
/**
|
|
271
|
+
* 带空洞的数组字面量([1,,3]):hole 槽位置为 undefined 值但 `in` 判定 false。
|
|
272
|
+
* 超 cap 退化 arr 时丢弃 hole 精度(元素 join,长度语义已由 arr 承接)。
|
|
273
|
+
*/
|
|
274
|
+
declare function $arrWithHoles(items: Abs[], holes: number[]): Abs;
|
|
275
|
+
declare function isArrMutator(name: string): boolean;
|
|
276
|
+
declare function fillTuple(shape: {
|
|
277
|
+
k: "tuple";
|
|
278
|
+
elements: Abs[];
|
|
279
|
+
holes?: number[];
|
|
280
|
+
} | {
|
|
281
|
+
k: "arr";
|
|
282
|
+
element: Abs;
|
|
283
|
+
}, vals: Abs[], arr: Abs): Abs;
|
|
284
|
+
/**
|
|
285
|
+
* 深拷贝可变容器(fork/switch 快照与循环 pack 用)。
|
|
286
|
+
* 容器写就地进行后(引用语义),分析分支/迭代的状态分离必须靠拷贝——
|
|
287
|
+
* 浅引用快照会让臂间/迭代间互相污染。
|
|
288
|
+
*/
|
|
289
|
+
declare function $copy(a: Abs): Abs;
|
|
290
|
+
/** 数组/元组方法(push/pop/shift/unshift/splice/reverse/sort/copyWithin/fill)
|
|
291
|
+
* 的就地 mutator:Abs 身份不变(JS 引用语义——`const b = a; b.push(4)` 对 a
|
|
292
|
+
* 可见);transpile 重绑 `a = $arrMutContainer(a, …)` 仍写回同一对象。 */
|
|
293
|
+
declare function $arrMutContainer(arr: Abs, method: string, args: Abs[]): Abs;
|
|
294
|
+
/** 下标读 a[i];字面量 i 走 tuple 精确投影,否则并所有元素;string[i] → 单字符 */
|
|
295
|
+
declare function $idx(a: Abs, i: Abs): Abs;
|
|
296
|
+
/** 下标写 a[i]=v → 新 tuple(越界写按 JS 语义增长,空洞为 undefined) */
|
|
297
|
+
declare function $idxSet(a: Abs, i: Abs, value: Abs): Abs;
|
|
298
|
+
/** 数组/字符串长度 */
|
|
299
|
+
declare function $len(a: Abs): Abs;
|
|
300
|
+
/** 对象字面量 → Abs obj */
|
|
301
|
+
declare function $obj(slots: Record<string, Abs>): Abs;
|
|
302
|
+
/** 对象展开 { ...a, b } */
|
|
303
|
+
declare function $spread(a: Abs, b: Abs): Abs;
|
|
304
|
+
/**
|
|
305
|
+
* 解构 rest:`const { a, ...rest } = o` → rest = o 去掉 named keys。
|
|
306
|
+
* closed obj:剩余槽 closed;open / optional 键:rest 仍 open(可能有未知键)。
|
|
307
|
+
*/
|
|
308
|
+
declare function $objRest(o: Abs, keys: string[]): Abs;
|
|
309
|
+
/** 数组 rest:`const [a, ...rest] = arr` → rest = 从 start 起的尾段 */
|
|
310
|
+
declare function $arrRest(a: Abs, start: number): Abs;
|
|
311
|
+
/** 数组连接 [...a, ...b] / [...a, x];结果超 cap 时与字面量同策略降 arr */
|
|
312
|
+
declare function $concat(a: Abs, b: Abs): Abs;
|
|
313
|
+
/** 元素列表(tuple 展开;arr 抽象;C1 Set/Map 逐条目;matchAll 迭代器逐匹配项;
|
|
314
|
+
* 字符串按 code points)。Map 迭代语义是 entry `[key, value]` 元组,不是裸 value。 */
|
|
315
|
+
declare function $elems(a: Abs): Abs[];
|
|
316
|
+
/**
|
|
317
|
+
* for-of:对 iterable 每个元素跑 body;有界展开。
|
|
318
|
+
* body(item, i) 可返回 void;状态由外部 JS 变量承接。
|
|
319
|
+
* - 具体空 tuple:体 0 次(不得用 `length || maxIters` 展开成 maxIters)
|
|
320
|
+
* - 抽象 arr / 未知长度:0..maxIters 出口与 pack 状态 join
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* for-in 键序列:原生顺序为整数键升序 → 其余键按插入序;
|
|
324
|
+
* 数组 hole 槽不出键(读值为 undefined 但不可枚举)。仅自有可枚举键。
|
|
325
|
+
*/
|
|
326
|
+
declare function $forInKeys(o: Abs): Abs;
|
|
327
|
+
declare function $forOf(iterable: Abs, body: (item: Abs, index: Abs) => void, maxIters?: number, opts?: {
|
|
328
|
+
pack?: () => Abs;
|
|
329
|
+
unpack?: (s: Abs) => void;
|
|
330
|
+
/** 标签循环:仅吸收同标签 break/continue 信号 */
|
|
331
|
+
label?: string;
|
|
332
|
+
}): void;
|
|
333
|
+
/**
|
|
334
|
+
* 命名空间身份表:transpile 后 `Math.max(0, x)` 的接收者是宿主 JS 全局对象
|
|
335
|
+
* (非 Abs)。按对象身份识别命名空间,路由到 Abs builtin 表。
|
|
336
|
+
*/
|
|
337
|
+
declare function namespaceNameOf(v: unknown): string | undefined;
|
|
338
|
+
/** 正则字面量 → RegExp brand(source/flags/lastIndex 进 slots,供 exec/test 精确执行) */
|
|
339
|
+
declare function $regex(pattern: string, flags?: string): Abs;
|
|
340
|
+
/** 成员读:obj.slots[key];缺失 → undefined 字面量;brand 解包内层 */
|
|
341
|
+
declare function $get(o: Abs, key: string, opts?: {
|
|
342
|
+
silent?: boolean;
|
|
343
|
+
}): Abs;
|
|
344
|
+
/**
|
|
345
|
+
* Map/Set forEach:条目表逐条调用回调(value, key, recv)。
|
|
346
|
+
* 回调是 B 路径 JS 函数(transpile 内联箭头)直接调用;Abs fn 走 $call。
|
|
347
|
+
* 回调返回值丢弃;forEach 表达式值恒 undefined。
|
|
348
|
+
*/
|
|
349
|
+
declare function $collectionForEach(recv: Abs, cb: unknown): Abs | undefined;
|
|
350
|
+
/** 成员写:返回新 obj/brand(不可变更新);frozen/sealed/只读目标按 sloppy 静默失败 */
|
|
351
|
+
declare function $set(o: Abs, key: string, value: Abs): Abs;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* async / await / generator / $switch / $nullishTest。
|
|
355
|
+
*/
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* async 函数体包进 thunk,返回值经 wrapPromise。
|
|
359
|
+
*/
|
|
360
|
+
declare function $async(thunk: () => Abs): Abs;
|
|
361
|
+
/** await → 解包 eff("promise") */
|
|
362
|
+
declare function $await(v: Abs): Abs;
|
|
363
|
+
/** async 直接 return 的 coerce */
|
|
364
|
+
declare function $asyncReturn(v: Abs): Abs;
|
|
365
|
+
/** function* 体:收集所有 yield 值为 tuple Abs;抽象分支时降 conf(P0-6) */
|
|
366
|
+
declare function $gen(body: () => void): Abs;
|
|
367
|
+
/** yield v:压入当前生成器收集器;表达式值用 unknown */
|
|
368
|
+
declare function $yield(v: Abs): Abs;
|
|
369
|
+
/**
|
|
370
|
+
* switch:具体 disc 选中匹配 case;抽象 disc 并所有分支。
|
|
371
|
+
* 抽象路径与 $fork 同构:集合 side-table 按臂 overlay,共享 body 只跑一次;
|
|
372
|
+
* 臂内 NudoReturn/NudoThrow 不冒泡污染兄弟臂。
|
|
373
|
+
* **无 default 时必须隐式 fall-through 臂(undef)**,否则无匹配路径被丢掉(P0-2)。
|
|
374
|
+
*/
|
|
375
|
+
/** `??` / `??=` 测试:确定非 nullish → false;lit nullish → true;否则抽象 boolean */
|
|
376
|
+
declare function $nullishTest(v: Abs): Abs;
|
|
377
|
+
|
|
378
|
+
type TranspileOptions = {
|
|
379
|
+
/** 运行时 import 说明符 */
|
|
380
|
+
runtimeImport?: string;
|
|
381
|
+
maxLoopIters?: number;
|
|
382
|
+
/** 方法体内 this 的绑定名(transpile class 时注入) */
|
|
383
|
+
thisParam?: string;
|
|
384
|
+
/** 当前类名(super 派发用) */
|
|
385
|
+
className?: string;
|
|
386
|
+
/** 原始源码(@nudo:replace 按节点文本匹配) */
|
|
387
|
+
source?: string;
|
|
388
|
+
/** 替换表:归一化目标文本 → 注入变量名;可选语句范围 */
|
|
389
|
+
replacements?: Array<{
|
|
390
|
+
target: string;
|
|
391
|
+
varName: string;
|
|
392
|
+
/** 仅该语句范围内生效(1-based 行) */
|
|
393
|
+
stmtStart?: number;
|
|
394
|
+
stmtEnd?: number;
|
|
395
|
+
}>;
|
|
396
|
+
/** @nudo:as:覆盖紧随语句的 init / return */
|
|
397
|
+
asOverrides?: Array<{
|
|
398
|
+
varName: string;
|
|
399
|
+
stmtStart: number;
|
|
400
|
+
stmtEnd: number;
|
|
401
|
+
}>;
|
|
402
|
+
/** 循环嵌套深度(>0 时 return → $loopReturn,C2.1) */
|
|
403
|
+
inLoop?: number;
|
|
404
|
+
/** 循环体/switch 臂内:无标签 break 语义分别为跳出循环信号 / 臂结束 return */
|
|
405
|
+
inSwitchArm?: boolean;
|
|
406
|
+
/** 标签循环名(`outer: for …`):传给 $for/$whileSeq/$forOf 供信号匹配 */
|
|
407
|
+
loopLabel?: string;
|
|
408
|
+
/** 宽松全局:标识符调用 callee 未声明 → undefined($callNamed 保守
|
|
409
|
+
* unknown),模块不因 ReferenceError 中断——调用点发现的 exec 采集用
|
|
410
|
+
* (测试框架 it/describe/test 等未注入全局) */
|
|
411
|
+
lenientGlobals?: boolean;
|
|
412
|
+
/** try 嵌套深度(>0 时 return 前 drain throwExits,使 catch 能吸收抽象 throw) */
|
|
413
|
+
inTry?: number;
|
|
414
|
+
/** 当前 try 的 mark 变量名(return drain 用;避免全局栈顶污染) */
|
|
415
|
+
tryMarkName?: string;
|
|
416
|
+
/** 当前 try 是否带 catch handler(soft may-throw digest/release 分支) */
|
|
417
|
+
hasTryHandler?: boolean;
|
|
418
|
+
/** 当前 try 的 catch 体是否可能 rethrow(正常路径 soft 效果 release 而非 digest) */
|
|
419
|
+
tryRethrowCatch?: boolean;
|
|
420
|
+
/** 分支/循环体内深度(赋值记录 conditional 标记;inLoop 也计入) */
|
|
421
|
+
conditionalFlow?: number;
|
|
422
|
+
/** 函数/箭头体内(顶层绑定表只收顶层作用域) */
|
|
423
|
+
inFunction?: boolean;
|
|
424
|
+
/**
|
|
425
|
+
* 当前词法作用域的 `arguments` 绑定名(非箭头函数 prologue 里 `$arguments(...)`)。
|
|
426
|
+
* 箭头沿外层继承;无绑定(模块顶层 / 仅嵌套箭头引用)→ Identifier 分支折 $unknown()。
|
|
427
|
+
*/
|
|
428
|
+
argsBinding?: string;
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* transpile 共享 AST 工具:形参名、match、fold、静态键、作用域收集、mutator receiver 扫描。
|
|
433
|
+
* 不依赖 stmt/expr 发射器(无环)。
|
|
434
|
+
*/
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* 编译期常量字符串折叠(require 说明符子集):
|
|
438
|
+
* - StringLiteral
|
|
439
|
+
* - TemplateLiteral(无插值 / 插值全为可 ToString 字面量)
|
|
440
|
+
* - `+` 字符串拼接(至少一侧为可折叠字符串,另一侧为字符串或字面量)
|
|
441
|
+
* 不能折叠 → undefined(诚实动态,不假精确)。
|
|
442
|
+
*/
|
|
443
|
+
declare function foldStaticStringExpr(node: unknown): string | undefined;
|
|
444
|
+
/** require(...) 第一个参数 → 可折叠说明符(StringLiteral / 模板 / 字面量拼接) */
|
|
445
|
+
declare function foldRequireSpecArg(arg: unknown): string | undefined;
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* 语句 / 块 / class 发射:transpileStatement、transpileBodyNode、transpileClass。
|
|
449
|
+
*/
|
|
450
|
+
|
|
451
|
+
declare function transpileBodyNode(node: Node, opts: TranspileOptions): string;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* 表达式发射:transpileExpression / transpileShortCircuitExpr。
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
declare function transpileExpression(expr: Expression, opts?: TranspileOptions): string;
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* B 路径 transpile:JS AST → 可在 Node 上执行的抽象值程序(源码字符串)。
|
|
461
|
+
* 运算符改为 $add/$sub/…;if 改为 $fork;for 改为 $for。
|
|
462
|
+
* 值类型是 Abs;副作用与模块仍由 host mock/注入。
|
|
463
|
+
*
|
|
464
|
+
* 实现按语句/表达式/模式拆在 transpile/*.ts;本文件是 re-export facade,
|
|
465
|
+
* 对外符号面保持不变(exec/index.ts `export * from "./transpile.ts"`)。
|
|
466
|
+
*/
|
|
467
|
+
|
|
468
|
+
declare function transpileSource(source: string, opts?: TranspileOptions): string;
|
|
469
|
+
/** 运行时 import 行(body-fn 编译执行拼接用) */
|
|
470
|
+
declare function runtimeImportOf(runtime: string): string;
|
|
471
|
+
declare function transpileFile(file: File, opts?: TranspileOptions): string;
|
|
472
|
+
/** 解析 + transpile */
|
|
473
|
+
declare function transpile(source: string, opts?: TranspileOptions): string;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* 调用 Abs 一等函数(absFunction impl)或 mock apply。
|
|
477
|
+
* 供 B 路径 import 绑定包装:`(...args) => $call(absFn, args)`。
|
|
478
|
+
*
|
|
479
|
+
* 统一顺序:apply → body → relation → isRelFn(委托 applyAbsFn)。
|
|
480
|
+
* 行为对齐说明(与旧 $call 的差异,均属刻意):
|
|
481
|
+
* 1. 带 body 的函数也进 call-budget(递归会 truncated 而非爆栈)
|
|
482
|
+
* 2. body 抛错 → never(applyAbsFn 内恢复,不返回中间值)
|
|
483
|
+
* 3. 无 impl 时 isRelFn 可走 E 路径(旧版恒 unknown)
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
declare function $call(fn: Abs, args: Abs[], thisVal?: Abs): Abs;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* B class 规格表(无 call 依赖,避免循环)。
|
|
490
|
+
* Abs-eval registerClassDecl 与 transpile $class 共用。
|
|
491
|
+
*/
|
|
492
|
+
|
|
493
|
+
type BClassAccessor = {
|
|
494
|
+
get?: (thisVal: Abs) => Abs;
|
|
495
|
+
set?: (thisVal: Abs, v: Abs) => Abs;
|
|
496
|
+
};
|
|
497
|
+
type BClassSpec = {
|
|
498
|
+
name: string;
|
|
499
|
+
superName?: string;
|
|
500
|
+
ctor?: (thisVal: Abs, ...args: Abs[]) => Abs;
|
|
501
|
+
methods?: Record<string, (thisVal: Abs, ...args: Abs[]) => Abs>;
|
|
502
|
+
/** 实例方法形参展示名(AST 形参名;未调用方法槽 `shape.params` 用) */
|
|
503
|
+
methodParams?: Record<string, string[]>;
|
|
504
|
+
staticMethods?: Record<string, (...args: Abs[]) => Abs>;
|
|
505
|
+
/** 静态方法形参展示名 */
|
|
506
|
+
staticMethodParams?: Record<string, string[]>;
|
|
507
|
+
statics?: Record<string, Abs>;
|
|
508
|
+
/** 实例 get/set:get 无参返回 Abs;set 收到 (thisVal, v) 返回更新后的 thisVal */
|
|
509
|
+
accessors?: Record<string, BClassAccessor>;
|
|
510
|
+
/** 静态 get/set:挂在类构造器上,不在实例原型链 */
|
|
511
|
+
staticAccessors?: Record<string, BClassAccessor>;
|
|
512
|
+
};
|
|
513
|
+
declare function registerBClass(spec: BClassSpec): void;
|
|
514
|
+
declare function getBClass(name: string): BClassSpec | undefined;
|
|
515
|
+
declare function clearBClasses(): void;
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* RegExp brand 执行面(leaf-ish):从 class.ts 拆出,避免巨型文件。
|
|
519
|
+
*/
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* 语句级 RegExp 状态写回(test/exec):执行并把 lastIndex 更新后的 brand
|
|
523
|
+
* 返回给 transpile 重绑($reStateCall 与 $arrMutContainer 同模式)。
|
|
524
|
+
* 表达式位置不写回($invoke 只读执行,调用方按 JS 语义先取值)。
|
|
525
|
+
*/
|
|
526
|
+
declare function $reStateCall(re: Abs, method: string, args: Abs[]): Abs;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* B 路径 class:brand 实例 + ctor/method 闭包 + 继承链。
|
|
530
|
+
* 方法内 this 由 transpile 改写为 thisVal 参数。
|
|
531
|
+
*/
|
|
532
|
+
|
|
533
|
+
/** 定义类 → 可 new 的 Abs(brand 标记;静态字段挂在 slots) */
|
|
534
|
+
declare function $class(name: string, spec: Omit<BClassSpec, "name"> & {
|
|
535
|
+
extends?: string | Abs | unknown;
|
|
536
|
+
}): Abs;
|
|
537
|
+
/** new C(...) → 空 brand 实例 + ctor 写字段;非类构造走 impl/$call */
|
|
538
|
+
declare function $new(cls: Abs | ((...a: unknown[]) => unknown), args: Abs[]): Abs;
|
|
539
|
+
/**
|
|
540
|
+
* super(...):父类构造写入字段(this 保持子类 brand)。
|
|
541
|
+
* transpile: super(a,b) → __this = $super(__this, "Child", [a,b])
|
|
542
|
+
*/
|
|
543
|
+
declare function $super(thisVal: Abs, childName: string, args: Abs[]): Abs;
|
|
544
|
+
|
|
545
|
+
/** 实例方法调用:沿继承链;类 Abs 上回落 staticMethods;obj 上回落属性函数 */
|
|
546
|
+
declare function $invoke(thisVal: Abs, method: string, args: Abs[], loc?: [number, number]): Abs;
|
|
547
|
+
/** super.method():从父类起找(跳过自身覆盖) */
|
|
548
|
+
declare function $invokeSuper(thisVal: Abs, childName: string, method: string, args: Abs[]): Abs;
|
|
549
|
+
declare function $thisGet(thisVal: Abs, key: string): Abs;
|
|
550
|
+
declare function $thisSet(thisVal: Abs, key: string, value: Abs): Abs;
|
|
551
|
+
/** 解构默认值:undefined(含 sum 成员 / 可能缺失)时用 default 并入非 undefined 部分 */
|
|
552
|
+
declare function $orDefault(v: Abs, dflt: () => Abs): Abs;
|
|
553
|
+
/** 可选链 a?.b:nullish 短路为 undefined 字面量 */
|
|
554
|
+
declare function $optionalGet(o: Abs, key: string): Abs;
|
|
555
|
+
/** 可选链 a?.m():nullish 短路为 undefined */
|
|
556
|
+
declare function $optionalInvoke(thisVal: Abs, method: string, args: Abs[]): Abs;
|
|
557
|
+
/** 静态方法:cls.staticMethod(args) */
|
|
558
|
+
declare function $staticInvoke(cls: Abs, method: string, args: Abs[]): Abs;
|
|
559
|
+
/** 计算属性写:o[kAbs] = v。非字面量 key → open + index join(不得写成字面槽 "?") */
|
|
560
|
+
declare function $setKey(o: Abs, key: Abs, value: Abs): Abs;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* B 路径调用点记录:transpile 把 `f(args)` 改成 $callNamed,
|
|
564
|
+
* 分析时可收集 call@ 所需的 AbsCallRecord。
|
|
565
|
+
* 成员缺失诊断见 member-diag.ts(共用,避免循环依赖)。
|
|
566
|
+
*/
|
|
567
|
+
|
|
568
|
+
type BCallRecord = {
|
|
569
|
+
fnName: string;
|
|
570
|
+
args: Abs[];
|
|
571
|
+
result: Abs;
|
|
572
|
+
callLoc?: {
|
|
573
|
+
line: number;
|
|
574
|
+
column: number;
|
|
575
|
+
};
|
|
576
|
+
threw?: boolean;
|
|
577
|
+
};
|
|
578
|
+
/** B 赋值记录(与 ast-records.ts AbsAssignRecord 同形;structuralAssignIssues 消费) */
|
|
579
|
+
type BAbsAssignRecord = {
|
|
580
|
+
name: string;
|
|
581
|
+
prev: Abs | undefined;
|
|
582
|
+
next: Abs;
|
|
583
|
+
line?: number;
|
|
584
|
+
column?: number;
|
|
585
|
+
conditional?: boolean;
|
|
586
|
+
};
|
|
587
|
+
/** 返回先前 collector,便于嵌套调用 save/restore(禁止 finally 置 null 砸外层) */
|
|
588
|
+
declare function setBAssignCollector(collector: ((r: BAbsAssignRecord) => void) | null): ((r: BAbsAssignRecord) => void) | null;
|
|
589
|
+
/** 结构赋值记录(transpile 插桩调用;无收集器时 no-op) */
|
|
590
|
+
declare function $assignRecord(name: string, prev: Abs | undefined, next: Abs, line: number, column: number, conditional: boolean): void;
|
|
591
|
+
declare function setBBindingSink(sink: Map<string, unknown> | null): void;
|
|
592
|
+
/** 顶层绑定记录(transpile 插桩调用) */
|
|
593
|
+
declare function $recordBinding(name: string, value: unknown): void;
|
|
594
|
+
/** 返回先前 collector,便于嵌套调用 save/restore(禁止 finally 置 null 砸外层) */
|
|
595
|
+
/** 成员/方法调用点打点($invoke 等;无收集器时 no-op)。不进 $callNamed 预算。 */
|
|
596
|
+
declare function noteBCallRecord(r: BCallRecord): void;
|
|
597
|
+
declare function setBCallCollector(collector: ((r: BCallRecord) => void) | null): ((r: BCallRecord) => void) | null;
|
|
598
|
+
declare function getBCallCollector(): ((r: BCallRecord) => void) | null;
|
|
599
|
+
/**
|
|
600
|
+
* 按名调用并记录。
|
|
601
|
+
* loc: [line, column](1-based line,0-based column,与 Babel 一致)
|
|
602
|
+
* argLocs: 与 args 对齐的实参字面量源位置(provenance;无 loc 用 null)
|
|
603
|
+
*/
|
|
604
|
+
declare const MAX_B_CALL_DEPTH = 64;
|
|
605
|
+
/** 总调用上限:与 call-budget.MAX_TOTAL_CALLS 同阀(递归×循环×分支展开的
|
|
606
|
+
* 规模阀)。200k 在病态展开(lodash _baseFlatten)下 ~30s,20k 收口到
|
|
607
|
+
* ~3s——截断 → opaque(更保守,zero-FP 安全)。 */
|
|
608
|
+
declare const MAX_B_TOTAL_CALLS = 20000;
|
|
609
|
+
/** 宿主入口(runTranspiled / callTranspiledExportFull)前重置 */
|
|
610
|
+
declare function resetBCallBudget(): void;
|
|
611
|
+
declare function $callNamed(name: string, fn: unknown, args: Abs[], loc?: [number, number], argLocs?: Array<[number, number] | null | undefined>): Abs;
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Abs 模块面(无 fs):import 绑定 + export 收集。
|
|
615
|
+
* 解析路径/读文件在 host;core 只吃「specifier → 导出表」。
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
type AbsModuleExports = {
|
|
619
|
+
named: Record<string, Abs>;
|
|
620
|
+
default?: Abs;
|
|
621
|
+
};
|
|
622
|
+
/** 把 import 说明符绑定进 env(宿主已求值依赖) */
|
|
623
|
+
declare function bindImports(node: ImportDeclaration, env: AstEnv, modules: Record<string, AbsModuleExports>): void;
|
|
624
|
+
/**
|
|
625
|
+
* 从已求值 env + AST 收集 ESM 导出。
|
|
626
|
+
* 支持:export function/const、export { a, b as c }、export default(具名)、
|
|
627
|
+
* 以及带 source 的 re-export(`export { a } from "mod"` / `export * from "mod"`——
|
|
628
|
+
* 需 host 传入已求值 modules)。
|
|
629
|
+
*/
|
|
630
|
+
declare function collectAbsExports(file: File, env: AstEnv, modules?: Record<string, AbsModuleExports>): AbsModuleExports;
|
|
631
|
+
|
|
632
|
+
type RunTranspiledOptions = {
|
|
633
|
+
/** 说明符 → 依赖导出(host 模块图或 runTranspiled 产物) */
|
|
634
|
+
modules?: Record<string, AbsModuleExports | Record<string, unknown>>;
|
|
635
|
+
maxLoopIters?: number;
|
|
636
|
+
/** analyze = 跳过效应性顶层语句 */
|
|
637
|
+
mode?: "exec" | "analyze";
|
|
638
|
+
/** @nudo:replace 注入值:varName → Abs */
|
|
639
|
+
replacements?: Record<string, Abs>;
|
|
640
|
+
/** @nudo:replace 匹配表:传给 transpile */
|
|
641
|
+
replacementTargets?: Array<{
|
|
642
|
+
target: string;
|
|
643
|
+
varName: string;
|
|
644
|
+
stmtStart?: number;
|
|
645
|
+
stmtEnd?: number;
|
|
646
|
+
}>;
|
|
647
|
+
/** @nudo:as 注入值:varName → Abs */
|
|
648
|
+
asOverrides?: Record<string, Abs>;
|
|
649
|
+
/** @nudo:as 语句范围表 */
|
|
650
|
+
asOverrideTargets?: Array<{
|
|
651
|
+
varName: string;
|
|
652
|
+
stmtStart: number;
|
|
653
|
+
stmtEnd: number;
|
|
654
|
+
}>;
|
|
655
|
+
/** @nudo:env 全局 Abs(JSON/Math/console…)→ 作用域绑定 */
|
|
656
|
+
envGlobals?: Record<string, Abs>;
|
|
657
|
+
/** @nudo:mock 注入值:name → Abs(mockDirectivesToAbsSeeds 产物) */
|
|
658
|
+
mocks?: Record<string, Abs>;
|
|
659
|
+
/** 宽松全局(调用点发现 exec 采集:未声明全局调用保守 unknown 不中断) */
|
|
660
|
+
lenientGlobals?: boolean;
|
|
661
|
+
};
|
|
662
|
+
/**
|
|
663
|
+
* inject/modules **内容**指纹(memo 键)。对象身份对「每次新建同内容」
|
|
664
|
+
* 的 CLI 注入不稳——同一语义的 inject 跨 checkSource 调用会 miss 缓存。
|
|
665
|
+
*/
|
|
666
|
+
declare function runTranspiledOptionsMemoKey(opts: RunTranspiledOptions | undefined): string;
|
|
667
|
+
declare const RUNTIME_IMPORT_RE: RegExp;
|
|
668
|
+
declare function bindingsOf(run: Record<string, unknown>): Map<string, unknown> | undefined;
|
|
669
|
+
/**
|
|
670
|
+
* 执行一段 B 路径程序,返回顶层 `export function` / `export const`。
|
|
671
|
+
*/
|
|
672
|
+
declare function runTranspiled(source: string, opts?: RunTranspiledOptions): Record<string, unknown>;
|
|
673
|
+
/** B-path 回落事件(观测单一埋点;reason: unsupported:* = 能力边界,internal = B 自身缺陷) */
|
|
674
|
+
type BPathFallback = {
|
|
675
|
+
reason: string;
|
|
676
|
+
message: string;
|
|
677
|
+
loc?: {
|
|
678
|
+
line: number;
|
|
679
|
+
column: number;
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
declare function setBPathFallbackCollector(collector: ((f: BPathFallback) => void) | null): void;
|
|
683
|
+
/** 表达式级求值(scan 的 case 字面量实参等静态求值面):编译单表达式经
|
|
684
|
+
* B 运行时执行。bindings:表达式自由标识符 → Abs(调用方按绑定表注入)。
|
|
685
|
+
* 编译失败抛错(调用方按需 catch)。 */
|
|
686
|
+
declare function evalExprAbs(expr: _babel_types.Expression, bindings?: Record<string, Abs>): Abs;
|
|
687
|
+
/** 记录一次 B 回落(body-fn 等非 runTranspiled 入口共用) */
|
|
688
|
+
declare function noteBPathFallback(e: unknown): void;
|
|
689
|
+
/**
|
|
690
|
+
* B 单一入口:runTranspiled + 类型化回落观测。
|
|
691
|
+
* unsupported:*(能力边界)/ internal(B 缺陷)都记录到收集器;
|
|
692
|
+
* 返回 undefined 表示调用方应走解释路径。
|
|
693
|
+
*/
|
|
694
|
+
declare function tryRunTranspiled(source: string, opts?: RunTranspiledOptions): Record<string, unknown> | undefined;
|
|
695
|
+
type TranspiledCallResult = {
|
|
696
|
+
result: Abs;
|
|
697
|
+
/** 非 never 表示函数可能 throw 该类型 */
|
|
698
|
+
throws: Abs;
|
|
699
|
+
};
|
|
700
|
+
/** 调用 runTranspiled 导出(捕获 $throw)。opts.phi:入口 Φ 种子
|
|
701
|
+
* (instantiate/symbolic 的约束入口——B 侧路径条件收窄)。 */
|
|
702
|
+
declare function callTranspiledExportFull(exports: Record<string, unknown>, name: string, args: Abs[], opts?: {
|
|
703
|
+
phi?: Phi;
|
|
704
|
+
}): TranspiledCallResult;
|
|
705
|
+
/** 调用 runTranspiled 导出(仅结果) */
|
|
706
|
+
declare function callTranspiledExport(exports: Record<string, unknown>, name: string, args: Abs[]): Abs;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* 转译器无法正确 lowering 的构造:抛此错误(替代静默降级注释)。
|
|
710
|
+
* 消费方(tryRunTranspiled / body-fn)捕获后记录并 fail-closed
|
|
711
|
+
* 结构化回落理由(unsupported:*)——能力知识单一事实源在转译点,
|
|
712
|
+
* 不再依赖带外的 isBPathCapable 清单。
|
|
713
|
+
*/
|
|
714
|
+
declare class NudoUnsupportedError extends Error {
|
|
715
|
+
readonly reason: string;
|
|
716
|
+
readonly loc?: {
|
|
717
|
+
line: number;
|
|
718
|
+
column: number;
|
|
719
|
+
};
|
|
720
|
+
constructor(reason: string, loc?: {
|
|
721
|
+
line: number;
|
|
722
|
+
column: number;
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
export { $add as $, type AbsModuleExports as A, $eq as B, $eqLoose as C, $fnVal as D, $for as E, $forInKeys as F, $forIter as G, $forOf as H, $fork as I, $ge as J, $gen as K, $get as L, $gt as M, $idx as N, $idxSet as O, $importMeta as P, $in as Q, type RunTranspiledOptions as R, $instanceof as S, $instanceofNonIdent as T, $invoke as U, $invokeSuper as V, $isBreakTo as W, $isForkExit as X, $join as Y, $le as Z, $len as _, $arguments as a, NudoReturn as a$, $lit as a0, $loopBreak as a1, $loopContinue as a2, $loopReturn as a3, $lt as a4, $mod as a5, $mul as a6, $ne as a7, $neLoose as a8, $neg as a9, $thisSet as aA, $throw as aB, $toNumber as aC, $tryCurrentMark as aD, $tryDetachSoftCatch as aE, $tryDigestSoftCatch as aF, $tryDiscardSoft as aG, $tryMark as aH, $tryOrphanSoft as aI, $tryPopMark as aJ, $tryReleaseSoftCatch as aK, $tryReleaseSoftOut as aL, $tryTakeSince as aM, $typeof as aN, $unknown as aO, $ushr as aP, $while as aQ, $whileSeq as aR, $yield as aS, type BAbsAssignRecord as aT, type BCallRecord as aU, type BClassSpec as aV, type BPathFallback as aW, DEFAULT_MAX_LOOP_ITERS as aX, MAX_B_CALL_DEPTH as aY, MAX_B_TOTAL_CALLS as aZ, NudoLoopSignal as a_, $new as aa, $not as ab, $nullishTest as ac, $obj as ad, $objAccessor as ae, $objRest as af, $optionalGet as ag, $optionalInvoke as ah, $orDefault as ai, $pow as aj, $pushLoopExit as ak, $rawThis as al, $reStateCall as am, $recordBinding as an, $regex as ao, $rethrowIfNudoReturn as ap, $set as aq, $setKey as ar, $shl as as, $shr as at, $spread as au, $staticInvoke as av, $sub as aw, $super as ax, $switch as ay, $thisGet as az, $arr as b, NudoThrow as b0, NudoUnsupportedError as b1, RUNTIME_IMPORT_RE as b2, type TranspileOptions as b3, type TranspiledCallResult as b4, asAbsVal as b5, bindImports as b6, bindingsOf as b7, callAtFunctionBoundary as b8, callTranspiledExport as b9, resetBCallBudget as bA, runTranspiled as bB, runTranspiledOptionsMemoKey as bC, runWithLoopExits as bD, runtimeImportOf as bE, setBAssignCollector as bF, setBBindingSink as bG, setBCallCollector as bH, setBPathFallbackCollector as bI, takeLoopExits as bJ, takeThrowExits as bK, transpile as bL, transpileBodyNode as bM, transpileExpression as bN, transpileFile as bO, transpileSource as bP, tryRunTranspiled as bQ, withExecPhi as bR, callTranspiledExportFull as ba, clearBClasses as bb, clearStaleTermPred as bc, collectAbsExports as bd, currentExecPhi as be, evalExprAbs as bf, fillTuple as bg, foldRequireSpecArg as bh, foldStaticStringExpr as bi, getBCallCollector as bj, getBClass as bk, isArrMutator as bl, isDefinitelyFalse as bm, isDefinitelyTrue as bn, isNudoBreak as bo, isNudoContinue as bp, isNudoReturn as bq, isNudoThrow as br, litTruth as bs, lookupObjAccessor as bt, namespaceNameOf as bu, noteBCallRecord as bv, noteBPathFallback as bw, pushLoopExit as bx, pushThrowExit as by, registerBClass as bz, $arrMutContainer as c, $arrRest as d, $arrWithHoles as e, $assignRecord as f, $async as g, $asyncReturn as h, $await as i, $bitand as j, $bitnot as k, $bitor as l, $bitxor as m, $call as n, $callNamed as o, $catchVal as p, $class as q, $classExpr as r, $collectionForEach as s, $concat as t, $copy as u, $del as v, $delRes as w, $div as x, $dynamicImport as y, $elems as z };
|