@nudojs/core 1.16.0 → 1.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OM6SAY2M.js → chunk-CUFP2AYV.js} +6429 -5834
- package/dist/{chunk-POGFCYV2.js → chunk-G27PMV2U.js} +290 -239
- package/dist/exec.d.ts +326 -121
- package/dist/exec.js +14 -16
- package/dist/index.d.ts +57 -79
- package/dist/index.js +24 -210
- package/dist/internal.d.ts +16 -41
- package/dist/internal.js +3 -32
- package/dist/{projection-budget-DW-svmIf.d.ts → projection-budget-NCXMnUDn.d.ts} +4 -1
- package/dist/{run-T9HWTziZ.d.ts → run-DeKkteRZ.d.ts} +55 -40
- package/package.json +1 -1
- /package/dist/{chunk-US532PZA.js → chunk-II73GZOY.js} +0 -0
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-DeKkteRZ.js';
|
|
2
|
+
export { V as $assignRecord, W as $call, X as $callNamed, bG as $nodoPos, Y as $recordBinding, a4 as EvalAbsAssignRecord, a5 as EvalCallRecord, a6 as EvalFallback, g as EvalFallbackStats, a7 as EvalPosRecord, aa as MAX_EVAL_CALL_DEPTH, ab as MAX_EVAL_TOTAL_CALLS, R as RunTranspiledOptions, ad as TranspiledCallResult, ar as bindingsOf, au as callTranspiledExport, av as callTranspiledExportApply, aw as callTranspiledExportFull, l as clearPureCallMemo, m as clearPureMemo, n as enterEvalCallBudgetSession, aB as evalExprAbs, p as exitEvalCallBudgetSession, v as getEvalCallBudgetState, aE as getEvalCallCollector, w as getEvalFallbackStats, bH as getPosCollector, aM as isAbsVal, aO as isCjsMainRun, b3 as noteEvalCallRecord, b4 as noteEvalFallback, bl as resetEvalCallBudget, H as resetEvalFallbackStats, bI as routeApplyThrows, bm as runTranspiled, bn as runTranspiledOptionsMemoKey, bo as setEvalAssignCollector, bp as setEvalBindingSink, bq as setEvalCallCollector, br as setEvalFallbackCollector, bt as setPosCollector, bD as tryRunTranspiled, O as withEvalBudgetOverride } from './run-DeKkteRZ.js';
|
|
3
3
|
import { Node, Expression, File } from '@babel/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -95,8 +95,18 @@ declare function $fnVal(params: string[], impl: (...args: Abs[]) => Abs, opts?:
|
|
|
95
95
|
* globalThis——归一到 $lit(undefined)(strict 模块语义下的 this)。
|
|
96
96
|
*/
|
|
97
97
|
declare function $rawThis(v: unknown): Abs;
|
|
98
|
+
/** const 绑定再赋值(Assignment to constant variable)→ hard TypeError */
|
|
99
|
+
declare function $throwConstAssign(): never;
|
|
100
|
+
/**
|
|
101
|
+
* 自由 `arguments` 读(模块顶层 / 无任何外层函数绑定):非宿主全局,
|
|
102
|
+
* 原生 unresolvable reference → hard ReferenceError(ESM 无 arguments
|
|
103
|
+
* 全局;`typeof arguments` 豁免由 transpile 折 "undefined" 不走此处)。
|
|
104
|
+
*/
|
|
105
|
+
declare function $throwFreeArguments(): never;
|
|
98
106
|
/** `new.target` 读:栈顶类值;普通调用面已清空 → undefined 字面量 */
|
|
99
107
|
declare function $newTarget(): Abs;
|
|
108
|
+
/** 生成代码可用的真值判定(undefined = 无法判定);与 litTruth 同口径 */
|
|
109
|
+
declare function $litTruth(a: Abs): boolean | undefined;
|
|
100
110
|
/** 字面量 → Abs(transpile 侧数字/字符串/布尔/null/undefined) */
|
|
101
111
|
declare function $lit(v: unknown): Abs;
|
|
102
112
|
/** JS 真值:字面量按 Boolean(v);对象形恒真;不可判 → undefined */
|
|
@@ -145,6 +155,14 @@ declare class NudoReturn extends Error {
|
|
|
145
155
|
declare function isNudoReturn(e: unknown): e is NudoReturn;
|
|
146
156
|
/** transpile `return x` inside for/while → `$loopReturn(x)` */
|
|
147
157
|
declare function $loopReturn(v: Abs): never;
|
|
158
|
+
/**
|
|
159
|
+
* transpile 函数体边界吸收器:`try { body } catch (e) { return $catchReturn(e); }`
|
|
160
|
+
* —— 函数体内 $loopReturn 早退(循环 / if 臂)在函数自身边界收成返回值,
|
|
161
|
+
* 转译模块对裸宿主调用(e2e 真实 .mjs 导入 / 模块顶层互调)自包含;
|
|
162
|
+
* 其余异常(NudoThrow / 原生错误)原样 rethrow。仅在发射体含 $loopReturn
|
|
163
|
+
* 时由 transpile 侧包裹。
|
|
164
|
+
*/
|
|
165
|
+
declare function $catchReturn(e: unknown): Abs;
|
|
148
166
|
declare class NudoLoopSignal extends Error {
|
|
149
167
|
readonly kind: "break" | "continue";
|
|
150
168
|
readonly label: string | undefined;
|
|
@@ -174,6 +192,23 @@ declare function $sub(a: Abs, b: Abs): Abs;
|
|
|
174
192
|
declare function $mul(a: Abs, b: Abs): Abs;
|
|
175
193
|
declare function $div(a: Abs, b: Abs): Abs;
|
|
176
194
|
declare function $mod(a: Abs, b: Abs): Abs;
|
|
195
|
+
/**
|
|
196
|
+
* issue #165:局部量引理锚定。`@nudo:assume <name> <= <name>` 从仅形参扩展到
|
|
197
|
+
* 形参 ∪ 函数体顶层 const/let/var 局部绑定,SSA 语义:引理作用于绑定值,
|
|
198
|
+
* 从定义点到作用域尾。transpile 在局部量 init 处包裹
|
|
199
|
+
* `$assumeAnchor(init, name)`——把 init 结果的 term α-改名为 var(name),
|
|
200
|
+
* 使后续读点与 assume 前提里的 var(name) 同项,arithmetic 的同名相关性
|
|
201
|
+
* 折叠(le 折除法界等)才能命中。shape/conf 不动,嵌套 shape 内 term
|
|
202
|
+
* 不改(保守:根 term 已建立项身份,深改无消费方)。
|
|
203
|
+
*
|
|
204
|
+
* 为何需要当前帧前提护栏:assume 前提不随调用链继承——callee 帧一律见空
|
|
205
|
+
* (callAtFunctionBoundary 以 withAssumePremises(pTrue, …) 包裹 callee 体)。
|
|
206
|
+
* 锚定落在错帧(前提 pTrue,或 and 原子中没有任何 le 原子在 a/b 侧以
|
|
207
|
+
* var(name) 出现——本帧没有这条引理)时,改名只会凭空捏造约束身份 →
|
|
208
|
+
* 原样 no-op。这也封死 #123 式同名 term 碰撞:callee 恰有同名局部时,
|
|
209
|
+
* caller 帧前提已被清空,caller 引理不会错投到 callee 的同名绑定上。
|
|
210
|
+
*/
|
|
211
|
+
declare function $assumeAnchor(v: unknown, name: string): unknown;
|
|
177
212
|
declare function $bitand(a: Abs, b: Abs): Abs;
|
|
178
213
|
declare function $bitor(a: Abs, b: Abs): Abs;
|
|
179
214
|
declare function $bitxor(a: Abs, b: Abs): Abs;
|
|
@@ -237,7 +272,7 @@ declare function $in(key: Abs, o: Abs): Abs;
|
|
|
237
272
|
declare function $instanceof(left: Abs, rightName: string, rightVal?: Abs): Abs;
|
|
238
273
|
/** instanceof 右操作数非标识符(表达式/成员路径):RHS 值传入时先做原生
|
|
239
274
|
* 非对象校验(definite / may TypeError);构造器值未知 → 抽象 boolean */
|
|
240
|
-
declare function $instanceofNonIdent(
|
|
275
|
+
declare function $instanceofNonIdent(_left: Abs, right?: Abs): Abs;
|
|
241
276
|
/**
|
|
242
277
|
* ClassExpression 值:构造器函数形状,不得折成精确 undefined。
|
|
243
278
|
*
|
|
@@ -292,17 +327,12 @@ declare function lookupObjAccessor(o: Abs, key: string): {
|
|
|
292
327
|
*/
|
|
293
328
|
declare const DEFAULT_MAX_LOOP_ITERS = 8;
|
|
294
329
|
|
|
295
|
-
declare function $fork(test: Abs, consequent: () => Abs, alternate?: () => Abs): Abs;
|
|
296
|
-
|
|
297
330
|
/**
|
|
298
|
-
* for
|
|
299
|
-
* 抽象条件无法诚实终止——消费者必须自带 maxIters。
|
|
331
|
+
* 控制流:loop/try 退出栈、$fork/$for/$whileSeq、$throw。
|
|
300
332
|
*/
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
afterBody: Abs;
|
|
305
|
-
}, void, void>;
|
|
333
|
+
|
|
334
|
+
declare function $fork(test: Abs, consequent: () => Abs, alternate?: () => Abs): Abs;
|
|
335
|
+
|
|
306
336
|
/**
|
|
307
337
|
* 有界 for:unroll ≤ maxIters,每步「可能退出」的态 join;
|
|
308
338
|
* 相邻态 leq 视为不动点提前停。
|
|
@@ -316,11 +346,6 @@ declare function $for(init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, b
|
|
|
316
346
|
* ——转译侧在体的 finally 里写回共享槽;缺省(未插桩)时以 state 近似。 */
|
|
317
347
|
loopVar?: () => Abs;
|
|
318
348
|
}): Abs;
|
|
319
|
-
/**
|
|
320
|
-
* 有界 while:state 线程穿 test/step(与 $for 同折叠语义)。
|
|
321
|
-
* 抽象条件无法诚实终止——必须 maxIters。
|
|
322
|
-
*/
|
|
323
|
-
declare function $while(init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, maxIters?: number): Abs;
|
|
324
349
|
/**
|
|
325
350
|
* 顺序 while(具体/可变闭包):body 内对 JS 变量赋值。
|
|
326
351
|
* 提供 pack/unpack 时,抽象条件的可能出口会 join 回绑定(P0 健全);
|
|
@@ -334,19 +359,6 @@ declare function $whileSeq(test: () => Abs, body: () => void, maxIters?: number,
|
|
|
334
359
|
/** 标签循环:仅吸收同标签 break/continue 信号 */
|
|
335
360
|
label?: string;
|
|
336
361
|
}): void;
|
|
337
|
-
/**
|
|
338
|
-
* switch:具体 disc 选中匹配 case;抽象 disc 并所有分支。
|
|
339
|
-
* 抽象路径与 $fork 同构:集合 side-table 按臂 overlay,共享 body 只跑一次;
|
|
340
|
-
* 臂内 NudoReturn/NudoThrow 不冒泡污染兄弟臂。
|
|
341
|
-
* **无 default 时必须隐式 fall-through 臂(undef)**,否则无匹配路径被丢掉(P0-2)。
|
|
342
|
-
*
|
|
343
|
-
* Bug 241:**字面量判别式 + 非字面量 case 测试**(`switch (true) { case x > 0: … }`)
|
|
344
|
-
* ——原生里 case 测试是运行时求值的表达式,命中与否取决于测试值;此前字面量
|
|
345
|
-
* 判别式路径只接受「case 测试也是字面量」的臂,其余臂被**整条丢弃**(永不
|
|
346
|
-
* 命中)⇒ 臂内返回值从返回域/签名里消失 ⇒ 契约真实违约被漏报(L1 门禁假绿)。
|
|
347
|
-
* 修法:遇到非字面量 case 测试 ⇒ **分叉**(命中该臂 / 不命中继续后续臂与
|
|
348
|
-
* default),两路结果并入返回域(switchForked)。
|
|
349
|
-
*/
|
|
350
362
|
declare function $switch(disc: Abs, cases: Array<{
|
|
351
363
|
test: Abs;
|
|
352
364
|
run: () => Abs;
|
|
@@ -377,6 +389,10 @@ declare function $catchVal(e: unknown): Abs;
|
|
|
377
389
|
* - $copy 是 fork/switch/循环 pack 的状态分离机制:所有可挂侧表的形状
|
|
378
390
|
* (extState/propFlags/accessorTable/nullProto/matchIter)必须随快照
|
|
379
391
|
* 迁移,副本丢失侧表 = 臂内写不再硬抛 / 延迟异常静默丢弃。
|
|
392
|
+
* - fn 形状同样是可扩展对象:expando 槽面(含 optionalParams/ctor/类型
|
|
393
|
+
* 侧信息)逐臂独立复制(共享槽面会让兄弟臂写互相覆盖);impl 身份、
|
|
394
|
+
* 槽面写权限侧表(objects.ts 的 userFnSlotOwners)、null-proto 标记与
|
|
395
|
+
* 新鲜实例 id 随副本迁移(侧表丢失 ⇒ `__proto__` 读翻转 / `===` 退化)。
|
|
380
396
|
* - $spread 原生语义会**调用**源对象 getter 并把结果拷为数据槽——必须
|
|
381
397
|
* 用 getter 求值后的副本(accessorTable 求值,抛/失败折 unknown)。
|
|
382
398
|
* - $objRest 同理:原生 CopyDataProperties 对保留键发 Get ⇒ getter 必须
|
|
@@ -387,8 +403,18 @@ declare function $catchVal(e: unknown): Abs;
|
|
|
387
403
|
* 深拷贝可变容器(fork/switch 快照与循环 pack 用)。
|
|
388
404
|
* 容器写就地进行后(引用语义),分析分支/迭代的状态分离必须靠拷贝——
|
|
389
405
|
* 浅引用快照会让臂间/迭代间互相污染。
|
|
406
|
+
*
|
|
407
|
+
* `memo` 是**身份图**:同一原始 Abs 在同一次快照里必须映射到同一个副本。
|
|
408
|
+
* - 循环引用(`o.self = o`)靠「先占位、后填空」终止递归;
|
|
409
|
+
* - 共享子图(DAG)不再指数复制;
|
|
410
|
+
* - 同一次快照/调用边界里的多个绑定保持别名关系(memo 必须由调用方共享;
|
|
411
|
+
* `$copy(a)` 单参调用只为兼容旧行为,等价于每次新建 memo)。
|
|
412
|
+
*
|
|
413
|
+
* 注意:这只能保证**被复制集合内部**的身份关系。若 `b` 是 `a` 的别名但
|
|
414
|
+
* 不在同一次快照的绑定集合里,fork/pack 仍会断开 `a`/`b`;调用方必须把
|
|
415
|
+
* 别名伙伴一起纳入复制集合(见 transpile 的 aliasGroups)。
|
|
390
416
|
*/
|
|
391
|
-
declare function $copy(a: Abs): Abs;
|
|
417
|
+
declare function $copy(a: Abs, memo?: WeakMap<object, Abs>): Abs;
|
|
392
418
|
/** 对象字面量 → Abs obj(槽位写走 setSlot,`__proto__` 不踩宿主 setter) */
|
|
393
419
|
declare function $obj(slots: Record<string, Abs>): Abs;
|
|
394
420
|
/**
|
|
@@ -725,64 +751,26 @@ declare function $set(o: Abs, key: string, value: Abs, opts?: {
|
|
|
725
751
|
}): Abs;
|
|
726
752
|
|
|
727
753
|
/**
|
|
728
|
-
*
|
|
754
|
+
* 空值 / 类型 / 相等 / 关系守卫的臂剪影(narrowing)运行时。
|
|
729
755
|
*
|
|
730
|
-
*
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
*
|
|
736
|
-
*
|
|
737
|
-
* - Bug
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
741
|
-
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
744
|
-
*
|
|
756
|
+
* 域:转译器在守卫臂内对绑定名做的影子重绑(`exec/transpile/stmt-predicates.ts`
|
|
757
|
+
* 发射、`runtime.ts` facade 转出):
|
|
758
|
+
* - nullish:`$removeNullish` / `$removeNull` / `$removeUndefined` /
|
|
759
|
+
* `$removeMemberNullish`——按 term 字面量逐成员剥离 null / undefined
|
|
760
|
+
* (Bug 3 粒度),`$nullishTest` 产出 `??` / `??=` 的测试值;
|
|
761
|
+
* - typeof:`$narrowTypeOf` 按 typeof 分类剪 union 成员(事实臂 / 补集臂);
|
|
762
|
+
* - 判别等值:`$narrowMemberEq` 按 key 槽的字面量事实剪成员(issue #126);
|
|
763
|
+
* - 关系:`$refineRel` 给关系事实臂挂界(Bug 1)。
|
|
764
|
+
*
|
|
765
|
+
* 共享 nullish 谓词:`isNullishLitAbs` / `definitelyNotNullishShape`
|
|
766
|
+
* (surface.ts)与本地 `isNullLitAbs` / `isUndefLitAbs` /
|
|
767
|
+
* `definitelyNullishAbs` 是同一套逐成员判定口径——各剪影的「剪空 → 原样
|
|
768
|
+
* 返回」保守分支都以此为准;其它 runtime 文件不要另造第二套。
|
|
769
|
+
*
|
|
770
|
+
* 本文件不依赖 async / generator 机制(单向:runtime/async.ts 与
|
|
771
|
+
* runtime.ts 只做转出);新增 narrow 算子放这里,不要回填 async.ts。
|
|
745
772
|
*/
|
|
746
773
|
|
|
747
|
-
declare function $async(thunk: () => Abs): Abs;
|
|
748
|
-
/** await → 解包 eff("promise") */
|
|
749
|
-
declare function $await(v: Abs): Abs;
|
|
750
|
-
/** async 直接 return 的 coerce */
|
|
751
|
-
declare function $asyncReturn(v: Abs): Abs;
|
|
752
|
-
/** function* 体:收集所有 yield 值;返回带迭代器协议面的生成器对象 Abs;
|
|
753
|
-
* 抽象分支时降 conf(P0-6)
|
|
754
|
-
*
|
|
755
|
-
* Bug 58:调用生成器是原生全操作——体只在首个 next() 执行。body() eager
|
|
756
|
-
* 执行的体内效果(成员读 may-throw / 显式 throw)不折进**调用方** throws
|
|
757
|
-
* 域——以捕获式 may-throw 帧包裹:soft 效果与 NudoThrow 挂生成器对象
|
|
758
|
-
* (Bug 34 延迟重放:首个触达抛点的 next()/迭代消费,仅构造不消费不
|
|
759
|
-
* 表面)。yield 收集保持 eager(既有值域建模,注释口径不变)。
|
|
760
|
-
* Bug 2:thunk 返回值 = 终末 return 值——不再丢弃,经 makeGenObject 在
|
|
761
|
-
* 首个 done:true 作为 value 交付(node 实测:此后 next 回 undefined)。
|
|
762
|
-
* Bug 22:结果从 yield 元组数组改为生成器对象(next/return/throw 方法面 +
|
|
763
|
-
* constructor 身份);元素域经侧表保留($arr 的 ≤cap tuple / >cap arr
|
|
764
|
-
* widen 策略不变),迭代路径(for-of/spread/Array.from)继续工作。
|
|
765
|
-
* Bug 53:侧表/next() 消费完整收集序列(ys.els)——$arr >cap widen 只影响
|
|
766
|
-
* 形状槽(类型面),不再把 >8 yield 截断成单元素流。
|
|
767
|
-
* Bug 52:yield 点 try 上下文(ys.ctxs,$yield 第二实参)随序列传递——
|
|
768
|
-
* .return()/.throw() 挂起点语义见 makeGenObject。
|
|
769
|
-
* Bug 141:asyncMode(第二实参)= async generator 面——迭代结果经 promise
|
|
770
|
-
* 交付(next/return/throw 返 promise)、装 @@asyncIterator 自返槽与
|
|
771
|
-
* @@toStringTag "AsyncGenerator"(原生 async function* / async * 方法)。 */
|
|
772
|
-
declare function $gen(body: () => Abs, asyncMode?: boolean): Abs;
|
|
773
|
-
/** yield v:压入当前生成器收集器;表达式值用 unknown。
|
|
774
|
-
* tryCtx(Bug 52)= transpile 静态标注的 yield 点 try 上下文位
|
|
775
|
-
* (YIELD_TRY_FINALLY / YIELD_TRY_CATCH),.return()/.throw() 挂起点
|
|
776
|
-
* 语义用(见 makeGenObject)。 */
|
|
777
|
-
declare function $yield(v: Abs, tryCtx?: number): Abs;
|
|
778
|
-
/** yield* v(Bug 82):委托迭代 ≠ yield v——GetIterator 校验先行($elems
|
|
779
|
-
* 同分类器:非可迭代接收者 definite/may TypeError,生成器体内按 $gen
|
|
780
|
-
* 迭代期语义由外层帧吸收),**元素**逐个压入收集器(此前把整个可迭代值
|
|
781
|
-
* 压一次);表达式值 = 内层迭代器的 return 值(生成器 return / 自定义
|
|
782
|
-
* iterator 的 done 值,不可判)→ 保守 unknown。长度不可判的接收者
|
|
783
|
-
* (arr/any/…)单代表元素过近似并入 + bumpGenPathSensitive 压 conf
|
|
784
|
-
* (mergeArmYields 同口径,禁 exact 元组出货)。 */
|
|
785
|
-
declare function $yieldStar(v: unknown, tryCtx?: number): Abs;
|
|
786
774
|
/**
|
|
787
775
|
* `??` 非 nullish 臂:从左值 Abs 剥离 nullish 部分($nullishTest 判 true
|
|
788
776
|
* 的成员)。索引访问 `M[k]` 对抽象键产出 joinAbs(element, undef()),
|
|
@@ -855,9 +843,144 @@ declare function $narrowMemberEq(a: Abs, key: string, value: string | number | b
|
|
|
855
843
|
/** `??` / `??=` 测试:确定非 nullish → false;lit nullish → true;否则抽象 boolean */
|
|
856
844
|
declare function $nullishTest(v: Abs): Abs;
|
|
857
845
|
|
|
846
|
+
/**
|
|
847
|
+
* async / await / generator 运行时(nullish / typeof / 判别 / 关系守卫的臂
|
|
848
|
+
* 剪影在 runtime/narrow.ts,本文件只为深路径导入者做兼容转出)。
|
|
849
|
+
*
|
|
850
|
+
* 不变量(本文件):
|
|
851
|
+
* - `$await` 的取值面 = 原生的 adopt 口径:promise 走 eff("promise") 通道
|
|
852
|
+
* (**双臂** promise 的 rejected 臂不得丢——记入 throw 通道供体内
|
|
853
|
+
* try/catch 吸收,未被吸收者并入 promise 的 rejected 通道);**thenable**
|
|
854
|
+
* (闭对象 + 自有 then 槽)走 PromiseResolve 式采纳(取 then(res, rej)
|
|
855
|
+
* 的 settle 值,不是 thenable 本身)。any/unknown/fn/开对象的采纳面
|
|
856
|
+
* 不可判 → 保持原值(不猜、不用 unknown 掩盖)。
|
|
857
|
+
* - Bug 1052:thenable 采纳的**判定与调用**与 promise 构造面(`Promise.resolve`
|
|
858
|
+
* / `new Promise(resolve => resolve(thenable))`)**同一套机制**
|
|
859
|
+
* (`builtins/promise.ts` 的 `thenableAdoption`)——本文件只做 await 面的
|
|
860
|
+
* 语义映射(reject → throw;未 settle → 悬挂)。
|
|
861
|
+
* - 生成器对象是**内部槽对象**:协议方法与 yield 元素的槽标 internal
|
|
862
|
+
* (枚举面 / 自有面不可见;$get / $in 照常直读直查)。
|
|
863
|
+
* - `yield*` 委托的 `.return(v)` 必须**转发**给委托迭代器(委托的清理
|
|
864
|
+
* 副作用不得整体丢失)。
|
|
865
|
+
*/
|
|
866
|
+
|
|
867
|
+
declare function $async(thunk: () => Abs): Abs;
|
|
868
|
+
/**
|
|
869
|
+
* Bug 201:async 体的**真挂起**路径(宿主生成器驱动)。
|
|
870
|
+
*
|
|
871
|
+
* 转译侧:async 体(**直接含 await**)编译成宿主生成器 `function*(){…}`,
|
|
872
|
+
* `await x` 发射 `yield x`(挂起点 + 被等待值)。本函数驱动生成器:
|
|
873
|
+
*
|
|
874
|
+
* - **同步段**:跑到第一个挂起点即返回 promise(inner 暂 unknown)⇒
|
|
875
|
+
* await 之后的语句**不在调用点内联跑完**(原生:恢复点是微任务)。
|
|
876
|
+
* - **续体**:登记到宿主微任务队列(与 promise reaction **同一队列** ⇒
|
|
877
|
+
* 跨 promise 链的先后顺序天然保真——上游 promise 的续体先跑,下游
|
|
878
|
+
* `await` 恢复时读到的已是上游终值)。
|
|
879
|
+
* - **值域**:续体跑完 ⇒ 就地填 promise 的 inner(终值由续体给出)。
|
|
880
|
+
*
|
|
881
|
+
* 与 `$async(thunk)` 的分工:**无 await 的 async 体**没有挂起点,沿用
|
|
882
|
+
* `$async` 的同步路径(发射产物逐字不变 ⇒ 既有金标零漂移)。
|
|
883
|
+
*
|
|
884
|
+
* Bug 1126:live `$asyncGen` promise 带 **pending 态**(体尚未 settle)与
|
|
885
|
+
* **waiter 列表**(等它 settle 才恢复的 await 恢复点)。
|
|
886
|
+
*
|
|
887
|
+
* **机制共用**(Bug 1148):pending 判定 + waiter 冲刷抽到
|
|
888
|
+
* `builtins/promise.ts` 的 `pendingPromiseWaiters`(`registerPendingPromise` /
|
|
889
|
+
* `isPendingPromiseShape` / `onPromiseSettled` / `flushPromiseWaiters`)——
|
|
890
|
+
* `Promise.all` 的活通道聚合(元素 settle 后刷新兑现值)与本文件的 await 恢复
|
|
891
|
+
* 点**同一套** pending 机制(不另造第二套)。
|
|
892
|
+
*
|
|
893
|
+
* 键 = promise 的 shape 对象(活通道本体:`inner` 就地填)。每个 `$asyncGen`
|
|
894
|
+
* 调用一个 shape ⇒ 键唯一;WeakMap ⇒ 随 promise 回收,不泄漏。
|
|
895
|
+
*
|
|
896
|
+
* **不挂在 shape 上**:`Shape` 是 `abs.ts` 的公开联合类型(eff 面无 pending
|
|
897
|
+
* 槽),且 waiter 闭包不该进投影 / 指纹面(`absShapeKey` / `shapeKey` 只读
|
|
898
|
+
* `inner`)。
|
|
899
|
+
*/
|
|
900
|
+
declare function $asyncGen(genFn: () => Generator): Abs;
|
|
901
|
+
/** await → 解包 eff("promise") */
|
|
902
|
+
declare function $await(v: Abs): Abs;
|
|
903
|
+
/** function* 体:收集所有 yield 值;返回带迭代器协议面的生成器对象 Abs;
|
|
904
|
+
* 抽象分支时降 conf(P0-6)
|
|
905
|
+
*
|
|
906
|
+
* Bug 58:调用生成器是原生全操作——体只在首个 next() 执行。body() eager
|
|
907
|
+
* 执行的体内效果(成员读 may-throw / 显式 throw)不折进**调用方** throws
|
|
908
|
+
* 域——以捕获式 may-throw 帧包裹:soft 效果与 NudoThrow 挂生成器对象
|
|
909
|
+
* (Bug 34 延迟重放:首个触达抛点的 next()/迭代消费,仅构造不消费不
|
|
910
|
+
* 表面)。yield 收集保持 eager(既有值域建模,注释口径不变)。
|
|
911
|
+
* Bug 2:thunk 返回值 = 终末 return 值——不再丢弃,经 makeGenObject 在
|
|
912
|
+
* 首个 done:true 作为 value 交付(node 实测:此后 next 回 undefined)。
|
|
913
|
+
* Bug 22:结果从 yield 元组数组改为生成器对象(next/return/throw 方法面 +
|
|
914
|
+
* constructor 身份);元素域经侧表保留($arr 的 ≤cap tuple / >cap arr
|
|
915
|
+
* widen 策略不变),迭代路径(for-of/spread/Array.from)继续工作。
|
|
916
|
+
* Bug 53:侧表/next() 消费完整收集序列(ys.els)——$arr >cap widen 只影响
|
|
917
|
+
* 形状槽(类型面),不再把 >8 yield 截断成单元素流。
|
|
918
|
+
* Bug 52:yield 点 try 上下文(ys.ctxs,$yield 第二实参)随序列传递——
|
|
919
|
+
* .return()/.throw() 挂起点语义见 makeGenObject。
|
|
920
|
+
* Bug 141:asyncMode(第二实参)= async generator 面——迭代结果经 promise
|
|
921
|
+
* 交付(next/return/throw 返 promise)、装 @@asyncIterator 自返槽与
|
|
922
|
+
* @@toStringTag "AsyncGenerator"(原生 async function* / async * 方法)。 */
|
|
923
|
+
declare function $gen(body: () => Abs, asyncMode?: boolean): Abs;
|
|
924
|
+
/** yield v:压入当前生成器收集器;表达式值用 unknown。
|
|
925
|
+
* tryCtx(Bug 52)= transpile 静态标注的 yield 点 try 上下文位
|
|
926
|
+
* (YIELD_TRY_FINALLY / YIELD_TRY_CATCH),.return()/.throw() 挂起点
|
|
927
|
+
* 语义用(见 makeGenObject)。 */
|
|
928
|
+
declare function $yield(v: Abs, tryCtx?: number): Abs;
|
|
929
|
+
/** yield* v(Bug 82):委托迭代 ≠ yield v——GetIterator 校验先行($elems
|
|
930
|
+
* 同分类器:非可迭代接收者 definite/may TypeError,生成器体内按 $gen
|
|
931
|
+
* 迭代期语义由外层帧吸收),**元素**逐个压入收集器(此前把整个可迭代值
|
|
932
|
+
* 压一次);表达式值 = 内层迭代器的 return 值(生成器 return / 自定义
|
|
933
|
+
* iterator 的 done 值,不可判)→ 保守 unknown。长度不可判的接收者
|
|
934
|
+
* (arr/any/…)单代表元素过近似并入 + bumpGenPathSensitive 压 conf
|
|
935
|
+
* (mergeArmYields 同口径,禁 exact 元组出货)。 */
|
|
936
|
+
declare function $yieldStar(v: unknown, tryCtx?: number): Abs;
|
|
937
|
+
|
|
858
938
|
type TranspileOptions = {
|
|
859
|
-
/**
|
|
860
|
-
|
|
939
|
+
/**
|
|
940
|
+
* 运行时 import 说明符。
|
|
941
|
+
*
|
|
942
|
+
* `null` = **不发射**运行时 import 行(宿主编译:`new Function` 单元以
|
|
943
|
+
* 形参注入运行符号)。缺省 = `@nudojs/core/exec`。
|
|
944
|
+
*/
|
|
945
|
+
runtimeImport?: string | null;
|
|
946
|
+
/**
|
|
947
|
+
* 发射目标(缺省 `"esm"`,既有产物逐字节不变):
|
|
948
|
+
* - `"esm"`:保留标准 `import` / `export` 语句(run.ts 后处理改写);
|
|
949
|
+
* - `"host"`:直接发射宿主编译形态——import → `__nudoBindImport` /
|
|
950
|
+
* `__nudoBindNamespace` 绑定,export → `__nudoExport*` 调用,不残留任何
|
|
951
|
+
* `import` / `export` 语句,也不发射运行时 import 行(宿主以形参注入)。
|
|
952
|
+
*/
|
|
953
|
+
target?: "esm" | "host";
|
|
954
|
+
/**
|
|
955
|
+
* 发射模式(缺省 `"exec"`):
|
|
956
|
+
* - `"exec"`:完整发射(全部顶层语句,含副作用);
|
|
957
|
+
* - `"analyze"`:**发射期**剥离顶层效应语句——顶层 `if` / `for` /
|
|
958
|
+
* `while`、危险或未知全局调用(判定表见 `transpile/analyze-strip.ts`);
|
|
959
|
+
* `var` 提升仍按**原始**源 AST 计算。调用方(run.ts 的 analyze 模式)
|
|
960
|
+
* 不再解析生成产物做二次剥离;保留语句的发射字节与 `"exec"` 完全一致,
|
|
961
|
+
* 剥离只减少语句。
|
|
962
|
+
*
|
|
963
|
+
* `for-in` / `for-of` **不剥离**(判定表无该臂):二者按发射形态落顶层
|
|
964
|
+
* `$forOf(...)` 调用(循环体随该调用在模块顶层执行)⇒ analyze 模式保留
|
|
965
|
+
* 其语义;标签 `for` / `while` 随标签一并剥离。
|
|
966
|
+
*/
|
|
967
|
+
mode?: "exec" | "analyze";
|
|
968
|
+
/**
|
|
969
|
+
* host target 的 mock 名集:命中的 import 本地名绑定 `__nudoEnv[<名>]`
|
|
970
|
+
* 而非 `__nudoBindImport` / `__nudoBindNamespace`,且不登记 live refresh
|
|
971
|
+
* (刷新会把 mock 冲掉)。esm target 忽略(run.ts 的文本改写负责 mock)。
|
|
972
|
+
*/
|
|
973
|
+
mockNames?: ReadonlySet<string>;
|
|
974
|
+
/**
|
|
975
|
+
* @internal host target 的 live import refresh 发射状态(transpileFile
|
|
976
|
+
* 创建并跨语句线程化):`binds` 是全量刷新赋值文本(按源序,已排除
|
|
977
|
+
* mock),`done` 标记注册行是否已随首个「产生绑定」的 import 语句发射。
|
|
978
|
+
* 直接调用 `transpileStatement` 的低层单元不传 ⇒ 不发射注册行。
|
|
979
|
+
*/
|
|
980
|
+
hostImportRefresh?: {
|
|
981
|
+
readonly binds: readonly string[];
|
|
982
|
+
done: boolean;
|
|
983
|
+
};
|
|
861
984
|
maxLoopIters?: number;
|
|
862
985
|
/** 方法/函数体内 this 的绑定名(transpile class 时注入) */
|
|
863
986
|
thisParam?: string;
|
|
@@ -983,6 +1106,20 @@ type TranspileOptions = {
|
|
|
983
1106
|
asyncForAwaitGates?: ReadonlySet<string>;
|
|
984
1107
|
/** 函数/箭头体内(顶层绑定表只收顶层作用域) */
|
|
985
1108
|
inFunction?: boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* 当前**函数体作用域**的形参名(含解构 / rest 模式名)。
|
|
1111
|
+
*
|
|
1112
|
+
* 用途:标识符赋值的结构检查插桩(`$assignRecord` 第 7 实参
|
|
1113
|
+
* `paramBinding`)——JS 形参没有声明类型,分析面看到的「旧值」是本次
|
|
1114
|
+
* 调用实参的形状而非绑定的声明的域 ⇒ 形参重赋值不参与
|
|
1115
|
+
* `nudo:assign-mismatch`(归一化形参 `x = [].concat(x)` 是常规写法,
|
|
1116
|
+
* 否则真实包假阳性)。
|
|
1117
|
+
*
|
|
1118
|
+
* 生命周期:函数/方法体边界由 `transpileFnBodyStmts` 按该体自身的形参
|
|
1119
|
+
* 重算(嵌套函数体不继承外层的表);模块顶层无此表。**表达式体箭头**
|
|
1120
|
+
* (`(x) => (x = 1)`)不经语句表 ⇒ 无表(该形态不插标)。
|
|
1121
|
+
*/
|
|
1122
|
+
paramNames?: ReadonlySet<string>;
|
|
986
1123
|
/**
|
|
987
1124
|
* 当前词法作用域的 `arguments` 绑定名(非箭头函数 prologue 里 `$arguments(...)`)。
|
|
988
1125
|
* 箭头沿外层继承;无绑定(模块顶层 / 仅嵌套箭头引用)→ Identifier 分支折 $unknown()。
|
|
@@ -1013,6 +1150,45 @@ type TranspileOptions = {
|
|
|
1013
1150
|
* 成员/下标写对根的内部重绑不在用户赋值路径,不走此表。
|
|
1014
1151
|
*/
|
|
1015
1152
|
constNames?: ReadonlySet<string>;
|
|
1153
|
+
/**
|
|
1154
|
+
* 直接 const 别名组(`const a = {...}; const b = a;`)。
|
|
1155
|
+
*
|
|
1156
|
+
* fork/循环 pack 只按「被写绑定」收集快照名;别名伙伴不在集合里时,
|
|
1157
|
+
* 臂/轮次结束把 `a` 重绑为副本会断开 `b` 的引用语义。该表在**作用域
|
|
1158
|
+
* 边界**上计算(只收 init 为同作用域、此前已声明 const 的标识符,避免
|
|
1159
|
+
* TDZ 与可重绑 let):函数/方法体与嵌套块由 transpileFnBodyStmts 算,
|
|
1160
|
+
* **模块顶层**(模块体逐语句发射、不经函数体入口)由 transpile.ts 算。
|
|
1161
|
+
* 嵌套作用域**继承**外层组并按自身遮蔽名过滤(未被遮蔽 ⇒ 同一绑定,
|
|
1162
|
+
* 展开安全;被遮蔽 ⇒ 该组在本处指向不同绑定,丢弃),fork/pack 发射时
|
|
1163
|
+
* 据此扩展 snapshot 集合。
|
|
1164
|
+
*/
|
|
1165
|
+
aliasGroups?: ReadonlyArray<readonly string[]>;
|
|
1166
|
+
/**
|
|
1167
|
+
* 本转译单元内被用户绑定**遮蔽**的宿主内建名(undefined / NaN / Infinity
|
|
1168
|
+
* 的子集,保守单位级)。
|
|
1169
|
+
*
|
|
1170
|
+
* 名字是**宿主全局**但用户可合法遮蔽(`const undefined = 5`、形参名
|
|
1171
|
+
* `undefined`、`let NaN`、import 绑定)。命中者按**位置**分态:
|
|
1172
|
+
* - Identifier 读点(含标签模板位)→ `$absVal(<名>)`,由 JS 词法绑定
|
|
1173
|
+
* 决定读值;
|
|
1174
|
+
* - 调用位 callee → `$callNamed(<名>, <名>, …)`(绑定是 Abs 值,宿主裸
|
|
1175
|
+
* 调用会把它当非函数调 ⇒ 假抛 TypeError)。
|
|
1176
|
+
*
|
|
1177
|
+
* 未命中者:读点恢复字面量精确折叠(`$lit(void 0)` / `$lit(0/0)` /
|
|
1178
|
+
* `$lit(1/0)`,与旧产物逐字节一致),调用位保留宿主裸调用(原生
|
|
1179
|
+
* `undefined(1)` / `NaN(1)` 定抛 TypeError,抛点与原生一致)。
|
|
1180
|
+
*
|
|
1181
|
+
* 计算:`transpileFile` 从源 AST 声明扫描(任意作用域,保守单位级);
|
|
1182
|
+
* `transpileBodyNode` 从 body AST 计算并并入调用方补给;body-fn 补给
|
|
1183
|
+
* 形参 / 闭包绑定名;evalExprAbs 补给注入的 bindings 名 **∪ 表达式 AST
|
|
1184
|
+
* 声明扫描**;表达式入口(exec/transpile/expr.ts 的 `transpileExpression`)
|
|
1185
|
+
* 同补声明扫描(表达式内部的形参 / 局部声明此前不可见);run.ts 补给
|
|
1186
|
+
* @nudo:mock 注入的内建名(env 注入本就跳过这三个名字)。
|
|
1187
|
+
*
|
|
1188
|
+
* 静态窄化面:`x === undefined` / `case undefined:` 只在**未遮蔽**时作
|
|
1189
|
+
* 字面量事实——遮蔽后该标识符是普通绑定,比较值是绑定值(如 5)。
|
|
1190
|
+
*/
|
|
1191
|
+
shadowedIntrinsics?: ReadonlySet<string>;
|
|
1016
1192
|
/**
|
|
1017
1193
|
* **调用方补给的**用户标识符词形集(Bug 1058 避让的补充来源)。
|
|
1018
1194
|
*
|
|
@@ -1035,6 +1211,21 @@ type TranspileOptions = {
|
|
|
1035
1211
|
* 声明语句),此类名字从提升集扣除、不发改赋值。
|
|
1036
1212
|
*/
|
|
1037
1213
|
keepVarDecl?: boolean;
|
|
1214
|
+
/**
|
|
1215
|
+
* 本文件**真实**的静态声明导出名(源 AST:`export function|class|const|let`
|
|
1216
|
+
* / `var`,多声明符全收;解构声明不收内部名)。
|
|
1217
|
+
*
|
|
1218
|
+
* 只有顶层 FunctionDeclaration 的名字命中本集合时才发射 `export ` 前缀
|
|
1219
|
+
* ——此前所有顶层函数一律带 export(发射 quirk)⇒ run.ts 的文本回收把
|
|
1220
|
+
* 私有顶层函数当导出 ⇒ `export *` 被本地私有同名函数遮蔽、私有名泄漏进
|
|
1221
|
+
* 模块导出面、转译产物作为真实 ESM 时多出导出。
|
|
1222
|
+
*
|
|
1223
|
+
* `export { f }` specifier 名**不**在此集合(同名声明未必是声明式导出;
|
|
1224
|
+
* run.ts 在运行时把 specifier 改写成 __nudoExportLazy)。
|
|
1225
|
+
* transpileFile 从已解析 AST 计算并线程化;缺省(直接调用
|
|
1226
|
+
* transpileStatement 的低层单元)⇒ 不发 export。
|
|
1227
|
+
*/
|
|
1228
|
+
exportedDeclNames?: ReadonlySet<string>;
|
|
1038
1229
|
/**
|
|
1039
1230
|
* issue #165:文件含 `@nudo:assume` 引理——transpileFile 顶层对源文本
|
|
1040
1231
|
* 做一次 includes 判定后置位。文件级快速门:无引理的文件不进锚定收集,
|
|
@@ -1085,6 +1276,22 @@ declare function foldStaticStringExpr(node: unknown): string | undefined;
|
|
|
1085
1276
|
/** require(...) 第一个参数 → 可折叠说明符(StringLiteral / 模板 / 字面量拼接) */
|
|
1086
1277
|
declare function foldRequireSpecArg(arg: unknown): string | undefined;
|
|
1087
1278
|
|
|
1279
|
+
/**
|
|
1280
|
+
* 运行时 import 行(body-fn 编译执行 / evalExprAbs / 模块体拼接用)。
|
|
1281
|
+
* 产出形态:`import { $a, $b } from "<runtime>";`(单行,双引号说明符)。
|
|
1282
|
+
*/
|
|
1283
|
+
declare function runtimeImportOf(runtime: string): string;
|
|
1284
|
+
/**
|
|
1285
|
+
* 宿主编译前**剥离**上面那行 import 的正则(默认 ESM 产物 / 旧调用方)。
|
|
1286
|
+
*
|
|
1287
|
+
* `new Function` 单元没有 ESM 导入面——运行符号是形参注入(rt.ts 的
|
|
1288
|
+
* compileRuntimeUnit)。host target(`runtimeImport: null`)不发射该行;
|
|
1289
|
+
* 默认 ESM 产物若被宿主直接编译,仍需本正则剥离。只认**双引号**说明符
|
|
1290
|
+
* (runtimeImportOf 的产物);用户源码的 import 由 host target 的
|
|
1291
|
+
* `emitHostImportDeclaration` 直接发射绑定。
|
|
1292
|
+
*/
|
|
1293
|
+
declare const RUNTIME_IMPORT_RE: RegExp;
|
|
1294
|
+
|
|
1088
1295
|
/**
|
|
1089
1296
|
* 方法/函数体统一发射(stmt 按域拆分之一;语句 switch 在 ./statement.ts)。
|
|
1090
1297
|
*
|
|
@@ -1129,24 +1336,36 @@ declare function foldRequireSpecArg(arg: unknown): string | undefined;
|
|
|
1129
1336
|
declare function transpileBodyNode(node: Node, opts: TranspileOptions): string;
|
|
1130
1337
|
|
|
1131
1338
|
/**
|
|
1132
|
-
*
|
|
1339
|
+
* 表达式发射:transpileExpression / transpileShortCircuitExpr。
|
|
1340
|
+
* 按域拆分(facade 保持原导入面不变):
|
|
1341
|
+
* - transpile 主分派(replace/Chain/可选链入口/switch 路由 + dispatch bind)
|
|
1342
|
+
* - short-circuit $fork 短路协议(&&/||/??/三元/逻辑赋值)
|
|
1343
|
+
* - optional-chain 可选链整链短路(flatten/emit/delete 链)
|
|
1344
|
+
* - atom 字面量/标识符/模板/import()/JSX
|
|
1345
|
+
* - operators 二元逻辑/条件/一元/更新/await/yield/序列
|
|
1346
|
+
* - member 成员读(静态/计算/私有名/length/super 读)
|
|
1347
|
+
* - call 调用/new/super 调用/require
|
|
1348
|
+
* - object 对象/数组字面量与展开
|
|
1349
|
+
* - assignment 赋值/复合赋值/逻辑赋值/解构赋值
|
|
1350
|
+
* - function 函数/类表达式 + 参数模式名
|
|
1133
1351
|
*
|
|
1134
|
-
*
|
|
1135
|
-
*
|
|
1136
|
-
* (./optional-chain.ts)→ Super 接收者 → 按节点类别族路由;未 lowering
|
|
1137
|
-
* 的表达式统一 default unsupported(不得假精确 undefined);
|
|
1138
|
-
* - positionRecordWrap 只包一次:内部递归一律经 transpileExpression 入口,
|
|
1139
|
-
* 族模块回环经 transpile-dispatch 别名(emitTranspileExpression);
|
|
1140
|
-
* - SSR 加载序陷阱:模块体尾部的 dispatch bind 是加载期副作用——必须直接
|
|
1141
|
-
* import leaf(transpile-dispatch)与定义模块(./short-circuit.ts),不经
|
|
1142
|
-
* facade/barrel 中转(vite SSR 下 barrel 再导出不是实例化期绑定)。
|
|
1352
|
+
* 本文件是**表达式入口**(公开面):`transpileExpression` 在此补遮蔽判定
|
|
1353
|
+
* (见下方函数注释)——主分派(./expr/transpile.ts)保持纯发射。
|
|
1143
1354
|
*/
|
|
1144
1355
|
|
|
1145
1356
|
/**
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1357
|
+
* 表达式入口(公开面):**遮蔽判定**补声明扫描。
|
|
1358
|
+
*
|
|
1359
|
+
* 宿主内建名(undefined / NaN / Infinity)的读点按遮蔽分态(未遮蔽 → 字面量
|
|
1360
|
+
* 精确折叠;已遮蔽 → 标识符读点 `$absVal`,由 JS 词法绑定决定读值)。模块
|
|
1361
|
+
* 入口(transpileFile / transpileBodyNode / body-fn)按**单元级**扫描声明
|
|
1362
|
+
* 绑定名判定;表达式入口此前只信调用方给的 `opts.shadowedIntrinsics` ⇒ 表达
|
|
1363
|
+
* 式**内部**的声明(形参名 undefined / 局部 let / const / var / catch 参数)
|
|
1364
|
+
* 不可见 ⇒ 体折宿主内建(原生读的是绑定值 ⇒ 自信的错值)。
|
|
1365
|
+
*
|
|
1366
|
+
* 口径与模块入口同源(helpers.ts 的 shadowedIntrinsicsOf):单元级**保守**
|
|
1367
|
+
* 扫描(任意作用域出现同名绑定即计入)∪ 调用方已给的遮蔽集(注入名 / mock)。
|
|
1368
|
+
* 无命中 → 不写 opts 字段 ⇒ 产物逐字节不变。
|
|
1150
1369
|
*/
|
|
1151
1370
|
declare function transpileExpression(expr: Expression, opts?: TranspileOptions): string;
|
|
1152
1371
|
|
|
@@ -1156,7 +1375,7 @@ declare function transpileExpression(expr: Expression, opts?: TranspileOptions):
|
|
|
1156
1375
|
* 值类型是 Abs;副作用与模块仍由 host mock/注入。
|
|
1157
1376
|
*
|
|
1158
1377
|
* 实现按语句/表达式/模式拆在 transpile/*.ts;本文件是 re-export facade,
|
|
1159
|
-
* 对外符号面保持不变(exec/index.ts
|
|
1378
|
+
* 对外符号面保持不变(exec/index.ts 对公开符号做显式具名导出)。
|
|
1160
1379
|
*
|
|
1161
1380
|
* 不变量(解构临时名,Bug 181):
|
|
1162
1381
|
* - 模块级解构临时名计数器(`destrTmpSeq`)在**创建处**即预置避让:序号
|
|
@@ -1166,8 +1385,6 @@ declare function transpileExpression(expr: Expression, opts?: TranspileOptions):
|
|
|
1166
1385
|
*/
|
|
1167
1386
|
|
|
1168
1387
|
declare function transpileSource(source: string, opts?: TranspileOptions): string;
|
|
1169
|
-
/** 运行时 import 行(body-fn 编译执行拼接用) */
|
|
1170
|
-
declare function runtimeImportOf(runtime: string): string;
|
|
1171
1388
|
declare function transpileFile(file: File, opts?: TranspileOptions): string;
|
|
1172
1389
|
/** 解析 + transpile */
|
|
1173
1390
|
declare function transpile(source: string, opts?: TranspileOptions): string;
|
|
@@ -1260,7 +1477,7 @@ declare function getEvalClass(name: string): EvalClassSpec | undefined;
|
|
|
1260
1477
|
declare function clearBClasses(): void;
|
|
1261
1478
|
|
|
1262
1479
|
/**
|
|
1263
|
-
* 类声明/注册/构造:$class/$new
|
|
1480
|
+
* 类声明/注册/构造:$class/$new + registry 辅助。
|
|
1264
1481
|
*
|
|
1265
1482
|
* Invariants:
|
|
1266
1483
|
* - classImpl(WeakMap)是 spec 的唯一私有挂载点:Abs 对象身份 → 定义
|
|
@@ -1280,13 +1497,6 @@ declare function $class(name: string, spec: Omit<EvalClassSpec, "name"> & {
|
|
|
1280
1497
|
}, displayName?: string): Abs;
|
|
1281
1498
|
/** new C(...) → 空 brand 实例 + ctor 写字段;非类构造走 impl/$call */
|
|
1282
1499
|
declare function $new(cls: Abs | ((...a: unknown[]) => unknown), args: Abs[]): Abs;
|
|
1283
|
-
/**
|
|
1284
|
-
* Bug 77:静态块在类定义期执行(原生 ClassDefinitionEvaluation 的
|
|
1285
|
-
* InitializeStaticElements)。transpile 在 `let C = $class(...)` 绑定完成
|
|
1286
|
-
* **之后**发射本调用——块体内类名按词法可见(原生 static 块内类绑定已
|
|
1287
|
-
* 初始化);this 绑定类值;块内 throw 在定义点表面(NudoThrow 上浮)。
|
|
1288
|
-
*/
|
|
1289
|
-
declare function $staticInit(cls: Abs, thunks: Array<(thisVal: Abs) => unknown>): void;
|
|
1290
1500
|
|
|
1291
1501
|
/**
|
|
1292
1502
|
* super 家族:$super/$invokeSuper/$getSuper/$setSuper + 对象超与静态超。
|
|
@@ -1376,18 +1586,15 @@ declare function $invokeKey(thisVal: Abs, key: Abs, args: Abs[] | (() => Abs[]),
|
|
|
1376
1586
|
declare function $optionalInvokeKey(thisVal: Abs, key: Abs, args: Abs[]): Abs;
|
|
1377
1587
|
|
|
1378
1588
|
/**
|
|
1379
|
-
* this/可选链/静态成员读写:$
|
|
1589
|
+
* this/可选链/静态成员读写:$optionalGet/$staticInvoke/$setKey。
|
|
1380
1590
|
*
|
|
1381
1591
|
* Invariants:
|
|
1382
|
-
* -
|
|
1383
|
-
* (?.)已过 nullish 排除——不重复记 may-throw。
|
|
1592
|
+
* - 可选链臂(?.)已过 nullish 排除——不重复记 may-throw。
|
|
1384
1593
|
* - $setKey 计算键写:非字面量 key → open + index join(不得写成字面
|
|
1385
1594
|
* 槽 "?");对象字面量计算键 __proto__ 是自有数据属性(与 $set 的
|
|
1386
1595
|
* setter 语义分流)。
|
|
1387
1596
|
*/
|
|
1388
1597
|
|
|
1389
|
-
declare function $thisGet(thisVal: Abs, key: string): Abs;
|
|
1390
|
-
declare function $thisSet(thisVal: Abs, key: string, value: Abs): Abs;
|
|
1391
1598
|
/** 解构默认值:undefined(含 sum 成员 / 可能缺失)时用 default 并入非 undefined 部分 */
|
|
1392
1599
|
declare function $orDefault(v: Abs, dflt: () => Abs): Abs;
|
|
1393
1600
|
/** 可选链 a?.b:nullish 短路为 undefined 字面量。非 nullish 臂的属性读对
|
|
@@ -1399,8 +1606,6 @@ declare function $optionalGet(o: Abs, key: string, opts?: {
|
|
|
1399
1606
|
}): Abs;
|
|
1400
1607
|
/** 可选链 a?.m():nullish 短路为 undefined */
|
|
1401
1608
|
declare function $optionalInvoke(thisVal: Abs, method: string, args: Abs[]): Abs;
|
|
1402
|
-
/** 静态方法:cls.staticMethod(args) */
|
|
1403
|
-
declare function $staticInvoke(cls: Abs, method: string, args: Abs[]): Abs;
|
|
1404
1609
|
/** 计算属性写:o[kAbs] = v。非字面量 key → open + index join(不得写成字面槽 "?") */
|
|
1405
1610
|
declare function $setKey(o: Abs, key: Abs, value: Abs): Abs;
|
|
1406
1611
|
|
|
@@ -1438,4 +1643,4 @@ declare class NudoUnsupportedError extends Error {
|
|
|
1438
1643
|
detail?: string);
|
|
1439
1644
|
}
|
|
1440
1645
|
|
|
1441
|
-
export { $absVal, $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $async, $
|
|
1646
|
+
export { $absVal, $add, $arguments, $arr, $arrMutContainer, $arrRest, $arrWithHoles, $assumeAnchor, $async, $asyncGen, $await, $bitand, $bitnot, $bitor, $bitxor, $catchReturn, $catchVal, $class, $classExpr, $collectionForEach, $concat, $copy, $del, $delRes, $div, $dynamicImport, $elems, $eq, $eqLoose, $fnKindStamp, $fnVal, $for, $forInKeys, $forOf, $fork, $ge, $gen, $get, $getSuper, $getSuperObj, $gt, $idx, $idxSet, $importMeta, $in, $instanceof, $instanceofNonIdent, $invoke, $invokeKey, $invokeSuper, $invokeSuperKey, $invokeSuperObj, $isBreakTo, $isForkExit, $iterCheck, $join, $le, $len, $lit, $litTruth, $loopBreak, $loopContinue, $loopReturn, $lt, $mod, $mul, $narrowMemberEq, $narrowTypeOf, $ne, $neLoose, $neg, $new, $newTarget, $not, $nullishTest, $obj, $objAccessor, $objAccessorKey, $objRest, $optionalGet, $optionalInvoke, $optionalInvokeKey, $orDefault, $pow, $pushLoopExit, $rawThis, $reStateCall, $refineRel, $regex, $removeMemberNullish, $removeNull, $removeNullish, $removeUndefined, $restBind, $rethrowIfNudoReturn, $set, $setKey, $setProto, $setSuper, $setSuperObj, $setSuperStatic, $shl, $shr, $spread, $staticSuperInvoke, $sub, $super, $switch, $throw, $throwConstAssign, $throwFreeArguments, $toNumber, $toNumeric, $tpl, $tryCurrentMark, $tryDetachSoftCatch, $tryDigestSoftCatch, $tryDiscardSoft, $tryMark, $tryOrphanSoft, $tryPopMark, $tryReleaseSoftCatch, $tryReleaseSoftOut, $tryTakeSince, $typeof, $unknown, $updateAdd, $updateSub, $ushr, $whileSeq, $yield, $yieldStar, DEFAULT_MAX_LOOP_ITERS, type EvalClassSpec, NudoLoopSignal, NudoReturn, NudoThrow, NudoUnsupportedError, RUNTIME_IMPORT_RE, type TranspileOptions, asAbsVal, callAtFunctionBoundary, clearBClasses, clearStaleTermPred, currentAssumePremises, 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, withAssumePremises, withExecPhi };
|