From 33c8609882b28b409380212e8bb982b0e9ac9515 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Mon, 17 Aug 2026 18:31:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20list=20=E5=86=85=E7=BD=AE=E5=88=86?= =?UTF-8?q?=E6=94=AF=E7=BD=AE=E4=BD=8D=20hit=5Fbox=20=E5=B9=B6=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E5=AF=B9=E8=B1=A1=E7=B1=BB=E5=9E=8B=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20nums.set=20=E6=89=BE=E4=B8=8D=E5=88=B0=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=20SHA1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - list 内置分支 set/clear 等 void 方法成功处理返回 None 时未被标记命中,translate_call 误判未命中继续走跨模块路径,把对象名当模块名查 SHA1 → '跨模块调用 nums.set 找不到模块 SHA1'(ListTest 根因) - 进入 list 内置分支即置位 hit_box(对齐 _translate_method_call 调用点模式),void 方法返回 None 视为已处理 - 增加对象类型确认(额外搜索路径):从对象结构体名匹配 list,明确非 list(dict/普通类未注册场景)跳过本分支,避免按 list 布局 GEP 误处理 --- App/lib/core/Gen/CallGenDispatch.vp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/App/lib/core/Gen/CallGenDispatch.vp b/App/lib/core/Gen/CallGenDispatch.vp index 4ff2c0e..54e4f02 100644 --- a/App/lib/core/Gen/CallGenDispatch.vp +++ b/App/lib/core/Gen/CallGenDispatch.vp @@ -1288,6 +1288,28 @@ class CallGenDispatch(CallGenBase.CallGenBase): # fail-fast,绝不 VLogger.critical 后 return None 静默吞掉 HandlesType.fatal_error( lm_at.value, f"list 方法 '{lm_name}' 目标对象非指针", "TypeError") + # list 对象类型确认(额外搜索路径):list 内置分支仅按方法名 + # 判断(get/set/__getitem__ 等非 list 专有),须确认对象确实 + # 是 list——从对象结构体名匹配 "list"。明确非 list(如 dict / + # 普通类未注册场景)跳过本分支,避免按 list 布局 GEP 生成 + # 错误 IR(dict 的 get 被当 list.get 按 __data__/__elem_size__ + # 偏移读写垃圾)。 + lm_conf_ty: llvmlite.LLVMType | t.CPtr = \ + HandlesStruct.get_struct_type_from_value(lm_obj) + lm_conf_nm: str = None + if lm_conf_ty is not None: + lm_conf_nm = llvmlite.get_struct_name(lm_conf_ty) + if lm_conf_nm is not None and \ + string.strstr(lm_conf_nm, "list") is None: + return None + # list 内置分支命中标记:void 方法(set/clear)成功处理后返回 + # None,必须置位 hit_box 区分"已识别为 list 方法路径",否则 + # translate_call 误判未命中继续走跨模块函数路径,把对象名当 + # 模块名查 SHA1 → "跨模块调用 'nums.set' 找不到模块 SHA1" + # (ListTest main.vp nums.set(1,99) 根因;对齐 _translate_method_call + # 调用点的 hit_box 置位模式)。 + if hit_box is not None: + hit_box[0] = 1 i64_ty: llvmlite.LLVMType | t.CPtr = llvmlite.Int64(pool) i8_ty: llvmlite.LLVMType | t.CPtr = llvmlite.Int8(pool) i8_ptr_ty: llvmlite.LLVMType | t.CPtr = llvmlite.Ptr(pool, i8_ty)