examples: α/γ rt.malloc → alloc([], N)! (cmatrix + lispcore)

Phase 0 #8 seventh α-batch. 11 sites across two examples:
 - cmatrix.ww: cmat struct (alloc(cmat{})!) + 4 γ i32 arrays
   (head/length/speed/counter) + 1 α u8 (glyphs)
 - lispcore.ww: 1 α arena chunk u8 + 2 γ i32 (sym_off/sym_len)
   + 2 α u8 (sym_blob, obuf)

γ pattern uses element count (was bytes/4). Struct fields stay
`*T` (legacy) so callers extract via intermediate `*_sl` local
slice + `.ptr` assign — verbose but mechanical until struct-field
slice types are part of a separate refactor.

Verified 132/132 + 995_self_rebuild byte-identity.
This commit is contained in:
2026-05-21 02:41:37 +09:00
parent 0f011661b6
commit 775b271dc7
2 changed files with 21 additions and 13 deletions

View File

@@ -201,18 +201,22 @@ fn now_ns() u64 = {
// ---- cmat allocate / free ---------------------------------------------
fn cmat_alloc(w: i32, h: i32, r: *rng) *cmat = {
let m = rt.malloc(CMAT_SZ): *cmat;
let m = alloc(cmat{})!;
m.w = w;
m.h = h;
m.gspeed = -1;
m.gtheme = theme.GREEN: i32;
m.flash = 0;
let n4 = (w: u64) * 4u64;
m.head = rt.malloc(n4): *i32;
m.length = rt.malloc(n4): *i32;
m.speed = rt.malloc(n4): *i32;
m.counter = rt.malloc(n4): *i32;
m.glyphs = rt.malloc((w: u64) * (MAX_TRAIL: u64)): *u8;
let head_sl: []i32 = alloc([], w: u64)!;
m.head = head_sl.ptr;
let length_sl: []i32 = alloc([], w: u64)!;
m.length = length_sl.ptr;
let speed_sl: []i32 = alloc([], w: u64)!;
m.speed = speed_sl.ptr;
let counter_sl: []i32 = alloc([], w: u64)!;
m.counter = counter_sl.ptr;
let glyphs_sl: []u8 = alloc([], (w: u64) * (MAX_TRAIL: u64))!;
m.glyphs = glyphs_sl.ptr;
let c = 0;
for (c < w) {
m.head[c] = -rng_range(r, 0, h);