rpg_loops.zig, rpg_shape.zig: a decimal FOR with a field limit, a two-digit start, bare DOWNTO and an explicit BY 1 #768

Manually merged
binjovi-bot merged 4 commits from lcf3 into trunk 2026-11-08 17:27:53 +00:00
Owner

rpg_loops.zig: a FOR over a decimal index with a field limit, a two-digit start, bare DOWNTO and an explicit BY 1 (touches rpg_shape.zig)

Predicted mechanism (written before the capture and before the rule). rpg_loops.decimalFor matches the
normalized FOR head statement of a packed or zoned index against one fixed layout built with l.add(...):

  • s11: the statement is not the layout's length (the layout is 37 to 45 operations by sym_init, zoned
    and by);
  • s13: at one position the operation or its operand count differs, the length being equal;
  • s14: an operand differs.

The limit slot of the layout is 27 <decimal constant> (decimalConstant) and the step slot of a BY layout is
the same. Every public twin of the layout (lr1-di-pk3, lr1-di-pk5, lr1-di-pk5-sub, lr1-di-zd4, lr1-lf-*) has a
literal limit, so the layout was fitted to literal limits only. A limit that is a field of the index's own type is
the candidate for s13: 32 <field> 0 <type> where the layout has 27 <constant>, the same length, one
operation of another code and operand count. A limit of another digit count, class or home (an array element, a
parameter, a subfield) is expected to add operations and stop at s11.

The two other tokens of the line are expected to come from the same refused head statement and not from the body.
The head starts with 33 <return point>; 35 <control slot> (the local call that holds the counting code), and the
33 pushes a label pointer (kind 22), which is not data. When decimalFor refuses, the head statement falls back
to raw operations and the first operation without a value rule is that 33 (rpg_eval.step s02, the address
push of a non-data symbol); the DSPLY proof, tried on the same statement, sees the same 33 first and declines at
rpg_display.stagedAddress s02. The body (EXSR, a procedure call, DSPLY) is a control.

Battery: ~/data/sourcerer-loop/requests/lcf3/for-forms (24 cases, lcf3-for-*: step and direction, limit kind,
index class and digit count, start field, body). The mapping from a token to its statement group is
~/data/sourcerer-loop/runs/lcf3/groups.awk (a marker is written when a group is evidenced, so the tokens before
marker k belong to group k; validated on lr1-di-pk3, where group 14 is the recovered FOR head and has none).

Measured on the first 9 of 24 captured cases (lcf3-for-*)

The head hypothesis holds: in every refused head the tracer prints rpg_eval.step s02 in the same statement group as
the decimalFor token (dn: s10; dn-by1 and dn-lim-fld: s14). The bodies (EXSR, local procedure, DSPLY) and
base, by1, by2 recover with no token, so the body is not a cause. Three forms differ from the layout:

  • The start literal: the operand of the 88 conversion is the digit count of the literal (88 1 for 1..9, 88 2 for
    10..99), not a constant 1. A start of 10 or more gave s14. Now checked against the digit count.
  • A bare DOWNTO (no BY): the non-BY layout with the compare 11 and a step constant of -1 (s10 before).
  • A limit that is a field of the index's own type: 29 F 0 T where the layout has 27 C (same length, op and
    operand count differ: s13, hidden behind s14 when the start has two digits). The limit is then named.
  • An explicit BY 1 compiles to the BY layout and recompiles differently from the implicit step: Proof.by keeps it,
    and the header is written TO 10 BY 1 (it was TO 10).

Test: src/rpg_for_forms_test.zig (red on trunk 623d80aa for by1, dn, dn-by1, dn-lim-fld; green here).
Probes lcf3-for-base, -by1, -dn, -dn-by1, -dn-lim-fld.

All 24 cases (tracer on the build of this change)

Recover and emit clean: base, by1, by2, dn, dn-by1, dn-lim-fld, lim-fld-p5, lim-fld-p3, lim-fld-zd, lim-fld-int,
zd5-lim-fld, pk4, pk9, pk15, pk9-lim-fld, zd9, st-fld-lim-fld, body-exsr, body-proc, body-dsply (the loop; the
DSPLY of a packed field stays partial, DSPLY ?, a value-flow family outside this lane).

The limit slot (rpg_loops.limitOf) has three forms, all measured: a decimal constant 27 C; a field 29 F 0 T
of any packed length (no conversion), of a zoned field (then 84 N 1) or of a 4-byte integer (then 86 10), the
field's own type T and its class checked; and a packed parameter by reference 29 P 0 T; 32 V 0 T; 61 N 0 0.
The emitted header names the field. Zoned index with zoned limit (zd5-lim-fld) is the zoned layout plus the
field form.

Negative results (tokens as printed, no rule):

case token what the head holds
lim-dssub decimalFor s11 limit in a data structure subfield: 33 DS before the loop test and 27 ptr; 5; 5; 32 i; 61; 5; 32 sub; 61 (the address stays on the stack)
lim-elem decimalFor s11 limit a(1): 34 A 0 and the same 5; 5; ...; 5 stack shape
int-lim-pk decimalFor s06 an integer index with a packed limit takes the binary path (78 8; 75 4) and a 86 10; 61 10 0 0 before the packed limit
lim-parm head recovers; closeLoop s02 the linear-main procedure has a part with code after ENDFOR that is not the last part; the closing, not the decimal head

Every other change: the emitted text of the earlier five probes is byte-identical to the build of 49cb348f.
Probes adopted: lcf3-for-{base,by1,dn,dn-by1,dn-lim-fld,lim-fld-p5,lim-fld-p3,lim-fld-zd,lim-fld-int,zd5-lim-fld,pk9-lim-fld,st-fld-lim-fld,pk15,zd9}.

# rpg_loops.zig: a FOR over a decimal index with a field limit, a two-digit start, bare DOWNTO and an explicit BY 1 (touches rpg_shape.zig) Predicted mechanism (written before the capture and before the rule). `rpg_loops.decimalFor` matches the normalized FOR head statement of a packed or zoned index against one fixed layout built with `l.add(...)`: - `s11`: the statement is not the layout's length (the layout is 37 to 45 operations by `sym_init`, `zoned` and `by`); - `s13`: at one position the operation or its operand count differs, the length being equal; - `s14`: an operand differs. The limit slot of the layout is `27 <decimal constant>` (`decimalConstant`) and the step slot of a BY layout is the same. Every public twin of the layout (lr1-di-pk3, lr1-di-pk5, lr1-di-pk5-sub, lr1-di-zd4, lr1-lf-*) has a literal limit, so the layout was fitted to literal limits only. A limit that is a field of the index's own type is the candidate for `s13`: `32 <field> 0 <type>` where the layout has `27 <constant>`, the same length, one operation of another code and operand count. A limit of another digit count, class or home (an array element, a parameter, a subfield) is expected to add operations and stop at `s11`. The two other tokens of the line are expected to come from the same refused head statement and not from the body. The head starts with `33 <return point>; 35 <control slot>` (the local call that holds the counting code), and the `33` pushes a label pointer (kind 22), which is not data. When `decimalFor` refuses, the head statement falls back to raw operations and the first operation without a value rule is that `33` (`rpg_eval.step s02`, the address push of a non-data symbol); the DSPLY proof, tried on the same statement, sees the same `33` first and declines at `rpg_display.stagedAddress s02`. The body (EXSR, a procedure call, DSPLY) is a control. Battery: `~/data/sourcerer-loop/requests/lcf3/for-forms` (24 cases, `lcf3-for-*`: step and direction, limit kind, index class and digit count, start field, body). The mapping from a token to its statement group is `~/data/sourcerer-loop/runs/lcf3/groups.awk` (a marker is written when a group is evidenced, so the tokens before marker k belong to group k; validated on lr1-di-pk3, where group 14 is the recovered FOR head and has none). ## Measured on the first 9 of 24 captured cases (lcf3-for-*) The head hypothesis holds: in every refused head the tracer prints `rpg_eval.step s02` in the same statement group as the `decimalFor` token (dn: `s10`; dn-by1 and dn-lim-fld: `s14`). The bodies (EXSR, local procedure, DSPLY) and `base`, `by1`, `by2` recover with no token, so the body is not a cause. Three forms differ from the layout: - The start literal: the operand of the `88` conversion is the digit count of the literal (`88 1` for 1..9, `88 2` for 10..99), not a constant 1. A start of 10 or more gave `s14`. Now checked against the digit count. - A bare `DOWNTO` (no BY): the non-BY layout with the compare `11` and a step constant of -1 (`s10` before). - A limit that is a field of the index's own type: `29 F 0 T` where the layout has `27 C` (same length, op and operand count differ: `s13`, hidden behind `s14` when the start has two digits). The limit is then named. - An explicit `BY 1` compiles to the BY layout and recompiles differently from the implicit step: `Proof.by` keeps it, and the header is written `TO 10 BY 1` (it was `TO 10`). Test: `src/rpg_for_forms_test.zig` (red on trunk 623d80aa for by1, dn, dn-by1, dn-lim-fld; green here). Probes `lcf3-for-base`, `-by1`, `-dn`, `-dn-by1`, `-dn-lim-fld`. ## All 24 cases (tracer on the build of this change) Recover and emit clean: base, by1, by2, dn, dn-by1, dn-lim-fld, lim-fld-p5, lim-fld-p3, lim-fld-zd, lim-fld-int, zd5-lim-fld, pk4, pk9, pk15, pk9-lim-fld, zd9, st-fld-lim-fld, body-exsr, body-proc, body-dsply (the loop; the DSPLY of a packed field stays partial, `DSPLY ?`, a value-flow family outside this lane). The limit slot (`rpg_loops.limitOf`) has three forms, all measured: a decimal constant `27 C`; a field `29 F 0 T` of any packed length (no conversion), of a zoned field (then `84 N 1`) or of a 4-byte integer (then `86 10`), the field's own type `T` and its class checked; and a packed parameter by reference `29 P 0 T; 32 V 0 T; 61 N 0 0`. The emitted header names the field. Zoned index with zoned limit (`zd5-lim-fld`) is the zoned layout plus the field form. Negative results (tokens as printed, no rule): | case | token | what the head holds | |---|---|---| | lim-dssub | `decimalFor s11` | limit in a data structure subfield: `33 DS` before the loop test and `27 ptr; 5; 5; 32 i; 61; 5; 32 sub; 61` (the address stays on the stack) | | lim-elem | `decimalFor s11` | limit `a(1)`: `34 A 0` and the same `5; 5; ...; 5` stack shape | | int-lim-pk | `decimalFor s06` | an integer index with a packed limit takes the binary path (`78 8; 75 4`) and a `86 10; 61 10 0 0` before the packed limit | | lim-parm | head recovers; `closeLoop s02` | the linear-main procedure has a part with code after ENDFOR that is not the last part; the closing, not the decimal head | Every other change: the emitted text of the earlier five probes is byte-identical to the build of 49cb348f. Probes adopted: `lcf3-for-{base,by1,dn,dn-by1,dn-lim-fld,lim-fld-p5,lim-fld-p3,lim-fld-zd,lim-fld-int,zd5-lim-fld,pk9-lim-fld,st-fld-lim-fld,pk15,zd9}`.
sean force-pushed lcf3 from 2898b1dd1d
All checks were successful
binjovi/ci Binjovi completed the frozen plan
to 7ca69a61b3
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-08 17:18:42 +00:00
Compare
binjovi-bot manually merged commit 7ca69a61b3 into trunk 2026-11-08 17:27:53 +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!768
No description provided.