mlib-tgt-vms-ia64.adb, [...] (Is_Interface): Change Ada bind file prefix on VMS from...
[gcc.git] / gcc / ada / butil.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- B U T I L --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2005, 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
26
27 with Namet; use Namet;
28 with Output; use Output;
29 with Targparm; use Targparm;
30
31 package body Butil is
32
33 ----------------------
34 -- Is_Internal_Unit --
35 ----------------------
36
37 -- Note: the reason we do not use the Fname package for this function
38 -- is that it would drag too much junk into the binder.
39
40 function Is_Internal_Unit return Boolean is
41 begin
42 return Is_Predefined_Unit
43 or else (Name_Len > 4
44 and then (Name_Buffer (1 .. 5) = "gnat%"
45 or else
46 Name_Buffer (1 .. 5) = "gnat."))
47 or else
48 (OpenVMS_On_Target
49 and then Name_Len > 3
50 and then (Name_Buffer (1 .. 4) = "dec%"
51 or else
52 Name_Buffer (1 .. 4) = "dec."));
53
54 end Is_Internal_Unit;
55
56 ------------------------
57 -- Is_Predefined_Unit --
58 ------------------------
59
60 -- Note: the reason we do not use the Fname package for this function
61 -- is that it would drag too much junk into the binder.
62
63 function Is_Predefined_Unit return Boolean is
64 begin
65 return (Name_Len > 3
66 and then Name_Buffer (1 .. 4) = "ada.")
67
68 or else (Name_Len > 6
69 and then Name_Buffer (1 .. 7) = "system.")
70
71 or else (Name_Len > 10
72 and then Name_Buffer (1 .. 11) = "interfaces.")
73
74 or else (Name_Len > 3
75 and then Name_Buffer (1 .. 4) = "ada%")
76
77 or else (Name_Len > 8
78 and then Name_Buffer (1 .. 9) = "calendar%")
79
80 or else (Name_Len > 9
81 and then Name_Buffer (1 .. 10) = "direct_io%")
82
83 or else (Name_Len > 10
84 and then Name_Buffer (1 .. 11) = "interfaces%")
85
86 or else (Name_Len > 13
87 and then Name_Buffer (1 .. 14) = "io_exceptions%")
88
89 or else (Name_Len > 12
90 and then Name_Buffer (1 .. 13) = "machine_code%")
91
92 or else (Name_Len > 13
93 and then Name_Buffer (1 .. 14) = "sequential_io%")
94
95 or else (Name_Len > 6
96 and then Name_Buffer (1 .. 7) = "system%")
97
98 or else (Name_Len > 7
99 and then Name_Buffer (1 .. 8) = "text_io%")
100
101 or else (Name_Len > 20
102 and then Name_Buffer (1 .. 21) = "unchecked_conversion%")
103
104 or else (Name_Len > 22
105 and then Name_Buffer (1 .. 23) = "unchecked_deallocation%")
106
107 or else (Name_Len > 4
108 and then Name_Buffer (1 .. 5) = "gnat%")
109
110 or else (Name_Len > 4
111 and then Name_Buffer (1 .. 5) = "gnat.");
112 end Is_Predefined_Unit;
113
114 ----------------
115 -- Uname_Less --
116 ----------------
117
118 function Uname_Less (U1, U2 : Unit_Name_Type) return Boolean is
119 begin
120 Get_Name_String (U1);
121
122 declare
123 U1_Name : constant String (1 .. Name_Len) :=
124 Name_Buffer (1 .. Name_Len);
125 Min_Length : Natural;
126
127 begin
128 Get_Name_String (U2);
129
130 if Name_Len < U1_Name'Last then
131 Min_Length := Name_Len;
132 else
133 Min_Length := U1_Name'Last;
134 end if;
135
136 for I in 1 .. Min_Length loop
137 if U1_Name (I) > Name_Buffer (I) then
138 return False;
139 elsif U1_Name (I) < Name_Buffer (I) then
140 return True;
141 end if;
142 end loop;
143
144 return U1_Name'Last < Name_Len;
145 end;
146 end Uname_Less;
147
148 ---------------------
149 -- Write_Unit_Name --
150 ---------------------
151
152 procedure Write_Unit_Name (U : Unit_Name_Type) is
153 begin
154 Get_Name_String (U);
155 Write_Str (Name_Buffer (1 .. Name_Len - 2));
156
157 if Name_Buffer (Name_Len) = 's' then
158 Write_Str (" (spec)");
159 else
160 Write_Str (" (body)");
161 end if;
162
163 Name_Len := Name_Len + 5;
164 end Write_Unit_Name;
165
166 end Butil;