1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2023, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 -- This package contains utility routines for the binder
28 with Namet
; use Namet
;
29 with Types
; use Types
;
33 function Is_Predefined_Unit
return Boolean;
34 -- Given a unit name stored in Name_Buffer with length in Name_Len,
35 -- returns True if this is the name of a predefined unit or a child of
36 -- a predefined unit (including the obsolescent renamings). This is used
37 -- in the preference selection (see Better_Choice in body of Binde).
39 function Is_Internal_Unit
return Boolean;
40 -- Given a unit name stored in Name_Buffer with length in Name_Len,
41 -- returns True if this is the name of an internal unit or a child of
42 -- an internal unit. Similar in usage to Is_Predefined_Unit.
44 -- Note: the following functions duplicate functionality in Uname, but
45 -- we want to avoid bringing Uname into the binder since it generates
46 -- to many unnecessary dependencies, and makes the binder too large.
48 function Uname_Less
(U1
, U2
: Unit_Name_Type
) return Boolean;
49 -- Determines if the unit name U1 is alphabetically before U2
51 procedure Write_Unit_Name
(U
: Unit_Name_Type
);
52 -- Output unit name with (body) or (spec) after as required. On return
53 -- Name_Len is set to the number of characters which were output.
59 -- The following type represents an iterator over all units that are
60 -- specified in the forced-elaboration-order file supplied by the binder
63 type Forced_Units_Iterator
is private;
65 function Has_Next
(Iter
: Forced_Units_Iterator
) return Boolean;
66 pragma Inline
(Has_Next
);
67 -- Determine whether iterator Iter has more units to examine
69 function Iterate_Forced_Units
return Forced_Units_Iterator
;
70 pragma Inline
(Iterate_Forced_Units
);
71 -- Obtain an iterator over all units in the forced-elaboration-order file
74 (Iter
: in out Forced_Units_Iterator
;
75 Unit_Name
: out Unit_Name_Type
;
76 Unit_Line
: out Logical_Line_Number
);
78 -- Return the current unit referenced by iterator Iter along with the
79 -- line number it appears on, and advance to the next available unit.
82 First_Line_Number
: constant Logical_Line_Number
:= No_Line_Number
+ 1;
84 type Forced_Units_Iterator
is record
85 Order
: String_Ptr
:= null;
86 -- A reference to the contents of the forced-elaboration-order file,
87 -- read in as a string.
89 Order_Index
: Positive := 1;
90 -- Index into the order string
92 Order_Line
: Logical_Line_Number
:= First_Line_Number
;
93 -- Logical line number within the order string
95 Unit_Line
: Logical_Line_Number
:= No_Line_Number
;
96 -- The logical line number of the current unit name within the order
99 Unit_Name
: Unit_Name_Type
:= No_Unit_Name
;
100 -- The current unit name parsed from the order string