OSDN Git Service

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