| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- E I N F O . U T I L S -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2020-2025, 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 |
------------------------------------------------------------------------------ |
| 25 |
|
| 26 |
with Einfo.Entities; use Einfo.Entities; |
| 27 |
with Sinfo.Nodes; use Sinfo.Nodes; |
| 28 |
|
| 29 |
package Einfo.Utils is |
| 30 |
|
| 31 |
------------------------------------------- |
| 32 |
-- Aliases/Renamings of Renamed_Or_Alias -- |
| 33 |
------------------------------------------- |
| 34 |
|
| 35 |
-- See the comment in einfo.ads, "Renaming and Aliasing", which is somewhat |
| 36 |
-- incorrect. Each of the following calls [Set_]Renamed_Or_Alias. Alias and |
| 37 |
-- Renamed_Entity are fields of nonobject Entity_Ids, and the value of the |
| 38 |
-- field is Entity_Id. Alias is only for callable entities and subprogram |
| 39 |
-- types. We sometimes call Set_Renamed_Entity and then expect Alias to |
| 40 |
-- return the value set. Renamed_Object is a field of Entity_Ids that are |
| 41 |
-- objects, and it returns an expression, because you can rename things |
| 42 |
-- like "X.all(J).Y". Renamings of entries and subprograms can also be |
| 43 |
-- expressions, but those use different mechanisms; the fields here are not |
| 44 |
-- used. |
| 45 |
|
| 46 |
function Alias (N : Entity_Id) return Entity_Id with Inline; |
| 47 |
procedure Set_Alias (N : Entity_Id; Val : Entity_Id) with Inline; |
| 48 |
function Renamed_Entity (N : Entity_Id) return Entity_Id with Inline; |
| 49 |
procedure Set_Renamed_Entity (N : Entity_Id; Val : Entity_Id) with Inline; |
| 50 |
function Renamed_Object (N : Entity_Id) return Node_Id with Inline; |
| 51 |
procedure Set_Renamed_Object (N : Entity_Id; Val : Node_Id) with Inline; |
| 52 |
|
| 53 |
function Renamed_Entity_Or_Object (N : Entity_Id) return Node_Id |
| 54 |
with Inline; |
| 55 |
-- This getter is used when we don't know statically whether we want to |
| 56 |
-- call Renamed_Entity or Renamed_Object. |
| 57 |
|
| 58 |
procedure Set_Renamed_Object_Of_Possibly_Void |
| 59 |
(N : Entity_Id; Val : Node_Id) with Inline; |
| 60 |
-- Set_Renamed_Object doesn't allow Void; this is used in the rare cases |
| 61 |
-- where we set the field of an entity that might be Void. It might be a |
| 62 |
-- good idea to get rid of calls to this. |
| 63 |
|
| 64 |
------------------- |
| 65 |
-- Type Synonyms -- |
| 66 |
------------------- |
| 67 |
|
| 68 |
-- The following type synonyms are used to tidy up the function and |
| 69 |
-- procedure declarations that follow. Note that E and N have predicates |
| 70 |
-- ensuring the correct kind; we use Entity_Id or Node_Id when the |
| 71 |
-- predicates can't be satisfied. |
| 72 |
|
| 73 |
subtype B is Boolean; |
| 74 |
subtype C is Component_Alignment_Kind; |
| 75 |
subtype E is N_Entity_Id; |
| 76 |
subtype F is Float_Rep_Kind; |
| 77 |
subtype M is Mechanism_Type; |
| 78 |
subtype N is Node_Id with Predicate => N /= Empty and then N not in E; |
| 79 |
subtype U is Uint; |
| 80 |
subtype R is Ureal; |
| 81 |
subtype L is Elist_Id; |
| 82 |
subtype S is List_Id; |
| 83 |
|
| 84 |
------------------------------- |
| 85 |
-- Classification Attributes -- |
| 86 |
------------------------------- |
| 87 |
|
| 88 |
-- These functions provide a convenient functional notation for testing |
| 89 |
-- whether an Ekind value belongs to a specified kind, for example the |
| 90 |
-- function Is_Elementary_Type tests if its argument is in Elementary_Kind. |
| 91 |
-- In some cases, the test is of an entity attribute (e.g. in the case of |
| 92 |
-- Is_Generic_Type where the Ekind does not provide the needed |
| 93 |
-- information). |
| 94 |
|
| 95 |
function Is_Access_Object_Type (Id : E) return B with Inline; |
| 96 |
function Is_Access_Type (Id : E) return B with Inline; |
| 97 |
function Is_Access_Protected_Subprogram_Type (Id : E) return B with Inline; |
| 98 |
function Is_Access_Subprogram_Type (Id : E) return B with Inline; |
| 99 |
function Is_Address_Compatible_Type (Id : E) return B with Inline; |
| 100 |
-- Check whether the type represents an address |
| 101 |
function Is_Aggregate_Type (Id : E) return B with Inline; |
| 102 |
function Is_Anonymous_Access_Type (Id : E) return B with Inline; |
| 103 |
function Is_Array_Type (Id : E) return B with Inline; |
| 104 |
function Is_Assignable (Id : E) return B with Inline; |
| 105 |
function Is_Class_Wide_Type (Id : E) return B with Inline; |
| 106 |
function Is_Composite_Type (Id : E) return B with Inline; |
| 107 |
function Is_Concurrent_Body (Id : E) return B with Inline; |
| 108 |
function Is_Concurrent_Type (Id : E) return B with Inline; |
| 109 |
function Is_Decimal_Fixed_Point_Type (Id : E) return B with Inline; |
| 110 |
function Is_Digits_Type (Id : E) return B with Inline; |
| 111 |
function Is_Discrete_Or_Fixed_Point_Type (Id : E) return B with Inline; |
| 112 |
function Is_Discrete_Type (Id : E) return B with Inline; |
| 113 |
function Is_Elementary_Type (Id : E) return B with Inline; |
| 114 |
function Is_Entry (Id : E) return B with Inline; |
| 115 |
function Is_Enumeration_Type (Id : E) return B with Inline; |
| 116 |
function Is_Fixed_Point_Type (Id : E) return B with Inline; |
| 117 |
function Is_Floating_Point_Type (Id : E) return B with Inline; |
| 118 |
function Is_Formal (Id : E) return B with Inline; |
| 119 |
function Is_Formal_Object (Id : E) return B with Inline; |
| 120 |
function Is_Generic_Subprogram (Id : E) return B with Inline; |
| 121 |
function Is_Generic_Unit (Id : E) return B with Inline; |
| 122 |
function Is_Ghost_Entity (Id : E) return B with Inline; |
| 123 |
function Is_Incomplete_Or_Private_Type (Id : E) return B with Inline; |
| 124 |
function Is_Incomplete_Type (Id : E) return B with Inline; |
| 125 |
function Is_Integer_Type (Id : E) return B with Inline; |
| 126 |
function Is_Modular_Integer_Type (Id : E) return B with Inline; |
| 127 |
function Is_Named_Access_Type (Id : E) return B with Inline; |
| 128 |
function Is_Named_Number (Id : E) return B with Inline; |
| 129 |
function Is_Numeric_Type (Id : E) return B with Inline; |
| 130 |
function Is_Object (Id : E) return B with Inline; |
| 131 |
function Is_Ordinary_Fixed_Point_Type (Id : E) return B with Inline; |
| 132 |
function Is_Overloadable (Id : E) return B with Inline; |
| 133 |
function Is_Private_Type (Id : E) return B with Inline; |
| 134 |
function Is_Protected_Type (Id : E) return B with Inline; |
| 135 |
function Is_Real_Type (Id : E) return B with Inline; |
| 136 |
function Is_Record_Type (Id : E) return B with Inline; |
| 137 |
function Is_Scalar_Type (Id : E) return B with Inline; |
| 138 |
function Is_Signed_Integer_Type (Id : E) return B with Inline; |
| 139 |
function Is_Subprogram (Id : E) return B with Inline; |
| 140 |
function Is_Subprogram_Or_Entry (Id : E) return B with Inline; |
| 141 |
function Is_Subprogram_Or_Generic_Subprogram (Id : E) return B with Inline; |
| 142 |
function Is_Task_Type (Id : E) return B with Inline; |
| 143 |
function Is_Type (Id : E) return B with Inline; |
| 144 |
|
| 145 |
------------------------------------- |
| 146 |
-- Synthesized Attribute Functions -- |
| 147 |
------------------------------------- |
| 148 |
|
| 149 |
-- The functions in this section synthesize attributes from the tree, |
| 150 |
-- so they do not correspond to defined fields in the entity itself. |
| 151 |
|
| 152 |
function Address_Clause (Id : E) return Node_Id with Inline; |
| 153 |
function Aft_Value (Id : E) return U; |
| 154 |
function Alignment_Clause (Id : E) return Node_Id with Inline; |
| 155 |
function Base_Type (Id : E) return E with Inline; |
| 156 |
function Declaration_Node (Id : E) return Node_Id; |
| 157 |
function Designated_Type (Id : E) return E; |
| 158 |
function Entry_Index_Type (Id : E) return E; |
| 159 |
function First_Component (Id : E) return Entity_Id; |
| 160 |
function First_Component_Or_Discriminant (Id : E) return Entity_Id; |
| 161 |
function First_Formal (Id : E) return Entity_Id; |
| 162 |
function First_Formal_With_Extras (Id : E) return Entity_Id; |
| 163 |
|
| 164 |
function Float_Rep |
| 165 |
(N : Entity_Id) return F with Inline, Pre => |
| 166 |
N in E_Void_Id |
| 167 |
| Float_Kind_Id; |
| 168 |
procedure Set_Float_Rep |
| 169 |
(Ignore_N : Entity_Id; Ignore_Val : F) with Inline, Pre => |
| 170 |
Ignore_N in E_Void_Id |
| 171 |
| Float_Kind_Id; |
| 172 |
|
| 173 |
function Has_Attach_Handler (Id : E) return B; |
| 174 |
function Has_DIC (Id : E) return B; |
| 175 |
function Has_Entries (Id : E) return B; |
| 176 |
function Has_Foreign_Convention (Id : E) return B with Inline; |
| 177 |
function Has_Interrupt_Handler (Id : E) return B; |
| 178 |
function Has_Invariants (Id : E) return B; |
| 179 |
function Has_Limited_View (Id : E) return B; |
| 180 |
function Has_Non_Limited_View (Id : E) return B with Inline; |
| 181 |
function Has_Non_Null_Abstract_State (Id : E) return B; |
| 182 |
function Has_Non_Null_Visible_Refinement (Id : E) return B; |
| 183 |
function Has_Null_Abstract_State (Id : E) return B; |
| 184 |
function Has_Null_Visible_Refinement (Id : E) return B; |
| 185 |
function Implementation_Base_Type (Id : E) return E; |
| 186 |
function Is_Boolean_Type (Id : E) return B with Inline; |
| 187 |
function Is_Constant_Object (Id : E) return B with Inline; |
| 188 |
function Is_Controlled (Id : E) return B with Inline; |
| 189 |
function Is_Discriminal (Id : E) return B with Inline; |
| 190 |
function Is_Dynamic_Scope (Id : E) return B; |
| 191 |
function Is_Elaboration_Target (Id : E) return B; |
| 192 |
function Is_External_State (Id : E) return B; |
| 193 |
function Is_Full_Access (Id : E) return B with Inline; |
| 194 |
function Is_Null_State (Id : E) return B; |
| 195 |
function Is_Package_Or_Generic_Package (Id : E) return B with Inline; |
| 196 |
function Is_Packed_Array (Id : E) return B with Inline; |
| 197 |
function Is_Prival (Id : E) return B with Inline; |
| 198 |
function Is_Protected_Component (Id : E) return B with Inline; |
| 199 |
function Is_Protected_Interface (Id : E) return B; |
| 200 |
function Is_Protected_Record_Type (Id : E) return B with Inline; |
| 201 |
function Is_Standard_Character_Type (Id : E) return B; |
| 202 |
function Is_Standard_String_Type (Id : E) return B; |
| 203 |
function Is_String_Type (Id : E) return B with Inline; |
| 204 |
function Is_Synchronized_Interface (Id : E) return B; |
| 205 |
function Is_Synchronized_State (Id : E) return B; |
| 206 |
function Is_Task_Interface (Id : E) return B; |
| 207 |
function Is_Task_Record_Type (Id : E) return B with Inline; |
| 208 |
function Is_Wrapper_Package (Id : E) return B with Inline; |
| 209 |
function Last_Formal (Id : E) return Entity_Id; |
| 210 |
function Machine_Emax_Value (Id : E) return U; |
| 211 |
function Machine_Emin_Value (Id : E) return U; |
| 212 |
function Machine_Mantissa_Value (Id : E) return U; |
| 213 |
function Machine_Radix_Value (Id : E) return U; |
| 214 |
function Model_Emin_Value (Id : E) return U; |
| 215 |
function Model_Epsilon_Value (Id : E) return R; |
| 216 |
function Model_Mantissa_Value (Id : E) return U; |
| 217 |
function Model_Small_Value (Id : E) return R; |
| 218 |
function Next_Component (Id : E) return Entity_Id; |
| 219 |
function Next_Component_Or_Discriminant (Id : E) return Entity_Id; |
| 220 |
function Next_Discriminant (Id : E) return Entity_Id; |
| 221 |
function Next_Formal (Id : E) return Entity_Id; |
| 222 |
function Next_Formal_With_Extras (Id : E) return Entity_Id; |
| 223 |
function Next_Index (Id : N) return Node_Id; |
| 224 |
function Next_Literal (Id : E) return Entity_Id; |
| 225 |
function Next_Stored_Discriminant (Id : E) return Entity_Id; |
| 226 |
function Number_Dimensions (Id : E) return Pos; |
| 227 |
function Number_Entries (Id : E) return Nat; |
| 228 |
function Number_Formals (Id : E) return Nat; |
| 229 |
function Object_Size_Clause (Id : E) return Node_Id; |
| 230 |
function Parameter_Mode (Id : E) return Formal_Kind; |
| 231 |
function Partial_Refinement_Constituents (Id : E) return L; |
| 232 |
function Primitive_Operations (Id : E) return L; |
| 233 |
function Root_Type (Id : E) return E; |
| 234 |
function Safe_Emax_Value (Id : E) return U; |
| 235 |
function Safe_First_Value (Id : E) return R; |
| 236 |
function Safe_Last_Value (Id : E) return R; |
| 237 |
function Size_Clause (Id : E) return Node_Id with Inline; |
| 238 |
function Stream_Size_Clause (Id : E) return N with Inline; |
| 239 |
function Type_High_Bound (Id : E) return N with Inline; |
| 240 |
function Type_Low_Bound (Id : E) return N with Inline; |
| 241 |
function Underlying_Type (Id : E) return Entity_Id; |
| 242 |
|
| 243 |
function Scope_Depth (Id : Scope_Kind_Id) return U with Inline; |
| 244 |
function Scope_Depth_Set (Id : Scope_Kind_Id) return B with Inline; |
| 245 |
|
| 246 |
function Scope_Depth_Default_0 (Id : Scope_Kind_Id) return U; |
| 247 |
-- In rare cases, the Scope_Depth_Value (queried by Scope_Depth) is |
| 248 |
-- not correctly set before querying it; this may be used instead of |
| 249 |
-- Scope_Depth in such cases. It returns Uint_0 if the Scope_Depth_Value |
| 250 |
-- has not been set. See documentation in Einfo. |
| 251 |
|
| 252 |
------------------------------------------ |
| 253 |
-- Type Representation Attribute Fields -- |
| 254 |
------------------------------------------ |
| 255 |
|
| 256 |
function Known_Alignment (E : Entity_Id) return B with Inline; |
| 257 |
procedure Reinit_Alignment (Id : E) with Inline; |
| 258 |
procedure Copy_Alignment (To, From : E); |
| 259 |
|
| 260 |
function Known_Component_Bit_Offset (E : Entity_Id) return B with Inline; |
| 261 |
function Known_Static_Component_Bit_Offset (E : Entity_Id) return B |
| 262 |
with Inline; |
| 263 |
|
| 264 |
function Known_Component_Size (E : Entity_Id) return B with Inline; |
| 265 |
function Known_Static_Component_Size (E : Entity_Id) return B with Inline; |
| 266 |
|
| 267 |
function Known_Esize (E : Entity_Id) return B with Inline; |
| 268 |
function Known_Static_Esize (E : Entity_Id) return B with Inline; |
| 269 |
procedure Reinit_Esize (Id : E) with Inline; |
| 270 |
procedure Copy_Esize (To, From : E); |
| 271 |
|
| 272 |
function Known_Normalized_First_Bit (E : Entity_Id) return B with Inline; |
| 273 |
function Known_Static_Normalized_First_Bit (E : Entity_Id) return B |
| 274 |
with Inline; |
| 275 |
|
| 276 |
function Known_Normalized_Position (E : Entity_Id) return B with Inline; |
| 277 |
function Known_Static_Normalized_Position (E : Entity_Id) return B |
| 278 |
with Inline; |
| 279 |
|
| 280 |
function Known_RM_Size (E : Entity_Id) return B with Inline; |
| 281 |
function Known_Static_RM_Size (E : Entity_Id) return B with Inline; |
| 282 |
procedure Reinit_RM_Size (Id : E) with Inline; |
| 283 |
procedure Copy_RM_Size (To, From : E); |
| 284 |
|
| 285 |
-- NOTE: "known" here does not mean "known at compile time". It means that |
| 286 |
-- the compiler has computed the value of the field (either by default, or |
| 287 |
-- by noting some representation clauses), and the field has not been |
| 288 |
-- reinitialized. |
| 289 |
-- |
| 290 |
-- We document the Esize functions here; the others above are analogous: |
| 291 |
-- |
| 292 |
-- Known_Esize: True if Set_Esize has been called without a subsequent |
| 293 |
-- Reinit_Esize. |
| 294 |
-- |
| 295 |
-- Known_Static_Esize: True if Known_Esize and the Esize is known at |
| 296 |
-- compile time. (We're not using "static" in the Ada RM sense here. We |
| 297 |
-- are using it to mean "known at compile time".) |
| 298 |
-- |
| 299 |
-- Reinit_Esize: Set the Esize field to its initial unknown state. |
| 300 |
-- |
| 301 |
-- Copy_Esize: Copies the Esize from From to To; Known_Esize (From) may |
| 302 |
-- be False, in which case Known_Esize (To) becomes False. |
| 303 |
-- |
| 304 |
-- Esize: This is the normal automatically-generated getter for Esize, |
| 305 |
-- declared elsewhere. Returns No_Uint if not Known_Esize. |
| 306 |
-- |
| 307 |
-- Set_Esize: This is the normal automatically-generated setter for |
| 308 |
-- Esize. After a call to this, Known_Esize is True. It is an error |
| 309 |
-- to call this with a No_Uint value. |
| 310 |
-- |
| 311 |
-- Normally, we call Set_Esize first, and then query Esize (and similarly |
| 312 |
-- for other fields). However in some cases, we need to check Known_Esize |
| 313 |
-- before calling Esize, because the code is written in such a way that we |
| 314 |
-- don't know whether Set_Esize has already been called. |
| 315 |
-- |
| 316 |
-- In two cases, Known_Static_Esize and Known_Static_RM_Size, there is one |
| 317 |
-- more consideration, which is that we always return False for generic |
| 318 |
-- types. Within a template, the size can look Known_Static, because of the |
| 319 |
-- fake size values we put in template types, but they are not really |
| 320 |
-- Known_Static and anyone testing if they are Known_Static within the |
| 321 |
-- template should get False as a result to prevent incorrect assumptions. |
| 322 |
|
| 323 |
--------------------------------------------------------- |
| 324 |
-- Procedures for setting multiple of the above fields -- |
| 325 |
--------------------------------------------------------- |
| 326 |
|
| 327 |
procedure Reinit_Component_Location (Id : E); |
| 328 |
-- Initializes all fields describing the location of a component |
| 329 |
-- (Normalized_Position, Component_Bit_Offset, Normalized_First_Bit, |
| 330 |
-- Esize) to all be Unknown. |
| 331 |
|
| 332 |
procedure Init_Size (Id : E; V : Int); |
| 333 |
-- Initialize both the Esize and RM_Size fields of E to V |
| 334 |
|
| 335 |
procedure Reinit_Size_Align (Id : E); |
| 336 |
-- This procedure initializes both size fields and the alignment |
| 337 |
-- field to all be Unknown. |
| 338 |
|
| 339 |
procedure Reinit_Object_Size_Align (Id : E); |
| 340 |
-- Same as Reinit_Size_Align except RM_Size field (which is only for types) |
| 341 |
-- is unaffected. |
| 342 |
|
| 343 |
--------------------------------------------------- |
| 344 |
-- Access to Subprograms in Subprograms_For_Type -- |
| 345 |
--------------------------------------------------- |
| 346 |
|
| 347 |
-- Now that we have variable-sized nodes, it might be possible to replace |
| 348 |
-- the following with regular fields, and get rid of the flags used to mark |
| 349 |
-- these kinds of subprograms. |
| 350 |
|
| 351 |
function Is_Partial_DIC_Procedure (Id : E) return B; |
| 352 |
|
| 353 |
function DIC_Procedure (Id : E) return Entity_Id; |
| 354 |
function Partial_DIC_Procedure (Id : E) return Entity_Id; |
| 355 |
function Invariant_Procedure (Id : E) return Entity_Id; |
| 356 |
function Partial_Invariant_Procedure (Id : E) return Entity_Id; |
| 357 |
function Predicate_Function (Id : E) return Entity_Id; |
| 358 |
|
| 359 |
procedure Set_DIC_Procedure (Id : E; V : E); |
| 360 |
procedure Set_Partial_DIC_Procedure (Id : E; V : E); |
| 361 |
procedure Set_Invariant_Procedure (Id : E; V : E); |
| 362 |
procedure Set_Partial_Invariant_Procedure (Id : E; V : E); |
| 363 |
procedure Set_Predicate_Function (Id : E; V : E); |
| 364 |
|
| 365 |
--------------- |
| 366 |
-- Iterators -- |
| 367 |
--------------- |
| 368 |
|
| 369 |
-- Next_xxx (obj) is equivalent to obj := Next_xxx (obj) |
| 370 |
|
| 371 |
procedure Next_Component (N : in out Node_Id) with Inline; |
| 372 |
procedure Next_Component_Or_Discriminant (N : in out Node_Id) with Inline; |
| 373 |
procedure Next_Discriminant (N : in out Node_Id) with Inline; |
| 374 |
procedure Next_Formal (N : in out Node_Id) with Inline; |
| 375 |
procedure Next_Formal_With_Extras (N : in out Node_Id) with Inline; |
| 376 |
procedure Next_Index (N : in out Node_Id) with Inline; |
| 377 |
procedure Next_Inlined_Subprogram (N : in out Node_Id) with Inline; |
| 378 |
procedure Next_Literal (N : in out Node_Id) with Inline; |
| 379 |
procedure Next_Stored_Discriminant (N : in out Node_Id) with Inline; |
| 380 |
|
| 381 |
--------------------------- |
| 382 |
-- Testing Warning Flags -- |
| 383 |
--------------------------- |
| 384 |
|
| 385 |
-- These routines are to be used rather than testing flags Warnings_Off, |
| 386 |
-- Has_Pragma_Unmodified, Has_Pragma_Unreferenced. They deal with setting |
| 387 |
-- the flags Warnings_Off_Used[_Unmodified|Unreferenced] for later access. |
| 388 |
|
| 389 |
function Has_Warnings_Off (E : Entity_Id) return Boolean; |
| 390 |
-- If Warnings_Off is set on E, then returns True and also sets the flag |
| 391 |
-- Warnings_Off_Used on E. If Warnings_Off is not set on E, returns False |
| 392 |
-- and has no side effect. |
| 393 |
|
| 394 |
function Has_Unmodified (E : Entity_Id) return Boolean; |
| 395 |
-- If flag Has_Pragma_Unmodified is set on E, returns True with no side |
| 396 |
-- effects. Otherwise if Warnings_Off is set on E, returns True and also |
| 397 |
-- sets the flag Warnings_Off_Used_Unmodified on E. If neither of the flags |
| 398 |
-- Warnings_Off nor Has_Pragma_Unmodified is set, returns False with no |
| 399 |
-- side effects. |
| 400 |
|
| 401 |
function Has_Unreferenced (E : Entity_Id) return Boolean; |
| 402 |
-- If flag Has_Pragma_Unreferenced is set on E, returns True with no side |
| 403 |
-- effects. Otherwise if Warnings_Off is set on E, returns True and also |
| 404 |
-- sets the flag Warnings_Off_Used_Unreferenced on E. If neither of the |
| 405 |
-- flags Warnings_Off nor Has_Pragma_Unreferenced is set, returns False |
| 406 |
-- with no side effects. |
| 407 |
|
| 408 |
---------------------------------------------- |
| 409 |
-- Subprograms for Accessing Rep Item Chain -- |
| 410 |
---------------------------------------------- |
| 411 |
|
| 412 |
-- The First_Rep_Item field of every entity points to a linked list (linked |
| 413 |
-- through Next_Rep_Item) of representation pragmas, attribute definition |
| 414 |
-- clauses, representation clauses, and aspect specifications that apply to |
| 415 |
-- the item. Note that in the case of types, it is assumed that any such |
| 416 |
-- rep items for a base type also apply to all subtypes. This is achieved |
| 417 |
-- by having the chain for subtypes link onto the chain for the base type, |
| 418 |
-- so that new entries for the subtype are added at the start of the chain. |
| 419 |
-- |
| 420 |
-- Note: aspect specification nodes are linked only when evaluation of the |
| 421 |
-- expression is deferred to the freeze point. For further details see |
| 422 |
-- Sem_Ch13.Analyze_Aspect_Specifications. |
| 423 |
|
| 424 |
function Get_Attribute_Definition_Clause |
| 425 |
(E : Entity_Id; |
| 426 |
Id : Attribute_Id) return Node_Id; |
| 427 |
-- Searches the Rep_Item chain for a given entity E, for an instance of an |
| 428 |
-- attribute definition clause with the given attribute Id. If found, the |
| 429 |
-- value returned is the N_Attribute_Definition_Clause node, otherwise |
| 430 |
-- Empty is returned. |
| 431 |
|
| 432 |
-- WARNING: There is a matching C declaration of this subprogram in fe.h |
| 433 |
|
| 434 |
function Get_Pragma (E : Entity_Id; Id : Pragma_Id) return Node_Id; |
| 435 |
-- Searches the Rep_Item chain of entity E, for an instance of a pragma |
| 436 |
-- with the given pragma Id. If found, the value returned is the N_Pragma |
| 437 |
-- node, otherwise Empty is returned. The following contract pragmas that |
| 438 |
-- appear in N_Contract nodes are also handled by this routine: |
| 439 |
-- Abstract_State |
| 440 |
-- Always_Terminates |
| 441 |
-- Async_Readers |
| 442 |
-- Async_Writers |
| 443 |
-- Attach_Handler |
| 444 |
-- Constant_After_Elaboration |
| 445 |
-- Contract_Cases |
| 446 |
-- Depends |
| 447 |
-- Effective_Reads |
| 448 |
-- Effective_Writes |
| 449 |
-- Exceptional_Cases |
| 450 |
-- Exit_Cases |
| 451 |
-- Extensions_Visible |
| 452 |
-- Global |
| 453 |
-- Initial_Condition |
| 454 |
-- Initializes |
| 455 |
-- Interrupt_Handler |
| 456 |
-- No_Caching |
| 457 |
-- Part_Of |
| 458 |
-- Precondition |
| 459 |
-- Postcondition |
| 460 |
-- Refined_Depends |
| 461 |
-- Refined_Global |
| 462 |
-- Refined_Post |
| 463 |
-- Refined_State |
| 464 |
-- Side_Effects |
| 465 |
-- Subprogram_Variant |
| 466 |
-- Test_Case |
| 467 |
-- Volatile_Function |
| 468 |
|
| 469 |
function Get_Class_Wide_Pragma |
| 470 |
(E : Entity_Id; |
| 471 |
Id : Pragma_Id) return Node_Id; |
| 472 |
-- Examine Rep_Item chain to locate a classwide pre- or postcondition of a |
| 473 |
-- primitive operation. Returns Empty if not present. |
| 474 |
|
| 475 |
function Get_Record_Representation_Clause (E : Entity_Id) return Node_Id; |
| 476 |
-- Searches the Rep_Item chain for a given entity E, for a record |
| 477 |
-- representation clause, and if found, returns it. Returns Empty |
| 478 |
-- if no such clause is found. |
| 479 |
|
| 480 |
function Present_In_Rep_Item (E : Entity_Id; N : Node_Id) return Boolean; |
| 481 |
-- Return True if N is present in the Rep_Item chain for a given entity E |
| 482 |
|
| 483 |
procedure Record_Rep_Item (E : Entity_Id; N : Node_Id); |
| 484 |
-- N is the node for a representation pragma, representation clause, an |
| 485 |
-- attribute definition clause, or an aspect specification that applies to |
| 486 |
-- entity E. This procedure links the node N onto the Rep_Item chain for |
| 487 |
-- entity E. Note that it is an error to call this procedure with E being |
| 488 |
-- overloadable, and N being a pragma that applies to multiple overloadable |
| 489 |
-- entities (Convention, Interface, Inline, Inline_Always, Import, Export, |
| 490 |
-- External). This is not allowed even in the case where the entity is not |
| 491 |
-- overloaded, since we can't rely on it being present in the overloaded |
| 492 |
-- case, it is not useful to have it present in the non-overloaded case. |
| 493 |
|
| 494 |
------------------------------- |
| 495 |
-- Miscellaneous Subprograms -- |
| 496 |
------------------------------- |
| 497 |
|
| 498 |
procedure Append_Entity (Id : Entity_Id; Scop : Entity_Id); |
| 499 |
-- Add an entity to the list of entities declared in the scope Scop |
| 500 |
|
| 501 |
function Get_Full_View (T : Entity_Id) return Entity_Id; |
| 502 |
-- If T is an incomplete type and the full declaration has been seen, or |
| 503 |
-- is the name of a class_wide type whose root is incomplete, return the |
| 504 |
-- corresponding full declaration, else return T itself. |
| 505 |
|
| 506 |
function Is_Base_Type (Id : E) return B with Inline; |
| 507 |
-- Return True for a type entity and False for a subtype entity. Note that |
| 508 |
-- this returns True for nontypes. |
| 509 |
|
| 510 |
-- WARNING: There is a matching C declaration of this subprogram in fe.h |
| 511 |
|
| 512 |
function Is_Entity_Name (N : Node_Id) return Boolean with Inline; |
| 513 |
-- Test if the node N is the name of an entity (i.e. is an identifier, |
| 514 |
-- expanded name, or an attribute reference that returns an entity). |
| 515 |
|
| 516 |
-- WARNING: There is a matching C declaration of this subprogram in fe.h |
| 517 |
|
| 518 |
procedure Link_Entities (First, Second : Entity_Id); |
| 519 |
-- Link entities First and Second in one entity chain. |
| 520 |
-- |
| 521 |
-- NOTE: No updates are done to the First_Entity and Last_Entity fields |
| 522 |
-- of the scope. |
| 523 |
|
| 524 |
procedure Remove_Entity (Id : Entity_Id); |
| 525 |
-- Remove entity Id from the entity chain of its scope |
| 526 |
|
| 527 |
function Subtype_Kind (K : Entity_Kind) return Entity_Kind; |
| 528 |
-- Given an entity_kind K this function returns the entity_kind |
| 529 |
-- corresponding to subtype kind of the type represented by K. For |
| 530 |
-- example if K is E_Signed_Integer_Type then E_Signed_Integer_Subtype |
| 531 |
-- is returned. If K is already a subtype kind it itself is returned. An |
| 532 |
-- internal error is generated if no such correspondence exists for K. |
| 533 |
|
| 534 |
procedure Unlink_Next_Entity (Id : Entity_Id); |
| 535 |
-- Unchain entity Id's forward link within the entity chain of its scope |
| 536 |
|
| 537 |
function Is_Volatile (Id : E) return B; |
| 538 |
procedure Set_Is_Volatile (Id : E; V : B := True); |
| 539 |
-- Call [Set_]Is_Volatile_Type/Is_Volatile_Object as appropriate for the |
| 540 |
-- Ekind of Id. |
| 541 |
|
| 542 |
function Convention |
| 543 |
(N : Entity_Id) return Convention_Id renames Basic_Convention; |
| 544 |
procedure Set_Convention (E : Entity_Id; Val : Convention_Id); |
| 545 |
-- Same as Set_Basic_Convention, but with an extra check for access types. |
| 546 |
-- In particular, if E is an access-to-subprogram type, and Val is a |
| 547 |
-- foreign convention, then we set Can_Use_Internal_Rep to False on E. |
| 548 |
-- Also, if the Etype of E is set and is an anonymous access type with |
| 549 |
-- no convention set, this anonymous type inherits the convention of E. |
| 550 |
|
| 551 |
---------------------------------- |
| 552 |
-- Debugging Output Subprograms -- |
| 553 |
---------------------------------- |
| 554 |
|
| 555 |
procedure Write_Entity_Info (Id : Entity_Id; Prefix : String); |
| 556 |
-- A debugging procedure to write out information about an entity |
| 557 |
|
| 558 |
end Einfo.Utils; |