rpg_decimal_call.zig, rpg_subst_offset.zig, rpg_trim.zig, rpg_eval.zig, rpg_eval_builtins.zig and rpg_facts.zig: %DEC of a %SUBST with a variable start #766

Manually merged
binjovi-bot merged 4 commits from lo15c into trunk 2026-11-08 15:52:24 +00:00
Owner

rpg_decimal_call.zig, rpg_subst_offset.zig, rpg_trim.zig, rpg_eval.zig, rpg_eval_builtins.zig and rpg_facts.zig: %DEC of a %SUBST with a variable start

part = %dec(%subst(out7 : pos : 3) : 3 : 0) (SC-ILE/EXPERIMENTS
r5e-editc-held, G6 of the dump, source statement 12) stopped at control_flow /
operation_semantics on operation 15: the range checks of the substring keep four
labels, and rpg_subst_offset reads a literal start only.

  • rpg_subst_offset.recoverVariable reads the 44 operations of the unit: the
    check of the start (1 .. LEN, error 100), start - 1 + COUNT, the check of
    the end (0 .. LEN) and the address operation 62, for a character field F, a
    constant COUNT with 0 < COUNT <= LEN and temporaries of the procedure.
  • rpg_trim.substCount rewrites the unit, the 113 and the load of the length
    to op_subst_var (operands F and COUNT; the start stays on the stack, the
    value is %SUBST(F: start: COUNT)), the 113 and the load of COUNT.
  • rpg_decimal_call.recoverFrom takes this unit as the source of the
    _QRNX_GET_DECIMAL_NUM call (variableSource): the length argument is the
    temporary that the unit wrote, the four labels have no other jump and no label
    pointer, the fact range starts at the unit. The fact has variable_start; its
    text writes ADDRESS(A254.START, 3) and not a byte offset that is not known.
    isTextSource replaces the two tests of %TRIM( in builtinCall (the source
    is the text of a unit).

Result: S255 = %DEC(%SUBST(S254: S256: 3): 3: 0), emitted as
A_00255 = %DEC(%SUBST(A_00254: A_00256: 3): 3: 0);. The red test is
r5e-editc-held G6 / 12 in src/rpg_lo15_labels_test.zig.

%LEN of a varying-length field is shown as the length

Since v0.1.466 h-bifs-char statement 37, I = %len(V) with V varchar(20), was
shown as S259 = S267 and emitted as A_00259 = V00267;: the load of the two
length bytes pushed the name of the field, and the program is then not the
source (the h-bifs-char twin did not compile, RNF7416). The length check that
follows the load (error 115 above the size less two) is the proof that the two
bytes are the length of a varying-length field. rpg_eval.varyingCheck now
rewrites the value of the load on the stack, in the saved copies and in the record
of the length to %LEN(F) once it has proved the check
(varyingLengthShown). Without the check the text stays as before. The
red test is h-bifs-char G22 / 37 (src/rpg_lo15_labels_test.zig).

# rpg_decimal_call.zig, rpg_subst_offset.zig, rpg_trim.zig, rpg_eval.zig, rpg_eval_builtins.zig and rpg_facts.zig: %DEC of a %SUBST with a variable start `part = %dec(%subst(out7 : pos : 3) : 3 : 0)` (SC-ILE/EXPERIMENTS r5e-editc-held, G6 of the dump, source statement 12) stopped at control_flow / operation_semantics on operation 15: the range checks of the substring keep four labels, and `rpg_subst_offset` reads a literal start only. - `rpg_subst_offset.recoverVariable` reads the 44 operations of the unit: the check of the start (1 .. LEN, error 100), `start - 1 + COUNT`, the check of the end (0 .. LEN) and the address operation 62, for a character field F, a constant COUNT with 0 < COUNT <= LEN and temporaries of the procedure. - `rpg_trim.substCount` rewrites the unit, the `113` and the load of the length to `op_subst_var` (operands F and COUNT; the start stays on the stack, the value is `%SUBST(F: start: COUNT)`), the `113` and the load of COUNT. - `rpg_decimal_call.recoverFrom` takes this unit as the source of the `_QRNX_GET_DECIMAL_NUM` call (`variableSource`): the length argument is the temporary that the unit wrote, the four labels have no other jump and no label pointer, the fact range starts at the unit. The fact has `variable_start`; its text writes `ADDRESS(A254.START, 3)` and not a byte offset that is not known. `isTextSource` replaces the two tests of `%TRIM(` in `builtinCall` (the source is the text of a unit). Result: `S255 = %DEC(%SUBST(S254: S256: 3): 3: 0)`, emitted as `A_00255 = %DEC(%SUBST(A_00254: A_00256: 3): 3: 0);`. The red test is r5e-editc-held G6 / 12 in `src/rpg_lo15_labels_test.zig`. ## %LEN of a varying-length field is shown as the length Since v0.1.466 h-bifs-char statement 37, `I = %len(V)` with `V varchar(20)`, was shown as `S259 = S267` and emitted as `A_00259 = V00267;`: the load of the two length bytes pushed the name of the field, and the program is then not the source (the h-bifs-char twin did not compile, RNF7416). The length check that follows the load (error 115 above the size less two) is the proof that the two bytes are the length of a varying-length field. `rpg_eval.varyingCheck` now rewrites the value of the load on the stack, in the saved copies and in the record of the length to `%LEN(F)` once it has proved the check (`varyingLengthShown`). Without the check the text stays as before. The red test is h-bifs-char G22 / 37 (`src/rpg_lo15_labels_test.zig`).
binjovi-bot manually merged commit c7dec05551 into trunk 2026-11-08 15:52:24 +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!766
No description provided.