aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/nodes_gc.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2017-11-11 08:48:28 +0100
committerTristan Gingold <tgingold@free.fr>2017-11-11 08:48:28 +0100
commite8a21ffe5226aad4970bd1facd4a3464a4b436f1 (patch)
tree6dabc27375bc31dbd435d50a98dc223fa4145ac2 /src/vhdl/nodes_gc.adb
parent9a90393e30827308ec6cd834963f5359158115a0 (diff)
downloadghdl-e8a21ffe5226aad4970bd1facd4a3464a4b436f1.tar.gz
ghdl-e8a21ffe5226aad4970bd1facd4a3464a4b436f1.tar.bz2
ghdl-e8a21ffe5226aad4970bd1facd4a3464a4b436f1.zip
Rework list implementation, use iterator.
Diffstat (limited to 'src/vhdl/nodes_gc.adb')
-rw-r--r--src/vhdl/nodes_gc.adb27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/vhdl/nodes_gc.adb b/src/vhdl/nodes_gc.adb
index 89da35c4e..b4c11149f 100644
--- a/src/vhdl/nodes_gc.adb
+++ b/src/vhdl/nodes_gc.adb
@@ -62,17 +62,17 @@ package body Nodes_GC is
procedure Mark_Iir_List (N : Iir_List)
is
- El : Iir;
+ It : List_Iterator;
begin
case N is
when Null_Iir_List
| Iir_List_All =>
null;
when others =>
- for I in Natural loop
- El := Get_Nth_Element (N, I);
- exit when El = Null_Iir;
- Mark_Iir (El);
+ It := List_Iterate (N);
+ while Is_Valid (It) loop
+ Mark_Iir (Get_Element (It));
+ Next (It);
end loop;
end case;
end Mark_Iir_List;
@@ -80,18 +80,20 @@ package body Nodes_GC is
procedure Mark_Iir_List_Ref (N : Iir_List; F : Fields_Enum)
is
El : Iir;
+ It : List_Iterator;
begin
case N is
when Null_Iir_List
| Iir_List_All =>
null;
when others =>
- for I in Natural loop
- El := Get_Nth_Element (N, I);
- exit when El = Null_Iir;
+ It := List_Iterate (N);
+ while Is_Valid (It) loop
+ El := Get_Element (It);
if not Markers (El) then
Report_Early_Reference (El, F);
end if;
+ Next (It);
end loop;
end case;
end Mark_Iir_List_Ref;
@@ -312,6 +314,7 @@ package body Nodes_GC is
procedure Mark_Unit (Unit : Iir)
is
List : Iir_List;
+ It : List_Iterator;
El : Iir;
begin
pragma Assert (Get_Kind (Unit) = Iir_Kind_Design_Unit);
@@ -331,10 +334,9 @@ package body Nodes_GC is
-- First mark dependences
List := Get_Dependence_List (Unit);
if List /= Null_Iir_List then
- for I in Natural loop
- El := Get_Nth_Element (List, I);
- exit when El = Null_Iir;
-
+ It := List_Iterate (List);
+ while Is_Valid (It) loop
+ El := Get_Element (It);
case Get_Kind (El) is
when Iir_Kind_Design_Unit =>
Mark_Unit (El);
@@ -366,6 +368,7 @@ package body Nodes_GC is
when others =>
Error_Kind ("mark_unit", El);
end case;
+ Next (It);
end loop;
end if;