diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-05-22 18:38:12 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-05-22 18:38:12 +0200 |
commit | d985daf8d54419f00adde0292cbf5a2cf0376609 (patch) | |
tree | 94b6e23220f205dc66aeb5e56c6ac3ea1b7d94fb /src/vhdl/vhdl-elocations.adb.in | |
parent | b6267cd2b25a3e6115fd5df2db3a07ad0c013f47 (diff) | |
download | ghdl-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.in')
-rw-r--r-- | src/vhdl/vhdl-elocations.adb.in | 22 |
1 files changed, 21 insertions, 1 deletions
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; |