fix(translator,peephole): TPC 属性链解析修复与窥孔 T1-T3 收尾
- TPC(lib/core): 泛型父特化形参按声明类登记 var_struct_class; _find_struct_key 键归一支持方括号内嵌 sha 前缀; 字段探测失败不再冒泡 FuncGen fail-fast; cast 局部通用指针槽按静态类 bitcast; 属性解析失败附诊断 - 窥孔(includes/llvmlite/__function.vp): 窥孔移至 Renumber 前使输出 SSA 编号连续; T3 no-op bitcast 消除; T4(数组 bitcast->GEP)验证干扰返回类型收敛已移除 - 附调试打点与 1.log
This commit is contained in:
1 parent
76d1ee6076
commit
0bda395ecc
20 files changed
+103
-463
No files matched your search
@@ -1792,6 +1792,44 @@ class FunctionHandle(BaseHandle):
|
||||
found_struct: str | None = FindStructNameInAnnotation(arg.annotation, Gen.structs)
|
||||
if found_struct:
|
||||
Gen.var_struct_class[param_name] = found_struct
|
||||
# 普通类注解形参(非 BinOp 联合):rowptr[X] / t.CPtr[X] / X / t.X
|
||||
# 一律按"声明类"登记 var_struct_class。避免按 param.type.pointee 匹配
|
||||
# 到泛型父特化(如 class Function(GSListNode[Function]) 的形参 func 被
|
||||
# 登记成 GSListNode[Function],其 struct 仅含 Next → func.Blocks 访问
|
||||
# fast-fail "属性 'Blocks' 在类 'GSListNode[Function]' 中找不到")。
|
||||
# 泛型占位(rowptr[T])的 T 不在 Gen.structs,自动跳过、保留 pointee 匹配。
|
||||
for i, arg in enumerate(Node.args.args):
|
||||
if arg.annotation is None:
|
||||
continue
|
||||
if isinstance(arg.annotation, ast.BinOp) and isinstance(arg.annotation.op, ast.BitOr):
|
||||
continue # 联合注解由上方循环处理
|
||||
param_name = ParamNames[i] if i < len(ParamNames) else arg.arg
|
||||
if param_name not in Gen.variables:
|
||||
continue
|
||||
ann = arg.annotation
|
||||
target: str | None = None
|
||||
if isinstance(ann, ast.Name):
|
||||
target = ann.id
|
||||
elif isinstance(ann, ast.Attribute):
|
||||
target = ann.attr
|
||||
elif isinstance(ann, ast.Subscript):
|
||||
subv = ann.value
|
||||
subname = getattr(subv, 'id', None) or getattr(subv, 'attr', '')
|
||||
if subname in ('rowptr', 'CPtr', 'Ptr'):
|
||||
slc = ann.slice
|
||||
if isinstance(slc, ast.Name):
|
||||
target = slc.id
|
||||
elif isinstance(slc, ast.Attribute):
|
||||
target = slc.attr
|
||||
if not target:
|
||||
continue
|
||||
key: str | None = target if target in Gen.structs else None
|
||||
if key is None:
|
||||
_sha_t: str | None = (getattr(Gen, 'class_sha1_map', {}) or {}).get(target)
|
||||
if _sha_t and f'{_sha_t}.{target}' in Gen.structs:
|
||||
key = f'{_sha_t}.{target}'
|
||||
if key:
|
||||
Gen.var_struct_class[param_name] = key
|
||||
if ResolvedClassName and (IsMethod or RawFuncName == '__init__'):
|
||||
self.Trans._CurrentCpythonObjectClass = ResolvedClassName
|
||||
Gen._variadic_info = None
|
||||
|
||||
Reference in new issue
Block a user