diff options
Diffstat (limited to 'gcc/ada/a-cihama.adb')
-rw-r--r-- | gcc/ada/a-cihama.adb | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/gcc/ada/a-cihama.adb b/gcc/ada/a-cihama.adb index 84bbdfdf327..e9b9cc05d91 100644 --- a/gcc/ada/a-cihama.adb +++ b/gcc/ada/a-cihama.adb @@ -34,7 +34,6 @@ with Ada.Containers.Hash_Tables.Generic_Keys; pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Keys); with Ada.Unchecked_Deallocation; - with System; use type System.Address; package body Ada.Containers.Indefinite_Hashed_Maps is @@ -45,10 +44,13 @@ package body Ada.Containers.Indefinite_Hashed_Maps is procedure Free_Element is new Ada.Unchecked_Deallocation (Element_Type, Element_Access); - type Iterator is limited new - Map_Iterator_Interfaces.Forward_Iterator with record - Container : Map_Access; - end record; + type Iterator is new Limited_Controlled and + Map_Iterator_Interfaces.Forward_Iterator with + record + Container : Map_Access; + end record; + + overriding procedure Finalize (Object : in out Iterator); overriding function First (Object : Iterator) return Cursor; @@ -421,6 +423,18 @@ package body Ada.Containers.Indefinite_Hashed_Maps is HT_Ops.Finalize (Container.HT); end Finalize; + procedure Finalize (Object : in out Iterator) is + begin + if Object.Container /= null then + declare + B : Natural renames Object.Container.all.HT.Busy; + + begin + B := B - 1; + end; + end if; + end Finalize; + ---------- -- Find -- ---------- @@ -433,7 +447,7 @@ package body Ada.Containers.Indefinite_Hashed_Maps is return No_Element; end if; - return Cursor'(Container'Unchecked_Access, Node); + return Cursor'(Container'Unrestricted_Access, Node); end Find; -------------------- @@ -471,7 +485,7 @@ package body Ada.Containers.Indefinite_Hashed_Maps is return No_Element; end if; - return Cursor'(Container'Unchecked_Access, Node); + return Cursor'(Container'Unrestricted_Access, Node); end First; function First (Object : Iterator) return Cursor is @@ -687,10 +701,10 @@ package body Ada.Containers.Indefinite_Hashed_Maps is procedure Process_Node (Node : Node_Access) is begin - Process (Cursor'(Container'Unchecked_Access, Node)); + Process (Cursor'(Container'Unrestricted_Access, Node)); end Process_Node; - B : Natural renames Container'Unrestricted_Access.HT.Busy; + B : Natural renames Container'Unrestricted_Access.all.HT.Busy; -- Start of processing Iterate @@ -711,8 +725,15 @@ package body Ada.Containers.Indefinite_Hashed_Maps is function Iterate (Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'Class is + B : Natural renames Container'Unrestricted_Access.all.HT.Busy; + begin - return Iterator'(Container => Container'Unrestricted_Access); + return It : constant Iterator := + (Limited_Controlled with + Container => Container'Unrestricted_Access) + do + B := B + 1; + end return; end Iterate; --------- |