rpg_eval.zig: the concatenation of varying-length fields, pieces at computed offsets #747

Manually merged
binjovi-bot merged 3 commits from lc2h into trunk 2026-11-07 12:38:33 +00:00
Owner

rpg_eval.zig: the concatenation of varying-length fields, pieces at computed offsets

A concatenation with a varying-length piece stopped at value_flow / operation 62
(lc2-cat-varchar-src, -two, -both, -field, lc2-cat-call-const-vary2). The compiler
copies the data of the first field to a buffer and addresses the next piece at the
buffer plus the length of the first (27 L; 62). That length is a temporary that
the program computed, so the evaluator, which knew only numeric offsets of an
address, had nothing to add to.

  • A typed address with a computed length. Value.address_plus is the address
    of a temporary at a byte plus a length that is the text of a value. It is a
    variant of its own, never an address, so no rule that tests a numeric offset
    can match it, and Address, the key of the saved temporaries, does not change.
    62 produces it only for a temporary base whose offset is neither an integer
    nor a recognised substring start.
  • Pieces. A copy to a temporary whose length is computed, or to an
    address_plus, is a piece: it follows the piece that has the length in the
    address, and its text is the field (a varying field is read as its data and
    its length, proved by the load of its first two bytes), a literal or a field.
    The copy of the whole buffer reads the pieces, in order, as a + b.
  • Three proofs where the program computes. The length check of a varying field
    (error 115 when the length is more than the size less the two length bytes),
    the minimum of the total and the size of a varying target
    (27 A; 27 B; 11; 17 L; 27 B; 35 A; 15 L 1), and the blank fill after the copy
    to a fixed field (the fill is the pad of the copy, which becomes the assignment).
    A skip whose label lies after the body of the statement (the fill) is closed
    at the end of the run when it is proved.

Results: S262.0 = S268 + 'x', S262.0 = S268 + S269, S267 = S268 + S269,
S267 = S268 + S255 and CALLP SHOWV(S268 + S269). Still open in the battery:
lc2-cat-varchar-tgt (v = a + b) and lc2-cat-call-const-vary (showv(a + 'x')),
which stop at call / 97 on a first copy of another shape, and lc2-cat-return-concat.

Gates

{"checks":{"net_statements":0},"census":{"statuses":{"recovered":645,"partial":0,"unresolved":0},"regressions":0,"newly_recovered":0},"golden":"golden floor 173 ceiling 0 <= dump 173/5/0","legend":"current","emit":{"worse":[],"better":3,"newly_clean":1,"clean_delta":1,"base":415,"new":416},"twins":{"groups":649,"recovered":640,"regressions":[],"newly":27},"allgroups":{"regressions":[],"newly":["savf/SC-CONSTRUCT/TLICR/archive.savf 2","savf/SC-ILE/EXPERIMENTS/h-bifs-char/stripped/object.savf 2","savf/SC-ILE/EXPERIMENTS/r9r-decstr/stripped/object.savf 1"],"worse":["savf/SC-CONSTRUCT/TLICR/archive.savf|TLICR.PGM|3031-3121","savf/SC-CONSTRUCT/TRPG3/archive.savf|TRPG3.PGM|3179-3362"]},"full_check":{"exit":0,"seconds":1292}}
## rpg_eval.zig: the concatenation of varying-length fields, pieces at computed offsets A concatenation with a varying-length piece stopped at value_flow / operation 62 (lc2-cat-varchar-src, -two, -both, -field, lc2-cat-call-const-vary2). The compiler copies the data of the first field to a buffer and addresses the next piece at the buffer plus the length of the first (`27 L; 62`). That length is a temporary that the program computed, so the evaluator, which knew only numeric offsets of an address, had nothing to add to. - **A typed address with a computed length.** `Value.address_plus` is the address of a temporary at a byte plus a length that is the text of a value. It is a variant of its own, never an `address`, so no rule that tests a numeric offset can match it, and `Address`, the key of the saved temporaries, does not change. `62` produces it only for a temporary base whose offset is neither an integer nor a recognised substring start. - **Pieces.** A copy to a temporary whose length is computed, or to an `address_plus`, is a piece: it follows the piece that has the length in the address, and its text is the field (a varying field is read as its data and its length, proved by the load of its first two bytes), a literal or a field. The copy of the whole buffer reads the pieces, in order, as `a + b`. - **Three proofs where the program computes.** The length check of a varying field (error 115 when the length is more than the size less the two length bytes), the minimum of the total and the size of a varying target (`27 A; 27 B; 11; 17 L; 27 B; 35 A; 15 L 1`), and the blank fill after the copy to a fixed field (the fill is the pad of the copy, which becomes the assignment). A skip whose label lies after the body of the statement (the fill) is closed at the end of the run when it is proved. Results: `S262.0 = S268 + 'x'`, `S262.0 = S268 + S269`, `S267 = S268 + S269`, `S267 = S268 + S255` and `CALLP SHOWV(S268 + S269)`. Still open in the battery: lc2-cat-varchar-tgt (`v = a + b`) and lc2-cat-call-const-vary (`showv(a + 'x')`), which stop at call / 97 on a first copy of another shape, and lc2-cat-return-concat. ## Gates ``` {"checks":{"net_statements":0},"census":{"statuses":{"recovered":645,"partial":0,"unresolved":0},"regressions":0,"newly_recovered":0},"golden":"golden floor 173 ceiling 0 <= dump 173/5/0","legend":"current","emit":{"worse":[],"better":3,"newly_clean":1,"clean_delta":1,"base":415,"new":416},"twins":{"groups":649,"recovered":640,"regressions":[],"newly":27},"allgroups":{"regressions":[],"newly":["savf/SC-CONSTRUCT/TLICR/archive.savf 2","savf/SC-ILE/EXPERIMENTS/h-bifs-char/stripped/object.savf 2","savf/SC-ILE/EXPERIMENTS/r9r-decstr/stripped/object.savf 1"],"worse":["savf/SC-CONSTRUCT/TLICR/archive.savf|TLICR.PGM|3031-3121","savf/SC-CONSTRUCT/TRPG3/archive.savf|TRPG3.PGM|3179-3362"]},"full_check":{"exit":0,"seconds":1292}} ```
binjovi-bot manually merged commit 7535624129 into trunk 2026-11-07 12:38:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sean/sourcerer!747
No description provided.