fix(gentype): _HandleSizeofLlvm 的 CType.POINTER 改 t.CType.POINTER

CType 未导入 HandlesExprCall.py,6ff76f3 引入 NameError。t 模块已导入,
改用 t.CType.POINTER。
This commit is contained in:
TermiNexus committed 2026-08-19 22:52:49 +08:00
1 parent 6ff76f3cb6
commit c02f7dbaf1
1 file changed
+11 -11
+11 -11
View File
@@ -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)