cmd: α/γ-4 rt.malloc → alloc([], N)! (w6a/w6c/w6l file slurps + sized bufs)

Phase 0 #8 fourth α-batch. 10 α/γ conversions across 6 files:
 - w6a/main.ww slurp (1)
 - w6c/main.ww slurp (1)
 - w6l/dyn.ww slurpso (1)
 - w6l/obj.ww slurp (1)
 - w6l/dynout.ww filebuf at :661 (1; threads .ptr through ~50
   dwr*/dbcopy callees — that's the 139-line w6l/dynout diff)
 - w6l/out.ww hdr at :92 (1)
 - w6l/main.ww 4 sites: bufp + γ {inputs, libdirs, lflags} (4)

Deferred:
 - w6l/main.ww 3× 16/8/20-byte δ fixed-bufs at :67/:106/:176 →
   stack-promote in a separate sub-task.
 - w6l/obj.ww :113/:135 β text-buffer growth → memio.dynamic refactor.

Pattern unchanged from 47918d3/00d88ff/e9eb67d: `alloc([], N: u64)!` +
`buf.len = N: i32;` + `buf.ptr` for callees taking `*u8`. γ uses
element-count (was bytes): `maxinputs: u64` not `maxinputs*8u64`.

Verified 132/132 + 995_self_rebuild byte-identity. Advances #45.
This commit is contained in:
2026-05-21 01:59:58 +09:00
parent e9eb67de04
commit 368b85ea33
10 changed files with 270 additions and 258 deletions

View File

@@ -131,13 +131,14 @@ fn islinkable(path: *u8) bool = {
// then lib<name>.a. Return arena-owned NUL-terminated path on success,
// nil on miss.
fn resolvelib(a: *arena, name: *u8, libdirs: **u8, nlibdirs: i32) *u8 = {
let bufp: *u8 = rt.malloc(1024u64): *u8;
let bufp: []u8 = alloc([], 1024u64)!;
bufp.len = 1024;
let i: i32 = 0;
for (i < nlibdirs) {
let dir: *u8 = libdirs[i];
let _l1: u64 = buildpath(bufp, dir, name, ".so");
if (islinkable(bufp)) {
let pl: u64 = cstrlen(bufp);
let _l1: u64 = buildpath(bufp.ptr, dir, name, ".so");
if (islinkable(bufp.ptr)) {
let pl: u64 = cstrlen(bufp.ptr);
let p: *u8 = amalloc(a, pl + 1u64): *u8;
let k: u64 = 0u64;
for (k <= pl) { p[k] = bufp[k]; k += 1u64; };
@@ -145,9 +146,9 @@ fn resolvelib(a: *arena, name: *u8, libdirs: **u8, nlibdirs: i32) *u8 = {
};
let v: u64 = 0u64;
for (v <= 8u64) {
let _l2: u64 = buildpathv(bufp, dir, name, v);
if (islinkable(bufp)) {
let pl2: u64 = cstrlen(bufp);
let _l2: u64 = buildpathv(bufp.ptr, dir, name, v);
if (islinkable(bufp.ptr)) {
let pl2: u64 = cstrlen(bufp.ptr);
let p2: *u8 = amalloc(a, pl2 + 1u64): *u8;
let k2: u64 = 0u64;
for (k2 <= pl2) { p2[k2] = bufp[k2]; k2 += 1u64; };
@@ -155,9 +156,9 @@ fn resolvelib(a: *arena, name: *u8, libdirs: **u8, nlibdirs: i32) *u8 = {
};
v += 1u64;
};
let _l3: u64 = buildpath(bufp, dir, name, ".a");
if (islinkable(bufp)) {
let pl3: u64 = cstrlen(bufp);
let _l3: u64 = buildpath(bufp.ptr, dir, name, ".a");
if (islinkable(bufp.ptr)) {
let pl3: u64 = cstrlen(bufp.ptr);
let p3: *u8 = amalloc(a, pl3 + 1u64): *u8;
let k3: u64 = 0u64;
for (k3 <= pl3) { p3[k3] = bufp[k3]; k3 += 1u64; };
@@ -189,11 +190,14 @@ fn isso(path: *u8) i32 = {
export fn main(argc: i32, argv: **u8) i32 = {
let outpath: *u8 = nil;
let maxinputs: i32 = 64;
let inputs: **u8 = rt.malloc((maxinputs: u64) * 8u64): **u8;
let inputs: []*u8 = alloc([], maxinputs: u64)!;
inputs.len = maxinputs;
let ninputs: i32 = 0;
let libdirs: **u8 = rt.malloc((maxinputs: u64) * 8u64): **u8;
let libdirs: []*u8 = alloc([], maxinputs: u64)!;
libdirs.len = maxinputs;
let nlibdirs: i32 = 0;
let lflags: **u8 = rt.malloc((maxinputs: u64) * 8u64): **u8;
let lflags: []*u8 = alloc([], maxinputs: u64)!;
lflags.len = maxinputs;
let nlflags: i32 = 0;
let i: i32 = 1;
@@ -283,7 +287,7 @@ export fn main(argc: i32, argv: **u8) i32 = {
// objects register their exports.
let lf: i32 = 0;
for (lf < nlflags) {
let p: *u8 = resolvelib(a, lflags[lf], libdirs, nlibdirs);
let p: *u8 = resolvelib(a, lflags[lf], libdirs.ptr, nlibdirs);
if (p == nil) {
os.write(2, "w6l: cannot find -l".ptr, 18u64);
let nm: *u8 = lflags[lf];