Skip to content

Commit 32768c9

Browse files
committed
Use Ada 2022 delta aggregate.
1 parent c2d389d commit 32768c9

File tree

1 file changed

+70
-125
lines changed

1 file changed

+70
-125
lines changed

src/templates_parser.adb

Lines changed: 70 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,15 +1149,13 @@ package body Templates_Parser is
11491149
else
11501150
T.Data.Last.Next := Item;
11511151
T.Data.all :=
1152-
(T.Data.Count + 1,
1153-
Min => Natural'Min (T.Data.Min, 1),
1154-
Max => Natural'Max (T.Data.Max, 1),
1155-
Nested_Level => T.Data.Nested_Level,
1156-
Separator => T.Data.Separator,
1157-
Head => T.Data.Head,
1158-
Last => Item,
1159-
Tag_Nodes => null,
1160-
Values => null);
1152+
(@ with delta
1153+
Count => @.Count + 1,
1154+
Min => Natural'Min (@.Min, 1),
1155+
Max => Natural'Max (@.Max, 1),
1156+
Last => Item,
1157+
Tag_Nodes => null,
1158+
Values => null);
11611159

11621160
return (Ada.Finalization.Controlled with T.Ref_Count, Data => T.Data);
11631161
end if;
@@ -1189,15 +1187,13 @@ package body Templates_Parser is
11891187

11901188
else
11911189
T.Data.all :=
1192-
(T.Data.Count + 1,
1193-
Min => Natural'Min (T.Data.Min, 1),
1194-
Max => Natural'Max (T.Data.Max, 1),
1195-
Nested_Level => T.Data.Nested_Level,
1196-
Separator => T.Data.Separator,
1197-
Head => Item,
1198-
Last => T.Data.Last,
1199-
Tag_Nodes => null,
1200-
Values => null);
1190+
(@ with delta
1191+
Count => @.Count + 1,
1192+
Min => Natural'Min (@.Min, 1),
1193+
Max => Natural'Max (@.Max, 1),
1194+
Head => Item,
1195+
Tag_Nodes => null,
1196+
Values => null);
12011197

12021198
return (Ada.Finalization.Controlled with T.Ref_Count, T.Data);
12031199
end if;
@@ -1230,17 +1226,16 @@ package body Templates_Parser is
12301226
T.Data.Last.Next := Item;
12311227

12321228
T.Data.all :=
1233-
(T.Data.Count + 1,
1234-
Min => Natural'Min (T.Data.Min, T_Size),
1235-
Max => Natural'Max (T.Data.Max, T_Size),
1236-
Nested_Level =>
1237-
Positive'Max
1238-
(T.Data.Nested_Level, Value.Data.Nested_Level + 1),
1239-
Separator => T.Data.Separator,
1240-
Head => T.Data.Head,
1241-
Last => Item,
1242-
Tag_Nodes => null,
1243-
Values => null);
1229+
(@ with delta
1230+
Count => @.Count + 1,
1231+
Min => Natural'Min (@.Min, T_Size),
1232+
Max => Natural'Max (@.Max, T_Size),
1233+
Nested_Level =>
1234+
Positive'Max
1235+
(T.Data.Nested_Level, Value.Data.Nested_Level + 1),
1236+
Last => Item,
1237+
Tag_Nodes => null,
1238+
Values => null);
12441239

12451240
return (Ada.Finalization.Controlled with T.Ref_Count, T.Data);
12461241
end if;
@@ -1423,11 +1418,14 @@ package body Templates_Parser is
14231418
end if;
14241419

14251420
Unchecked_Free (T.Data.Tag_Nodes);
1426-
T.Data.Tag_Nodes := null;
1427-
T.Data.Count := T.Data.Count + 1;
1428-
T.Data.Min := Natural'Min (T.Data.Min, T_Size);
1429-
T.Data.Max := Natural'Max (T.Data.Max, T_Size);
1430-
T.Data.Last := Item;
1421+
1422+
T.Data.all :=
1423+
(@ with delta
1424+
Count => @.Count + 1,
1425+
Tag_Nodes => null,
1426+
Min => Natural'Min (@.Min, T_Size),
1427+
Max => Natural'Max (@.Max, T_Size),
1428+
Last => Item);
14311429
end Append;
14321430

14331431
procedure Append (T : in out Tag; Value : Unbounded_String) is
@@ -1444,11 +1442,14 @@ package body Templates_Parser is
14441442
end if;
14451443

14461444
Unchecked_Free (T.Data.Tag_Nodes);
1447-
T.Data.Tag_Nodes := null;
1448-
T.Data.Count := T.Data.Count + 1;
1449-
T.Data.Min := Natural'Min (T.Data.Min, 1);
1450-
T.Data.Max := Natural'Max (T.Data.Max, 1);
1451-
T.Data.Last := Item;
1445+
1446+
T.Data.all :=
1447+
(@ with delta
1448+
Count => @.Count + 1,
1449+
Tag_Nodes => null,
1450+
Min => Natural'Min (@.Min, 1),
1451+
Max => Natural'Max (@.Max, 1),
1452+
Last => Item);
14521453
end Append;
14531454

14541455
procedure Append (T : in out Tag; Value : String) is
@@ -5401,21 +5402,7 @@ package body Templates_Parser is
54015402
function NS
54025403
(State : Parse_State; Line : Natural) return Parse_State is
54035404
begin
5404-
return (Parse_State'(State.P_Size,
5405-
State.Cursor,
5406-
State.Max_Lines,
5407-
State.Max_Expand,
5408-
State.Reverse_Index,
5409-
State.Table_Level,
5410-
State.Inline_Sep,
5411-
State.Filename,
5412-
Line,
5413-
State.Blocks_Count,
5414-
State.I_Params,
5415-
State.F_Params,
5416-
State.Block,
5417-
State.Terse_Table,
5418-
State.Parent));
5405+
return (Parse_State'(State with delta Line => Line));
54195406
end NS;
54205407

54215408
---------------------------
@@ -5950,20 +5937,16 @@ package body Templates_Parser is
59505937
end if;
59515938

59525939
Analyze (T.Blocks,
5953-
Parse_State'(State.F_Params'Length,
5954-
State.Cursor,
5955-
Max_Lines, Max_Expand,
5956-
T.Reverse_Index,
5957-
State.Table_Level + 1,
5958-
State.Inline_Sep,
5959-
State.Filename,
5960-
T.Line,
5961-
T.Blocks_Count,
5962-
State.I_Params,
5963-
State.F_Params,
5964-
Empty_Block_State,
5965-
T.Terse,
5966-
L_State'Unchecked_Access));
5940+
Parse_State'(State with delta
5941+
Max_Lines => Max_Lines,
5942+
Max_Expand => Max_Expand,
5943+
Reverse_Index => T.Reverse_Index,
5944+
Table_Level => State.Table_Level + 1,
5945+
Line => T.Line,
5946+
Blocks_Count => T.Blocks_Count,
5947+
Block => Empty_Block_State,
5948+
Terse_Table => T.Terse,
5949+
Parent => L_State'Unchecked_Access));
59675950

59685951
-- Align_On attribute present
59695952

@@ -6061,37 +6044,21 @@ package body Templates_Parser is
60616044

60626045
Analyze
60636046
(Block.Common,
6064-
Parse_State'(State.F_Params'Length,
6065-
New_Cursor,
6066-
State.Max_Lines, State.Max_Expand,
6067-
State.Reverse_Index,
6068-
State.Table_Level,
6069-
State.Inline_Sep,
6070-
State.Filename,
6071-
Block.Line,
6072-
State.Blocks_Count,
6073-
State.I_Params,
6074-
State.F_Params,
6075-
Empty_Block_State,
6076-
State.Terse_Table,
6077-
L_State'Unchecked_Access));
6047+
Parse_State'
6048+
(State with delta
6049+
Cursor => New_Cursor,
6050+
Line => Block.Line,
6051+
Block => Empty_Block_State,
6052+
Parent => L_State'Unchecked_Access));
60786053

60796054
Analyze
60806055
(Block.Sections,
6081-
Parse_State'(State.F_Params'Length,
6082-
New_Cursor,
6083-
State.Max_Lines, State.Max_Expand,
6084-
State.Reverse_Index,
6085-
State.Table_Level,
6086-
State.Inline_Sep,
6087-
State.Filename,
6088-
Block.Line,
6089-
State.Blocks_Count,
6090-
State.I_Params,
6091-
State.F_Params,
6092-
B_State (B),
6093-
State.Terse_Table,
6094-
L_State'Unchecked_Access));
6056+
Parse_State'
6057+
(State with delta
6058+
Cursor => New_Cursor,
6059+
Line => Block.Line,
6060+
Block => B_State (B),
6061+
Parent => L_State'Unchecked_Access));
60956062

60966063
Block := @.Next;
60976064
B := @ + 1;
@@ -6107,20 +6074,9 @@ package body Templates_Parser is
61076074
when Section_Stmt =>
61086075
Analyze
61096076
(State.Block.Section.Next,
6110-
Parse_State'(State.F_Params'Length,
6111-
State.Cursor,
6112-
State.Max_Lines, State.Max_Expand,
6113-
State.Reverse_Index,
6114-
State.Table_Level,
6115-
State.Inline_Sep,
6116-
State.Filename,
6117-
T.Line,
6118-
State.Blocks_Count,
6119-
State.I_Params,
6120-
State.F_Params,
6121-
State.Block,
6122-
State.Terse_Table,
6123-
L_State'Unchecked_Access));
6077+
Parse_State'(State with delta
6078+
Line => T.Line,
6079+
Parent => L_State'Unchecked_Access));
61246080

61256081
when Include_Stmt =>
61266082
Analyze (T.I_Included);
@@ -6135,21 +6091,10 @@ package body Templates_Parser is
61356091
Start_Pos := Length (Results) + 1;
61366092

61376093
Analyze (T.I_Block,
6138-
Parse_State'(State.F_Params'Length,
6139-
Cursor => State.Cursor,
6140-
Max_Lines => State.Max_Lines,
6141-
Max_Expand => State.Max_Expand,
6142-
Reverse_Index => State.Reverse_Index,
6143-
Table_Level => State.Table_Level,
6144-
Inline_Sep => T.Sep,
6145-
Filename => State.Filename,
6146-
Line => T.Line,
6147-
Blocks_Count => State.Blocks_Count,
6148-
I_Params => State.I_Params,
6149-
F_Params => State.F_Params,
6150-
Block => State.Block,
6151-
Terse_Table => State.Terse_Table,
6152-
Parent => L_State'Unchecked_Access));
6094+
Parse_State'(State with delta
6095+
Inline_Sep => T.Sep,
6096+
Line => T.Line,
6097+
Parent => L_State'Unchecked_Access));
61536098

61546099
Flush;
61556100
End_Pos := Length (Results);

0 commit comments

Comments
 (0)