annotate gcc/ada/exp_tss.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- E X P _ T S S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- Type Support Subprogram (TSS) handling
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Namet; use Namet;
kono
parents:
diff changeset
29 with Types; use Types;
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 package Exp_Tss is
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 -- A type support subprogram (TSS) is an internally generated function or
kono
parents:
diff changeset
34 -- procedure that is associated with a particular type. Examples are the
kono
parents:
diff changeset
35 -- implicit initialization procedure, and subprograms for the Input and
kono
parents:
diff changeset
36 -- Output attributes.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- A given TSS is either generated once at the point of the declaration of
kono
parents:
diff changeset
39 -- the type, or it is generated as needed in clients, but only one copy is
kono
parents:
diff changeset
40 -- required in any one generated object file. The choice between these two
kono
parents:
diff changeset
41 -- possibilities is made on a TSS-by-TSS basis depending on the estimation
kono
parents:
diff changeset
42 -- of how likely the TSS is to be used. Initialization procedures fall in
kono
parents:
diff changeset
43 -- the first category, for example, since it is likely that any declared
kono
parents:
diff changeset
44 -- type will be used in a context requiring initialization, but the stream
kono
parents:
diff changeset
45 -- attributes use the second approach, since it is more likely that they
kono
parents:
diff changeset
46 -- will not be used at all, or will only be used in one client in any case.
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 -------------------------
kono
parents:
diff changeset
49 -- Current Limitations --
kono
parents:
diff changeset
50 -------------------------
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 -- In the current version of this package, only the case of generating a
kono
parents:
diff changeset
53 -- TSS at the point of declaration of the type is accommodated. A clear
kono
parents:
diff changeset
54 -- improvement would be to follow through with the full implementation
kono
parents:
diff changeset
55 -- as described above, and also accommodate the requirement of generating
kono
parents:
diff changeset
56 -- only one copy in a given object file.
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 -- For now, we deal with the local case by generating duplicate versions
kono
parents:
diff changeset
59 -- of the TSS routine, which is clearly rather inefficient in space usage.
kono
parents:
diff changeset
60 -- This is done by using Make_TSS_Name_Local to generate unique names
kono
parents:
diff changeset
61 -- for the different instances of TSS routines in a given scope.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 ----------------
kono
parents:
diff changeset
64 -- TSS Naming --
kono
parents:
diff changeset
65 ----------------
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- A TSS is identified by its Chars name. The name has the form typXY or
kono
parents:
diff changeset
68 -- typ_<serial>XY, where typ is the type name, and XY are two characters
kono
parents:
diff changeset
69 -- that identify the particular TSS routine. A unique serial number is
kono
parents:
diff changeset
70 -- included for the case where several local instances of the same TSS
kono
parents:
diff changeset
71 -- must be generated (see discussion under Make_TSS_Name_Local).
kono
parents:
diff changeset
72
kono
parents:
diff changeset
73 -- The following codes are used to denote TSSs:
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 -- Note: When making additions to this list, make the corresponding change
kono
parents:
diff changeset
76 -- to the list in snames.adb-tmpl.
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 type TSS_Name_Type is new String (1 .. 2);
kono
parents:
diff changeset
79 subtype TNT is TSS_Name_Type;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 TSS_Deep_Adjust : constant TNT := "DA"; -- Deep Adjust
kono
parents:
diff changeset
82 TSS_Deep_Finalize : constant TNT := "DF"; -- Deep Finalize
kono
parents:
diff changeset
83 TSS_Deep_Initialize : constant TNT := "DI"; -- Deep Initialize
kono
parents:
diff changeset
84 TSS_Composite_Equality : constant TNT := "EQ"; -- Composite Equality
kono
parents:
diff changeset
85 TSS_Finalize_Address : constant TNT := "FD"; -- Finalize Address
kono
parents:
diff changeset
86 TSS_From_Any : constant TNT := "FA"; -- PolyORB/DSA From_Any
kono
parents:
diff changeset
87 TSS_Init_Proc : constant TNT := "IP"; -- Initialization Procedure
kono
parents:
diff changeset
88 TSS_CPP_Init_Proc : constant TNT := "IC"; -- Init C++ dispatch tables
kono
parents:
diff changeset
89 TSS_RAS_Access : constant TNT := "RA"; -- RAS type access
kono
parents:
diff changeset
90 TSS_RAS_Dereference : constant TNT := "RD"; -- RAS type dereference
kono
parents:
diff changeset
91 TSS_Rep_To_Pos : constant TNT := "RP"; -- Rep to Pos conversion
kono
parents:
diff changeset
92 TSS_Slice_Assign : constant TNT := "SA"; -- Slice assignment
kono
parents:
diff changeset
93 TSS_Stream_Input : constant TNT := "SI"; -- Stream Input attribute
kono
parents:
diff changeset
94 TSS_Stream_Output : constant TNT := "SO"; -- Stream Output attribute
kono
parents:
diff changeset
95 TSS_Stream_Read : constant TNT := "SR"; -- Stream Read attribute
kono
parents:
diff changeset
96 TSS_Stream_Write : constant TNT := "SW"; -- Stream Write attribute
kono
parents:
diff changeset
97 TSS_To_Any : constant TNT := "TA"; -- PolyORB/DSA To_Any
kono
parents:
diff changeset
98 TSS_TypeCode : constant TNT := "TC"; -- PolyORB/DSA TypeCode
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -- The array below contains all valid TSS names
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 TSS_Names : constant array (Natural range <>) of TSS_Name_Type :=
kono
parents:
diff changeset
103 (TSS_Deep_Adjust,
kono
parents:
diff changeset
104 TSS_Deep_Finalize,
kono
parents:
diff changeset
105 TSS_Deep_Initialize,
kono
parents:
diff changeset
106 TSS_Composite_Equality,
kono
parents:
diff changeset
107 TSS_Finalize_Address,
kono
parents:
diff changeset
108 TSS_From_Any,
kono
parents:
diff changeset
109 TSS_Init_Proc,
kono
parents:
diff changeset
110 TSS_CPP_Init_Proc,
kono
parents:
diff changeset
111 TSS_RAS_Access,
kono
parents:
diff changeset
112 TSS_RAS_Dereference,
kono
parents:
diff changeset
113 TSS_Rep_To_Pos,
kono
parents:
diff changeset
114 TSS_Slice_Assign,
kono
parents:
diff changeset
115 TSS_Stream_Input,
kono
parents:
diff changeset
116 TSS_Stream_Output,
kono
parents:
diff changeset
117 TSS_Stream_Read,
kono
parents:
diff changeset
118 TSS_Stream_Write,
kono
parents:
diff changeset
119 TSS_To_Any,
kono
parents:
diff changeset
120 TSS_TypeCode);
kono
parents:
diff changeset
121
kono
parents:
diff changeset
122 TSS_Null : constant TNT := " ";
kono
parents:
diff changeset
123 -- Dummy entry used to indicated that this is not really a TSS
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 function Get_TSS_Name (E : Entity_Id) return TSS_Name_Type;
kono
parents:
diff changeset
126 -- Given an entity, if it is a TSS, then return the corresponding TSS
kono
parents:
diff changeset
127 -- name type, otherwise return TSS_Null.
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 function Make_TSS_Name
kono
parents:
diff changeset
130 (Typ : Entity_Id;
kono
parents:
diff changeset
131 Nam : TSS_Name_Type) return Name_Id;
kono
parents:
diff changeset
132 -- Construct the name as described above for the given TSS routine
kono
parents:
diff changeset
133 -- identified by Nam for the type identified by Typ.
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 function Make_TSS_Name_Local
kono
parents:
diff changeset
136 (Typ : Entity_Id;
kono
parents:
diff changeset
137 Nam : TSS_Name_Type) return Name_Id;
kono
parents:
diff changeset
138 -- Similar to the above call, but a string of the form _nnn is inserted
kono
parents:
diff changeset
139 -- before the TSS code suffix, where nnn is a unique serial number. This
kono
parents:
diff changeset
140 -- is used when multiple instances of the same TSS routine may be
kono
parents:
diff changeset
141 -- generated in the same scope (see also discussion above of current
kono
parents:
diff changeset
142 -- limitations).
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 function Make_Init_Proc_Name (Typ : Entity_Id) return Name_Id;
kono
parents:
diff changeset
145 -- Version for init procs, same as Make_TSS_Name (Typ, TSS_Init_Proc)
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 function Is_CPP_Init_Proc (E : Entity_Id) return Boolean;
kono
parents:
diff changeset
148 -- Version for CPP init procs, same as Is_TSS (E, TSS_CPP_Init_Proc);
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 function Is_Init_Proc (E : Entity_Id) return Boolean;
kono
parents:
diff changeset
151 -- Version for init procs, same as Is_TSS (E, TSS_Init_Proc);
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 function Is_TSS (E : Entity_Id; Nam : TSS_Name_Type) return Boolean;
kono
parents:
diff changeset
154 -- Determines if given entity (E) is the name of a TSS identified by Nam
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 function Is_TSS (N : Name_Id; Nam : TSS_Name_Type) return Boolean;
kono
parents:
diff changeset
157 -- Same test applied directly to a Name_Id value
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 -----------------------------------------
kono
parents:
diff changeset
160 -- TSS Data structures and Subprograms --
kono
parents:
diff changeset
161 -----------------------------------------
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 -- The TSS's for a given type are stored in an element list associated with
kono
parents:
diff changeset
164 -- the type, and referenced from the TSS_Elist field of the N_Freeze_Entity
kono
parents:
diff changeset
165 -- node associated with the type (all types that need TSS's always need to
kono
parents:
diff changeset
166 -- be explicitly frozen, so the N_Freeze_Entity node always exists).
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 function TSS (Typ : Entity_Id; Nam : TSS_Name_Type) return Entity_Id;
kono
parents:
diff changeset
169 -- Finds the TSS with the given name associated with the given type
kono
parents:
diff changeset
170 -- If no such TSS exists, then Empty is returned;
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 function TSS (Typ : Entity_Id; Nam : Name_Id) return Entity_Id;
kono
parents:
diff changeset
173 -- Finds the TSS with the given name associated with the given type. If
kono
parents:
diff changeset
174 -- no such TSS exists, then Empty is returned.
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 function Same_TSS (E1, E2 : Entity_Id) return Boolean;
kono
parents:
diff changeset
177 -- Returns True if E1 and E2 are the same kind of TSS, even if the names
kono
parents:
diff changeset
178 -- are different (i.e. if the names of E1 and E2 end with two upper case
kono
parents:
diff changeset
179 -- letters that are the same).
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 procedure Set_TSS (Typ : Entity_Id; TSS : Entity_Id);
kono
parents:
diff changeset
182 -- This procedure is used to install a newly created TSS. The second
kono
parents:
diff changeset
183 -- argument is the entity for such a new TSS. This entity is placed in the
kono
parents:
diff changeset
184 -- TSS list for the type given as the first argument, replacing an old
kono
parents:
diff changeset
185 -- entry of the same name if one was present. The tree for the body of this
kono
parents:
diff changeset
186 -- TSS, which is not analyzed yet, is placed in the actions field of the
kono
parents:
diff changeset
187 -- freeze node for the type. All such bodies are inserted into the main
kono
parents:
diff changeset
188 -- tree and analyzed at the point at which the freeze node itself is
kono
parents:
diff changeset
189 -- expanded.
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 procedure Copy_TSS (TSS : Entity_Id; Typ : Entity_Id);
kono
parents:
diff changeset
192 -- Given an existing TSS for another type (which is already installed,
kono
parents:
diff changeset
193 -- analyzed and expanded), install it as the corresponding TSS for Typ.
kono
parents:
diff changeset
194 -- Note that this just copies a reference, not the tree. This can also be
kono
parents:
diff changeset
195 -- used to initially install a TSS in the case where the subprogram for the
kono
parents:
diff changeset
196 -- TSS has already been created and its declaration processed.
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 function CPP_Init_Proc (Typ : Entity_Id) return Entity_Id;
kono
parents:
diff changeset
199 -- Obtains the CPP_Init TSS entity the given type. The CPP_Init TSS is a
kono
parents:
diff changeset
200 -- procedure used to initialize the C++ part of the primary and secondary
kono
parents:
diff changeset
201 -- dispatch tables of a tagged type derived from CPP types.
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 function Init_Proc
kono
parents:
diff changeset
204 (Typ : Entity_Id;
kono
parents:
diff changeset
205 Ref : Entity_Id := Empty) return Entity_Id;
kono
parents:
diff changeset
206 -- Obtains the _init TSS entry for the given type. This function call is
kono
parents:
diff changeset
207 -- equivalent to TSS (Typ, Name_uInit). The _init TSS is the procedure
kono
parents:
diff changeset
208 -- used to initialize otherwise uninitialized instances of a type. If
kono
parents:
diff changeset
209 -- there is no _init TSS, then the type requires no initialization. Note
kono
parents:
diff changeset
210 -- that subtypes and implicit types never have an _init TSS since subtype
kono
parents:
diff changeset
211 -- objects are always initialized using the initialization procedure for
kono
parents:
diff changeset
212 -- the corresponding base type (see Base_Init_Proc function). A special
kono
parents:
diff changeset
213 -- case arises for concurrent types. Such types do not themselves have an
kono
parents:
diff changeset
214 -- init proc TSS, but initialization is required. The init proc used is
kono
parents:
diff changeset
215 -- the one for the corresponding record type (see Base_Init_Proc). If
kono
parents:
diff changeset
216 -- Ref is present it is a call to a subprogram whose profile matches the
kono
parents:
diff changeset
217 -- profile of the required constructor (this argument is used to handle
kono
parents:
diff changeset
218 -- non-default CPP constructors).
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 function Base_Init_Proc
kono
parents:
diff changeset
221 (Typ : Entity_Id;
kono
parents:
diff changeset
222 Ref : Entity_Id := Empty) return Entity_Id;
kono
parents:
diff changeset
223 -- Obtains the _Init TSS entry from the base type of the entity, and also
kono
parents:
diff changeset
224 -- deals with going indirect through the Corresponding_Record_Type field
kono
parents:
diff changeset
225 -- for concurrent objects (which are initialized with the initialization
kono
parents:
diff changeset
226 -- routine for the corresponding record type). Returns Empty if there is no
kono
parents:
diff changeset
227 -- _Init TSS entry for the base type. If Ref is present it is a call to a
kono
parents:
diff changeset
228 -- subprogram whose profile matches the profile of the required constructor
kono
parents:
diff changeset
229 -- (this argument is used to handle non-default CPP constructors).
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 procedure Set_Init_Proc (Typ : Entity_Id; Init : Entity_Id);
kono
parents:
diff changeset
232 pragma Inline (Set_Init_Proc);
kono
parents:
diff changeset
233 -- The second argument is the _init TSS to be established for the type
kono
parents:
diff changeset
234 -- given as the first argument. Equivalent to Set_TSS (Typ, Init).
kono
parents:
diff changeset
235
kono
parents:
diff changeset
236 function Has_Non_Null_Base_Init_Proc (Typ : Entity_Id) return Boolean;
kono
parents:
diff changeset
237 -- Returns true if the given type has a defined Base_Init_Proc and
kono
parents:
diff changeset
238 -- this init proc is not a null init proc (null init procs occur as
kono
parents:
diff changeset
239 -- a result of the processing for Initialize_Scalars). This function
kono
parents:
diff changeset
240 -- is used to test for the presence of an init proc in cases where
kono
parents:
diff changeset
241 -- a null init proc is considered equivalent to no init proc.
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 function Find_Inherited_TSS
kono
parents:
diff changeset
244 (Typ : Entity_Id;
kono
parents:
diff changeset
245 Nam : TSS_Name_Type) return Entity_Id;
kono
parents:
diff changeset
246 -- Returns the TSS of name Nam of Typ, or of its closest ancestor defining
kono
parents:
diff changeset
247 -- such a TSS. Empty is returned is neither Typ nor any of its ancestors
kono
parents:
diff changeset
248 -- have such a TSS.
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 end Exp_Tss;