OSDN Git Service

Delete all lines containing "$Revision:".
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-finimp.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --    S Y S T E M . F I N A L I Z A T I O N _ I M P L E M E N T A T I O N   --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                                                                          --
10 --          Copyright (C) 1992-1998 Free Software Foundation, Inc.          --
11 --                                                                          --
12 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
13 -- terms of the  GNU General Public License as published  by the Free Soft- --
14 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
15 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNAT was originally developed  by the GNAT team at  New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 with System.Finalization_Root;
36
37 package System.Finalization_Implementation is
38 pragma Elaborate_Body (Finalization_Implementation);
39
40    package SFR  renames System.Finalization_Root;
41
42    ------------------------------------------------
43    -- Finalization Management Abstract Interface --
44    ------------------------------------------------
45
46    Global_Final_List : SFR.Finalizable_Ptr;
47    --  This list stores the controlled objects defined in library-level
48    --  packages. They will be finalized after the main program completion.
49
50    procedure Finalize_Global_List;
51    --  The procedure to be called in order to finalize the global list;
52
53    procedure Attach_To_Final_List
54      (L       : in out SFR.Finalizable_Ptr;
55       Obj     : in out SFR.Finalizable;
56       Nb_Link : Short_Short_Integer);
57    --  Attach finalizable object Obj to the linked list L. Nb_Link controls
58    --  the number of link of the linked_list, and can be either 0 for no
59    --  attachement, 1 for simple linked lists or 2 for doubly linked lists
60    --  or even 3 for a simple attachement of a whole array of elements.
61    --  Attachement to a simply linked list is not protected against
62    --  concurrent access and should only be used in context where it
63    --  doesn't matter, such as for objects allocated on the stack. In the
64    --  case of an attachment on a doubly linked list, L must not be null
65    --  and Obj will be inserted AFTER the first element and the attachment
66    --  is protected against concurrent call. Typically used to attach to
67    --  a dynamically allocated object to a List_Controller (whose first
68    --  element is always a dummy element)
69
70    procedure Finalize_List (L : SFR.Finalizable_Ptr);
71    --  Call Finalize on each element of the list L;
72
73    procedure Finalize_One (Obj  : in out SFR.Finalizable);
74    --  Call Finalize on Obj and remove its final list.
75
76    ---------------------
77    -- Deep Procedures --
78    ---------------------
79
80    procedure Deep_Tag_Initialize
81      (L : in out SFR.Finalizable_Ptr;
82       A : System.Address;
83       B : Short_Short_Integer);
84    --  Generic initialize for tagged objects with controlled components. A
85    --  is the address of the object, L the finalization list when it needs
86    --  to be attached and B the attachement level (see Attach_To_Final_List)
87
88    procedure Deep_Tag_Adjust
89      (L : in out SFR.Finalizable_Ptr;
90       A : System.Address;
91       B : Short_Short_Integer);
92    --  Generic adjust for tagged objects with controlled components. A
93    --  is the address of the object, L the finalization list when it needs
94    --  to be attached and B the attachement level (see Attach_To_Final_List)
95
96    procedure Deep_Tag_Finalize
97      (L : in out SFR.Finalizable_Ptr;
98       A : System.Address;
99       B : Boolean);
100    --  Generic finalize for tagged objects with controlled components. A
101    --  is the address of the object, L the finalization list when it needs
102    --  to be attached and B the attachement level (see Attach_To_Final_List)
103
104    procedure Deep_Tag_Attach
105      (L : in out SFR.Finalizable_Ptr;
106       A : System.Address;
107       B : Short_Short_Integer);
108    --  Generic attachement for tagged objects with controlled components. A
109    --  is the address of the object, L the finalization list when it needs
110    --  to be attached and B the attachement level (see Attach_To_Final_List)
111
112    -----------------------------
113    -- Record Controller Types --
114    -----------------------------
115
116    --  Definition of the types of the controller component that is included
117    --  in records containing controlled components. This controller is
118    --  attached to the finalization chain of the upper-level and carries
119    --  the pointer of the finalization chain for the lower level
120
121    type Limited_Record_Controller is new SFR.Root_Controlled with record
122       F : SFR.Finalizable_Ptr;
123    end record;
124
125    procedure Initialize (Object : in out Limited_Record_Controller);
126    --  Does nothing
127
128    procedure Finalize (Object : in out Limited_Record_Controller);
129    --  Finalize the controlled components of the enclosing record by
130    --  following the list starting at Object.F
131
132    type Record_Controller is
133       new Limited_Record_Controller with record
134          My_Address : System.Address;
135       end record;
136
137    procedure Initialize (Object : in out Record_Controller);
138    --  Initialize the field My_Address to the Object'Address
139
140    procedure Adjust (Object : in out Record_Controller);
141    --  Adjust the components and their finalization pointers by subtracting
142    --  by the offset of the target and the source addresses of the assignment
143
144    --  Inherit Finalize from Limited_Record_Controller
145
146    procedure Detach_From_Final_List (Obj : in out SFR.Finalizable);
147    --  Remove the specified object from its Final list which must be a
148    --  doubly linked list.
149
150 end System.Finalization_Implementation;