refactor(gen): P2-2 StructGenMixin - HandlesStruct 53 函数迁移 + 委托层
HandlesStruct 全局注册表/可见性状态迁入 StructGenMixin 字段, 53 个结构体注册/查找/字段函数迁移为方法(register_struct/find_struct/ lookup_field/get_mro_chain 等);旧函数保留为本地 _g_gen 单例委托。 Generator 多继承追加 StructGenMixin(现为 3 Mixin 组合)。
This commit is contained in:
1 parent
e1ef67d013
commit
34a37358c9
5 files changed
+1428
-1125
No files matched your search
@@ -142,9 +142,10 @@ def TranslateFileGetTrans(mb: memhub.MemBuddy | t.CPtr, file_path: str,
|
||||
gen.__before_init__()
|
||||
gen.__init__(mb)
|
||||
GenGenerator.set_global_gen(gen)
|
||||
# P2: 注入 HandlesType 模块级单例(委托函数经本地 _g_gen 访问,
|
||||
# P2: 注入 HandlesType/HandlesStruct 模块级单例(委托函数经本地 _g_gen 访问,
|
||||
# 避免函数体 import 包模块与 Generator 类/模块名歧义)
|
||||
HandlesType.set_global_gen(gen)
|
||||
HandlesStruct.set_global_gen(gen)
|
||||
# 设置当前文件名(供报错使用)
|
||||
HandlesType.set_current_file(file_path)
|
||||
# 同步到 HandlesImports(import 时 SHA1 检查报错需要当前文件名,循环依赖无法直接读 HandlesType)
|
||||
|
||||
@@ -4,6 +4,7 @@ import memhub
|
||||
import llvmlite
|
||||
import lib.core.Gen.BaseGenMixin as BaseGenMixin
|
||||
import lib.core.Gen.TypeGenMixin as TypeGenMixin
|
||||
import lib.core.Gen.StructGenMixin as StructGenMixin
|
||||
import lib.core.Handles.HandlesVar as HandlesVar
|
||||
import lib.core.Handles.HandlesExprCall as HandlesExprCall
|
||||
|
||||
@@ -21,7 +22,8 @@ import lib.core.Handles.HandlesExprCall as HandlesExprCall
|
||||
# 全部内联,不调用父类 Init* 方法。
|
||||
# ============================================================
|
||||
@t.NoVTable
|
||||
class Generator(BaseGenMixin.BaseGenMixin, TypeGenMixin.TypeGenMixin):
|
||||
class Generator(BaseGenMixin.BaseGenMixin, TypeGenMixin.TypeGenMixin,
|
||||
StructGenMixin.StructGenMixin):
|
||||
"""生成器:多继承 Mixin 组合(对象化迁移宿主)"""
|
||||
|
||||
def __init__(self, pool: memhub.MemBuddy | t.CPtr):
|
||||
@@ -59,6 +61,12 @@ class Generator(BaseGenMixin.BaseGenMixin, TypeGenMixin.TypeGenMixin):
|
||||
self.CTypedefVisiting = None
|
||||
self.CurrentFile = None
|
||||
self.ConstEvalOk = 0
|
||||
# ---- StructGenMixin 字段 ----
|
||||
self.StructTable = None
|
||||
self.StructCount = 0
|
||||
self.StdlibAlloc = 0
|
||||
self.VisibleStructs = None
|
||||
self.StrictVisibility = 0
|
||||
|
||||
|
||||
# ============================================================
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+378
-1122
File diff suppressed because it is too large.
Load diff
+2
-1
@@ -87,8 +87,9 @@ def main() -> int:
|
||||
gen.__before_init__()
|
||||
gen.__init__(mb)
|
||||
GenGenerator.set_global_gen(gen)
|
||||
# P2: 注入 HandlesType 模块级单例(Phase1 阶段即调用 HandlesType 状态函数)
|
||||
# P2: 注入 HandlesType/HandlesStruct 模块级单例(Phase1 阶段即调用其状态函数)
|
||||
HandlesType.set_global_gen(gen)
|
||||
HandlesStruct.set_global_gen(gen)
|
||||
|
||||
# 初始化 VLogger 并打印启动日志
|
||||
log: VLogger.Logger | t.CPtr = VLogger.get_logger()
|
||||
|
||||
Reference in new issue
Block a user