refactor(sidecar): 删除 BuildCombinedIR 文本合并死代码(④-d)
在线模型方案(④-a~④-c)已由 LoadFullIR 取代文本合并,BuildCombinedIR 及其专属辅助(_Seen* 去重表、_RegisterStubLines、_LoadAndAppendStub、_LoadAndAppendTextDeclares、_IsTypeDefLine/_IsIrHeaderLine/HoistTypeDefsBeforeDeclares、_collect_stub_sha1s、_stub_scan_cache_*)已无调用方,一并删除(约 1348 行);同步改写 #35/TranslatorGenMixin 中引用旧函数的注释。
This commit is contained in:
1 parent
df9a5a9beb
commit
9bd3ac3dfb
4 files changed
+6
-1347
No files matched your search
@@ -57,7 +57,7 @@ def _sliced_path(temp_dir: str, td_len: sizet, sha1: str, ext: str) -> str:
|
||||
|
||||
# 确保子目录存在: {temp_dir}/{subdir}
|
||||
# 不创建目录会导致 fileio.File(MODE.W) 静默失败(file.closed==True),
|
||||
# 进而 BuildCombinedIR 读不到文件返回 0("BuildCombinedIR 失败")。
|
||||
# 进而读取端读不到文件返回 0("加载 IR 失败")。
|
||||
dir_path_len: sizet = td_len + sub_len + 2
|
||||
dir_path: bytes = stdlib.malloc(dir_path_len)
|
||||
if dir_path is not None:
|
||||
@@ -80,86 +80,7 @@ def _sliced_path(temp_dir: str, td_len: sizet, sha1: str, ext: str) -> str:
|
||||
viperlib.snprintf(path, path_len, "%s/%s.%s", temp_dir, sha1, ext)
|
||||
|
||||
return path
|
||||
# ============================================================
|
||||
# _collect_stub_sha1s - 递归扫描子目录,收集 .stub.ll 文件的 SHA1(从文件名提取)
|
||||
#
|
||||
# level=0 → 扫描 {base_dir}/*.stub.ll;level>0 → 扫描 {base_dir}/* 的子目录并对每个子目录递归调用。
|
||||
#
|
||||
# Args: base_dir 当前扫描目录;bd_len base_dir 长度;level 剩余递归层数;out_arr 输出数组(每个 SHA1 17 字节 = 16字符 + null);out_count 当前已收集数量;max_count 最大数量
|
||||
# Returns: 收集后的总数量
|
||||
# ============================================================
|
||||
def _collect_stub_sha1s(base_dir: str, bd_len: sizet, level: int,
|
||||
out_arr: str, out_count: int, max_count: int) -> int:
|
||||
"""递归扫描子目录,收集 .stub.ll 文件的 SHA1"""
|
||||
if base_dir is None or out_arr is None:
|
||||
return out_count
|
||||
if out_count >= max_count:
|
||||
return out_count
|
||||
|
||||
find_data: rawptr[win32file.WIN32_FIND_DATAA] = stdlib.malloc(win32file.WIN32_FIND_DATAA.__sizeof__())
|
||||
if find_data is None:
|
||||
return out_count
|
||||
string.memset(find_data, 0, win32file.WIN32_FIND_DATAA.__sizeof__())
|
||||
|
||||
if level <= 0:
|
||||
# 扫描 {base_dir}/*.stub.ll
|
||||
pattern: bytes = stdlib.malloc(bd_len + 16)
|
||||
if pattern is None:
|
||||
stdlib.free(find_data)
|
||||
return out_count
|
||||
viperlib.snprintf(pattern, bd_len + 16, "%s/*.stub.ll", base_dir)
|
||||
handle: win32base.HANDLE = win32file.FindFirstFileA(pattern, find_data)
|
||||
stdlib.free(pattern)
|
||||
if handle != win32base.INVALID_HANDLE_VALUE:
|
||||
while True:
|
||||
if out_count >= max_count:
|
||||
break
|
||||
fname: str = find_data.cFileName
|
||||
if fname is not None:
|
||||
if fname[0] != '\0':
|
||||
# 从文件名提取 SHA1(前 16 字符)
|
||||
string.strncpy(out_arr + out_count * 17, fname, 16)
|
||||
out_arr[out_count * 17 + 16] = '\0'
|
||||
out_count += 1
|
||||
if win32file.FindNextFileA(handle, find_data) == 0:
|
||||
break
|
||||
win32file.FindClose(handle)
|
||||
else:
|
||||
# 扫描 {base_dir}/* 的子目录
|
||||
pattern = stdlib.malloc(bd_len + 4)
|
||||
if pattern is None:
|
||||
stdlib.free(find_data)
|
||||
return out_count
|
||||
viperlib.snprintf(pattern, bd_len + 4, "%s/*", base_dir)
|
||||
handle = win32file.FindFirstFileA(pattern, find_data)
|
||||
stdlib.free(pattern)
|
||||
if handle != win32base.INVALID_HANDLE_VALUE:
|
||||
while True:
|
||||
# 检查是否是目录(FILE_ATTRIBUTE_DIRECTORY = 0x10 = 16)
|
||||
attrs: uint32 = find_data.dwFileAttributes
|
||||
if (attrs & 16) != 0:
|
||||
fname = find_data.cFileName
|
||||
if fname is not None:
|
||||
# 跳过 "." 和 ".."
|
||||
is_dot: int = 0
|
||||
if fname[0] == '.':
|
||||
if fname[1] == '\0':
|
||||
is_dot = 1
|
||||
elif fname[1] == '.' and fname[2] == '\0':
|
||||
is_dot = 1
|
||||
if is_dot == 0:
|
||||
# 构建子目录路径并递归扫描
|
||||
sub_dir: str = Utils.JoinPath(base_dir, fname)
|
||||
if sub_dir is not None:
|
||||
sub_dir_len: sizet = string.strlen(sub_dir)
|
||||
out_count = _collect_stub_sha1s(sub_dir, sub_dir_len, level - 1, out_arr, out_count, max_count)
|
||||
stdlib.free(sub_dir)
|
||||
if win32file.FindNextFileA(handle, find_data) == 0:
|
||||
break
|
||||
win32file.FindClose(handle)
|
||||
|
||||
stdlib.free(find_data)
|
||||
return out_count
|
||||
# ============================================================
|
||||
# _load_includes_sha1_set - 从全局内存存储器收集 includes 的 SHA1
|
||||
#
|
||||
|
||||
Reference in new issue
Block a user