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:
@@ -1,16 +1,13 @@
|
||||
/*
|
||||
* 779_log_vstream_run — project #94 fold-e5 sentinel. Pins the
|
||||
* additive lib/log/vstream.ww Option C parallel API: module-static
|
||||
* stderrsink_ctx_g with `vt: io.vtable` as the first field for the
|
||||
* intrusive vstream cast, the 10 _v variants of OLD log.ww's surface
|
||||
* (new_v / lprintln_v / println_v / lprintfln_v / printfln_v / lfatal_v
|
||||
* / fatal_v / lfatalf_v / fatalf_v / setlogger_v), a vlogger vtable +
|
||||
* vstdlogger over io.vstream sink, and lazy ensureinit_v wiring the
|
||||
* stderr default + silent_v / default_v / global_v *vlogger globals.
|
||||
* Coexists with the pre-vtable log.logger / log.stdlogger / log.new /
|
||||
* log.println / etc. surface in log.ww (fold-eFinal, task #50, retires
|
||||
* the latter and drops the `_v` suffix wholesale to match Hare's bare
|
||||
* names).
|
||||
* 779_log_vstream_run — project #94 fold-eFinal sentinel. Pins the
|
||||
* single-surface lib/log: module-static stderrsink_ctx_g with
|
||||
* `vt: io.vtable` as the first field for the intrusive cast, the 10
|
||||
* exported variants of log.ww's surface (new / lprintln / println /
|
||||
* lprintfln / printfln / lfatal / fatal / lfatalf / fatalf /
|
||||
* setlogger), a logger vtable + stdlogger over an io.stream sink, and
|
||||
* lazy ensureinit wiring the stderr default + silent / default /
|
||||
* global *logger globals. The fold-eFinal FLIP collapsed the dual
|
||||
* surface into this one Hare-shaped surface (bare names, no suffix).
|
||||
*
|
||||
* Each row imports os + log + memio + io. log itself imports fmt,
|
||||
* so the formattable / field types flow through transitively.
|
||||
@@ -18,8 +15,8 @@
|
||||
* Cstage-only per row (no STAGE_WW, no byte_id) — pre-existing
|
||||
* wwstage bug #209 (sibling of #190): the wwstage checker bails on
|
||||
* match-arm-over-formattable when fmt is imported transitively, which
|
||||
* lib/log does for the vlogger vtable signatures + the fmt.vfprint /
|
||||
* vfprintf dispatch in stdprintln_v / stdprintfln_v. The bug bites the
|
||||
* lib/log does for the logger vtable signatures + the fmt.fprint /
|
||||
* fprintf dispatch in stdprintln / stdprintfln. The bug bites the
|
||||
* OLD log surface identically — `log.println("hi")` from a probe
|
||||
* trips the same trace. Existing 970 logtest runs the @test fixture
|
||||
* under cstage `ww run` only, so the OLD surface is fine via cstage.
|
||||
@@ -30,70 +27,63 @@
|
||||
*
|
||||
* row | what it pins
|
||||
* --------------------------+--------------------------------------
|
||||
* println_v_default_stderr | log.println_v through the [[default_v]]
|
||||
* println_v_default_stderr | log.println through the [[default]]
|
||||
* | global, routed to fd 2 via the
|
||||
* | module-static stderrsink_ctx_g. Asserts
|
||||
* | ensureinit_v wires + dispatches without
|
||||
* | ensureinit wires + dispatches without
|
||||
* | crashing; stderr capture is left to the
|
||||
* | shell runner. Pins the full chain:
|
||||
* | println_v → lprintln_v(global_v) →
|
||||
* | (*vlogger).println_v → stdprintln_v →
|
||||
* | fmt.vfprint + io.st_write("\n").
|
||||
* | println → lprintln(global) →
|
||||
* | (*logger).println → stdprintln →
|
||||
* | fmt.fprint + io.write("\n").
|
||||
* printfln_v_default_stderr | Same chain as row 1 but through the
|
||||
* | format-string slot (printfln_v →
|
||||
* | lprintfln_v(global_v) → stdprintfln_v
|
||||
* | → fmt.vfprintf + io.st_write("\n")).
|
||||
* | format-string slot (printfln →
|
||||
* | lprintfln(global) → stdprintfln
|
||||
* | → fmt.fprintf + io.write("\n")).
|
||||
* | Pins the {n}-placeholder dispatch
|
||||
* | through vformatfield reaches the
|
||||
* | default sink.
|
||||
* lprintln_v_custom_sink | memio.fixed_vstream-backed vstdlogger;
|
||||
* | log.new_v wires the vtable + sink,
|
||||
* | log.lprintln_v dispatches "hi" + 7i64
|
||||
* | through stdprintln_v. Asserts the
|
||||
* lprintln_v_custom_sink | memio.fixed-backed stdlogger;
|
||||
* | log.new wires the vtable + sink,
|
||||
* | log.lprintln dispatches "hi" + 7i64
|
||||
* | through stdprintln. Asserts the
|
||||
* | exact bytes ("hi 7\n") land in the
|
||||
* | caller's buffer (fixed_vstream borrows
|
||||
* | caller's buffer (fixed borrows
|
||||
* | the slice, so the bytes are visible
|
||||
* | back through buf[]).
|
||||
* branched_lprintln_v | branched callee per #105: two distinct
|
||||
* | vstdlogger sinks runtime-selected via
|
||||
* | *vlogger pointer. lprintln_v dispatches
|
||||
* branched_lprintln | branched callee per #105: two distinct
|
||||
* | stdlogger sinks runtime-selected via
|
||||
* | *logger pointer. lprintln dispatches
|
||||
* | through the picked sink only; the
|
||||
* | other stays empty. Catches a constant-
|
||||
* | fold mistake in the fn-ptr dispatch
|
||||
* | (mirror of 778's branched_bufio_vstream).
|
||||
* | (mirror of 778's branched_bufio_wrap).
|
||||
*
|
||||
* SIBLINGS (filed inline, NOT fixed here — fold-e5 is purely
|
||||
* additive over fold-e1/e2/e3/e4's frozen io.* + memio.* + fmt.* +
|
||||
* bufio.* surface plus the minimal `export` bump on fmt.vfprint /
|
||||
* fmt.vfprintf):
|
||||
* DEFERRALS / RELATED (NOT addressed by this row):
|
||||
*
|
||||
* - eFinal (#50): atomic flip + delete OLD log surface + drop the
|
||||
* `_v` suffix wholesale.
|
||||
* - #206 (bare &fn → (*alias|void)): 2 cast sites at ensureinit
|
||||
* in lib/log/log.ww; the explicit casts are KEPT (ken/#214 —
|
||||
* cast-drop is a separate deferred payoff gated on #214).
|
||||
*
|
||||
* - #206 (bare &fn → (*alias|void)): 2 cast sites at ensureinit_v
|
||||
* in lib/log/vstream.ww; drop out wholesale on close.
|
||||
*
|
||||
* - #173 (TRY-on-tagged-return both-stages broken): stderrwrite_v
|
||||
* - #173 (TRY-on-tagged-return both-stages broken): stderrwrite
|
||||
* constructs nomem and widens to io.error explicitly rather than
|
||||
* using `os.trywrite(...)?`; same shape memio.vstream.ww +
|
||||
* fmt.vstream.ww + bufio.vstream.ww adopt.
|
||||
* using `os.trywrite(...)?`; same shape memio.ww + fmt.ww +
|
||||
* bufio.ww adopt.
|
||||
*
|
||||
* - #209 (wwstage formattable match-arm bail): every row is
|
||||
* STAGE_CS-only; byte-id deferred until #209 lands.
|
||||
*
|
||||
* BOOTSTRAP-EMBED CHECK: log is NOT embedded in any selfhost
|
||||
* combined.ww (grep `package log\|import log` returned empty pre-
|
||||
* impl). Adding lib/log/vstream.ww + the two `export` bumps on
|
||||
* lib/fmt/vstream.ww does NOT require a Makefile regen (#110); only
|
||||
* lib/log/ + lib/fmt/ test paths see the new module surface. 990-997
|
||||
* byte-id gates stay green by virtue of log being test-only and the
|
||||
* fmt vstream.ww changes being non-embedded.
|
||||
* combined.ww (grep `package log\|import log` returns empty), so the
|
||||
* fold-eFinal log collapse does not require a Makefile regen (#110);
|
||||
* only lib/log/ + lib/fmt/ test paths see the surface. 990-997
|
||||
* byte-id gates stay green by virtue of log being test-only.
|
||||
*
|
||||
* GATE POLARITY: must stay GREEN. A red here means vstream.ww
|
||||
* GATE POLARITY: must stay GREEN. A red here means lib/log
|
||||
* regressed, the module-static stderrsink_ctx_g zero-init or chained
|
||||
* vt-field assigns regressed, the intrusive vstream→*stderrsink_ctx
|
||||
* cast miscomputed offsets, ensureinit_v's one-shot guard broke, or
|
||||
* the fn-ptr dispatch through vlogger.println_v / printfln_v stopped
|
||||
* vt-field assigns regressed, the intrusive io.stream→*stderrsink_ctx
|
||||
* cast miscomputed offsets, ensureinit's one-shot guard broke, or
|
||||
* the fn-ptr dispatch through logger.println / printfln stopped
|
||||
* resolving.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
@@ -128,7 +118,7 @@ static const struct row rows[] = {
|
||||
"import os;\n"
|
||||
"import log;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" log.println_v(\"hello\");\n"
|
||||
" log.println(\"hello\");\n"
|
||||
" return 42;\n"
|
||||
"};\n",
|
||||
42,
|
||||
@@ -138,7 +128,7 @@ static const struct row rows[] = {
|
||||
"import os;\n"
|
||||
"import log;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" log.printfln_v(\"v={}\", 7i64);\n"
|
||||
" log.printfln(\"v={}\", 7i64);\n"
|
||||
" return 43;\n"
|
||||
"};\n",
|
||||
43,
|
||||
@@ -151,10 +141,10 @@ static const struct row rows[] = {
|
||||
"import io;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let buf: [16]u8;\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"
|
||||
" let st: memio.stream = memio.fixed(buf[0:16]);\n"
|
||||
" let vs: io.stream = &st.vt;\n"
|
||||
" let sl: log.stdlogger = log.new(vs);\n"
|
||||
" log.lprintln(&sl.logger, \"hi\", 7i64);\n"
|
||||
" if (buf[0] != 104u8) { return 91; };\n"
|
||||
" if (buf[1] != 105u8) { return 92; };\n"
|
||||
" if (buf[2] != 32u8) { return 93; };\n"
|
||||
@@ -164,7 +154,7 @@ static const struct row rows[] = {
|
||||
"};\n",
|
||||
44,
|
||||
STAGE_CS, 0 },
|
||||
{ "branched_lprintln_v",
|
||||
{ "branched_lprintln",
|
||||
"package main;\n"
|
||||
"import os;\n"
|
||||
"import log;\n"
|
||||
@@ -173,16 +163,16 @@ static const struct row rows[] = {
|
||||
"export fn main() i32 = {\n"
|
||||
" let bufA: [16]u8;\n"
|
||||
" let bufB: [16]u8;\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 stA: memio.stream = memio.fixed(bufA[0:16]);\n"
|
||||
" let vsA: io.stream = &stA.vt;\n"
|
||||
" let stB: memio.stream = memio.fixed(bufB[0:16]);\n"
|
||||
" let vsB: io.stream = &stB.vt;\n"
|
||||
" let slA: log.stdlogger = log.new(vsA);\n"
|
||||
" let slB: log.stdlogger = log.new(vsB);\n"
|
||||
" let sel: i32 = 1;\n"
|
||||
" let chosen: *log.vlogger = &slA.logger;\n"
|
||||
" let chosen: *log.logger = &slA.logger;\n"
|
||||
" if (sel == 0) { chosen = &slB.logger; };\n"
|
||||
" log.lprintln_v(chosen, \"pick\");\n"
|
||||
" log.lprintln(chosen, \"pick\");\n"
|
||||
" if (bufA[0] != 112u8) { return 91; };\n"
|
||||
" if (bufA[1] != 105u8) { return 92; };\n"
|
||||
" if (bufA[2] != 99u8) { return 93; };\n"
|
||||
|
||||
Reference in New Issue
Block a user