fix(type): resolve_typedef_or_map 补齐裸内建别名,修复 int(x, t.CPtr) 类型解析

裸名 str/bytes/int/char/bool/float/double/void 在 map_t_type 中只有 t.CXXX 拼写,导致 _tc_h4 的双参指针包装分支拿不到 bare_ty,落回外部函数返回类型兜底并 fail-fast(argparse.vp:93 c.Deref(int(uint64(ptr), t.CPtr)) 报 TypeError: int)。
This commit is contained in:
TermiNexus committed 2026-10-05 14:14:29 +08:00
1 parent 0f4aeeceff
commit 87b24c2445
1 file changed
+11
+11
View File
@@ -840,6 +840,17 @@ novirtual class TypeGenResolve(TypeGenBase.TypeGenBase):
lib_ty: mlirlite.LLVMType* = self.resolve_annotation_type(pool, lib_node, imported_modules, from_imports, trans, 1)
self.Gen.TypeGenCType.CTypedefResolveDepth -= 1
if lib_ty is not None: return lib_ty
# Bare Python/C builtin aliases: map_t_type only knows the t.CXxx spelling, so
# resolve them here to match resolve_annotation_type's bare-name branch. Without
# this the two-arg form int(x, t.CPtr) misses _tc_h4 and fails fast as "int".
if string.strcmp(name, "str") == 0: return mlirlite.Ptr(pool, mlirlite.Int8(pool))
if string.strcmp(name, "bytes") == 0: return mlirlite.Ptr(pool, mlirlite.Int8(pool))
if string.strcmp(name, "int") == 0: return mlirlite.Int32(pool)
if string.strcmp(name, "char") == 0: return mlirlite.Int8(pool)
if string.strcmp(name, "bool") == 0: return mlirlite.Int1(pool)
if string.strcmp(name, "float") == 0: return mlirlite.Float(pool)
if string.strcmp(name, "double") == 0: return mlirlite.Double(pool)
if string.strcmp(name, "void") == 0: return mlirlite.Void(pool)
return self.map_t_type(pool, name)
def get_type_size_bytes(self, pool: memhub.MemBuddy*, name: str, imported_modules: str, from_imports: str) -> int:
"""Return the type size in bytes via resolve_typedef_or_map, or 0 on failure."""