rpg_range.zig, rpg_trim.zig, rpg_eval.zig and rpg_eval_builtins.zig: the guards of %LEFT, %RIGHT and %SUBST with a variable start own their labels (operation 15) #764

Manually merged
binjovi-bot merged 2 commits from lo15b into trunk 2026-11-08 15:05:22 +00:00
Owner

rpg_range.zig, rpg_trim.zig, rpg_eval.zig and rpg_eval_builtins.zig: the guards of %LEFT, %RIGHT and %SUBST with a variable start own their labels (operation 15)

Three built-ins of a character field keep guards that stop the statement at
control_flow / operation_semantics on the first label definition (operation 15),
which no value rewriter read.

  • %LEFT and %RIGHT with a constant length (S = %left(C : 3),
    h-bifs-char G14 / source 29 and G15 / 30). The compiler keeps the zero tests of
    the field length and of the requested length, both constants that the unit
    itself stored, so neither jump is taken. rpg_range.unit proves the constants
    (0 < K <= LEN = length of C), the two jumps, their two label definitions
    (only those jumps go to them) and the typed copy with its blank fill, and
    reads the whole as %SUBST(C: 1: K) (%LEFT) or %SUBST(C: LEN - K + 1: K)
    (%RIGHT), the operation op_subst_const. The text is the substring because the
    object does not distinguish %LEFT(C : K) from %SUBST(C : 1 : K), and the emitter
    already writes a substring. A first version left the copy to the raw rules and
    produced S = C, which pads all of C: wrong text that compiles. The copy is
    now part of the unit.
  • %SUBST(C : I) with a variable start (h-bifs-char G8 / 23). rpg_trim.substVar
    reads the range check of the start (error 100 outside 1..LEN, the signal of the
    status), the address and the length of the rest, then the copy of the bytes on
    the stack to the field (copyTail, new mode onstack). The start stays on the
    stack and op_subst_var shows %SUBST(C: start).

rpg_eval.zig takes one hook line; the value is rpg_eval_builtins.substConst.

Red tests (G header of the dump / source statement)

Recovered: h-bifs-char G8 / 23, G14 / 29, G15 / 30 (src/rpg_lo15_labels_test.zig).

Not done: r5e-editc-held G6 / 12, %dec(%subst(out7 : pos : 3) : 3 : 0)

The statement has the same start check, then a second check of the end
(start - 1 + 3 against the field length) and the call
_QRNX_GET_DECIMAL_NUM on the substring. The checks are the same shape as
substVar, but the consumer is the decimal-call reader (rpg_decimal_call.zig),
which reads ADDRESS(F.K, N) with constant offset K and has no source at a
variable start. A unit in this lane's files cannot finish the statement; the
change is in rpg_decimal_call.zig: accept the substring value of the
variable start as the source of the conversion.

# rpg_range.zig, rpg_trim.zig, rpg_eval.zig and rpg_eval_builtins.zig: the guards of %LEFT, %RIGHT and %SUBST with a variable start own their labels (operation 15) Three built-ins of a character field keep guards that stop the statement at control_flow / operation_semantics on the first label definition (operation 15), which no value rewriter read. - **%LEFT and %RIGHT with a constant length** (`S = %left(C : 3)`, h-bifs-char G14 / source 29 and G15 / 30). The compiler keeps the zero tests of the field length and of the requested length, both constants that the unit itself stored, so neither jump is taken. `rpg_range.unit` proves the constants (0 < K <= LEN = length of C), the two jumps, their two label definitions (only those jumps go to them) and the typed copy with its blank fill, and reads the whole as `%SUBST(C: 1: K)` (`%LEFT`) or `%SUBST(C: LEN - K + 1: K)` (`%RIGHT`), the operation `op_subst_const`. The text is the substring because the object does not distinguish %LEFT(C : K) from %SUBST(C : 1 : K), and the emitter already writes a substring. A first version left the copy to the raw rules and produced `S = C`, which pads all of C: wrong text that compiles. The copy is now part of the unit. - **%SUBST(C : I) with a variable start** (h-bifs-char G8 / 23). `rpg_trim.substVar` reads the range check of the start (error 100 outside 1..LEN, the signal of the status), the address and the length of the rest, then the copy of the bytes on the stack to the field (`copyTail`, new mode `onstack`). The start stays on the stack and `op_subst_var` shows `%SUBST(C: start)`. `rpg_eval.zig` takes one hook line; the value is `rpg_eval_builtins.substConst`. ## Red tests (G header of the dump / source statement) Recovered: h-bifs-char G8 / 23, G14 / 29, G15 / 30 (`src/rpg_lo15_labels_test.zig`). ## Not done: r5e-editc-held G6 / 12, `%dec(%subst(out7 : pos : 3) : 3 : 0)` The statement has the same start check, then a second check of the end (`start - 1 + 3` against the field length) and the call `_QRNX_GET_DECIMAL_NUM` on the substring. The checks are the same shape as `substVar`, but the consumer is the decimal-call reader (`rpg_decimal_call.zig`), which reads `ADDRESS(F.K, N)` with constant offset K and has no source at a variable start. A unit in this lane's files cannot finish the statement; the change is in `rpg_decimal_call.zig`: accept the substring value of the variable start as the source of the conversion.
binjovi-bot manually merged commit 6f7cfa8b8f into trunk 2026-11-08 15:05:22 +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!764
No description provided.