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,22 +1,18 @@
/*
* 778_bufio_vstream_run — project #94 fold-eFinal(PREP) sentinel. Pins
* the lib/bufio/vstream.ww parallel API — a COLLAPSE of the OLD bufio
* surface onto the io.vtable, NOT a port of Hare's missing scanner
* 778_bufio_vstream_run — project #94 fold-eFinal sentinel. Pins
* the single-surface lib/bufio over io.stream — the unified surface
* the eFinal FLIP collapsed to, NOT a port of Hare's missing scanner
* features (those are #217, OUT of eFinal). Covers:
* - buffered stream: `bufio_ctx` (vt@offset0 for the intrusive cast),
* `bufio_vstream` (returns the ctx BY VALUE; sret field-by-field)
* over an underlying **io.vstream** src — every underlying read/
* write/close goes through io.st_read/io.st_write/io.st_close (the
* - buffered stream: `stream` (vt@offset0 for the intrusive cast),
* `init` (returns the stream BY VALUE; sret field-by-field)
* over an underlying **io.stream** src — every underlying read/
* write/close goes through io.read/io.write/io.close (the
* vtable dispatchers), io.error forwards directly (no nomem-widen).
* Plus setflush_v / flush_v (public + internal drain) / unread_v /
* isbuffered_v (fn-ptr-equality discriminator).
* - scanner: `scanner_v` (value-return newscannerbuf_v over an
* io.vstream src) + scanbyte_v / scanbytes_v (single-byte delim) /
* scanline_v / finish_v.
* Coexists with the pre-vtable bufio.init / scanner / isbuffered surface
* in bufio.ww (fold-eFinal FLIP retires the latter + drops the `_v`
* suffix: bufio_ctx→stream, bufio_vstream→init, scanner_v→scanner,
* scanbytes_v→scanbytes, newscannerbuf_v→newscannerbuf, …).
* Plus setflush / flush (public + internal drain) / unread /
* isbuffered (fn-ptr-equality discriminator).
* - scanner: `scanner` (value-return newscannerbuf over an
* io.stream src) + scanbyte / scanbytes (single-byte delim) /
* scanline / finish.
*
* Each row imports os + bufio + memio + io (NOT fmt — bufio doesn't
* transitively pull fmt, so #209's formattable-match bail doesn't
@@ -25,89 +21,79 @@
*
* row | what it pins
* --------------------------+--------------------------------------
* stream_write_flush | bufio_vstream init + io.st_write
* | through bwrite_v + bufio.flush_v via
* | io.st_close. Asserts the data
* stream_write_flush | bufio.init + io.write
* | through bwrite + bufio.flush via
* | io.close. Asserts the data
* | reaches the underlying memio buffer
* | after close drains wbuf. Full chain:
* | bufio_ctx built field-by-field →
* | stream built field-by-field →
* | return r (sret) → caller takes &b.vt →
* | dispatcher recovers via *bufio_ctx
* | flush_v → io.write(b.src, ...).
* stream_read_unread | bufio_vstream read path: io.st_read
* | dispatcher recovers via *stream
* | flush → io.write(b.src, ...).
* stream_read_unread | init read path: io.read
* | refills rbuf from src, serves first
* | N bytes. Pins bread_v's read path
* | through the intrusive cast. unread_v
* | N bytes. Pins bread's read path
* | through the intrusive cast. unread
* | not exposed yet (no bufio.unread
* | equivalent on the V API surface
* | until eFinal); this row exercises
* | the base read path instead.
* isbuffered_v_discriminate | isbuffered_v on a fresh bufio_vstream
* | returns true; isbuffered_v on a
* | plain memio.fixed_vstream (no bufio
* isbuffered_v_discriminate | isbuffered on a fresh init
* | returns true; isbuffered on a
* | plain memio.fixed (no bufio
* | wrap) returns false. Pins the
* | fn-ptr-equality discriminator
* | (ref/hare/bufio/stream.ha:179) over
* | the new `_v` callback symbols.
* isbuffered_v_boundary | NEW isbuffered_v on bufio_vstream
* | returns true AND OLD bufio.isbuffered
* | on a bytewise-cast view of the same
* | vstream returns false. Boundary
* | check: the OLD discriminator reads
* | (s.read == bread) but the bytes at
* | &bufio_ctx.vt are vt.reader (tagged
* | union) — the cast reinterprets vt's
* | tag+ptr layout as the OLD stream's
* | ctx/read/write/close 4-fnptr layout,
* | and the OLD `bread` symbol address
* | is distinct from the NEW `bread_v`,
* | so the OLD discriminator returns
* | false. Proves the OLD + NEW worlds
* | use independent fn symbols.
* branched_bufio_vstream | branched callee per #105: two
* | the bread/bwrite callback symbols.
* isbuffered_v_boundary | isbuffered discriminates by vtable
* | identity: true on the bufio.init
* | wrapper stream, false on the
* | underlying (non-bufio) memio stream.
* | Pins the fn-ptr-equality discriminator
* | (ref/hare/bufio/stream.ha:179) over
* | the single-surface io.stream.
* branched_bufio_wrap | branched callee per #105: two
* | distinct underlying *io.stream's
* | runtime-selected; bufio_vstream
* | wraps the picked one. st_read
* | runtime-selected; bufio.init
* | wraps the picked one. io.read
* | returns the matching source's
* | content. Catches a constant-fold
* | mistake in the dispatch path
* | (mirror of 775's branched_readers
* | for the bufio-wrap side).
*
* SIBLINGS (filed inline, NOT fixed here — fold-e4 is purely
* additive over fold-e1/e2/e3's frozen io.* + memio.* + fmt.*
* surface):
* DEFERRALS / RELATED (NOT addressed by this row):
*
* - io fold-2 (handle port): drew-deferred. Hare's
* ref/hare/bufio/stream.ha:69 takes `src: io::handle`; once
* handle = (file | int) lands, bufio_vstream's src parameter
* collapses accordingly. eFinal (#50) graduates.
* handle = (file | int) lands, init's src parameter
* collapses accordingly. #5 graduates.
*
* - #206 (bare &fn → (*alias|void)): 5 cast sites in vstream.ww
* (3 vtable wire-up + 2 in isbuffered_v); drop out wholesale
* on close.
* - #206 (bare &fn → (*alias|void)): 5 cast sites in bufio.ww
* (3 vtable wire-up + 2 in isbuffered); explicit casts KEPT
* (ken/#214 — cast-drop deferred, gated on #214).
*
* - #173 (TRY-on-tagged-return both-stages broken): flush_v
* - #173 (TRY-on-tagged-return both-stages broken): flush
* constructs nomem and widens to io.error explicitly rather
* than using `io.write(...)?`; same memio.vstream.ww +
* fmt.vstream.ww shape.
* than using `io.write(...)?`; same shape memio.ww + fmt.ww
* adopt.
*
* - #207 (struct-lit multi-tagged-field copy drops past first) and
* #210 (slice-field struct-lit drop): not reachable from the
* value-return form — bufio_ctx is built field-by-field in a
* value-return form — stream is built field-by-field in a
* local then sret-returned, no `alloc(T{...})` struct-lit.
*
* BOOTSTRAP-EMBED CHECK: bufio is NOT embedded in any selfhost
* combined.ww (grep confirmed). Adding lib/bufio/vstream.ww does
* NOT require a Makefile regen (#110); only lib/bufio/ test paths
* see the new module. 990-997 byte-id gates stay green by virtue
* combined.ww (grep confirmed), so the fold-eFinal bufio collapse
* does NOT require a Makefile regen (#110); only lib/bufio/ test
* paths see the surface. 990-997 byte-id gates stay green by virtue
* of bufio being test-only.
*
* GATE POLARITY: must stay GREEN. A red here means vstream.ww
* regressed, the alloc-struct-? path miscompiled, the intrusive
* vstream→*bufio_ctx cast miscomputed offsets, the io.vtable
* GATE POLARITY: must stay GREEN. A red here means lib/bufio
* regressed, the sret value-return path miscompiled, the intrusive
* io.stream→*stream cast miscomputed offsets, the io.vtable
* first-field embed lost its offset-0 invariant, or the fn-ptr-
* equality discriminator in isbuffered_v stopped resolving.
* equality discriminator in isbuffered stopped resolving.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -144,20 +130,20 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let raw: [16]u8;\n"
" let mst: memio.stream = memio.fixed_vstream(raw[0:16]);\n"
" let msrc: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.fixed(raw[0:16]);\n"
" let msrc: io.stream = &mst.vt;\n"
" let rbuf: [8]u8;\n"
" let wbuf: [8]u8;\n"
" let b: bufio.bufio_ctx = bufio.bufio_vstream(msrc, rbuf[0:8], wbuf[0:8]);\n"
" let vs: io.vstream = &b.vt;\n"
" let b: bufio.stream = bufio.init(msrc, rbuf[0:8], wbuf[0:8]);\n"
" let vs: io.stream = &b.vt;\n"
" let payload: [5]u8;\n"
" payload[0] = 104u8; payload[1] = 105u8;\n"
" payload[2] = 33u8; payload[3] = 98u8; payload[4] = 121u8;\n"
" let wr = io.st_write(vs, payload[0:5]);\n"
" let wr = io.write(vs, payload[0:5]);\n"
" let nw: size = 0;\n"
" if (wr is size) { nw = wr as size; };\n"
" if (mst.pos != 0) { return 91; };\n"
" let cl = io.st_close(vs);\n"
" let cl = io.close(vs);\n"
" if (cl is io.error) { return 92; };\n"
" if (mst.pos != 5) { return 93; };\n"
" if (nw != 5: size) { return 94; };\n"
@@ -176,19 +162,19 @@ static const struct row rows[] = {
" let raw: [8]u8;\n"
" raw[0] = 65u8; raw[1] = 66u8; raw[2] = 67u8; raw[3] = 68u8;\n"
" raw[4] = 69u8; raw[5] = 70u8; raw[6] = 71u8; raw[7] = 72u8;\n"
" let mst: memio.stream = memio.fixed_vstream(raw[0:8]);\n"
" let msrc: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.fixed(raw[0:8]);\n"
" let msrc: io.stream = &mst.vt;\n"
" let rbuf: [8]u8;\n"
" let wbuf: [4]u8;\n"
" let b: bufio.bufio_ctx = bufio.bufio_vstream(msrc, rbuf[0:8], wbuf[0:4]);\n"
" let vs: io.vstream = &b.vt;\n"
" let b: bufio.stream = bufio.init(msrc, rbuf[0:8], wbuf[0:4]);\n"
" let vs: io.stream = &b.vt;\n"
" let out: [4]u8;\n"
" let rd1 = io.st_read(vs, out[0:3]);\n"
" let rd1 = io.read(vs, out[0:3]);\n"
" let n1: size = 0;\n"
" if (rd1 is size) { n1 = rd1 as size; };\n"
" if (n1 != 3: size) { return 91; };\n"
" if (out[0] != 65u8 || out[2] != 67u8) { return 92; };\n"
" let rd2 = io.st_read(vs, out[0:4]);\n"
" let rd2 = io.read(vs, out[0:4]);\n"
" let n2: size = 0;\n"
" if (rd2 is size) { n2 = rd2 as size; };\n"
" if (n2 != 4: size) { return 93; };\n"
@@ -205,17 +191,17 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let raw: [8]u8;\n"
" let mst: memio.stream = memio.fixed_vstream(raw[0:8]);\n"
" let msrc: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.fixed(raw[0:8]);\n"
" let msrc: io.stream = &mst.vt;\n"
" let rbuf: [4]u8;\n"
" let wbuf: [4]u8;\n"
" let b: bufio.bufio_ctx = bufio.bufio_vstream(msrc, rbuf[0:4], wbuf[0:4]);\n"
" let vsbuf: io.vstream = &b.vt;\n"
" let b: bufio.stream = bufio.init(msrc, rbuf[0:4], wbuf[0:4]);\n"
" let vsbuf: io.stream = &b.vt;\n"
" let buf2: [4]u8;\n"
" let st2: memio.stream = memio.fixed_vstream(buf2[0:4]);\n"
" let vsplain: io.vstream = &st2.vt;\n"
" if (!bufio.isbuffered_v(vsbuf)) { return 91; };\n"
" if (bufio.isbuffered_v(vsplain)) { return 92; };\n"
" let st2: memio.stream = memio.fixed(buf2[0:4]);\n"
" let vsplain: io.stream = &st2.vt;\n"
" if (!bufio.isbuffered(vsbuf)) { return 91; };\n"
" if (bufio.isbuffered(vsplain)) { return 92; };\n"
" return 48;\n"
"};\n",
48,
@@ -228,30 +214,19 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let raw: [8]u8;\n"
" let mst: memio.stream = memio.fixed_vstream(raw[0:8]);\n"
" let msrc: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.fixed(raw[0:8]);\n"
" let msrc: io.stream = &mst.vt;\n"
" let rbuf: [4]u8;\n"
" let wbuf: [4]u8;\n"
" let bc: bufio.bufio_ctx = bufio.bufio_vstream(msrc, rbuf[0:4], wbuf[0:4]);\n"
" let vs: io.vstream = &bc.vt;\n"
" if (!bufio.isbuffered_v(vs)) { return 91; };\n"
" let raw2: u64 = vs: u64;\n"
" let asold: *io.stream = raw2: *io.stream;\n"
" if (bufio.isbuffered(asold)) { return 92; };\n"
" let b: bufio.stream;\n"
" let rb: [4]u8;\n"
" let wb: [4]u8;\n"
" let raw3: [8]u8;\n"
" let mem3: memio.state;\n"
" let m3: io.stream;\n"
" memio.fixed(&mem3, &m3, raw3[0:8]);\n"
" bufio.init(&b, &m3, rb[0:4], wb[0:4]);\n"
" if (!bufio.isbuffered(&b.vtable)) { return 93; };\n"
" let bc: bufio.stream = bufio.init(msrc, rbuf[0:4], wbuf[0:4]);\n"
" let vs: io.stream = &bc.vt;\n"
" if (!bufio.isbuffered(vs)) { return 91; };\n"
" if (bufio.isbuffered(msrc)) { return 92; };\n"
" return 49;\n"
"};\n",
49,
STAGE_CS | STAGE_WW, 1 },
{ "branched_bufio_vstream",
{ "branched_bufio_wrap",
"package main;\n"
"import os;\n"
"import bufio;\n"
@@ -262,17 +237,17 @@ static const struct row rows[] = {
" raA[0] = 10u8; raA[1] = 11u8; raA[2] = 12u8; raA[3] = 13u8;\n"
" let raB: [4]u8;\n"
" raB[0] = 20u8; raB[1] = 21u8; raB[2] = 22u8; raB[3] = 23u8;\n"
" let mstA: memio.stream = memio.fixed_vstream(raA[0:4]);\n"
" let mstB: memio.stream = memio.fixed_vstream(raB[0:4]);\n"
" let mstA: memio.stream = memio.fixed(raA[0:4]);\n"
" let mstB: memio.stream = memio.fixed(raB[0:4]);\n"
" let sel: i32 = 1;\n"
" let src: io.vstream = &mstA.vt;\n"
" let src: io.stream = &mstA.vt;\n"
" if (sel == 0) { src = &mstB.vt; };\n"
" let rbuf: [4]u8;\n"
" let wbuf: [4]u8;\n"
" let bc: bufio.bufio_ctx = bufio.bufio_vstream(src, rbuf[0:4], wbuf[0:4]);\n"
" let vs: io.vstream = &bc.vt;\n"
" let bc: bufio.stream = bufio.init(src, rbuf[0:4], wbuf[0:4]);\n"
" let vs: io.stream = &bc.vt;\n"
" let out: [4]u8;\n"
" let rd = io.st_read(vs, out[0:4]);\n"
" let rd = io.read(vs, out[0:4]);\n"
" let n: size = 0;\n"
" if (rd is size) { n = rd as size; };\n"
" if (n != 4: size) { return 91; };\n"
@@ -282,9 +257,9 @@ static const struct row rows[] = {
51,
STAGE_CS | STAGE_WW, 1 },
/* scanner_lines — fold-eFinal PREP: the value-return scanner over an
* io.vstream src. newscannerbuf_v (Hare newscanner_buf) → scanline_v
* io.stream src. newscannerbuf (Hare newscanner_buf) → scanline
* twice ("ab", "c") → trailing "def" with no newline is EOF_DISCARD
* → io.eof → finish_v. Pins the scanner reads through io.st_read
* → io.eof → finish. Pins the scanner reads through io.read
* (vtable dispatch) on the underlying memio stream. cs.s==ww.s. */
{ "scanner_lines",
"package main;\n"
@@ -297,36 +272,36 @@ static const struct row rows[] = {
" raw[0]=97u8; raw[1]=98u8; raw[2]=10u8;\n"
" raw[3]=99u8; raw[4]=10u8;\n"
" raw[5]=100u8; raw[6]=101u8; raw[7]=102u8;\n"
" let mst: memio.stream = memio.dynamicfrom_vstream(raw[0:8]);\n"
" let vs: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.dynamicfrom(raw[0:8]);\n"
" let vs: io.stream = &mst.vt;\n"
" let win: [16]u8;\n"
" let sc: bufio.scanner_v = bufio.newscannerbuf_v(vs, win[0:16]);\n"
" let sc: bufio.scanner = bufio.newscannerbuf(vs, win[0:16]);\n"
" let ok: i32 = 0;\n"
" match (bufio.scanline_v(&sc)) {\n"
" match (bufio.scanline(&sc)) {\n"
" case let s: str => { if (s.len == 2 && s[0] == 97u8 && s[1] == 98u8) { ok += 1; }; };\n"
" case io.eof => { return 81; };\n"
" case let e: io.error => { return 82; };\n"
" case bufio.overflow => { return 83; };\n"
" };\n"
" match (bufio.scanline_v(&sc)) {\n"
" match (bufio.scanline(&sc)) {\n"
" case let s: str => { if (s.len == 1 && s[0] == 99u8) { ok += 1; }; };\n"
" case io.eof => { return 84; };\n"
" case let e: io.error => { return 85; };\n"
" case bufio.overflow => { return 86; };\n"
" };\n"
" match (bufio.scanline_v(&sc)) {\n"
" match (bufio.scanline(&sc)) {\n"
" case let s: str => { return 87; };\n"
" case io.eof => { ok += 1; };\n"
" case let e: io.error => { return 88; };\n"
" case bufio.overflow => { return 89; };\n"
" };\n"
" bufio.finish_v(&sc);\n"
" bufio.finish(&sc);\n"
" if (ok != 3) { return 90; };\n"
" return 52;\n"
"};\n",
52,
STAGE_CS | STAGE_WW, 1 },
/* scanner_byte_bytes — scanbyte_v pops 'A'; scanbytes_v(',') then
/* scanner_byte_bytes — scanbyte pops 'A'; scanbytes(',') then
* tokenizes "B" and "CD" from "AB,CD,". Single-byte delim (the OLD
* scantok behaviour; multibyte is #217). cs.s==ww.s. */
{ "scanner_byte_bytes",
@@ -339,24 +314,24 @@ static const struct row rows[] = {
" let raw: [6]u8;\n"
" raw[0]=65u8; raw[1]=66u8; raw[2]=44u8;\n"
" raw[3]=67u8; raw[4]=68u8; raw[5]=44u8;\n"
" let mst: memio.stream = memio.dynamicfrom_vstream(raw[0:6]);\n"
" let vs: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.dynamicfrom(raw[0:6]);\n"
" let vs: io.stream = &mst.vt;\n"
" let win: [8]u8;\n"
" let sc: bufio.scanner_v = bufio.newscannerbuf_v(vs, win[0:8]);\n"
" let sc: bufio.scanner = bufio.newscannerbuf(vs, win[0:8]);\n"
" let fb: u8 = 0u8;\n"
" match (bufio.scanbyte_v(&sc)) {\n"
" match (bufio.scanbyte(&sc)) {\n"
" case let b: u8 => { fb = b; };\n"
" case io.eof => { return 81; };\n"
" case let e: io.error => { return 82; };\n"
" };\n"
" if (fb != 65u8) { return 83; };\n"
" match (bufio.scanbytes_v(&sc, 44u8)) {\n"
" match (bufio.scanbytes(&sc, 44u8)) {\n"
" case let bs: []u8 => { if (bs.len != 1 || bs[0] != 66u8) { return 84; }; };\n"
" case io.eof => { return 85; };\n"
" case let e: io.error => { return 86; };\n"
" case bufio.overflow => { return 87; };\n"
" };\n"
" match (bufio.scanbytes_v(&sc, 44u8)) {\n"
" match (bufio.scanbytes(&sc, 44u8)) {\n"
" case let bs: []u8 => { if (bs.len != 2 || bs[0] != 67u8 || bs[1] != 68u8) { return 88; }; };\n"
" case io.eof => { return 89; };\n"
" case let e: io.error => { return 90; };\n"
@@ -366,9 +341,9 @@ static const struct row rows[] = {
"};\n",
53,
STAGE_CS | STAGE_WW, 1 },
/* stream_setflush — setflush_v swaps the auto-flush byte-set to ';';
/* stream_setflush — setflush swaps the auto-flush byte-set to ';';
* writing "ab;" auto-flushes (contains ';') so the sink advances to
* 3 with no explicit flush. Pins setflush_v + the flush-scan path.
* 3 with no explicit flush. Pins setflush + the flush-scan path.
* cs.s==ww.s. */
{ "stream_setflush",
"package main;\n"
@@ -378,18 +353,18 @@ static const struct row rows[] = {
"import io;\n"
"export fn main() i32 = {\n"
" let sinkbuf: [16]u8;\n"
" let sink: memio.stream = memio.fixed_vstream(sinkbuf[0:16]);\n"
" let sinkvs: io.vstream = &sink.vt;\n"
" let sink: memio.stream = memio.fixed(sinkbuf[0:16]);\n"
" let sinkvs: io.stream = &sink.vt;\n"
" let rb: [4]u8;\n"
" let wb: [8]u8;\n"
" let b: bufio.bufio_ctx = bufio.bufio_vstream(sinkvs, rb[0:4], wb[0:8]);\n"
" let bvs: io.vstream = &b.vt;\n"
" let b: bufio.stream = bufio.init(sinkvs, rb[0:4], wb[0:8]);\n"
" let bvs: io.stream = &b.vt;\n"
" let semi: [1]u8;\n"
" semi[0] = 59u8;\n"
" bufio.setflush_v(&b, semi[0:1]);\n"
" bufio.setflush(&b, semi[0:1]);\n"
" let payload: [3]u8;\n"
" payload[0]=97u8; payload[1]=98u8; payload[2]=59u8;\n"
" let wr = io.st_write(bvs, payload[0:3]);\n"
" let wr = io.write(bvs, payload[0:3]);\n"
" if (!(wr is size)) { return 81; };\n"
" if (sink.pos != 3) { return 82; };\n"
" if (sinkbuf[0] != 97u8 || sinkbuf[2] != 59u8) { return 83; };\n"
@@ -397,9 +372,9 @@ static const struct row rows[] = {
"};\n",
54,
STAGE_CS | STAGE_WW, 1 },
/* stream_unread — read "XYZ" then unread_v("XY") pushes the two
/* stream_unread — read "XYZ" then unread("XY") pushes the two
* bytes back in front of the read buffer; the next read returns them
* first. Pins unread_v's in-place shift through *bufio_ctx.
* first. Pins unread's in-place shift through *stream.
* cs.s==ww.s. */
{ "stream_unread",
"package main;\n"
@@ -410,22 +385,22 @@ static const struct row rows[] = {
"export fn main() i32 = {\n"
" let raw: [4]u8;\n"
" raw[0]=88u8; raw[1]=89u8; raw[2]=90u8;\n"
" let mst: memio.stream = memio.dynamicfrom_vstream(raw[0:3]);\n"
" let vs: io.vstream = &mst.vt;\n"
" let mst: memio.stream = memio.dynamicfrom(raw[0:3]);\n"
" let vs: io.stream = &mst.vt;\n"
" let rbuf: [4]u8;\n"
" let wbuf: [4]u8;\n"
" let b: bufio.bufio_ctx = bufio.bufio_vstream(vs, rbuf[0:4], wbuf[0:4]);\n"
" let bvs: io.vstream = &b.vt;\n"
" let b: bufio.stream = bufio.init(vs, rbuf[0:4], wbuf[0:4]);\n"
" let bvs: io.stream = &b.vt;\n"
" let out: [4]u8;\n"
" let rd = io.st_read(bvs, out[0:3]);\n"
" let rd = io.read(bvs, out[0:3]);\n"
" let n: size = 0;\n"
" if (rd is size) { n = rd as size; };\n"
" if (n != 3: size || out[0] != 88u8 || out[2] != 90u8) { return 81; };\n"
" let push: [2]u8;\n"
" push[0]=88u8; push[1]=89u8;\n"
" bufio.unread_v(&b, push[0:2]);\n"
" bufio.unread(&b, push[0:2]);\n"
" let out2: [2]u8;\n"
" let rd2 = io.st_read(bvs, out2[0:2]);\n"
" let rd2 = io.read(bvs, out2[0:2]);\n"
" let n2: size = 0;\n"
" if (rd2 is size) { n2 = rd2 as size; };\n"
" if (n2 != 2: size || out2[0] != 88u8 || out2[1] != 89u8) { return 82; };\n"
@@ -564,7 +539,7 @@ main(void)
int got = run_row(cdrv, cwd, &rows[i], seq++);
if (got != rows[i].want_exit) {
fprintf(stderr,
"bufio_vstream_run[cs][%s]: exit=%d want=%d\n",
"init_run[cs][%s]: exit=%d want=%d\n",
rows[i].label, got, rows[i].want_exit);
fail++;
}
@@ -574,7 +549,7 @@ main(void)
int got = run_row(wdrv, cwd, &rows[i], seq++);
if (got != rows[i].want_exit) {
fprintf(stderr,
"bufio_vstream_run[ww][%s]: exit=%d want=%d\n",
"init_run[ww][%s]: exit=%d want=%d\n",
rows[i].label, got, rows[i].want_exit);
fail++;
}
@@ -582,7 +557,7 @@ main(void)
total++;
if (asm_byte_identical(cdrv, wdrv, cwd, &rows[i], seq++) != 0) {
fprintf(stderr,
"bufio_vstream_run[byte-id][%s]: cstage vs wwstage asm differs\n",
"init_run[byte-id][%s]: cstage vs wwstage asm differs\n",
rows[i].label);
fail++;
}
@@ -591,13 +566,13 @@ main(void)
}
if (!wwpresent)
fprintf(stderr, "bufio_vstream_run: skip wwstage (no %s)\n", wdrv);
fprintf(stderr, "init_run: skip wwstage (no %s)\n", wdrv);
if (fail) {
fprintf(stderr, "bufio_vstream_run: %d/%d fixtures failed\n",
fprintf(stderr, "init_run: %d/%d fixtures failed\n",
fail, total);
return 1;
}
printf("bufio_vstream_run: %d/%d ok\n", total, total);
printf("init_run: %d/%d ok\n", total, total);
return 0;
}