diff --git a/App/lib/core/Gen/CallGenMixin.vp b/App/lib/core/Gen/CallGenMixin.vp index 76f8172..956211c 100644 --- a/App/lib/core/Gen/CallGenMixin.vp +++ b/App/lib/core/Gen/CallGenMixin.vp @@ -226,8 +226,30 @@ class CallGenMixin(CallGenBase.CallGenBase): # 用 find_struct_by_module 规避跨模块同名 find_struct 找错 struct_ty: llvmlite.LLVMType | t.CPtr = None gen_ctor_entry: GenTypes.StructEntry | t.CPtr = None + # 模块限定构造 Module.Class(...) 优先:按模块名解析 SHA1 精确命中类。 + # 必须在裸名可见性分支之前——跨模块同名类(VKernel gfx 与 App gfx 都 + # 定义 Scene3D)存在时,裸名 find_struct 返回先注册的错误 entry + # (0ae → ctor 生成 @0ae.Scene3D.__before_init__ → 链接 undefined + # symbol,Scene3D 根因)。模块解析成功即锁定,跳过下方裸名回退。 + mod_qual_done: int = 0 + if trans is not None and cl.func is not None and cl.func.kind() == ast.ASTKind.Attribute: + at_qc0: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(cl.func) + mod_path0: str = None + if at_qc0.value is not None and at_qc0.value.kind() == ast.ASTKind.Name: + mod_nm0: ast.Name | t.CPtr = (ast.Name | t.CPtr)(at_qc0.value) + if mod_nm0.id is not None: + mod_path0 = mod_nm0.id + elif at_qc0.value is not None and at_qc0.value.kind() == ast.ASTKind.Attribute: + mod_path0 = self.Gen.ExprGenAttr._attr_module_path_str(pool, at_qc0.value) + if mod_path0 is not None: + if self.Gen.ImportsGen.is_module_imported(trans._imported_modules, mod_path0) != 0: + mod_sha1_0: str = self._lookup_module_sha1(mod_path0) + if mod_sha1_0 is not None: + gen_ctor_entry = self.Gen.StructGen.find_struct_by_module( + func_name, mod_sha1_0) + mod_qual_done = 1 vis: int = self.Gen.StructGen.is_struct_visible(func_name) - if vis != 0: + if mod_qual_done == 0 and vis != 0: if trans is not None: gen_ctor_entry = self.Gen.StructGen.find_struct_by_module(func_name, trans.ModuleSha1) if gen_ctor_entry is None: