diff --git a/App/lib/core/Gen/Type/TypeGenCType.vp b/App/lib/core/Gen/Type/TypeGenCType.vp index 97055a9..247c2af 100644 --- a/App/lib/core/Gen/Type/TypeGenCType.vp +++ b/App/lib/core/Gen/Type/TypeGenCType.vp @@ -52,6 +52,25 @@ def _ctypedef_idx_hash(name: str) -> uint64: class TypeGenCType(TypeGenBase.TypeGenBase): """CTypedef 表(register/lookup/ScanCTypedefDeclarations/_eval_const_int_expr)""" + # ============================================================ + # 字段必须在**类体**声明(跨模块可见性要求,不是风格问题) + # + # 缘由:`.vpi`(声明存根)只携带**类体 AnnAssign 字段**与 `__init__` 里**带注解**的 + # `self.x: T = ...`;而方法体里的裸 `self.x = ...` 只被**定义模块自己**的成员收集 + # (HandlesClassDef 的 self.x 扫描)收录 ⇒ 同一字段"定义模块的成员表里有、引用模块的 + # 没有",且两侧 struct 布局不同源。 + # 现场:`GenApi._g_gen.TypeGenCType.CTypedefNames`(Repl.vp:802)在引用模块里属性链 + # 求值为空 → 带注解赋值被判定"无值可存"而终止编译(该字段原仅由 `self.CTypedefNames = + # tn` 赋值,.vpi 与跨模块成员表里都没有它)。 + # 判据:凡会被**别的模块**读到的字段,一律在类体写注解;只在类内使用的临时状态才允许 + # 只写 `self.x = ...`。 + # ============================================================ + CTypedefNames: list[str] | t.CPtr + CTypedefTypeStrs: list[str] | t.CPtr + CTypedefNameIdx: sizet* + CTypedefNameIdxCap: int + CTypedefNameIdxBuilt: int + # ============================================================ # CTypedef 名索引(开放寻址;槽存 index+1,0=空槽) # ============================================================