From 0a84ca8db38f1d65ed87b04a7c36ca2b33a0c3f8 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 29 Aug 2026 08:42:26 +0800 Subject: [PATCH] =?UTF-8?q?debug(tpv):=20=E4=B8=B4=E6=97=B6=E8=AF=8A?= =?UTF-8?q?=E6=96=AD=E5=AE=9A=E4=BD=8D=20SECURITY=5FATTRIBUTES=20=E7=A9=BA?= =?UTF-8?q?=E7=B1=BB=E6=B3=A8=E5=86=8C=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - register_struct/add_field 打印 [DBG-EMP](SECURITY_ATTRIBUTES 过滤) - ClassGenDef 空类报错改为 pending + 打印(定位期间不中断编译) - 定位后移除 --- App/lib/core/Gen/Class/ClassGenDef.vp | 12 +++++++----- App/lib/core/Gen/StructGenMixin.vp | 9 +++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/App/lib/core/Gen/Class/ClassGenDef.vp b/App/lib/core/Gen/Class/ClassGenDef.vp index 0041c5b..7c24169 100644 --- a/App/lib/core/Gen/Class/ClassGenDef.vp +++ b/App/lib/core/Gen/Class/ClassGenDef.vp @@ -85,11 +85,13 @@ class ClassGenDef(ClassGenBase.ClassGenBase): # 仅当"类体声明了字段但 FieldCount==0"才算注册不完整(Phase A-pre 漏注册)。 if existing.FieldCount == 0 and trans._declare_only == 0: if self.Gen.ClassGenBase._class_body_has_field(cd) != 0: - # Phase B 时字段数为 0 说明注册不完整(Phase A-pre 可能漏注册) - self.Gen.TypeGenErr.fatal_error( - node, - f"结构体已注册但字段数为0,类: {class_name},可能注册不完整", - "InternalCompilerError") + # [DBG-EMP] 临时诊断:定位空类注册来源(win32base SECURITY_ATTRIBUTES)。 + # 报错期间改为 pending 延迟(不 fatal 中断多遍收敛),配合 + # register_struct/add_field 的 [DBG-EMP] 打印定位谁注册了空类。 + VLogger.info(f"[DBG-EMP] class={class_name} FC=0 ty={t.CUInt64T(existing.Ty)} 类体有字段", "DBG") + if trans is not None: + trans._deps_pending = 1 + return 0 # 结构体已注册(Phase A-pre 多遍扫描或 Phase B 重新翻译),但仍需在当前模块中翻译方法 if existing.Ty is not None: # Phase 1b(declare_only=0):existing.Ty 是 Phase 1a 注册的 struct_ty, diff --git a/App/lib/core/Gen/StructGenMixin.vp b/App/lib/core/Gen/StructGenMixin.vp index 55ac563..f4aca57 100644 --- a/App/lib/core/Gen/StructGenMixin.vp +++ b/App/lib/core/Gen/StructGenMixin.vp @@ -221,6 +221,12 @@ class StructGenMixin: entry.Ty = struct_ty entry.FieldCount = 0 + # [DBG-EMP] 临时诊断:定位空类注册来源(win32base SECURITY_ATTRIBUTES) + if name is not None and string.strstr(name, "SECURITY_ATTRIBUTES") is not None: + sha1_s: str = "?" + if sha1 is not None: + sha1_s = sha1 + VLogger.info(f"[DBG-REG] {name} sha1={sha1_s} Ty={t.CUInt64T(struct_ty)}", "DBG") # 注册时直接设置 SHA1(避免 set_struct_sha1 跨模块同名时找错 entry) # SHA1 同样按 StdlibAlloc 选分配源(跨 1a/1b 存活,防 strcmp 悬空) @@ -351,6 +357,9 @@ class StructGenMixin: return -1 idx: int = struct_entry.FieldCount + # [DBG-EMP] 临时诊断:定位空类字段添加(win32base SECURITY_ATTRIBUTES) + if struct_entry.Name is not None and string.strstr(struct_entry.Name, "SECURITY_ATTRIBUTES") is not None: + VLogger.info(f"[DBG-ADDF] {struct_entry.Name} field={field_name} idx={idx}", "DBG") fe: GenTypes.FieldEntry | t.CPtr = self._get_field_entry(struct_entry, idx) if fe is None: return -1