From d082bb39966fc42da1ca485451d76f244fae49c9 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Wed, 26 Aug 2026 23:40:22 +0800 Subject: [PATCH] =?UTF-8?q?debug(exprgenattr):=20=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E6=9F=A5=E6=89=BE=20arg/func=20=E6=97=B6=E6=89=93=E5=8D=B0=20a?= =?UTF-8?q?ttr/=E7=B1=BB=E5=9E=8B/=E7=B4=A2=E5=BC=95/=E5=AE=9E=E9=99=85?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D=EF=BC=8C=E5=AE=9A=E4=BD=8D=20Thread?= =?UTF-8?q?.arg=20=E7=B4=A2=E5=BC=95=E9=94=99=E8=A7=A3=E6=9E=90=E6=88=90?= =?UTF-8?q?=20func(3)=20=E6=A0=B9=E5=9B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Gen/ExprGenAttr.vp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/App/lib/core/Gen/ExprGenAttr.vp b/App/lib/core/Gen/ExprGenAttr.vp index 993cf4f..9ac1431 100644 --- a/App/lib/core/Gen/ExprGenAttr.vp +++ b/App/lib/core/Gen/ExprGenAttr.vp @@ -789,6 +789,18 @@ class ExprGenAttr(ExprGenBase.ExprGenBase): # 查找字段索引和类型 field_info: GenTypes.FieldEntry | t.CPtr = self.Gen.StructGen.lookup_field( struct_ty, at.attr) + # [GAP-DIAG] 定位 th.arg=arg 字段索引错(func/arg 都解析成 3)根因: + # 打印字段名/结构体类型名/查到的索引与实际字段名 + if field_info is not None \ + and (string.strcmp(at.attr, "arg") == 0 or string.strcmp(at.attr, "func") == 0): + dbg_gap: str = pool.alloc(200) + if dbg_gap is not None: + ty_nm_gap: str = self.Gen.StructGen._extract_struct_name(struct_ty) + if ty_nm_gap is None: + ty_nm_gap = "?" + viperlib.snprintf(dbg_gap, 200, "[GAP] attr=%s ty=%s idx=%d fe_name=%s\n", + at.attr, ty_nm_gap, field_info.Index, field_info.Name) + stdio.printf("%s", dbg_gap) # REnum 变体字段查找: lookup_field 失败时,尝试 REnum 别名 # REnum 结构体字段名是 _p1/_p2/...,但源码用变体字段名访问(如 ty.Pointee) if field_info is None: