fix(gentype): list[t.CPtr] 特化与 list[对象] elem_size 根本修复
两处根因:
1. list[t.CPtr] 报 Undefined method 'append':
- _resolve_generic_slice_type 对 t.CPtr 返回裸名 'CPtr',type_map['T']='CPtr'
替换进模板(item: CPtr)后 CPtr 不在顶层作用域 → append 声明注册失败
- 改保留带前缀 't.CPtr'(可解析)
- 查找端(SymbolUtils.FindStructNameInAnnotation)与声明端
(DeclarationGenerator)的 CPtr 统一规范化为 'ptr',与特化端
_mangle_generic_class_name 一致(list[CPtr]/list[i8*] vs list[ptr])
- _specialize_generic_class 的 cptr_params/class_type_names 判定改 tn_bare
2. list[对象] elem_size=0(get(0)==get(1) 同槽根因):
- T.__sizeof__() 特化后为 'X | t.CPtr'(BinOp 联合),_HandleSizeofLlvm
对 BinOp 落到 else 返回 0 → list.__elem_size__=0 → 元素全写同槽
- 改含 t.CPtr 的联合类型返回 8(指针大小)
This commit is contained in:
1 parent
e82640ac94
commit
2f0d52e736
5 files changed
+97
-23
No files matched your search
@@ -1209,6 +1209,12 @@ class DeclarationGenerator:
|
||||
if gc_args:
|
||||
gc_mangled: list[str] = []
|
||||
for gc_ta in gc_args:
|
||||
# t.CPtr/CPtr → 'ptr'(与 _resolve_type_arg_str 的
|
||||
# 泛型 mangling 一致);NameToLLVM('CPtr') 返回 'i8*'
|
||||
# 会导致声明端 'list[i8*]' 与特化端 'list[ptr]' 不匹配
|
||||
if gc_ta == 'CPtr':
|
||||
gc_mangled.append('ptr')
|
||||
continue
|
||||
gc_llvm: str | None = CTypeRegistry.NameToLLVM(gc_ta)
|
||||
if gc_llvm:
|
||||
if gc_llvm in ('float', 'double', 'half', 'fp128'):
|
||||
|
||||
Reference in new issue
Block a user