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:
@@ -376,9 +376,9 @@ export fn isxdigit(c: rune) bool = {
|
||||
return false;
|
||||
};
|
||||
|
||||
// digitval — value of `c` as a hex/decimal digit, or -1 if not one.
|
||||
// Useful when scanning numeric literals.
|
||||
export fn digitval(c: rune) i32 = {
|
||||
// digitval — value of `c` as a hex/decimal digit. void variant means
|
||||
// `c` isn't a hex digit. Useful when scanning numeric literals.
|
||||
export fn digitval(c: rune) (i32 | void) = {
|
||||
if (isdigit(c)) { return (c - 48): i32; };
|
||||
if (c >= 65) {
|
||||
if (c <= 70) { return ((c - 65) + 10): i32; };
|
||||
@@ -386,7 +386,7 @@ export fn digitval(c: rune) i32 = {
|
||||
if (c >= 97) {
|
||||
if (c <= 102) { return ((c - 97) + 10): i32; };
|
||||
};
|
||||
return -1;
|
||||
return;
|
||||
};
|
||||
|
||||
// isidstart / isidpart — identifier classes used by the lexer.
|
||||
@@ -559,7 +559,11 @@ export fn main() i32 = {
|
||||
if (!ascii.isalpha(122)) { return 16; }; // 'z'
|
||||
if (!ascii.isidstart(95)) { return 17; }; // '_'
|
||||
if (!ascii.isidpart(48)) { return 18; }; // '0' is part
|
||||
if (ascii.digitval(70) != 15) { return 19; }; // 'F' = 15
|
||||
let dv: (i32 | void) = ascii.digitval(70);
|
||||
match (dv) {
|
||||
case let v: i32 => { if (v != 15) { return 19; }; }; // 'F' = 15
|
||||
case void => { return 19; };
|
||||
};
|
||||
if (ascii.tolower(65) != 97) { return 20; }; // 'A' -> 'a'
|
||||
|
||||
// Probe 7 — file open/read via the new os APIs. /proc/self/cmdline
|
||||
|
||||
@@ -142,7 +142,11 @@ export fn main() i32 = {
|
||||
if (!ascii.isalpha(122)) { return 16; }; // 'z'
|
||||
if (!ascii.isidstart(95)) { return 17; }; // '_'
|
||||
if (!ascii.isidpart(48)) { return 18; }; // '0' is part
|
||||
if (ascii.digitval(70) != 15) { return 19; }; // 'F' = 15
|
||||
let dv: (i32 | void) = ascii.digitval(70);
|
||||
match (dv) {
|
||||
case let v: i32 => { if (v != 15) { return 19; }; }; // 'F' = 15
|
||||
case void => { return 19; };
|
||||
};
|
||||
if (ascii.tolower(65) != 97) { return 20; }; // 'A' -> 'a'
|
||||
|
||||
// Probe 7 — file open/read via the new os APIs. /proc/self/cmdline
|
||||
|
||||
Reference in New Issue
Block a user