OSDN Git Service

2006-10-31 Javier Miranda <miranda@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / exp_ch3.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                              E X P _ C H 3                               --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1992-2006, 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,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, 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 --  Expand routines for chapter 3 constructs
28
29 with Types;  use Types;
30 with Elists; use Elists;
31 with Uintp;  use Uintp;
32
33 package Exp_Ch3 is
34
35    procedure Expand_N_Object_Declaration         (N : Node_Id);
36    procedure Expand_N_Subtype_Indication         (N : Node_Id);
37    procedure Expand_N_Variant_Part               (N : Node_Id);
38    procedure Expand_N_Full_Type_Declaration      (N : Node_Id);
39
40    procedure Expand_Previous_Access_Type (Def_Id : Entity_Id);
41    --  For a full type declaration that contains tasks, or that is a task,
42    --  check whether there exists an access type whose designated type is an
43    --  incomplete declarations for the current composite type. If so, build the
44    --  master for that access type, now that it is known to denote an object
45    --  with tasks.
46
47    procedure Expand_Record_Extension (T : Entity_Id; Def : Node_Id);
48    --  Add a field _parent in the extension part of the record
49
50    procedure Build_Class_Wide_Master (T : Entity_Id);
51    --  For access to class-wide limited types we must build a task master
52    --  because some subsequent extension may add a task component. To avoid
53    --  bringing in the tasking run-time whenever an access-to-class-wide
54    --  limited type is used, we use the soft-link mechanism and add a level of
55    --  indirection to calls to routines that manipulate Master_Ids. This must
56    --  also be used for anonymous access types whose designated type is a task
57    --  or synchronized interface.
58
59    procedure Build_Discr_Checking_Funcs (N : Node_Id);
60    --  Builds function which checks whether the component name is consistent
61    --  with the current discriminants. N is the full type declaration node,
62    --  and the discriminant checking functions are inserted after this node.
63
64    function Build_Initialization_Call
65      (Loc               : Source_Ptr;
66       Id_Ref            : Node_Id;
67       Typ               : Entity_Id;
68       In_Init_Proc      : Boolean := False;
69       Enclos_Type       : Entity_Id := Empty;
70       Discr_Map         : Elist_Id := New_Elmt_List;
71       With_Default_Init : Boolean := False) return List_Id;
72    --  Builds a call to the initialization procedure of the Id entity. Id_Ref
73    --  is either a new reference to Id (for record fields), or an indexed
74    --  component (for array elements). Loc is the source location for the
75    --  constructed tree, and Typ is the type of the entity (the initialization
76    --  procedure of the base type is the procedure that actually gets called).
77    --  In_Init_Proc has to be set to True when the call is itself in an init
78    --  proc in order to enable the use of discriminals. Enclos_type is the type
79    --  of the init proc and it is used for various expansion cases including
80    --  the case where Typ is a task type which is a array component, the
81    --  indices of the enclosing type are used to build the string that
82    --  identifies each task at runtime.
83    --
84    --  Discr_Map is used to replace discriminants by their discriminals in
85    --  expressions used to constrain record components. In the presence of
86    --  entry families bounded by discriminants, protected type discriminants
87    --  can appear within expressions in array bounds (not as stand-alone
88    --  identifiers) and a general replacement is necessary.
89    --
90    --  Ada 2005 (AI-287): With_Default_Init is used to indicate that the
91    --  initialization call corresponds to a default initialized component
92    --  of an aggregate.
93
94    procedure Build_Master_Renaming (N : Node_Id; T : Entity_Id);
95    --  If the designated type of an access type is a task type or contains
96    --  tasks, we make sure that a _Master variable is declared in the current
97    --  scope, and then declare a renaming for it:
98    --
99    --    atypeM : Master_Id renames _Master;
100    --
101    --  where atyp is the name of the access type. This declaration is
102    --  used when an allocator for the access type is expanded. The node N
103    --  is the full declaration of the designated type that contains tasks.
104    --  The renaming declaration is inserted before N, and after the Master
105    --  declaration.
106
107    function Freeze_Type (N : Node_Id) return Boolean;
108    --  This function executes the freezing actions associated with the given
109    --  freeze type node N and returns True if the node is to be deleted. We
110    --  delete the node if it is present just for front end purpose and we don't
111    --  want Gigi to see the node. This function can't delete the node itself
112    --  since it would confuse any remaining processing of the freeze node.
113
114    procedure Init_Secondary_Tags
115      (Typ        : Entity_Id;
116       Target     : Node_Id;
117       Stmts_List : List_Id);
118    --  Ada 2005 (AI-251): Initialize the tags of all the secondary tables
119    --  associated with the abstract interfaces of Typ. The generated code
120    --  referencing tag fields of Target is appended to Stmts_List.
121
122    function Needs_Simple_Initialization (T : Entity_Id) return Boolean;
123    --  Certain types need initialization even though there is no specific
124    --  initialization routine. In this category are access types (which need
125    --  initializing to null), packed array types whose implementation is a
126    --  modular type, and all scalar types if Normalize_Scalars is set, as well
127    --  as private types whose underlying type is present and meets any of these
128    --  criteria. Finally, descendants of String and Wide_String also need
129    --  initialization in Initialize/Normalize_Scalars mode.
130
131    function Get_Simple_Init_Val
132      (T    : Entity_Id;
133       Loc  : Source_Ptr;
134       Size : Uint := No_Uint) return Node_Id;
135    --  For a type which Needs_Simple_Initialization (see above), prepares the
136    --  tree for an expression representing the required initial value. Loc is
137    --  the source location used in constructing this tree which is returned as
138    --  the result of the call. The Size parameter indicates the target size of
139    --  the object if it is known (indicated by a value that is not No_Uint and
140    --  is greater than zero). If Size is not given (Size set to No_Uint, or
141    --  non-positive), then the Esize of T is used as an estimate of the Size.
142    --  The object size is needed to prepare a known invalid value for use by
143    --  Normalize_Scalars.
144
145 end Exp_Ch3;