diff --git a/App/lib/core/Gen/StmtGenMixin.vp b/App/lib/core/Gen/StmtGenMixin.vp index 38593eb..e8085db 100644 --- a/App/lib/core/Gen/StmtGenMixin.vp +++ b/App/lib/core/Gen/StmtGenMixin.vp @@ -255,14 +255,26 @@ class StmtGenMixin: trans._funcs, trans._func_count, trans) if ctx_val is None: continue - # 提取类名:Call(func=Attribute("memhub"."MemPool") / Name("MemPool")) + # 提取类名(注解类名,Attribute 时带模块前缀,如 "memhub.MemPool"—— + # 与 AnnAssign 的 extract_class_name_from_annotation 一致,跨模块 + # 方法调用靠 AnnotClassName 回退按模块名查 SHA1) cls_name: str = None ce: ast.AST | t.CPtr = item.context_expr if ce.kind() == ast.ASTKind.Call: cfn: ast.AST | t.CPtr = ((ast.Call | t.CPtr)(ce)).func if cfn is not None: if cfn.kind() == ast.ASTKind.Attribute: - cls_name = ((ast.Attribute | t.CPtr)(cfn)).attr + ca: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(cfn) + if ca.value is not None and ca.value.kind() == ast.ASTKind.Name: + cmn: ast.Name | t.CPtr = (ast.Name | t.CPtr)(ca.value) + if cmn.id is not None: + ml2: t.CSizeT = string.strlen(cmn.id) + string.strlen(ca.attr) + 2 + mbuf: str = pool.alloc(ml2) + if mbuf is not None: + viperlib.snprintf(mbuf, ml2, "%s.%s", cmn.id, ca.attr) + cls_name = mbuf + if cls_name is None: + cls_name = ca.attr elif cfn.kind() == ast.ASTKind.Name: cls_name = ((ast.Name | t.CPtr)(cfn)).id # context 对象存入 __with_ctx(方法调用解析 self 用)