Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
[official-gcc.git] / gcc / ada / exp_ch7.ads
blob4c227505b0c66a60d118176213ae226d67a06a58
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ C H 7 --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1992-2001 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 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 -- --
26 ------------------------------------------------------------------------------
28 with Types; use Types;
30 package Exp_Ch7 is
32 procedure Expand_N_Package_Body (N : Node_Id);
33 procedure Expand_N_Package_Declaration (N : Node_Id);
35 ------------------------------
36 -- Finalization Management --
37 ------------------------------
39 function In_Finalization_Root (E : Entity_Id) return Boolean;
40 -- True if current scope is in package System.Finalization_Root. Used
41 -- to avoid certain expansions that would involve circularity in the
42 -- Rtsfind mechanism.
44 procedure Build_Final_List (N : Node_Id; Typ : Entity_Id);
45 -- Build finalization list for anonymous access types, and for access
46 -- types that are frozen before their designated types are known to
47 -- be controlled.
49 procedure Build_Controlling_Procs (Typ : Entity_Id);
50 -- Typ is a record, and array type having controlled components.
51 -- Create the procedures Deep_Initialize, Deep_Adjust and Deep_Finalize
52 -- that take care of finalization management at run-time.
54 procedure Build_Late_Proc (Typ : Entity_Id; Nam : Name_Id);
55 -- Build one controlling procedure when a late body overrides one of
56 -- the controlling operations.
58 function Controller_Component (Typ : Entity_Id) return Entity_Id;
59 -- Returns the entity of the component whose name is 'Name_uController'
61 function Controlled_Type (T : Entity_Id) return Boolean;
62 -- True if T potentially needs finalization actions
64 function Find_Final_List
65 (E : Entity_Id;
66 Ref : Node_Id := Empty)
67 return Node_Id;
68 -- E is an entity representing a controlled object, a controlled type
69 -- or a scope. If Ref is not empty, it is a reference to a controlled
70 -- record, the closest Final list is in the controller component of
71 -- the record containing Ref otherwise this function returns a
72 -- reference to the final list attached to the closest dynamic scope
73 -- (that can be E itself) creating this final list if necessary.
75 function Has_New_Controlled_Component (E : Entity_Id) return Boolean;
76 -- E is a type entity. Give the same resul as Has_Controlled_Component
77 -- except for tagged extensions where the result is True only if the
78 -- latest extension contains a controlled component.
80 function Make_Attach_Call
81 (Obj_Ref : Node_Id;
82 Flist_Ref : Node_Id;
83 With_Attach : Node_Id)
84 return Node_Id;
85 -- Attach the referenced object to the referenced Final Chain
86 -- 'Flist_Ref' With_Attach is an expression of type Short_Short_Integer
87 -- which can be either '0' to signify no attachment, '1' for
88 -- attachement to a simply linked list or '2' for attachement to a
89 -- doubly linked list.
91 function Make_Init_Call
92 (Ref : Node_Id;
93 Typ : Entity_Id;
94 Flist_Ref : Node_Id;
95 With_Attach : Node_Id)
96 return List_Id;
97 -- Ref is an expression (with no-side effect and is not required to
98 -- have been previously analyzed) that references the object to be
99 -- initialized. Typ is the expected type of Ref, which is a controlled
100 -- type (Is_Controlled) or a type with controlled components
101 -- (Has_Controlled). 'Dynamic_Case' controls the way the object is
102 -- attached which is different whether the object is dynamically
103 -- allocated or not.
105 -- This function will generate the appropriate calls to make
106 -- sure that the objects referenced by Ref are initialized. The
107 -- generate code is quite different depending on the fact the type
108 -- IS_Controlled or HAS_Controlled but this is not the problem of the
109 -- caller, the details are in the body.
111 function Make_Adjust_Call
112 (Ref : Node_Id;
113 Typ : Entity_Id;
114 Flist_Ref : Node_Id;
115 With_Attach : Node_Id)
116 return List_Id;
117 -- Ref is an expression (with no-side effect and is not required to
118 -- have been previously analyzed) that references the object to be
119 -- adjusted. Typ is the expected type of Ref, which is a controlled
120 -- type (Is_Controlled) or a type with controlled components
121 -- (Has_Controlled).
123 -- This function will generate the appropriate calls to make
124 -- sure that the objects referenced by Ref are adjusted. The generated
125 -- code is quite different depending on the fact the type IS_Controlled
126 -- or HAS_Controlled but this is not the problem of the caller, the
127 -- details are in the body. If the parameter With_Attach is set to
128 -- True, the finalizable objects involved are attached to the proper
129 -- finalization chain. The objects must be attached when the adjust
130 -- takes place after an initialization expression but not when it takes
131 -- place after a regular assignment.
133 -- The description of With_Attach is completely obsolete ???
135 function Make_Final_Call
136 (Ref : Node_Id;
137 Typ : Entity_Id;
138 With_Detach : Node_Id)
139 return List_Id;
140 -- Ref is an expression (with no-side effect and is not required to
141 -- have been previously analyzed) that references the object
142 -- to be Finalized. Typ is the expected type of Ref, which is a
143 -- controlled type (Is_Controlled) or a type with controlled
144 -- components (Has_Controlled).
146 -- This function will generate the appropriate calls to make
147 -- sure that the objects referenced by Ref are finalized. The generated
148 -- code is quite different depending on the fact the type IS_Controlled
149 -- or HAS_Controlled but this is not the problem of the caller, the
150 -- details are in the body. If the parameter With_Detach is set to
151 -- True, the finalizable objects involved are detached from the proper
152 -- finalization chain. The objects must be detached when finalizing an
153 -- unchecked deallocated object but not when finalizing the target of
154 -- an assignment, it is not necessary either on scope exit.
156 procedure Expand_Ctrl_Function_Call (N : Node_Id);
157 -- Expand a call to a function returning a controlled value. That is to
158 -- say attach the result of the call to the current finalization list,
159 -- which is the one of the transient scope created for such constructs.
161 --------------------------------
162 -- Transient Scope Management --
163 --------------------------------
165 procedure Expand_Cleanup_Actions (N : Node_Id);
166 -- Expand the necessary stuff into a scope to enable finalization of local
167 -- objects and deallocation of transient data when exiting the scope. N is
168 -- a "scope node" that is to say one of the following: N_Block_Statement,
169 -- N_Subprogram_Body, N_Task_Body, N_Entry_Body.
171 procedure Establish_Transient_Scope (N : Node_Id; Sec_Stack : Boolean);
172 -- Push a new transient scope on the scope stack. N is the node responsible
173 -- for the need of a transient scope. If Sec_Stack is True then the
174 -- secondary stack is brought in, otherwise it isn't.
176 function Node_To_Be_Wrapped return Node_Id;
177 -- return the node to be wrapped if the current scope is transient.
179 procedure Store_Before_Actions_In_Scope (L : List_Id);
180 -- Append the list L of actions to the end of the before-actions store
181 -- in the top of the scope stack
183 procedure Store_After_Actions_In_Scope (L : List_Id);
184 -- Append the list L of actions to the beginning of the after-actions
185 -- store in the top of the scope stack
187 procedure Wrap_Transient_Declaration (N : Node_Id);
188 -- N is an object declaration. Expand the finalization calls after the
189 -- declaration and make the outer scope beeing the transient one.
191 procedure Wrap_Transient_Expression (N : Node_Id);
192 -- N is a sub-expression. Expand a transient block around an expression
194 procedure Wrap_Transient_Statement (N : Node_Id);
195 -- N is a statement. Expand a transient block around an instruction
197 end Exp_Ch7;