ascii: graduate digitval to (i32 | void); selfhost tagged ABI follow-on

ascii.digitval returns (i32 | void) instead of an i32 -1 sentinel.
Two callers updated to match-on the result (lib/ww/lex/lex.ww escape
parse, selfhost/test/smoke.ww probe 6).

`!` would have been more idiomatic at both call sites — both have
verified isxdigit beforehand — but the selfhost parser doesn't yet
recognize postfix `!`/`?`, so using them in bootstrap-bound code
breaks the 993/995 byte-identity gates. Match is fine for now.

Selfhost cgen follow-on for the 8-byte-rounded tagged-union ABI
(landed in 1e2f55a for the C side):
- cgenutil.slotsize: tagged size = 8 (tag) + max(payload), padded to
  8-byte multiple. Was hardcoded 24.
- cgendecl prologue: spill size/8 arg registers, not always 3.
- cgenstmt cglet tagged-call path: spill the CX value-word only when
  the slot is >16 bytes.

All three were emitting 3-register patterns appropriate to (T | str)
sized unions and overflowing the new 16-byte (i32 | void) slots.
This commit is contained in:
2026-05-12 02:10:10 +09:00
parent 4085742853
commit 2f385cec00
9 changed files with 173 additions and 99 deletions

View File

@@ -240,8 +240,18 @@ fn escape(l: *lex, out: *i32) bool = {
errat(l, &cp, "bad \\x escape");
return false;
};
let h: i32 = ascii.digitval(hi: rune);
let lv: i32 = ascii.digitval(lo: rune);
let hr: (i32 | void) = ascii.digitval(hi: rune);
let lr: (i32 | void) = ascii.digitval(lo: rune);
let h: i32 = 0;
let lv: i32 = 0;
match (hr) {
case let v: i32 => h = v;
case void => { return false; };
};
match (lr) {
case let v: i32 => lv = v;
case void => { return false; };
};
*out = (h << 4) | lv;
return true;
};