refactor(io): unify QB45 binary GET/PUT layout in QbBinaryCodec
authorSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 3 Sep 2026 20:51:52 +0000 (23:51 +0300)
committerSvjatoslav Agejenko <svjatoslav@svjatoslav.eu>
Thu, 3 Sep 2026 20:51:52 +0000 (23:51 +0300)
commitc9b7951a734fb0a23bfcbd8cf0f290d384adb417
tree4f339b039009ea189f807bae3275f11ca7311703
parent3ccaa91a38175d95edcf4eb3b8fcb5f812eb3f17
refactor(io): unify QB45 binary GET/PUT layout in QbBinaryCodec

The little-endian byte layout (INTEGER 2, LONG 4, SINGLE 4, DOUBLE 8,
fixed STRING*n space-padded) was written out four times in Interpreter:
scalar and record variants of both decode and encode, and the
record-target lookup (scalar cell vs array element) was copy-pasted
between decodeInto and encodeFrom.

QbBinaryCodec owns the layout now: decodeScalar/encodeScalar,
decodeRecord/encodeRecord over field descriptors. Numeric range
narrowing stays in the interpreter (it raises the trappable Overflow);
the codec is pure byte layout. Interpreter gains one recordTarget()
lookup used by byteSizeOf, decodeInto and encodeFrom.

Verification: 93/93 tests green; INDEX (RANDOM record GET/PUT),
QLBDUMP (BINARY GET into TYPE records) and SEARCH re-run — all
pixel-identical to the pre-refactor captures.
src/main/java/eu/svjatoslav/crtbasic/interp/Interpreter.java
src/main/java/eu/svjatoslav/crtbasic/io/QbBinaryCodec.java [new file with mode: 0644]