selfhost/cmd/wcc: collapse type-kind predicates onto n.type_ (A.6.3b, #46)
The node-keyed kind helpers (typeis8byteprimitive, isstrtype/raw,
isslicetype/raw, istaggedtype/raw, isfloattype, isf32type/raw,
isf64typeraw, isnullabletype) each re-walked TNAME aliases via
aliaslookup and peeled TBANG by hand — duplicating cstage's single-
peel kind predicates at the AST level. After A.6.2 every type-AST
kind these read is tinfo-stamped at check.ww L426-436, and
tinfofornode collapses N_TBANG (check.ww:1145-1152) and the TY_NAMED
chain, so each predicate folds to one tinfo read.
Six new tinfo helpers in lib/ww/typ.ww mirror their cstage SSoT
verbatim:
typeisstr — cstage cgen.c:159 `type_isstr` (TY_STR / TY_UNTYPED_STR)
typeisslice — cstage cgen.c:174 `type_isslice`
typeistagged — cstage cgen.c:516 `type_istagged`
typeisf32 — cstage cgen.c:188 `type_isf32`
typeisnullable — cstage cgen.c:396 `type_isnullable` (reads tinfo.nullable
stamped at check.ww:1309-1318)
typeis8byteprim — cstage cgen.c N_LET sz==8 ladder (slot-pad set)
Rule 9 carve-out per the A.6.3a precedent: each helper has a named
cstage counterpart; the wwstage shape mirrors it directly. The five
dead AST-walking variants (isstrtyperaw, isslicetyperaw,
istaggedtyperaw, isf32typeraw, isf64typeraw) are deleted; the five
remaining callsites (cgenstmt cglet / cgmlet str-routing, cgenexpr
cgdot tuple-field) graduate to the alias-aware isstrtype(c, t).
nullableptrtag stays AST-keyed for now — tinfofornode doesn't
populate TY_TAGGED.params (check.ww:1287-1337 sets size / align /
nullable but not the variant chain), so the tinfo equivalent of
cstage cgen.c:405 `nullable_ptr_tag` can't read params today. WHY
comment at the site cites #50 / A.6.3f as the graduation point,
alongside the variant-index work and the tparam-population glue.
Byte-identity (994/995) is the behavior gate; full `make test` green
at 133/133 confirms.
This commit is contained in:
@@ -712,8 +712,8 @@ fn cglet(c: *cgen, n: *node) void = {
|
||||
let p1t: *node = nil;
|
||||
if (p0 != nil) { p0t = p0.lhs; };
|
||||
if (p1 != nil) { p1t = p1.lhs; };
|
||||
let s0_is_str: bool = isstrtyperaw(p0t);
|
||||
let s1_is_str: bool = isstrtyperaw(p1t);
|
||||
let s0_is_str: bool = isstrtype(c, p0t);
|
||||
let s1_is_str: bool = isstrtype(c, p1t);
|
||||
if (p0 != nil) {
|
||||
if (p1 != nil) {
|
||||
if (s0_is_str != s1_is_str) {
|
||||
@@ -1255,8 +1255,8 @@ fn cgmlet(c: *cgen, n: *node) void = {
|
||||
if (t0 == nil) { t0 = p0t; };
|
||||
if (t1 == nil) { t1 = p1t; };
|
||||
|
||||
let s0_is_str: bool = isstrtyperaw(t0);
|
||||
let s1_is_str: bool = isstrtyperaw(t1);
|
||||
let s0_is_str: bool = isstrtype(c, t0);
|
||||
let s1_is_str: bool = isstrtype(c, t1);
|
||||
|
||||
cgexpr(c, rhs);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user