1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
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. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- Type Support Subprogram (TSS) handling
30 with Types
; use Types
;
34 -- A type support subprogram (TSS) is an internally generated function or
35 -- procedure that is associated with a particular type. Examples are the
36 -- implicit initialization procedure, and subprograms for the Input and
39 -- A given TSS is either generated once at the point of the declaration of
40 -- the type, or it is generated as needed in clients, but only one copy is
41 -- required in any one generated object file. The choice between these two
42 -- possibilities is made on a TSS-by-TSS basis depending on the estimation
43 -- of how likely the TSS is to be used. Initialization procedures fall in
44 -- the first category, for example, since it is likely that any declared
45 -- type will be used in a context requiring initialization, but the stream
46 -- attributes use the second approach, since it is more likely that they
47 -- will not be used at all, or will only be used in one client in any case.
49 -- A TSS is identified by its Chars name, i.e. for a given TSS type, the
50 -- same name is used for all types, e.g. the initialization routine has
51 -- the name _init for all types.
53 -- The TSS's for a given type are stored in an element list associated with
54 -- the type, and referenced from the TSS_Elist field of the N_Freeze_Entity
55 -- node associated with the type (all types that need TSS's always need to
56 -- be explicitly frozen, so the N_Freeze_Entity node always exists).
58 function TSS
(Typ
: Entity_Id
; Nam
: Name_Id
) return Entity_Id
;
59 -- Finds the TSS with the given name associated with the given type. If
60 -- no such TSS exists, then Empty is returned.
62 procedure Set_TSS
(Typ
: Entity_Id
; TSS
: Entity_Id
);
63 -- This procedure is used to install a newly created TSS. The second
64 -- argument is the entity for such a new TSS. This entity is placed in
65 -- the TSS list for the type given as the first argument, replacing an
66 -- old entry of the same name if one was present. The tree for the body
67 -- of this TSS, which is not analyzed yet, is placed in the actions field
68 -- of the freeze node for the type. All such bodies are inserted into the
69 -- main tree and analyzed at the point at which the freeze node itself is
72 procedure Copy_TSS
(TSS
: Entity_Id
; Typ
: Entity_Id
);
73 -- Given an existing TSS for another type (which is already installed,
74 -- analyzed and expanded), install it as the corresponding TSS for Typ.
75 -- Note that this just copies a reference, not the tree. This can also
76 -- be used to initially install a TSS in the case where the subprogram
77 -- for the TSS has already been created and its declaration processed.
79 function Init_Proc
(Typ
: Entity_Id
) return Entity_Id
;
80 pragma Inline
(Init_Proc
);
81 -- Obtains the _init TSS entry for the given type. This function call is
82 -- equivalent to TSS (Typ, Name_uInit). The _init TSS is the procedure
83 -- used to initialize otherwise uninitialized instances of a type. If
84 -- there is no _init TSS, then the type requires no initialization. Note
85 -- that subtypes and implicit types never have an _init TSS since subtype
86 -- objects are always initialized using the initialization procedure for
87 -- the corresponding base type (see Base_Init_Proc function). A special
88 -- case arises for concurrent types. Such types do not themselves have an
89 -- _init TSR, but initialization is required. The initialization procedure
90 -- used is the one fot the corresponding record type (see Base_Init_Proc).
92 function Base_Init_Proc
(Typ
: Entity_Id
) return Entity_Id
;
93 -- Obtains the _Init TSS entry from the base type of the entity, and also
94 -- deals with going indirect through the Corresponding_Record_Type field
95 -- for concurrent objects (which are initialized with the initialization
96 -- routine for the corresponding record type). Returns Empty if there is
97 -- no _Init TSS entry for the base type.
99 procedure Set_Init_Proc
(Typ
: Entity_Id
; Init
: Entity_Id
);
100 pragma Inline
(Set_Init_Proc
);
101 -- The second argument is the _init TSS to be established for the type
102 -- given as the first argument. Equivalent to Set_TSS (Typ, Init).
104 function Has_Non_Null_Base_Init_Proc
(Typ
: Entity_Id
) return Boolean;
105 -- Returns true if the given type has a defined Base_Init_Proc and
106 -- this init proc is not a null init proc (null init procs occur as
107 -- a result of the processing for Initialize_Scalars. This function
108 -- is used to test for the presence of an Init_Proc in cases where
109 -- a null init proc is considered equivalent to no Init_Proc.