fixing pr42337
[official-gcc.git] / gcc / ada / exp_atag.ads
blob1fa243cf91f67c11cbf250d24e5525ac953e4815
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- E X P _ A T A G --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2006-2009, 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 ------------------------------------------------------------------------------
26 -- This package contains routines involved in the frontend expansion of
27 -- subprograms of package Ada.Tags
29 with Types; use Types;
30 with Uintp; use Uintp;
32 package Exp_Atag is
34 -- Note: In all the subprograms of this package formal 'Loc' is the source
35 -- location used in constructing the corresponding nodes.
37 procedure Build_Common_Dispatching_Select_Statements
38 (Loc : Source_Ptr;
39 DT_Ptr : Entity_Id;
40 Stmts : List_Id);
41 -- Ada 2005 (AI-345): Generate statements that are common between timed,
42 -- asynchronous, and conditional select expansion.
44 procedure Build_CW_Membership
45 (Loc : Source_Ptr;
46 Obj_Tag_Node : in out Node_Id;
47 Typ_Tag_Node : Node_Id;
48 Related_Nod : Node_Id;
49 New_Node : out Node_Id);
50 -- Build code that returns true if Obj_Tag is in Typ_Tag'Class. Each DT
51 -- has a table of ancestors and its inheritance level (Idepth). Obj is in
52 -- Typ'Class if Typ'Tag is found in the table of ancestors referenced by
53 -- Obj'Tag. Knowing the level of inheritance of both types, this can be
54 -- computed in constant time by the formula:
56 -- Index := TSD (Obj'Tag).Idepth - TSD (Typ'Tag).Idepth;
57 -- Index > 0 and then TSD (Obj'Tag).Tags_Table (Index) = Typ'Tag
59 -- Related_Nod is the node where the implicit declaration of variable Index
60 -- is inserted. Obj_Tag_Node is relocated.
62 function Build_Get_Access_Level
63 (Loc : Source_Ptr;
64 Tag_Node : Node_Id) return Node_Id;
65 -- Build code that retrieves the accessibility level of the tagged type.
67 -- Generates: TSD (Tag).Access_Level
69 procedure Build_Get_Predefined_Prim_Op_Address
70 (Loc : Source_Ptr;
71 Position : Uint;
72 Tag_Node : in out Node_Id;
73 New_Node : out Node_Id);
74 -- Given a pointer to a dispatch table (T) and a position in the DT, build
75 -- code that gets the address of the predefined virtual function stored in
76 -- it (used for dispatching calls). Tag_Node is relocated.
78 -- Generates: Predefined_DT (Tag).D (Position);
80 procedure Build_Get_Prim_Op_Address
81 (Loc : Source_Ptr;
82 Typ : Entity_Id;
83 Position : Uint;
84 Tag_Node : in out Node_Id;
85 New_Node : out Node_Id);
86 -- Build code that retrieves the address of the virtual function stored in
87 -- a given position of the dispatch table (used for dispatching calls).
88 -- Tag_Node is relocated.
90 -- Generates: To_Tag (Tag).D (Position);
92 function Build_Get_Transportable
93 (Loc : Source_Ptr;
94 Tag_Node : Node_Id) return Node_Id;
95 -- Build code that retrieves the value of the Transportable flag for
96 -- the given Tag.
98 -- Generates: TSD (Tag).Transportable;
100 function Build_Inherit_Predefined_Prims
101 (Loc : Source_Ptr;
102 Old_Tag_Node : Node_Id;
103 New_Tag_Node : Node_Id) return Node_Id;
104 -- Build code that inherits the predefined primitives of the parent.
106 -- Generates: Predefined_DT (New_T).D (All_Predefined_Prims) :=
107 -- Predefined_DT (Old_T).D (All_Predefined_Prims);
109 -- Required to build non-library level dispatch tables. Also required
110 -- when compiling without static dispatch tables support.
112 function Build_Inherit_Prims
113 (Loc : Source_Ptr;
114 Typ : Entity_Id;
115 Old_Tag_Node : Node_Id;
116 New_Tag_Node : Node_Id;
117 Num_Prims : Nat) return Node_Id;
118 -- Build code that inherits Num_Prims user-defined primitives from the
119 -- dispatch table of the parent type of tagged type Typ. It is used to
120 -- copy the dispatch table of the parent in the following cases:
121 -- a) case of derivations of CPP_Class types
122 -- b) tagged types whose dispatch table is not statically allocated
124 -- Generates:
125 -- New_Tag.Prims_Ptr (1 .. Num_Prims) :=
126 -- Old_Tag.Prims_Ptr (1 .. Num_Prims);
128 function Build_Offset_To_Top
129 (Loc : Source_Ptr;
130 This_Node : Node_Id) return Node_Id;
131 -- Build code that references the Offset_To_Top component of the primary
132 -- or secondary dispatch table associated with This_Node. This subprogram
133 -- provides a subset of the functionality provided by the function
134 -- Offset_To_Top of package Ada.Tags, and is only called by the frontend
135 -- when such routine is not available in a configurable runtime.
137 -- Generates:
138 -- Offset_To_Top_Ptr
139 -- (Address!(Tag_Ptr!(This).all) - Offset_To_Top_Offset)
141 function Build_Set_Predefined_Prim_Op_Address
142 (Loc : Source_Ptr;
143 Tag_Node : Node_Id;
144 Position : Uint;
145 Address_Node : Node_Id) return Node_Id;
146 -- Build code that saves the address of a virtual function in a given
147 -- Position of the portion of the dispatch table associated with the
148 -- predefined primitives of Tag. Called from Exp_Disp.Fill_DT_Entry
149 -- and Exp_Disp.Fill_Secondary_DT_Entry. It is used for:
150 -- 1) Filling the dispatch table of CPP_Class types.
151 -- 2) Late overriding (see Check_Dispatching_Operation).
153 -- Generates: Predefined_DT (Tag).D (Position) := Value
155 function Build_Set_Prim_Op_Address
156 (Loc : Source_Ptr;
157 Typ : Entity_Id;
158 Tag_Node : Node_Id;
159 Position : Uint;
160 Address_Node : Node_Id) return Node_Id;
161 -- Build code that saves the address of a virtual function in a given
162 -- Position of the dispatch table associated with the Tag. Called from
163 -- Exp_Disp.Fill_DT_Entry and Exp_Disp.Fill_Secondary_DT_Entry. Used for:
164 -- 1) Filling the dispatch table of CPP_Class types.
165 -- 2) Late overriding (see Check_Dispatching_Operation).
167 -- Generates: Tag.D (Position) := Value
169 function Build_Set_Size_Function
170 (Loc : Source_Ptr;
171 Tag_Node : Node_Id;
172 Size_Func : Entity_Id) return Node_Id;
173 -- Build code that saves in the TSD the address of the function
174 -- calculating _size of the object.
176 function Build_Set_Static_Offset_To_Top
177 (Loc : Source_Ptr;
178 Iface_Tag : Node_Id;
179 Offset_Value : Node_Id) return Node_Id;
180 -- Build code that initialize the Offset_To_Top component of the
181 -- secondary dispatch table referenced by Iface_Tag.
183 -- Generates:
184 -- Offset_To_Top_Ptr
185 -- (Address!(Tag_Ptr!(This).all) - Offset_To_Top_Offset).all
186 -- := Offset_Value
188 end Exp_Atag;