selfhost/cmd/wcc: collapse typenameisunsigned onto tinfo (#52, A.6.3c-cast)

A.6.3a (#45) deferred typenameisunsigned because its two callers —
typenodeprimresolved and exprprimresolved — consumed a raw str:
TNAME.str / INTLIT.tsuffix. #51 (1ce0f63) stamped tsuffix-typed
N_INTLIT.type_ via tinfofornode; together with check.ww L426-436
type-AST stamping, both call sites now read a stamped n.type_
instead of a raw name.

typenodeprimresolved L1583 swaps typenameisunsigned(nm) for
typeisunsigned(cur.type_: *tinfo). cur is the walked N_TNAME; its
type_ is stamped at check time.

exprprimresolved L1620 swaps typenameisunsigned(s) for typeisunsigned
(n.type_: *tinfo). n is the N_INTLIT whose tsuffix is s; type_ is
stamped by the #51 arm. primsize(s) > 0 IS the tsuffix-resolves-to-
builtin gate, so the stamp is guaranteed at the read site.

typenameisunsigned (cgenutil.ww L850-866) deleted: -17 LOC of body
+ WHY block. Net change is three files (cgenutil.ww + two
.combined.ww bundler regens, same -17 each).

Mirrors cstage cmd/wcc/type.c:178 type_isunsigned plus cmd/w6c/cgen.c
castsrcprim routing INTLIT.tsuffix through n->type, then
type_isunsigned. Aligned, not richer.

Byte-identity (994/995) is the behavior gate; full make test green
at 133/133 confirms.
This commit is contained in:
2026-05-22 23:44:31 +09:00
parent 3eef2828c6
commit 747279c029
3 changed files with 6 additions and 57 deletions

View File

@@ -11221,23 +11221,6 @@ fn nodeisstr(c: *cgen, n: *node) bool = {
return false; return false;
}; };
// typenameisunsigned — primitive-name unsigned check. Kept because
// two call sites (typenodeprimresolved L1729, exprprimresolved L1766)
// have only a raw `str` in scope (TNAME.str / INTLIT.tsuffix), not a
// stamped *node — the typed-AST path doesn't reach them yet (#47
// A.6.3c). The node-keyed predicates collapsed onto
// typeisunsigned(n.type_: *tinfo) per A.6.3a (#45).
fn typenameisunsigned(nm: str) bool = {
if (streq(nm, "u8")) { return true; };
if (streq(nm, "u16")) { return true; };
if (streq(nm, "u32")) { return true; };
if (streq(nm, "u64")) { return true; };
if (streq(nm, "uint")) { return true; };
if (streq(nm, "uintptr")) { return true; };
if (streq(nm, "rune")) { return true; };
return false;
};
// typeis8byteprimitive — does this type take exactly one 8-byte // typeis8byteprimitive — does this type take exactly one 8-byte
// slot rather than a wider aggregate? One-liner via typeis8byteprim // slot rather than a wider aggregate? One-liner via typeis8byteprim
// (cstage N_LET sz==8 ladder SSoT). t.type_ is stamped at check.ww // (cstage N_LET sz==8 ladder SSoT). t.type_ is stamped at check.ww
@@ -11969,7 +11952,7 @@ export fn typenodeprimresolved(c: *cgen, t: *node,
let ps: i32 = primsize(nm); let ps: i32 = primsize(nm);
if (ps > 0) { if (ps > 0) {
*sz_out = ps; *sz_out = ps;
*unsigned_out = typenameisunsigned(nm); *unsigned_out = typeisunsigned(cur.type_: *tinfo);
return; return;
}; };
let al: *node = aliaslookup(c, nm); let al: *node = aliaslookup(c, nm);
@@ -12006,7 +11989,7 @@ export fn exprprimresolved(c: *cgen, n: *node,
let ps: i32 = primsize(s); let ps: i32 = primsize(s);
if (ps > 0) { if (ps > 0) {
*sz_out = ps; *sz_out = ps;
*unsigned_out = typenameisunsigned(s); *unsigned_out = typeisunsigned(n.type_: *tinfo);
}; };
}; };
return; return;

View File

@@ -849,23 +849,6 @@ fn nodeisstr(c: *cgen, n: *node) bool = {
return false; return false;
}; };
// typenameisunsigned — primitive-name unsigned check. Kept because
// two call sites (typenodeprimresolved L1729, exprprimresolved L1766)
// have only a raw `str` in scope (TNAME.str / INTLIT.tsuffix), not a
// stamped *node — the typed-AST path doesn't reach them yet (#47
// A.6.3c). The node-keyed predicates collapsed onto
// typeisunsigned(n.type_: *tinfo) per A.6.3a (#45).
fn typenameisunsigned(nm: str) bool = {
if (streq(nm, "u8")) { return true; };
if (streq(nm, "u16")) { return true; };
if (streq(nm, "u32")) { return true; };
if (streq(nm, "u64")) { return true; };
if (streq(nm, "uint")) { return true; };
if (streq(nm, "uintptr")) { return true; };
if (streq(nm, "rune")) { return true; };
return false;
};
// typeis8byteprimitive — does this type take exactly one 8-byte // typeis8byteprimitive — does this type take exactly one 8-byte
// slot rather than a wider aggregate? One-liner via typeis8byteprim // slot rather than a wider aggregate? One-liner via typeis8byteprim
// (cstage N_LET sz==8 ladder SSoT). t.type_ is stamped at check.ww // (cstage N_LET sz==8 ladder SSoT). t.type_ is stamped at check.ww
@@ -1597,7 +1580,7 @@ export fn typenodeprimresolved(c: *cgen, t: *node,
let ps: i32 = primsize(nm); let ps: i32 = primsize(nm);
if (ps > 0) { if (ps > 0) {
*sz_out = ps; *sz_out = ps;
*unsigned_out = typenameisunsigned(nm); *unsigned_out = typeisunsigned(cur.type_: *tinfo);
return; return;
}; };
let al: *node = aliaslookup(c, nm); let al: *node = aliaslookup(c, nm);
@@ -1634,7 +1617,7 @@ export fn exprprimresolved(c: *cgen, n: *node,
let ps: i32 = primsize(s); let ps: i32 = primsize(s);
if (ps > 0) { if (ps > 0) {
*sz_out = ps; *sz_out = ps;
*unsigned_out = typenameisunsigned(s); *unsigned_out = typeisunsigned(n.type_: *tinfo);
}; };
}; };
return; return;

View File

@@ -11221,23 +11221,6 @@ fn nodeisstr(c: *cgen, n: *node) bool = {
return false; return false;
}; };
// typenameisunsigned — primitive-name unsigned check. Kept because
// two call sites (typenodeprimresolved L1729, exprprimresolved L1766)
// have only a raw `str` in scope (TNAME.str / INTLIT.tsuffix), not a
// stamped *node — the typed-AST path doesn't reach them yet (#47
// A.6.3c). The node-keyed predicates collapsed onto
// typeisunsigned(n.type_: *tinfo) per A.6.3a (#45).
fn typenameisunsigned(nm: str) bool = {
if (streq(nm, "u8")) { return true; };
if (streq(nm, "u16")) { return true; };
if (streq(nm, "u32")) { return true; };
if (streq(nm, "u64")) { return true; };
if (streq(nm, "uint")) { return true; };
if (streq(nm, "uintptr")) { return true; };
if (streq(nm, "rune")) { return true; };
return false;
};
// typeis8byteprimitive — does this type take exactly one 8-byte // typeis8byteprimitive — does this type take exactly one 8-byte
// slot rather than a wider aggregate? One-liner via typeis8byteprim // slot rather than a wider aggregate? One-liner via typeis8byteprim
// (cstage N_LET sz==8 ladder SSoT). t.type_ is stamped at check.ww // (cstage N_LET sz==8 ladder SSoT). t.type_ is stamped at check.ww
@@ -11969,7 +11952,7 @@ export fn typenodeprimresolved(c: *cgen, t: *node,
let ps: i32 = primsize(nm); let ps: i32 = primsize(nm);
if (ps > 0) { if (ps > 0) {
*sz_out = ps; *sz_out = ps;
*unsigned_out = typenameisunsigned(nm); *unsigned_out = typeisunsigned(cur.type_: *tinfo);
return; return;
}; };
let al: *node = aliaslookup(c, nm); let al: *node = aliaslookup(c, nm);
@@ -12006,7 +11989,7 @@ export fn exprprimresolved(c: *cgen, n: *node,
let ps: i32 = primsize(s); let ps: i32 = primsize(s);
if (ps > 0) { if (ps > 0) {
*sz_out = ps; *sz_out = ps;
*unsigned_out = typenameisunsigned(s); *unsigned_out = typeisunsigned(n.type_: *tinfo);
}; };
}; };
return; return;