| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT COMPILER COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- B I N D O . U N I T S -- |
| 6 |
-- -- |
| 7 |
-- S p e c -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2019-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 |
-- For full architecture, see unit Bindo. |
| 27 |
|
| 28 |
-- The following unit contains facilities to collect all elaborable units in |
| 29 |
-- the bind and inspect their properties. |
| 30 |
|
| 31 |
with GNAT; use GNAT; |
| 32 |
with GNAT.Sets; use GNAT.Sets; |
| 33 |
|
| 34 |
package Bindo.Units is |
| 35 |
|
| 36 |
--------------- |
| 37 |
-- Unit sets -- |
| 38 |
--------------- |
| 39 |
|
| 40 |
function Hash_Unit (U_Id : Unit_Id) return Bucket_Range_Type; |
| 41 |
pragma Inline (Hash_Unit); |
| 42 |
-- Obtain the hash value of key U_Id |
| 43 |
|
| 44 |
package Unit_Sets is new Membership_Sets |
| 45 |
(Element_Type => Unit_Id, |
| 46 |
"=" => "=", |
| 47 |
Hash => Hash_Unit); |
| 48 |
|
| 49 |
procedure Collect_Elaborable_Units; |
| 50 |
pragma Inline (Collect_Elaborable_Units); |
| 51 |
-- Gather all units in the bind that require elaboration. The units are |
| 52 |
-- accessible via iterator Elaborable_Units_Iterator. |
| 53 |
|
| 54 |
function Corresponding_Body (U_Id : Unit_Id) return Unit_Id; |
| 55 |
pragma Inline (Corresponding_Body); |
| 56 |
-- Return the body of a spec unit U_Id |
| 57 |
|
| 58 |
function Corresponding_Spec (U_Id : Unit_Id) return Unit_Id; |
| 59 |
pragma Inline (Corresponding_Spec); |
| 60 |
-- Return the spec of a body unit U_Id |
| 61 |
|
| 62 |
function Corresponding_Unit (FNam : File_Name_Type) return Unit_Id; |
| 63 |
pragma Inline (Corresponding_Unit); |
| 64 |
-- Obtain the unit which corresponds to name FNam |
| 65 |
|
| 66 |
function Corresponding_Unit (UNam : Unit_Name_Type) return Unit_Id; |
| 67 |
pragma Inline (Corresponding_Unit); |
| 68 |
-- Obtain the unit which corresponds to name FNam |
| 69 |
|
| 70 |
function File_Name (U_Id : Unit_Id) return File_Name_Type; |
| 71 |
pragma Inline (File_Name); |
| 72 |
-- Obtain the file name of unit U_Id |
| 73 |
|
| 74 |
type Unit_Processor_Ptr is access procedure (U_Id : Unit_Id); |
| 75 |
|
| 76 |
procedure For_Each_Elaborable_Unit (Processor : Unit_Processor_Ptr); |
| 77 |
pragma Inline (For_Each_Elaborable_Unit); |
| 78 |
-- Invoke Processor on each elaborable unit in the bind |
| 79 |
|
| 80 |
procedure For_Each_Unit (Processor : Unit_Processor_Ptr); |
| 81 |
pragma Inline (For_Each_Unit); |
| 82 |
-- Invoke Processor on each unit in the bind |
| 83 |
|
| 84 |
function Has_No_Elaboration_Code (U_Id : Unit_Id) return Boolean; |
| 85 |
pragma Inline (Has_No_Elaboration_Code); |
| 86 |
-- Determine whether unit U_Id lacks elaboration code |
| 87 |
|
| 88 |
function Hash_Invocation_Signature |
| 89 |
(IS_Id : Invocation_Signature_Id) return Bucket_Range_Type; |
| 90 |
pragma Inline (Hash_Invocation_Signature); |
| 91 |
-- Obtain the hash value of key IS_Id |
| 92 |
|
| 93 |
function Invocation_Graph_Encoding |
| 94 |
(U_Id : Unit_Id) return Invocation_Graph_Encoding_Kind; |
| 95 |
pragma Inline (Invocation_Graph_Encoding); |
| 96 |
-- Obtain the encoding format used to capture invocation constructs and |
| 97 |
-- relations in the ALI file of unit U_Id. |
| 98 |
|
| 99 |
function Is_Dynamically_Elaborated (U_Id : Unit_Id) return Boolean; |
| 100 |
pragma Inline (Is_Dynamically_Elaborated); |
| 101 |
-- Determine whether unit U_Id was compiled using the dynamic elaboration |
| 102 |
-- model. |
| 103 |
|
| 104 |
function Is_Internal_Unit (U_Id : Unit_Id) return Boolean; |
| 105 |
pragma Inline (Is_Internal_Unit); |
| 106 |
-- Determine whether unit U_Id is internal |
| 107 |
|
| 108 |
function Is_Predefined_Unit (U_Id : Unit_Id) return Boolean; |
| 109 |
pragma Inline (Is_Predefined_Unit); |
| 110 |
-- Determine whether unit U_Id is predefined |
| 111 |
|
| 112 |
function Name (U_Id : Unit_Id) return Unit_Name_Type; |
| 113 |
pragma Inline (Name); |
| 114 |
-- Obtain the name of unit U_Id |
| 115 |
|
| 116 |
function Needs_Elaboration (IS_Id : Invocation_Signature_Id) return Boolean; |
| 117 |
pragma Inline (Needs_Elaboration); |
| 118 |
-- Determine whether invocation signature IS_Id belongs to a construct that |
| 119 |
-- appears in a unit which needs to be elaborated. |
| 120 |
|
| 121 |
function Needs_Elaboration (U_Id : Unit_Id) return Boolean; |
| 122 |
pragma Inline (Needs_Elaboration); |
| 123 |
-- Determine whether unit U_Id needs to be elaborated |
| 124 |
|
| 125 |
function Number_Of_Elaborable_Units return Natural; |
| 126 |
pragma Inline (Number_Of_Elaborable_Units); |
| 127 |
-- Obtain the number of units in the bind that need to be elaborated |
| 128 |
|
| 129 |
function Number_Of_Units return Natural; |
| 130 |
pragma Inline (Number_Of_Units); |
| 131 |
-- Obtain the number of units in the bind |
| 132 |
|
| 133 |
--------------- |
| 134 |
-- Iterators -- |
| 135 |
--------------- |
| 136 |
|
| 137 |
-- The following type represents an iterator over all units that need to be |
| 138 |
-- elaborated. |
| 139 |
|
| 140 |
type Elaborable_Units_Iterator is private; |
| 141 |
|
| 142 |
function Has_Next (Iter : Elaborable_Units_Iterator) return Boolean; |
| 143 |
pragma Inline (Has_Next); |
| 144 |
-- Determine whether iterator Iter has more units to examine |
| 145 |
|
| 146 |
function Iterate_Elaborable_Units return Elaborable_Units_Iterator; |
| 147 |
pragma Inline (Iterate_Elaborable_Units); |
| 148 |
-- Obtain an iterator over all units that need to be elaborated |
| 149 |
|
| 150 |
procedure Next |
| 151 |
(Iter : in out Elaborable_Units_Iterator; |
| 152 |
U_Id : out Unit_Id); |
| 153 |
pragma Inline (Next); |
| 154 |
-- Return the current unit referenced by iterator Iter and advance to the |
| 155 |
-- next available unit. |
| 156 |
|
| 157 |
----------------- |
| 158 |
-- Maintenance -- |
| 159 |
----------------- |
| 160 |
|
| 161 |
procedure Finalize_Units; |
| 162 |
pragma Inline (Finalize_Units); |
| 163 |
-- Destroy the internal structures of this unit |
| 164 |
|
| 165 |
procedure Initialize_Units; |
| 166 |
pragma Inline (Initialize_Units); |
| 167 |
-- Initialize the internal structures of this unit |
| 168 |
|
| 169 |
private |
| 170 |
type Elaborable_Units_Iterator is new Unit_Sets.Iterator; |
| 171 |
|
| 172 |
end Bindo.Units; |