lib: collapse the parallel vstream scaffold onto the single Hare io surface (#94 fold-eFinal)

The Option-C parallel _v vstream API was scaffolding to bring the io stack up alongside the old surface; carrying both permanently is a rule-9 divergence from ref/hare, which has exactly one io surface. Collapse onto that surface (stream = *vtable, ref/hare/io/stream.ha) and rename the _v symbols to their Hare names (io vstream->stream, fmt vfprint->fprint, bufio/memio/log surfaces, log.new). Deletes the 4 lib/*/vstream.ww scaffold files; regenerates w6c/wwdump combined.ww. cstage and wwstage stay byte-identical and combined_ww_fresh holds; all 220 tests pass.
This commit is contained in:
2026-05-30 03:24:23 +09:00
parent 80184a3acf
commit 7d39f6d623
31 changed files with 2371 additions and 4834 deletions

View File

@@ -1,10 +1,12 @@
/*
* 775_io_vtable_run — project #94 fold-e1 sentinel. Pins the additive
* lib/io/stream.ww vtable port: `vtable` (the three (*T|void) slots),
* `vstream` (= *vtable), and the `st_read`/`st_write`/`st_close`
* dispatchers (ref/hare/io/stream.ha:33-68). Coexists with lib/io/io.ww's
* legacy `stream` struct + read/write/close wrappers (fold-e2+ migrates
* them to vtable-backed implementations and retires the legacy surface).
* 775_io_vtable_run — project #94 fold-eFinal sentinel. Pins the
* single-surface lib/io/stream.ww vtable port: `vtable` (the three
* (*T|void) slots), `stream` (= *vtable), and the read/write/close
* dispatchers (ref/hare/io/stream.ha:33-68). The fold-eFinal FLIP
* retired the pre-vtable `stream` struct + `closed` tag, leaving this
* as the sole io surface. (Comment prose below predates the FLIP and
* still says `vstream`/`st_read`/`st_write`/`st_close` for the same
* `stream`/`read`/`write`/`close`.)
*
* Each row imports io, allocates a vtable, optionally points one slot at
* a user fn (via the `(&fn): *io.<role>` cast — see SIBLINGS below),
@@ -48,7 +50,7 @@
* | callee row; catches a constant-fold
* | mistake in the dispatch path.
*
* SIBLINGS (filed inline, NOT fixed here — fold-e1 is purely additive):
* DEFERRALS / RELATED (NOT addressed by these rows):
*
* - #199b layout-extension (wrapped-slot tag-remap): when widening a
* NAMED wrapper-typed value (e.g. `error`) into a tagged parent
@@ -109,16 +111,16 @@ static const struct row rows[] = {
{ "reader_set_happy",
"package main;\n"
"import io;\n"
"fn myread(s: io.vstream, buf: []u8) (size | io.eof | io.error) = {\n"
"fn myread(s: io.stream, buf: []u8) (size | io.eof | io.error) = {\n"
" return 7: size;\n"
"};\n"
"export fn main() i32 = {\n"
" let vt: io.vtable;\n"
" vt.reader = (&myread): *io.reader;\n"
" let v: io.vstream = &vt;\n"
" let v: io.stream = &vt;\n"
" let buf: [4]u8;\n"
" let bs: []u8 = buf[0:4];\n"
" let r = io.st_read(v, bs);\n"
" let r = io.read(v, bs);\n"
" if (r is size) {\n"
" let n = r as size;\n"
" if (n == 7: size) { return 70; };\n"
@@ -133,10 +135,10 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let vt: io.vtable;\n"
" let v: io.vstream = &vt;\n"
" let v: io.stream = &vt;\n"
" let buf: [4]u8;\n"
" let bs: []u8 = buf[0:4];\n"
" let _r = io.st_read(v, bs);\n"
" let _r = io.read(v, bs);\n"
" return 11;\n"
"};\n",
11,
@@ -144,16 +146,16 @@ static const struct row rows[] = {
{ "writer_set_happy",
"package main;\n"
"import io;\n"
"fn mywrite(s: io.vstream, buf: []u8) (size | io.error) = {\n"
"fn mywrite(s: io.stream, buf: []u8) (size | io.error) = {\n"
" return buf.len: size;\n"
"};\n"
"export fn main() i32 = {\n"
" let vt: io.vtable;\n"
" vt.writer = (&mywrite): *io.writer;\n"
" let v: io.vstream = &vt;\n"
" let v: io.stream = &vt;\n"
" let buf: [5]u8;\n"
" let bs: []u8 = buf[0:5];\n"
" let r = io.st_write(v, bs);\n"
" let r = io.write(v, bs);\n"
" if (r is size) {\n"
" let n = r as size;\n"
" if (n == 5: size) { return 80; };\n"
@@ -168,10 +170,10 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let vt: io.vtable;\n"
" let v: io.vstream = &vt;\n"
" let v: io.stream = &vt;\n"
" let buf: [3]u8;\n"
" let bs: []u8 = buf[0:3];\n"
" let _r = io.st_write(v, bs);\n"
" let _r = io.write(v, bs);\n"
" return 22;\n"
"};\n",
22,
@@ -181,8 +183,8 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let vt: io.vtable;\n"
" let v: io.vstream = &vt;\n"
" let r = io.st_close(v);\n"
" let v: io.stream = &vt;\n"
" let r = io.close(v);\n"
" if (r is void) { return 50; };\n"
" return 99;\n"
"};\n",
@@ -191,14 +193,14 @@ static const struct row rows[] = {
{ "closer_set",
"package main;\n"
"import io;\n"
"fn myclose(s: io.vstream) (void | io.error) = {\n"
"fn myclose(s: io.stream) (void | io.error) = {\n"
" return void;\n"
"};\n"
"export fn main() i32 = {\n"
" let vt: io.vtable;\n"
" vt.closer = (&myclose): *io.closer;\n"
" let v: io.vstream = &vt;\n"
" let r = io.st_close(v);\n"
" let v: io.stream = &vt;\n"
" let r = io.close(v);\n"
" if (r is void) { return 60; };\n"
" return 99;\n"
"};\n",
@@ -207,10 +209,10 @@ static const struct row rows[] = {
{ "branched_readers",
"package main;\n"
"import io;\n"
"fn r1(s: io.vstream, buf: []u8) (size | io.eof | io.error) = {\n"
"fn r1(s: io.stream, buf: []u8) (size | io.eof | io.error) = {\n"
" return 1: size;\n"
"};\n"
"fn r2(s: io.vstream, buf: []u8) (size | io.eof | io.error) = {\n"
"fn r2(s: io.stream, buf: []u8) (size | io.eof | io.error) = {\n"
" return 2: size;\n"
"};\n"
"export fn main() i32 = {\n"
@@ -220,8 +222,8 @@ static const struct row rows[] = {
" vt2.reader = (&r2): *io.reader;\n"
" let buf: [4]u8;\n"
" let bs: []u8 = buf[0:4];\n"
" let a = io.st_read(&vt1, bs);\n"
" let b = io.st_read(&vt2, bs);\n"
" let a = io.read(&vt1, bs);\n"
" let b = io.read(&vt2, bs);\n"
" let asz: size = 0;\n"
" let bsz: size = 0;\n"
" if (a is size) { asz = a as size; };\n"