annotate gcc/ada/exp_ch3.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- E X P _ C H 3 --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- Expand routines for chapter 3 constructs
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Types; use Types;
kono
parents:
diff changeset
29 with Elists; use Elists;
kono
parents:
diff changeset
30 with Uintp; use Uintp;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package Exp_Ch3 is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 procedure Expand_N_Object_Declaration (N : Node_Id);
kono
parents:
diff changeset
35 procedure Expand_N_Subtype_Indication (N : Node_Id);
kono
parents:
diff changeset
36 procedure Expand_N_Variant_Part (N : Node_Id);
kono
parents:
diff changeset
37 procedure Expand_N_Full_Type_Declaration (N : Node_Id);
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 procedure Expand_Previous_Access_Type (Def_Id : Entity_Id);
kono
parents:
diff changeset
40 -- For a full type declaration that contains tasks, or that is a task,
kono
parents:
diff changeset
41 -- check whether there exists an access type whose designated type is an
kono
parents:
diff changeset
42 -- incomplete declarations for the current composite type. If so, build the
kono
parents:
diff changeset
43 -- master for that access type, now that it is known to denote an object
kono
parents:
diff changeset
44 -- with tasks.
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 procedure Expand_Record_Extension (T : Entity_Id; Def : Node_Id);
kono
parents:
diff changeset
47 -- Add a field _parent in the extension part of the record
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 procedure Build_Discr_Checking_Funcs (N : Node_Id);
kono
parents:
diff changeset
50 -- Builds function which checks whether the component name is consistent
kono
parents:
diff changeset
51 -- with the current discriminants. N is the full type declaration node,
kono
parents:
diff changeset
52 -- and the discriminant checking functions are inserted after this node.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 function Build_Initialization_Call
kono
parents:
diff changeset
55 (Loc : Source_Ptr;
kono
parents:
diff changeset
56 Id_Ref : Node_Id;
kono
parents:
diff changeset
57 Typ : Entity_Id;
kono
parents:
diff changeset
58 In_Init_Proc : Boolean := False;
kono
parents:
diff changeset
59 Enclos_Type : Entity_Id := Empty;
kono
parents:
diff changeset
60 Discr_Map : Elist_Id := New_Elmt_List;
kono
parents:
diff changeset
61 With_Default_Init : Boolean := False;
kono
parents:
diff changeset
62 Constructor_Ref : Node_Id := Empty) return List_Id;
kono
parents:
diff changeset
63 -- Builds a call to the initialization procedure for the base type of Typ,
kono
parents:
diff changeset
64 -- passing it the object denoted by Id_Ref, plus additional parameters as
kono
parents:
diff changeset
65 -- appropriate for the type (the _Master, for task types, for example).
kono
parents:
diff changeset
66 -- Loc is the source location for the constructed tree. In_Init_Proc has
kono
parents:
diff changeset
67 -- to be set to True when the call is itself in an init proc in order to
kono
parents:
diff changeset
68 -- enable the use of discriminals. Enclos_Type is the enclosing type when
kono
parents:
diff changeset
69 -- initializing a component in an outer init proc, and it is used for
kono
parents:
diff changeset
70 -- various expansion cases including the case where Typ is a task type
kono
parents:
diff changeset
71 -- which is an array component, the indexes of the enclosing type are
kono
parents:
diff changeset
72 -- used to build the string that identifies each task at runtime.
kono
parents:
diff changeset
73 --
kono
parents:
diff changeset
74 -- Discr_Map is used to replace discriminants by their discriminals in
kono
parents:
diff changeset
75 -- expressions used to constrain record components. In the presence of
kono
parents:
diff changeset
76 -- entry families bounded by discriminants, protected type discriminants
kono
parents:
diff changeset
77 -- can appear within expressions in array bounds (not as stand-alone
kono
parents:
diff changeset
78 -- identifiers) and a general replacement is necessary.
kono
parents:
diff changeset
79 --
kono
parents:
diff changeset
80 -- Ada 2005 (AI-287): With_Default_Init is used to indicate that the
kono
parents:
diff changeset
81 -- initialization call corresponds to a default initialized component
kono
parents:
diff changeset
82 -- of an aggregate.
kono
parents:
diff changeset
83 --
kono
parents:
diff changeset
84 -- Constructor_Ref is a call to a constructor subprogram. It is currently
kono
parents:
diff changeset
85 -- used only to support C++ constructors.
kono
parents:
diff changeset
86
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
87 function Build_Variant_Record_Equality
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
88 (Typ : Entity_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
89 Body_Id : Entity_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
90 Param_Specs : List_Id) return Node_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
91 -- Build the body of the equality function Body_Id for the untagged variant
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 -- record Typ with the given parameters specification list.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
93
111
kono
parents:
diff changeset
94 function Freeze_Type (N : Node_Id) return Boolean;
kono
parents:
diff changeset
95 -- This function executes the freezing actions associated with the given
kono
parents:
diff changeset
96 -- freeze type node N and returns True if the node is to be deleted. We
kono
parents:
diff changeset
97 -- delete the node if it is present just for front end purpose and we don't
kono
parents:
diff changeset
98 -- want Gigi to see the node. This function can't delete the node itself
kono
parents:
diff changeset
99 -- since it would confuse any remaining processing of the freeze node.
kono
parents:
diff changeset
100
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 function Get_Simple_Init_Val
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
102 (Typ : Entity_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 N : Node_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 Size : Uint := No_Uint) return Node_Id;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105 -- Build an expression which represents the required initial value of type
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
106 -- Typ for which predicate Needs_Simple_Initialization is True. N is a node
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
107 -- whose source location used in the construction of the expression. Size
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108 -- is utilized as follows:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109 --
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
110 -- * If the size of the object to be initialized it is known, it should
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 -- be passed to the routine.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
112 --
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
113 -- * If the size is unknown or is zero, then the Esize of Typ is used as
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 -- an estimate of the size.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 --
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
116 -- The object size is needed to prepare a known invalid value for use by
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117 -- Normalize_Scalars. A call to this routine where Typ denotes a scalar
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
118 -- type is only valid when Normalize_Scalars or Initialize_Scalars is
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119 -- active, or if N is the node for a 'Invalid_Value attribute node.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
120
111
kono
parents:
diff changeset
121 procedure Init_Secondary_Tags
kono
parents:
diff changeset
122 (Typ : Entity_Id;
kono
parents:
diff changeset
123 Target : Node_Id;
kono
parents:
diff changeset
124 Init_Tags_List : List_Id;
kono
parents:
diff changeset
125 Stmts_List : List_Id;
kono
parents:
diff changeset
126 Fixed_Comps : Boolean := True;
kono
parents:
diff changeset
127 Variable_Comps : Boolean := True);
kono
parents:
diff changeset
128 -- Ada 2005 (AI-251): Initialize the tags of the secondary dispatch tables
kono
parents:
diff changeset
129 -- of Typ. The generated code referencing tag fields of Target is appended
kono
parents:
diff changeset
130 -- to Init_Tags_List and the code required to complete the elaboration of
kono
parents:
diff changeset
131 -- the dispatch tables of Typ is appended to Stmts_List. If Fixed_Comps is
kono
parents:
diff changeset
132 -- True then the tag components located at fixed positions of Target are
kono
parents:
diff changeset
133 -- initialized; if Variable_Comps is True then tags components located at
kono
parents:
diff changeset
134 -- variable positions of Target are initialized.
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 function Make_Tag_Assignment (N : Node_Id) return Node_Id;
kono
parents:
diff changeset
137 -- An object declaration that has an initialization for a tagged object
kono
parents:
diff changeset
138 -- requires a separate reassignment of the tag of the given type, because
kono
parents:
diff changeset
139 -- the expression may include an unchecked conversion. This tag assignment
kono
parents:
diff changeset
140 -- is inserted after the declaration, but if the object has an address
kono
parents:
diff changeset
141 -- clause the assignment is handled as part of the freezing of the object,
kono
parents:
diff changeset
142 -- see Check_Address_Clause.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 end Exp_Ch3;