lib/ww: migrate 5 typed amalloc sites to alloc(T{...})! (typed-9)

Phase 0 critical lib/ww/ gap (frontend used by BOTH cstage + wwstage,
not covered by phase0-mapper's selfhost/cmd/ audit). 5 typed-struct
amalloc sites + 1 γ pointer-array + 1 α byte buffer:

 - lib/ww/ast.ww newnode (node, 20 fields, was 208u64 over-sized)
 - lib/ww/typ.ww newtype (tinfo, 13 fields, was 112u64 over-sized)
 - lib/ww/typ.ww tinfocachebind (tinfocacheent, was 32u64 sizelint-ok)
 - lib/ww/sym.ww newscope (scope, 6 fields, was 64u64) + buckets γ
 - lib/ww/sym.ww scopedefineinmodule (sym, 10 fields, was 112u64)
 - lib/ww/parse/parse.ww joindotted (α []u8 + .ptr extract)

Retires 4 rule-7 over-sized amalloc workarounds plus a #36
tinfocacheent sizelint-ok. WHY-comments documenting the workarounds
are dropped (no longer applicable — alloc(T{...})! sizes from the
type table).

ast.ww newnode's `fval = 0: f64` carries a 3-line WHY comment naming
the 990_selfhost TK_FLOAT-count diff probe (lex.ww:382 precedent for
the same cast pattern). Bare `0.0` here would shift the dump-diff
token-input scope and break 990's byte-identity probe.

β grow loops in lib/ww/lex/lex.ww:570,592 deferred — separate sweep.

Verified 132/132 + 995_self_rebuild byte-identity. Net -63 lines.
This commit is contained in:
2026-05-21 04:18:52 +09:00
parent a3e4c6942f
commit 6ff38f52bb
6 changed files with 48 additions and 111 deletions

View File

@@ -125,17 +125,17 @@ fn expectbindname(p: *parser, into: *str) bool = {
// cross-module dependency.
fn joindotted(a: *arena, head: str, tail: str) str = {
let n: u64 = head.len: u64 + 1u64 + tail.len: u64;
let p: *u8 = amalloc(a, n + 1u64): *u8;
let buf: []u8 = alloc([], n + 1u64)!;
let i: u64 = 0u64;
let j: i32 = 0;
for (j < head.len) { p[i] = head[j]; i += 1u64; j += 1; };
p[i] = 46u8; // '.'
for (j < head.len) { buf[i] = head[j]; i += 1u64; j += 1; };
buf[i] = 46u8; // '.'
i += 1u64;
j = 0;
for (j < tail.len) { p[i] = tail[j]; i += 1u64; j += 1; };
p[i] = 0u8;
for (j < tail.len) { buf[i] = tail[j]; i += 1u64; j += 1; };
buf[i] = 0u8;
let r: str;
r.ptr = p;
r.ptr = buf.ptr;
r.len = n: i32;
return r;
};