rpg_source.zig, rpg_eval.zig: read SORTA of an array or of %SUBARR and %LOOKUP of a packed array #797
Loading…
Reference in a new issue
No description provided.
Delete branch "lsrt"
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.zig, rpg_eval.zig: read SORTA of an array or of %SUBARR and %LOOKUP of a packed array
SORTA a;,SORTA(D) a;,SORTA %SUBARR(a: 1: 5);,SORTA %SUBARR(a: 1: n);,SORTA %SUBARR(a: s);andp = %LOOKUP(x: a),%LOOKUP(x: a: s),%LOOKUP(x: a: s: n)were
? unresolved statement. Two rewrite units (rpg_sorta.zig,rpg_lookup.zig, in the chain ofrpg_value_units.zig) prove the whole operation family of the statement and become one operation each(
op_sort0x7f000030,op_lookup0x7f000031).rpg_sort_value.zig(the twosteparms ofrpg_eval.zig)reads the names the unit cannot (the helper, the signalling procedure), writes the line, and gives the
emitter the array (
array_element_v1: dimension and element width), sodcl-s a packed(5:0) dim(10);comes with the statement. The families are written as text (
rpg_unit_pattern.zig:34 AR 0; 35 TP; ...,a capital name is a slot that every later place must repeat), so the measurement is the pattern. A shape
that differs in any operation or operand reads nothing and the statement keeps its failure.
Emitter (the only edits of
rpg_source*.zig, ten lines, no more were needed to print the statement):rpg_source.zighas a head arm forSORTAandSORTA(D)(formemit_sorta_v1inrpg_source_forms.zig;noCalculationRulenames SORTA) and%SUBARR,%LOOKUPin its list of built-in functions.Measured (SC-ILE/EXPERIMENTS lsrt-sorta-, lsrt-lookup-; a packed(5) dim(10), c char(5) dim(10))
SORTA calls a helper procedure of the module,
_QRNI_SORT_{A|D}_<name of the array of the source>(
_QRNI_SORT_A_Asortsa,_QRNI_SORT_A_Csortsc,_QRNI_SORT_D_Asortsadescending: the objectkeeps the source name of the array in the name of the helper, a name the emitter does not use yet; one
helper for each SORTA statement, 89 operations): a shell sort of the array symbol AR with the element
type TE. SORTA and SORTA(D) are the same
statement operation for operation; only the one comparison in the helper differs (
12ascending,10descending), so the unit reads the helper (
102 H; 106 x3; 103 x5; ... 32 AR 0 TE; CMP; 17 0; ... 101 H)and the name must agree with the comparison. The call has five arguments: the address of the first
element, the count, three null pointers (
99 H 5 0 0).34 AR 0; 113 6 2; 35 TP; 27 TP; 27 CN; 27 NU x3; 99 H 5 0 0(CN = dimension)sorta a;sorta(d) a;27 NU; 35 TP; 27 ST; 75 8; 27 ONE; 52; 75 4; 35 S0; 27 CT; 75 8; 75 4; 35 TC; 34 AR 0; 27 S0; 65 W; 35 TP; 27 TC; 35 S0; 27 TP; 27 TC; 77 4; 27 NU x3; 99 H 5 0 0sorta %SUBARR(a: 1: 5);29 N 0 TN; 87 8; 75 8; 27 DIM; 27 S0; 52; 35 MX; 1; 35 CV; 27 CV; 27 MX; 75 8; 12; 16 L1; 27 CV; 27 ONE2; 10; 17 L2; 15 L1 2; 27 ER; 35 54; 99 SG 0 0 0; 15 L2 2; 75 4; 35 TC;and the address (ER = 121)sorta %SUBARR(a: 1: n);(c:char(5) dim(10))27 NU; 35 TP; 29 S 0 TS; 87 8; 75 8; 1; 35 CV; 27 CV; 27 DIM; 12; 16 L1; 27 CV; 27 ONE2; 10; 17 L2; 15 L1 2; 27 ER; 35 54; 99 SG 0 0 0; 15 L2 2; 27 ONE; 52; 75 4; 35 S0; 27 DIM2; 27 S0; 52; 35 TC;then the addresssorta %SUBARR(a: s);%LOOKUP has no call. The compiler writes a loop: TS the first index, TE the last, TP the array address, TV the
search value (
27 KV; 61 5 0 0; 35 TV), TI the result (0 when not found), the equality7:27 TS; 27 TE; 9; 17 LNF; 27 TS; 77 4; 35 TI; 15 LL 2; 27 TV; 27 TP; 27 TI; 27 ONE; 52; 65 W; 32 AR 0 ET; 7; 17 LF; 27 TI; 27 ONE; 47; 1; 35 TI; 78 4; 27 TE; 9; 16 LL; 15 LX 2; 15 LNF 2; 27 Z2; 35 TI; 18 LEND; 15 LF 2; 15 LEND 2; 27 TI(42 operations with the head), then the field store76 8; 88 20; 61 5 0 0; 37 P 0 TP.27 K1; 35 TS; 27 DIM; 35 TE; 34 AR 0; 35 TP; 27 KV; 61 5 0 0; 35 TV(start 1, end = dimension)p = %LOOKUP(4: a);29 S 0 TT; 35 TV; 27 TV; 27 K1; 86 5; 10; 16 LE; 27 TV; 27 DIM; 86 5; 12; 16 LE; 18 LOK; 15 LE 1; 27 ER; 35 54; 99 SG 0 0 0; 15 LOK 1; 27 TV; 87 8; 75 4; 35 TS; 27 DIM; 35 TE; 34 AR 0; 35 TP;and the search value (TV is the start, then the value)%LOOKUP(4: a: s)27 DIM; 27 TS; 52; 27 ONE; 78 4; 47; 35 TE; 29 N 0 TN; 35 TC; 27 TC; 27 Z1; 86 63; 10; 16 LE2; 27 TC; 27 TE; 86 63; 12; 16 LE2; 18 LOK2; 15 LE2 1; 27 ER; 35 54; 99 SG 0 0 0; 15 LOK2 1; 27 TC; 87 8; 75 4; 27 TS; 27 ONE; 78 4; 52; 47; 35 TE;(the count is checked 0 to the elements left, TE = TS + N - 1)%LOOKUP(4: a: s: n)34 253 0; 27 OFF; 62before the unit (the address ofa(2), OFF = 3), and32 SA 0 TS2; 61 5 0 0; 35 TVfor the value%LOOKUP(a(2): a: s)Proved before a unit reads: the helper body and its array, direction and element type (packed or character);
the dimension (the length of the array over the element width: the constant form of %SUBARR holds no
dimension constant, so for it that is the whole proof), the element width and the constants (1, 0, 121, the
dimension; the start of a %SUBARR is the constant 1, no other start is measured; the literal count is 1 to
the dimension); the element of a %LOOKUP is an element of the array it searches (the only measured case);
the null pointers; the packed fields and their types; the temporaries are
compiler temporaries that no other operation names; the labels are defined once, inside the unit, and
jumped to only from inside it; the digits of the rescale and of the checked temporaries; the names of the
helper (
_QRNI_SORT_{A|D}_and a name, the letter agrees with the comparison) and of the signallingprocedure (
_QRNI_SOFT_ERR). A changed operation, a changed operand of any of them (all but thesignalling procedure, which the evaluator proves by its name), a stray reader of a temporary, a start other
than 1, an element of another array and another comparison refuse, in
src/rpg_lsrt_test.zig.Effect
The ten battery statements read (
agree.sh: same 61 to 75, suspect 2 to 2, wrong parameters 0,emit-lint0 findings); none of the ten emits is free of failure lines, because statements 9, 10 and 13 of the probes
(an array element assignment,
%CHAR,%CHAR(a(1))) are other work. Development programs, reported as fit(no rule or test holds their text): p3 5 failure lines to 3 (its two
SORTA %SUBARR(array: 1: count)read),p4 6 to 4 (its two SORTA read); the
%LOOKUPof p4 (a search value that is an element of another arrayat a variable index) matches the three-argument unit and is refused where the value is read, because the
battery has no such element: the request
requests/lsrt/sorta2holds it, and 23 more shapes (a variable,literal or expression start, a literal count, a character, zoned and integer array, %LOOKUPGT, LT, GE and LE
of an ASCEND array, a variable start and count and a literal start of 2 in %SUBARR, SORTA(D) of a character
array; a shape that keeps the measured family, as SORTA(D) of a character array does, would already read).
Probes adopted (matrix rows, none host-matching yet): lsrt-sorta-all, lsrt-sorta-desc,
lsrt-sorta-subarr-lit, lsrt-sorta-subarr-n, lsrt-sorta-subarr-s, lsrt-sorta-char, lsrt-lookup-2,
lsrt-lookup-3, lsrt-lookup-4, lsrt-lookup-elem. docs/OPERATIONS.md is regenerated (
ops-legend.sh --write).Gates
Two rewrite units prove the whole operation family of the statement (rpg_sorta.zig: the helper procedure _QRNI_SORT_{A|D}_<array>, its comparison and the %SUBARR start and count with their status 121 checks; rpg_lookup.zig: the inline search loop with two, three or four arguments and a constant or element search value). rpg_sort_value.zig reads the names, writes the line and tells the emitter the array. The families are written as text in rpg_unit_pattern.zig. The emitter prints SORTA and knows %SUBARR and %LOOKUP.6260f66082db5007bdbddb5007bdbd536c21a579