实现了 TPV 的 pyi 生成逻辑(部分),删除了直接拷贝自 CPython(TPC) 版本的死代码

This commit is contained in:
2026-07-22 19:47:23 +08:00
parent a99d2a5ad9
commit 751dc72d61
19 changed files with 641 additions and 1436 deletions

View File

@@ -68,7 +68,6 @@ def _load_includes_sha1_set(pool: memhub.MemBuddy | t.CPtr,
# 打开文件
f: fileio.File | t.CPtr = fileio.File(map_path, fileio.MODE.R)
if f.closed:
stdio.printf("[StubMerger] _sha1_map.txt 不存在: %s\n", map_path)
return -1
# 读取内容(使用 stdlib.malloc 避免 mbuddy 池耗尽)
@@ -166,7 +165,6 @@ def WriteIncludesSha1Map(mb: memhub.MemBuddy | t.CPtr, temp_dir: str,
# 打开文件写入CREATE_ALWAYS
f: fileio.File | t.CPtr = fileio.File(map_path, fileio.MODE.W)
if f.closed:
stdio.printf("[Phase1] 无法写入 _sha1_map.txt: %s\n", map_path)
return 1
# 写入每个 include 条目: {sha1}:includes/{rel_path}\n
@@ -192,7 +190,6 @@ def WriteIncludesSha1Map(mb: memhub.MemBuddy | t.CPtr, temp_dir: str,
written_count += 1
f.close()
stdio.printf("[Phase1] 已写入 _sha1_map.txt (%d 个 includes)\n", written_count)
return 0
@@ -1160,7 +1157,6 @@ def BuildCombinedIR(temp_dir: str, local_sha1: str,
if temp_dir is None or local_sha1 is None or out_buf is None or out_size == 0:
return 0
stdio.printf("[BuildCombinedIR] start: sha1=%s\n", local_sha1)
td_len: t.CSizeT = string.strlen(temp_dir)
out_buf[0] = '\0'
out_pos: t.CSizeT = 0
@@ -1182,7 +1178,6 @@ def BuildCombinedIR(temp_dir: str, local_sha1: str,
stub_br: t.CInt64T = sf.read_all(stub_content, STUB_READ_BUF_SIZE)
sf.close()
stdlib.free(stub_path)
stdio.printf("[BuildCombinedIR] stub read: %d bytes\n", stub_br)
if stub_br <= 0:
stdlib.free(stub_content)
return 0
@@ -1212,7 +1207,6 @@ def BuildCombinedIR(temp_dir: str, local_sha1: str,
stub_content[ext_off + 6] = ' '
stub_content[ext_off + 7] = ' '
fix_pos = ext_off + 8
stdio.printf("[BuildCombinedIR] stub_fix done, slen=%d\n", slen)
# 直接复制修复后的 stub 内容
if out_pos + slen + 2 < out_size:
string.strcpy(out_buf + out_pos, stub_content)