From 07e1efeb8263dc53057ae9ec9388748f10621085 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 13 Aug 2026 06:54:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20=E7=A7=BB=E9=99=A4=20vtable=20?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E8=AF=8A=E6=96=AD=E4=BB=A3=E7=A0=81=E5=B9=B6?= =?UTF-8?q?=E6=89=A9=E5=AE=B9=20MAX=5FFUNCS=20256=E2=86=921024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1) 移除 _generate_vtable 中临时诊断块(含 self.find_func_global 调用), 该调用被当成 ClassGenMixin 类方法 mangling 导致 bootstrap 链接失败 (undefined symbol: ClassGenMixin.find_func_global)。 2) MAX_FUNCS 256→1024:VpiReader 注入依赖 declare(~102)+ 大模块方法 (stmts 162 个)累积使函数表恰好溢出,ImportFrom.dump 等第 257 个 注册静默失败 → vtable 缺实现误杀。同步 7 处(HandlesTranslator/ TranslatorGenMixin 常量 + ClassGenMixin/FuncGenMixin/VpiReader 硬编码)。 --- App/lib/StubGen/VpiReader.vp | 2 +- App/lib/core/Gen/ClassGenMixin.vp | 4 ++-- App/lib/core/Gen/FuncGenMixin.vp | 4 ++-- App/lib/core/Gen/TranslatorGenMixin.vp | 2 +- App/lib/core/Handles/HandlesTranslator.vp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/App/lib/StubGen/VpiReader.vp b/App/lib/StubGen/VpiReader.vp index 5bdceb4..6a6bfbc 100644 --- a/App/lib/StubGen/VpiReader.vp +++ b/App/lib/StubGen/VpiReader.vp @@ -896,7 +896,7 @@ def _ParseVpiIntoModuleImpl(pool: memhub.MemBuddy | t.CPtr, # 函数表信息 funcs_ptr: HandlesExprCall.FuncEntry | t.CPtr = trans._funcs - max_funcs: int = 256 + max_funcs: int = 1024 i: t.CSizeT for i in range(n): diff --git a/App/lib/core/Gen/ClassGenMixin.vp b/App/lib/core/Gen/ClassGenMixin.vp index 9037bce..9269db0 100644 --- a/App/lib/core/Gen/ClassGenMixin.vp +++ b/App/lib/core/Gen/ClassGenMixin.vp @@ -3497,7 +3497,7 @@ class ClassGenMixin: md_default_count = len(md_dlist) # 注册到函数表(用 ClassName.method_name 作为查找名,支持后缀匹配) - max_funcs: int = 256 + max_funcs: int = 1024 if HandlesExprCall.add_func_to_table(funcs_ptr, func_count, full_name, func, max_funcs, md_defaults, md_default_count, md_param_count, pool) == 0: @@ -3765,7 +3765,7 @@ class ClassGenMixin: return 0 # 注册到函数表 - max_funcs: int = 256 + max_funcs: int = 1024 rc_add: int = HandlesExprCall.add_func_to_table(funcs_ptr, func_count, full_name, func, max_funcs, None, 0, 0, pool) if rc_add == 0: trans._func_count = func_count + 1 diff --git a/App/lib/core/Gen/FuncGenMixin.vp b/App/lib/core/Gen/FuncGenMixin.vp index 7f7a423..77fa486 100644 --- a/App/lib/core/Gen/FuncGenMixin.vp +++ b/App/lib/core/Gen/FuncGenMixin.vp @@ -415,7 +415,7 @@ class FuncGenMixin: fd_default_count = len(fd_dlist) # 注册到函数表(用裸名 fd.name,不是 mangled_name) - max_funcs: int = 256 + max_funcs: int = 1024 cur_count: int = trans._func_count if HandlesExprCall.add_func_to_table(funcs_ptr, cur_count, fd.name, func, max_funcs, fd_defaults, fd_default_count, fd_param_count, @@ -663,7 +663,7 @@ class FuncGenMixin: tfd_default_count = len(tfd_dlist) # 注册到函数表 - max_funcs: int = 256 + max_funcs: int = 1024 if HandlesExprCall.add_func_to_table(funcs_ptr, func_count, fd.name, func, max_funcs, tfd_defaults, tfd_default_count, tfd_param_count, trans.Pool) == 0: diff --git a/App/lib/core/Gen/TranslatorGenMixin.vp b/App/lib/core/Gen/TranslatorGenMixin.vp index d92d565..a08a267 100644 --- a/App/lib/core/Gen/TranslatorGenMixin.vp +++ b/App/lib/core/Gen/TranslatorGenMixin.vp @@ -45,7 +45,7 @@ import lib.core.Handles.HandlesAnnAssign as HandlesAnnAssign # 常量(与 HandlesTranslator 保持一致) # ============================================================ MAX_VARS: t.CDefine = 256 -MAX_FUNCS: t.CDefine = 256 +MAX_FUNCS: t.CDefine = 1024 MAX_GLOBAL_NAMES: t.CDefine = 32 diff --git a/App/lib/core/Handles/HandlesTranslator.vp b/App/lib/core/Handles/HandlesTranslator.vp index ae9cb0f..cb54e9d 100644 --- a/App/lib/core/Handles/HandlesTranslator.vp +++ b/App/lib/core/Handles/HandlesTranslator.vp @@ -48,7 +48,7 @@ import lib.Projectrans.Config as Config # 常量 MAX_VARS: t.CDefine = 256 -MAX_FUNCS: t.CDefine = 256 +MAX_FUNCS: t.CDefine = 1024 MAX_GLOBAL_NAMES: t.CDefine = 32