rpg_source_forms.zig, rpg_source_render_emit.zig: the trailer for declarations that do not fit says how many lines are missing #798
Loading…
Reference in a new issue
No description provided.
Delete branch "ldfit"
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_source_forms.zig, rpg_source_render_emit.zig: the trailer for declarations that do not fit says how many lines are missing
The compiler numbers a statement by its source line, so a program whose declarations need more lines than the lines
before its first statement shifts every statement after them, and it can never match. The emit already says so in a
trailer. The trailer now also says how many lines the declarations lack:
Layout.missingis the sum of the rises of the displacement of numbered lines (Layout.push): the lines by which textthat has no number pushed a numbered line below its number, counted again only where the push grows; a numbered line that
lands on its number ends the push. It is the shortfall under the rule the emitter applies now (the declarations of a scope
go on the lines before the first statement of that scope). The text keeps the prefix
declarations do not fit before source line Nthatrt-stmt-diff.sh,agree.awkandemit-families.awkread. The tail "later statement numbers move" isgone: with the count the line is 78 to 82 characters (the old one was 92 to 94), and
clipcuts a trailer at 100. Both trailer sites (renderandrenderColumns) use one helper. Nothing else in any emit changes.No placement rule is shipped. No public compiled source puts a declaration after an executable statement, so the objects
do not say whether the compiler accepts it or whether it changes the object (see "Why no placement rule yet").
Measure (2026-11-13, v0.1.513, every public emit with the trailer)
Trailer counts before and after this change: Async 6, scout2 1, committed twins 28 (the same programs; the committed
twin
ldsv-asyncpromis the Async programasyncprom, so 34 distinct programs, 35 emits). Of the 19 scout2 captures onecarries the trailer (barrettotte-vscode-ibmi-languages-1), not 7. The brief's 7 may be Async 6 plus this 1; that is a guess.
Where the source put its declarations: in none of the 35 programs after an executable statement of the same scope. The
fixed-form twins cannot (D before C). The 7 free-form captures: every local declaration directly after
end-pi, every globalbefore the first
dcl-proc. A search for adcl-s,dcl-c,dcl-dsordcl-prthat follows an executable statement of itsscope, or a global that follows a
dcl-procor a module-level statement (/IF DEFINEDblocks evaluated, continuation linesskipped,
on-exitcounted as code) finds none in 753 committed free-form sources (the rpg-corpus files hold several programseach, so they are left out), in the 25 captures, and in the 8 free-form dev5 sources. No compiled object decides the question.
The Async emits (the lines are source lines;
need= declaration and interface lines of the emit,lead= the lines thecurrent rule has (before the first statement of each scope),
free= all free lines of the scopes, contiguous or not, soneed > freeproves that no placement fits):In each program 15 scopes (asyncprom 16) are over, and none of them packs in order into the free runs of its procedure
(a block of lines is one run). In 13 of them the whole procedure, blank lines after the first statement included, has fewer
free lines than the emit has declaration lines: 44 lines short in all even if every free line were usable. Gaps cannot
fix a program of this kind. The cause is the size of the declarations: asyncage
has 38 local
dcl-ds ... likeds(task_t) based(p)lines in the source, one each. The emit recovers 18 of them as fullstructures of 100 lines in all (18
dcl-ds, 35 filler linesGn char(k), 29 subfield lines, 18end-ds;), where thesource spends 18 lines. (
likedsof the template and apos()subfield in place of a filler would shorten them; neither isin this change, and
pos()is not proved.)The scout2 emit: l10-barrettotte-vscode-ibmi-languages-1 is a different defect. The
on-exitsection is written as aprocedure
_QRNI_ON_EXIT_MAINwithdcl-pi/ one failing parameter /end-pi(3 lines) where the source has the lineon-exit;(line 49) and no interface, so*inlr = *on;(source line 50) lands on line 53. It misses 3 lines. Twins whoseon-exitis recognized writeon-exit;(e.g. P700F32C9S).The 28 committed twins (rows with
n/mare programs whose statement numbers are not source lines because the compilernumbers the generated I/O lines, so
leadandfreeare not computed):(
needcounts the**FREEline,ctl-opt, file declarations and the interface; the statement numbers of thetwo programs marked
n/m(ws-fixed,fixed-exsr) are not lines: the first calculation offixed-exsris statement 9 onsource line 5, because the compiler numbers the lines it generates for the file.
fx-heldandfx-held2have acalculation on line 1, so no line is free before it.) 16 of the 28 have no failure line
except the trailer: l3b-ds-const, lv-pds-pi-ds, packed-add-held, the nine
lv-af-*, lr1-ec-loop-next, l3b-elem-const,ws-fixed and fixed-exsr; so these 16 are the programs that a fit would turn into candidates for a host round trip. None
of the 28 is
matchin the newest matrix snapshot (base-v0.1.513.ndjson: 25different, 3failed).What the 16 need: a fixed-form source spends one line on
H, eachF, eachDand the subfields of a structure; thefree-form emit spends the same lines plus
**FREEand anend-ds;for each structure, and has no free line in the sourceto take them (
lv-af-evalh: six source lines before the first statement, eight emitted; the two free lines at 8 and 10are
/FREEand/END-FREE, one line each, and the four-linedcl-dsis one block). No fit is possible by placement.Why no placement rule yet
Placing a declaration after an executable statement is accepted or refused by the compiler, and the objects do not say
which: no public compiled program does it (search above), so a rule would be a guess. Wrong text without a failure line is
worse than a refusal, and a refused compile turns a program with a trailer into one that fails to build. The measure above
shows how little the rule could win: even if the compiler accepted every placement, 32 of the 35 emits have a scope whose
declaration blocks do not pack in order into its free runs (a block is one run), so no placement fits them. The other
three are
r5x-cycle-print(11 failure lines) andfixed-exsrandws-fixed, whose statement numbers are not lines (notcomputed) and whose sources have no blank or comment line, so there is no free line to place anything on. The four
lv-af-*twins withfree=needshow the limit: the free runs are lines 1 to 6, 8 and 10, and the structure is oneblock of 4 lines. Packing two statements on one line is closed too until it is measured:
docs/DUMP.mdrecords RNF5508for two statements on a line, and the matrix has the three twins whose emit has
chain ...; *in90 = ...on one line(
fk-fixed,fk-fixed2,fk-multifix) asfailed.~/data/sourcerer-loop/requests/ldfit/place/(manifest, 24 cases, README) is the battery: every variant is the base ofits family with one declaration moved to a line that the base keeps blank, so every statement stays on its line.
Cycle program (M, 8 cases):
dcl-s,dcl-c, a four-linedcl-dsand a four-linedcl-prbetween two calculations,dcl-safter the first use (refusal expected),dcl-safter the last calculation, two declarations swapped. Procedure(P, 7 cases): the same kinds local, a local
static. Global between two procedures, before and after the using one(G, 4 cases). The same procedure cases with
option(*srcstmt)(S, 2 cases). Statements on one line (L, 3 cases:two
dcl-s,ctl-optanddcl-s, a wholedcl-ds). The README says how to read each answer: the compile result, theoperations and statement numbers against the base, the symbol list, the static initialization order. The manifest lists
the cases that must compile first (the four bases and the swap), then the unknowns, then the three
l-*cases (refusalexpected, RNF5508), then the three that name a field before its declaration (refusal certain). The batch runner stops at
the first refused compile, so the README says how to rerun the rest into a fresh destination.
Who reads the trailer
rt-stmt-diff.sh(pairs by order when the emit holdsdeclarations do not fit before source line),agree.awk(
declarations do not fit) andemit-families.awk(do not fit before) match a prefix that the new text keeps.reason-audit.shtakes the first failure line that namesstatement N: the old trailer endedstatement numbers move(no digits) and the new one has no
statement, so for the 16 twins whose only failure is the trailer it finds nofailure line either way. The fixture of
tests/rt-stmt-diff.shhas its own text. The header comments ofrt-stmt-diff.shandagree-twins.shstill quote the old tail; they are insean/sourcerer-loop, not here.Proof
src/rpg_decl_fit_test.zig(registered insrc/root.zig):lv-af-evalhreads7: 2 lines missing(red before:Layouthad no count),fk-subphas no trailer and its statements stay on their lines, andLayoutcounts the rises ofthe displacement and not the lines of the displacement itself (5 declaration lines before line 4: 3 missing; the next
statement stays 3 below its line: still 3; a line on its number ends it; a second scope short by 2: 5).
emit-all.shwith the base binary (v0.1.513) and with this branch, on the 826 emitted twins: acmpof every filefinds 28 changed (the 28 above), and
diffof each shows only the lines withdeclarations do not fit. The summaryline is equal (
failures928,emitted8422,clean593). The 854 receipts are equal atstatements,emitted,failures,placeholders,form_counts, the number of lines and the form of each line, so no form moves.capture-emit-diff.shover the 25 public captures with the branch binary of this ship: 25 cases, 7 changed (6 Async,barrettotte), each by its trailer line only, statements, emitted and failures equal in all 25, and no head emit without a
failure line.
emit-bytes-diff.shexits 1 by design and prints the first 20 lines of each diff: the trailer line ofP92F0A341S,PABC59092S,PD55A2B53SandP892E45BCS, and rows of the forms projection that differ intext_sha256only (
form_counts,lines,statements,emittedandfailuresare equal in every row it printed). None of the 28 ismatchin the matrix.asyncprom 56, barrettotte 3, and 26 of the 28 twins agree to the line. The two that differ,
fixed-exsrandws-fixed(the script says 0, the emitter 1), have statement numbers that are not lines.
ship.sh: census 645 / 0 regressions, golden, legend current, emitworseempty, twins and allgroups regressionsempty, unit, full check.
Gate
762994388883a64769f8