fix(tpv): t.CArray/t.CPtr 下标元素解析失败改为返回 None 交多遍收敛
阶段2 删 map_t_type stdint 硬编码后,UINT 等 typedef 仅经 CTypedef 动态表解析;Phase 1a(declare_only=1)无 vpi 注入,依赖 typedef 的类(zhuff_code)被跳过,导致 t.CArray[zhuff_code, N] 元素解析被误 fatal 中断编译(zhuff.vp L19 根因)。与裸名 CArray 路径及 ClassGenDef 字段 pending 机制保持一致,真实类型错误由 Phase A 收敛检查暴露。
This commit is contained in:
1 parent
0a84ca8db3
commit
99ddff2d87
1 file changed
+20
-3
@@ -1805,7 +1805,15 @@ class TypeGenResolve(TypeGenBase.TypeGenBase):
|
||||
inner_cptr_ty: llvmlite.LLVMType | t.CPtr = self.resolve_annotation_type(
|
||||
pool, sub.slice, imported_modules, from_imports, trans, depth + 1)
|
||||
if inner_cptr_ty is None:
|
||||
self.Gen.TypeGenErr.fatal_type_error(sub.slice, "t.CPtr[?] 元素类型解析失败")
|
||||
# 元素类型依赖未就绪(如 t.CPtr[类] 中类尚未注册):返回 None
|
||||
# 交上层多遍收敛,不在此 fatal 中断 Phase 1a 预注册。
|
||||
# 根因:阶段2 删 map_t_type stdint 硬编码后,UINT 等只经 CTypedef
|
||||
# 动态表解析;Phase 1a(declare_only=1)无 vpi 注入 → 依赖 typedef
|
||||
# 的类(zhuff_code)被跳过 → t.CArray[t.CPtr?]/t.CPtr[类] 元素
|
||||
# 解析失败被误 fatal(zhuff.vp 根因)。与裸名 CArray 路径(L1760)
|
||||
# 及 ClassGenDef 字段 pending 机制保持一致;真实类型错误由 Phase A
|
||||
# 收敛检查暴露("Phase A 无法完成翻译")。
|
||||
return None
|
||||
return llvmlite.Ptr(pool, inner_cptr_ty)
|
||||
if string.strcmp(arr_at.attr, "CArray") != 0:
|
||||
self.Gen.TypeGenErr.fatal_type_error(node, "不支持的 Subscript 类型注解(仅支持 t.CArray / t.Callable)")
|
||||
@@ -1817,7 +1825,8 @@ class TypeGenResolve(TypeGenBase.TypeGenBase):
|
||||
elem_ty_single: llvmlite.LLVMType | t.CPtr = self.resolve_annotation_type(
|
||||
pool, sub.slice, imported_modules, from_imports, trans, depth + 1)
|
||||
if elem_ty_single is None:
|
||||
self.Gen.TypeGenErr.fatal_type_error(sub.slice, "t.CArray[?] 元素类型解析失败")
|
||||
# 元素类型依赖未就绪(同 L1807 注释):返回 None 交多遍收敛
|
||||
return None
|
||||
return llvmlite.Ptr(pool, elem_ty_single)
|
||||
# 双参数形式: t.CArray[elem_ty, count] → [count x elem_ty]
|
||||
tup: ast.Tuple | t.CPtr = (ast.Tuple | t.CPtr)(sub.slice)
|
||||
@@ -1835,7 +1844,15 @@ class TypeGenResolve(TypeGenBase.TypeGenBase):
|
||||
elem_ty: llvmlite.LLVMType | t.CPtr = self.resolve_annotation_type(
|
||||
pool, elem_node, imported_modules, from_imports, trans, depth + 1)
|
||||
if elem_ty is None:
|
||||
self.Gen.TypeGenErr.fatal_type_error(elem_node, "t.CArray 元素类型解析失败")
|
||||
# 元素类型依赖未就绪(如 t.CArray[类, N] 中类尚未注册):返回 None
|
||||
# 交上层多遍收敛,不在此 fatal 中断 Phase 1a 预注册。
|
||||
# 根因:阶段2 删 map_t_type stdint 硬编码后,UINT 等只经 CTypedef
|
||||
# 动态表解析;Phase 1a(declare_only=1)无 vpi 注入 → 依赖 typedef
|
||||
# 的类(zhuff_code)被跳过 → t.CArray[zhuff_code, N] 元素解析失败
|
||||
# 被误 fatal(zhuff.vp L19 根因)。与裸名 CArray 路径(L1760)及
|
||||
# ClassGenDef 字段 pending 机制保持一致;真实类型错误由 Phase A
|
||||
# 收敛检查暴露("Phase A 无法完成翻译")。
|
||||
return None
|
||||
# 解析 count(支持整数常量、None、CDefine 常量名、常量表达式如 2*MAX)
|
||||
# t.CArray[elem_ty, None] 等价于单参数形式 → Ptr(elem_ty)
|
||||
# t.CArray[elem_ty, NAME] 其中 NAME: t.CDefine = value → [value x elem_ty]
|
||||
|
||||
Reference in new issue
Block a user