summary_showcase15.md 2.1 KB

Showcase 15 — IOChan over files + strict signature checks

Tags v3-showcase15, v3-showcase15-summary (this doc). Suite 131/131; fixpoint OK (2,103,316 bytes).

What it runs

compiler/tests/showcase15.mod (Showcase15, exit 42) links a DEFINITION/IMPLEMENTATION helper plus four stdlib modules:

IMPORT Showcase15Lib, IOChan, TextIO, Strings;
  1. Separate compilation + strict 235 — Showcase15Lib is a classic DEFINITION/IMPLEMENTATION pair; its signatures are verified by the new check (InitPoint, SumPoint, AppendInt).
  2. Records and VAR formals — Point, InitPoint(VAR p …).
  3. String concatenation/assignment — builds the report line "point " + <int> via Strings.Assign + AppendInt.
  4. IOChan over files — OpenWrite a channel, write "total", "point <n>", Close, then OpenRead and ReadString the lines back, checking both.

Output:

read back: point 42
showcase15 total=42

Bug found and fixed (shim)

m2freadline originally set the descriptor's count header to the number of bytes read. But HIGH(s) of an open ARRAY OF CHAR formal reads that same header, so HIGH(s) + 1 (used by IOChan.ReadString as the capacity) collapsed to the previous line's length after the first read — the second line was truncated ("point" instead of "point 42").

m2freadline now leaves the capacity header intact and returns the byte count instead, so a caller may keep using HIGH. (ReadString only needs the NUL-terminated content.)

Also, max is now declared int in C: Modula-2 CARDINAL arguments arrive in a 32-bit register (QBE w), so only the low 32 bits of the C long parameter are defined.

Registration

rm -f gen_ssa/_showcase15.txt before and after; expect_run_files_out Showcase15 42 "read back: point 42" … with the helper and the SysShim/Utf8/iochan/textio/strings/ conversions modules.

Files

compiler/tests/showcase15.mod, compiler/tests/showcase15lib.def/.mod, compiler/run_tests.sh, runtime/syslib/shim.c, docs/summary_showcase15.md.