From d985daf8d54419f00adde0292cbf5a2cf0376609 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 22 May 2019 18:38:12 +0200 Subject: vhdl: add hook on free_node, automatically free --- src/vhdl/vhdl-elocations.adb.in | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/vhdl/vhdl-elocations.adb.in') diff --git a/src/vhdl/vhdl-elocations.adb.in b/src/vhdl/vhdl-elocations.adb.in index 80fab21ce..164fdb00c 100644 --- a/src/vhdl/vhdl-elocations.adb.in +++ b/src/vhdl/vhdl-elocations.adb.in @@ -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; @@ -185,4 +202,7 @@ package body Vhdl.Elocations is procedure Set_Field6 is new Set_FieldX (6); -- Subprograms + +begin + Vhdl.Nodes.Register_Free_Hook (Free_Hook'Access); end Vhdl.Elocations; -- cgit v1.2.3