selfhost/cmd/w6a/parse + lib/ww/lex: amalloc → alloc([], N)! (α-8)

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.
This commit is contained in:
2026-05-21 03:14:04 +09:00
parent 4972ab4a5c
commit 4f4504d10a
5 changed files with 14 additions and 14 deletions

View File

@@ -454,7 +454,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = {
// Strip underscores from the digits (Hare allows 1_000.5) // Strip underscores from the digits (Hare allows 1_000.5)
// before parsing — match what cmd/wcc/lex.c does with // before parsing — match what cmd/wcc/lex.c does with
// strtod over a cleaned buffer. // 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 i: u64 = 0u64;
let j: u64 = 0u64; let j: u64 = 0u64;
for (i < n) { for (i < n) {
@@ -466,7 +466,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = {
i += 1u64; i += 1u64;
}; };
clean[j] = 0u8; clean[j] = 0u8;
let fv: f64 = parsef64(clean, j); let fv: f64 = parsef64(clean.ptr, j);
out.fval = fv; out.fval = fv;
// Stash the IEEE bits in uval — cgen consumers read floats // Stash the IEEE bits in uval — cgen consumers read floats
// as integers (n.uval) to avoid an SSE round-trip when // as integers (n.uval) to avoid an SSE round-trip when

View File

@@ -1347,21 +1347,21 @@ fn nextline(a: *asm_) (*u8, u64) = {
else { a.pos += 1u64; continue; }; else { a.pos += 1u64; continue; };
// hit newline // hit newline
let n: u64 = a.pos - start; 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; let i: u64 = 0u64;
for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; };
buf[n] = 0u8; buf[n] = 0u8;
a.pos += 1u64; // skip newline a.pos += 1u64; // skip newline
return buf, n; return buf.ptr, n;
}; };
// EOF without trailing newline // EOF without trailing newline
let n: u64 = a.pos - start; let n: u64 = a.pos - start;
if (n == 0u64) { return nil, 0u64; }; 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; let i: u64 = 0u64;
for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; };
buf[n] = 0u8; buf[n] = 0u8;
return buf, n; return buf.ptr, n;
}; };
fn skipws(p: *u8, off: u64, n: u64) u64 = { fn skipws(p: *u8, off: u64, n: u64) u64 = {

View File

@@ -195,21 +195,21 @@ fn nextline(a: *asm_) (*u8, u64) = {
else { a.pos += 1u64; continue; }; else { a.pos += 1u64; continue; };
// hit newline // hit newline
let n: u64 = a.pos - start; 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; let i: u64 = 0u64;
for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; };
buf[n] = 0u8; buf[n] = 0u8;
a.pos += 1u64; // skip newline a.pos += 1u64; // skip newline
return buf, n; return buf.ptr, n;
}; };
// EOF without trailing newline // EOF without trailing newline
let n: u64 = a.pos - start; let n: u64 = a.pos - start;
if (n == 0u64) { return nil, 0u64; }; 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; let i: u64 = 0u64;
for (i < n) { buf[i] = a.src[start + i]; i += 1u64; }; for (i < n) { buf[i] = a.src[start + i]; i += 1u64; };
buf[n] = 0u8; buf[n] = 0u8;
return buf, n; return buf.ptr, n;
}; };
fn skipws(p: *u8, off: u64, n: u64) u64 = { fn skipws(p: *u8, off: u64, n: u64) u64 = {

View File

@@ -4166,7 +4166,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = {
// Strip underscores from the digits (Hare allows 1_000.5) // Strip underscores from the digits (Hare allows 1_000.5)
// before parsing — match what cmd/wcc/lex.c does with // before parsing — match what cmd/wcc/lex.c does with
// strtod over a cleaned buffer. // 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 i: u64 = 0u64;
let j: u64 = 0u64; let j: u64 = 0u64;
for (i < n) { for (i < n) {
@@ -4178,7 +4178,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = {
i += 1u64; i += 1u64;
}; };
clean[j] = 0u8; clean[j] = 0u8;
let fv: f64 = parsef64(clean, j); let fv: f64 = parsef64(clean.ptr, j);
out.fval = fv; out.fval = fv;
// Stash the IEEE bits in uval — cgen consumers read floats // Stash the IEEE bits in uval — cgen consumers read floats
// as integers (n.uval) to avoid an SSE round-trip when // as integers (n.uval) to avoid an SSE round-trip when

View File

@@ -4166,7 +4166,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = {
// Strip underscores from the digits (Hare allows 1_000.5) // Strip underscores from the digits (Hare allows 1_000.5)
// before parsing — match what cmd/wcc/lex.c does with // before parsing — match what cmd/wcc/lex.c does with
// strtod over a cleaned buffer. // 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 i: u64 = 0u64;
let j: u64 = 0u64; let j: u64 = 0u64;
for (i < n) { for (i < n) {
@@ -4178,7 +4178,7 @@ fn lexnum(l: *lex, start: *pos, out: *tok) void = {
i += 1u64; i += 1u64;
}; };
clean[j] = 0u8; clean[j] = 0u8;
let fv: f64 = parsef64(clean, j); let fv: f64 = parsef64(clean.ptr, j);
out.fval = fv; out.fval = fv;
// Stash the IEEE bits in uval — cgen consumers read floats // Stash the IEEE bits in uval — cgen consumers read floats
// as integers (n.uval) to avoid an SSE round-trip when // as integers (n.uval) to avoid an SSE round-trip when