lumbda/wasm/c
russell@unturf.com cf7ff2219f
c-tier streaming: re-add the trailing newline emcc strips before postMessage
Emscripten's Module.print fires once per line and hands the loader
just the line content — no trailing newline; the caller is expected
to add it back when joining (outBuf.join('\n') does that for the
final return). Streaming path was forwarding the line straight to
onChunk without the newline, so successive chunks concatenated
horizontally in the playground panel — the loop

  (let loop ((i 0))
    (cond ((= (modulo i 10000) 0) (display \"tick \") (display i) (newline)))
    (loop (+ i 1)))

was running fine on c tier (each (newline) ended a printf line) but
arriving in the UI as 'tick 0tick 10000tick 20000...' with no
breaks.

Loader's print/printErr callbacks now pass `line + \"\\n\"` to
currentOnChunk. Final buffered join (which already adds the \\n)
is untouched, so the post-eval output string keeps the same shape.
Pyodide _StreamingStdout sees Python's raw write() bytes including
the \\n already; asm's emit_chunk fires AFTER output_len was
incremented past the \\n, so the slice [flush_start, output_len)
includes it. Neither needed a change.
2026-06-15 05:38:03 -04:00
..
bend-call-library.js bend: fix C tier LinkError — switch EM_JS to --js-library mergeInto 2026-06-14 19:33:07 -04:00
jit-stub.c wasm: three-tier Lumbda to WebAssembly + browser playground 2026-06-14 11:40:34 -04:00
lumbda-c.loader.js c-tier streaming: re-add the trailing newline emcc strips before postMessage 2026-06-15 05:38:03 -04:00
lumbda_wasm_entry.c bend: wire bend!-call into the Emscripten C tier — playground c 2026-06-14 19:04:52 -04:00