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_Root
;
34 package Ada
.Finalization
.List_Controller
is
35 pragma Elaborate_Body
;
37 package SFR
renames System
.Finalization_Root
;
39 ----------------------------
40 -- Simple_List_Controller --
41 ----------------------------
43 type Simple_List_Controller
is new Ada
.Finalization
.Limited_Controlled
45 F
: SFR
.Finalizable_Ptr
;
47 -- Used by the compiler to carry a list of temporary objects that
48 -- needs to be finalized after having being used. This list is
49 -- embedded in a controlled type so that if an exception is raised
50 -- while those temporaries are still in use, they will be reclaimed
51 -- by the normal finalization mechanism.
53 overriding
procedure Finalize
(Object
: in out Simple_List_Controller
);
59 -- Management of a bidirectional linked heterogeneous list of
60 -- dynamically Allocated objects. To simplify the management of the
61 -- linked list, the First and Last elements are statically part of the
62 -- original List controller:
67 -- |--<-- | record with ctrl components
68 -- |------------| +----------+
70 -- | |------------| | |
71 -- | |+--------+ | +--------+ |+--------+|
72 -- +->|| prev | F|---<---|-- |----<---||-- ||--<--+
73 -- ||--------| i| |--------| ||--------|| |
74 -- || next | r|--->---| --|---->---|| --||--------+
75 -- |+--------+ s| |--------| ||--------|| | |
76 -- | t| | ctrl | || || | |
77 -- | | : : |+--------+| | |
78 -- | | : object : |rec | | |
79 -- | | : : |controller| | |
81 -- |+--------+ | +--------+ +----------+ | |
82 -- || prev -|-L|--------------------->--------------------+ |
84 -- || next | s|-------------------<-------------------------+
89 type List_Controller
is new Ada
.Finalization
.Limited_Controlled
91 F
: SFR
.Finalizable_Ptr
;
93 Last
: aliased SFR
.Root_Controlled
;
95 -- Controls the chains of dynamically allocated controlled
96 -- objects makes sure that they get finalized upon exit from
97 -- the access type that defined them
99 overriding
procedure Initialize
(Object
: in out List_Controller
);
100 overriding
procedure Finalize
(Object
: in out List_Controller
);
102 end Ada
.Finalization
.List_Controller
;