1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 -- Expand routines for chapter 3 constructs
29 with Types
; use Types
;
30 with Elists
; use Elists
;
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
);
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
43 -- the master for that access type, now that it is known to denote an
46 procedure Expand_Record_Extension
(T
: Entity_Id
; Def
: Node_Id
);
47 -- Add a field _parent in the extension part of the record.
49 procedure Build_Discr_Checking_Funcs
(N
: Node_Id
);
50 -- Builds function which checks whether the component name is consistent
51 -- with the current discriminants. N is the full type declaration node,
52 -- and the discriminant checking functions are inserted after this node.
54 function Build_Initialization_Call
58 In_Init_Proc
: Boolean := False;
59 Enclos_Type
: Entity_Id
:= Empty
;
60 Discr_Map
: Elist_Id
:= New_Elmt_List
;
61 With_Default_Init
: Boolean := False) return List_Id
;
62 -- Builds a call to the initialization procedure of the Id entity. Id_Ref
63 -- is either a new reference to Id (for record fields), or an indexed
64 -- component (for array elements). Loc is the source location for the
65 -- constructed tree, and Typ is the type of the entity (the initialization
66 -- procedure of the base type is the procedure that actually gets called).
67 -- In_Init_Proc has to be set to True when the call is itself in an init
68 -- proc in order to enable the use of discriminals. Enclos_type is the
69 -- type of the init proc and it is used for various expansion cases
70 -- including the case where Typ is a task type which is a array component,
71 -- the indices of the enclosing type are used to build the string that
72 -- identifies each task at runtime.
74 -- Discr_Map is used to replace discriminants by their discriminals in
75 -- expressions used to constrain record components. In the presence of
76 -- entry families bounded by discriminants, protected type discriminants
77 -- can appear within expressions in array bounds (not as stand-alone
78 -- identifiers) and a general replacement is necessary.
80 -- Ada 2005 (AI-287): With_Default_Init is used to indicate that the
81 -- initialization call corresponds to a default initialized component
84 procedure Freeze_Type
(N
: Node_Id
);
85 -- This procedure executes the freezing actions associated with the given
86 -- freeze type node N.
88 function Needs_Simple_Initialization
(T
: Entity_Id
) return Boolean;
89 -- Certain types need initialization even though there is no specific
90 -- initialization routine. In this category are access types (which
91 -- need initializing to null), packed array types whose implementation
92 -- is a modular type, and all scalar types if Normalize_Scalars is set,
93 -- as well as private types whose underlying type is present and meets
94 -- any of these criteria. Finally, descendants of String and Wide_String
95 -- also need initialization in Initialize/Normalize_Scalars mode.
97 function Get_Simple_Init_Val
99 Loc
: Source_Ptr
) return Node_Id
;
100 -- For a type which Needs_Simple_Initialization (see above), prepares
101 -- the tree for an expression representing the required initial value.
102 -- Loc is the source location used in constructing this tree which is
103 -- returned as the result of the call.