diff options
Diffstat (limited to 'gcc/ada/a-coorse.adb')
-rw-r--r-- | gcc/ada/a-coorse.adb | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/gcc/ada/a-coorse.adb b/gcc/ada/a-coorse.adb index ce004e2d737..b4518f40b75 100644 --- a/gcc/ada/a-coorse.adb +++ b/gcc/ada/a-coorse.adb @@ -42,15 +42,17 @@ with System; use type System.Address; package body Ada.Containers.Ordered_Sets is - type Iterator is limited new - Set_Iterator_Interfaces.Reversible_Iterator with record - Container : Set_Access; - Node : Node_Access; - end record; + type Iterator is new Limited_Controlled and + Set_Iterator_Interfaces.Reversible_Iterator with + record + Container : Set_Access; + Node : Node_Access; + end record; - overriding function First (Object : Iterator) return Cursor; + overriding procedure Finalize (Object : in out Iterator); - overriding function Last (Object : Iterator) return Cursor; + overriding function First (Object : Iterator) return Cursor; + overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; @@ -512,6 +514,22 @@ package body Ada.Containers.Ordered_Sets is end if; end Exclude; + -------------- + -- Finalize -- + -------------- + + procedure Finalize (Object : in out Iterator) is + begin + if Object.Container /= null then + declare + B : Natural renames Object.Container.all.Tree.Busy; + + begin + B := B - 1; + end; + end if; + end Finalize; + ---------- -- Find -- ---------- @@ -1160,7 +1178,7 @@ package body Ada.Containers.Ordered_Sets is Process (Cursor'(Container'Unrestricted_Access, Node)); end Process_Node; - T : Tree_Type renames Container.Tree'Unrestricted_Access.all; + T : Tree_Type renames Container'Unrestricted_Access.all.Tree; B : Natural renames T.Busy; -- Start of processing for Iterate @@ -1182,6 +1200,8 @@ package body Ada.Containers.Ordered_Sets is function Iterate (Container : Set) return Set_Iterator_Interfaces.Reversible_Iterator'Class is + B : Natural renames Container'Unrestricted_Access.all.Tree.Busy; + begin -- The value of the Node component influences the behavior of the First -- and Last selector functions of the iterator object. When the Node @@ -1193,12 +1213,19 @@ package body Ada.Containers.Ordered_Sets is -- Note: For a forward iterator, Container.First is the beginning, and -- for a reverse iterator, Container.Last is the beginning. - return Iterator'(Container'Unrestricted_Access, Node => null); + B := B + 1; + + return It : constant Iterator := + Iterator'(Limited_Controlled with + Container => Container'Unrestricted_Access, + Node => null); end Iterate; function Iterate (Container : Set; Start : Cursor) return Set_Iterator_Interfaces.Reversible_Iterator'Class is + B : Natural renames Container'Unrestricted_Access.all.Tree.Busy; + begin -- It was formerly the case that when Start = No_Element, the partial -- iterator was defined to behave the same as for a complete iterator, @@ -1233,7 +1260,12 @@ package body Ada.Containers.Ordered_Sets is -- the start position has the same value irrespective of whether this is -- a forward or reverse iteration. - return Iterator'(Container'Unrestricted_Access, Node => Start.Node); + B := B + 1; + + return It : constant Iterator := + Iterator'(Limited_Controlled with + Container => Container'Unrestricted_Access, + Node => Start.Node); end Iterate; ---------- |