wcc_ww: c1 collapse plain TY_NAMED chase loops into tichase across cgenstmt/cgen/check — byte-id neutral

F2a batch-4 c1, mechanical, per rob's spec census (re-verified at
4adf914; check.ww/cgenstmt.ww cites were stable as predicted, the
two cgenutil [B3-SHIFT] cites moved +8: :2746->:2754, :2895->:2903).

42 conversions, every site eyes-classified plain nil+NAMED:
- cgenstmt.ww 26: one-line :149 :325 :352 :532 :551 :594 :715 :732
  :938 :940 :1577 :1629 :1782 :2230 :2575 :3372 :3678 + multi-line
  :986 :1912 :2287 :2291 :2702 :2759 :2823 :3037 :3715 (all plain,
  no extra guards).
- cgen.ww 13: one-line :1505 :1541 :1658 :1691 :1697 :1947 :1951
  :2065 :2109 :2118 + multi-line :2239 :2648 :2663 (incl. the
  emitdefconstants struct/array arms — plain).
- check.ww 3: :1627 tupleelemslot, :1673 fieldslotsize, :4111 arrlit
  elem chase; WHY comments kept. tichase visibility verified: same
  `package wcc` (cgenstmt/cgen already call it) — no second helper.

Survivors (classified, untouched):
- cgenutil.ww :1301 tichase's own body (the accessor) + :2754
  nullableptrtag single peel (batch-2 c3-B2 PROBE-CLEARED, 018ef66 —
  peel-ok annotation added this commit, cites the banked record; cs
  twin cmd/w6c/cgen.c:747 verified at this SHA) + :2903
  flatvariantidxt pass-2 guard (batch-4 c2's site).
- check.ww :1765 comment + :1805 construction write (peellint-ok
  annotation added — the one WRITE building the NAMED link) + :2038
  spread peel (c3-B1) + :2273/:2275 &len/cap hand-walk (c3-B2) +
  :3666 comment FALSE POSITIVE ("io.underread" matches `.under`).
- cgenexpr.ww :2886 comment only.

Lint note for the peellint finale: the `.under` token-match must be
token-bounded — check.ww:3666's "io.underread" is a comment
false-positive at a non-boundary match.

Behavior sites (:2038, :2273/:2275, :2903) and #80's site excluded
per spec — they ride c2-c4.

Byte-neutral proof: rebuilt w6c_ww on the five BASE main.combined.ww
inputs -> all five .s byte-identical to the base build's outputs;
cs==ww byte-id holds on the five REGENERATED combineds; test-unit
290 green. w6c_ww + wwdump combined.ww regens ride along.
This commit is contained in:
2026-06-05 23:58:54 +09:00
parent 4adf914f2f
commit b26b3dbdc5
6 changed files with 147 additions and 198 deletions

View File

@@ -1502,7 +1502,7 @@ fn emitfloatlitdata(c: *cgen, directive: str, name: str, module: str,
fn emitstructlitbytes(c: *cgen, structt: *tinfo, rhs: *node,
base: u64) bool = {
let su: *tinfo = structt;
for (su != nil && su.kind == tykind.TY_NAMED) { su = su.under; };
su = tichase(su);
if (su == nil) { return false; };
if (su.kind != tykind.TY_STRUCT) { return false; };
let pos: u64 = base;
@@ -1538,7 +1538,7 @@ fn emitstructlitbytes(c: *cgen, structt: *tinfo, rhs: *node,
let vr: *node = v;
for (vr != nil && vr.kind == nkind.N_CAST) { vr = vr.lhs; };
let fu: *tinfo = f.type_;
for (fu != nil && fu.kind == tykind.TY_NAMED) { fu = fu.under; };
fu = tichase(fu);
if (fu != nil && fu.kind == tykind.TY_STRUCT) {
if (vr == nil) {
let m: str = "emitstructlitbytes: nested struct field rhs nil (#129 A.2)\n";
@@ -1655,7 +1655,7 @@ fn emitstructlitbytes(c: *cgen, structt: *tinfo, rhs: *node,
fn emitstructdata(c: *cgen, directive: str, name: str, module: str,
structt: *tinfo, rhs: *node) bool = {
let su: *tinfo = structt;
for (su != nil && su.kind == tykind.TY_NAMED) { su = su.under; };
su = tichase(su);
if (su == nil) { return false; };
if (su.kind != tykind.TY_STRUCT) { return false; };
emitline(directive);
@@ -1688,13 +1688,13 @@ fn emitstructdata(c: *cgen, directive: str, name: str, module: str,
fn emitarraylitbytes(c: *cgen, arrt: *tinfo, rhs: *node,
emit_phase: i32) bool = {
let au: *tinfo = arrt;
for (au != nil && au.kind == tykind.TY_NAMED) { au = au.under; };
au = tichase(au);
if (au == nil) { return false; };
if (au.kind != tykind.TY_ARRAY) { return false; };
let esz: i32 = au.sub.size: i32;
let alen: i32 = au.alen: i32;
let eu: *tinfo = au.sub;
for (eu != nil && eu.kind == tykind.TY_NAMED) { eu = eu.under; };
eu = tichase(eu);
if (eu != nil && eu.kind == tykind.TY_STRUCT) {
// Validate: every element must be N_STRUCTLIT (after N_CAST).
@@ -1944,11 +1944,11 @@ fn emitarraylitbytes(c: *cgen, arrt: *tinfo, rhs: *node,
fn emitstrarraydata(c: *cgen, directive: str, name: str, module: str,
arrt: *tinfo, rhs: *node) bool = {
let au: *tinfo = arrt;
for (au != nil && au.kind == tykind.TY_NAMED) { au = au.under; };
au = tichase(au);
if (au == nil) { return false; };
if (au.kind != tykind.TY_ARRAY) { return false; };
let eu: *tinfo = au.sub;
for (eu != nil && eu.kind == tykind.TY_NAMED) { eu = eu.under; };
eu = tichase(eu);
if (eu == nil) { return false; };
if (eu.kind != tykind.TY_STR) { return false; };
if (!streq(directive, "DATAW")) { return false; };
@@ -2062,7 +2062,7 @@ fn emitstrarraydata(c: *cgen, directive: str, name: str, module: str,
fn emitarraydata(c: *cgen, directive: str, name: str, module: str,
arrt: *tinfo, rhs: *node) bool = {
let au: *tinfo = arrt;
for (au != nil && au.kind == tykind.TY_NAMED) { au = au.under; };
au = tichase(au);
if (au == nil) { return false; };
if (au.kind != tykind.TY_ARRAY) { return false; };
if (rhs == nil) {
@@ -2106,7 +2106,7 @@ fn emitarraydata(c: *cgen, directive: str, name: str, module: str,
fn emitslicedata(c: *cgen, name: str, module: str, slt: *tinfo,
rhs: *node) void = {
let su: *tinfo = slt;
for (su != nil && su.kind == tykind.TY_NAMED) { su = su.under; };
su = tichase(su);
// Defensive, mirrors cstage emit_slice_data's
// `if (u == NULL || u->kind != TY_SLICE) return 0` (rule-10): the
// letvarisslice gate already guarantees a slice, so this is
@@ -2115,7 +2115,7 @@ fn emitslicedata(c: *cgen, name: str, module: str, slt: *tinfo,
if (su == nil || su.kind != tykind.TY_SLICE) { return; };
let etype: *tinfo = su.sub;
let eu: *tinfo = etype;
for (eu != nil && eu.kind == tykind.TY_NAMED) { eu = eu.under; };
eu = tichase(eu);
if (eu != nil) {
if (eu.kind == tykind.TY_STR || eu.kind == tykind.TY_SLICE
|| eu.kind == tykind.TY_TAGGED) {
@@ -2235,9 +2235,7 @@ fn emittupledata(c: *cgen, name: str, module: str, tt: *node, rhs: *node) bool =
{
let eti: *tinfo = nil;
if (et != nil) { eti = et.type_: *tinfo; };
for (eti != nil && eti.kind == tykind.TY_NAMED) {
eti = eti.under;
};
eti = tichase(eti);
if (eti != nil && eti.kind == tykind.TY_TAGGED) {
return false;
};
@@ -2644,9 +2642,7 @@ fn emitdefconstants(c: *cgen, file: *node) void = {
if (r != nil) { if (r.kind == nkind.N_STRUCTLIT) {
let st: *tinfo = d.lhs.type_: *tinfo;
let su: *tinfo = st;
for (su != nil && su.kind == tykind.TY_NAMED) {
su = su.under;
};
su = tichase(su);
if (su != nil) {
if (su.kind == tykind.TY_STRUCT) {
emitstructdata(c, "DATA",
@@ -2659,9 +2655,7 @@ fn emitdefconstants(c: *cgen, file: *node) void = {
if (r != nil) { if (r.kind == nkind.N_ARRLIT) {
let at: *tinfo = d.lhs.type_: *tinfo;
let au: *tinfo = at;
for (au != nil && au.kind == tykind.TY_NAMED) {
au = au.under;
};
au = tichase(au);
if (au != nil) {
if (au.kind == tykind.TY_ARRAY) {
emitarraydata(c, "DATA",