annotate gcc/ada/exp_atag.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
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 _ A T A G --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2006-2019, 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 -- This package contains routines involved in the frontend expansion of
kono
parents:
diff changeset
27 -- subprograms of package Ada.Tags
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 with Types; use Types;
kono
parents:
diff changeset
30 with Uintp; use Uintp;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package Exp_Atag is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 -- Note: In all the subprograms of this package formal 'Loc' is the source
kono
parents:
diff changeset
35 -- location used in constructing the corresponding nodes.
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 procedure Build_Common_Dispatching_Select_Statements
kono
parents:
diff changeset
38 (Typ : Entity_Id;
kono
parents:
diff changeset
39 Stmts : List_Id);
kono
parents:
diff changeset
40 -- Ada 2005 (AI-345): Build statements that are common to the expansion of
kono
parents:
diff changeset
41 -- timed, asynchronous, and conditional select and append them to Stmts.
kono
parents:
diff changeset
42 -- Typ is the tagged type used for dispatching calls.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 procedure Build_CW_Membership
kono
parents:
diff changeset
45 (Loc : Source_Ptr;
kono
parents:
diff changeset
46 Obj_Tag_Node : in out Node_Id;
kono
parents:
diff changeset
47 Typ_Tag_Node : Node_Id;
kono
parents:
diff changeset
48 Related_Nod : Node_Id;
kono
parents:
diff changeset
49 New_Node : out Node_Id);
kono
parents:
diff changeset
50 -- Build code that returns true if Obj_Tag is in Typ_Tag'Class. Each DT
kono
parents:
diff changeset
51 -- has a table of ancestors and its inheritance level (Idepth). Obj is in
kono
parents:
diff changeset
52 -- Typ'Class if Typ'Tag is found in the table of ancestors referenced by
kono
parents:
diff changeset
53 -- Obj'Tag. Knowing the level of inheritance of both types, this can be
kono
parents:
diff changeset
54 -- computed in constant time by the formula:
kono
parents:
diff changeset
55 --
kono
parents:
diff changeset
56 -- Index := TSD (Obj'Tag).Idepth - TSD (Typ'Tag).Idepth;
kono
parents:
diff changeset
57 -- Index >= 0 and then TSD (Obj'Tag).Tags_Table (Index) = Typ'Tag
kono
parents:
diff changeset
58 --
kono
parents:
diff changeset
59 -- Related_Nod is the node where the implicit declaration of variable Index
kono
parents:
diff changeset
60 -- is inserted. Obj_Tag_Node is relocated.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 function Build_Get_Access_Level
kono
parents:
diff changeset
63 (Loc : Source_Ptr;
kono
parents:
diff changeset
64 Tag_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
65 -- Build code that retrieves the accessibility level of the tagged type.
kono
parents:
diff changeset
66 --
kono
parents:
diff changeset
67 -- Generates: TSD (Tag).Access_Level
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 function Build_Get_Alignment
kono
parents:
diff changeset
70 (Loc : Source_Ptr;
kono
parents:
diff changeset
71 Tag_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
72 -- Build code that retrieves the alignment of the tagged type.
kono
parents:
diff changeset
73 -- Generates: TSD (Tag).Alignment
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 procedure Build_Get_Predefined_Prim_Op_Address
kono
parents:
diff changeset
76 (Loc : Source_Ptr;
kono
parents:
diff changeset
77 Position : Uint;
kono
parents:
diff changeset
78 Tag_Node : in out Node_Id;
kono
parents:
diff changeset
79 New_Node : out Node_Id);
kono
parents:
diff changeset
80 -- Given a pointer to a dispatch table (T) and a position in the DT, build
kono
parents:
diff changeset
81 -- code that gets the address of the predefined virtual function stored in
kono
parents:
diff changeset
82 -- it (used for dispatching calls). Tag_Node is relocated.
kono
parents:
diff changeset
83 --
kono
parents:
diff changeset
84 -- Generates: Predefined_DT (Tag).D (Position);
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 procedure Build_Get_Prim_Op_Address
kono
parents:
diff changeset
87 (Loc : Source_Ptr;
kono
parents:
diff changeset
88 Typ : Entity_Id;
kono
parents:
diff changeset
89 Position : Uint;
kono
parents:
diff changeset
90 Tag_Node : in out Node_Id;
kono
parents:
diff changeset
91 New_Node : out Node_Id);
kono
parents:
diff changeset
92 -- Build code that retrieves the address of the virtual function stored in
kono
parents:
diff changeset
93 -- a given position of the dispatch table (used for dispatching calls).
kono
parents:
diff changeset
94 -- Tag_Node is relocated.
kono
parents:
diff changeset
95 --
kono
parents:
diff changeset
96 -- Generates: To_Tag (Tag).D (Position);
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 function Build_Get_Transportable
kono
parents:
diff changeset
99 (Loc : Source_Ptr;
kono
parents:
diff changeset
100 Tag_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
101 -- Build code that retrieves the value of the Transportable flag for
kono
parents:
diff changeset
102 -- the given Tag.
kono
parents:
diff changeset
103 --
kono
parents:
diff changeset
104 -- Generates: TSD (Tag).Transportable;
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 function Build_Inherit_CPP_Prims (Typ : Entity_Id) return List_Id;
kono
parents:
diff changeset
107 -- Build code that copies from Typ's parent the dispatch table slots of
kono
parents:
diff changeset
108 -- inherited primitives and updates slots of overridden primitives. The
kono
parents:
diff changeset
109 -- generated code handles primary and secondary dispatch tables of Typ.
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 function Build_Inherit_Predefined_Prims
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
112 (Loc : Source_Ptr;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
113 Old_Tag_Node : Node_Id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
114 New_Tag_Node : Node_Id;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
115 Num_Predef_Prims : Int) return Node_Id;
111
kono
parents:
diff changeset
116 -- Build code that inherits the predefined primitives of the parent.
kono
parents:
diff changeset
117 --
kono
parents:
diff changeset
118 -- Generates: Predefined_DT (New_T).D (All_Predefined_Prims) :=
kono
parents:
diff changeset
119 -- Predefined_DT (Old_T).D (All_Predefined_Prims);
kono
parents:
diff changeset
120 --
kono
parents:
diff changeset
121 -- Required to build non-library level dispatch tables. Also required
kono
parents:
diff changeset
122 -- when compiling without static dispatch tables support.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 function Build_Inherit_Prims
kono
parents:
diff changeset
125 (Loc : Source_Ptr;
kono
parents:
diff changeset
126 Typ : Entity_Id;
kono
parents:
diff changeset
127 Old_Tag_Node : Node_Id;
kono
parents:
diff changeset
128 New_Tag_Node : Node_Id;
kono
parents:
diff changeset
129 Num_Prims : Nat) return Node_Id;
kono
parents:
diff changeset
130 -- Build code that inherits Num_Prims user-defined primitives from the
kono
parents:
diff changeset
131 -- dispatch table of the parent type of tagged type Typ. It is used to
kono
parents:
diff changeset
132 -- copy the dispatch table of the parent in the following cases:
kono
parents:
diff changeset
133 -- a) case of derivations of CPP_Class types
kono
parents:
diff changeset
134 -- b) tagged types whose dispatch table is not statically allocated
kono
parents:
diff changeset
135 --
kono
parents:
diff changeset
136 -- Generates:
kono
parents:
diff changeset
137 -- New_Tag.Prims_Ptr (1 .. Num_Prims) :=
kono
parents:
diff changeset
138 -- Old_Tag.Prims_Ptr (1 .. Num_Prims);
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 function Build_Offset_To_Top
kono
parents:
diff changeset
141 (Loc : Source_Ptr;
kono
parents:
diff changeset
142 This_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
143 -- Build code that references the Offset_To_Top component of the primary
kono
parents:
diff changeset
144 -- or secondary dispatch table associated with This_Node. This subprogram
kono
parents:
diff changeset
145 -- provides a subset of the functionality provided by the function
kono
parents:
diff changeset
146 -- Offset_To_Top of package Ada.Tags, and is only called by the frontend
kono
parents:
diff changeset
147 -- when such routine is not available in a configurable runtime.
kono
parents:
diff changeset
148 --
kono
parents:
diff changeset
149 -- Generates:
kono
parents:
diff changeset
150 -- Offset_To_Top_Ptr
kono
parents:
diff changeset
151 -- (Address!(Tag_Ptr!(This).all) - Offset_To_Top_Offset).all
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 function Build_Set_Predefined_Prim_Op_Address
kono
parents:
diff changeset
154 (Loc : Source_Ptr;
kono
parents:
diff changeset
155 Tag_Node : Node_Id;
kono
parents:
diff changeset
156 Position : Uint;
kono
parents:
diff changeset
157 Address_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
158 -- Build code that saves the address of a virtual function in a given
kono
parents:
diff changeset
159 -- Position of the portion of the dispatch table associated with the
kono
parents:
diff changeset
160 -- predefined primitives of Tag. Called from Exp_Disp.Fill_DT_Entry
kono
parents:
diff changeset
161 -- and Exp_Disp.Fill_Secondary_DT_Entry. It is used for:
kono
parents:
diff changeset
162 -- 1) Filling the dispatch table of CPP_Class types.
kono
parents:
diff changeset
163 -- 2) Late overriding (see Check_Dispatching_Operation).
kono
parents:
diff changeset
164 --
kono
parents:
diff changeset
165 -- Generates: Predefined_DT (Tag).D (Position) := Value
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 function Build_Set_Prim_Op_Address
kono
parents:
diff changeset
168 (Loc : Source_Ptr;
kono
parents:
diff changeset
169 Typ : Entity_Id;
kono
parents:
diff changeset
170 Tag_Node : Node_Id;
kono
parents:
diff changeset
171 Position : Uint;
kono
parents:
diff changeset
172 Address_Node : Node_Id) return Node_Id;
kono
parents:
diff changeset
173 -- Build code that saves the address of a virtual function in a given
kono
parents:
diff changeset
174 -- Position of the dispatch table associated with the Tag. Called from
kono
parents:
diff changeset
175 -- Exp_Disp.Fill_DT_Entry and Exp_Disp.Fill_Secondary_DT_Entry. Used for:
kono
parents:
diff changeset
176 -- 1) Filling the dispatch table of CPP_Class types.
kono
parents:
diff changeset
177 -- 2) Late overriding (see Check_Dispatching_Operation).
kono
parents:
diff changeset
178 --
kono
parents:
diff changeset
179 -- Generates: Tag.D (Position) := Value
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 function Build_Set_Size_Function
kono
parents:
diff changeset
182 (Loc : Source_Ptr;
kono
parents:
diff changeset
183 Tag_Node : Node_Id;
kono
parents:
diff changeset
184 Size_Func : Entity_Id) return Node_Id;
kono
parents:
diff changeset
185 -- Build code that saves in the TSD the address of the function
kono
parents:
diff changeset
186 -- calculating _size of the object.
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 function Build_Set_Static_Offset_To_Top
kono
parents:
diff changeset
189 (Loc : Source_Ptr;
kono
parents:
diff changeset
190 Iface_Tag : Node_Id;
kono
parents:
diff changeset
191 Offset_Value : Node_Id) return Node_Id;
kono
parents:
diff changeset
192 -- Build code that initialize the Offset_To_Top component of the
kono
parents:
diff changeset
193 -- secondary dispatch table referenced by Iface_Tag.
kono
parents:
diff changeset
194 --
kono
parents:
diff changeset
195 -- Generates:
kono
parents:
diff changeset
196 -- Offset_To_Top_Ptr
kono
parents:
diff changeset
197 -- (Address!(Tag_Ptr!(This).all) - Offset_To_Top_Offset).all
kono
parents:
diff changeset
198 -- := Offset_Value
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 end Exp_Atag;