From c02f7dbaf1f3f194fe12b646d2e0210aec8bbc40 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 19 Aug 2026 22:52:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(gentype):=20=5FHandleSizeofLlvm=20=E7=9A=84?= =?UTF-8?q?=20CType.POINTER=20=E6=94=B9=20t.CType.POINTER?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CType 未导入 HandlesExprCall.py,6ff76f3 引入 NameError。t 模块已导入, 改用 t.CType.POINTER。 --- lib/core/Handles/HandlesExprCall.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/core/Handles/HandlesExprCall.py b/lib/core/Handles/HandlesExprCall.py index 69e510d..64817e6 100644 --- a/lib/core/Handles/HandlesExprCall.py +++ b/lib/core/Handles/HandlesExprCall.py @@ -35,14 +35,14 @@ def _BinOpContainsCPtr(node: ast.AST) -> bool: return False -class ExprCallHandle(BaseHandle): - # vtable on-demand 缓存(类级,跨 worker 任务共享,进程内单线程无竞争)。 - # 原实现 pyi_cache 是 _try_register_vtable_ondemand 函数局部变量,每次调用都 - # 重建 → 437 次调用 = 437 次 open+ast.parse 同一批 pyi(prof 38.5s)。 - # vpi 以 sha1 命名、单次编译内只增不减,路径不变则内容不可变,进程内缓存安全。 - # _vtable_pyi_cache:pyi 文件绝对路径 → {类名: ClassDef 节点} - # _vtable_methods_cache:(sha1, class_name) → (methods, is_cvtable, is_novtable, parent_name) - _vtable_pyi_cache: dict[str, dict[str, ast.ClassDef]] = {} +class ExprCallHandle(BaseHandle): + # vtable on-demand 缓存(类级,跨 worker 任务共享,进程内单线程无竞争)。 + # 原实现 pyi_cache 是 _try_register_vtable_ondemand 函数局部变量,每次调用都 + # 重建 → 437 次调用 = 437 次 open+ast.parse 同一批 pyi(prof 38.5s)。 + # vpi 以 sha1 命名、单次编译内只增不减,路径不变则内容不可变,进程内缓存安全。 + # _vtable_pyi_cache:pyi 文件绝对路径 → {类名: ClassDef 节点} + # _vtable_methods_cache:(sha1, class_name) → (methods, is_cvtable, is_novtable, parent_name) + _vtable_pyi_cache: dict[str, dict[str, ast.ClassDef]] = {} _vtable_methods_cache: dict[tuple[str, str], tuple[list[str], bool, bool, str | None]] = {} def _append_eh_msg_out_arg(self, CallArgs: list[ir.Value], func: ir.Function | None, Gen: LlvmGeneratorMixin) -> None: if not func: @@ -2345,8 +2345,8 @@ class ExprCallHandle(BaseHandle): if mn not in covered_names: merged.append(m) - result = (merged, is_cvtable, is_novtable, parent_name) - self._vtable_methods_cache[key] = result + result = (merged, is_cvtable, is_novtable, parent_name) + self._vtable_methods_cache[key] = result return result methods, is_cvtable, is_novtable, parent_name = collect_class_methods(ClassName, class_sha1, set()) @@ -3658,7 +3658,7 @@ class ExprCallHandle(BaseHandle): # 根因:t.CPtr.__sizeof__() 返回 0 → list[t.CPtr] # elem_size=0 → append 全写同槽/alloc(0) → 崩溃。 if getattr(ctype_inst, 'HasPosition', None) \ - and ctype_inst.HasPosition(CType.POINTER) \ + and ctype_inst.HasPosition(t.CType.POINTER) \ and size_bytes == 0: size_bytes = 8 return ir.Constant(ir.IntType(64), size_bytes)