From 54462320d2158f3fd130c25e0736d054e1e4d7f8 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Fri, 28 Aug 2026 04:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=EF=BC=8C=E6=9C=80=E5=90=8E=E4=BB=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=20fb=20=E7=BC=93=E5=86=B2=E5=8C=BA=E7=9A=84=E7=89=88?= =?UTF-8?q?=E6=9C=AC=EF=BC=88=E6=96=B0=E7=89=88=E6=9C=AC=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20=E6=A0=88f-string=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/Phase/Phase1/Phase1Main.vp | 5 +- App/lib/Phase/Phase1/Phase1Scan.vp | 2 +- App/lib/Phase/Phase1/__init__.vp | 22 ---- App/lib/Phase/Phase2/__init__.vp | 4 +- App/lib/Stub/StubGen/VpiReader.vp | 2 +- App/lib/core/CompilerFactory.vp | 29 +----- App/lib/core/Gen/AssignGenMixin.vp | 148 +++++++++------------------ App/lib/core/Gen/BaseGenMixin.vp | 9 -- App/lib/core/Gen/CallGenBase.vp | 10 +- App/lib/core/Gen/CallGenDispatch.vp | 17 --- App/lib/core/Gen/CallGenLeafKit.vp | 26 ++--- App/lib/core/Gen/ClassGenBase.vp | 20 ++-- App/lib/core/Gen/ClassGenDef.vp | 10 +- App/lib/core/Gen/ClassGenEnum.vp | 24 ++--- App/lib/core/Gen/ClassGenGeneric.vp | 16 +-- App/lib/core/Gen/ClassGenVTable.vp | 14 +-- App/lib/core/Gen/ExprGenCls.vp | 8 +- App/lib/core/Gen/Generator.vp | 94 ++++++++--------- App/lib/core/Gen/StmtGenDeclMixin.vp | 10 +- App/lib/core/Gen/StructGenMixin.vp | 31 +----- App/lib/core/Gen/TypeGenBase.vp | 2 +- App/lib/core/Gen/TypeGenCDef.vp | 2 +- App/lib/core/Gen/__init__.vp | 2 +- App/main.vp | 9 +- 24 files changed, 175 insertions(+), 341 deletions(-) diff --git a/App/lib/Phase/Phase1/Phase1Main.vp b/App/lib/Phase/Phase1/Phase1Main.vp index e070821..612d295 100644 --- a/App/lib/Phase/Phase1/Phase1Main.vp +++ b/App/lib/Phase/Phase1/Phase1Main.vp @@ -5,7 +5,6 @@ import stdlib import memhub import viperlib import w32.fileio as fileio -import w32.win32file import w32.win32base import ast import llvmlite @@ -79,9 +78,7 @@ def RunPhase1(mb: memhub.MemBuddy | t.CPtr, includes_dir: str, temp_dir: str, result: IncludesScanner.ScanResult | t.CPtr = IncludesScanner.scan_includes(mb, includes_dir) t_scan1: t.CUInt64T = w32.win32base.GetTickCount64() fb: str = VLogger.fmtbuffer - viperlib.snprintf(fb, 1024, - "扫描 includes 总耗时: %llu ms (%d 文件, 含 SHA1 计算)", - t_scan1 - t_scan0, result.Count if result is not None else 0) + viperlib.snprintf(fb, 1024, "扫描 includes 总耗时: %llu ms (%d 文件, 含 SHA1 计算)", t_scan1 - t_scan0, result.Count if result is not None else 0) VLogger.info(fb, "Phase1") if result is None: VLogger.error("扫描失败", "Phase1") diff --git a/App/lib/Phase/Phase1/Phase1Scan.vp b/App/lib/Phase/Phase1/Phase1Scan.vp index 707c72a..8f054ac 100644 --- a/App/lib/Phase/Phase1/Phase1Scan.vp +++ b/App/lib/Phase/Phase1/Phase1Scan.vp @@ -278,7 +278,7 @@ def _PreRegisterAllGenericTemplates(mb: memhub.MemBuddy | t.CPtr, """预注册全部 includes 文件的泛型类模板,返回处理到的泛型类数量""" if result is None or mb is None: return 0 - perm: memhub.MemBuddy | t.CPtr = CompilerFactory.get_perm_pool() + perm: memhub.MemBuddy | t.CPtr = CompilerFactory.factory.PermPool if perm is None: return 0 p1e_size: t.CSizeT = IncludesScanner.FileEntry.__sizeof__() diff --git a/App/lib/Phase/Phase1/__init__.vp b/App/lib/Phase/Phase1/__init__.vp index 9389798..65969e5 100644 --- a/App/lib/Phase/Phase1/__init__.vp +++ b/App/lib/Phase/Phase1/__init__.vp @@ -1,28 +1,6 @@ import t, c from stdint import * -import string -import stdlib import memhub -import viperlib -import w32.fileio as fileio -import w32.win32file -import w32.win32base -import ast -import llvmlite -import lib.core.VLogger as VLogger -import lib.core.Handles.HandlesTranslator as HandlesTranslator -import lib.core.Handles.HandlesExprCall as HandlesExprCall -import lib.core.IncludesScanner as IncludesScanner -import lib.Stub.StubMerger as StubMerger -import lib.core.Gen.Generator as GenGenerator -import lib.core.CompilerFactory as CompilerFactory -import lib.Phase.BuildPipeline as BuildPipeline -import lib.Projectrans.Config as Config -import lib.Stub.StubGen.Converter as StubConverter -import lib.Stub.StubMerger.StubMergerBuild as StubMergerBuild -import lib.Stub.StubMerger.StubMergerCollect as StubMergerCollect -import lib.Stub.StubMerger.StubMergerIR as StubMergerIR -import lib.Stub.StubMerger.StubMergerStore as StubMergerStore # 全局 mbuddy 指针 _mbuddy: memhub.MemBuddy | t.CPtr diff --git a/App/lib/Phase/Phase2/__init__.vp b/App/lib/Phase/Phase2/__init__.vp index 83ede30..b15ba01 100644 --- a/App/lib/Phase/Phase2/__init__.vp +++ b/App/lib/Phase/Phase2/__init__.vp @@ -38,7 +38,7 @@ SRC_BUF_SIZE: t.CDefine = 1048576 # 最大源文件数(递归扫描子目录后文件数增多:App 现有 65 个 .vp, # 2026-08-14 CompilerFactory.vp 加入后超出 64 被截断 → 链接 undefined symbol -# CompilerFactory.get_perm_pool。增大到 128 留余量) +# CompilerFactory.factory.PermPool。增大到 128 留余量) MAX_SRC_FILES: t.CDefine = 128 @t.NoVTable @@ -308,7 +308,7 @@ def _PreRegisterAppGenericTemplates(mb: memhub.MemBuddy | t.CPtr, else: src_buf_pa[SRC_BUF_SIZE - 1] = 0 # 解析 AST(只解析,不完整翻译;用永久池使模板节点跨 mark2 reset 存活) - perm_pa: memhub.MemBuddy | t.CPtr = CompilerFactory.get_perm_pool() + perm_pa: memhub.MemBuddy | t.CPtr = CompilerFactory.factory.PermPool if perm_pa is None: perm_pa = mb lx_pa: ast.Lexer | t.CPtr = ast.new_lexer(perm_pa) diff --git a/App/lib/Stub/StubGen/VpiReader.vp b/App/lib/Stub/StubGen/VpiReader.vp index cfcde75..4853eac 100644 --- a/App/lib/Stub/StubGen/VpiReader.vp +++ b/App/lib/Stub/StubGen/VpiReader.vp @@ -1597,7 +1597,7 @@ def _inject_class_struct_declare(pool: memhub.MemBuddy | t.CPtr, # (对齐 ClassGenDef.translate_class_def L489-494) if GenApi.get_stdlib_alloc() != 0: st_copy_c: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), struct_ty_c) + CompilerFactory.factory.PermPool, struct_ty_c) if st_copy_c is not None: struct_ty_c = st_copy_c # 6. 注册到当前模块(输出类型定义行)+ 全局 StructTable + 可见性 diff --git a/App/lib/core/CompilerFactory.vp b/App/lib/core/CompilerFactory.vp index af03dbf..fbf9d3a 100644 --- a/App/lib/core/CompilerFactory.vp +++ b/App/lib/core/CompilerFactory.vp @@ -13,7 +13,7 @@ import memhub # - Pool :主内存池(MemBuddy,瞬时数据,受 mark/reset_to 回收) # - PermPool :永久内存池(MemBuddy,跨 mark 持久数据专用,从不 reset) # -# 各模块经模块级委托 CompilerFactory.get_perm_pool() 获取永久池, +# 各模块经模块级委托 CompilerFactory.PermPool 获取永久池, # 避免把编译器专属单例塞进通用内存库 memhub(memhub 保持通用)。 # includes 层(llvmlite/__types.vp 的 DeepCopyType)不依赖本工厂: # 深拷贝的分配源由调用方以 pool 参数传入(传 PermPool 即持久)。 @@ -40,29 +40,4 @@ class CompilerFactory: # ============================================================ # 全局工厂单例 # ============================================================ -_g_factory: CompilerFactory | t.CPtr = None - - -def set_factory(factory: CompilerFactory | t.CPtr) -> None: - """注册全局工厂单例(main 创建后注册)""" - global _g_factory - _g_factory = factory - - -def get_factory() -> CompilerFactory | t.CPtr: - """获取全局工厂单例(未注册返回 None)""" - return _g_factory - - -def get_pool() -> memhub.MemBuddy | t.CPtr: - """获取主内存池(瞬时数据分配源)""" - if _g_factory is not None: - return _g_factory.Pool - return None - - -def get_perm_pool() -> memhub.MemBuddy | t.CPtr: - """获取永久内存池(跨 mark 持久数据分配源)""" - if _g_factory is not None: - return _g_factory.PermPool - return None +factory: CompilerFactory | t.CPtr = None diff --git a/App/lib/core/Gen/AssignGenMixin.vp b/App/lib/core/Gen/AssignGenMixin.vp index 84c24eb..dc6b52f 100644 --- a/App/lib/core/Gen/AssignGenMixin.vp +++ b/App/lib/core/Gen/AssignGenMixin.vp @@ -12,31 +12,13 @@ import lib.core.VLogger as VLogger import lib.core.Handles.HandlesTranslator as HT import lib.core.Handles.HandlesExpr as HandlesExpr import lib.Stub.StubMerger.StubMergerStore as StubMergerStore - import lib.core.Gen.GenTypes as GenTypes import lib.core.Gen.Generator as Generator -import lib.core.Gen.TypeGenCType as TypeGenCType -import lib.core.Gen.ExprGenAttr as ExprGenAttr -import lib.core.Gen.CallGenBase as CallGenBase -import lib.core.Gen.CallGenFd as CallGenFd -import lib.core.Gen.CallGenVt as CallGenVt - import lib.Stub.StubGen.VpiReader as VpiReader # ============================================================ # AssignGenMixin - 赋值翻译 Mixin(P6 方法化) # -# 从 HandlesAssign/HandlesAnnAssign/HandlesAugAssign 迁移: -# 模块级无状态函数(trans/pool 首参)→ 类方法;全局状态 -# (HandlesAnnAssign._g_recover_found)→ 本类字段 RecoverFound。 -# -# 迁移原则(与 P1-P5 一致,行为零变化): -# 1. 方法保留原函数签名(含 trans/pool 首参),仅函数体内的 -# 本模块函数调用改为 self.xxx(...) -# 2. 外部模块调用(HandlesType.xxx/HandlesExpr.xxx 等)保留模块前缀 -# 3. 原 Handles 模块函数保留为"委托":本地模块级单例 _g_gen -# (BuildPipeline/main 注入)cast 成 Generator 类型 -# # @t.NoVTable:静态绑定(方法沿 MRO 直接调用 + this 调整)。 # ============================================================ @@ -46,11 +28,10 @@ class AssignGenMixin: Gen: Generator.Generator | t.CPtr """赋值翻译 Mixin(P6 方法化)""" - # --- 原 HandlesAnnAssign._g_recover_found 模块级全局(迁移为实例字段) --- RecoverFound: int # ============================================================ - # is_cdefine_annotation - 检测注解是否为 t.CDefine(模块级函数) + # 检测注解是否为 t.CDefine(模块级函数) # # 支持两种形式: # 1. Attribute(Name('t'), 'CDefine') @@ -58,8 +39,7 @@ class AssignGenMixin: # ============================================================ def is_cdefine_annotation(self, annot: ast.AST | t.CPtr) -> int: """检测注解是否为 t.CDefine,返回 1 表示是,0 表示否""" - if annot is None: - return 0 + if annot is None: return 0 k: int = annot.kind() if k == ast.ASTKind.Attribute: at: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(annot) @@ -68,7 +48,7 @@ class AssignGenMixin: return 0 if k == ast.ASTKind.BinOp: bop: ast.BinOp | t.CPtr = (ast.BinOp | t.CPtr)(annot) - if self.is_cdefine_annotation(bop.left) != 0: + if self.is_cdefine_annotation(bop.left) != 0: return 1 if self.is_cdefine_annotation(bop.right) != 0: return 1 @@ -109,31 +89,19 @@ class AssignGenMixin: # Case 2: BinOp — 如 FOREGROUND_RED | FOREGROUND_GREEN、(1 << ZDEFLATE_WINDOW_BITS) if k == ast.ASTKind.BinOp: bop: ast.BinOp | t.CPtr = (ast.BinOp | t.CPtr)(val_node) - left_val: t.CInt64T = self.extract_cdefine_int_value(bop.left) + left_val: t.CInt64T = self.extract_cdefine_int_value(bop.left) right_val: t.CInt64T = self.extract_cdefine_int_value(bop.right) - if bop.op == ast.OpKind.BitOr: - return left_val | right_val - if bop.op == ast.OpKind.BitAnd: - return left_val & right_val - if bop.op == ast.OpKind.BitXor: - return left_val ^ right_val - if bop.op == ast.OpKind.LShift: - return left_val << right_val - if bop.op == ast.OpKind.RShift: - return left_val >> right_val - if bop.op == ast.OpKind.Add: - return left_val + right_val - if bop.op == ast.OpKind.Sub: - return left_val - right_val - if bop.op == ast.OpKind.Mult: - return left_val * right_val - if bop.op == ast.OpKind.Div: - # 整数常量除法:与 FloorDiv 一致(对齐 TPC ConstEvaluator L354-355) - return left_val // right_val - if bop.op == ast.OpKind.FloorDiv: - return left_val // right_val - if bop.op == ast.OpKind.Mod: - return left_val % right_val + if bop.op == ast.OpKind.BitOr: return left_val | right_val + if bop.op == ast.OpKind.BitAnd: return left_val & right_val + if bop.op == ast.OpKind.BitXor: return left_val ^ right_val + if bop.op == ast.OpKind.LShift: return left_val << right_val + if bop.op == ast.OpKind.RShift: return left_val >> right_val + if bop.op == ast.OpKind.Add: return left_val + right_val + if bop.op == ast.OpKind.Sub: return left_val - right_val + if bop.op == ast.OpKind.Mult: return left_val * right_val + if bop.op == ast.OpKind.Div: return left_val // right_val + if bop.op == ast.OpKind.FloorDiv: return left_val // right_val + if bop.op == ast.OpKind.Mod: return left_val % right_val # 未知 BinOp 运算符:直接报错终止(fail-fast) self.Gen.TypeGenErr.fatal_error(val_node, "CDefine 值提取失败:无法从表达式解析编译期常量", "TypeError") @@ -141,7 +109,7 @@ class AssignGenMixin: if k == ast.ASTKind.Name: nm: ast.Name | t.CPtr = (ast.Name | t.CPtr)(val_node) if nm.id is not None: - # True/False 布尔字面量 → 1/0(对齐 TPC:bool 在 CDefine 语境按整数处理) + # True/False 布尔字面量 → 1/0(bool 在 CDefine 语境按整数处理) if string.strcmp(nm.id, "True") == 0: return 1 if string.strcmp(nm.id, "False") == 0: @@ -169,12 +137,9 @@ class AssignGenMixin: if k == ast.ASTKind.UnaryOp: uop: ast.UnaryOp | t.CPtr = (ast.UnaryOp | t.CPtr)(val_node) operand_val: t.CInt64T = self.extract_cdefine_int_value(uop.operand) - if uop.op == ast.OpKind.USub: - return -operand_val - if uop.op == ast.OpKind.UAdd: - return operand_val - if uop.op == ast.OpKind.Invert: - return ~operand_val + if uop.op == ast.OpKind.USub: return -operand_val + if uop.op == ast.OpKind.UAdd: return operand_val + if uop.op == ast.OpKind.Invert: return ~operand_val # 未知 UnaryOp 运算符:直接报错终止(fail-fast) self.Gen.TypeGenErr.fatal_error(val_node, "CDefine 值提取失败:无法从表达式解析编译期常量", "TypeError") @@ -649,16 +614,11 @@ class AssignGenMixin: # 将两个操作数转换为目标浮点类型(int→float via si2fp, float→float via fpext/fptrunc) lhs = self.Gen.ExprGenBase.coerce_to_type(builder, lhs, target_float_ty, node) rhs = self.Gen.ExprGenBase.coerce_to_type(builder, rhs, target_float_ty, node) - if op == ast.OpKind.Add: - return llvmlite.build_fadd(builder, lhs, rhs) - if op == ast.OpKind.Sub: - return llvmlite.build_fsub(builder, lhs, rhs) - if op == ast.OpKind.Mult: - return llvmlite.build_fmul(builder, lhs, rhs) - if op == ast.OpKind.Div: - return llvmlite.build_fdiv(builder, lhs, rhs) - if op == ast.OpKind.Mod: - return llvmlite.build_frem(builder, lhs, rhs) + if op == ast.OpKind.Add: return llvmlite.build_fadd(builder, lhs, rhs) + if op == ast.OpKind.Sub: return llvmlite.build_fsub(builder, lhs, rhs) + if op == ast.OpKind.Mult: return llvmlite.build_fmul(builder, lhs, rhs) + if op == ast.OpKind.Div: return llvmlite.build_fdiv(builder, lhs, rhs) + if op == ast.OpKind.Mod: return llvmlite.build_frem(builder, lhs, rhs) return None # 指针算术: ptr += int / ptr -= int → getelementptr(按元素大小缩放) @@ -674,26 +634,16 @@ class AssignGenMixin: elif rhs_bits > lhs_bits and lhs_bits > 0: lhs = self.Gen.ExprGenBase.coerce_to_type(builder, lhs, rhs.Ty, node) - if op == ast.OpKind.Add: - return llvmlite.build_add(builder, lhs, rhs) - elif op == ast.OpKind.Sub: - return llvmlite.build_sub(builder, lhs, rhs) - elif op == ast.OpKind.Mult: - return llvmlite.build_mul(builder, lhs, rhs) - elif op == ast.OpKind.Div: - return llvmlite.build_sdiv(builder, lhs, rhs) - elif op == ast.OpKind.FloorDiv: - return llvmlite.build_sdiv(builder, lhs, rhs) - elif op == ast.OpKind.Mod: - return llvmlite.build_srem(builder, lhs, rhs) - elif op == ast.OpKind.BitAnd: - return llvmlite.build_and(builder, lhs, rhs) - elif op == ast.OpKind.BitOr: - return llvmlite.build_or(builder, lhs, rhs) - elif op == ast.OpKind.BitXor: - return llvmlite.build_xor(builder, lhs, rhs) - elif op == ast.OpKind.LShift: - return llvmlite.build_shl(builder, lhs, rhs) + if op == ast.OpKind.Add: return llvmlite.build_add(builder, lhs, rhs) + elif op == ast.OpKind.Sub: return llvmlite.build_sub(builder, lhs, rhs) + elif op == ast.OpKind.Mult: return llvmlite.build_mul(builder, lhs, rhs) + elif op == ast.OpKind.Div: return llvmlite.build_sdiv(builder, lhs, rhs) + elif op == ast.OpKind.FloorDiv: return llvmlite.build_sdiv(builder, lhs, rhs) + elif op == ast.OpKind.Mod: return llvmlite.build_srem(builder, lhs, rhs) + elif op == ast.OpKind.BitAnd: return llvmlite.build_and(builder, lhs, rhs) + elif op == ast.OpKind.BitOr: return llvmlite.build_or(builder, lhs, rhs) + elif op == ast.OpKind.BitXor: return llvmlite.build_xor(builder, lhs, rhs) + elif op == ast.OpKind.LShift: return llvmlite.build_shl(builder, lhs, rhs) elif op == ast.OpKind.RShift: # 无符号 >> → lshr(逻辑右移),有符号 >> → ashr(算术右移) # 对齐 TPC ExprGen.emit_binary_op:i8/i16 默认无符号;其余查操作数无符号性 @@ -1867,7 +1817,7 @@ class AssignGenMixin: continue attr_node: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(target) attr_name: str = "(unknown)" - obj_name: str = "(unknown)" + obj_name: str = "(unknown)" if attr_node is not None: attr_name = attr_node.attr if attr_node.value is not None and attr_node.value.kind() == ast.ASTKind.Name: @@ -2173,21 +2123,21 @@ class AssignGenMixin: # ============================================================ def _op_to_dunder(self, op: int) -> str: """BinOp/UnaryOp 运算符 → dunder 方法名,无映射返回 None""" - if op == ast.OpKind.Add: return "__add__" - if op == ast.OpKind.Sub: return "__sub__" - if op == ast.OpKind.Mult: return "__mul__" - if op == ast.OpKind.Div: return "__truediv__" + if op == ast.OpKind.Add: return "__add__" + if op == ast.OpKind.Sub: return "__sub__" + if op == ast.OpKind.Mult: return "__mul__" + if op == ast.OpKind.Div: return "__truediv__" if op == ast.OpKind.FloorDiv: return "__floordiv__" - if op == ast.OpKind.Mod: return "__mod__" - if op == ast.OpKind.Pow: return "__pow__" - if op == ast.OpKind.BitAnd: return "__and__" - if op == ast.OpKind.BitOr: return "__or__" - if op == ast.OpKind.BitXor: return "__xor__" - if op == ast.OpKind.LShift: return "__lshift__" - if op == ast.OpKind.RShift: return "__rshift__" - if op == ast.OpKind.USub: return "__neg__" - if op == ast.OpKind.UAdd: return "__pos__" - if op == ast.OpKind.Invert: return "__invert__" + if op == ast.OpKind.Mod: return "__mod__" + if op == ast.OpKind.Pow: return "__pow__" + if op == ast.OpKind.BitAnd: return "__and__" + if op == ast.OpKind.BitOr: return "__or__" + if op == ast.OpKind.BitXor: return "__xor__" + if op == ast.OpKind.LShift: return "__lshift__" + if op == ast.OpKind.RShift: return "__rshift__" + if op == ast.OpKind.USub: return "__neg__" + if op == ast.OpKind.UAdd: return "__pos__" + if op == ast.OpKind.Invert: return "__invert__" return None # ============================================================ diff --git a/App/lib/core/Gen/BaseGenMixin.vp b/App/lib/core/Gen/BaseGenMixin.vp index 817c698..409b1a9 100644 --- a/App/lib/core/Gen/BaseGenMixin.vp +++ b/App/lib/core/Gen/BaseGenMixin.vp @@ -9,15 +9,6 @@ import lib.core.Handles.HandlesExprCall as HandlesExprCall # ============================================================ # BaseGenMixin - 生成器基座(状态容器) -# -# 对象化重构 P1(方案见 wiki/14-oo-refactor.md): -# 将 Translator/Handles 的共享状态集中于此。后续 Mixin -# (TypeGen/StructGen/ExprGen/CallGen/FuncGen/ClassGen/StmtGen/ -# ImportsGen)单继承本类,逐步把 Handles* 模块的函数迁移为 -# Generator 的方法,消除 (pool, builder, mod, node, ...) 六参连传。 -# -# 注意:@t.NoVTable(静态绑定,骨架无多态需求;若未来需要 -# 运行时多态再改 @t.CVTable,字段布局由编译器统一管理)。 # ============================================================ @t.NoVTable class BaseGenMixin: diff --git a/App/lib/core/Gen/CallGenBase.vp b/App/lib/core/Gen/CallGenBase.vp index 0088120..151fec1 100644 --- a/App/lib/core/Gen/CallGenBase.vp +++ b/App/lib/core/Gen/CallGenBase.vp @@ -26,12 +26,6 @@ import lib.Stub.StubGen.VpiReader as VpiReader # ============================================================ # CallGenBase - CallGenMixin 拆分 1/9(最底层父类):模块符号查找 + # 返回类型解析基础设施 -# -# 按功能域从 CallGenMixin.vp 拆出(500~1500 行/文件架构重构): -# 字段(15 个)+ InitCallGen + 模块符号查找(sha1/cexport/vpi/reexport/find_func_in_module) -# + 返回类型解析链(_ensure_method_declare/_LookupMethodRetTyFromTextLL/_dep_text_ll_exists 等) -# -# @t.NoVTable:静态绑定(方法沿 MRO 直接调用 + this 调整)。 # ============================================================ @@ -310,8 +304,8 @@ class CallGenBase: if self.Gen is None or sha1 is None or func_name is None: return 0 if self.Gen.CallGenBase.CexportSha1Arr is None: - self.Gen.CallGenBase.CexportSha1Arr = CompilerFactory.get_perm_pool().alloc(_CEXPORT_MAX * 17) - self.Gen.CallGenBase.CexportFuncArr = CompilerFactory.get_perm_pool().alloc(_CEXPORT_MAX * 64) + self.Gen.CallGenBase.CexportSha1Arr = CompilerFactory.factory.PermPool.alloc(_CEXPORT_MAX * 17) + self.Gen.CallGenBase.CexportFuncArr = CompilerFactory.factory.PermPool.alloc(_CEXPORT_MAX * 64) if self.Gen.CallGenBase.CexportSha1Arr is None or self.Gen.CallGenBase.CexportFuncArr is None: return 0 string.memset(self.Gen.CallGenBase.CexportSha1Arr, 0, _CEXPORT_MAX * 17) diff --git a/App/lib/core/Gen/CallGenDispatch.vp b/App/lib/core/Gen/CallGenDispatch.vp index 1848ad9..85df4e3 100644 --- a/App/lib/core/Gen/CallGenDispatch.vp +++ b/App/lib/core/Gen/CallGenDispatch.vp @@ -930,29 +930,12 @@ class CallGenDispatch(CallGenBase.CallGenBase): if st_at.value.kind() == ast.ASTKind.Name: st_nm: ast.Name | t.CPtr = (ast.Name | t.CPtr)(st_at.value) if st_nm.id is not None: - # 仅当该名称不是普通变量且是已注册结构体类名时尝试静态/类方法 - # 追加"非导入模块"条件:st_nm.id 是模块名(import X as Y 把别名 - # Y 加入 _imported_modules,HandlesImports L344-347)时,X.Y(...) - # 是模块限定调用(Module.Class 构造 / Module.func 函数),不是 - # ClassName.method(obj,args)。模块名与类名同名时(CompilerFactory. - # CompilerFactory(...) 构造 / .set_factory(...) 函数,main.vp - # 追加84/84b 根因)get_struct_type(st_nm.id) 会误判为类名 → - # 把首实参当 self 传 _call_method_on_ptr → 返回类型查 "X.Y" 永远 - # 落空 → fail-fast。模块限定调用由尾部 ctor 检测(L7441 模块限定 - # 构造)与跨模块函数路径正确路由。 st_var: llvmlite.Value | t.CPtr = self.Gen.VarGen.lookup_var( trans.SymTab, st_nm.id) if st_var is None and self.Gen.StructGen.get_struct_type(st_nm.id) is not None \ and self.Gen.ImportsGen.is_module_imported( trans._imported_modules, st_nm.id) == 0: # REnum 变体构造优先于静态/类方法调用: - # ClassName.VariantName(args)(如 Option.Some(42))若被当 - # "实例方法经类名调用"处理,会把首实参 42 当 self 传 - # _call_method_on_ptr → 查 "Option.Some" 方法返回类型 → - # 跨模块 stub 未命中 → fail-fast(EnumTest "方法 - # 'Option.Some' 返回类型无法确定" 根因)。REnum 变体 - # 构造检测原在 translate_call 尾部(L7493),被本分支 - # 拦截先执行不到,此处提前检测。 if self.Gen.ClassGenEnum._is_renum_class_name(st_nm.id) != 0: rc_tag_sc: int = self.Gen.ClassGenEnum._lookup_renum_variant_in_class( st_nm.id, func_name) diff --git a/App/lib/core/Gen/CallGenLeafKit.vp b/App/lib/core/Gen/CallGenLeafKit.vp index f46c8d2..be1937d 100644 --- a/App/lib/core/Gen/CallGenLeafKit.vp +++ b/App/lib/core/Gen/CallGenLeafKit.vp @@ -591,7 +591,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): """确保闭包名表已分配,0 失败""" if self.ClosureNames is not None: return 1 - self.ClosureNames = CompilerFactory.get_perm_pool().alloc(64 * MAX_CLOSURE_NAMES) + self.ClosureNames = CompilerFactory.factory.PermPool.alloc(64 * MAX_CLOSURE_NAMES) if self.ClosureNames is None: return 0 string.memset(self.ClosureNames, 0, 64 * MAX_CLOSURE_NAMES) @@ -627,8 +627,8 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): """确保函数指针签名表已分配(stdlib.malloc,懒初始化)""" if self.FuncptrNames is not None: return 1 - self.FuncptrNames = CompilerFactory.get_perm_pool().alloc(64 * MAX_FUNC_PTR_SIGS) - self.FuncptrRets = CompilerFactory.get_perm_pool().alloc(8 * MAX_FUNC_PTR_SIGS) + self.FuncptrNames = CompilerFactory.factory.PermPool.alloc(64 * MAX_FUNC_PTR_SIGS) + self.FuncptrRets = CompilerFactory.factory.PermPool.alloc(8 * MAX_FUNC_PTR_SIGS) if self.FuncptrNames is None or self.FuncptrRets is None: return 0 string.memset(self.FuncptrNames, 0, 64 * MAX_FUNC_PTR_SIGS) @@ -650,7 +650,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): # ret_ty 是调用方 pool 分配的裸 LLVMType,1a 每文件 reset 后悬空; # 深拷贝到 perm_pool(lookup_func_ptr_ret 跨文件读取) ret_copy_fp: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), ret_ty) + CompilerFactory.factory.PermPool, ret_ty) if ret_copy_fp is not None: self.FuncptrRets[self.FuncptrCount] = t.CUInt64T(ret_copy_fp) else: @@ -1011,7 +1011,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): if self.GlobalFuncs is not None: return 1 size: t.CSizeT = GLOBAL_FUNC_MAX * GenTypes.FuncEntry.__sizeof__() - self.GlobalFuncs = CompilerFactory.get_perm_pool().alloc(size) + self.GlobalFuncs = CompilerFactory.factory.PermPool.alloc(size) if self.GlobalFuncs is None: return 0 string.memset(self.GlobalFuncs, 0, size) @@ -1058,7 +1058,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): # 深拷贝到 stdlib 区(TypeStr 跨文件永久存活) ts_len: t.CSizeT = string.strlen(ty_buf) - ts_copy: str = CompilerFactory.get_perm_pool().alloc(ts_len + 1) + ts_copy: str = CompilerFactory.factory.PermPool.alloc(ts_len + 1) if ts_copy is None: return None string.strcpy(ts_copy, ty_buf) @@ -1088,7 +1088,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): # Name 深拷贝到 stdlib 区:全局表跨文件永久存活,pool 内名字会被 1b 每文件 # reset_to(mark1) 回收导致悬空(vtable 生成 find_func_global 后 strcmp 崩溃) name_len: t.CSizeT = string.strlen(name) - name_copy: str = CompilerFactory.get_perm_pool().alloc(name_len + 1) + name_copy: str = CompilerFactory.factory.PermPool.alloc(name_len + 1) if name_copy is None: return 1 string.strcpy(name_copy, name) @@ -1144,7 +1144,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): if self.GlobalDefaults is not None: return 1 size: t.CSizeT = GLOBAL_DEFAULTS_MAX * GenTypes.FuncDefaultsEntry.__sizeof__() - self.GlobalDefaults = CompilerFactory.get_perm_pool().alloc(size) + self.GlobalDefaults = CompilerFactory.factory.PermPool.alloc(size) if self.GlobalDefaults is None: return 0 string.memset(self.GlobalDefaults, 0, size) @@ -1175,7 +1175,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): entry: GenTypes.FuncDefaultsEntry | t.CPtr = (GenTypes.FuncDefaultsEntry | t.CPtr)(t.CVoid(entry_addr, t.CPtr)) # Name 深拷贝到 stdlib(全局表跨文件永久存活) nm_len: t.CSizeT = string.strlen(name) - nm_copy: str = CompilerFactory.get_perm_pool().alloc(nm_len + 1) + nm_copy: str = CompilerFactory.factory.PermPool.alloc(nm_len + 1) if nm_copy is None: return 1 string.strcpy(nm_copy, name) @@ -1192,9 +1192,9 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): return 0 # 提取常量快照到 stdlib if default_count > 0: - kinds: t.CInt | t.CPtr = CompilerFactory.get_perm_pool().alloc(default_count * 4) - ints: t.CInt64T | t.CPtr = CompilerFactory.get_perm_pool().alloc(default_count * 8) - strs: t.CSizeT | t.CPtr = CompilerFactory.get_perm_pool().alloc(default_count * 8) + kinds: t.CInt | t.CPtr = CompilerFactory.factory.PermPool.alloc(default_count * 4) + ints: t.CInt64T | t.CPtr = CompilerFactory.factory.PermPool.alloc(default_count * 8) + strs: t.CSizeT | t.CPtr = CompilerFactory.factory.PermPool.alloc(default_count * 8) if kinds is not None and ints is not None and strs is not None: string.memset(kinds, 0, default_count * 4) string.memset(ints, 0, default_count * 8) @@ -1209,7 +1209,7 @@ class CallGenLeafKit(CallGenCBuiltin.CallGenCBuiltin): ints[di] = dcn.int_val if dcn.const_kind == ast.CONST_STR and dcn.str_val is not None: slen: t.CSizeT = string.strlen(dcn.str_val) - scopy: str = CompilerFactory.get_perm_pool().alloc(slen + 1) + scopy: str = CompilerFactory.factory.PermPool.alloc(slen + 1) if scopy is not None: string.strcpy(scopy, dcn.str_val) strs[di] = t.CSizeT(scopy) diff --git a/App/lib/core/Gen/ClassGenBase.vp b/App/lib/core/Gen/ClassGenBase.vp index a749c5f..e660b53 100644 --- a/App/lib/core/Gen/ClassGenBase.vp +++ b/App/lib/core/Gen/ClassGenBase.vp @@ -397,9 +397,9 @@ class ClassGenBase: if pool is None or cls is None or field is None: return -1 if self.ClassMetaKinds is None: - self.ClassMetaKinds = CompilerFactory.get_perm_pool().alloc(CLASS_META_MAX * 4) - self.ClassMetaClss = CompilerFactory.get_perm_pool().alloc(CLASS_META_MAX * 64) - self.ClassMetaFields = CompilerFactory.get_perm_pool().alloc(CLASS_META_MAX * 64) + self.ClassMetaKinds = CompilerFactory.factory.PermPool.alloc(CLASS_META_MAX * 4) + self.ClassMetaClss = CompilerFactory.factory.PermPool.alloc(CLASS_META_MAX * 64) + self.ClassMetaFields = CompilerFactory.factory.PermPool.alloc(CLASS_META_MAX * 64) if self.ClassMetaKinds is None or self.ClassMetaClss is None or self.ClassMetaFields is None: return -1 string.memset(self.ClassMetaKinds, 0, CLASS_META_MAX * 4) @@ -455,11 +455,11 @@ class ClassGenBase: if pool is None or func_name is None or wrapper_name is None: return -1 if self.DecoratorFuncNames is None: - self.DecoratorFuncNames = CompilerFactory.get_perm_pool().alloc( + self.DecoratorFuncNames = CompilerFactory.factory.PermPool.alloc( DECOR_FUNC_MAX * DECOR_NAME_LEN) - self.DecoratorWrapNames = CompilerFactory.get_perm_pool().alloc( + self.DecoratorWrapNames = CompilerFactory.factory.PermPool.alloc( DECOR_FUNC_MAX * DECOR_NAME_LEN) - self.DecoratorArgs = CompilerFactory.get_perm_pool().alloc( + self.DecoratorArgs = CompilerFactory.factory.PermPool.alloc( DECOR_FUNC_MAX * 8) if self.DecoratorFuncNames is None or self.DecoratorWrapNames is None \ or self.DecoratorArgs is None: @@ -505,7 +505,7 @@ class ClassGenBase: """懒初始化异常表(perm_pool),返回 0 成功""" if self.ExceptionNames is not None: return 0 - pp_e: memhub.MemBuddy | t.CPtr = CompilerFactory.get_perm_pool() + pp_e: memhub.MemBuddy | t.CPtr = CompilerFactory.factory.PermPool if pp_e is None: return -1 self.ExceptionNames = pp_e.alloc(EXCEPTION_MAX * EXCEPTION_NAME_LEN) @@ -710,8 +710,8 @@ class ClassGenBase: return # 懒初始化 if self.MethodMetaKeys is None: - self.MethodMetaKeys = CompilerFactory.get_perm_pool().alloc(META_MAX * META_KEY_LEN) - self.MethodMetaFlags = CompilerFactory.get_perm_pool().alloc(META_MAX * 4) + self.MethodMetaKeys = CompilerFactory.factory.PermPool.alloc(META_MAX * META_KEY_LEN) + self.MethodMetaFlags = CompilerFactory.factory.PermPool.alloc(META_MAX * 4) if self.MethodMetaKeys is None or self.MethodMetaFlags is None: return string.memset(self.MethodMetaKeys, 0, META_MAX * META_KEY_LEN) @@ -902,7 +902,7 @@ class ClassGenBase: while orig[og_len] != ' ' and orig[og_len] != '\0': og_len += 1 if og_len > 0: - og_buf: str = CompilerFactory.get_perm_pool().alloc(og_len + 1) + og_buf: str = CompilerFactory.factory.PermPool.alloc(og_len + 1) if og_buf is not None: string.strncpy(og_buf, orig, og_len) og_buf[og_len] = '\0' diff --git a/App/lib/core/Gen/ClassGenDef.vp b/App/lib/core/Gen/ClassGenDef.vp index adf7c8b..cb8d9aa 100644 --- a/App/lib/core/Gen/ClassGenDef.vp +++ b/App/lib/core/Gen/ClassGenDef.vp @@ -105,13 +105,13 @@ class ClassGenDef(ClassGenBase.ClassGenBase): # 读悬空挂起(G3 LinkedNode.prepend 挂起根因)。DeepCopyType # 递归深拷贝字段链表/子类型/Name 到 stdlib(深度上限+链守卫)。 ty_deep: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), existing.Ty) + CompilerFactory.factory.PermPool, existing.Ty) if ty_deep is not None: existing.Ty = ty_deep old_name: str = llvmlite.get_struct_name(existing.Ty) if old_name is not None: on_len: t.CSizeT = string.strlen(old_name) - on_copy: str = CompilerFactory.get_perm_pool().alloc(on_len + 1) + on_copy: str = CompilerFactory.factory.PermPool.alloc(on_len + 1) if on_copy is not None: string.strcpy(on_copy, old_name) c.DerefAs(existing.Ty, llvmlite.LLVMType.Struct( @@ -461,7 +461,7 @@ class ClassGenDef(ClassGenBase.ClassGenBase): type_name = name_buf if trans._declare_only == 0 and type_name is not None: tn_len: t.CSizeT = string.strlen(type_name) - tn_copy: str = CompilerFactory.get_perm_pool().alloc(tn_len + 1) + tn_copy: str = CompilerFactory.factory.PermPool.alloc(tn_len + 1) if tn_copy is not None: string.strcpy(tn_copy, type_name) type_name = tn_copy @@ -484,7 +484,7 @@ class ClassGenDef(ClassGenBase.ClassGenBase): # 崩溃(LoopTest _scan_type_for_cross_module_refs 0xFFFF 根因)。 if trans._declare_only == 0 or self.Gen.StructGen.get_stdlib_alloc() != 0: st_copy: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), struct_ty) + CompilerFactory.factory.PermPool, struct_ty) if st_copy is not None: struct_ty = st_copy type_name = llvmlite.get_struct_name(struct_ty) @@ -522,7 +522,7 @@ class ClassGenDef(ClassGenBase.ClassGenBase): # find_struct(ParentName) strcmp 解引用 → 用 stdlib 拷贝保证跨文件存活 if self.Gen.StructGen.get_stdlib_alloc() != 0: pn_len: t.CSizeT = string.strlen(parent_name) - pn_buf: str = CompilerFactory.get_perm_pool().alloc(pn_len + 1) + pn_buf: str = CompilerFactory.factory.PermPool.alloc(pn_len + 1) if pn_buf is not None: string.strcpy(pn_buf, parent_name) entry.ParentName = pn_buf diff --git a/App/lib/core/Gen/ClassGenEnum.vp b/App/lib/core/Gen/ClassGenEnum.vp index 3b9c3cc..ca53d0c 100644 --- a/App/lib/core/Gen/ClassGenEnum.vp +++ b/App/lib/core/Gen/ClassGenEnum.vp @@ -508,7 +508,7 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): # (LoopTest _scan_type_for_cross_module_refs 0xFFFF 根因)。 if trans._declare_only == 0 or self.Gen.StructGen.get_stdlib_alloc() != 0: union_copy: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), union_ty) + CompilerFactory.factory.PermPool, union_ty) if union_copy is not None: union_ty = union_copy @@ -779,7 +779,7 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): # StdlibAlloc=1(Phase2 mark2 后)也必须深拷贝:同 union 的悬空根因。 if trans._declare_only == 0 or self.Gen.StructGen.get_stdlib_alloc() != 0: renum_copy: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), renum_ty) + CompilerFactory.factory.PermPool, renum_ty) if renum_copy is not None: renum_ty = renum_copy @@ -844,10 +844,10 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): # 若用 pool 会被 reset_to(mark1) 回收导致悬空(LLVMType 的 match 在 # parser.vp 等后续文件翻译时访问已回收的表 → 崩溃)。 if self.RenumClassNames is None: - self.RenumClassNames = CompilerFactory.get_perm_pool().alloc(8 * RENUM_CLASS_MAX) - self.RenumClassVariantCounts = CompilerFactory.get_perm_pool().alloc(8 * RENUM_CLASS_MAX) - self.RenumVariantNames = CompilerFactory.get_perm_pool().alloc(8 * RENUM_CLASS_MAX * RENUM_VARIANT_PER_CLASS) - self.RenumVariantTags = CompilerFactory.get_perm_pool().alloc(8 * RENUM_CLASS_MAX * RENUM_VARIANT_PER_CLASS) + self.RenumClassNames = CompilerFactory.factory.PermPool.alloc(8 * RENUM_CLASS_MAX) + self.RenumClassVariantCounts = CompilerFactory.factory.PermPool.alloc(8 * RENUM_CLASS_MAX) + self.RenumVariantNames = CompilerFactory.factory.PermPool.alloc(8 * RENUM_CLASS_MAX * RENUM_VARIANT_PER_CLASS) + self.RenumVariantTags = CompilerFactory.factory.PermPool.alloc(8 * RENUM_CLASS_MAX * RENUM_VARIANT_PER_CLASS) if (self.RenumClassNames is None or self.RenumClassVariantCounts is None or self.RenumVariantNames is None or self.RenumVariantTags is None): self.RenumClassNames = None @@ -893,7 +893,7 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): # _lookup_renum_variant/_is_renum_class_name 的 strcmp 会读毒化内存) idx: int = self.RenumClassCount cn_len_rv: t.CSizeT = string.strlen(class_name) - cn_buf_rv: str = CompilerFactory.get_perm_pool().alloc(cn_len_rv + 1) + cn_buf_rv: str = CompilerFactory.factory.PermPool.alloc(cn_len_rv + 1) if cn_buf_rv is None: return string.strcpy(cn_buf_rv, class_name) @@ -923,7 +923,7 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): name_offset: t.CSizeT = idx * RENUM_VARIANT_PER_CLASS + tag # 变体名同样 strcpy 到 perm_pool(1a 每文件 reset 后 vcd.name 悬空) vn_len_rv: t.CSizeT = string.strlen(vcd.name) - vn_buf_rv: str = CompilerFactory.get_perm_pool().alloc(vn_len_rv + 1) + vn_buf_rv: str = CompilerFactory.factory.PermPool.alloc(vn_len_rv + 1) if vn_buf_rv is None: break string.strcpy(vn_buf_rv, vcd.name) @@ -993,7 +993,7 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): # 懒初始化表(perm_pool:1a 每文件 reset 后表本体不被回收) if self.RenumAliasClass is None: - alias_pool_rfa: memhub.MemBuddy | t.CPtr = CompilerFactory.get_perm_pool() + alias_pool_rfa: memhub.MemBuddy | t.CPtr = CompilerFactory.factory.PermPool self.RenumAliasClass = alias_pool_rfa.alloc(8 * RENUM_ALIAS_MAX) self.RenumAliasField = alias_pool_rfa.alloc(8 * RENUM_ALIAS_MAX) self.RenumAliasIndex = alias_pool_rfa.alloc(8 * RENUM_ALIAS_MAX) @@ -1032,7 +1032,7 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): # class_name 槽位保持原指针:_update_renum_alias_class_ptr 会统一为 # entry.Name(perm_pool 拷贝),指针值比较契约不变。 fn_len_rfa: t.CSizeT = string.strlen(field_name) - fn_buf_rfa: str = CompilerFactory.get_perm_pool().alloc(fn_len_rfa + 1) + fn_buf_rfa: str = CompilerFactory.factory.PermPool.alloc(fn_len_rfa + 1) if fn_buf_rfa is None: return string.strcpy(fn_buf_rfa, field_name) @@ -1043,14 +1043,14 @@ class ClassGenEnum(ClassGenBase.ClassGenBase): self.RenumAliasTy[idx] = 0 if field_ty is not None: ty_copy_rfa: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), field_ty) + CompilerFactory.factory.PermPool, field_ty) if ty_copy_rfa is not None: self.RenumAliasTy[idx] = t.CSizeT(ty_copy_rfa) # 变体名同样 strcpy 到 perm_pool(1a reset 后 variant_cd.name 悬空) self.RenumAliasVariant[idx] = 0 if variant_name is not None: vn_len_rfa: t.CSizeT = string.strlen(variant_name) - vn_buf_rfa: str = CompilerFactory.get_perm_pool().alloc(vn_len_rfa + 1) + vn_buf_rfa: str = CompilerFactory.factory.PermPool.alloc(vn_len_rfa + 1) if vn_buf_rfa is not None: string.strcpy(vn_buf_rfa, variant_name) self.RenumAliasVariant[idx] = t.CSizeT(vn_buf_rfa) diff --git a/App/lib/core/Gen/ClassGenGeneric.vp b/App/lib/core/Gen/ClassGenGeneric.vp index 194c9af..56ac5a7 100644 --- a/App/lib/core/Gen/ClassGenGeneric.vp +++ b/App/lib/core/Gen/ClassGenGeneric.vp @@ -67,7 +67,7 @@ class ClassGenGeneric(ClassGenBase.ClassGenBase): self.GenericClassSha1s = list[str](pool, 8) self.GenericClassFiles = list[str](pool, 8) if self.GenericClassTpParams is None: - self.GenericClassTpParams = CompilerFactory.get_perm_pool().alloc(GENERIC_TEMPLATE_MAX * 8) + self.GenericClassTpParams = CompilerFactory.factory.PermPool.alloc(GENERIC_TEMPLATE_MAX * 8) if self.GenericClassTpParams is None: return string.memset(self.GenericClassTpParams, 0, GENERIC_TEMPLATE_MAX * 8) @@ -108,7 +108,7 @@ class ClassGenGeneric(ClassGenBase.ClassGenBase): tp_name: str = tp.get(ti) if tp_name is not None: total += string.strlen(tp_name) + 1 - buf: str = CompilerFactory.get_perm_pool().alloc(total) + buf: str = CompilerFactory.factory.PermPool.alloc(total) if buf is None: return None buf[0] = '\0' @@ -426,8 +426,8 @@ class ClassGenGeneric(ClassGenBase.ClassGenBase): if spec_key is None or spec_name is None: return if self.SpecKeys is None: - self.SpecKeys = CompilerFactory.get_perm_pool().alloc(SPEC_CACHE_MAX * 8) - self.SpecNames = CompilerFactory.get_perm_pool().alloc(SPEC_CACHE_MAX * 8) + self.SpecKeys = CompilerFactory.factory.PermPool.alloc(SPEC_CACHE_MAX * 8) + self.SpecNames = CompilerFactory.factory.PermPool.alloc(SPEC_CACHE_MAX * 8) if self.SpecKeys is None or self.SpecNames is None: return string.memset(self.SpecKeys, 0, SPEC_CACHE_MAX * 8) @@ -438,8 +438,8 @@ class ClassGenGeneric(ClassGenBase.ClassGenBase): # 深拷贝字符串到 stdlib 区 key_len: t.CSizeT = string.strlen(spec_key) name_len: t.CSizeT = string.strlen(spec_name) - key_copy: str = CompilerFactory.get_perm_pool().alloc(key_len + 1) - name_copy: str = CompilerFactory.get_perm_pool().alloc(name_len + 1) + key_copy: str = CompilerFactory.factory.PermPool.alloc(key_len + 1) + name_copy: str = CompilerFactory.factory.PermPool.alloc(name_len + 1) if key_copy is None or name_copy is None: return string.strcpy(key_copy, spec_key) @@ -485,7 +485,7 @@ class ClassGenGeneric(ClassGenBase.ClassGenBase): if string.strcmp(entry_rt.Name, spec_name) != 0: return 0 ts_len_r: t.CSizeT = string.strlen(trigger_sha1) - ts_buf_r: str = CompilerFactory.get_perm_pool().alloc(ts_len_r + 1) + ts_buf_r: str = CompilerFactory.factory.PermPool.alloc(ts_len_r + 1) if ts_buf_r is None: return 0 string.strcpy(ts_buf_r, trigger_sha1) @@ -512,7 +512,7 @@ class ClassGenGeneric(ClassGenBase.ClassGenBase): # 特化触发文件 sha1:进入函数时 trans.ModuleSha1 是触发方文件, # 翻译特化类时会被切换为模板 sha1(见下方),作废重译时按此重置 # 特化类 MethodsEmitted(见 _record_spec_trigger / reset_module_methods_emitted) - spec_trigger_sha1: str = trans.ModuleSha1 + spec_trigger_sha1: str = trans.ModuleSha1 if self.GenericSpecDepth > GENERIC_SPEC_MAX_DEPTH: err_spec: str = trans.Pool.alloc(256) if err_spec is not None: diff --git a/App/lib/core/Gen/ClassGenVTable.vp b/App/lib/core/Gen/ClassGenVTable.vp index e588682..774f6bc 100644 --- a/App/lib/core/Gen/ClassGenVTable.vp +++ b/App/lib/core/Gen/ClassGenVTable.vp @@ -139,10 +139,10 @@ class ClassGenVTable(ClassGenBase.ClassGenBase): # 1. 收集虚方法信息 # stdlib 分配:method_names_buf 存到 StructEntry.VTableMethods(跨文件永久存活), # 必须迁出 mb 池 reset 区间,否则 1b 每文件 reset_to(mark1) 会回收导致悬空。 - full_names_buf: t.CSizeT | t.CPtr = CompilerFactory.get_perm_pool().alloc(8 * VTBL_METHOD_MAX) - method_names_buf: t.CSizeT | t.CPtr = CompilerFactory.get_perm_pool().alloc(8 * VTBL_METHOD_MAX) + full_names_buf: t.CSizeT | t.CPtr = CompilerFactory.factory.PermPool.alloc(8 * VTBL_METHOD_MAX) + method_names_buf: t.CSizeT | t.CPtr = CompilerFactory.factory.PermPool.alloc(8 * VTBL_METHOD_MAX) # 记录每个方法的父类 SHA1(非 0=继承方法用父模块 SHA1 mangling,0=当前类方法) - method_parent_sha1s: t.CSizeT | t.CPtr = CompilerFactory.get_perm_pool().alloc(8 * VTBL_METHOD_MAX) + method_parent_sha1s: t.CSizeT | t.CPtr = CompilerFactory.factory.PermPool.alloc(8 * VTBL_METHOD_MAX) if full_names_buf is None or method_names_buf is None or method_parent_sha1s is None: return 0 string.memset(full_names_buf, 0, 8 * VTBL_METHOD_MAX) @@ -232,13 +232,13 @@ class ClassGenVTable(ClassGenBase.ClassGenBase): def_class = anc break mro_i += 1 - pfname_buf: str = CompilerFactory.get_perm_pool().alloc(128) + pfname_buf: str = CompilerFactory.factory.PermPool.alloc(128) if pfname_buf is not None: viperlib.snprintf(pfname_buf, 128, "%s.%s", def_class, pmethod_name) full_names_buf[method_count] = t.CSizeT(pfname_buf) # 复制方法名(短名) pmname_len: t.CSizeT = string.strlen(pmethod_name) - pmname_buf: str = CompilerFactory.get_perm_pool().alloc(pmname_len + 1) + pmname_buf: str = CompilerFactory.factory.PermPool.alloc(pmname_len + 1) if pmname_buf is not None: string.strcpy(pmname_buf, pmethod_name) method_names_buf[method_count] = t.CSizeT(pmname_buf) @@ -294,14 +294,14 @@ class ClassGenVTable(ClassGenBase.ClassGenBase): # 构造 full_name = "ClassName.method_name" # 内容必须落在 perm_pool:1a(mark_only=1)收集的 VTableMethods 被 # Phase 1b 依赖模块翻译跨文件读取,1a 每文件 reset 后 pool 裸字符串悬空 - fname_buf: str = CompilerFactory.get_perm_pool().alloc(128) + fname_buf: str = CompilerFactory.factory.PermPool.alloc(128) if fname_buf is not None: viperlib.snprintf(fname_buf, 128, "%s.%s", class_name, mname) full_names_buf[method_count] = t.CSizeT(fname_buf) # 复制方法名 mname_len: t.CSizeT = string.strlen(mname) - mname_buf: str = CompilerFactory.get_perm_pool().alloc(mname_len + 1) + mname_buf: str = CompilerFactory.factory.PermPool.alloc(mname_len + 1) if mname_buf is not None: string.strcpy(mname_buf, mname) method_names_buf[method_count] = t.CSizeT(mname_buf) diff --git a/App/lib/core/Gen/ExprGenCls.vp b/App/lib/core/Gen/ExprGenCls.vp index e9fd8fd..f14eddf 100644 --- a/App/lib/core/Gen/ExprGenCls.vp +++ b/App/lib/core/Gen/ExprGenCls.vp @@ -78,8 +78,8 @@ class ExprGenCls(ExprGenBase.ExprGenBase): if string.strlen(doc) == 0: return if self.DocKeys is None: - self.DocKeys = CompilerFactory.get_perm_pool().alloc(DOC_MAX * DOC_KEY_SZ) - self.DocValues = CompilerFactory.get_perm_pool().alloc(DOC_MAX * DOC_VAL_SZ) + self.DocKeys = CompilerFactory.factory.PermPool.alloc(DOC_MAX * DOC_KEY_SZ) + self.DocValues = CompilerFactory.factory.PermPool.alloc(DOC_MAX * DOC_VAL_SZ) if self.DocKeys is None or self.DocValues is None: return string.memset(self.DocKeys, 0, DOC_MAX * DOC_KEY_SZ) @@ -337,10 +337,6 @@ class ExprGenCls(ExprGenBase.ExprGenBase): if ca is None or ca.attr is None or ca.value is None: return None # 模块级函数调用(Module.func()):接收者是已导入模块名而非类对象 - # (CompilerFactory.get_perm_pool())。返回注解可能是联合类型 - # (memhub.MemBuddy | t.CPtr),查 vpi 模块函数返回注解(cls=None) - # 提取返回类,解决链式方法调用 .alloc() 推断失败退化裸名 @alloc - # (链接 undefined symbol: alloc 根因)。 if ca.value.kind() == ast.ASTKind.Name: mod_nm2: str = ((ast.Name | t.CPtr)(ca.value)).id if mod_nm2 is not None and trans._from_imports is not None: diff --git a/App/lib/core/Gen/Generator.vp b/App/lib/core/Gen/Generator.vp index 959b5b2..60b7f33 100644 --- a/App/lib/core/Gen/Generator.vp +++ b/App/lib/core/Gen/Generator.vp @@ -120,329 +120,329 @@ class Generator: if self is None: return # ---- alloc 46 个子对象 + 回指(永久池,fail-fast) ---- - SubBaseGen: BaseGenMixin.BaseGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(BaseGenMixin.BaseGenMixin.__sizeof__()) + SubBaseGen: BaseGenMixin.BaseGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(BaseGenMixin.BaseGenMixin.__sizeof__()) if SubBaseGen is None: stdio.printf("FAIL: BaseGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubBaseGen, 0, BaseGenMixin.BaseGenMixin.__sizeof__()) SubBaseGen.Gen = self self.BaseGen = SubBaseGen - SubTypeGenBase: TypeGenBase.TypeGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenBase.TypeGenBase.__sizeof__()) + SubTypeGenBase: TypeGenBase.TypeGenBase | t.CPtr = CompilerFactory.factory.PermPool.alloc(TypeGenBase.TypeGenBase.__sizeof__()) if SubTypeGenBase is None: stdio.printf("FAIL: TypeGenBase alloc failed\n") stdlib.exit(1) string.memset(SubTypeGenBase, 0, TypeGenBase.TypeGenBase.__sizeof__()) SubTypeGenBase.Gen = self self.TypeGenBase = SubTypeGenBase - SubTypeGen: TypeGenMixin.TypeGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenMixin.TypeGenMixin.__sizeof__()) + SubTypeGen: TypeGenMixin.TypeGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(TypeGenMixin.TypeGenMixin.__sizeof__()) if SubTypeGen is None: stdio.printf("FAIL: TypeGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubTypeGen, 0, TypeGenMixin.TypeGenMixin.__sizeof__()) SubTypeGen.Gen = self self.TypeGen = SubTypeGen - SubTypeGenCDef: TypeGenCDef.TypeGenCDef | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenCDef.TypeGenCDef.__sizeof__()) + SubTypeGenCDef: TypeGenCDef.TypeGenCDef | t.CPtr = CompilerFactory.factory.PermPool.alloc(TypeGenCDef.TypeGenCDef.__sizeof__()) if SubTypeGenCDef is None: stdio.printf("FAIL: TypeGenCDef alloc failed\n") stdlib.exit(1) string.memset(SubTypeGenCDef, 0, TypeGenCDef.TypeGenCDef.__sizeof__()) SubTypeGenCDef.Gen = self self.TypeGenCDef = SubTypeGenCDef - SubTypeGenCType: TypeGenCType.TypeGenCType | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenCType.TypeGenCType.__sizeof__()) + SubTypeGenCType: TypeGenCType.TypeGenCType | t.CPtr = CompilerFactory.factory.PermPool.alloc(TypeGenCType.TypeGenCType.__sizeof__()) if SubTypeGenCType is None: stdio.printf("FAIL: TypeGenCType alloc failed\n") stdlib.exit(1) string.memset(SubTypeGenCType, 0, TypeGenCType.TypeGenCType.__sizeof__()) SubTypeGenCType.Gen = self self.TypeGenCType = SubTypeGenCType - SubTypeGenResolve: TypeGenResolve.TypeGenResolve | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenResolve.TypeGenResolve.__sizeof__()) + SubTypeGenResolve: TypeGenResolve.TypeGenResolve | t.CPtr = CompilerFactory.factory.PermPool.alloc(TypeGenResolve.TypeGenResolve.__sizeof__()) if SubTypeGenResolve is None: stdio.printf("FAIL: TypeGenResolve alloc failed\n") stdlib.exit(1) string.memset(SubTypeGenResolve, 0, TypeGenResolve.TypeGenResolve.__sizeof__()) SubTypeGenResolve.Gen = self self.TypeGenResolve = SubTypeGenResolve - SubTypeGenErr: TypeGenErr.TypeGenErr | t.CPtr = CompilerFactory.get_perm_pool().alloc(TypeGenErr.TypeGenErr.__sizeof__()) + SubTypeGenErr: TypeGenErr.TypeGenErr | t.CPtr = CompilerFactory.factory.PermPool.alloc(TypeGenErr.TypeGenErr.__sizeof__()) if SubTypeGenErr is None: stdio.printf("FAIL: TypeGenErr alloc failed\n") stdlib.exit(1) string.memset(SubTypeGenErr, 0, TypeGenErr.TypeGenErr.__sizeof__()) SubTypeGenErr.Gen = self self.TypeGenErr = SubTypeGenErr - SubStructGen: StructGenMixin.StructGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StructGenMixin.StructGenMixin.__sizeof__()) + SubStructGen: StructGenMixin.StructGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(StructGenMixin.StructGenMixin.__sizeof__()) if SubStructGen is None: stdio.printf("FAIL: StructGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubStructGen, 0, StructGenMixin.StructGenMixin.__sizeof__()) SubStructGen.Gen = self self.StructGen = SubStructGen - SubExprGenBase: ExprGenBase.ExprGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenBase.ExprGenBase.__sizeof__()) + SubExprGenBase: ExprGenBase.ExprGenBase | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenBase.ExprGenBase.__sizeof__()) if SubExprGenBase is None: stdio.printf("FAIL: ExprGenBase alloc failed\n") stdlib.exit(1) string.memset(SubExprGenBase, 0, ExprGenBase.ExprGenBase.__sizeof__()) SubExprGenBase.Gen = self self.ExprGenBase = SubExprGenBase - SubExprGen: ExprGenMixin.ExprGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenMixin.ExprGenMixin.__sizeof__()) + SubExprGen: ExprGenMixin.ExprGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenMixin.ExprGenMixin.__sizeof__()) if SubExprGen is None: stdio.printf("FAIL: ExprGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubExprGen, 0, ExprGenMixin.ExprGenMixin.__sizeof__()) SubExprGen.Gen = self self.ExprGen = SubExprGen - SubExprGenConst: ExprGenConst.ExprGenConst | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenConst.ExprGenConst.__sizeof__()) + SubExprGenConst: ExprGenConst.ExprGenConst | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenConst.ExprGenConst.__sizeof__()) if SubExprGenConst is None: stdio.printf("FAIL: ExprGenConst alloc failed\n") stdlib.exit(1) string.memset(SubExprGenConst, 0, ExprGenConst.ExprGenConst.__sizeof__()) SubExprGenConst.Gen = self self.ExprGenConst = SubExprGenConst - SubExprGenFstr: ExprGenFstr.ExprGenFstr | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenFstr.ExprGenFstr.__sizeof__()) + SubExprGenFstr: ExprGenFstr.ExprGenFstr | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenFstr.ExprGenFstr.__sizeof__()) if SubExprGenFstr is None: stdio.printf("FAIL: ExprGenFstr alloc failed\n") stdlib.exit(1) string.memset(SubExprGenFstr, 0, ExprGenFstr.ExprGenFstr.__sizeof__()) SubExprGenFstr.Gen = self self.ExprGenFstr = SubExprGenFstr - SubExprGenOps: ExprGenOps.ExprGenOps | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenOps.ExprGenOps.__sizeof__()) + SubExprGenOps: ExprGenOps.ExprGenOps | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenOps.ExprGenOps.__sizeof__()) if SubExprGenOps is None: stdio.printf("FAIL: ExprGenOps alloc failed\n") stdlib.exit(1) string.memset(SubExprGenOps, 0, ExprGenOps.ExprGenOps.__sizeof__()) SubExprGenOps.Gen = self self.ExprGenOps = SubExprGenOps - SubExprGenCdef: ExprGenCdef.ExprGenCdef | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenCdef.ExprGenCdef.__sizeof__()) + SubExprGenCdef: ExprGenCdef.ExprGenCdef | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenCdef.ExprGenCdef.__sizeof__()) if SubExprGenCdef is None: stdio.printf("FAIL: ExprGenCdef alloc failed\n") stdlib.exit(1) string.memset(SubExprGenCdef, 0, ExprGenCdef.ExprGenCdef.__sizeof__()) SubExprGenCdef.Gen = self self.ExprGenCdef = SubExprGenCdef - SubExprGenName: ExprGenName.ExprGenName | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenName.ExprGenName.__sizeof__()) + SubExprGenName: ExprGenName.ExprGenName | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenName.ExprGenName.__sizeof__()) if SubExprGenName is None: stdio.printf("FAIL: ExprGenName alloc failed\n") stdlib.exit(1) string.memset(SubExprGenName, 0, ExprGenName.ExprGenName.__sizeof__()) SubExprGenName.Gen = self self.ExprGenName = SubExprGenName - SubExprGenAttr: ExprGenAttr.ExprGenAttr | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenAttr.ExprGenAttr.__sizeof__()) + SubExprGenAttr: ExprGenAttr.ExprGenAttr | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenAttr.ExprGenAttr.__sizeof__()) if SubExprGenAttr is None: stdio.printf("FAIL: ExprGenAttr alloc failed\n") stdlib.exit(1) string.memset(SubExprGenAttr, 0, ExprGenAttr.ExprGenAttr.__sizeof__()) SubExprGenAttr.Gen = self self.ExprGenAttr = SubExprGenAttr - SubExprGenCls: ExprGenCls.ExprGenCls | t.CPtr = CompilerFactory.get_perm_pool().alloc(ExprGenCls.ExprGenCls.__sizeof__()) + SubExprGenCls: ExprGenCls.ExprGenCls | t.CPtr = CompilerFactory.factory.PermPool.alloc(ExprGenCls.ExprGenCls.__sizeof__()) if SubExprGenCls is None: stdio.printf("FAIL: ExprGenCls alloc failed\n") stdlib.exit(1) string.memset(SubExprGenCls, 0, ExprGenCls.ExprGenCls.__sizeof__()) SubExprGenCls.Gen = self self.ExprGenCls = SubExprGenCls - SubCallGenBase: CallGenBase.CallGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenBase.CallGenBase.__sizeof__()) + SubCallGenBase: CallGenBase.CallGenBase | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenBase.CallGenBase.__sizeof__()) if SubCallGenBase is None: stdio.printf("FAIL: CallGenBase alloc failed\n") stdlib.exit(1) string.memset(SubCallGenBase, 0, CallGenBase.CallGenBase.__sizeof__()) SubCallGenBase.Gen = self self.CallGenBase = SubCallGenBase - SubCallGenCBuiltin: CallGenCBuiltin.CallGenCBuiltin | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenCBuiltin.CallGenCBuiltin.__sizeof__()) + SubCallGenCBuiltin: CallGenCBuiltin.CallGenCBuiltin | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenCBuiltin.CallGenCBuiltin.__sizeof__()) if SubCallGenCBuiltin is None: stdio.printf("FAIL: CallGenCBuiltin alloc failed\n") stdlib.exit(1) string.memset(SubCallGenCBuiltin, 0, CallGenCBuiltin.CallGenCBuiltin.__sizeof__()) SubCallGenCBuiltin.Gen = self self.CallGenCBuiltin = SubCallGenCBuiltin - SubCallGenLeafKit: CallGenLeafKit.CallGenLeafKit | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenLeafKit.CallGenLeafKit.__sizeof__()) + SubCallGenLeafKit: CallGenLeafKit.CallGenLeafKit | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenLeafKit.CallGenLeafKit.__sizeof__()) if SubCallGenLeafKit is None: stdio.printf("FAIL: CallGenLeafKit alloc failed\n") stdlib.exit(1) string.memset(SubCallGenLeafKit, 0, CallGenLeafKit.CallGenLeafKit.__sizeof__()) SubCallGenLeafKit.Gen = self self.CallGenLeafKit = SubCallGenLeafKit - SubCallGenCtor: CallGenCtor.CallGenCtor | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenCtor.CallGenCtor.__sizeof__()) + SubCallGenCtor: CallGenCtor.CallGenCtor | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenCtor.CallGenCtor.__sizeof__()) if SubCallGenCtor is None: stdio.printf("FAIL: CallGenCtor alloc failed\n") stdlib.exit(1) string.memset(SubCallGenCtor, 0, CallGenCtor.CallGenCtor.__sizeof__()) SubCallGenCtor.Gen = self self.CallGenCtor = SubCallGenCtor - SubCallGenCall: CallGenCall.CallGenCall | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenCall.CallGenCall.__sizeof__()) + SubCallGenCall: CallGenCall.CallGenCall | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenCall.CallGenCall.__sizeof__()) if SubCallGenCall is None: stdio.printf("FAIL: CallGenCall alloc failed\n") stdlib.exit(1) string.memset(SubCallGenCall, 0, CallGenCall.CallGenCall.__sizeof__()) SubCallGenCall.Gen = self self.CallGenCall = SubCallGenCall - SubCallGen: CallGenMixin.CallGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenMixin.CallGenMixin.__sizeof__()) + SubCallGen: CallGenMixin.CallGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenMixin.CallGenMixin.__sizeof__()) if SubCallGen is None: stdio.printf("FAIL: CallGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubCallGen, 0, CallGenMixin.CallGenMixin.__sizeof__()) SubCallGen.Gen = self self.CallGen = SubCallGen - SubCallGenDispatch: CallGenDispatch.CallGenDispatch | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenDispatch.CallGenDispatch.__sizeof__()) + SubCallGenDispatch: CallGenDispatch.CallGenDispatch | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenDispatch.CallGenDispatch.__sizeof__()) if SubCallGenDispatch is None: stdio.printf("FAIL: CallGenDispatch alloc failed\n") stdlib.exit(1) string.memset(SubCallGenDispatch, 0, CallGenDispatch.CallGenDispatch.__sizeof__()) SubCallGenDispatch.Gen = self self.CallGenDispatch = SubCallGenDispatch - SubCallGenLib: CallGenLib.CallGenLib | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenLib.CallGenLib.__sizeof__()) + SubCallGenLib: CallGenLib.CallGenLib | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenLib.CallGenLib.__sizeof__()) if SubCallGenLib is None: stdio.printf("FAIL: CallGenLib alloc failed\n") stdlib.exit(1) string.memset(SubCallGenLib, 0, CallGenLib.CallGenLib.__sizeof__()) SubCallGenLib.Gen = self self.CallGenLib = SubCallGenLib - SubCallGenVt: CallGenVt.CallGenVt | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenVt.CallGenVt.__sizeof__()) + SubCallGenVt: CallGenVt.CallGenVt | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenVt.CallGenVt.__sizeof__()) if SubCallGenVt is None: stdio.printf("FAIL: CallGenVt alloc failed\n") stdlib.exit(1) string.memset(SubCallGenVt, 0, CallGenVt.CallGenVt.__sizeof__()) SubCallGenVt.Gen = self self.CallGenVt = SubCallGenVt - SubCallGenVa: CallGenVa.CallGenVa | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenVa.CallGenVa.__sizeof__()) + SubCallGenVa: CallGenVa.CallGenVa | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenVa.CallGenVa.__sizeof__()) if SubCallGenVa is None: stdio.printf("FAIL: CallGenVa alloc failed\n") stdlib.exit(1) string.memset(SubCallGenVa, 0, CallGenVa.CallGenVa.__sizeof__()) SubCallGenVa.Gen = self self.CallGenVa = SubCallGenVa - SubCallGenProp: CallGenProp.CallGenProp | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenProp.CallGenProp.__sizeof__()) + SubCallGenProp: CallGenProp.CallGenProp | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenProp.CallGenProp.__sizeof__()) if SubCallGenProp is None: stdio.printf("FAIL: CallGenProp alloc failed\n") stdlib.exit(1) string.memset(SubCallGenProp, 0, CallGenProp.CallGenProp.__sizeof__()) SubCallGenProp.Gen = self self.CallGenProp = SubCallGenProp - SubCallGenFd: CallGenFd.CallGenFd | t.CPtr = CompilerFactory.get_perm_pool().alloc(CallGenFd.CallGenFd.__sizeof__()) + SubCallGenFd: CallGenFd.CallGenFd | t.CPtr = CompilerFactory.factory.PermPool.alloc(CallGenFd.CallGenFd.__sizeof__()) if SubCallGenFd is None: stdio.printf("FAIL: CallGenFd alloc failed\n") stdlib.exit(1) string.memset(SubCallGenFd, 0, CallGenFd.CallGenFd.__sizeof__()) SubCallGenFd.Gen = self self.CallGenFd = SubCallGenFd - SubFuncGenBase: FuncGenBase.FuncGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(FuncGenBase.FuncGenBase.__sizeof__()) + SubFuncGenBase: FuncGenBase.FuncGenBase | t.CPtr = CompilerFactory.factory.PermPool.alloc(FuncGenBase.FuncGenBase.__sizeof__()) if SubFuncGenBase is None: stdio.printf("FAIL: FuncGenBase alloc failed\n") stdlib.exit(1) string.memset(SubFuncGenBase, 0, FuncGenBase.FuncGenBase.__sizeof__()) SubFuncGenBase.Gen = self self.FuncGenBase = SubFuncGenBase - SubFuncGenDef: FuncGenDef.FuncGenDef | t.CPtr = CompilerFactory.get_perm_pool().alloc(FuncGenDef.FuncGenDef.__sizeof__()) + SubFuncGenDef: FuncGenDef.FuncGenDef | t.CPtr = CompilerFactory.factory.PermPool.alloc(FuncGenDef.FuncGenDef.__sizeof__()) if SubFuncGenDef is None: stdio.printf("FAIL: FuncGenDef alloc failed\n") stdlib.exit(1) string.memset(SubFuncGenDef, 0, FuncGenDef.FuncGenDef.__sizeof__()) SubFuncGenDef.Gen = self self.FuncGenDef = SubFuncGenDef - SubFuncGen: FuncGenMixin.FuncGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(FuncGenMixin.FuncGenMixin.__sizeof__()) + SubFuncGen: FuncGenMixin.FuncGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(FuncGenMixin.FuncGenMixin.__sizeof__()) if SubFuncGen is None: stdio.printf("FAIL: FuncGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubFuncGen, 0, FuncGenMixin.FuncGenMixin.__sizeof__()) SubFuncGen.Gen = self self.FuncGen = SubFuncGen - SubClassGenBase: ClassGenBase.ClassGenBase | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenBase.ClassGenBase.__sizeof__()) + SubClassGenBase: ClassGenBase.ClassGenBase | t.CPtr = CompilerFactory.factory.PermPool.alloc(ClassGenBase.ClassGenBase.__sizeof__()) if SubClassGenBase is None: stdio.printf("FAIL: ClassGenBase alloc failed\n") stdlib.exit(1) string.memset(SubClassGenBase, 0, ClassGenBase.ClassGenBase.__sizeof__()) SubClassGenBase.Gen = self self.ClassGenBase = SubClassGenBase - SubClassGen: ClassGenMixin.ClassGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenMixin.ClassGenMixin.__sizeof__()) + SubClassGen: ClassGenMixin.ClassGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(ClassGenMixin.ClassGenMixin.__sizeof__()) if SubClassGen is None: stdio.printf("FAIL: ClassGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubClassGen, 0, ClassGenMixin.ClassGenMixin.__sizeof__()) SubClassGen.Gen = self self.ClassGen = SubClassGen - SubClassGenEnum: ClassGenEnum.ClassGenEnum | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenEnum.ClassGenEnum.__sizeof__()) + SubClassGenEnum: ClassGenEnum.ClassGenEnum | t.CPtr = CompilerFactory.factory.PermPool.alloc(ClassGenEnum.ClassGenEnum.__sizeof__()) if SubClassGenEnum is None: stdio.printf("FAIL: ClassGenEnum alloc failed\n") stdlib.exit(1) string.memset(SubClassGenEnum, 0, ClassGenEnum.ClassGenEnum.__sizeof__()) SubClassGenEnum.Gen = self self.ClassGenEnum = SubClassGenEnum - SubClassGenGeneric: ClassGenGeneric.ClassGenGeneric | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenGeneric.ClassGenGeneric.__sizeof__()) + SubClassGenGeneric: ClassGenGeneric.ClassGenGeneric | t.CPtr = CompilerFactory.factory.PermPool.alloc(ClassGenGeneric.ClassGenGeneric.__sizeof__()) if SubClassGenGeneric is None: stdio.printf("FAIL: ClassGenGeneric alloc failed\n") stdlib.exit(1) string.memset(SubClassGenGeneric, 0, ClassGenGeneric.ClassGenGeneric.__sizeof__()) SubClassGenGeneric.Gen = self self.ClassGenGeneric = SubClassGenGeneric - SubClassGenVTable: ClassGenVTable.ClassGenVTable | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenVTable.ClassGenVTable.__sizeof__()) + SubClassGenVTable: ClassGenVTable.ClassGenVTable | t.CPtr = CompilerFactory.factory.PermPool.alloc(ClassGenVTable.ClassGenVTable.__sizeof__()) if SubClassGenVTable is None: stdio.printf("FAIL: ClassGenVTable alloc failed\n") stdlib.exit(1) string.memset(SubClassGenVTable, 0, ClassGenVTable.ClassGenVTable.__sizeof__()) SubClassGenVTable.Gen = self self.ClassGenVTable = SubClassGenVTable - SubClassGenDef: ClassGenDef.ClassGenDef | t.CPtr = CompilerFactory.get_perm_pool().alloc(ClassGenDef.ClassGenDef.__sizeof__()) + SubClassGenDef: ClassGenDef.ClassGenDef | t.CPtr = CompilerFactory.factory.PermPool.alloc(ClassGenDef.ClassGenDef.__sizeof__()) if SubClassGenDef is None: stdio.printf("FAIL: ClassGenDef alloc failed\n") stdlib.exit(1) string.memset(SubClassGenDef, 0, ClassGenDef.ClassGenDef.__sizeof__()) SubClassGenDef.Gen = self self.ClassGenDef = SubClassGenDef - SubImportsGen: ImportsGenMixin.ImportsGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(ImportsGenMixin.ImportsGenMixin.__sizeof__()) + SubImportsGen: ImportsGenMixin.ImportsGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(ImportsGenMixin.ImportsGenMixin.__sizeof__()) if SubImportsGen is None: stdio.printf("FAIL: ImportsGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubImportsGen, 0, ImportsGenMixin.ImportsGenMixin.__sizeof__()) SubImportsGen.Gen = self self.ImportsGen = SubImportsGen - SubStmtGenCif: StmtGenCifMixin.StmtGenCifMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StmtGenCifMixin.StmtGenCifMixin.__sizeof__()) + SubStmtGenCif: StmtGenCifMixin.StmtGenCifMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(StmtGenCifMixin.StmtGenCifMixin.__sizeof__()) if SubStmtGenCif is None: stdio.printf("FAIL: StmtGenCifMixin alloc failed\n") stdlib.exit(1) string.memset(SubStmtGenCif, 0, StmtGenCifMixin.StmtGenCifMixin.__sizeof__()) SubStmtGenCif.Gen = self self.StmtGenCif = SubStmtGenCif - SubStmtGenDecl: StmtGenDeclMixin.StmtGenDeclMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StmtGenDeclMixin.StmtGenDeclMixin.__sizeof__()) + SubStmtGenDecl: StmtGenDeclMixin.StmtGenDeclMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(StmtGenDeclMixin.StmtGenDeclMixin.__sizeof__()) if SubStmtGenDecl is None: stdio.printf("FAIL: StmtGenDeclMixin alloc failed\n") stdlib.exit(1) string.memset(SubStmtGenDecl, 0, StmtGenDeclMixin.StmtGenDeclMixin.__sizeof__()) SubStmtGenDecl.Gen = self self.StmtGenDecl = SubStmtGenDecl - SubStmtGen: StmtGenMixin.StmtGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(StmtGenMixin.StmtGenMixin.__sizeof__()) + SubStmtGen: StmtGenMixin.StmtGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(StmtGenMixin.StmtGenMixin.__sizeof__()) if SubStmtGen is None: stdio.printf("FAIL: StmtGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubStmtGen, 0, StmtGenMixin.StmtGenMixin.__sizeof__()) SubStmtGen.Gen = self self.StmtGen = SubStmtGen - SubMatchGen: MatchGenMixin.MatchGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(MatchGenMixin.MatchGenMixin.__sizeof__()) + SubMatchGen: MatchGenMixin.MatchGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(MatchGenMixin.MatchGenMixin.__sizeof__()) if SubMatchGen is None: stdio.printf("FAIL: MatchGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubMatchGen, 0, MatchGenMixin.MatchGenMixin.__sizeof__()) SubMatchGen.Gen = self self.MatchGen = SubMatchGen - SubAssignGen: AssignGenMixin.AssignGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(AssignGenMixin.AssignGenMixin.__sizeof__()) + SubAssignGen: AssignGenMixin.AssignGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(AssignGenMixin.AssignGenMixin.__sizeof__()) if SubAssignGen is None: stdio.printf("FAIL: AssignGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubAssignGen, 0, AssignGenMixin.AssignGenMixin.__sizeof__()) SubAssignGen.Gen = self self.AssignGen = SubAssignGen - SubVarGen: VarGenMixin.VarGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(VarGenMixin.VarGenMixin.__sizeof__()) + SubVarGen: VarGenMixin.VarGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(VarGenMixin.VarGenMixin.__sizeof__()) if SubVarGen is None: stdio.printf("FAIL: VarGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubVarGen, 0, VarGenMixin.VarGenMixin.__sizeof__()) SubVarGen.Gen = self self.VarGen = SubVarGen - SubTranslatorGen: TranslatorGenMixin.TranslatorGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(TranslatorGenMixin.TranslatorGenMixin.__sizeof__()) + SubTranslatorGen: TranslatorGenMixin.TranslatorGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(TranslatorGenMixin.TranslatorGenMixin.__sizeof__()) if SubTranslatorGen is None: stdio.printf("FAIL: TranslatorGenMixin alloc failed\n") stdlib.exit(1) string.memset(SubTranslatorGen, 0, TranslatorGenMixin.TranslatorGenMixin.__sizeof__()) SubTranslatorGen.Gen = self self.TranslatorGen = SubTranslatorGen - SubAsyncGen: AsyncGenMixin.AsyncGenMixin | t.CPtr = CompilerFactory.get_perm_pool().alloc(AsyncGenMixin.AsyncGenMixin.__sizeof__()) + SubAsyncGen: AsyncGenMixin.AsyncGenMixin | t.CPtr = CompilerFactory.factory.PermPool.alloc(AsyncGenMixin.AsyncGenMixin.__sizeof__()) if SubAsyncGen is None: stdio.printf("FAIL: AsyncGenMixin alloc failed\n") stdlib.exit(1) diff --git a/App/lib/core/Gen/StmtGenDeclMixin.vp b/App/lib/core/Gen/StmtGenDeclMixin.vp index c3ccc61..8189efc 100644 --- a/App/lib/core/Gen/StmtGenDeclMixin.vp +++ b/App/lib/core/Gen/StmtGenDeclMixin.vp @@ -424,7 +424,7 @@ class StmtGenDeclMixin(StmtGenCifMixin.StmtGenCifMixin): return 1 entry_size: t.CSizeT = GenTypes.EnumEntry.__sizeof__() - self.EnumTable = CompilerFactory.get_perm_pool().alloc(entry_size * ENUM_MAX) + self.EnumTable = CompilerFactory.factory.PermPool.alloc(entry_size * ENUM_MAX) if self.EnumTable is None: return 0 string.memset(self.EnumTable, 0, entry_size * ENUM_MAX) @@ -471,14 +471,14 @@ class StmtGenDeclMixin(StmtGenCifMixin.StmtGenCifMixin): # 分配成员数组(永久池:跨 mark/reset 存活,对齐 EnumTable 永久池化) member_size: t.CSizeT = GenTypes.EnumMember.__sizeof__() - entry.Members = CompilerFactory.get_perm_pool().alloc(member_size * ENUM_MEMBER_MAX) + entry.Members = CompilerFactory.factory.PermPool.alloc(member_size * ENUM_MEMBER_MAX) if entry.Members is None: return None string.memset(entry.Members, 0, member_size * ENUM_MEMBER_MAX) # 复制类名(永久池深拷贝) name_len: t.CSizeT = string.strlen(name) - name_buf: str = CompilerFactory.get_perm_pool().alloc(name_len + 1) + name_buf: str = CompilerFactory.factory.PermPool.alloc(name_len + 1) if name_buf is not None: string.strcpy(name_buf, name) entry.Name = name_buf @@ -491,7 +491,7 @@ class StmtGenDeclMixin(StmtGenCifMixin.StmtGenCifMixin): # self.StdlibAlloc(NoVTable 按本 Mixin 字段布局编译),走模块级委托。 if self.Gen.StructGen.get_stdlib_alloc() != 0: base_ty_copy: llvmlite.LLVMType | t.CPtr = llvmlite.DeepCopyType( - CompilerFactory.get_perm_pool(), base_ty) + CompilerFactory.factory.PermPool, base_ty) if base_ty_copy is not None: entry.BaseTy = base_ty_copy else: @@ -533,7 +533,7 @@ class StmtGenDeclMixin(StmtGenCifMixin.StmtGenCifMixin): # 复制成员名(永久池深拷贝:成员表跨 mark/reset 存活) name_len: t.CSizeT = string.strlen(member_name) - name_buf: str = CompilerFactory.get_perm_pool().alloc(name_len + 1) + name_buf: str = CompilerFactory.factory.PermPool.alloc(name_len + 1) if name_buf is not None: string.strcpy(name_buf, member_name) me.Name = name_buf diff --git a/App/lib/core/Gen/StructGenMixin.vp b/App/lib/core/Gen/StructGenMixin.vp index 08f104a..414f32f 100644 --- a/App/lib/core/Gen/StructGenMixin.vp +++ b/App/lib/core/Gen/StructGenMixin.vp @@ -832,36 +832,7 @@ class StructGenMixin: self.Gen.TypeGenErr.fatal_error(node, fb, "AttributeError") stdlib.free(mod_buf_q) return None - # 模块可解析但类未注册:先看裸名同名类是否唯一—— - # 模块归属错位场景(如 "ast.Attribute":模块 'ast' 经包名 - # 回退解析到 ast/__init__.vp 的 sha1,但 Attribute 类实际 - # 注册在子模块 ast/exprs.vp,ModuleSha1 不匹配 → 查不到)。 - # 裸名唯一时回退(Attribute 短名无跨模块同名,安全); - # 多同名时保持 fail-fast(防 sched.Thread 被顶掉的同类问题)。 - same_cnt_q: int = 0 - same_entry_q: GenTypes.StructEntry | t.CPtr = None - for i_sq in range(self.StructCount): - e_sq: GenTypes.StructEntry | t.CPtr = self._get_struct_entry(i_sq) - if e_sq is not None and e_sq.Name is not None: - if string.strcmp(e_sq.Name, bare_q) == 0: - same_cnt_q += 1 - same_entry_q = e_sq - if same_cnt_q == 1 and same_entry_q is not None: - for fi_q2 in range(same_entry_q.FieldCount): - fe_q2: GenTypes.FieldEntry | t.CPtr = \ - self._get_field_entry(same_entry_q, fi_q2) - if fe_q2 is not None and fe_q2.Name is not None: - if string.strcmp(fe_q2.Name, field_name) == 0: - stdlib.free(mod_buf_q) - return fe_q2 - # 裸名类命中但字段未找到:返回 None(不 fatal_error)—— - # 字段可能是 REnum 变体别名(如 LLVMType.Pointee → _p2 - # 槽位)或继承字段,调用方(ExprGenAttr L853-864)有 - # REnum 别名回退等后续机会;对齐主 SHA1 匹配分支 - # (L797-798 字段未找到 return None)的语义。 - stdlib.free(mod_buf_q) - return None - # 裸名也不唯一/不存在:fail-fast(暴露 vpi 注入/注册缺陷, + # 模块可解析但类未注册:fail-fast(暴露 vpi 注入/注册缺陷, # 不再裸名跨库抓其他模块同名类) viperlib.snprintf(fb, 1024, "lookup_field_by_class: 类 '%s' 未找到(模块 '%s' 可解析" diff --git a/App/lib/core/Gen/TypeGenBase.vp b/App/lib/core/Gen/TypeGenBase.vp index 13e172b..05d4c22 100644 --- a/App/lib/core/Gen/TypeGenBase.vp +++ b/App/lib/core/Gen/TypeGenBase.vp @@ -115,7 +115,7 @@ class TypeGenBase: if self.TraceFrames is not None: return 1 entry_size: t.CSizeT = GenTypes.TraceFrame.__sizeof__() - self.TraceFrames = CompilerFactory.get_perm_pool().alloc(entry_size * TypeGenMixin.TRACE_MAX) + self.TraceFrames = CompilerFactory.factory.PermPool.alloc(entry_size * TypeGenMixin.TRACE_MAX) if self.TraceFrames is None: return 0 string.memset(self.TraceFrames, 0, entry_size * TypeGenMixin.TRACE_MAX) diff --git a/App/lib/core/Gen/TypeGenCDef.vp b/App/lib/core/Gen/TypeGenCDef.vp index 269b429..4256c08 100644 --- a/App/lib/core/Gen/TypeGenCDef.vp +++ b/App/lib/core/Gen/TypeGenCDef.vp @@ -143,7 +143,7 @@ class TypeGenCDef(TypeGenBase.TypeGenBase): x_nm: str = self.XmodCdefNames.get(x_i) if x_nm is not None and string.strcmp(x_nm, name) == 0: return - perm: memhub.MemBuddy | t.CPtr = CompilerFactory.get_perm_pool() + perm: memhub.MemBuddy | t.CPtr = CompilerFactory.factory.PermPool if self.XmodCdefNames is None: self.XmodCdefNames = list[str](perm, 64) self.XmodCdefValues = list[str](perm, 64) diff --git a/App/lib/core/Gen/__init__.vp b/App/lib/core/Gen/__init__.vp index d97d564..ed78aed 100644 --- a/App/lib/core/Gen/__init__.vp +++ b/App/lib/core/Gen/__init__.vp @@ -1,4 +1,4 @@ # ============================================================ # Gen - 对象化生成器(P1 骨架 + P2 TypeGenMixin) -# Generator: 翻译状态容器 + Mixin 组合(BaseGen 状态 + TypeGen 类型映射, +# Generator: 翻译状态容器 # ============================================================ diff --git a/App/main.vp b/App/main.vp index a839747..8fe9f08 100644 --- a/App/main.vp +++ b/App/main.vp @@ -88,7 +88,7 @@ def main() -> int: stdio.printf("FAIL: perm_pool init failed\n") return 1 - CompilerFactory.set_factory(CompilerFactory.CompilerFactory(mb, perm_pool)) + CompilerFactory.factory = CompilerFactory.CompilerFactory(mb, perm_pool) # 设置全局 mbuddy 指针(sys 和 argparse 都需要) sys._mbuddy = mb @@ -133,6 +133,7 @@ def main() -> int: if log is None: log.error("TransPyV Failed to parse parameters") fmtbuf: str = VLogger.fmtbuffer + fb: str = VLogger.fmtbuffer # 初始化命令行参数(Windows: GetCommandLineA, POSIX: /proc/self/cmdline) sys._init_argv() @@ -233,10 +234,8 @@ Target: %s mf_inc_bin_asan: str = Config.get_includes_binary_dir() if mf_inc_bin_asan is not None: n_asan: int = Utils.CleanDir(mf_inc_bin_asan) - fb_asan: str = VLogger.fmtbuffer - if fb_asan is not None: - viperlib.snprintf(fb_asan, 1024, "ASan 模式清理 includes 缓存: %d 个文件(将重建 asan obj)", n_asan) - log.info(fb_asan, "asan") + viperlib.snprintf(fb, 1024, "ASan 模式清理 includes 缓存: %d 个文件(将重建 asan obj)", n_asan) + log.info(f"ASan 模式清理 includes 缓存: {n_asan} 个文件(将重建 asan obj)", "asan") else: BuildPipeline._asan_mode = False Config._inc_bin_suffix = ".binary"