rpg_source.zig (with rpg_export.zig, rpg_frames.zig, rpg_end.zig): an export procedure is written like a local one, plus export #784

Manually merged
binjovi-bot merged 2 commits from lexp into trunk 2026-11-11 03:39:18 +00:00
Owner

Since v0.1.500 an export procedure is read as a procedure (Module.isCycleMain),
but the emitter refused its dcl-proc line, its parameters, its locals and its
END-PROC, and never wrote the keyword. The change writes it from two object
facts and keeps a failure line whenever the two do not agree.

What proves export (measured)

Two facts of the object. They agree on every procedure of the public data, so the
data does not say which one is the cause; the emitter asks for both.

  1. The symbol class of the procedure symbol: class 1 with a symbol other than 1
    (symbol 1 of class 1 is the cycle main). A local procedure is class 3.
  2. A row of the export table of the module binding structure (module header
    +0x28, then +0x10; rpg_export.zig): the row holds the number of a row of the
    procedure table, and that row holds the procedure symbol (+112) and the name
    (+108). The export name equals the name of the row.

Crosstab over every procedure of the ILE RPG objects among the 1684 public
stripped objects (the committed twins and the captures, some objects counted
twice; an object is RPG when it has a _QRNP_PEP_ procedure: 1607 objects, all
programs, no RPG module or service program):

procedure count row in the export table
class 1, symbol other than 1 (export) 175 175
class 3 or class 4 5847 0
class 1, symbol 1 (the cycle main) 1504 1445 (the 59 others have no binding structure: AddressOutsideSections)

The same holds in the C and CL objects of the data (143 class 1 procedures other
than symbol 1, 143 rows), which the emitter does not read.

The cycle main is in the table too, under the name of the module, so a row alone
does not prove export: the cycle main is not written as dcl-proc at all.
The pair lsel-loc-if / lsel-exp-if (and -sel) differs in exactly these two
facts and in the text: the sibling procedure is class 3 with no row, the exported
one class 1 with one row (outline.json: exports is empty against
TARGET procedure 3).

Emitter.isSubprocedure (rpg_source.zig) now reads: a class 3 procedure with no
export row, or a class 1 procedure that is not the cycle main and has an export
row. A class 3 procedure with a row (not observed) and a class 1 procedure with no
row (not observed, or the table does not read) are not subprocedures: their
DCL-PROC keeps the failure line, because a clean emit would drop export or
invent it. The keyword is written in dcl-proc NAME export;, also on the
dcl-proc of a failure line.

The readers of a procedure frame took class 3 only

The emitter was not the only reader. Module.isSubprocedure (class 3, or class 1
that is not the cycle main) now stands where a reader asked for the class of the
procedure it recovers: rpg_frames.procedure (parameters, return value, a call to
the procedure: the RUNPROBE call of TARGET was ? unresolved statement),
rpg_calls.oneParameter, rpg_end.procedureExitTransfer and rpg_end.guard (the
procedure end: END-PROC and RETURN were partial), rpg_init_layout,
rpg_ccsid_init and rpg_cycle_template.linearPrologue (the initialisation of
the frame). Class 3 and the cycle main read as before; the 886 committed twins
emit byte for byte what they emitted (emit-all.sh, base against head, the six
adopted twins included), except the seven twins that hold an exported procedure:
lsel-exp-if, lsel-exp-sel, lsel-for-arr-if-if and the four adopted below
(lext-export-cycle-p, lext-export-main-p, lsel-cx-if, lsel-cx-sel).

Counter (capture-emit-diff, base ~/bin/sourcerer v0.1.500, head this change)

Statements / emitted / failure lines, summed over the group:

group cases statements emitted before -> after failures before -> after
lsel-exp-* 9 93 23 -> 93 79 -> 9
lsel-cx-* (cycle main + export) 2 24 9 -> 24 15 -> 0
lext-export-* 3 17 8 -> 17 11 -> 2
six Async captures 6 3659 1357 -> 1953 2345 -> 1762
lsel-for-arr-if-* 2 59 26 -> 39 37 -> 26

Free of failure lines now: lsel-cx-if, lsel-cx-sel, lext-export-cycle-p.
Each lsel-exp-* case and lext-export-main-* keeps exactly one failure line,
compiler statement 2100000001 is partial, which its local sibling
(lsel-loc-if, lsel-loc-sel) has too: a main() module gap, not the export.
The text of an exported twin equals the text of its local sibling with
export; taken off the dcl-proc (a test, lsel-exp-if against lsel-loc-if,
lsel-exp-sel against lsel-loc-sel).

Read against source.rpgle: all new lines of the 9 lsel-exp-*, the 2
lsel-cx-* and the 3 lext-export-* cases agree with their sources (names are
placeholders; r += 1 is written A = A + 1; inz(0) is not written, as for
the local siblings). Of the six Async programs the dcl-proc and dcl-pi of the
26 exported procedures were compared with the source by script, and the bodies of
the 26 exported procedures of l10-async-asyncage were read; the other five
programs were not read in full. Newly emitted lines that disagree with the source:

  • Async_Run second parameter arg pointer value options(*nopass) is written
    int(10) options(*nopass) in 4 programs, Async_Return first parameter
    data pointer value is written int(10) in 1 program (no marker). The local
    procedures do the same in the base emit (sleepFor: arg pointer value is
    int(10); startThread: likeds(TMPL...)): a parameter-type rule, not the
    export.
  • Async_ThrowIfCanceled: the empty dcl-pi *n; end-pi; is not written (benign).
  • Every other mismatch of a parameter or return type is in a procedure that
    carries a failure line or a SOURCERER-TODO placeholder (an array parameter
    dim() const options(*varsize) written uns(10) or char(16384), a missing
    return type on the dcl-proc line, a varchar const). Async_Then's local
    known ind is written char(1) inz('0') (not compared with a local procedure).

No Async program is free of failure lines. The emit of a non-exported procedure
changes only where it calls an exported one: a failure line (? unresolved statement, CALLP ... partial) becomes the call text (Async_Sleep(10);,
A = Async_Await(...)), or the line before the call now resolves; 27 of 151 local
procedures of the six programs change so, and no line of theirs that was written
before changes.

Seen, not changed

  • The readers rpg_display.recover, rpg_display_numeric and
    rpg_output_spec still take raw class 1 as "the main". No public case has a
    DSPLY or an output specification in an export procedure.
  • An array parameter dim() const options(*varsize) is written char(40) or
    uns(10), with a parameter_type TODO in the Async programs.
  • In lsel-for-arr-if-if the store to a subfield of a likeds parameter is still
    written as an assignment to the whole parameter (the known item of lane Lsel).
  • A call to a procedure that is defined later in the source, with no dcl-pr, is
    written as the object holds it (A = TARGET(A);); the local siblings do the
    same. Whether RPG accepts it is for the round trip.

Not determined

  • An export procedure of a nomain module or a service program: no capture. The
    rule is measured on programs (*PGM) only.
  • Which of the two facts is the cause: no object has one without the other.
  • export(extname) is not in the data.

Tests: src/rpg_export_proc_test.zig. Adopted twins: lsel-cx-if, lsel-cx-sel,
lext-export-cycle-p, lext-export-main-p, lsel-loc-if, lsel-loc-sel.

Release gate (coordinator, build of e33c6631 against v0.1.500)

  • Ship row e33c6631: all gates passed (census 645/0, twins regressions none, emit worse none).
  • Development emits: byte-identical. L10-test direction: rose.
  • Committed twins at v0.1.500 (emit-bytes-diff.sh): only lsel-exp-if, lsel-exp-sel and lsel-for-arr-if-if change, the three with an exported procedure.
  • 66 public captures (capture-emit-diff.sh): 22 change, none with fewer emitted statements or more failures. The number of dcl-proc NAME export lines never exceeds the source's, and every exported procedure of a source is either written with the keyword or keeps its failure line.
  • Host round trips with this build, 11 of 11 match: lsel-cx-if, lsel-cx-sel (a cycle main and an export procedure), lext-export-cycle-p, lext-export-main-p, lext-export-main-c, lsel-exp-if, lsel-exp-sel, lsel-exp-if-thr, lsel-exp-ifelse, lsel-exp-pi-if, lsel-loc-if. At v0.1.500 lsel-exp-if and lsel-exp-sel were different.
  • Known and not from this change: on the public Async captures a pointer parameter passed by value is written int(10) without a failure line (the same rule writes local procedures); those programs still carry failure lines and do not compile. It is the next change, with the store to a subfield of a likeds parameter.
Since v0.1.500 an `export` procedure is read as a procedure (`Module.isCycleMain`), but the emitter refused its `dcl-proc` line, its parameters, its locals and its `END-PROC`, and never wrote the keyword. The change writes it from two object facts and keeps a failure line whenever the two do not agree. ## What proves `export` (measured) Two facts of the object. They agree on every procedure of the public data, so the data does not say which one is the cause; the emitter asks for both. 1. The symbol class of the procedure symbol: class 1 with a symbol other than 1 (symbol 1 of class 1 is the cycle main). A local procedure is class 3. 2. A row of the export table of the module binding structure (module header +0x28, then +0x10; `rpg_export.zig`): the row holds the number of a row of the procedure table, and that row holds the procedure symbol (+112) and the name (+108). The export name equals the name of the row. Crosstab over every procedure of the ILE RPG objects among the 1684 public stripped objects (the committed twins and the captures, some objects counted twice; an object is RPG when it has a `_QRNP_PEP_` procedure: 1607 objects, all programs, no RPG module or service program): | procedure | count | row in the export table | |---|---|---| | class 1, symbol other than 1 (`export`) | 175 | 175 | | class 3 or class 4 | 5847 | 0 | | class 1, symbol 1 (the cycle main) | 1504 | 1445 (the 59 others have no binding structure: `AddressOutsideSections`) | The same holds in the C and CL objects of the data (143 class 1 procedures other than symbol 1, 143 rows), which the emitter does not read. The cycle main is in the table too, under the name of the module, so a row alone does not prove `export`: the cycle main is not written as `dcl-proc` at all. The pair `lsel-loc-if` / `lsel-exp-if` (and `-sel`) differs in exactly these two facts and in the text: the sibling procedure is class 3 with no row, the exported one class 1 with one row (`outline.json`: `exports` is empty against `TARGET procedure 3`). `Emitter.isSubprocedure` (`rpg_source.zig`) now reads: a class 3 procedure with no export row, or a class 1 procedure that is not the cycle main and has an export row. A class 3 procedure with a row (not observed) and a class 1 procedure with no row (not observed, or the table does not read) are not subprocedures: their `DCL-PROC` keeps the failure line, because a clean emit would drop `export` or invent it. The keyword is written in `dcl-proc NAME export;`, also on the `dcl-proc` of a failure line. ## The readers of a procedure frame took class 3 only The emitter was not the only reader. `Module.isSubprocedure` (class 3, or class 1 that is not the cycle main) now stands where a reader asked for the class of the procedure it recovers: `rpg_frames.procedure` (parameters, return value, a call to the procedure: the `RUNPROBE` call of `TARGET` was `? unresolved statement`), `rpg_calls.oneParameter`, `rpg_end.procedureExitTransfer` and `rpg_end.guard` (the procedure end: `END-PROC` and `RETURN` were partial), `rpg_init_layout`, `rpg_ccsid_init` and `rpg_cycle_template.linearPrologue` (the initialisation of the frame). Class 3 and the cycle main read as before; the 886 committed twins emit byte for byte what they emitted (`emit-all.sh`, base against head, the six adopted twins included), except the seven twins that hold an exported procedure: `lsel-exp-if`, `lsel-exp-sel`, `lsel-for-arr-if-if` and the four adopted below (`lext-export-cycle-p`, `lext-export-main-p`, `lsel-cx-if`, `lsel-cx-sel`). ## Counter (capture-emit-diff, base `~/bin/sourcerer` v0.1.500, head this change) Statements / emitted / failure lines, summed over the group: | group | cases | statements | emitted before -> after | failures before -> after | |---|---|---|---|---| | `lsel-exp-*` | 9 | 93 | 23 -> 93 | 79 -> 9 | | `lsel-cx-*` (cycle main + export) | 2 | 24 | 9 -> 24 | 15 -> 0 | | `lext-export-*` | 3 | 17 | 8 -> 17 | 11 -> 2 | | six Async captures | 6 | 3659 | 1357 -> 1953 | 2345 -> 1762 | | `lsel-for-arr-if-*` | 2 | 59 | 26 -> 39 | 37 -> 26 | Free of failure lines now: `lsel-cx-if`, `lsel-cx-sel`, `lext-export-cycle-p`. Each `lsel-exp-*` case and `lext-export-main-*` keeps exactly one failure line, `compiler statement 2100000001 is partial`, which its local sibling (`lsel-loc-if`, `lsel-loc-sel`) has too: a `main()` module gap, not the export. The text of an exported twin equals the text of its local sibling with ` export;` taken off the `dcl-proc` (a test, `lsel-exp-if` against `lsel-loc-if`, `lsel-exp-sel` against `lsel-loc-sel`). Read against `source.rpgle`: all new lines of the 9 `lsel-exp-*`, the 2 `lsel-cx-*` and the 3 `lext-export-*` cases agree with their sources (names are placeholders; `r += 1` is written `A = A + 1`; `inz(0)` is not written, as for the local siblings). Of the six Async programs the `dcl-proc` and `dcl-pi` of the 26 exported procedures were compared with the source by script, and the bodies of the 26 exported procedures of `l10-async-asyncage` were read; the other five programs were not read in full. Newly emitted lines that disagree with the source: - `Async_Run` second parameter `arg pointer value options(*nopass)` is written `int(10) options(*nopass)` in 4 programs, `Async_Return` first parameter `data pointer value` is written `int(10)` in 1 program (no marker). The local procedures do the same in the base emit (`sleepFor`: `arg pointer value` is `int(10)`; `startThread`: `likeds(TMPL...)`): a parameter-type rule, not the export. - `Async_ThrowIfCanceled`: the empty `dcl-pi *n; end-pi;` is not written (benign). - Every other mismatch of a parameter or return type is in a procedure that carries a failure line or a `SOURCERER-TODO` placeholder (an array parameter `dim() const options(*varsize)` written `uns(10)` or `char(16384)`, a missing return type on the `dcl-proc` line, a varchar `const`). `Async_Then`'s local `known ind` is written `char(1) inz('0')` (not compared with a local procedure). No Async program is free of failure lines. The emit of a non-exported procedure changes only where it calls an exported one: a failure line (`? unresolved statement`, `CALLP ... partial`) becomes the call text (`Async_Sleep(10);`, `A = Async_Await(...)`), or the line before the call now resolves; 27 of 151 local procedures of the six programs change so, and no line of theirs that was written before changes. ## Seen, not changed - The readers `rpg_display.recover`, `rpg_display_numeric` and `rpg_output_spec` still take raw class 1 as "the main". No public case has a DSPLY or an output specification in an export procedure. - An array parameter `dim() const options(*varsize)` is written `char(40)` or `uns(10)`, with a `parameter_type` TODO in the Async programs. - In `lsel-for-arr-if-if` the store to a subfield of a `likeds` parameter is still written as an assignment to the whole parameter (the known item of lane Lsel). - A call to a procedure that is defined later in the source, with no `dcl-pr`, is written as the object holds it (`A = TARGET(A);`); the local siblings do the same. Whether RPG accepts it is for the round trip. ## Not determined - An `export` procedure of a `nomain` module or a service program: no capture. The rule is measured on programs (`*PGM`) only. - Which of the two facts is the cause: no object has one without the other. - `export(extname)` is not in the data. Tests: `src/rpg_export_proc_test.zig`. Adopted twins: `lsel-cx-if`, `lsel-cx-sel`, `lext-export-cycle-p`, `lext-export-main-p`, `lsel-loc-if`, `lsel-loc-sel`. ## Release gate (coordinator, build of e33c6631 against v0.1.500) - Ship row e33c6631: all gates passed (census 645/0, twins regressions none, emit worse none). - Development emits: byte-identical. L10-test direction: rose. - Committed twins at v0.1.500 (`emit-bytes-diff.sh`): only `lsel-exp-if`, `lsel-exp-sel` and `lsel-for-arr-if-if` change, the three with an exported procedure. - 66 public captures (`capture-emit-diff.sh`): 22 change, none with fewer emitted statements or more failures. The number of `dcl-proc NAME export` lines never exceeds the source's, and every exported procedure of a source is either written with the keyword or keeps its failure line. - Host round trips with this build, 11 of 11 `match`: `lsel-cx-if`, `lsel-cx-sel` (a cycle main and an `export` procedure), `lext-export-cycle-p`, `lext-export-main-p`, `lext-export-main-c`, `lsel-exp-if`, `lsel-exp-sel`, `lsel-exp-if-thr`, `lsel-exp-ifelse`, `lsel-exp-pi-if`, `lsel-loc-if`. At v0.1.500 `lsel-exp-if` and `lsel-exp-sel` were `different`. - Known and not from this change: on the public Async captures a pointer parameter passed by value is written `int(10)` without a failure line (the same rule writes local procedures); those programs still carry failure lines and do not compile. It is the next change, with the store to a subfield of a `likeds` parameter.
An export procedure is class 1 with a symbol other than 1, and the export table of the
module binding structure has a row for it. The emitter writes `dcl-proc NAME export;`
only when both facts hold, and keeps the DCL-PROC failure line when they disagree.
The readers of a procedure frame (parameters, return value, a call, the procedure
end, the frame initialisation) take an export procedure as they take a class 3 one.
Regenerate the operations legend
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
e33c6631ba
sean force-pushed lexp from e33c6631ba
Some checks reported errors
binjovi/ci A newer source or plan superseded this Build
to 6e4fe40326
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-11 03:28:47 +00:00
Compare
binjovi-bot manually merged commit 6e4fe40326 into trunk 2026-11-11 03:39:18 +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!784
No description provided.