fix(viperc): 支持多级模块路径的 typedef 强转(win32.win32base.LPCWSTR)
This commit is contained in:
1 parent
37c15c9aa0
commit
08fe5a7b6b
1 file changed
+15
-6
@@ -337,17 +337,26 @@ novirtual class CallGenDispatch(CallGenBase.CallGenBase):
|
||||
|
||||
def _tc_h4_type_casts(self, pool: memhub.MemBuddy*, builder: mlirlite.IRBuilder*, mod: mlirlite.LLVMModule*, cl: ast.Call*, funcs_ptr: rawptr, func_count: int, trans: HT.Translator*, func_name: str, cargs: list[ast.AST*]*, can: sizet) -> mlirlite.Value*:
|
||||
"""Builtin / typedef type casts; returns None when unmatched."""
|
||||
# Module-qualified typedef cast (posix.mode_t(mode), win32.win32base.HANDLE(v), ...): func is
|
||||
# Attribute(Name(module), typedef); non-typedef names still go to the module function call.
|
||||
# Module-qualified typedef cast (posix.mode_t(mode), win32.win32base.LPCWSTR(v), ...): the
|
||||
# callee is Attribute(<module path>, typedef); non-typedef names still go to the module call.
|
||||
if cl.func is not None and cl.func.kind() == ast.ASTKind.Attribute:
|
||||
mt_at: ast.Attribute* = ast.Attribute*(cl.func)
|
||||
if mt_at.value is not None and mt_at.value.kind() == ast.ASTKind.Name:
|
||||
mt_mod_nm: ast.Name* = ast.Name*(mt_at.value)
|
||||
if mt_mod_nm.id is not None:
|
||||
if mt_at.attr is not None:
|
||||
# Module path supports both `mod.T` and nested `pkg.mod.T`.
|
||||
mt_mod_path: str = None
|
||||
if mt_at.value is not None and mt_at.value.kind() == ast.ASTKind.Name:
|
||||
mt_mod_nm: ast.Name* = ast.Name*(mt_at.value)
|
||||
mt_mod_path = mt_mod_nm.id
|
||||
elif mt_at.value is not None and mt_at.value.kind() == ast.ASTKind.Attribute:
|
||||
mt_mod_path = self.Gen.ExprGenAttr._attr_module_path_str(pool, mt_at.value)
|
||||
if mt_mod_path is not None:
|
||||
mod_td_ty: mlirlite.LLVMType* = self.Gen.TypeGenResolve.map_builtin_type(pool, func_name)
|
||||
if mod_td_ty is None:
|
||||
mod_td_str: str = self.Gen.TypeGenCType.lookup_ctypedef(func_name)
|
||||
if mod_td_str is not None and self.Gen.TypeGenCType.is_ctypedef_found() != 0:
|
||||
if mod_td_str is None or self.Gen.TypeGenCType.is_ctypedef_found() == 0:
|
||||
# Library typedef closure may not be injected yet: scan the module source.
|
||||
mod_td_str = self.Gen.TypeGenResolve._lookup_library_typedef(pool, mt_mod_path, func_name)
|
||||
if mod_td_str is not None:
|
||||
mod_td_ast: ast.AST* = self.Gen.TypeGenResolve._parse_type_string(pool, mod_td_str, 0)
|
||||
if mod_td_ast is not None:
|
||||
mod_imp_td: str = None
|
||||
|
||||
Reference in new issue
Block a user