lib: complete the parallel vstream surface to Hare value-return shape (#94 fold-eFinal prep)

The #94 Option-C vstream surface was left incomplete and structurally
divergent from Hare: constructors heap-allocated and returned (X | nomem)
or used out-params instead of Hare's by-value stack ownership; memio lacked
reset/buffer/borrowedread; bufio's scanner was never ported to the vtable.
This is the additive half of the eFinal collapse — OLD surface stays fully
live; the destructive FLIP (delete OLD + drop _v + repoint) is the next
commit.

Reshape all constructors to VALUE-RETURN (field-by-field sret; the heap +
nomem was an unnecessary crutch — wide slice-bearing struct return-by-value
is byte-id-proven, cf 925_sret_struct_return_run). memio fixed/dynamic/
dynamicfrom, bufio init, log new now return the struct by value; the nomem
is gone with the alloc that forced it.

memio: unify the per-flavour ctx structs onto one `stream` (vt at offset 0);
collapse fixed_string + dynamic_string into a single string() over the common
header (bare-str return is the ratified rule-9 frombytes carve-out, cited at
the site per ref/hare/memio/stream.ha:81); port reset/buffer/borrowedread as
single fns over the header.

bufio: collapse the EXISTING scanner subset (newscannerbuf/scanbyte/scanbytes/
scanline/finish + setflush/flush/unread/isbuffered) onto the vtable, with src
now io.vstream so reads go through io.st_read. The Hare scanner functions ww
never implemented (scanrune/scanstring-arbitrary-delim/readtok/readline/
auto-grow newscanner) are out of scope and deferred to #217 — eFinal is a
collapse, not a feature expansion.

Keep the explicit (&fn): *io.T casts on vtable-slot stores (cgen-neutral;
avoids the #214 (X|void) over-acceptance surface; dropping the casts is a
deferred #206 payoff gated on #214).

Self-gate: 776 (memio) 18/18 and 778 (bufio) 27/27, every row carrying a
cs.s == ww.s byte-id check — bufio/fmt/log are not compiler-embedded, so
these rows are their only byte-id coverage. 779/781 stay STAGE_CS-only
pending #209. Regen w6c+wwdump combined.ww (io+memio are the embedded
modules).
This commit is contained in:
2026-05-29 21:14:39 +09:00
parent f9f83faca7
commit 10cb835f99
10 changed files with 1068 additions and 860 deletions

View File

@@ -151,14 +151,9 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let buf: [16]u8;\n"
" let r = memio.fixed_vstream(buf[0:16]);\n"
" let vs: io.vstream = nil: *io.vtable;\n"
" match (r) {\n"
" case let v: io.vstream => { vs = v; };\n"
" case nomem => { return 50; };\n"
" };\n"
" let sl: log.vstdlogger;\n"
" log.new_v(&sl, vs);\n"
" let st: memio.stream = memio.fixed_vstream(buf[0:16]);\n"
" let vs: io.vstream = &st.vt;\n"
" let sl: log.vstdlogger = log.new_v(vs);\n"
" log.lprintln_v(&sl.logger, \"hi\", 7i64);\n"
" if (buf[0] != 104u8) { return 91; };\n"
" if (buf[1] != 105u8) { return 92; };\n"
@@ -178,22 +173,12 @@ static const struct row rows[] = {
"export fn main() i32 = {\n"
" let bufA: [16]u8;\n"
" let bufB: [16]u8;\n"
" let rA = memio.fixed_vstream(bufA[0:16]);\n"
" let vsA: io.vstream = nil: *io.vtable;\n"
" match (rA) {\n"
" case let v: io.vstream => { vsA = v; };\n"
" case nomem => { return 50; };\n"
" };\n"
" let rB = memio.fixed_vstream(bufB[0:16]);\n"
" let vsB: io.vstream = nil: *io.vtable;\n"
" match (rB) {\n"
" case let v: io.vstream => { vsB = v; };\n"
" case nomem => { return 51; };\n"
" };\n"
" let slA: log.vstdlogger;\n"
" let slB: log.vstdlogger;\n"
" log.new_v(&slA, vsA);\n"
" log.new_v(&slB, vsB);\n"
" let stA: memio.stream = memio.fixed_vstream(bufA[0:16]);\n"
" let vsA: io.vstream = &stA.vt;\n"
" let stB: memio.stream = memio.fixed_vstream(bufB[0:16]);\n"
" let vsB: io.vstream = &stB.vt;\n"
" let slA: log.vstdlogger = log.new_v(vsA);\n"
" let slB: log.vstdlogger = log.new_v(vsB);\n"
" let sel: i32 = 1;\n"
" let chosen: *log.vlogger = &slA.logger;\n"
" if (sel == 0) { chosen = &slB.logger; };\n"