chore(gen): 删除 CallGenDispatch 的 [MDISP] 临时探针及其专用 import stdio

该探针(并排取证 __with_ctx.__enter__ 与 pool.alloc 的 H6 判据命中差异)为定位 MpoolOopTest 的「跨模块调用 pool.alloc 找不到模块 SHA1」临时加入,现缺陷已定位,探针与其唯一使用者 import stdio 一并移除;非 local 对象分派逻辑不变。
This commit is contained in:
TermiNexus committed 2026-09-27 12:32:52 +08:00
1 parent 9455db0eec
commit 87f5b1026c
1 file changed
-75
-75
View File
@@ -8,7 +8,6 @@ import ast
import llvmlite
import memhub
import string
import stdio
import stdlib
import sys
import viperlib
@@ -1242,80 +1241,6 @@ novirtual class CallGenDispatch(CallGenBase.CallGenBase):
if method_at.value.kind() == ast.ASTKind.Name and trans is not None:
method_obj_nm: ast.Name* = ast.Name*(method_at.value)
if method_obj_nm.id is not None:
# [DIAG] 并排取证「已知成功」与「刚落空」的形的方法调用,看 H6 各级
# 判据的命中差异(临时探针,定位后连同 import stdio 一起删除):
# A) recv=__with_ctx m=__enter__ :with 绑定 asname 之前执行,已知成功
# B) recv=pool m=alloc :与 A 同一注释类名(memhub.MemPool),
# 但接收者 LLVM 类型来自 __enter__ 的**返回值**(A 是构造结果)
# 只有这一对能解释 H6 为何对 B 全线落空 —— 落空且不置 hit_box 时,
# translate_call 会把接收者名当模块名,报「跨模块调用 'pool.alloc'
# 找不到模块 SHA1」(MpoolOopTest/App/mpooltest.vp:14)。
dg_hit: int = 0
if string.strcmp(func_name, "alloc") == 0 \
and string.strcmp(method_obj_nm.id, "pool") == 0:
dg_hit = 1
if string.strcmp(func_name, "__enter__") == 0 \
and string.strcmp(method_obj_nm.id, "__with_ctx") == 0:
dg_hit = 1
if dg_hit != 0:
dg_obj: llvmlite.Value* = self.Gen.VarGen.lookup_var(trans.SymTab, method_obj_nm.id)
dg_found: int = 0
dg_ty: str = "-"
dg_c1: str = "-"
dg_c2: str = "-"
dg_an: str = "-"
dg_struct_ok: int = -1
dg_sha1_ok: int = -1
dg_spc_ok: int = -1
if dg_obj is not None:
dg_found = 1
if dg_obj.Ty is not None:
dg_ty = pool.alloc(256)
if dg_ty is not None:
llvmlite.TypePrint(dg_ty, 256, dg_obj.Ty, pool)
dg_s1: llvmlite.LLVMType* = None
if self.Gen.ExprGenBase.is_ptr_type(dg_obj.Ty) != 0:
dg_s1 = dg_obj.Ty.Pointee
if dg_s1 is not None:
dg_x1: str = self.Gen.StructGen.get_class_name_by_type(pool, dg_s1)
if dg_x1 is not None:
dg_c1 = dg_x1
if self.Gen.ExprGenBase.is_ptr_type(dg_s1) != 0:
dg_x2: str = self.Gen.StructGen.get_class_name_by_type(pool, dg_s1.Pointee)
if dg_x2 is not None:
dg_c2 = dg_x2
dg_ve: GenTypes.VarEntry* = self.Gen.VarGen.lookup_var_entry(trans.SymTab, method_obj_nm.id)
dg_anr: str = self.Gen.VarGen.var_annot_class_name(dg_ve)
if dg_anr is not None:
dg_an = dg_anr
dg_bare: str = dg_anr
dg_dot: str = string.strrchr(dg_anr, '.')
if dg_dot is not None:
dg_bare = dg_dot + 1
if self.Gen.StructGen.get_struct_type(dg_bare) is not None:
dg_struct_ok = 1
else:
dg_struct_ok = 0
if dg_dot is not None:
dg_ml: sizet = string.strlen(dg_anr) - string.strlen(dg_bare) - 1
dg_mb: str = pool.alloc(dg_ml + 1)
if dg_mb is not None:
string.strncpy(dg_mb, dg_anr, dg_ml)
dg_mb[dg_ml] = '\0'
if self._lookup_module_sha1(dg_mb) is not None:
dg_sha1_ok = 1
else:
dg_sha1_ok = 0
if self._special_method_ret_ty(pool, dg_bare, func_name) is not None:
dg_spc_ok = 1
else:
dg_spc_ok = 0
dg_nl: int = GenApi.is_nonlocal_name(trans, method_obj_nm.id)
stdio.printf("[MDISP] mod=%s line=%d recv=%s m=%s found=%d nonlocal=%d recv_ty=%s cls1=%s cls2=%s annot=%s struct_ok=%d sha1_ok=%d spc_ok=%d\n",
trans.ModuleSha1, cl.lineno, method_obj_nm.id, func_name,
dg_found, dg_nl, dg_ty, dg_c1, dg_c2, dg_an,
dg_struct_ok, dg_sha1_ok, dg_spc_ok)
stdio.fflush(None)
# nonlocal 对象:提升函数内从 env 读对象指针(load_nonlocal_var),
# 不能 lookup_var 跨函数命中父函数 alloca(SSA 编号错乱 →
# llc "use of undefined value")。entry.get() 等方法调用的