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
Loading…
Reference in a new issue
No description provided.
Delete branch "ld"
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_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);(twinlr3x-ds-step-first) andds.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 withdateandtimestampsubfields.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, or33 Sat byte 0) before the count, with one swap instead of two.Addcarries the byte offset;dateStepwrites 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.charNowno longer wraps%CHARaround a store into such a part.lr3x-date-char-in-ds: theinzcharacter subfield and the date subfield cannot both be declared from onechar(N)start value). Non-ISO formats of a subfield (*USA,*JISand the others) stay failures.rpg_array_element.prefixOf s04is a scan probe on the33 S; 27 K; 62shape; it is not changed.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 intoint(10)andpacked(9:0); probesld-dt-now-time-sec-int,-min-int,-hrs-int,-sec-pk.temporalStart), and a subfield that only a date call names gets its width from the format.dateResult s07is not printed by any of the 24 cases.%DIFFwith a subfield operand (33 S; 27 K; 62or34 S Kwith 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 theinzof its typed subfields. Probesld-dt-ds-diff-date-q,-time-q,-time-unq,-ts-q,ld-dt-now-time-rev,ld-dt-ds-add-days.%DIFF(%DATE(): ds.b)(ds-diff-now-date): the compiler pushes the62address ahead of the saved time whatever the source order, so the order of the operands is not proved.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 Sor33 S; 27 K; 62) is the signature of a qualified structure (lv-af-qual), and34 S Kthat of an unqualified one.rpg_date_fields.zigrecords the form of the descriptor addresses of each structure (address_first);rpg_source.zigmarks the structure qualified in that case (e.qualified), so it is declareddcl-ds NAME qualified;with subfields namedNAME.Fk. A structure reached both ways has no typed subfields.lr3x-ds-ts-firstdeclares its unusedn int(10)aschar(4): the object carries no type for a subfield that no statement names, so that line is left as it is.ef8fb3d1045eabab23d2