fix(TVP): get_class_name_by_type strstr 回退改后缀匹配,修复链式方法调用类名解析
特化类型名 SHA1.GSList[Param] 被 strstr 子串回退错误命中基础名 GSList → GSList.append 查找失败 → 兄弟 Mixin 兜底误匹配 LinkedNode.append(this 前移 sizeof(LinkedNode)=-48)→ 写穿 GSList 容器前 48 字节 → LLvmLiteTest Test 3 崩溃(function_add_param/function_add_block/block_append_line 链式调用根因)。 后缀匹配(SHA1.ClassName 尾部)比 strstr 子串匹配安全,保留精确匹配路径。
This commit is contained in:
1 parent
9e6e76fcab
commit
f7f3bbac02
1 file changed
+18
-4
@@ -927,10 +927,24 @@ class StructGenMixin:
|
||||
# 也直接比较类名(struct_ty 的 Name 可能无 SHA1 前缀)
|
||||
if string.strcmp(entry2.Name, ty_name) == 0:
|
||||
return entry2.Name
|
||||
# 最后回退: strstr 检查包含关系
|
||||
# ty_name 可能是 "SHA1.Counter",entry2.Name 是 "Counter"
|
||||
if string.strstr(ty_name, entry2.Name) is not None:
|
||||
return entry2.Name
|
||||
# 最后回退: 后缀匹配("SHA1.ClassName" 尾部)——比 strstr 子串
|
||||
# 匹配安全:特化名 "SHA1.GSList[Param]" 会被基础名 "GSList" 错误
|
||||
# 命中(子串),导致链式方法调用 class_name 解析错(如
|
||||
# func.Params.append → GSList.append 查找失败 → 兄弟 Mixin 兜底
|
||||
# 误匹配 LinkedNode.append,this 前移 sizeof(LinkedNode) 写穿
|
||||
# 容器前 48 字节,LLvmLiteTest Test 3 崩溃根因)。
|
||||
if entry2.Name is not None and string.strlen(entry2.Name) > 0:
|
||||
_tlen_cn: t.CSizeT = string.strlen(ty_name)
|
||||
_nlen_cn: t.CSizeT = string.strlen(entry2.Name)
|
||||
if _tlen_cn > _nlen_cn and ty_name[_tlen_cn - _nlen_cn - 1] == '.':
|
||||
_tail_ok_cn: int = 1
|
||||
_ti_cn: t.CSizeT
|
||||
for _ti_cn in range(_nlen_cn):
|
||||
if ty_name[_tlen_cn - _nlen_cn + _ti_cn] != entry2.Name[_ti_cn]:
|
||||
_tail_ok_cn = 0
|
||||
break
|
||||
if _tail_ok_cn == 1:
|
||||
return entry2.Name
|
||||
return None
|
||||
|
||||
def _extract_struct_name(self, ty: llvmlite.LLVMType | t.CPtr) -> str:
|
||||
|
||||
Reference in new issue
Block a user