feat(state): 调用点扫描补上 module_10032 内部构造

此前只扫跨模块的「别名 = dep.\\$.导出键」再 new,10032 内部动作互相 new 的 666 处全漏(215 个类里 212 个因此被判成无调用点)。改为先按局部类名直扫 10032,再扫其它模块。

结果:有调用点的类 639 → 861/864,调用点 1515 → 2181,已定类型字段 306 → 361(runtime 162 / callsite 199),无调用点字段 983 → 12,compileKotlinJs 通过。
This commit is contained in:
TermiNexus committed 2026-10-21 20:23:58 +08:00
1 parent 37be0e2418
commit a0466b6544
3 files changed
+9496 -3975

No files matched your search

File diff suppressed because it is too large. Load diff
+26 -18
View File
@@ -64,6 +64,31 @@ for (const [K, L] of ExportToLocal) if (LocalToName.has(L)) KeyToName.set(K, Loc
// 扫全包调用点
const Calls = new Map(); // 动作名 → [{Module, Args}]
// 在 Text 里收集 `<Local>(…)` 的构造点(Kotlin/JS 的 data class 用 new 调用)
function CollectCalls(Text, Local, Name, Module) {
const Re = new RegExp('(?<![\\w$.])new ' + Local.replace(/[$]/g, '\\$') + '\\s*\\(', 'g');
let M;
while ((M = Re.exec(Text))) {
const Open = Text.indexOf('(', M.index);
let Depth = 0;
let End = -1;
for (let I = Open; I < Text.length; I++) {
if (Text[I] === '(') Depth++;
else if (Text[I] === ')') { Depth--; if (Depth === 0) { End = I; break; } }
}
if (End < 0) continue;
const Args = SplitArgs(Text.slice(Open + 1, End));
const List = Calls.get(Name) || [];
List.push({ Module, Args });
Calls.set(Name, List);
}
}
// ① module_10032 内部:动作之间互相 new(这些类大多不导出,外部扫不到)
for (const [Local, Name] of LocalToName) CollectCalls(Src10032, Local, Name, 'module_10032');
// ② 其它模块:经由 `别名 = dep.$_$.<导出键>` 引入后 new
for (const F of fs.readdirSync(SRC).filter((N) => /^module_\d+\.js$/.test(N))) {
if (F === 'module_10032.js') continue;
const Text = fs.readFileSync(path.join(SRC, F), 'utf8');
@@ -75,24 +100,7 @@ for (const F of fs.readdirSync(SRC).filter((N) => /^module_\d+\.js$/.test(N))) {
if (Name && !Alias.has(M[1])) Alias.set(M[1], Name);
}
if (!Alias.size) continue;
for (const [Local, Name] of Alias) {
const Re = new RegExp('(?<![\\w$.])new ' + Local.replace(/[$]/g, '\\$') + '\\s*\\(', 'g');
let M;
while ((M = Re.exec(Text))) {
const Open = Text.indexOf('(', M.index);
let Depth = 0;
let End = -1;
for (let I = Open; I < Text.length; I++) {
if (Text[I] === '(') Depth++;
else if (Text[I] === ')') { Depth--; if (Depth === 0) { End = I; break; } }
}
if (End < 0) continue;
const Args = SplitArgs(Text.slice(Open + 1, End));
const List = Calls.get(Name) || [];
List.push({ Module: F.replace('.js', ''), Args });
Calls.set(Name, List);
}
}
for (const [Local, Name] of Alias) CollectCalls(Text, Local, Name, F.replace('.js', ''));
}
const Named = Inventory.Rows.filter((R) => Calls.has(R.Name));
File diff suppressed because it is too large. Load diff