wcc: add the size primitive type (TY_SIZE), classify as unsigned int (#85)

fold-1: type exists + classifies; mirrors TY_UINTPTR at every site, both stages. size(T)/len() return types UNCHANGED (fold-2). Regenerates the 5 combined.ww (lib/ww embedded).
This commit is contained in:
2026-05-26 01:26:03 +09:00
parent 68dbb77d6c
commit bd7181ae1f
7 changed files with 38 additions and 15 deletions

View File

@@ -57,6 +57,7 @@ type tykind = enum i32 {
// Tail-appended values keep prior TY_* stable for the byte-diff
// against cmd/wcc/ww.h.
TY_ENUM = 35,
TY_SIZE = 36, // #85 fold-1; mirrors TY_UINTPTR (8/8 amd64)
};
// ---- tinfo / tfield / tparam -----------------------------------------
@@ -158,6 +159,7 @@ type tctx = struct {
tyint: *tinfo,
tyuint: *tinfo,
tyuintptr: *tinfo,
tysize: *tinfo,
tyf32: *tinfo,
tyf64: *tinfo,
tystr: *tinfo,
@@ -203,6 +205,7 @@ export fn typesinit(c: *tctx) void = {
c.tyint = prim(tykind.TY_INT, "int", 8u64, 8u64);
c.tyuint = prim(tykind.TY_UINT, "uint", 8u64, 8u64);
c.tyuintptr= prim(tykind.TY_UINTPTR, "uintptr", 8u64, 8u64);
c.tysize = prim(tykind.TY_SIZE, "size", 8u64, 8u64); // #85
c.tyf32 = prim(tykind.TY_F32, "f32", 4u64, 4u64);
c.tyf64 = prim(tykind.TY_F64, "f64", 8u64, 8u64);
// str IS []u8: { *u8, len, cap } — 24B, 3-reg ABI (#1/Phase 3).
@@ -323,6 +326,7 @@ export fn typeisint(t: *tinfo) bool = {
if (k == tykind.TY_INT) { return true; };
if (k == tykind.TY_UINT){ return true; };
if (k == tykind.TY_UINTPTR) { return true; };
if (k == tykind.TY_SIZE) { return true; };
if (k == tykind.TY_RUNE){ return true; };
if (k == tykind.TY_UNTYPED_INT) { return true; };
if (k == tykind.TY_UNTYPED_RUNE) { return true; };
@@ -359,6 +363,7 @@ export fn typeisunsigned(t: *tinfo) bool = {
if (k == tykind.TY_U64) { return true; };
if (k == tykind.TY_UINT){ return true; };
if (k == tykind.TY_UINTPTR) { return true; };
if (k == tykind.TY_SIZE) { return true; };
if (k == tykind.TY_RUNE){ return true; };
if (k == tykind.TY_NAMED) { return typeisunsigned(t.under); };
if (k == tykind.TY_ENUM) { return typeisunsigned(t.sub); };