From 4f4504d10a5bf2148d8c98d9bbc5abcb114b9faa Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Thu, 21 May 2026 03:14:04 +0900 Subject: [PATCH] =?UTF-8?q?selfhost/cmd/w6a/parse=20+=20lib/ww/lex:=20amal?= =?UTF-8?q?loc=20=E2=86=92=20alloc([],=20N)!=20(=CE=B1-8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 0 #8 eighth α-batch. 3 sites: - w6a/parse.ww:198 nextline newline-hit branch - w6a/parse.ww:208 nextline EOF-no-newline branch - lib/ww/lex/lex.ww:457 float underscore-strip buffer All α: alloc([], n+1)! + p[k] indexing + .ptr at the consumer (`return buf.ptr, n` for parse; `parsef64(clean.ptr, j)` for lex). No struct-field shape change, no escape. Verified 132/132 + 995_self_rebuild byte-identity. --- lib/ww/lex/lex.ww | 4 ++-- selfhost/cmd/w6a/main.combined.ww | 8 ++++---- selfhost/cmd/w6a/parse.ww | 8 ++++---- selfhost/cmd/w6c/main.combined.ww | 4 ++-- selfhost/cmd/wwdump/main.combined.ww | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/ww/lex/lex.ww b/lib/ww/lex/lex.ww index 5990d949..04bce907 100644 --- a/lib/ww/lex/lex.ww +++ b/lib/ww/lex/lex.ww @@ -454,7 +454,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = { // Strip underscores from the digits (Hare allows 1_000.5) // before parsing — match what cmd/wcc/lex.c does with // strtod over a cleaned buffer. - let clean: *u8 = amalloc(l.a, n + 1u64): *u8; + let clean: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; let j: u64 = 0u64; for (i < n) { @@ -466,7 +466,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = { i += 1u64; }; clean[j] = 0u8; - let fv: f64 = parsef64(clean, j); + let fv: f64 = parsef64(clean.ptr, j); out.fval = fv; // Stash the IEEE bits in uval — cgen consumers read floats // as integers (n.uval) to avoid an SSE round-trip when diff --git a/selfhost/cmd/w6a/main.combined.ww b/selfhost/cmd/w6a/main.combined.ww index e3baa6a1..ffd0444b 100644 --- a/selfhost/cmd/w6a/main.combined.ww +++ b/selfhost/cmd/w6a/main.combined.ww @@ -1347,21 +1347,21 @@ fn nextline(a: *asm_) (*u8, u64) = { else { a.pos += 1u64; continue; }; // hit newline let n: u64 = a.pos - start; - let buf: *u8 = amalloc(a.a, n + 1u64): *u8; + let buf: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; buf[n] = 0u8; a.pos += 1u64; // skip newline - return buf, n; + return buf.ptr, n; }; // EOF without trailing newline let n: u64 = a.pos - start; if (n == 0u64) { return nil, 0u64; }; - let buf: *u8 = amalloc(a.a, n + 1u64): *u8; + let buf: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; buf[n] = 0u8; - return buf, n; + return buf.ptr, n; }; fn skipws(p: *u8, off: u64, n: u64) u64 = { diff --git a/selfhost/cmd/w6a/parse.ww b/selfhost/cmd/w6a/parse.ww index 64af80a9..af17671b 100644 --- a/selfhost/cmd/w6a/parse.ww +++ b/selfhost/cmd/w6a/parse.ww @@ -195,21 +195,21 @@ fn nextline(a: *asm_) (*u8, u64) = { else { a.pos += 1u64; continue; }; // hit newline let n: u64 = a.pos - start; - let buf: *u8 = amalloc(a.a, n + 1u64): *u8; + let buf: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; buf[n] = 0u8; a.pos += 1u64; // skip newline - return buf, n; + return buf.ptr, n; }; // EOF without trailing newline let n: u64 = a.pos - start; if (n == 0u64) { return nil, 0u64; }; - let buf: *u8 = amalloc(a.a, n + 1u64): *u8; + let buf: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; buf[n] = 0u8; - return buf, n; + return buf.ptr, n; }; fn skipws(p: *u8, off: u64, n: u64) u64 = { diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index e3a3c137..0597edff 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -4166,7 +4166,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = { // Strip underscores from the digits (Hare allows 1_000.5) // before parsing — match what cmd/wcc/lex.c does with // strtod over a cleaned buffer. - let clean: *u8 = amalloc(l.a, n + 1u64): *u8; + let clean: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; let j: u64 = 0u64; for (i < n) { @@ -4178,7 +4178,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = { i += 1u64; }; clean[j] = 0u8; - let fv: f64 = parsef64(clean, j); + let fv: f64 = parsef64(clean.ptr, j); out.fval = fv; // Stash the IEEE bits in uval — cgen consumers read floats // as integers (n.uval) to avoid an SSE round-trip when diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index 34c8323f..24945ed5 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -4166,7 +4166,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = { // Strip underscores from the digits (Hare allows 1_000.5) // before parsing — match what cmd/wcc/lex.c does with // strtod over a cleaned buffer. - let clean: *u8 = amalloc(l.a, n + 1u64): *u8; + let clean: []u8 = alloc([], n + 1u64)!; let i: u64 = 0u64; let j: u64 = 0u64; for (i < n) { @@ -4178,7 +4178,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = { i += 1u64; }; clean[j] = 0u8; - let fv: f64 = parsef64(clean, j); + let fv: f64 = parsef64(clean.ptr, j); out.fval = fv; // Stash the IEEE bits in uval — cgen consumers read floats // as integers (n.uval) to avoid an SSE round-trip when