From 46170c20ef5eeeaaf69a9a3a9c1be45e2dfa029d Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 19 Aug 2026 05:06:08 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20ExprGenCls/Fstr=20=E8=A1=A5?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=20DOC/FSTR=20=E5=B8=B8=E9=87=8F=E5=89=AF?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ExprGenMixin 拆分后 DOC/FSTR 系列常量只定义在 ExprGenMixin.vp(M),而 ExprGenCls(C)/ExprGenFstr(F) 按文件序先于 M 编译,跨模块 CDefine 全局表未注册 → NameError 未定义名称。按 CallGen 既有本地副本惯例补定义,消除文件序依赖。 --- App/lib/core/Gen/ExprGenCls.vp | 10 ++++++++++ App/lib/core/Gen/ExprGenFstr.vp | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/App/lib/core/Gen/ExprGenCls.vp b/App/lib/core/Gen/ExprGenCls.vp index b137358..da8c255 100644 --- a/App/lib/core/Gen/ExprGenCls.vp +++ b/App/lib/core/Gen/ExprGenCls.vp @@ -31,6 +31,16 @@ import lib.core.Gen.ExprGenBase as ExprGenBase import lib.core.StubMergerStore as StubMergerStore import lib.core.Handles.ExprCallBase as ExprCallBase +# ============================================================ +# docstring 登记表容量常量(与 ExprGenMixin 保持一致,本地副本避免 +# 跨模块 CDefine 查找 bug:ExprGenCls(C) 在 ExprGenMixin(M) 之前按 +# 文件序编译时,跨模块 CDefine 全局表未注册 → NameError 未定义) +# ============================================================ +DOC_MAX: t.CDefine = 512 +DOC_KEY_SZ: t.CDefine = 192 +DOC_VAL_SZ: t.CDefine = 4096 + + # ============================================================ # ExprGenCls - ExprGenMixin 拆分(阶段 D):类名推断/docstring 登记 # diff --git a/App/lib/core/Gen/ExprGenFstr.vp b/App/lib/core/Gen/ExprGenFstr.vp index 7da0874..8ad9520 100644 --- a/App/lib/core/Gen/ExprGenFstr.vp +++ b/App/lib/core/Gen/ExprGenFstr.vp @@ -29,6 +29,15 @@ import lib.Projectrans.Utils as Utils import lib.core.Gen.ExprGenBase as ExprGenBase +# ============================================================ +# f-string 翻译常量(与 ExprGenMixin 保持一致,本地副本避免跨模块 +# CDefine 查找 bug:ExprGenFstr(F) 在 ExprGenMixin(M) 之前按文件序 +# 编译时,跨模块 CDefine 全局表未注册 → NameError 未定义) +# ============================================================ +FSTR_BUF_SIZE: t.CDefine = 1024 +FSTR_SPEC_MAX: t.CDefine = 64 +FSTR_FMT_MAX: t.CDefine = 64 + # ============================================================ # ExprGenFstr - ExprGenMixin 拆分(阶段 D):f-string/格式化值翻译 #