diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index fa62e401..a37e7b2d 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -21114,7 +21114,7 @@ fn cgtagvariantidx(c: *cgen, tagged: *node, vt: *node) i32 = { // scrutinee shape, so the AST-keyed -1 here was a silent // tag-0 clamp on wwstage (cs CMPQ $1 vs ww CMPQ $0). let sti: *tinfo = tagged.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); if (sti != nil && sti.kind == tykind.TY_TAGGED && vt.type_ != nil) { return flatvariantidxt(sti, vt.type_: *tinfo); }; @@ -21141,12 +21141,12 @@ fn cgtagvariantidx(c: *cgen, tagged: *node, vt: *node) i32 = { fn cgtrytupleshift(c: *cgen, n: *node) bool = { if (n.lhs == nil) { return false; }; let ou: *tinfo = n.lhs.type_: *tinfo; - for (ou != nil && ou.kind == tykind.TY_NAMED) { ou = ou.under; }; + ou = tichase(ou); if (ou == nil) { return false; }; if (ou.kind != tykind.TY_TAGGED) { return false; }; if (ou.params == nil) { return false; }; let sv: *tinfo = ou.params.type_; - for (sv != nil && sv.kind == tykind.TY_NAMED) { sv = sv.under; }; + sv = tichase(sv); if (sv == nil) { return false; }; if (sv.kind != tykind.TY_TUPLE) { return false; }; cgtaggedtuplepayloadshift(c, sv); @@ -21164,12 +21164,12 @@ fn cgtrytupleshift(c: *cgen, n: *node) bool = { fn cgtrytaggedshift(c: *cgen, n: *node) bool = { if (n.lhs == nil) { return false; }; let ou: *tinfo = n.lhs.type_: *tinfo; - for (ou != nil && ou.kind == tykind.TY_NAMED) { ou = ou.under; }; + ou = tichase(ou); if (ou == nil) { return false; }; if (ou.kind != tykind.TY_TAGGED) { return false; }; if (ou.params == nil) { return false; }; let sv: *tinfo = ou.params.type_; - for (sv != nil && sv.kind == tykind.TY_NAMED) { sv = sv.under; }; + sv = tichase(sv); if (sv == nil) { return false; }; if (sv.kind != tykind.TY_TAGGED) { return false; }; if (sv.nullable != 0) { return false; }; @@ -21189,7 +21189,7 @@ fn cgtrytaggedshift(c: *cgen, n: *node) bool = { fn cgtryunwcursor(c: *cgen, n: *node, opname: str) void = { let u: *tinfo = nil; if (n.lhs != nil) { u = n.lhs.type_: *tinfo; }; - for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; }; + u = tichase(u); let utag: bool = false; if (u != nil) { if (u.kind == tykind.TY_TAGGED && u.nullable == 0) { @@ -21293,10 +21293,10 @@ fn cgtryprop(c: *cgen, n: *node) void = { // itself → zero instructions, byte-id with the pre-#173 emit. let u: *tinfo = nil; if (n.lhs != nil) { u = n.lhs.type_: *tinfo; }; - for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; }; + u = tichase(u); let r: *tinfo = nil; if (c.fnret != nil) { r = c.fnret.type_: *tinfo; }; - for (r != nil && r.kind == tykind.TY_NAMED) { r = r.under; }; + r = tichase(r); if (u != nil && r != nil && r.kind == tykind.TY_TAGGED && u.params != nil) { let propret: str; propret.ptr = nil; propret.len = 0; @@ -21518,9 +21518,7 @@ fn cgtypetest(c: *cgen, n: *node) void = { // cast source — loud. Mirrors cstage. { let icu: *tinfo = lhs.type_: *tinfo; - for (icu != nil && icu.kind == tykind.TY_NAMED) { - icu = icu.under; - }; + icu = tichase(icu); if (lhs.kind == nkind.N_CAST && icu != nil && icu.kind == tykind.TY_TAGGED && icu.nullable == 0) { @@ -21711,9 +21709,7 @@ fn cgtypeassert(c: *cgen, n: *node) void = { // cast source — loud. Mirrors cstage. { let acu: *tinfo = lhs.type_: *tinfo; - for (acu != nil && acu.kind == tykind.TY_NAMED) { - acu = acu.under; - }; + acu = tichase(acu); if (lhs.kind == nkind.N_CAST && acu != nil && acu.kind == tykind.TY_TAGGED && acu.nullable == 0) { @@ -21937,7 +21933,7 @@ fn cgident(c: *cgen, n: *node) void = { // just word0 in AX. Mirror of cstage cgexpr N_IDENT tuple arm. let itu: *tinfo = nil; if (lc.tnode != nil) { itu = lc.tnode.type_: *tinfo; }; - for (itu != nil && itu.kind == tykind.TY_NAMED) { itu = itu.under; }; + itu = tichase(itu); if (itu != nil) { if (itu.kind == tykind.TY_TUPLE) { cgtupleslottocursor(c, off, itu); return; @@ -22189,13 +22185,13 @@ fn dotchainaddr(c: *cgen, n: *node, dstreg: str) bool = { let x: *node = n.lhs; if (x == nil) { return false; }; let xu: *tinfo = x.type_: *tinfo; - for (xu != nil && xu.kind == tykind.TY_NAMED) { xu = xu.under; }; + xu = tichase(xu); if (xu == nil) { return false; }; let xviaptr: bool = false; let st: *tinfo = nil; if (xu.kind == tykind.TY_PTR) { let p: *tinfo = xu.sub; - for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; }; + p = tichase(p); if (p != nil) { if (p.kind == tykind.TY_STRUCT) { st = p; xviaptr = true; @@ -22288,13 +22284,13 @@ fn dotbaseaddr(c: *cgen, base: *node, dstreg: str) bool = { }; }; let bu: *tinfo = inner.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; let viaptr: bool = false; let structt: *tinfo = nil; if (bu.kind == tykind.TY_PTR) { let st: *tinfo = bu.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { structt = st; viaptr = true; @@ -22319,7 +22315,7 @@ fn dotbaseaddr(c: *cgen, base: *node, dstreg: str) bool = { // the existing cgexpr(base) path correctly loads the pointer/ // header value; over-firing here would skip the deref. Cstage // twin gate at cg_dotbase_addr. - for (ft != nil && ft.kind == tykind.TY_NAMED) { ft = ft.under; }; + ft = tichase(ft); if (ft == nil) { return false; }; if (ft.kind != tykind.TY_ARRAY) { return false; }; // #253: chained inner — compute the container base via the dot-chain @@ -22436,7 +22432,7 @@ fn aggargsrcaddr(c: *cgen, src: *node, dst: str) bool = { if (base == nil) { return false; }; if (base.kind != nkind.N_IDENT) { return false; }; let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; if (bu.kind != tykind.TY_ARRAY) { return false; }; let esz: i32 = 1; @@ -22581,13 +22577,13 @@ fn cgplaceaddr(c: *cgen, n: *node, dstreg: str) bool = { // enumerated arms never reach the resolver (those arms // dispatch first), so their asm is untouched. let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; if (bu.kind != tykind.TY_SLICE && bu.kind != tykind.TY_ARRAY) { return false; }; let et: *tinfo = n.type_: *tinfo; - for (et != nil && et.kind == tykind.TY_NAMED) { et = et.under; }; + et = tichase(et); if (et == nil) { return false; }; let esz: i32 = et.size: i32; cgexpr(c, idx); @@ -22619,13 +22615,13 @@ fn cgplaceaddr(c: *cgen, n: *node, dstreg: str) bool = { let base: *node = n.lhs; if (base == nil) { return false; }; let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; let viaptr: bool = false; let st: *tinfo = nil; if (bu.kind == tykind.TY_PTR) { let p: *tinfo = bu.sub; - for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; }; + p = tichase(p); if (p != nil) { if (p.kind == tykind.TY_STRUCT) { st = p; viaptr = true; @@ -23259,9 +23255,7 @@ fn cgslice(c: *cgen, n: *node) void = { let dotbu: *tinfo = nil; if (base != nil) { if (base.kind == nkind.N_DOT) { dotbu = base.type_: *tinfo; - for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) { - dotbu = dotbu.under; - }; + dotbu = tichase(dotbu); };}; // #31: an N_ARRLIT base (the desugared one-step `let xs:[]T=[..]` // borrow — the ONLY context that reaches here; call-arg/return/assign @@ -23590,9 +23584,7 @@ fn cgmatch(c: *cgen, n: *node) void = { // to match. Surfaced by reviewer-37's `match (*p)` // probe on a 56B box. let ms37: *tinfo = scrut.type_: *tinfo; - for (ms37 != nil && ms37.kind == tykind.TY_NAMED) { - ms37 = ms37.under; - }; + ms37 = tichase(ms37); if (ms37 != nil && ms37.kind == tykind.TY_TAGGED && ms37.size: i32 > TUPLE_GPCAP * 8) { let m37n: str = "#37: >32B tagged match scrutinee from a non-mem-based source unwired (rule 7)\n"; @@ -24464,13 +24456,13 @@ fn cgdot(c: *cgen, n: *node) void = { if (idxbase != nil) { if (idxbase.kind == nkind.N_IDENT) { let elemt: *tinfo = lhs.type_: *tinfo; let elemu: *tinfo = elemt; - for (elemu != nil && elemu.kind == tykind.TY_NAMED) { elemu = elemu.under; }; + elemu = tichase(elemu); let st: *tinfo = nil; let viaptr: bool = false; if (elemu != nil) { if (elemu.kind == tykind.TY_PTR) { let pin: *tinfo = elemu.sub; - for (pin != nil && pin.kind == tykind.TY_NAMED) { pin = pin.under; }; + pin = tichase(pin); if (pin != nil) { if (pin.kind == tykind.TY_STRUCT) { st = pin; viaptr = true; @@ -24487,7 +24479,7 @@ fn cgdot(c: *cgen, n: *node) void = { fwalk = fwalk.tnext; }; let bu: *tinfo = idxbase.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); let baseisarray: bool = false; let baseok: bool = false; if (bu != nil) { @@ -24556,7 +24548,7 @@ fn cgdot(c: *cgen, n: *node) void = { let foff: i64 = fnd.offset: i64; let ft: *tinfo = fnd.type_; let fu: *tinfo = ft; - for (fu != nil && fu.kind == tykind.TY_NAMED) { fu = fu.under; }; + fu = tichase(fu); // #270-1a: an `[N]T`-typed field of an // array element (`a[i].m[j]`) — leave the // field's ADDRESS, a base for the outer @@ -24743,9 +24735,7 @@ fn cgdot(c: *cgen, n: *node) void = { // registers (ken x5c: o.r.min as size added DX). if (typeistagged(leaftype)) { let tlu: *tinfo = leaftype; - for (tlu != nil && tlu.kind == tykind.TY_NAMED) { - tlu = tlu.under; - }; + tlu = tichase(tlu); let ttsz: i32 = tlu.size: i32; if (viacx) { if (ptrroot) { @@ -24899,7 +24889,7 @@ fn cgdot(c: *cgen, n: *node) void = { { let pbu: *tinfo = nil; if (lhs != nil) { pbu = lhs.type_: *tinfo; }; - for (pbu != nil && pbu.kind == tykind.TY_NAMED) { pbu = pbu.under; }; + pbu = tichase(pbu); let pbok: bool = false; if (pbu != nil) { if (pbu.kind == tykind.TY_SLICE @@ -24968,11 +24958,11 @@ fn cgdot(c: *cgen, n: *node) void = { let allptr: bool = true; for (croot != nil && croot.kind == nkind.N_DOT) { let ct: *tinfo = croot.type_: *tinfo; - for (ct != nil && ct.kind == tykind.TY_NAMED) { ct = ct.under; }; + ct = tichase(ct); let okp: bool = false; if (ct != nil) { if (ct.kind == tykind.TY_PTR) { let cs: *tinfo = ct.sub; - for (cs != nil && cs.kind == tykind.TY_NAMED) { cs = cs.under; }; + cs = tichase(cs); if (cs != nil) { if (cs.kind == tykind.TY_STRUCT) { okp = true; }; }; }; }; if (!okp) { allptr = false; }; @@ -24983,10 +24973,10 @@ fn cgdot(c: *cgen, n: *node) void = { localfindnode(c, croot.str) != nil) { it = lhs.type_: *tinfo; }; - for (it != nil && it.kind == tykind.TY_NAMED) { it = it.under; }; + it = tichase(it); if (it != nil) { if (it.kind == tykind.TY_PTR) { let st: *tinfo = it.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { let tf: *tfield = st.fields; for (tf != nil) { @@ -25001,9 +24991,7 @@ fn cgdot(c: *cgen, n: *node) void = { // scalar tail read stale DX as payload). if (typeistagged(ft)) { let plu: *tinfo = ft; - for (plu != nil && plu.kind == tykind.TY_NAMED) { - plu = plu.under; - }; + plu = tichase(plu); emitline("\tMOVQ\tAX, BX\n"); cgloadtaggedfield(c, "BX", tf.offset: i32, @@ -25200,7 +25188,7 @@ fn cgdot(c: *cgen, n: *node) void = { if (lhs != nil) { if (lhs.kind == nkind.N_DOT) { let pgu: *tinfo = lhs.type_: *tinfo; - for (pgu != nil && pgu.kind == tykind.TY_NAMED) { pgu = pgu.under; }; + pgu = tichase(pgu); if (pgu != nil) { if (pgu.kind == tykind.TY_PTR) { let mp: str = "cgdot: ptr-chained field read unwired in wwstage (task #37)\n"; @@ -25221,7 +25209,7 @@ fn cgdot(c: *cgen, n: *node) void = { { let rdt: *tinfo = n.type_: *tinfo; let rdu: *tinfo = rdt; - for (rdu != nil && rdu.kind == tykind.TY_NAMED) { rdu = rdu.under; }; + rdu = tichase(rdu); if (rdu != nil) { if (rdu.kind == tykind.TY_TAGGED) { let mt: str = "read-resolver: tagged field read not wired (rule-7)\n"; @@ -25751,7 +25739,7 @@ fn cgun(c: *cgen, n: *node) void = { // pulled a[0]'s VALUE and `(*p)[i]` then dereferenced it as // the index base — a wild pointer, SIGSEGV on both stages. let rti: *tinfo = n.type_: *tinfo; - for (rti != nil && rti.kind == tykind.TY_NAMED) { rti = rti.under; }; + rti = tichase(rti); if (rti != nil && rti.kind == tykind.TY_FN) { return; }; if (rti != nil && rti.kind == tykind.TY_ARRAY) { return; }; // Family C (#35/#46): a tagged box behind *p joins the @@ -26280,7 +26268,7 @@ fn cgappend(c: *cgen, n: *node) void = { // same source cstage reads (sn->type → su->sub->size). sti = sn.type_: *tinfo; let fsti: *tinfo = sti; - for (fsti != nil && fsti.kind == tykind.TY_NAMED) { fsti = fsti.under; }; + fsti = tichase(fsti); if (fsti != nil && fsti.sub != nil) { esz = fsti.sub.size: i32; }; if (esz <= 0) { let m15z: str = "#15: append() target element size unresolved (rule-7)\n"; @@ -26295,16 +26283,14 @@ fn cgappend(c: *cgen, n: *node) void = { // the value node's literal tinfo is the #25/#31 esz=0 trap. // Mirrors cstage cgen.c's append arm + the #270/#12/#20 // array-literal element dispatch (cgarrlitfillbp). - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esubti: *tinfo = nil; if (sti != nil) { esubti = sti.sub; }; // FA1: pre-peel handle — the indirect struct-lit fill keys its // structinfo off the NAMED element tinfo's name (the same leaf // structlookupchain resolves from the declared tnode). let esubnamed: *tinfo = esubti; - for (esubti != nil && esubti.kind == tykind.TY_NAMED) { - esubti = esubti.under; - }; + esubti = tichase(esubti); let elstr: bool = esubti != nil && esubti.kind == tykind.TY_STR; let elslice: bool = esubti != nil && esubti.kind == tykind.TY_SLICE; let eltagged: bool = esubti != nil && esubti.kind == tykind.TY_TAGGED; @@ -26351,7 +26337,7 @@ fn cgappend(c: *cgen, n: *node) void = { // shares the slice header layout. let itu: *tinfo = nil; if (it != nil) { itu = it.type_: *tinfo; }; - for (itu != nil && itu.kind == tykind.TY_NAMED) { itu = itu.under; }; + itu = tichase(itu); if (itu == nil || (itu.kind != tykind.TY_SLICE && itu.kind != tykind.TY_STR)) { let m35p: str = "#35: append() spread source shape unsupported (rule-7)\n"; @@ -26586,7 +26572,7 @@ fn cgappend(c: *cgen, n: *node) void = { let af: *tfield = nil; if (ab != nil) { let abu: *tinfo = ab.type_: *tinfo; - for (abu != nil && abu.kind == tykind.TY_NAMED) { abu = abu.under; }; + abu = tichase(abu); if (abu != nil && abu.kind == tykind.TY_STRUCT) { let fl: *tfield = abu.fields; for (fl != nil) { @@ -26602,11 +26588,11 @@ fn cgappend(c: *cgen, n: *node) void = { if (aok && ch.kind == nkind.N_INDEX) { let ab: *node = ch.lhs; let aet: *tinfo = ch.type_: *tinfo; - for (aet != nil && aet.kind == tykind.TY_NAMED) { aet = aet.under; }; + aet = tichase(aet); let abu: *tinfo = nil; if (ab != nil) { abu = ab.type_: *tinfo; - for (abu != nil && abu.kind == tykind.TY_NAMED) { abu = abu.under; }; + abu = tichase(abu); }; if (ab == nil || abu == nil || aet == nil || (abu.kind != tykind.TY_SLICE && abu.kind != tykind.TY_ARRAY)) { @@ -26889,10 +26875,10 @@ fn cgdelete(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -27021,10 +27007,10 @@ fn cgdeleterange(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -27220,10 +27206,10 @@ fn cginsert(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -27537,9 +27523,7 @@ fn cgcall(c: *cgen, n: *node) void = { let a: *node = n.list; let at: *tinfo = a.type_: *tinfo; let u: *tinfo = at; - for (u != nil && u.kind == tykind.TY_NAMED) { - u = u.under; - }; + u = tichase(u); let hdrish: bool = false; if (u != nil) { if (u.kind == tykind.TY_SLICE @@ -28412,9 +28396,7 @@ fn cgassign(c: *cgen, n: *node) void = { && n.op == tkind.TK_ASSIGN && n.rhs != nil) { if (n.rhs.kind == nkind.N_STRUCTLIT) { let iet: *tinfo = lhs.type_: *tinfo; - for (iet != nil && iet.kind == tykind.TY_NAMED) { - iet = iet.under; - }; + iet = tichase(iet); if (iet != nil) { if (iet.kind == tykind.TY_STRUCT) { placeslit = true; @@ -28434,9 +28416,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (lhs.kind == nkind.N_UN && lhs.op == tkind.TK_STAR && n.op == tkind.TK_ASSIGN) { let du: *tinfo = lhs.type_: *tinfo; - for (du != nil && du.kind == tykind.TY_NAMED) { - du = du.under; - }; + du = tichase(du); if (du != nil) { if (du.kind == tykind.TY_STRUCT || du.kind == tykind.TY_ARRAY @@ -28467,9 +28447,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (n.op == tkind.TK_ASSIGN && lhs != nil && n.rhs != nil) { if (n.rhs.kind == nkind.N_ARRLIT) { let alt: *tinfo = lhs.type_: *tinfo; - for (alt != nil && alt.kind == tykind.TY_NAMED) { - alt = alt.under; - }; + alt = tichase(alt); if (alt != nil) { if (alt.kind == tykind.TY_ARRAY) { let mal: str = "array-literal store at assignment unwired (task #32)\n"; @@ -28504,13 +28482,9 @@ fn cgassign(c: *cgen, n: *node) void = { }; if (asret > 0) { let aru: *tinfo = n.rhs.type_: *tinfo; - for (aru != nil && aru.kind == tykind.TY_NAMED) { - aru = aru.under; - }; + aru = tichase(aru); let alu: *tinfo = lc.tnode.type_: *tinfo; - for (alu != nil && alu.kind == tykind.TY_NAMED) { - alu = alu.under; - }; + alu = tichase(alu); let aexact: bool = false; if (aru != nil && aru == alu) { aexact = true; } else { @@ -28540,9 +28514,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (lc == nil && n.rhs != nil) { if (n.rhs.kind == nkind.N_CALL) { let gru: *tinfo = lhs.type_: *tinfo; - for (gru != nil && gru.kind == tykind.TY_NAMED) { - gru = gru.under; - }; + gru = tichase(gru); if (gru != nil && gru.kind == tykind.TY_TAGGED && callsretsize(c, n.rhs) > 0) { let m38g: str = "#38b: sret receive into a tagged GLOBAL lvalue unwired\n"; @@ -30539,11 +30511,11 @@ fn cgassign(c: *cgen, n: *node) void = { let allptr: bool = true; for (croot != nil && croot.kind == nkind.N_DOT) { let ct: *tinfo = croot.type_: *tinfo; - for (ct != nil && ct.kind == tykind.TY_NAMED) { ct = ct.under; }; + ct = tichase(ct); let okp: bool = false; if (ct != nil) { if (ct.kind == tykind.TY_PTR) { let cs: *tinfo = ct.sub; - for (cs != nil && cs.kind == tykind.TY_NAMED) { cs = cs.under; }; + cs = tichase(cs); if (cs != nil) { if (cs.kind == tykind.TY_STRUCT) { okp = true; }; }; }; }; if (!okp) { allptr = false; }; @@ -30554,10 +30526,10 @@ fn cgassign(c: *cgen, n: *node) void = { localfindnode(c, croot.str) != nil) { it = base.type_: *tinfo; }; - for (it != nil && it.kind == tykind.TY_NAMED) { it = it.under; }; + it = tichase(it); if (it != nil) { if (it.kind == tykind.TY_PTR) { let st: *tinfo = it.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { let tf: *tfield = st.fields; for (tf != nil) { @@ -30574,9 +30546,7 @@ fn cgassign(c: *cgen, n: *node) void = { // landed in the TAG slot (ken b8). if (typeistagged(ft)) { let flu: *tinfo = ft; - for (flu != nil && flu.kind == tykind.TY_NAMED) { - flu = flu.under; - }; + flu = tichase(flu); cgexpr(c, base); emitline("\tMOVQ\tAX, BX\n"); cgwidentaggedstore(c, flu, n.rhs, @@ -30801,9 +30771,7 @@ fn cgassign(c: *cgen, n: *node) void = { // (TK_ASSIGN gate above). if (typeistagged(leaftype)) { let wlu: *tinfo = leaftype; - for (wlu != nil && wlu.kind == tykind.TY_NAMED) { - wlu = wlu.under; - }; + wlu = tichase(wlu); let wtsz: i32 = wlu.size: i32; if (viacx) { if (ptrroot) { @@ -30889,9 +30857,7 @@ fn cgassign(c: *cgen, n: *node) void = { let leafname: str = ""; if (leaftype != nil) { let lp: *tinfo = leaftype; - for (lp != nil && lp.kind == tykind.TY_NAMED) { - lp = lp.under; - }; + lp = tichase(lp); if (lp != nil) { if (lp.kind == tykind.TY_STRUCT) { leafstruct = true; }; }; @@ -31366,7 +31332,7 @@ fn cgassign(c: *cgen, n: *node) void = { }; if (lvftn.kind == nkind.N_TARRAY) { let gat: *tinfo = lvftn.type_: *tinfo; - for (gat != nil && gat.kind == tykind.TY_NAMED) { gat = gat.under; }; + gat = tichase(gat); if (gat != nil) { gsz = gat.size: i32; }; }; if (gsz > 24) { @@ -31395,7 +31361,7 @@ fn cgassign(c: *cgen, n: *node) void = { && lvftn.kind == nkind.N_TARRAY) { let aggsz: i32 = 0; let aat: *tinfo = lvftn.type_: *tinfo; - for (aat != nil && aat.kind == tykind.TY_NAMED) { aat = aat.under; }; + aat = tichase(aat); if (aat != nil) { aggsz = aat.size: i32; }; if (aggsz > 0 && aggsz <= 24) { cgexpr(c, n.rhs); @@ -31438,9 +31404,7 @@ fn cgassign(c: *cgen, n: *node) void = { // tail below: one MOVQ AX, g(SB). if (n.op == tkind.TK_ASSIGN && lvftn != nil) { let gau: *tinfo = lvftn.type_: *tinfo; - for (gau != nil && gau.kind == tykind.TY_NAMED) { - gau = gau.under; - }; + gau = tichase(gau); if (gau != nil) { if (gau.kind == tykind.TY_STRUCT || gau.kind == tykind.TY_ARRAY @@ -31749,9 +31713,7 @@ fn cgassign(c: *cgen, n: *node) void = { && n.rhs != nil && n.rhs.kind == nkind.N_CALL) { let acati: *tinfo = nil; if (lcn.tnode != nil) { acati = lcn.tnode.type_: *tinfo; }; - for (acati != nil && acati.kind == tykind.TY_NAMED) { - acati = acati.under; - }; + acati = tichase(acati); if (acati != nil && acati.kind == tykind.TY_ARRAY) { let lcsz: i32 = acati.size: i32; if (lcsz > 24) { @@ -31872,9 +31834,7 @@ fn cgassign(c: *cgen, n: *node) void = { agu = lcn.tnode.type_: *tinfo; }; }; - for (agu != nil && agu.kind == tykind.TY_NAMED) { - agu = agu.under; - }; + agu = tichase(agu); if (agu != nil) { if (agu.kind == tykind.TY_STRUCT || agu.kind == tykind.TY_ARRAY @@ -32036,9 +31996,7 @@ fn cgassign(c: *cgen, n: *node) void = { || (lhs.kind == nkind.N_UN && lhs.op == tkind.TK_STAR)) { let ft: *tinfo = lhs.type_: *tinfo; let fu: *tinfo = ft; - for (fu != nil && fu.kind == tykind.TY_NAMED) { - fu = fu.under; - }; + fu = tichase(fu); let fsz: i32 = 8; if (ft != nil) { fsz = ft.size: i32; }; if (typeisfloat(ft)) { diff --git a/selfhost/cmd/wcc/cgenexpr.ww b/selfhost/cmd/wcc/cgenexpr.ww index b6205d0a..99a19026 100644 --- a/selfhost/cmd/wcc/cgenexpr.ww +++ b/selfhost/cmd/wcc/cgenexpr.ww @@ -144,7 +144,7 @@ fn cgtagvariantidx(c: *cgen, tagged: *node, vt: *node) i32 = { // scrutinee shape, so the AST-keyed -1 here was a silent // tag-0 clamp on wwstage (cs CMPQ $1 vs ww CMPQ $0). let sti: *tinfo = tagged.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); if (sti != nil && sti.kind == tykind.TY_TAGGED && vt.type_ != nil) { return flatvariantidxt(sti, vt.type_: *tinfo); }; @@ -171,12 +171,12 @@ fn cgtagvariantidx(c: *cgen, tagged: *node, vt: *node) i32 = { fn cgtrytupleshift(c: *cgen, n: *node) bool = { if (n.lhs == nil) { return false; }; let ou: *tinfo = n.lhs.type_: *tinfo; - for (ou != nil && ou.kind == tykind.TY_NAMED) { ou = ou.under; }; + ou = tichase(ou); if (ou == nil) { return false; }; if (ou.kind != tykind.TY_TAGGED) { return false; }; if (ou.params == nil) { return false; }; let sv: *tinfo = ou.params.type_; - for (sv != nil && sv.kind == tykind.TY_NAMED) { sv = sv.under; }; + sv = tichase(sv); if (sv == nil) { return false; }; if (sv.kind != tykind.TY_TUPLE) { return false; }; cgtaggedtuplepayloadshift(c, sv); @@ -194,12 +194,12 @@ fn cgtrytupleshift(c: *cgen, n: *node) bool = { fn cgtrytaggedshift(c: *cgen, n: *node) bool = { if (n.lhs == nil) { return false; }; let ou: *tinfo = n.lhs.type_: *tinfo; - for (ou != nil && ou.kind == tykind.TY_NAMED) { ou = ou.under; }; + ou = tichase(ou); if (ou == nil) { return false; }; if (ou.kind != tykind.TY_TAGGED) { return false; }; if (ou.params == nil) { return false; }; let sv: *tinfo = ou.params.type_; - for (sv != nil && sv.kind == tykind.TY_NAMED) { sv = sv.under; }; + sv = tichase(sv); if (sv == nil) { return false; }; if (sv.kind != tykind.TY_TAGGED) { return false; }; if (sv.nullable != 0) { return false; }; @@ -219,7 +219,7 @@ fn cgtrytaggedshift(c: *cgen, n: *node) bool = { fn cgtryunwcursor(c: *cgen, n: *node, opname: str) void = { let u: *tinfo = nil; if (n.lhs != nil) { u = n.lhs.type_: *tinfo; }; - for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; }; + u = tichase(u); let utag: bool = false; if (u != nil) { if (u.kind == tykind.TY_TAGGED && u.nullable == 0) { @@ -323,10 +323,10 @@ fn cgtryprop(c: *cgen, n: *node) void = { // itself → zero instructions, byte-id with the pre-#173 emit. let u: *tinfo = nil; if (n.lhs != nil) { u = n.lhs.type_: *tinfo; }; - for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; }; + u = tichase(u); let r: *tinfo = nil; if (c.fnret != nil) { r = c.fnret.type_: *tinfo; }; - for (r != nil && r.kind == tykind.TY_NAMED) { r = r.under; }; + r = tichase(r); if (u != nil && r != nil && r.kind == tykind.TY_TAGGED && u.params != nil) { let propret: str; propret.ptr = nil; propret.len = 0; @@ -548,9 +548,7 @@ fn cgtypetest(c: *cgen, n: *node) void = { // cast source — loud. Mirrors cstage. { let icu: *tinfo = lhs.type_: *tinfo; - for (icu != nil && icu.kind == tykind.TY_NAMED) { - icu = icu.under; - }; + icu = tichase(icu); if (lhs.kind == nkind.N_CAST && icu != nil && icu.kind == tykind.TY_TAGGED && icu.nullable == 0) { @@ -741,9 +739,7 @@ fn cgtypeassert(c: *cgen, n: *node) void = { // cast source — loud. Mirrors cstage. { let acu: *tinfo = lhs.type_: *tinfo; - for (acu != nil && acu.kind == tykind.TY_NAMED) { - acu = acu.under; - }; + acu = tichase(acu); if (lhs.kind == nkind.N_CAST && acu != nil && acu.kind == tykind.TY_TAGGED && acu.nullable == 0) { @@ -967,7 +963,7 @@ fn cgident(c: *cgen, n: *node) void = { // just word0 in AX. Mirror of cstage cgexpr N_IDENT tuple arm. let itu: *tinfo = nil; if (lc.tnode != nil) { itu = lc.tnode.type_: *tinfo; }; - for (itu != nil && itu.kind == tykind.TY_NAMED) { itu = itu.under; }; + itu = tichase(itu); if (itu != nil) { if (itu.kind == tykind.TY_TUPLE) { cgtupleslottocursor(c, off, itu); return; @@ -1219,13 +1215,13 @@ fn dotchainaddr(c: *cgen, n: *node, dstreg: str) bool = { let x: *node = n.lhs; if (x == nil) { return false; }; let xu: *tinfo = x.type_: *tinfo; - for (xu != nil && xu.kind == tykind.TY_NAMED) { xu = xu.under; }; + xu = tichase(xu); if (xu == nil) { return false; }; let xviaptr: bool = false; let st: *tinfo = nil; if (xu.kind == tykind.TY_PTR) { let p: *tinfo = xu.sub; - for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; }; + p = tichase(p); if (p != nil) { if (p.kind == tykind.TY_STRUCT) { st = p; xviaptr = true; @@ -1318,13 +1314,13 @@ fn dotbaseaddr(c: *cgen, base: *node, dstreg: str) bool = { }; }; let bu: *tinfo = inner.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; let viaptr: bool = false; let structt: *tinfo = nil; if (bu.kind == tykind.TY_PTR) { let st: *tinfo = bu.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { structt = st; viaptr = true; @@ -1349,7 +1345,7 @@ fn dotbaseaddr(c: *cgen, base: *node, dstreg: str) bool = { // the existing cgexpr(base) path correctly loads the pointer/ // header value; over-firing here would skip the deref. Cstage // twin gate at cg_dotbase_addr. - for (ft != nil && ft.kind == tykind.TY_NAMED) { ft = ft.under; }; + ft = tichase(ft); if (ft == nil) { return false; }; if (ft.kind != tykind.TY_ARRAY) { return false; }; // #253: chained inner — compute the container base via the dot-chain @@ -1466,7 +1462,7 @@ fn aggargsrcaddr(c: *cgen, src: *node, dst: str) bool = { if (base == nil) { return false; }; if (base.kind != nkind.N_IDENT) { return false; }; let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; if (bu.kind != tykind.TY_ARRAY) { return false; }; let esz: i32 = 1; @@ -1611,13 +1607,13 @@ fn cgplaceaddr(c: *cgen, n: *node, dstreg: str) bool = { // enumerated arms never reach the resolver (those arms // dispatch first), so their asm is untouched. let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; if (bu.kind != tykind.TY_SLICE && bu.kind != tykind.TY_ARRAY) { return false; }; let et: *tinfo = n.type_: *tinfo; - for (et != nil && et.kind == tykind.TY_NAMED) { et = et.under; }; + et = tichase(et); if (et == nil) { return false; }; let esz: i32 = et.size: i32; cgexpr(c, idx); @@ -1649,13 +1645,13 @@ fn cgplaceaddr(c: *cgen, n: *node, dstreg: str) bool = { let base: *node = n.lhs; if (base == nil) { return false; }; let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; let viaptr: bool = false; let st: *tinfo = nil; if (bu.kind == tykind.TY_PTR) { let p: *tinfo = bu.sub; - for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; }; + p = tichase(p); if (p != nil) { if (p.kind == tykind.TY_STRUCT) { st = p; viaptr = true; @@ -2289,9 +2285,7 @@ fn cgslice(c: *cgen, n: *node) void = { let dotbu: *tinfo = nil; if (base != nil) { if (base.kind == nkind.N_DOT) { dotbu = base.type_: *tinfo; - for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) { - dotbu = dotbu.under; - }; + dotbu = tichase(dotbu); };}; // #31: an N_ARRLIT base (the desugared one-step `let xs:[]T=[..]` // borrow — the ONLY context that reaches here; call-arg/return/assign @@ -2620,9 +2614,7 @@ fn cgmatch(c: *cgen, n: *node) void = { // to match. Surfaced by reviewer-37's `match (*p)` // probe on a 56B box. let ms37: *tinfo = scrut.type_: *tinfo; - for (ms37 != nil && ms37.kind == tykind.TY_NAMED) { - ms37 = ms37.under; - }; + ms37 = tichase(ms37); if (ms37 != nil && ms37.kind == tykind.TY_TAGGED && ms37.size: i32 > TUPLE_GPCAP * 8) { let m37n: str = "#37: >32B tagged match scrutinee from a non-mem-based source unwired (rule 7)\n"; @@ -3494,13 +3486,13 @@ fn cgdot(c: *cgen, n: *node) void = { if (idxbase != nil) { if (idxbase.kind == nkind.N_IDENT) { let elemt: *tinfo = lhs.type_: *tinfo; let elemu: *tinfo = elemt; - for (elemu != nil && elemu.kind == tykind.TY_NAMED) { elemu = elemu.under; }; + elemu = tichase(elemu); let st: *tinfo = nil; let viaptr: bool = false; if (elemu != nil) { if (elemu.kind == tykind.TY_PTR) { let pin: *tinfo = elemu.sub; - for (pin != nil && pin.kind == tykind.TY_NAMED) { pin = pin.under; }; + pin = tichase(pin); if (pin != nil) { if (pin.kind == tykind.TY_STRUCT) { st = pin; viaptr = true; @@ -3517,7 +3509,7 @@ fn cgdot(c: *cgen, n: *node) void = { fwalk = fwalk.tnext; }; let bu: *tinfo = idxbase.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); let baseisarray: bool = false; let baseok: bool = false; if (bu != nil) { @@ -3586,7 +3578,7 @@ fn cgdot(c: *cgen, n: *node) void = { let foff: i64 = fnd.offset: i64; let ft: *tinfo = fnd.type_; let fu: *tinfo = ft; - for (fu != nil && fu.kind == tykind.TY_NAMED) { fu = fu.under; }; + fu = tichase(fu); // #270-1a: an `[N]T`-typed field of an // array element (`a[i].m[j]`) — leave the // field's ADDRESS, a base for the outer @@ -3773,9 +3765,7 @@ fn cgdot(c: *cgen, n: *node) void = { // registers (ken x5c: o.r.min as size added DX). if (typeistagged(leaftype)) { let tlu: *tinfo = leaftype; - for (tlu != nil && tlu.kind == tykind.TY_NAMED) { - tlu = tlu.under; - }; + tlu = tichase(tlu); let ttsz: i32 = tlu.size: i32; if (viacx) { if (ptrroot) { @@ -3929,7 +3919,7 @@ fn cgdot(c: *cgen, n: *node) void = { { let pbu: *tinfo = nil; if (lhs != nil) { pbu = lhs.type_: *tinfo; }; - for (pbu != nil && pbu.kind == tykind.TY_NAMED) { pbu = pbu.under; }; + pbu = tichase(pbu); let pbok: bool = false; if (pbu != nil) { if (pbu.kind == tykind.TY_SLICE @@ -3998,11 +3988,11 @@ fn cgdot(c: *cgen, n: *node) void = { let allptr: bool = true; for (croot != nil && croot.kind == nkind.N_DOT) { let ct: *tinfo = croot.type_: *tinfo; - for (ct != nil && ct.kind == tykind.TY_NAMED) { ct = ct.under; }; + ct = tichase(ct); let okp: bool = false; if (ct != nil) { if (ct.kind == tykind.TY_PTR) { let cs: *tinfo = ct.sub; - for (cs != nil && cs.kind == tykind.TY_NAMED) { cs = cs.under; }; + cs = tichase(cs); if (cs != nil) { if (cs.kind == tykind.TY_STRUCT) { okp = true; }; }; }; }; if (!okp) { allptr = false; }; @@ -4013,10 +4003,10 @@ fn cgdot(c: *cgen, n: *node) void = { localfindnode(c, croot.str) != nil) { it = lhs.type_: *tinfo; }; - for (it != nil && it.kind == tykind.TY_NAMED) { it = it.under; }; + it = tichase(it); if (it != nil) { if (it.kind == tykind.TY_PTR) { let st: *tinfo = it.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { let tf: *tfield = st.fields; for (tf != nil) { @@ -4031,9 +4021,7 @@ fn cgdot(c: *cgen, n: *node) void = { // scalar tail read stale DX as payload). if (typeistagged(ft)) { let plu: *tinfo = ft; - for (plu != nil && plu.kind == tykind.TY_NAMED) { - plu = plu.under; - }; + plu = tichase(plu); emitline("\tMOVQ\tAX, BX\n"); cgloadtaggedfield(c, "BX", tf.offset: i32, @@ -4230,7 +4218,7 @@ fn cgdot(c: *cgen, n: *node) void = { if (lhs != nil) { if (lhs.kind == nkind.N_DOT) { let pgu: *tinfo = lhs.type_: *tinfo; - for (pgu != nil && pgu.kind == tykind.TY_NAMED) { pgu = pgu.under; }; + pgu = tichase(pgu); if (pgu != nil) { if (pgu.kind == tykind.TY_PTR) { let mp: str = "cgdot: ptr-chained field read unwired in wwstage (task #37)\n"; @@ -4251,7 +4239,7 @@ fn cgdot(c: *cgen, n: *node) void = { { let rdt: *tinfo = n.type_: *tinfo; let rdu: *tinfo = rdt; - for (rdu != nil && rdu.kind == tykind.TY_NAMED) { rdu = rdu.under; }; + rdu = tichase(rdu); if (rdu != nil) { if (rdu.kind == tykind.TY_TAGGED) { let mt: str = "read-resolver: tagged field read not wired (rule-7)\n"; @@ -4781,7 +4769,7 @@ fn cgun(c: *cgen, n: *node) void = { // pulled a[0]'s VALUE and `(*p)[i]` then dereferenced it as // the index base — a wild pointer, SIGSEGV on both stages. let rti: *tinfo = n.type_: *tinfo; - for (rti != nil && rti.kind == tykind.TY_NAMED) { rti = rti.under; }; + rti = tichase(rti); if (rti != nil && rti.kind == tykind.TY_FN) { return; }; if (rti != nil && rti.kind == tykind.TY_ARRAY) { return; }; // Family C (#35/#46): a tagged box behind *p joins the @@ -5310,7 +5298,7 @@ fn cgappend(c: *cgen, n: *node) void = { // same source cstage reads (sn->type → su->sub->size). sti = sn.type_: *tinfo; let fsti: *tinfo = sti; - for (fsti != nil && fsti.kind == tykind.TY_NAMED) { fsti = fsti.under; }; + fsti = tichase(fsti); if (fsti != nil && fsti.sub != nil) { esz = fsti.sub.size: i32; }; if (esz <= 0) { let m15z: str = "#15: append() target element size unresolved (rule-7)\n"; @@ -5325,16 +5313,14 @@ fn cgappend(c: *cgen, n: *node) void = { // the value node's literal tinfo is the #25/#31 esz=0 trap. // Mirrors cstage cgen.c's append arm + the #270/#12/#20 // array-literal element dispatch (cgarrlitfillbp). - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esubti: *tinfo = nil; if (sti != nil) { esubti = sti.sub; }; // FA1: pre-peel handle — the indirect struct-lit fill keys its // structinfo off the NAMED element tinfo's name (the same leaf // structlookupchain resolves from the declared tnode). let esubnamed: *tinfo = esubti; - for (esubti != nil && esubti.kind == tykind.TY_NAMED) { - esubti = esubti.under; - }; + esubti = tichase(esubti); let elstr: bool = esubti != nil && esubti.kind == tykind.TY_STR; let elslice: bool = esubti != nil && esubti.kind == tykind.TY_SLICE; let eltagged: bool = esubti != nil && esubti.kind == tykind.TY_TAGGED; @@ -5381,7 +5367,7 @@ fn cgappend(c: *cgen, n: *node) void = { // shares the slice header layout. let itu: *tinfo = nil; if (it != nil) { itu = it.type_: *tinfo; }; - for (itu != nil && itu.kind == tykind.TY_NAMED) { itu = itu.under; }; + itu = tichase(itu); if (itu == nil || (itu.kind != tykind.TY_SLICE && itu.kind != tykind.TY_STR)) { let m35p: str = "#35: append() spread source shape unsupported (rule-7)\n"; @@ -5616,7 +5602,7 @@ fn cgappend(c: *cgen, n: *node) void = { let af: *tfield = nil; if (ab != nil) { let abu: *tinfo = ab.type_: *tinfo; - for (abu != nil && abu.kind == tykind.TY_NAMED) { abu = abu.under; }; + abu = tichase(abu); if (abu != nil && abu.kind == tykind.TY_STRUCT) { let fl: *tfield = abu.fields; for (fl != nil) { @@ -5632,11 +5618,11 @@ fn cgappend(c: *cgen, n: *node) void = { if (aok && ch.kind == nkind.N_INDEX) { let ab: *node = ch.lhs; let aet: *tinfo = ch.type_: *tinfo; - for (aet != nil && aet.kind == tykind.TY_NAMED) { aet = aet.under; }; + aet = tichase(aet); let abu: *tinfo = nil; if (ab != nil) { abu = ab.type_: *tinfo; - for (abu != nil && abu.kind == tykind.TY_NAMED) { abu = abu.under; }; + abu = tichase(abu); }; if (ab == nil || abu == nil || aet == nil || (abu.kind != tykind.TY_SLICE && abu.kind != tykind.TY_ARRAY)) { @@ -5919,10 +5905,10 @@ fn cgdelete(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -6051,10 +6037,10 @@ fn cgdeleterange(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -6250,10 +6236,10 @@ fn cginsert(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -6567,9 +6553,7 @@ fn cgcall(c: *cgen, n: *node) void = { let a: *node = n.list; let at: *tinfo = a.type_: *tinfo; let u: *tinfo = at; - for (u != nil && u.kind == tykind.TY_NAMED) { - u = u.under; - }; + u = tichase(u); let hdrish: bool = false; if (u != nil) { if (u.kind == tykind.TY_SLICE @@ -7442,9 +7426,7 @@ fn cgassign(c: *cgen, n: *node) void = { && n.op == tkind.TK_ASSIGN && n.rhs != nil) { if (n.rhs.kind == nkind.N_STRUCTLIT) { let iet: *tinfo = lhs.type_: *tinfo; - for (iet != nil && iet.kind == tykind.TY_NAMED) { - iet = iet.under; - }; + iet = tichase(iet); if (iet != nil) { if (iet.kind == tykind.TY_STRUCT) { placeslit = true; @@ -7464,9 +7446,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (lhs.kind == nkind.N_UN && lhs.op == tkind.TK_STAR && n.op == tkind.TK_ASSIGN) { let du: *tinfo = lhs.type_: *tinfo; - for (du != nil && du.kind == tykind.TY_NAMED) { - du = du.under; - }; + du = tichase(du); if (du != nil) { if (du.kind == tykind.TY_STRUCT || du.kind == tykind.TY_ARRAY @@ -7497,9 +7477,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (n.op == tkind.TK_ASSIGN && lhs != nil && n.rhs != nil) { if (n.rhs.kind == nkind.N_ARRLIT) { let alt: *tinfo = lhs.type_: *tinfo; - for (alt != nil && alt.kind == tykind.TY_NAMED) { - alt = alt.under; - }; + alt = tichase(alt); if (alt != nil) { if (alt.kind == tykind.TY_ARRAY) { let mal: str = "array-literal store at assignment unwired (task #32)\n"; @@ -7534,13 +7512,9 @@ fn cgassign(c: *cgen, n: *node) void = { }; if (asret > 0) { let aru: *tinfo = n.rhs.type_: *tinfo; - for (aru != nil && aru.kind == tykind.TY_NAMED) { - aru = aru.under; - }; + aru = tichase(aru); let alu: *tinfo = lc.tnode.type_: *tinfo; - for (alu != nil && alu.kind == tykind.TY_NAMED) { - alu = alu.under; - }; + alu = tichase(alu); let aexact: bool = false; if (aru != nil && aru == alu) { aexact = true; } else { @@ -7570,9 +7544,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (lc == nil && n.rhs != nil) { if (n.rhs.kind == nkind.N_CALL) { let gru: *tinfo = lhs.type_: *tinfo; - for (gru != nil && gru.kind == tykind.TY_NAMED) { - gru = gru.under; - }; + gru = tichase(gru); if (gru != nil && gru.kind == tykind.TY_TAGGED && callsretsize(c, n.rhs) > 0) { let m38g: str = "#38b: sret receive into a tagged GLOBAL lvalue unwired\n"; @@ -9569,11 +9541,11 @@ fn cgassign(c: *cgen, n: *node) void = { let allptr: bool = true; for (croot != nil && croot.kind == nkind.N_DOT) { let ct: *tinfo = croot.type_: *tinfo; - for (ct != nil && ct.kind == tykind.TY_NAMED) { ct = ct.under; }; + ct = tichase(ct); let okp: bool = false; if (ct != nil) { if (ct.kind == tykind.TY_PTR) { let cs: *tinfo = ct.sub; - for (cs != nil && cs.kind == tykind.TY_NAMED) { cs = cs.under; }; + cs = tichase(cs); if (cs != nil) { if (cs.kind == tykind.TY_STRUCT) { okp = true; }; }; }; }; if (!okp) { allptr = false; }; @@ -9584,10 +9556,10 @@ fn cgassign(c: *cgen, n: *node) void = { localfindnode(c, croot.str) != nil) { it = base.type_: *tinfo; }; - for (it != nil && it.kind == tykind.TY_NAMED) { it = it.under; }; + it = tichase(it); if (it != nil) { if (it.kind == tykind.TY_PTR) { let st: *tinfo = it.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { let tf: *tfield = st.fields; for (tf != nil) { @@ -9604,9 +9576,7 @@ fn cgassign(c: *cgen, n: *node) void = { // landed in the TAG slot (ken b8). if (typeistagged(ft)) { let flu: *tinfo = ft; - for (flu != nil && flu.kind == tykind.TY_NAMED) { - flu = flu.under; - }; + flu = tichase(flu); cgexpr(c, base); emitline("\tMOVQ\tAX, BX\n"); cgwidentaggedstore(c, flu, n.rhs, @@ -9831,9 +9801,7 @@ fn cgassign(c: *cgen, n: *node) void = { // (TK_ASSIGN gate above). if (typeistagged(leaftype)) { let wlu: *tinfo = leaftype; - for (wlu != nil && wlu.kind == tykind.TY_NAMED) { - wlu = wlu.under; - }; + wlu = tichase(wlu); let wtsz: i32 = wlu.size: i32; if (viacx) { if (ptrroot) { @@ -9919,9 +9887,7 @@ fn cgassign(c: *cgen, n: *node) void = { let leafname: str = ""; if (leaftype != nil) { let lp: *tinfo = leaftype; - for (lp != nil && lp.kind == tykind.TY_NAMED) { - lp = lp.under; - }; + lp = tichase(lp); if (lp != nil) { if (lp.kind == tykind.TY_STRUCT) { leafstruct = true; }; }; @@ -10396,7 +10362,7 @@ fn cgassign(c: *cgen, n: *node) void = { }; if (lvftn.kind == nkind.N_TARRAY) { let gat: *tinfo = lvftn.type_: *tinfo; - for (gat != nil && gat.kind == tykind.TY_NAMED) { gat = gat.under; }; + gat = tichase(gat); if (gat != nil) { gsz = gat.size: i32; }; }; if (gsz > 24) { @@ -10425,7 +10391,7 @@ fn cgassign(c: *cgen, n: *node) void = { && lvftn.kind == nkind.N_TARRAY) { let aggsz: i32 = 0; let aat: *tinfo = lvftn.type_: *tinfo; - for (aat != nil && aat.kind == tykind.TY_NAMED) { aat = aat.under; }; + aat = tichase(aat); if (aat != nil) { aggsz = aat.size: i32; }; if (aggsz > 0 && aggsz <= 24) { cgexpr(c, n.rhs); @@ -10468,9 +10434,7 @@ fn cgassign(c: *cgen, n: *node) void = { // tail below: one MOVQ AX, g(SB). if (n.op == tkind.TK_ASSIGN && lvftn != nil) { let gau: *tinfo = lvftn.type_: *tinfo; - for (gau != nil && gau.kind == tykind.TY_NAMED) { - gau = gau.under; - }; + gau = tichase(gau); if (gau != nil) { if (gau.kind == tykind.TY_STRUCT || gau.kind == tykind.TY_ARRAY @@ -10779,9 +10743,7 @@ fn cgassign(c: *cgen, n: *node) void = { && n.rhs != nil && n.rhs.kind == nkind.N_CALL) { let acati: *tinfo = nil; if (lcn.tnode != nil) { acati = lcn.tnode.type_: *tinfo; }; - for (acati != nil && acati.kind == tykind.TY_NAMED) { - acati = acati.under; - }; + acati = tichase(acati); if (acati != nil && acati.kind == tykind.TY_ARRAY) { let lcsz: i32 = acati.size: i32; if (lcsz > 24) { @@ -10902,9 +10864,7 @@ fn cgassign(c: *cgen, n: *node) void = { agu = lcn.tnode.type_: *tinfo; }; }; - for (agu != nil && agu.kind == tykind.TY_NAMED) { - agu = agu.under; - }; + agu = tichase(agu); if (agu != nil) { if (agu.kind == tykind.TY_STRUCT || agu.kind == tykind.TY_ARRAY @@ -11066,9 +11026,7 @@ fn cgassign(c: *cgen, n: *node) void = { || (lhs.kind == nkind.N_UN && lhs.op == tkind.TK_STAR)) { let ft: *tinfo = lhs.type_: *tinfo; let fu: *tinfo = ft; - for (fu != nil && fu.kind == tykind.TY_NAMED) { - fu = fu.under; - }; + fu = tichase(fu); let fsz: i32 = 8; if (ft != nil) { fsz = ft.size: i32; }; if (typeisfloat(ft)) { diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index b31069ca..d86f0671 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -21114,7 +21114,7 @@ fn cgtagvariantidx(c: *cgen, tagged: *node, vt: *node) i32 = { // scrutinee shape, so the AST-keyed -1 here was a silent // tag-0 clamp on wwstage (cs CMPQ $1 vs ww CMPQ $0). let sti: *tinfo = tagged.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); if (sti != nil && sti.kind == tykind.TY_TAGGED && vt.type_ != nil) { return flatvariantidxt(sti, vt.type_: *tinfo); }; @@ -21141,12 +21141,12 @@ fn cgtagvariantidx(c: *cgen, tagged: *node, vt: *node) i32 = { fn cgtrytupleshift(c: *cgen, n: *node) bool = { if (n.lhs == nil) { return false; }; let ou: *tinfo = n.lhs.type_: *tinfo; - for (ou != nil && ou.kind == tykind.TY_NAMED) { ou = ou.under; }; + ou = tichase(ou); if (ou == nil) { return false; }; if (ou.kind != tykind.TY_TAGGED) { return false; }; if (ou.params == nil) { return false; }; let sv: *tinfo = ou.params.type_; - for (sv != nil && sv.kind == tykind.TY_NAMED) { sv = sv.under; }; + sv = tichase(sv); if (sv == nil) { return false; }; if (sv.kind != tykind.TY_TUPLE) { return false; }; cgtaggedtuplepayloadshift(c, sv); @@ -21164,12 +21164,12 @@ fn cgtrytupleshift(c: *cgen, n: *node) bool = { fn cgtrytaggedshift(c: *cgen, n: *node) bool = { if (n.lhs == nil) { return false; }; let ou: *tinfo = n.lhs.type_: *tinfo; - for (ou != nil && ou.kind == tykind.TY_NAMED) { ou = ou.under; }; + ou = tichase(ou); if (ou == nil) { return false; }; if (ou.kind != tykind.TY_TAGGED) { return false; }; if (ou.params == nil) { return false; }; let sv: *tinfo = ou.params.type_; - for (sv != nil && sv.kind == tykind.TY_NAMED) { sv = sv.under; }; + sv = tichase(sv); if (sv == nil) { return false; }; if (sv.kind != tykind.TY_TAGGED) { return false; }; if (sv.nullable != 0) { return false; }; @@ -21189,7 +21189,7 @@ fn cgtrytaggedshift(c: *cgen, n: *node) bool = { fn cgtryunwcursor(c: *cgen, n: *node, opname: str) void = { let u: *tinfo = nil; if (n.lhs != nil) { u = n.lhs.type_: *tinfo; }; - for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; }; + u = tichase(u); let utag: bool = false; if (u != nil) { if (u.kind == tykind.TY_TAGGED && u.nullable == 0) { @@ -21293,10 +21293,10 @@ fn cgtryprop(c: *cgen, n: *node) void = { // itself → zero instructions, byte-id with the pre-#173 emit. let u: *tinfo = nil; if (n.lhs != nil) { u = n.lhs.type_: *tinfo; }; - for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; }; + u = tichase(u); let r: *tinfo = nil; if (c.fnret != nil) { r = c.fnret.type_: *tinfo; }; - for (r != nil && r.kind == tykind.TY_NAMED) { r = r.under; }; + r = tichase(r); if (u != nil && r != nil && r.kind == tykind.TY_TAGGED && u.params != nil) { let propret: str; propret.ptr = nil; propret.len = 0; @@ -21518,9 +21518,7 @@ fn cgtypetest(c: *cgen, n: *node) void = { // cast source — loud. Mirrors cstage. { let icu: *tinfo = lhs.type_: *tinfo; - for (icu != nil && icu.kind == tykind.TY_NAMED) { - icu = icu.under; - }; + icu = tichase(icu); if (lhs.kind == nkind.N_CAST && icu != nil && icu.kind == tykind.TY_TAGGED && icu.nullable == 0) { @@ -21711,9 +21709,7 @@ fn cgtypeassert(c: *cgen, n: *node) void = { // cast source — loud. Mirrors cstage. { let acu: *tinfo = lhs.type_: *tinfo; - for (acu != nil && acu.kind == tykind.TY_NAMED) { - acu = acu.under; - }; + acu = tichase(acu); if (lhs.kind == nkind.N_CAST && acu != nil && acu.kind == tykind.TY_TAGGED && acu.nullable == 0) { @@ -21937,7 +21933,7 @@ fn cgident(c: *cgen, n: *node) void = { // just word0 in AX. Mirror of cstage cgexpr N_IDENT tuple arm. let itu: *tinfo = nil; if (lc.tnode != nil) { itu = lc.tnode.type_: *tinfo; }; - for (itu != nil && itu.kind == tykind.TY_NAMED) { itu = itu.under; }; + itu = tichase(itu); if (itu != nil) { if (itu.kind == tykind.TY_TUPLE) { cgtupleslottocursor(c, off, itu); return; @@ -22189,13 +22185,13 @@ fn dotchainaddr(c: *cgen, n: *node, dstreg: str) bool = { let x: *node = n.lhs; if (x == nil) { return false; }; let xu: *tinfo = x.type_: *tinfo; - for (xu != nil && xu.kind == tykind.TY_NAMED) { xu = xu.under; }; + xu = tichase(xu); if (xu == nil) { return false; }; let xviaptr: bool = false; let st: *tinfo = nil; if (xu.kind == tykind.TY_PTR) { let p: *tinfo = xu.sub; - for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; }; + p = tichase(p); if (p != nil) { if (p.kind == tykind.TY_STRUCT) { st = p; xviaptr = true; @@ -22288,13 +22284,13 @@ fn dotbaseaddr(c: *cgen, base: *node, dstreg: str) bool = { }; }; let bu: *tinfo = inner.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; let viaptr: bool = false; let structt: *tinfo = nil; if (bu.kind == tykind.TY_PTR) { let st: *tinfo = bu.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { structt = st; viaptr = true; @@ -22319,7 +22315,7 @@ fn dotbaseaddr(c: *cgen, base: *node, dstreg: str) bool = { // the existing cgexpr(base) path correctly loads the pointer/ // header value; over-firing here would skip the deref. Cstage // twin gate at cg_dotbase_addr. - for (ft != nil && ft.kind == tykind.TY_NAMED) { ft = ft.under; }; + ft = tichase(ft); if (ft == nil) { return false; }; if (ft.kind != tykind.TY_ARRAY) { return false; }; // #253: chained inner — compute the container base via the dot-chain @@ -22436,7 +22432,7 @@ fn aggargsrcaddr(c: *cgen, src: *node, dst: str) bool = { if (base == nil) { return false; }; if (base.kind != nkind.N_IDENT) { return false; }; let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; if (bu.kind != tykind.TY_ARRAY) { return false; }; let esz: i32 = 1; @@ -22581,13 +22577,13 @@ fn cgplaceaddr(c: *cgen, n: *node, dstreg: str) bool = { // enumerated arms never reach the resolver (those arms // dispatch first), so their asm is untouched. let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; if (bu.kind != tykind.TY_SLICE && bu.kind != tykind.TY_ARRAY) { return false; }; let et: *tinfo = n.type_: *tinfo; - for (et != nil && et.kind == tykind.TY_NAMED) { et = et.under; }; + et = tichase(et); if (et == nil) { return false; }; let esz: i32 = et.size: i32; cgexpr(c, idx); @@ -22619,13 +22615,13 @@ fn cgplaceaddr(c: *cgen, n: *node, dstreg: str) bool = { let base: *node = n.lhs; if (base == nil) { return false; }; let bu: *tinfo = base.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); if (bu == nil) { return false; }; let viaptr: bool = false; let st: *tinfo = nil; if (bu.kind == tykind.TY_PTR) { let p: *tinfo = bu.sub; - for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; }; + p = tichase(p); if (p != nil) { if (p.kind == tykind.TY_STRUCT) { st = p; viaptr = true; @@ -23259,9 +23255,7 @@ fn cgslice(c: *cgen, n: *node) void = { let dotbu: *tinfo = nil; if (base != nil) { if (base.kind == nkind.N_DOT) { dotbu = base.type_: *tinfo; - for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) { - dotbu = dotbu.under; - }; + dotbu = tichase(dotbu); };}; // #31: an N_ARRLIT base (the desugared one-step `let xs:[]T=[..]` // borrow — the ONLY context that reaches here; call-arg/return/assign @@ -23590,9 +23584,7 @@ fn cgmatch(c: *cgen, n: *node) void = { // to match. Surfaced by reviewer-37's `match (*p)` // probe on a 56B box. let ms37: *tinfo = scrut.type_: *tinfo; - for (ms37 != nil && ms37.kind == tykind.TY_NAMED) { - ms37 = ms37.under; - }; + ms37 = tichase(ms37); if (ms37 != nil && ms37.kind == tykind.TY_TAGGED && ms37.size: i32 > TUPLE_GPCAP * 8) { let m37n: str = "#37: >32B tagged match scrutinee from a non-mem-based source unwired (rule 7)\n"; @@ -24464,13 +24456,13 @@ fn cgdot(c: *cgen, n: *node) void = { if (idxbase != nil) { if (idxbase.kind == nkind.N_IDENT) { let elemt: *tinfo = lhs.type_: *tinfo; let elemu: *tinfo = elemt; - for (elemu != nil && elemu.kind == tykind.TY_NAMED) { elemu = elemu.under; }; + elemu = tichase(elemu); let st: *tinfo = nil; let viaptr: bool = false; if (elemu != nil) { if (elemu.kind == tykind.TY_PTR) { let pin: *tinfo = elemu.sub; - for (pin != nil && pin.kind == tykind.TY_NAMED) { pin = pin.under; }; + pin = tichase(pin); if (pin != nil) { if (pin.kind == tykind.TY_STRUCT) { st = pin; viaptr = true; @@ -24487,7 +24479,7 @@ fn cgdot(c: *cgen, n: *node) void = { fwalk = fwalk.tnext; }; let bu: *tinfo = idxbase.type_: *tinfo; - for (bu != nil && bu.kind == tykind.TY_NAMED) { bu = bu.under; }; + bu = tichase(bu); let baseisarray: bool = false; let baseok: bool = false; if (bu != nil) { @@ -24556,7 +24548,7 @@ fn cgdot(c: *cgen, n: *node) void = { let foff: i64 = fnd.offset: i64; let ft: *tinfo = fnd.type_; let fu: *tinfo = ft; - for (fu != nil && fu.kind == tykind.TY_NAMED) { fu = fu.under; }; + fu = tichase(fu); // #270-1a: an `[N]T`-typed field of an // array element (`a[i].m[j]`) — leave the // field's ADDRESS, a base for the outer @@ -24743,9 +24735,7 @@ fn cgdot(c: *cgen, n: *node) void = { // registers (ken x5c: o.r.min as size added DX). if (typeistagged(leaftype)) { let tlu: *tinfo = leaftype; - for (tlu != nil && tlu.kind == tykind.TY_NAMED) { - tlu = tlu.under; - }; + tlu = tichase(tlu); let ttsz: i32 = tlu.size: i32; if (viacx) { if (ptrroot) { @@ -24899,7 +24889,7 @@ fn cgdot(c: *cgen, n: *node) void = { { let pbu: *tinfo = nil; if (lhs != nil) { pbu = lhs.type_: *tinfo; }; - for (pbu != nil && pbu.kind == tykind.TY_NAMED) { pbu = pbu.under; }; + pbu = tichase(pbu); let pbok: bool = false; if (pbu != nil) { if (pbu.kind == tykind.TY_SLICE @@ -24968,11 +24958,11 @@ fn cgdot(c: *cgen, n: *node) void = { let allptr: bool = true; for (croot != nil && croot.kind == nkind.N_DOT) { let ct: *tinfo = croot.type_: *tinfo; - for (ct != nil && ct.kind == tykind.TY_NAMED) { ct = ct.under; }; + ct = tichase(ct); let okp: bool = false; if (ct != nil) { if (ct.kind == tykind.TY_PTR) { let cs: *tinfo = ct.sub; - for (cs != nil && cs.kind == tykind.TY_NAMED) { cs = cs.under; }; + cs = tichase(cs); if (cs != nil) { if (cs.kind == tykind.TY_STRUCT) { okp = true; }; }; }; }; if (!okp) { allptr = false; }; @@ -24983,10 +24973,10 @@ fn cgdot(c: *cgen, n: *node) void = { localfindnode(c, croot.str) != nil) { it = lhs.type_: *tinfo; }; - for (it != nil && it.kind == tykind.TY_NAMED) { it = it.under; }; + it = tichase(it); if (it != nil) { if (it.kind == tykind.TY_PTR) { let st: *tinfo = it.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { let tf: *tfield = st.fields; for (tf != nil) { @@ -25001,9 +24991,7 @@ fn cgdot(c: *cgen, n: *node) void = { // scalar tail read stale DX as payload). if (typeistagged(ft)) { let plu: *tinfo = ft; - for (plu != nil && plu.kind == tykind.TY_NAMED) { - plu = plu.under; - }; + plu = tichase(plu); emitline("\tMOVQ\tAX, BX\n"); cgloadtaggedfield(c, "BX", tf.offset: i32, @@ -25200,7 +25188,7 @@ fn cgdot(c: *cgen, n: *node) void = { if (lhs != nil) { if (lhs.kind == nkind.N_DOT) { let pgu: *tinfo = lhs.type_: *tinfo; - for (pgu != nil && pgu.kind == tykind.TY_NAMED) { pgu = pgu.under; }; + pgu = tichase(pgu); if (pgu != nil) { if (pgu.kind == tykind.TY_PTR) { let mp: str = "cgdot: ptr-chained field read unwired in wwstage (task #37)\n"; @@ -25221,7 +25209,7 @@ fn cgdot(c: *cgen, n: *node) void = { { let rdt: *tinfo = n.type_: *tinfo; let rdu: *tinfo = rdt; - for (rdu != nil && rdu.kind == tykind.TY_NAMED) { rdu = rdu.under; }; + rdu = tichase(rdu); if (rdu != nil) { if (rdu.kind == tykind.TY_TAGGED) { let mt: str = "read-resolver: tagged field read not wired (rule-7)\n"; @@ -25751,7 +25739,7 @@ fn cgun(c: *cgen, n: *node) void = { // pulled a[0]'s VALUE and `(*p)[i]` then dereferenced it as // the index base — a wild pointer, SIGSEGV on both stages. let rti: *tinfo = n.type_: *tinfo; - for (rti != nil && rti.kind == tykind.TY_NAMED) { rti = rti.under; }; + rti = tichase(rti); if (rti != nil && rti.kind == tykind.TY_FN) { return; }; if (rti != nil && rti.kind == tykind.TY_ARRAY) { return; }; // Family C (#35/#46): a tagged box behind *p joins the @@ -26280,7 +26268,7 @@ fn cgappend(c: *cgen, n: *node) void = { // same source cstage reads (sn->type → su->sub->size). sti = sn.type_: *tinfo; let fsti: *tinfo = sti; - for (fsti != nil && fsti.kind == tykind.TY_NAMED) { fsti = fsti.under; }; + fsti = tichase(fsti); if (fsti != nil && fsti.sub != nil) { esz = fsti.sub.size: i32; }; if (esz <= 0) { let m15z: str = "#15: append() target element size unresolved (rule-7)\n"; @@ -26295,16 +26283,14 @@ fn cgappend(c: *cgen, n: *node) void = { // the value node's literal tinfo is the #25/#31 esz=0 trap. // Mirrors cstage cgen.c's append arm + the #270/#12/#20 // array-literal element dispatch (cgarrlitfillbp). - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esubti: *tinfo = nil; if (sti != nil) { esubti = sti.sub; }; // FA1: pre-peel handle — the indirect struct-lit fill keys its // structinfo off the NAMED element tinfo's name (the same leaf // structlookupchain resolves from the declared tnode). let esubnamed: *tinfo = esubti; - for (esubti != nil && esubti.kind == tykind.TY_NAMED) { - esubti = esubti.under; - }; + esubti = tichase(esubti); let elstr: bool = esubti != nil && esubti.kind == tykind.TY_STR; let elslice: bool = esubti != nil && esubti.kind == tykind.TY_SLICE; let eltagged: bool = esubti != nil && esubti.kind == tykind.TY_TAGGED; @@ -26351,7 +26337,7 @@ fn cgappend(c: *cgen, n: *node) void = { // shares the slice header layout. let itu: *tinfo = nil; if (it != nil) { itu = it.type_: *tinfo; }; - for (itu != nil && itu.kind == tykind.TY_NAMED) { itu = itu.under; }; + itu = tichase(itu); if (itu == nil || (itu.kind != tykind.TY_SLICE && itu.kind != tykind.TY_STR)) { let m35p: str = "#35: append() spread source shape unsupported (rule-7)\n"; @@ -26586,7 +26572,7 @@ fn cgappend(c: *cgen, n: *node) void = { let af: *tfield = nil; if (ab != nil) { let abu: *tinfo = ab.type_: *tinfo; - for (abu != nil && abu.kind == tykind.TY_NAMED) { abu = abu.under; }; + abu = tichase(abu); if (abu != nil && abu.kind == tykind.TY_STRUCT) { let fl: *tfield = abu.fields; for (fl != nil) { @@ -26602,11 +26588,11 @@ fn cgappend(c: *cgen, n: *node) void = { if (aok && ch.kind == nkind.N_INDEX) { let ab: *node = ch.lhs; let aet: *tinfo = ch.type_: *tinfo; - for (aet != nil && aet.kind == tykind.TY_NAMED) { aet = aet.under; }; + aet = tichase(aet); let abu: *tinfo = nil; if (ab != nil) { abu = ab.type_: *tinfo; - for (abu != nil && abu.kind == tykind.TY_NAMED) { abu = abu.under; }; + abu = tichase(abu); }; if (ab == nil || abu == nil || aet == nil || (abu.kind != tykind.TY_SLICE && abu.kind != tykind.TY_ARRAY)) { @@ -26889,10 +26875,10 @@ fn cgdelete(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -27021,10 +27007,10 @@ fn cgdeleterange(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -27220,10 +27206,10 @@ fn cginsert(c: *cgen, n: *node) void = { // value node). Peel TY_NAMED on indexable AND element, mirroring // cstage's type_chase_named on both (#8 family). let sti: *tinfo = base.type_: *tinfo; - for (sti != nil && sti.kind == tykind.TY_NAMED) { sti = sti.under; }; + sti = tichase(sti); let esub: *tinfo = nil; if (sti != nil) { esub = sti.sub; }; - for (esub != nil && esub.kind == tykind.TY_NAMED) { esub = esub.under; }; + esub = tichase(esub); let esz: i32 = 0; if (esub != nil) { esz = esub.size: i32; }; if (esz <= 0) { @@ -27537,9 +27523,7 @@ fn cgcall(c: *cgen, n: *node) void = { let a: *node = n.list; let at: *tinfo = a.type_: *tinfo; let u: *tinfo = at; - for (u != nil && u.kind == tykind.TY_NAMED) { - u = u.under; - }; + u = tichase(u); let hdrish: bool = false; if (u != nil) { if (u.kind == tykind.TY_SLICE @@ -28412,9 +28396,7 @@ fn cgassign(c: *cgen, n: *node) void = { && n.op == tkind.TK_ASSIGN && n.rhs != nil) { if (n.rhs.kind == nkind.N_STRUCTLIT) { let iet: *tinfo = lhs.type_: *tinfo; - for (iet != nil && iet.kind == tykind.TY_NAMED) { - iet = iet.under; - }; + iet = tichase(iet); if (iet != nil) { if (iet.kind == tykind.TY_STRUCT) { placeslit = true; @@ -28434,9 +28416,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (lhs.kind == nkind.N_UN && lhs.op == tkind.TK_STAR && n.op == tkind.TK_ASSIGN) { let du: *tinfo = lhs.type_: *tinfo; - for (du != nil && du.kind == tykind.TY_NAMED) { - du = du.under; - }; + du = tichase(du); if (du != nil) { if (du.kind == tykind.TY_STRUCT || du.kind == tykind.TY_ARRAY @@ -28467,9 +28447,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (n.op == tkind.TK_ASSIGN && lhs != nil && n.rhs != nil) { if (n.rhs.kind == nkind.N_ARRLIT) { let alt: *tinfo = lhs.type_: *tinfo; - for (alt != nil && alt.kind == tykind.TY_NAMED) { - alt = alt.under; - }; + alt = tichase(alt); if (alt != nil) { if (alt.kind == tykind.TY_ARRAY) { let mal: str = "array-literal store at assignment unwired (task #32)\n"; @@ -28504,13 +28482,9 @@ fn cgassign(c: *cgen, n: *node) void = { }; if (asret > 0) { let aru: *tinfo = n.rhs.type_: *tinfo; - for (aru != nil && aru.kind == tykind.TY_NAMED) { - aru = aru.under; - }; + aru = tichase(aru); let alu: *tinfo = lc.tnode.type_: *tinfo; - for (alu != nil && alu.kind == tykind.TY_NAMED) { - alu = alu.under; - }; + alu = tichase(alu); let aexact: bool = false; if (aru != nil && aru == alu) { aexact = true; } else { @@ -28540,9 +28514,7 @@ fn cgassign(c: *cgen, n: *node) void = { if (lc == nil && n.rhs != nil) { if (n.rhs.kind == nkind.N_CALL) { let gru: *tinfo = lhs.type_: *tinfo; - for (gru != nil && gru.kind == tykind.TY_NAMED) { - gru = gru.under; - }; + gru = tichase(gru); if (gru != nil && gru.kind == tykind.TY_TAGGED && callsretsize(c, n.rhs) > 0) { let m38g: str = "#38b: sret receive into a tagged GLOBAL lvalue unwired\n"; @@ -30539,11 +30511,11 @@ fn cgassign(c: *cgen, n: *node) void = { let allptr: bool = true; for (croot != nil && croot.kind == nkind.N_DOT) { let ct: *tinfo = croot.type_: *tinfo; - for (ct != nil && ct.kind == tykind.TY_NAMED) { ct = ct.under; }; + ct = tichase(ct); let okp: bool = false; if (ct != nil) { if (ct.kind == tykind.TY_PTR) { let cs: *tinfo = ct.sub; - for (cs != nil && cs.kind == tykind.TY_NAMED) { cs = cs.under; }; + cs = tichase(cs); if (cs != nil) { if (cs.kind == tykind.TY_STRUCT) { okp = true; }; }; }; }; if (!okp) { allptr = false; }; @@ -30554,10 +30526,10 @@ fn cgassign(c: *cgen, n: *node) void = { localfindnode(c, croot.str) != nil) { it = base.type_: *tinfo; }; - for (it != nil && it.kind == tykind.TY_NAMED) { it = it.under; }; + it = tichase(it); if (it != nil) { if (it.kind == tykind.TY_PTR) { let st: *tinfo = it.sub; - for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; }; + st = tichase(st); if (st != nil) { if (st.kind == tykind.TY_STRUCT) { let tf: *tfield = st.fields; for (tf != nil) { @@ -30574,9 +30546,7 @@ fn cgassign(c: *cgen, n: *node) void = { // landed in the TAG slot (ken b8). if (typeistagged(ft)) { let flu: *tinfo = ft; - for (flu != nil && flu.kind == tykind.TY_NAMED) { - flu = flu.under; - }; + flu = tichase(flu); cgexpr(c, base); emitline("\tMOVQ\tAX, BX\n"); cgwidentaggedstore(c, flu, n.rhs, @@ -30801,9 +30771,7 @@ fn cgassign(c: *cgen, n: *node) void = { // (TK_ASSIGN gate above). if (typeistagged(leaftype)) { let wlu: *tinfo = leaftype; - for (wlu != nil && wlu.kind == tykind.TY_NAMED) { - wlu = wlu.under; - }; + wlu = tichase(wlu); let wtsz: i32 = wlu.size: i32; if (viacx) { if (ptrroot) { @@ -30889,9 +30857,7 @@ fn cgassign(c: *cgen, n: *node) void = { let leafname: str = ""; if (leaftype != nil) { let lp: *tinfo = leaftype; - for (lp != nil && lp.kind == tykind.TY_NAMED) { - lp = lp.under; - }; + lp = tichase(lp); if (lp != nil) { if (lp.kind == tykind.TY_STRUCT) { leafstruct = true; }; }; @@ -31366,7 +31332,7 @@ fn cgassign(c: *cgen, n: *node) void = { }; if (lvftn.kind == nkind.N_TARRAY) { let gat: *tinfo = lvftn.type_: *tinfo; - for (gat != nil && gat.kind == tykind.TY_NAMED) { gat = gat.under; }; + gat = tichase(gat); if (gat != nil) { gsz = gat.size: i32; }; }; if (gsz > 24) { @@ -31395,7 +31361,7 @@ fn cgassign(c: *cgen, n: *node) void = { && lvftn.kind == nkind.N_TARRAY) { let aggsz: i32 = 0; let aat: *tinfo = lvftn.type_: *tinfo; - for (aat != nil && aat.kind == tykind.TY_NAMED) { aat = aat.under; }; + aat = tichase(aat); if (aat != nil) { aggsz = aat.size: i32; }; if (aggsz > 0 && aggsz <= 24) { cgexpr(c, n.rhs); @@ -31438,9 +31404,7 @@ fn cgassign(c: *cgen, n: *node) void = { // tail below: one MOVQ AX, g(SB). if (n.op == tkind.TK_ASSIGN && lvftn != nil) { let gau: *tinfo = lvftn.type_: *tinfo; - for (gau != nil && gau.kind == tykind.TY_NAMED) { - gau = gau.under; - }; + gau = tichase(gau); if (gau != nil) { if (gau.kind == tykind.TY_STRUCT || gau.kind == tykind.TY_ARRAY @@ -31749,9 +31713,7 @@ fn cgassign(c: *cgen, n: *node) void = { && n.rhs != nil && n.rhs.kind == nkind.N_CALL) { let acati: *tinfo = nil; if (lcn.tnode != nil) { acati = lcn.tnode.type_: *tinfo; }; - for (acati != nil && acati.kind == tykind.TY_NAMED) { - acati = acati.under; - }; + acati = tichase(acati); if (acati != nil && acati.kind == tykind.TY_ARRAY) { let lcsz: i32 = acati.size: i32; if (lcsz > 24) { @@ -31872,9 +31834,7 @@ fn cgassign(c: *cgen, n: *node) void = { agu = lcn.tnode.type_: *tinfo; }; }; - for (agu != nil && agu.kind == tykind.TY_NAMED) { - agu = agu.under; - }; + agu = tichase(agu); if (agu != nil) { if (agu.kind == tykind.TY_STRUCT || agu.kind == tykind.TY_ARRAY @@ -32036,9 +31996,7 @@ fn cgassign(c: *cgen, n: *node) void = { || (lhs.kind == nkind.N_UN && lhs.op == tkind.TK_STAR)) { let ft: *tinfo = lhs.type_: *tinfo; let fu: *tinfo = ft; - for (fu != nil && fu.kind == tykind.TY_NAMED) { - fu = fu.under; - }; + fu = tichase(fu); let fsz: i32 = 8; if (ft != nil) { fsz = ft.size: i32; }; if (typeisfloat(ft)) {