Skip to content

Commit d12197c

Browse files
committed
Use Ada 2022 delta aggregate.
1 parent 60431b6 commit d12197c

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
@@ -1151,15 +1151,13 @@ package body Templates_Parser is
11511151
else
11521152
T.Data.Last.Next := Item;
11531153
T.Data.all :=
1154-
(T.Data.Count + 1,
1155-
Min => Natural'Min (T.Data.Min, 1),
1156-
Max => Natural'Max (T.Data.Max, 1),
1157-
Nested_Level => T.Data.Nested_Level,
1158-
Separator => T.Data.Separator,
1159-
Head => T.Data.Head,
1160-
Last => Item,
1161-
Tag_Nodes => null,
1162-
Values => null);
1154+
(@ with delta
1155+
Count => @.Count + 1,
1156+
Min => Natural'Min (@.Min, 1),
1157+
Max => Natural'Max (@.Max, 1),
1158+
Last => Item,
1159+
Tag_Nodes => null,
1160+
Values => null);
11631161

11641162
return (Ada.Finalization.Controlled with T.Ref_Count, Data => T.Data);
11651163
end if;
@@ -1191,15 +1189,13 @@ package body Templates_Parser is
11911189

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

12041200
return (Ada.Finalization.Controlled with T.Ref_Count, T.Data);
12051201
end if;
@@ -1232,17 +1228,16 @@ package body Templates_Parser is
12321228
T.Data.Last.Next := Item;
12331229

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

12471242
return (Ada.Finalization.Controlled with T.Ref_Count, T.Data);
12481243
end if;
@@ -1425,11 +1420,14 @@ package body Templates_Parser is
14251420
end if;
14261421

14271422
Unchecked_Free (T.Data.Tag_Nodes);
1428-
T.Data.Tag_Nodes := null;
1429-
T.Data.Count := T.Data.Count + 1;
1430-
T.Data.Min := Natural'Min (T.Data.Min, T_Size);
1431-
T.Data.Max := Natural'Max (T.Data.Max, T_Size);
1432-
T.Data.Last := Item;
1423+
1424+
T.Data.all :=
1425+
(@ with delta
1426+
Count => @.Count + 1,
1427+
Tag_Nodes => null,
1428+
Min => Natural'Min (@.Min, T_Size),
1429+
Max => Natural'Max (@.Max, T_Size),
1430+
Last => Item);
14331431
end Append;
14341432

14351433
procedure Append (T : in out Tag; Value : Unbounded_String) is
@@ -1446,11 +1444,14 @@ package body Templates_Parser is
14461444
end if;
14471445

14481446
Unchecked_Free (T.Data.Tag_Nodes);
1449-
T.Data.Tag_Nodes := null;
1450-
T.Data.Count := T.Data.Count + 1;
1451-
T.Data.Min := Natural'Min (T.Data.Min, 1);
1452-
T.Data.Max := Natural'Max (T.Data.Max, 1);
1453-
T.Data.Last := Item;
1447+
1448+
T.Data.all :=
1449+
(@ with delta
1450+
Count => @.Count + 1,
1451+
Tag_Nodes => null,
1452+
Min => Natural'Min (@.Min, 1),
1453+
Max => Natural'Max (@.Max, 1),
1454+
Last => Item);
14541455
end Append;
14551456

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

54235410
---------------------------
@@ -5952,20 +5939,16 @@ package body Templates_Parser is
59525939
end if;
59535940

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

59705953
-- Align_On attribute present
59715954

@@ -6063,37 +6046,21 @@ package body Templates_Parser is
60636046

60646047
Analyze
60656048
(Block.Common,
6066-
Parse_State'(State.F_Params'Length,
6067-
New_Cursor,
6068-
State.Max_Lines, State.Max_Expand,
6069-
State.Reverse_Index,
6070-
State.Table_Level,
6071-
State.Inline_Sep,
6072-
State.Filename,
6073-
Block.Line,
6074-
State.Blocks_Count,
6075-
State.I_Params,
6076-
State.F_Params,
6077-
Empty_Block_State,
6078-
State.Terse_Table,
6079-
L_State'Unchecked_Access));
6049+
Parse_State'
6050+
(State with delta
6051+
Cursor => New_Cursor,
6052+
Line => Block.Line,
6053+
Block => Empty_Block_State,
6054+
Parent => L_State'Unchecked_Access));
60806055

60816056
Analyze
60826057
(Block.Sections,
6083-
Parse_State'(State.F_Params'Length,
6084-
New_Cursor,
6085-
State.Max_Lines, State.Max_Expand,
6086-
State.Reverse_Index,
6087-
State.Table_Level,
6088-
State.Inline_Sep,
6089-
State.Filename,
6090-
Block.Line,
6091-
State.Blocks_Count,
6092-
State.I_Params,
6093-
State.F_Params,
6094-
B_State (B),
6095-
State.Terse_Table,
6096-
L_State'Unchecked_Access));
6058+
Parse_State'
6059+
(State with delta
6060+
Cursor => New_Cursor,
6061+
Line => Block.Line,
6062+
Block => B_State (B),
6063+
Parent => L_State'Unchecked_Access));
60976064

60986065
Block := @.Next;
60996066
B := @ + 1;
@@ -6109,20 +6076,9 @@ package body Templates_Parser is
61096076
when Section_Stmt =>
61106077
Analyze
61116078
(State.Block.Section.Next,
6112-
Parse_State'(State.F_Params'Length,
6113-
State.Cursor,
6114-
State.Max_Lines, State.Max_Expand,
6115-
State.Reverse_Index,
6116-
State.Table_Level,
6117-
State.Inline_Sep,
6118-
State.Filename,
6119-
T.Line,
6120-
State.Blocks_Count,
6121-
State.I_Params,
6122-
State.F_Params,
6123-
State.Block,
6124-
State.Terse_Table,
6125-
L_State'Unchecked_Access));
6079+
Parse_State'(State with delta
6080+
Line => T.Line,
6081+
Parent => L_State'Unchecked_Access));
61266082

61276083
when Include_Stmt =>
61286084
Analyze (T.I_Included);
@@ -6137,21 +6093,10 @@ package body Templates_Parser is
61376093
Start_Pos := Length (Results) + 1;
61386094

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

61566101
Flush;
61576102
End_Pos := Length (Results);

0 commit comments

Comments
 (0)