The external name of the main procedure #748
Loading…
Reference in a new issue
No description provided.
Delete branch "lk"
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?
The external name of the main procedure
Summary (ROUND9)
pool right before a stored literal, on the lv-parm-ds shape.
object name (
dcl-pr X extpgm('NAME'); dcl-pi X;ordcl-pi *n extpgm('NAME')). The compiler keeps it wheredcl-pi *nkeeps the modulename; the run is EBCDIC-sorted, so "right before" is a property of the bytes.
'BATTERY', no module-name text), every lv-parm-dstwin (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.
rpg_source_scale.externalName;interface()writesdcl-pi *n extpgm('NAME')when the run has no module-name text and exactly one unloadedtext is shaped as an object name. Otherwise unchanged.
lk-pr-extpgm-upper(src/rpg_pi_name_test.zig);pub-roundtrip MATCH on
lk-pr-extpgm-upperandlk-base-upper; the oracle'starget 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.
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 carriesextpgm('NAME')when the module keeps NAME as the unloaded program name ofits 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-01while the source writes
abcdefghijfirst; calls3:bnddir('QC2LE')online 2 sorts last and the last statement literal
'lit'sorts first. Aduplicate 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 *nhas 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 thedcl-pr pg extpgm('ABC')+dcl-pi pgpair give the same pool ('ABC'unloaded, nomodule name); a bare
extpgmkeeps the uppercased prototype name(
'PG');extpgm('abc')keeps lowercase bytes; an uncalleddcl-pr callee extpgm('XYZ')adds'XYZ'beside the module name. The symbol words of adcl-c, a literal and this name are the same, so adcl-c(branchlv-unused-const) adds the bytes but cannot remove the module-name text that
dcl-pi *ninjects: 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 anytext equals the module name, emit
dcl-pi *n;as before. Otherwise thecandidates 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
lk-pr-extpgm-lower,'abc'): the shape admits onlyuppercase, the shape of the build that matched; widening it changes the
candidate set of programs with lowercase unloaded texts.
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 themodule name.
lk-ctl-actgrp-nameactgrp('ABC'):'ABC'unloadedactgrp('QILE')beside anextpgmname makes two candidateslk-ctl-bnddirbnddir('QC2LE'):'QC2LE'unloadedlk-pr-callee-calledextpgm('XYZ')called once:'XYZ'still unloadedlk-pi-extpgm-and-callee'ABC'and'XYZ'unloaded, no module namelk-pr-extproc-uncalledextproc('fn'):'fn'unloadedlk-ctl-copyrightcopyright('abc'):'abc'unloadedlk-inz-nontemplateinz('abc')on the likeds base:'abc'unloaded in the run, and the padded 28-byte copy loaded by the init codelk-len-lit%len('xyz'):'xyz'unloadedlk-concat-lit'abc' + 'def':'abcdef'loaded, then'abc','def'unloadedlk-subst-mid%subst('abc': 2: 2):'bc'loaded, then'abc'unloadedlk-trim-lit%trim('abc '):'abc'loaded, then'abc 'unloadedlk-if-foldif 'xyz' = 'xyz':'xyz'loaded twicelk-pi-emptydcl-pi *n; end-pi;: the module name is in the runlk-psds-procOrder: the pieces of a folded expression (
'abc','def','abc ') standright after their result, not at their sorted place (
'abcdef'before'abc';'bc'before'abc'); the names and the statement literals keepthe EBCDIC order.
externalNamereads the whole run, so the order does nottouch 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 beforethe stored
'ABCDEF'; the PI gainsextpgm('ABC').lk-base-upper(dictionary capture): the run holds the module name; thePI stays
dcl-pi *n;.Gates
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.rpg_source.zig: the PI of the main procedure carries the external name the module keepsto The external name of the main procedure