修正了种子编译器的错误
This commit is contained in:
@@ -652,7 +652,17 @@ class FunctionHandle(BaseHandle):
|
||||
ParamTypeInfo.ArrayDims = []
|
||||
ParamTypeInfo.PtrCount = max(ParamTypeInfo.PtrCount, 1)
|
||||
ParamType: ir.Type = Gen._ctype_to_llvm(ParamTypeInfo)
|
||||
# 参数类型不能是 VoidType:C 语言不允许 void 参数,
|
||||
# VoidType 说明类型注解无法识别(如跨模块 ast.expr),直接报错终止
|
||||
if isinstance(ParamType, ir.VoidType):
|
||||
AnnStr: str = ast.unparse(Arg.annotation) if hasattr(ast, 'unparse') else str(Arg.annotation)
|
||||
raise SyntaxError(
|
||||
f"无法识别的参数类型注解: '{AnnStr}'(在函数 '{Node.name}' 的参数 '{Arg.arg}' 上)。"
|
||||
f"请使用有效的 TPV 类型(如 t.CPtr、ast.AST 或已注册的结构体)。"
|
||||
)
|
||||
ParamTypeStr: Any = ParamTypeInfo
|
||||
except SyntaxError:
|
||||
raise
|
||||
except Exception as e:
|
||||
ParamType = ir.IntType(32)
|
||||
ParamTypeStr = CTypeInfo()
|
||||
@@ -1402,9 +1412,19 @@ class FunctionHandle(BaseHandle):
|
||||
ParamTypeInfo.ArrayDims = []
|
||||
ParamTypeInfo.PtrCount = max(ParamTypeInfo.PtrCount, 1)
|
||||
ParamType = Gen._ctype_to_llvm(ParamTypeInfo)
|
||||
# 参数类型不能是 VoidType:C 语言不允许 void 参数,
|
||||
# VoidType 说明类型注解无法识别(如跨模块 ast.expr),直接报错终止
|
||||
if isinstance(ParamType, ir.VoidType):
|
||||
AnnStr: str = ast.unparse(Arg.annotation) if hasattr(ast, 'unparse') else str(Arg.annotation)
|
||||
raise SyntaxError(
|
||||
f"无法识别的参数类型注解: '{AnnStr}'(在函数 '{Node.name}' 的参数 '{Arg.arg}' 上)。"
|
||||
f"请使用有效的 TPV 类型(如 t.CPtr、ast.AST 或已注册的结构体)。"
|
||||
)
|
||||
if ParamTypeInfo and ParamTypeInfo.IsFuncPtr:
|
||||
ParamType = ir.IntType(8).as_pointer()
|
||||
ParamIsUnsigned = ParamTypeInfo.IsUInt
|
||||
except SyntaxError:
|
||||
raise
|
||||
except Exception: # 回退:参数类型解析失败时使用默认 i32
|
||||
ParamType = ir.IntType(32)
|
||||
ParamTypeInfo = CTypeInfo()
|
||||
|
||||
Reference in New Issue
Block a user