diff --git a/App/lib/core/Gen/StructGenMixin.vp b/App/lib/core/Gen/StructGenMixin.vp index d76d16e..c90cc08 100644 --- a/App/lib/core/Gen/StructGenMixin.vp +++ b/App/lib/core/Gen/StructGenMixin.vp @@ -710,9 +710,31 @@ class StructGenMixin: # 第二遍: 名称回退(is 未匹配到) ty_name: str = self._extract_struct_name(struct_ty) if ty_name is not None: + # 加强 SHA1 命名空间隔离:类型名形如 "3d4afd9cdffeba6d.Thread", + # 提取 16 位 hex 前缀后精确匹配 entry.ModuleSha1,禁止 strstr 裸名 + # 跨模块抓同名类(sched.Thread 被 includes/vthreading.vp 同名 + # Thread 顶掉根因:strstr("sha1.Thread", "Thread") 命中 vthreading + # 的 entry → 其 arg@3 被当成 sched.Thread.arg(应 4)→ th.func + # 被 th.arg=None 覆盖 → _thread_entry call 0 → #UD/#GP)。 + ty_sha1_lf: str = None + dot_ty_lf: str = string.strchr(ty_name, '.') + if dot_ty_lf is not None: + pre_len_lf: t.CSizeT = t.CSizeT( + t.CUInt64T(dot_ty_lf) - t.CUInt64T(ty_name)) + if pre_len_lf == 16: + sha_buf_lf: str = pool.alloc(17) + if sha_buf_lf is not None: + string.strncpy(sha_buf_lf, ty_name, 16) + sha_buf_lf[16] = '\0' + ty_sha1_lf = sha_buf_lf for i in range(self.StructCount): entry: GenTypes.StructEntry | t.CPtr = self._get_struct_entry(i) if entry is not None and entry.Name is not None: + # 提取到类型 SHA1:必须与 entry.ModuleSha1 精确一致,否则跳过 + if ty_sha1_lf is not None: + if entry.ModuleSha1 is None \ + or string.strcmp(entry.ModuleSha1, ty_sha1_lf) != 0: + continue matched: int = 0 if string.strcmp(entry.Name, ty_name) == 0: matched = 1