1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- A D A . F I N A L I Z A T I O N . L I S T _ C O N T R O L L E R --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 with System.Finalization_Implementation;
33 package body Ada.Finalization.List_Controller is
35 package SFI renames System.Finalization_Implementation;
41 procedure Finalize (Object : in out List_Controller) is
42 use type SFR.Finalizable_Ptr;
44 Last_Ptr : constant SFR.Finalizable_Ptr := Object.Last'Unchecked_Access;
47 -- First take note of the fact that finalization of this collection has
50 Object.F := SFI.Collection_Finalization_Started;
52 -- Then finalize all the objects. Note that finalization can call
53 -- Unchecked_Deallocation on other objects in the same collection,
54 -- which will cause them to be removed from the list if we have not
55 -- gotten to them yet. However, allocation in the collection will raise
56 -- Program_Error, due to the above Collection_Finalization_Started.
58 while Object.First.Next /= Last_Ptr loop
59 SFI.Finalize_One (Object.First.Next.all);
63 procedure Finalize (Object : in out Simple_List_Controller) is
65 SFI.Finalize_List (Object.F);
73 procedure Initialize (Object : in out List_Controller) is
75 Object.F := Object.First'Unchecked_Access;
76 Object.First.Next := Object.Last 'Unchecked_Access;
77 Object.Last.Prev := Object.First'Unchecked_Access;
80 end Ada.Finalization.List_Controller;