diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index b0f98f9e..32d1ea11 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -12016,7 +12016,8 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { if (cached != nil) { return cached; }; let r: *tinfo = nil; let k: nkind = n.kind; - if (k == nkind.N_TNAME) { + switch (k) { + case nkind.N_TNAME: let nm: str = n.str; if (streq(nm, "void")) { r = c.tc.tyvoid; }; if (streq(nm, "bool")) { r = c.tc.tybool; }; @@ -12090,7 +12091,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { }; }; }; - } else { if (k == nkind.N_TBANG) { + case nkind.N_TBANG: // #61 audit §1.8: `!T` propagates the inner shape; cstage's // resolve_type sets ty->iserror on the wrapper but no wwstage // cgen reader consumes it yet, so A.1 drops the flag and @@ -12098,13 +12099,13 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { // unwrapbang pre-walk; graduate alongside the first cgen // site that needs iserror discrimination. r = tinfofornode(c, n.lhs); - } else { if (k == nkind.N_TPTR) { + case nkind.N_TPTR: r = typeptr(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TSLICE) { + case nkind.N_TSLICE: r = typeslice(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TCHAN) { + case nkind.N_TCHAN: r = typechan(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TARRAY) { + case nkind.N_TARRAY: // Cstage cmd/wcc/check.c:314-326: length must be an integer // literal (`[_]T` keeps alen=0 as the inferred-length sentinel // patched at letslotsize-time). @@ -12120,7 +12121,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { }; let sub: *tinfo = tinfofornode(c, n.lhs); r = typearray(sub, elen); - } else { if (k == nkind.N_TFN) { + case nkind.N_TFN: // Cstage cmd/wcc/check.c:437-466: function types are 8B / 8B // (call-target pointer shape). Pre-bind before recursing into // the return type so a recursive `type F = fn() F` self-ref @@ -12132,7 +12133,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.slotsize = 8u64; tinfocachebind(c.tc, n, r); r.ret = tinfofornode(c, n.lhs); - } else { if (k == nkind.N_TENUM) { + case nkind.N_TENUM: // Cstage cmd/wcc/check.c:529-542: storage type's size/align // (default i32 = 4B/4B). Cgen's slotsize-TENUM fallback pads // to 8B per its stack-slot contract; tinfo.size carries the @@ -12145,7 +12146,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = storage.size; r.align = storage.align; r.slotsize = storage.size; - } else { if (k == nkind.N_TTUPLE) { + case nkind.N_TTUPLE: // Cstage cmd/wcc/check.c:329-345: sum of element sizes with // per-element alignment NOT padded — cstage uses raw sums for // tuples and 8B-rounding lives at the call/return ABI layer. @@ -12196,7 +12197,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = total; r.align = maxal; r.slotsize = slottotal; - } else { if (k == nkind.N_TSTRUCT) { + case nkind.N_TSTRUCT: // Cstage cmd/wcc/check.c:468-527: per-field alignment, max // align for the whole record, total rounded up to alignment. // Anonymous-embed promotion is deferred (#13). @@ -12271,7 +12272,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { soff = (soff + 7u64) & ~7u64; }; r.slotsize = soff; - } else { if (k == nkind.N_TTAGGED) { + case nkind.N_TTAGGED: // Cstage cmd/wcc/check.c:347-435: 8B tag + max(variant) // rounded up to 8. Pre-bind for cycle protection (recursive // sum-type shapes through NAMED variants). @@ -12371,7 +12372,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = 8u64 + pad; r.align = al; r.slotsize = 8u64 + pad; - };};};};};};};};};};}; + }; if (r != nil) { // #61 A.5: any arm that didn't set slotsize gets ti.size as // the default (covers primitives via prim() + the ptr/slice/ @@ -14846,10 +14847,11 @@ export fn checkfile(c: *checker, file: *node) void = { // inner nodes. if (d.attr != nil) { resolvewalk(c, d.attr); }; let k: nkind = d.kind; - if (k == nkind.N_FNDECL) { + switch (k) { + case nkind.N_FNDECL: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; // return type resolvefnbody(c, d); - } else { if (k == nkind.N_DEF) { + case nkind.N_DEF: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; if (d.rhs != nil) { resolvewalk(c, d.rhs); }; // #251: `def D: [N]T = [int/rune lits]` array-init @@ -14874,9 +14876,9 @@ export fn checkfile(c: *checker, file: *node) void = { }; }; }; - } else { if (k == nkind.N_TYPEDECL) { + case nkind.N_TYPEDECL: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; - } else { if (k == nkind.N_LET) { + case nkind.N_LET: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; if (d.rhs != nil) { resolvewalk(c, d.rhs); }; // #130: top-level let assignability — the subtree @@ -14886,7 +14888,7 @@ export fn checkfile(c: *checker, file: *node) void = { // were missed). Needed for the array accept-if-fits // range-check to fire on module-level `let A:[N]u8=[..]`. checkletassign(c, d); - };};};}; + }; d = d.next; }; diff --git a/selfhost/cmd/wcc/check.ww b/selfhost/cmd/wcc/check.ww index 63ceff1f..7c506f3b 100644 --- a/selfhost/cmd/wcc/check.ww +++ b/selfhost/cmd/wcc/check.ww @@ -1630,7 +1630,8 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { if (cached != nil) { return cached; }; let r: *tinfo = nil; let k: nkind = n.kind; - if (k == nkind.N_TNAME) { + switch (k) { + case nkind.N_TNAME: let nm: str = n.str; if (streq(nm, "void")) { r = c.tc.tyvoid; }; if (streq(nm, "bool")) { r = c.tc.tybool; }; @@ -1704,7 +1705,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { }; }; }; - } else { if (k == nkind.N_TBANG) { + case nkind.N_TBANG: // #61 audit §1.8: `!T` propagates the inner shape; cstage's // resolve_type sets ty->iserror on the wrapper but no wwstage // cgen reader consumes it yet, so A.1 drops the flag and @@ -1712,13 +1713,13 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { // unwrapbang pre-walk; graduate alongside the first cgen // site that needs iserror discrimination. r = tinfofornode(c, n.lhs); - } else { if (k == nkind.N_TPTR) { + case nkind.N_TPTR: r = typeptr(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TSLICE) { + case nkind.N_TSLICE: r = typeslice(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TCHAN) { + case nkind.N_TCHAN: r = typechan(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TARRAY) { + case nkind.N_TARRAY: // Cstage cmd/wcc/check.c:314-326: length must be an integer // literal (`[_]T` keeps alen=0 as the inferred-length sentinel // patched at letslotsize-time). @@ -1734,7 +1735,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { }; let sub: *tinfo = tinfofornode(c, n.lhs); r = typearray(sub, elen); - } else { if (k == nkind.N_TFN) { + case nkind.N_TFN: // Cstage cmd/wcc/check.c:437-466: function types are 8B / 8B // (call-target pointer shape). Pre-bind before recursing into // the return type so a recursive `type F = fn() F` self-ref @@ -1746,7 +1747,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.slotsize = 8u64; tinfocachebind(c.tc, n, r); r.ret = tinfofornode(c, n.lhs); - } else { if (k == nkind.N_TENUM) { + case nkind.N_TENUM: // Cstage cmd/wcc/check.c:529-542: storage type's size/align // (default i32 = 4B/4B). Cgen's slotsize-TENUM fallback pads // to 8B per its stack-slot contract; tinfo.size carries the @@ -1759,7 +1760,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = storage.size; r.align = storage.align; r.slotsize = storage.size; - } else { if (k == nkind.N_TTUPLE) { + case nkind.N_TTUPLE: // Cstage cmd/wcc/check.c:329-345: sum of element sizes with // per-element alignment NOT padded — cstage uses raw sums for // tuples and 8B-rounding lives at the call/return ABI layer. @@ -1810,7 +1811,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = total; r.align = maxal; r.slotsize = slottotal; - } else { if (k == nkind.N_TSTRUCT) { + case nkind.N_TSTRUCT: // Cstage cmd/wcc/check.c:468-527: per-field alignment, max // align for the whole record, total rounded up to alignment. // Anonymous-embed promotion is deferred (#13). @@ -1885,7 +1886,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { soff = (soff + 7u64) & ~7u64; }; r.slotsize = soff; - } else { if (k == nkind.N_TTAGGED) { + case nkind.N_TTAGGED: // Cstage cmd/wcc/check.c:347-435: 8B tag + max(variant) // rounded up to 8. Pre-bind for cycle protection (recursive // sum-type shapes through NAMED variants). @@ -1985,7 +1986,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = 8u64 + pad; r.align = al; r.slotsize = 8u64 + pad; - };};};};};};};};};};}; + }; if (r != nil) { // #61 A.5: any arm that didn't set slotsize gets ti.size as // the default (covers primitives via prim() + the ptr/slice/ @@ -4460,10 +4461,11 @@ export fn checkfile(c: *checker, file: *node) void = { // inner nodes. if (d.attr != nil) { resolvewalk(c, d.attr); }; let k: nkind = d.kind; - if (k == nkind.N_FNDECL) { + switch (k) { + case nkind.N_FNDECL: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; // return type resolvefnbody(c, d); - } else { if (k == nkind.N_DEF) { + case nkind.N_DEF: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; if (d.rhs != nil) { resolvewalk(c, d.rhs); }; // #251: `def D: [N]T = [int/rune lits]` array-init @@ -4488,9 +4490,9 @@ export fn checkfile(c: *checker, file: *node) void = { }; }; }; - } else { if (k == nkind.N_TYPEDECL) { + case nkind.N_TYPEDECL: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; - } else { if (k == nkind.N_LET) { + case nkind.N_LET: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; if (d.rhs != nil) { resolvewalk(c, d.rhs); }; // #130: top-level let assignability — the subtree @@ -4500,7 +4502,7 @@ export fn checkfile(c: *checker, file: *node) void = { // were missed). Needed for the array accept-if-fits // range-check to fire on module-level `let A:[N]u8=[..]`. checkletassign(c, d); - };};};}; + }; d = d.next; }; diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index 229edcee..eed95047 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -12016,7 +12016,8 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { if (cached != nil) { return cached; }; let r: *tinfo = nil; let k: nkind = n.kind; - if (k == nkind.N_TNAME) { + switch (k) { + case nkind.N_TNAME: let nm: str = n.str; if (streq(nm, "void")) { r = c.tc.tyvoid; }; if (streq(nm, "bool")) { r = c.tc.tybool; }; @@ -12090,7 +12091,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { }; }; }; - } else { if (k == nkind.N_TBANG) { + case nkind.N_TBANG: // #61 audit §1.8: `!T` propagates the inner shape; cstage's // resolve_type sets ty->iserror on the wrapper but no wwstage // cgen reader consumes it yet, so A.1 drops the flag and @@ -12098,13 +12099,13 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { // unwrapbang pre-walk; graduate alongside the first cgen // site that needs iserror discrimination. r = tinfofornode(c, n.lhs); - } else { if (k == nkind.N_TPTR) { + case nkind.N_TPTR: r = typeptr(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TSLICE) { + case nkind.N_TSLICE: r = typeslice(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TCHAN) { + case nkind.N_TCHAN: r = typechan(tinfofornode(c, n.lhs)); - } else { if (k == nkind.N_TARRAY) { + case nkind.N_TARRAY: // Cstage cmd/wcc/check.c:314-326: length must be an integer // literal (`[_]T` keeps alen=0 as the inferred-length sentinel // patched at letslotsize-time). @@ -12120,7 +12121,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { }; let sub: *tinfo = tinfofornode(c, n.lhs); r = typearray(sub, elen); - } else { if (k == nkind.N_TFN) { + case nkind.N_TFN: // Cstage cmd/wcc/check.c:437-466: function types are 8B / 8B // (call-target pointer shape). Pre-bind before recursing into // the return type so a recursive `type F = fn() F` self-ref @@ -12132,7 +12133,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.slotsize = 8u64; tinfocachebind(c.tc, n, r); r.ret = tinfofornode(c, n.lhs); - } else { if (k == nkind.N_TENUM) { + case nkind.N_TENUM: // Cstage cmd/wcc/check.c:529-542: storage type's size/align // (default i32 = 4B/4B). Cgen's slotsize-TENUM fallback pads // to 8B per its stack-slot contract; tinfo.size carries the @@ -12145,7 +12146,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = storage.size; r.align = storage.align; r.slotsize = storage.size; - } else { if (k == nkind.N_TTUPLE) { + case nkind.N_TTUPLE: // Cstage cmd/wcc/check.c:329-345: sum of element sizes with // per-element alignment NOT padded — cstage uses raw sums for // tuples and 8B-rounding lives at the call/return ABI layer. @@ -12196,7 +12197,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = total; r.align = maxal; r.slotsize = slottotal; - } else { if (k == nkind.N_TSTRUCT) { + case nkind.N_TSTRUCT: // Cstage cmd/wcc/check.c:468-527: per-field alignment, max // align for the whole record, total rounded up to alignment. // Anonymous-embed promotion is deferred (#13). @@ -12271,7 +12272,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { soff = (soff + 7u64) & ~7u64; }; r.slotsize = soff; - } else { if (k == nkind.N_TTAGGED) { + case nkind.N_TTAGGED: // Cstage cmd/wcc/check.c:347-435: 8B tag + max(variant) // rounded up to 8. Pre-bind for cycle protection (recursive // sum-type shapes through NAMED variants). @@ -12371,7 +12372,7 @@ fn tinfofornode(c: *checker, n: *node) *tinfo = { r.size = 8u64 + pad; r.align = al; r.slotsize = 8u64 + pad; - };};};};};};};};};};}; + }; if (r != nil) { // #61 A.5: any arm that didn't set slotsize gets ti.size as // the default (covers primitives via prim() + the ptr/slice/ @@ -14846,10 +14847,11 @@ export fn checkfile(c: *checker, file: *node) void = { // inner nodes. if (d.attr != nil) { resolvewalk(c, d.attr); }; let k: nkind = d.kind; - if (k == nkind.N_FNDECL) { + switch (k) { + case nkind.N_FNDECL: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; // return type resolvefnbody(c, d); - } else { if (k == nkind.N_DEF) { + case nkind.N_DEF: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; if (d.rhs != nil) { resolvewalk(c, d.rhs); }; // #251: `def D: [N]T = [int/rune lits]` array-init @@ -14874,9 +14876,9 @@ export fn checkfile(c: *checker, file: *node) void = { }; }; }; - } else { if (k == nkind.N_TYPEDECL) { + case nkind.N_TYPEDECL: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; - } else { if (k == nkind.N_LET) { + case nkind.N_LET: if (d.lhs != nil) { resolvewalk(c, d.lhs); }; if (d.rhs != nil) { resolvewalk(c, d.rhs); }; // #130: top-level let assignability — the subtree @@ -14886,7 +14888,7 @@ export fn checkfile(c: *checker, file: *node) void = { // were missed). Needed for the array accept-if-fits // range-check to fire on module-level `let A:[N]u8=[..]`. checkletassign(c, d); - };};};}; + }; d = d.next; };