OSDN Git Service

Update FSF address
[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-2005 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
44    --  the master for that access type, now that it is known to denote an
45    --  object 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_Discr_Checking_Funcs (N : Node_Id);
51    --  Builds function which checks whether the component name is consistent
52    --  with the current discriminants. N is the full type declaration node,
53    --  and the discriminant checking functions are inserted after this node.
54
55    function Build_Initialization_Call
56      (Loc               : Source_Ptr;
57       Id_Ref            : Node_Id;
58       Typ               : Entity_Id;
59       In_Init_Proc      : Boolean := False;
60       Enclos_Type       : Entity_Id := Empty;
61       Discr_Map         : Elist_Id := New_Elmt_List;
62       With_Default_Init : Boolean := False) return List_Id;
63    --  Builds a call to the initialization procedure of the Id entity. Id_Ref
64    --  is either a new reference to Id (for record fields), or an indexed
65    --  component (for array elements). Loc is the source location for the
66    --  constructed tree, and Typ is the type of the entity (the initialization
67    --  procedure of the base type is the procedure that actually gets called).
68    --  In_Init_Proc has to be set to True when the call is itself in an init
69    --  proc in order to enable the use of discriminals. Enclos_type is the
70    --  type of the init proc and it is used for various expansion cases
71    --  including the case where Typ is a task type which is a array component,
72    --  the indices of the enclosing type are used to build the string that
73    --  identifies each task at runtime.
74    --
75    --  Discr_Map is used to replace discriminants by their discriminals in
76    --  expressions used to constrain record components. In the presence of
77    --  entry families bounded by discriminants, protected type discriminants
78    --  can appear within expressions in array bounds (not as stand-alone
79    --  identifiers) and a general replacement is necessary.
80    --
81    --  Ada 2005 (AI-287): With_Default_Init is used to indicate that the
82    --  initialization call corresponds to a default initialized component
83    --  of an aggregate.
84
85    function Freeze_Type (N : Node_Id) return Boolean;
86    --  This function executes the freezing actions associated with the given
87    --  freeze type node N and returns True if the node is to be deleted.
88    --  We delete the node if it is present just for front end purpose and
89    --  we don't want Gigi to see the node.  This function can't delete the
90    --  node itself since it would confuse any remaining processing of the
91    --  freeze node.
92
93    function Needs_Simple_Initialization (T : Entity_Id) return Boolean;
94    --  Certain types need initialization even though there is no specific
95    --  initialization routine. In this category are access types (which
96    --  need initializing to null), packed array types whose implementation
97    --  is a modular type, and all scalar types if Normalize_Scalars is set,
98    --  as well as private types whose underlying type is present and meets
99    --  any of these criteria. Finally, descendants of String and Wide_String
100    --  also need initialization in Initialize/Normalize_Scalars mode.
101
102    function Get_Simple_Init_Val
103      (T    : Entity_Id;
104       Loc  : Source_Ptr;
105       Size : Uint := No_Uint) return Node_Id;
106    --  For a type which Needs_Simple_Initialization (see above), prepares
107    --  the tree for an expression representing the required initial value.
108    --  Loc is the source location used in constructing this tree which is
109    --  returned as the result of the call. The Size parameter indicates the
110    --  target size of the object if it is known (indicated by a value that
111    --  is not No_Uint and is greater than zero). If Size is not given (Size
112    --  set to No_Uint, or non-positive), then the Esize of T is used as an
113    --  estimate of the Size. The object size is needed to prepare a known
114    --  invalid value for use by Normalize_Scalars.
115
116 end Exp_Ch3;