fix(symbol): 泛型实参归一仅识别内建短名

CInt/CInt32T/CFloat/CFloat64T 等 C 类型类名不再归一,按原名返回;仅内建短名归一为 int。
This commit is contained in:
TermiNexus committed 2026-10-18 13:49:39 +08:00
1 parent 5157ce2996
commit 3c20d49c4a
1 file changed
+2 -22
+2 -22
View File
@@ -2713,16 +2713,6 @@ def IsPtrSubscriptNode(node: ast.AST, symtable: object | None = None,
_GENERIC_ARG_INT_NAMES: frozenset[str] = frozenset({
'CInt', 'CChar', 'CShort', 'CLong', 'CLongLong',
'CUnsigned', 'CUnsignedChar', 'CUnsignedInt', 'CUnsignedShort',
'CUnsignedLong', 'CUnsignedLongLong', 'CSignedChar', 'CBool',
'CInt8T', 'CInt16T', 'CInt32T', 'CInt64T',
'CUInt8T', 'CUInt16T', 'CUInt32T', 'CUInt64T',
'CIntFast8T', 'CIntFast16T', 'CIntFast32T', 'CIntFast64T',
'CUIntFast8T', 'CUIntFast16T', 'CUIntFast32T', 'CUIntFast64T',
'CIntLeast8T', 'CIntLeast16T', 'CIntLeast32T', 'CIntLeast64T',
'CUIntLeast8T', 'CUIntLeast16T', 'CUIntLeast32T', 'CUIntLeast64T',
'CSizeT', 'CIntPtrT', 'CUIntPtrT', 'CPtrDiffT',
'int8', 'int16', 'int32', 'int64',
'uint8', 'uint16', 'uint32', 'uint64',
'intfast8', 'intfast16', 'intfast32', 'intfast64',
@@ -2733,17 +2723,9 @@ _GENERIC_ARG_INT_NAMES: frozenset[str] = frozenset({
'long', 'ulong', 'longlong', 'ulonglong', 'ptrdifft',
})
_GENERIC_ARG_FLOAT_NAMES: frozenset[str] = frozenset({
'CFloat', 'CDouble', 'CFloat8T', 'CFloat16T',
'CFloat32T', 'CFloat64T', 'CFloat128T',
})
def NormalizeGenericArgName(NameId: str) -> str:
"""ast.Name 泛型实参 → 定义端 type_arg(HandlesExprCall._resolve_generic_slice_type
的 ast.Name 分支,逐分支同构):
int/double/float 保留源码名('list[int]' 而非 'list[i32]')、
char/bool → 'i8'、C 整数族 → 'int'、C 浮点族 → 'double'、其余原名。
"""泛型实参名归一:int/double/float 保留,char/bool → 'i8',
内建整数短名 → 'int',其余原样返回。
"""
if NameId in ('int', 'double', 'float'):
return NameId
@@ -2751,8 +2733,6 @@ def NormalizeGenericArgName(NameId: str) -> str:
return 'i8'
if NameId in _GENERIC_ARG_INT_NAMES:
return 'int'
if NameId in _GENERIC_ARG_FLOAT_NAMES:
return 'double'
return NameId