rpg_eval_builtins.zig and rpg_source.zig: date, time and timestamp subfields of a data structure, and %DIFF of the current time and of subfields #765

Manually merged
binjovi-bot merged 6 commits from ld into trunk 2026-11-08 16:57:57 +00:00
Owner

rpg_eval_builtins.zig and rpg_source.zig: a date, time or timestamp subfield of a data structure is typed from the descriptors at its offset

ds.b = %date(); ds.a = ds.b + %days(1); (twin lr3x-ds-step-first) and ds.a = %timestamp(); ds.a = ds.a + %hours(1); (lr3x-ds-ts-first) failed: the step was an unresolved statement and the store was refused because the subfield was declared as characters (lr3c). Both emit now with date and timestamp subfields.

  • rpg_date_add.zig: a step whose date is a subfield of a data structure. The compiler pushes the address of the subfield (33 S; 27 K; 62, or 33 S at byte 0) before the count, with one swap instead of two. Add carries the byte offset; dateStep writes the part (S253.0 = S253.10 + %DAYS(1)).
  • rpg_date_fields.zig: the stack simulation handles op 62 and keys a descriptor by (symbol, offset). A field of its own keeps its rule; a descriptor inside a longer structure is a part.
  • rpg_source.zig typeDateParts: a part of the default ISO form (date, time, timestamp) in a structure that starts blank is declared as that type; the target of a step takes the type of the subfield it steps from. charNow no longer wraps %CHAR around a store into such a part.
  • Unchanged on purpose: a structure with other start bytes keeps its failure (lr3x-date-char-in-ds: the inz character subfield and the date subfield cannot both be declared from one char(N) start value). Non-ISO formats of a subfield (*USA, *JIS and the others) stay failures.
  • rpg_array_element.prefixOf s04 is a scan probe on the 33 S; 27 K; 62 shape; it is not changed.
  • Tests: src/rpg_ld_test.zig.

Battery ld-dt-1 (24 cases, captures/ld-dt-1)

  • %DIFF(%TIME(): t: *UNIT) (dateDifferenceCall s13, the generic arm required a 10- or 26-byte field) recovers for an 8-byte time field into int(10) and packed(9:0); probes ld-dt-now-time-sec-int, -min-int, -hrs-int, -sec-pk.
  • A date, time or timestamp subfield start value in the ISO form is a literal (temporalStart), and a subfield that only a date call names gets its width from the format.
  • dateResult s07 is not printed by any of the 24 cases.
  • %DIFF with a subfield operand (33 S; 27 K; 62 or 34 S K with K not 0), and with the field first and the saved current time second (operandDifference): the widths are those of the two format descriptors, a subfield is a part typed from them, and the start bytes of the structure become the inz of its typed subfields. Probes ld-dt-ds-diff-date-q, -time-q, -time-unq, -ts-q, ld-dt-now-time-rev, ld-dt-ds-add-days.
  • Refused on purpose: %DIFF(%DATE(): ds.b) (ds-diff-now-date): the compiler pushes the 62 address ahead of the saved time whatever the source order, so the order of the operands is not proved.
  • Open: ds-add-months (the target of the step is read as a one-subfield structure; later lane), ds-sub-days-unq (dateStep s03), ds-now-* (no descriptor names the subfield: a correct refusal).

Qualified or not (round trip of lr3x-ds-step-first and lr3x-ds-ts-first, 2026-11-08)

The first emit declared the structure unqualified with flat names; the objects differed. The address-first form (33 S or 33 S; 27 K; 62) is the signature of a qualified structure (lv-af-qual), and 34 S K that of an unqualified one. rpg_date_fields.zig records the form of the descriptor addresses of each structure (address_first); rpg_source.zig marks the structure qualified in that case (e.qualified), so it is declared dcl-ds NAME qualified; with subfields named NAME.Fk. A structure reached both ways has no typed subfields. lr3x-ds-ts-first declares its unused n int(10) as char(4): the object carries no type for a subfield that no statement names, so that line is left as it is.

# rpg_eval_builtins.zig and rpg_source.zig: a date, time or timestamp subfield of a data structure is typed from the descriptors at its offset `ds.b = %date(); ds.a = ds.b + %days(1);` (twin `lr3x-ds-step-first`) and `ds.a = %timestamp(); ds.a = ds.a + %hours(1);` (`lr3x-ds-ts-first`) failed: the step was an unresolved statement and the store was refused because the subfield was declared as characters (lr3c). Both emit now with `date` and `timestamp` subfields. - `rpg_date_add.zig`: a step whose date is a subfield of a data structure. The compiler pushes the address of the subfield (`33 S; 27 K; 62`, or `33 S` at byte 0) before the count, with one swap instead of two. `Add` carries the byte offset; `dateStep` writes the part (`S253.0 = S253.10 + %DAYS(1)`). - `rpg_date_fields.zig`: the stack simulation handles op 62 and keys a descriptor by (symbol, offset). A field of its own keeps its rule; a descriptor inside a longer structure is a part. - `rpg_source.zig typeDateParts`: a part of the default ISO form (date, time, timestamp) in a structure that starts blank is declared as that type; the target of a step takes the type of the subfield it steps from. `charNow` no longer wraps `%CHAR` around a store into such a part. - Unchanged on purpose: a structure with other start bytes keeps its failure (`lr3x-date-char-in-ds`: the `inz` character subfield and the date subfield cannot both be declared from one `char(N)` start value). Non-ISO formats of a subfield (`*USA`, `*JIS` and the others) stay failures. - `rpg_array_element.prefixOf s04` is a scan probe on the `33 S; 27 K; 62` shape; it is not changed. - Tests: `src/rpg_ld_test.zig`. ## Battery ld-dt-1 (24 cases, captures/ld-dt-1) - `%DIFF(%TIME(): t: *UNIT)` (`dateDifferenceCall s13`, the generic arm required a 10- or 26-byte field) recovers for an 8-byte time field into `int(10)` and `packed(9:0)`; probes `ld-dt-now-time-sec-int`, `-min-int`, `-hrs-int`, `-sec-pk`. - A date, time or timestamp subfield start value in the ISO form is a literal (`temporalStart`), and a subfield that only a date call names gets its width from the format. - `dateResult s07` is not printed by any of the 24 cases. - `%DIFF` with a subfield operand (`33 S; 27 K; 62` or `34 S K` with K not 0), and with the field first and the saved current time second (`operandDifference`): the widths are those of the two format descriptors, a subfield is a part typed from them, and the start bytes of the structure become the `inz` of its typed subfields. Probes `ld-dt-ds-diff-date-q`, `-time-q`, `-time-unq`, `-ts-q`, `ld-dt-now-time-rev`, `ld-dt-ds-add-days`. - Refused on purpose: `%DIFF(%DATE(): ds.b)` (`ds-diff-now-date`): the compiler pushes the `62` address ahead of the saved time whatever the source order, so the order of the operands is not proved. - Open: `ds-add-months` (the target of the step is read as a one-subfield structure; later lane), `ds-sub-days-unq` (`dateStep s03`), `ds-now-*` (no descriptor names the subfield: a correct refusal). ## Qualified or not (round trip of lr3x-ds-step-first and lr3x-ds-ts-first, 2026-11-08) The first emit declared the structure unqualified with flat names; the objects differed. The address-first form (`33 S` or `33 S; 27 K; 62`) is the signature of a qualified structure (lv-af-qual), and `34 S K` that of an unqualified one. `rpg_date_fields.zig` records the form of the descriptor addresses of each structure (`address_first`); `rpg_source.zig` marks the structure qualified in that case (`e.qualified`), so it is declared `dcl-ds NAME qualified;` with subfields named `NAME.Fk`. A structure reached both ways has no typed subfields. `lr3x-ds-ts-first` declares its unused `n int(10)` as `char(4)`: the object carries no type for a subfield that no statement names, so that line is left as it is.
sean force-pushed ld from ef8fb3d104
All checks were successful
binjovi/ci Binjovi completed the frozen plan
to 5eabab23d2
All checks were successful
binjovi/ci Binjovi completed the frozen plan
2026-11-08 16:47:38 +00:00
Compare
binjovi-bot manually merged commit 5eabab23d2 into trunk 2026-11-08 16:57:57 +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!765
No description provided.