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
Loading…
Reference in a new issue
No description provided.
Delete branch "lcf3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.decimalFormatches thenormalized 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 bysym_init,zonedand
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 isthe 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 has27 <constant>, the same length, oneoperation 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 the33pushes a label pointer (kind 22), which is not data. WhendecimalForrefuses, the head statement falls backto raw operations and the first operation without a value rule is that
33(rpg_eval.step s02, the addresspush of a non-data symbol); the DSPLY proof, tried on the same statement, sees the same
33first and declines atrpg_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 beforemarker 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 s02in the same statement group asthe
decimalFortoken (dn:s10; dn-by1 and dn-lim-fld:s14). The bodies (EXSR, local procedure, DSPLY) andbase,by1,by2recover with no token, so the body is not a cause. Three forms differ from the layout:88conversion is the digit count of the literal (88 1for 1..9,88 2for10..99), not a constant 1. A start of 10 or more gave
s14. Now checked against the digit count.DOWNTO(no BY): the non-BY layout with the compare11and a step constant of -1 (s10before).29 F 0 Twhere the layout has27 C(same length, op andoperand count differ:
s13, hidden behinds14when the start has two digits). The limit is then named.BY 1compiles to the BY layout and recompiles differently from the implicit step:Proof.bykeeps it,and the header is written
TO 10 BY 1(it wasTO 10).Test:
src/rpg_for_forms_test.zig(red on trunk623d80aafor 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 constant27 C; a field29 F 0 Tof any packed length (no conversion), of a zoned field (then
84 N 1) or of a 4-byte integer (then86 10), thefield's own type
Tand its class checked; and a packed parameter by reference29 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 thefield form.
Negative results (tokens as printed, no rule):
decimalFor s1133 DSbefore the loop test and27 ptr; 5; 5; 32 i; 61; 5; 32 sub; 61(the address stays on the stack)decimalFor s11a(1):34 A 0and the same5; 5; ...; 5stack shapedecimalFor s0678 8; 75 4) and a86 10; 61 10 0 0before the packed limitcloseLoop s02Every 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}.2898b1dd1d7ca69a61b3