OSDN Git Service

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