aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-elocations.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-05-22 18:38:12 +0200
committerTristan Gingold <tgingold@free.fr>2019-05-22 18:38:12 +0200
commitd985daf8d54419f00adde0292cbf5a2cf0376609 (patch)
tree94b6e23220f205dc66aeb5e56c6ac3ea1b7d94fb /src/vhdl/vhdl-elocations.adb
parentb6267cd2b25a3e6115fd5df2db3a07ad0c013f47 (diff)
downloadghdl-d985daf8d54419f00adde0292cbf5a2cf0376609.tar.gz
ghdl-d985daf8d54419f00adde0292cbf5a2cf0376609.tar.bz2
ghdl-d985daf8d54419f00adde0292cbf5a2cf0376609.zip
vhdl: add hook on free_node, automatically free
Diffstat (limited to 'src/vhdl/vhdl-elocations.adb')
-rw-r--r--src/vhdl/vhdl-elocations.adb22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/vhdl/vhdl-elocations.adb b/src/vhdl/vhdl-elocations.adb
index 0ba3d0b0e..8bc68245c 100644
--- a/src/vhdl/vhdl-elocations.adb
+++ b/src/vhdl/vhdl-elocations.adb
@@ -130,14 +130,31 @@ package body Vhdl.Elocations is
Elocations_Table.Table (Idx .. Idx + Len - 1) := (others => No_Location);
end Create_Elocations;
- procedure Delete_Elocations (N : Iir) is
+ procedure Delete_Elocations (N : Iir)
+ is
+ use Vhdl.Nodes_Priv;
+ Old : Location_Index_Type;
begin
+ -- Cannot delete an already deleted location.
+ if N > Elocations_Index_Table.Last then
+ return;
+ end if;
+ Old := Elocations_Index_Table.Table (N);
+ if Old = No_Location_Index then
+ return;
+ end if;
+
-- Clear the corresponding index.
Elocations_Index_Table.Table (N) := No_Location_Index;
-- FIXME: keep free slots in chained list ?
end Delete_Elocations;
+ procedure Free_Hook (N : Iir) is
+ begin
+ Delete_Elocations (N);
+ end Free_Hook;
+
generic
Off : Location_Index_Type;
function Get_FieldX (N : Iir) return Location_Type;
@@ -707,4 +724,7 @@ package body Vhdl.Elocations is
Set_Field3 (N, Loc);
end Set_Assign_Location;
+
+begin
+ Vhdl.Nodes.Register_Free_Hook (Free_Hook'Access);
end Vhdl.Elocations;