The external name of the main procedure #748

Manually merged
binjovi-bot merged 4 commits from lk into trunk 2026-11-07 12:47:38 +00:00
Owner

The external name of the main procedure

Summary (ROUND9)

  • Question: which construct leaves one short unloaded text constant in the
    pool right before a stored literal, on the lv-parm-ds shape.
  • Answer: the external program name of the main procedure when it is not the
    object name (dcl-pr X extpgm('NAME'); dcl-pi X; or dcl-pi *n extpgm('NAME')). The compiler keeps it where dcl-pi *n keeps the module
    name; the run is EBCDIC-sorted, so "right before" is a property of the bytes.
  • Public evidence: calls3 ('BATTERY', no module-name text), every lv-parm-ds
    twin (module-name text with dcl-pi *n), bifs-char, strvar, sub1, lit1 (no PI,
    no such text). Battery lk-pi-name, 21 of 21 compiled, two captures.
  • Rule: rpg_source_scale.externalName; interface() writes dcl-pi *n extpgm('NAME') when the run has no module-name text and exactly one unloaded
    text is shaped as an object name. Otherwise unchanged.
  • Results: red then green on lk-pr-extpgm-upper (src/rpg_pi_name_test.zig);
    pub-roundtrip MATCH on lk-pr-extpgm-upper and lk-base-upper; the oracle's
    target MATCH with the ship BIN (coordinator's hash check); the four other dev
    programs byte-identical; ship gates census 645/0/0, emit worse [], twins
    regressions [], full-check 0. PR #748.
  • Open: the two-candidate selector (an uncalled prototype name or a named
    activation group beside the PI name), lowercase names, and the empty PI
    (lk-pi-empty): recorded below, next change.

rpg_source.zig: the procedure interface of the main procedure carries
extpgm('NAME') when the module keeps NAME as the unloaded program name of
its text run in the place of the module name.

Finding: the text run is sorted

The text constants of a module's run sort in EBCDIC byte order; source order
plays no part. bifs-char: abc < abcdefghij < vary < xy < ABC < 2026-01-01
while the source writes abcdefghij first; calls3: bnddir('QC2LE') on
line 2 sorts last and the last statement literal 'lit' sorts first. A
duplicate literal is one constant (lv-lp-lit-shared). So the position of a
constant is a function of its bytes, and "a constant immediately before a
stored literal" says what its bytes are, not where its construct stands.

Finding: the module-name constant is the PI's external name

Every twin with dcl-pi *n has an unloaded text equal to the module name;
no twin without a PI has one (bifs-char, strvar, sub1, lit1). calls3
(dcl-pr main extpgm('BATTERY'); dcl-pi main;) has unloaded 'BATTERY'
and no module-name text. The lk-pi-name battery confirms it on the
lv-parm-ds shape: dcl-pi *n extpgm('ABC') and the dcl-pr pg extpgm('ABC') + dcl-pi pg pair give the same pool ('ABC' unloaded, no
module name); a bare extpgm keeps the uppercased prototype name
('PG'); extpgm('abc') keeps lowercase bytes; an uncalled dcl-pr callee extpgm('XYZ') adds 'XYZ' beside the module name. The symbol words of a
dcl-c, a literal and this name are the same, so a dcl-c (branch
lv-unused-const) adds the bytes but cannot remove the module-name text that
dcl-pi *n injects: the pool ends one constant over.

Rule (rpg_source_scale.externalName)

For the main procedure's PI only. Walk the text run from runStart. If any
text equals the module name, emit dcl-pi *n; as before. Otherwise the
candidates are the texts that no instruction operand names and that are
shaped as an object name (1 to 10 of A-Z 0-9 $ # @ _, not digit-first).
Exactly one candidate: dcl-pi *n extpgm('NAME'); with the object's bytes.
None, or more than one (calls3: 'BATTERY' and the bnddir 'QC2LE'):
unchanged. The bytes never come from a guess.

Not in this change

  • Lowercase names (lk-pr-extpgm-lower, 'abc'): the shape admits only
    uppercase, the shape of the build that matched; widening it changes the
    candidate set of programs with lowercase unloaded texts.
  • Selecting the PI name beside a second program-name text (an uncalled
    prototype, a bnddir): lk-pi-name-r2 case lk-pi-extpgm-and-callee.

lk-pi-name-r2: what else puts an unloaded text in the run (follow-up record)

The other fourteen cases of the battery, captured after this rule was built;
none changes it. Each row is the run beside the stored 'abcdef' and the
module name.

case run shows consequence for a selector
lk-ctl-actgrp-name actgrp('ABC'): 'ABC' unloaded a named activation group is a program-name-shaped text; actgrp('QILE') beside an extpgm name makes two candidates
lk-ctl-bnddir bnddir('QC2LE'): 'QC2LE' unloaded as calls3
lk-pr-callee-called extpgm('XYZ') called once: 'XYZ' still unloaded a call does not mark the name
lk-pi-extpgm-and-callee 'ABC' and 'XYZ' unloaded, no module name the PI name and an uncalled prototype name are not told apart in the run; the rule refuses (unchanged PI)
lk-pr-extproc-uncalled extproc('fn'): 'fn' unloaded lowercase, outside the shape
lk-ctl-copyright copyright('abc'): 'abc' unloaded lowercase here; an uppercase copyright text of 10 bytes or fewer would be a candidate
lk-inz-nontemplate inz('abc') on the likeds base: 'abc' unloaded in the run, and the padded 28-byte copy loaded by the init code
lk-len-lit %len('xyz'): 'xyz' unloaded the folded literal stays
lk-concat-lit 'abc' + 'def': 'abcdef' loaded, then 'abc', 'def' unloaded
lk-subst-mid %subst('abc': 2: 2): 'bc' loaded, then 'abc' unloaded
lk-trim-lit %trim('abc '): 'abc' loaded, then 'abc ' unloaded
lk-if-fold if 'xyz' = 'xyz': 'xyz' loaded twice not folded
lk-pi-empty dcl-pi *n; end-pi;: the module name is in the run the emitter writes no PI for a main procedure without parameters, so such a program lacks this constant: a separate gap
lk-psds-proc nothing added

Order: the pieces of a folded expression ('abc', 'def', 'abc ') stand
right after their result, not at their sorted place ('abcdef' before
'abc'; 'bc' before 'abc'); the names and the statement literals keep
the EBCDIC order. externalName reads the whole run, so the order does not
touch the rule.

The two-candidate selector is the next change: nothing in the run tells the
PI name from an uncalled prototype name or an activation group name, so it
needs evidence from outside the run or stays a refusal.

Probes

  • lk-pr-extpgm-upper (dictionary capture): 'ABC' unloaded right before
    the stored 'ABCDEF'; the PI gains extpgm('ABC').
  • lk-base-upper (dictionary capture): the run holds the module name; the
    PI stays dcl-pi *n;.

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":2,"newly_clean":3,"clean_delta":3,"base":415,"new":418},"twins":{"groups":651,"recovered":642,"regressions":[],"newly":29},"allgroups":{"regressions":[],"newly":["savf/SC-CONSTRUCT/TLICR/archive.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":631}}
# The external name of the main procedure ## Summary (ROUND9) - Question: which construct leaves one short unloaded text constant in the pool right before a stored literal, on the lv-parm-ds shape. - Answer: the external program name of the main procedure when it is not the object name (`dcl-pr X extpgm('NAME'); dcl-pi X;` or `dcl-pi *n extpgm('NAME')`). The compiler keeps it where `dcl-pi *n` keeps the module name; the run is EBCDIC-sorted, so "right before" is a property of the bytes. - Public evidence: calls3 (`'BATTERY'`, no module-name text), every lv-parm-ds twin (module-name text with `dcl-pi *n`), bifs-char, strvar, sub1, lit1 (no PI, no such text). Battery lk-pi-name, 21 of 21 compiled, two captures. - Rule: `rpg_source_scale.externalName`; `interface()` writes `dcl-pi *n extpgm('NAME')` when the run has no module-name text and exactly one unloaded text is shaped as an object name. Otherwise unchanged. - Results: red then green on `lk-pr-extpgm-upper` (`src/rpg_pi_name_test.zig`); pub-roundtrip MATCH on `lk-pr-extpgm-upper` and `lk-base-upper`; the oracle's target MATCH with the ship BIN (coordinator's hash check); the four other dev programs byte-identical; ship gates census 645/0/0, emit worse [], twins regressions [], full-check 0. PR #748. - Open: the two-candidate selector (an uncalled prototype name or a named activation group beside the PI name), lowercase names, and the empty PI (`lk-pi-empty`): recorded below, next change. `rpg_source.zig`: the procedure interface of the main procedure carries `extpgm('NAME')` when the module keeps NAME as the unloaded program name of its text run in the place of the module name. ## Finding: the text run is sorted The text constants of a module's run sort in EBCDIC byte order; source order plays no part. bifs-char: `abc < abcdefghij < vary < xy < ABC < 2026-01-01` while the source writes `abcdefghij` first; calls3: `bnddir('QC2LE')` on line 2 sorts last and the last statement literal `'lit'` sorts first. A duplicate literal is one constant (lv-lp-lit-shared). So the position of a constant is a function of its bytes, and "a constant immediately before a stored literal" says what its bytes are, not where its construct stands. ## Finding: the module-name constant is the PI's external name Every twin with `dcl-pi *n` has an unloaded text equal to the module name; no twin without a PI has one (bifs-char, strvar, sub1, lit1). calls3 (`dcl-pr main extpgm('BATTERY'); dcl-pi main;`) has unloaded `'BATTERY'` and no module-name text. The lk-pi-name battery confirms it on the lv-parm-ds shape: `dcl-pi *n extpgm('ABC')` and the `dcl-pr pg extpgm('ABC')` + `dcl-pi pg` pair give the same pool (`'ABC'` unloaded, no module name); a bare `extpgm` keeps the uppercased prototype name (`'PG'`); `extpgm('abc')` keeps lowercase bytes; an uncalled `dcl-pr callee extpgm('XYZ')` adds `'XYZ'` beside the module name. The symbol words of a `dcl-c`, a literal and this name are the same, so a `dcl-c` (branch lv-unused-const) adds the bytes but cannot remove the module-name text that `dcl-pi *n` injects: the pool ends one constant over. ## Rule (`rpg_source_scale.externalName`) For the main procedure's PI only. Walk the text run from `runStart`. If any text equals the module name, emit `dcl-pi *n;` as before. Otherwise the candidates are the texts that no instruction operand names and that are shaped as an object name (1 to 10 of `A-Z 0-9 $ # @ _`, not digit-first). Exactly one candidate: `dcl-pi *n extpgm('NAME');` with the object's bytes. None, or more than one (calls3: `'BATTERY'` and the bnddir `'QC2LE'`): unchanged. The bytes never come from a guess. ## Not in this change - Lowercase names (`lk-pr-extpgm-lower`, `'abc'`): the shape admits only uppercase, the shape of the build that matched; widening it changes the candidate set of programs with lowercase unloaded texts. - Selecting the PI name beside a second program-name text (an uncalled prototype, a bnddir): lk-pi-name-r2 case `lk-pi-extpgm-and-callee`. ## lk-pi-name-r2: what else puts an unloaded text in the run (follow-up record) The other fourteen cases of the battery, captured after this rule was built; none changes it. Each row is the run beside the stored `'abcdef'` and the module name. | case | run shows | consequence for a selector | |---|---|---| | `lk-ctl-actgrp-name` | `actgrp('ABC')`: `'ABC'` unloaded | a named activation group is a program-name-shaped text; `actgrp('QILE')` beside an `extpgm` name makes two candidates | | `lk-ctl-bnddir` | `bnddir('QC2LE')`: `'QC2LE'` unloaded | as calls3 | | `lk-pr-callee-called` | `extpgm('XYZ')` called once: `'XYZ'` still unloaded | a call does not mark the name | | `lk-pi-extpgm-and-callee` | `'ABC'` and `'XYZ'` unloaded, no module name | the PI name and an uncalled prototype name are not told apart in the run; the rule refuses (unchanged PI) | | `lk-pr-extproc-uncalled` | `extproc('fn')`: `'fn'` unloaded | lowercase, outside the shape | | `lk-ctl-copyright` | `copyright('abc')`: `'abc'` unloaded | lowercase here; an uppercase copyright text of 10 bytes or fewer would be a candidate | | `lk-inz-nontemplate` | `inz('abc')` on the likeds base: `'abc'` unloaded in the run, and the padded 28-byte copy loaded by the init code | | | `lk-len-lit` | `%len('xyz')`: `'xyz'` unloaded | the folded literal stays | | `lk-concat-lit` | `'abc' + 'def'`: `'abcdef'` loaded, then `'abc'`, `'def'` unloaded | | | `lk-subst-mid` | `%subst('abc': 2: 2)`: `'bc'` loaded, then `'abc'` unloaded | | | `lk-trim-lit` | `%trim('abc ')`: `'abc'` loaded, then `'abc '` unloaded | | | `lk-if-fold` | `if 'xyz' = 'xyz'`: `'xyz'` loaded twice | not folded | | `lk-pi-empty` | `dcl-pi *n; end-pi;`: the module name is in the run | the emitter writes no PI for a main procedure without parameters, so such a program lacks this constant: a separate gap | | `lk-psds-proc` | nothing added | | Order: the pieces of a folded expression (`'abc'`, `'def'`, `'abc '`) stand right after their result, not at their sorted place (`'abcdef'` before `'abc'`; `'bc'` before `'abc'`); the names and the statement literals keep the EBCDIC order. `externalName` reads the whole run, so the order does not touch the rule. The two-candidate selector is the next change: nothing in the run tells the PI name from an uncalled prototype name or an activation group name, so it needs evidence from outside the run or stays a refusal. ## Probes - `lk-pr-extpgm-upper` (dictionary capture): `'ABC'` unloaded right before the stored `'ABCDEF'`; the PI gains `extpgm('ABC')`. - `lk-base-upper` (dictionary capture): the run holds the module name; the PI stays `dcl-pi *n;`. ## 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":2,"newly_clean":3,"clean_delta":3,"base":415,"new":418},"twins":{"groups":651,"recovered":642,"regressions":[],"newly":29},"allgroups":{"regressions":[],"newly":["savf/SC-CONSTRUCT/TLICR/archive.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":631}} ```
The text run of a module sorts in EBCDIC order; the unloaded text in the
module name's place is the external program name of the main procedure
(calls3, lk-pi-name). When the run has no module-name text and exactly one
unloaded text is shaped as an object name, the PI is
dcl-pi *n extpgm('NAME') with the object's bytes; otherwise unchanged.
Regenerate the operations legend
All checks were successful
binjovi/ci Binjovi completed the frozen plan
4c25f8f171
sean changed title from rpg_source.zig: the PI of the main procedure carries the external name the module keeps to The external name of the main procedure 2026-11-07 12:38:30 +00:00
docs/changes/lk.md: the ROUND9 summary of the external-name rule
All checks were successful
binjovi/ci Binjovi completed the frozen plan
0d2408b644
binjovi-bot manually merged commit 19291edd99 into trunk 2026-11-07 12:47:38 +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!748
No description provided.