annotate gcc/ada/ali-util.adb @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- A L I . U T I L --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 with Debug; use Debug;
kono
parents:
diff changeset
27 with Binderr; use Binderr;
kono
parents:
diff changeset
28 with Opt; use Opt;
kono
parents:
diff changeset
29 with Output; use Output;
kono
parents:
diff changeset
30 with Osint; use Osint;
kono
parents:
diff changeset
31 with Scans; use Scans;
kono
parents:
diff changeset
32 with Scng;
kono
parents:
diff changeset
33 with Sinput.C;
kono
parents:
diff changeset
34 with Snames; use Snames;
kono
parents:
diff changeset
35 with Stringt;
kono
parents:
diff changeset
36 with Styleg;
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 with System.OS_Lib; use System.OS_Lib;
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 package body ALI.Util is
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 -- Empty procedures needed to instantiate Scng. Error procedures are
kono
parents:
diff changeset
43 -- empty, because we don't want to report any errors when computing
kono
parents:
diff changeset
44 -- a source checksum.
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 procedure Post_Scan;
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr);
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 procedure Error_Msg_S (Msg : String);
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 procedure Error_Msg_SC (Msg : String);
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure Error_Msg_SP (Msg : String);
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 -- Instantiation of Styleg, needed to instantiate Scng
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 package Style is new Styleg
kono
parents:
diff changeset
59 (Error_Msg, Error_Msg_S, Error_Msg_SC, Error_Msg_SP);
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 -- A Scanner is needed to get checksum of a source (procedure
kono
parents:
diff changeset
62 -- Get_File_Checksum).
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 package Scanner is new Scng
kono
parents:
diff changeset
65 (Post_Scan, Error_Msg, Error_Msg_S, Error_Msg_SC, Error_Msg_SP, Style);
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 type Header_Num is range 0 .. 1_000;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 function Hash (F : File_Name_Type) return Header_Num;
kono
parents:
diff changeset
70 -- Function used to compute hash of ALI file name
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 package Interfaces is new Simple_HTable (
kono
parents:
diff changeset
73 Header_Num => Header_Num,
kono
parents:
diff changeset
74 Element => Boolean,
kono
parents:
diff changeset
75 No_Element => False,
kono
parents:
diff changeset
76 Key => File_Name_Type,
kono
parents:
diff changeset
77 Hash => Hash,
kono
parents:
diff changeset
78 Equal => "=");
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 ---------------------
kono
parents:
diff changeset
81 -- Checksums_Match --
kono
parents:
diff changeset
82 ---------------------
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Checksums_Match (Checksum1, Checksum2 : Word) return Boolean is
kono
parents:
diff changeset
85 begin
kono
parents:
diff changeset
86 return Checksum1 = Checksum2 and then Checksum1 /= Checksum_Error;
kono
parents:
diff changeset
87 end Checksums_Match;
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 ---------------
kono
parents:
diff changeset
90 -- Error_Msg --
kono
parents:
diff changeset
91 ---------------
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr) is
kono
parents:
diff changeset
94 pragma Warnings (Off, Msg);
kono
parents:
diff changeset
95 pragma Warnings (Off, Flag_Location);
kono
parents:
diff changeset
96 begin
kono
parents:
diff changeset
97 null;
kono
parents:
diff changeset
98 end Error_Msg;
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 -----------------
kono
parents:
diff changeset
101 -- Error_Msg_S --
kono
parents:
diff changeset
102 -----------------
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Error_Msg_S (Msg : String) is
kono
parents:
diff changeset
105 pragma Warnings (Off, Msg);
kono
parents:
diff changeset
106 begin
kono
parents:
diff changeset
107 null;
kono
parents:
diff changeset
108 end Error_Msg_S;
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 ------------------
kono
parents:
diff changeset
111 -- Error_Msg_SC --
kono
parents:
diff changeset
112 ------------------
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 procedure Error_Msg_SC (Msg : String) is
kono
parents:
diff changeset
115 pragma Warnings (Off, Msg);
kono
parents:
diff changeset
116 begin
kono
parents:
diff changeset
117 null;
kono
parents:
diff changeset
118 end Error_Msg_SC;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 ------------------
kono
parents:
diff changeset
121 -- Error_Msg_SP --
kono
parents:
diff changeset
122 ------------------
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 procedure Error_Msg_SP (Msg : String) is
kono
parents:
diff changeset
125 pragma Warnings (Off, Msg);
kono
parents:
diff changeset
126 begin
kono
parents:
diff changeset
127 null;
kono
parents:
diff changeset
128 end Error_Msg_SP;
kono
parents:
diff changeset
129
kono
parents:
diff changeset
130 -----------------------
kono
parents:
diff changeset
131 -- Get_File_Checksum --
kono
parents:
diff changeset
132 -----------------------
kono
parents:
diff changeset
133
kono
parents:
diff changeset
134 function Get_File_Checksum (Fname : File_Name_Type) return Word is
kono
parents:
diff changeset
135 Full_Name : File_Name_Type;
kono
parents:
diff changeset
136 Source_Index : Source_File_Index;
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 begin
kono
parents:
diff changeset
139 Full_Name := Find_File (Fname, Osint.Source);
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 -- If we cannot find the file, then return an impossible checksum,
kono
parents:
diff changeset
142 -- impossible because checksums have the high order bit zero, so
kono
parents:
diff changeset
143 -- that checksums do not match.
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 if Full_Name = No_File then
kono
parents:
diff changeset
146 return Checksum_Error;
kono
parents:
diff changeset
147 end if;
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 Source_Index := Sinput.C.Load_File (Get_Name_String (Full_Name));
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 if Source_Index <= No_Source_File then
kono
parents:
diff changeset
152 return Checksum_Error;
kono
parents:
diff changeset
153 end if;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 Scanner.Initialize_Scanner (Source_Index);
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 -- Make sure that the project language reserved words are not
kono
parents:
diff changeset
158 -- recognized as reserved words, but as identifiers. The byte info for
kono
parents:
diff changeset
159 -- those names have been set if we are in gnatmake.
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 Set_Name_Table_Byte (Name_Project, 0);
kono
parents:
diff changeset
162 Set_Name_Table_Byte (Name_Extends, 0);
kono
parents:
diff changeset
163 Set_Name_Table_Byte (Name_External, 0);
kono
parents:
diff changeset
164 Set_Name_Table_Byte (Name_External_As_List, 0);
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 -- Scan the complete file to compute its checksum
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 loop
kono
parents:
diff changeset
169 Scanner.Scan;
kono
parents:
diff changeset
170 exit when Token = Tok_EOF;
kono
parents:
diff changeset
171 end loop;
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 return Scans.Checksum;
kono
parents:
diff changeset
174 end Get_File_Checksum;
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 ----------
kono
parents:
diff changeset
177 -- Hash --
kono
parents:
diff changeset
178 ----------
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 function Hash (F : File_Name_Type) return Header_Num is
kono
parents:
diff changeset
181 begin
kono
parents:
diff changeset
182 return Header_Num (Int (F) rem Header_Num'Range_Length);
kono
parents:
diff changeset
183 end Hash;
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 ---------------------------
kono
parents:
diff changeset
186 -- Initialize_ALI_Source --
kono
parents:
diff changeset
187 ---------------------------
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 procedure Initialize_ALI_Source is
kono
parents:
diff changeset
190 begin
kono
parents:
diff changeset
191 -- When (re)initializing ALI data structures the ALI user expects to
kono
parents:
diff changeset
192 -- get a fresh set of data structures. Thus we first need to erase the
kono
parents:
diff changeset
193 -- marks put in the name table by the previous set of ALI routine calls.
kono
parents:
diff changeset
194 -- This loop is empty and harmless the first time in.
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 for J in Source.First .. Source.Last loop
kono
parents:
diff changeset
197 Set_Name_Table_Int (Source.Table (J).Sfile, 0);
kono
parents:
diff changeset
198 Source.Table (J).Source_Found := False;
kono
parents:
diff changeset
199 end loop;
kono
parents:
diff changeset
200
kono
parents:
diff changeset
201 Source.Init;
kono
parents:
diff changeset
202 Interfaces.Reset;
kono
parents:
diff changeset
203 end Initialize_ALI_Source;
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 ---------------
kono
parents:
diff changeset
206 -- Post_Scan --
kono
parents:
diff changeset
207 ---------------
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 procedure Post_Scan is
kono
parents:
diff changeset
210 begin
kono
parents:
diff changeset
211 null;
kono
parents:
diff changeset
212 end Post_Scan;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 ----------------------
kono
parents:
diff changeset
215 -- Read_Withed_ALIs --
kono
parents:
diff changeset
216 ----------------------
kono
parents:
diff changeset
217
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
218 procedure Read_Withed_ALIs (Id : ALI_Id) is
111
kono
parents:
diff changeset
219 Afile : File_Name_Type;
kono
parents:
diff changeset
220 Text : Text_Buffer_Ptr;
kono
parents:
diff changeset
221 Idread : ALI_Id;
kono
parents:
diff changeset
222
kono
parents:
diff changeset
223 begin
kono
parents:
diff changeset
224 -- Process all dependent units
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 for U in ALIs.Table (Id).First_Unit .. ALIs.Table (Id).Last_Unit loop
kono
parents:
diff changeset
227 for
kono
parents:
diff changeset
228 W in Units.Table (U).First_With .. Units.Table (U).Last_With
kono
parents:
diff changeset
229 loop
kono
parents:
diff changeset
230 Afile := Withs.Table (W).Afile;
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 -- Only process if not a generic (Afile /= No_File) and if
kono
parents:
diff changeset
233 -- file has not been processed already.
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 if Afile /= No_File
kono
parents:
diff changeset
236 and then Get_Name_Table_Int (Afile) = 0
kono
parents:
diff changeset
237 then
kono
parents:
diff changeset
238 Text := Read_Library_Info (Afile);
kono
parents:
diff changeset
239
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
240 -- Unless in GNATprove mode, return with an error if source
111
kono
parents:
diff changeset
241 -- cannot be found. We used to skip this check when we did not
kono
parents:
diff changeset
242 -- compile library generics separately, but we now always do,
kono
parents:
diff changeset
243 -- so there is no special case here anymore.
kono
parents:
diff changeset
244
kono
parents:
diff changeset
245 if Text = null then
kono
parents:
diff changeset
246
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
247 if not GNATprove_Mode then
111
kono
parents:
diff changeset
248 Error_Msg_File_1 := Afile;
kono
parents:
diff changeset
249 Error_Msg_File_2 := Withs.Table (W).Sfile;
kono
parents:
diff changeset
250 Error_Msg ("{ not found, { must be compiled");
kono
parents:
diff changeset
251 Set_Name_Table_Int (Afile, Int (No_Unit_Id));
kono
parents:
diff changeset
252 return;
kono
parents:
diff changeset
253 end if;
kono
parents:
diff changeset
254
kono
parents:
diff changeset
255 else
kono
parents:
diff changeset
256 -- Enter in ALIs table
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 Idread :=
kono
parents:
diff changeset
259 Scan_ALI
kono
parents:
diff changeset
260 (F => Afile,
kono
parents:
diff changeset
261 T => Text,
kono
parents:
diff changeset
262 Ignore_ED => False,
kono
parents:
diff changeset
263 Err => False);
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 Free (Text);
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 if ALIs.Table (Idread).Compile_Errors
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
268 and then not GNATprove_Mode
111
kono
parents:
diff changeset
269 then
kono
parents:
diff changeset
270 Error_Msg_File_1 := Withs.Table (W).Sfile;
kono
parents:
diff changeset
271 Error_Msg ("{ had errors, must be fixed, and recompiled");
kono
parents:
diff changeset
272 Set_Name_Table_Int (Afile, Int (No_Unit_Id));
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 -- In GNATprove mode, object files are never generated, so
kono
parents:
diff changeset
275 -- No_Object=True is not considered an error.
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 elsif ALIs.Table (Idread).No_Object
kono
parents:
diff changeset
278 and then not GNATprove_Mode
kono
parents:
diff changeset
279 then
kono
parents:
diff changeset
280 Error_Msg_File_1 := Withs.Table (W).Sfile;
kono
parents:
diff changeset
281 Error_Msg ("{ must be recompiled");
kono
parents:
diff changeset
282 Set_Name_Table_Int (Afile, Int (No_Unit_Id));
kono
parents:
diff changeset
283 end if;
kono
parents:
diff changeset
284
kono
parents:
diff changeset
285 -- If the Unit is an Interface to a Stand-Alone Library,
kono
parents:
diff changeset
286 -- set the Interface flag in the Withs table, so that its
kono
parents:
diff changeset
287 -- dependant are not considered for elaboration order.
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 if ALIs.Table (Idread).SAL_Interface then
kono
parents:
diff changeset
290 Withs.Table (W).SAL_Interface := True;
kono
parents:
diff changeset
291 Interface_Library_Unit := True;
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 -- Set the entry in the Interfaces hash table, so that
kono
parents:
diff changeset
294 -- other units that import this unit will set the flag
kono
parents:
diff changeset
295 -- in their entry in the Withs table.
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 Interfaces.Set (Afile, True);
kono
parents:
diff changeset
298
kono
parents:
diff changeset
299 else
kono
parents:
diff changeset
300 -- Otherwise, recurse to get new dependents
kono
parents:
diff changeset
301
kono
parents:
diff changeset
302 Read_Withed_ALIs (Idread);
kono
parents:
diff changeset
303 end if;
kono
parents:
diff changeset
304 end if;
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 -- If the ALI file has already been processed and is an interface,
kono
parents:
diff changeset
307 -- set the flag in the entry of the Withs table.
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 elsif Interface_Library_Unit and then Interfaces.Get (Afile) then
kono
parents:
diff changeset
310 Withs.Table (W).SAL_Interface := True;
kono
parents:
diff changeset
311 end if;
kono
parents:
diff changeset
312 end loop;
kono
parents:
diff changeset
313 end loop;
kono
parents:
diff changeset
314 end Read_Withed_ALIs;
kono
parents:
diff changeset
315
kono
parents:
diff changeset
316 ----------------------
kono
parents:
diff changeset
317 -- Set_Source_Table --
kono
parents:
diff changeset
318 ----------------------
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 procedure Set_Source_Table (A : ALI_Id) is
kono
parents:
diff changeset
321 F : File_Name_Type;
kono
parents:
diff changeset
322 S : Source_Id;
kono
parents:
diff changeset
323 Stamp : Time_Stamp_Type;
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 begin
kono
parents:
diff changeset
326 Sdep_Loop : for D in
kono
parents:
diff changeset
327 ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
kono
parents:
diff changeset
328 loop
kono
parents:
diff changeset
329 F := Sdep.Table (D).Sfile;
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 if F /= No_File then
kono
parents:
diff changeset
332
kono
parents:
diff changeset
333 -- If this is the first time we are seeing this source file,
kono
parents:
diff changeset
334 -- then make a new entry in the source table.
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 if Get_Name_Table_Int (F) = 0 then
kono
parents:
diff changeset
337 Source.Increment_Last;
kono
parents:
diff changeset
338 S := Source.Last;
kono
parents:
diff changeset
339 Set_Name_Table_Int (F, Int (S));
kono
parents:
diff changeset
340 Source.Table (S).Sfile := F;
kono
parents:
diff changeset
341 Source.Table (S).All_Timestamps_Match := True;
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 -- Initialize checksum fields
kono
parents:
diff changeset
344
kono
parents:
diff changeset
345 Source.Table (S).Checksum := Sdep.Table (D).Checksum;
kono
parents:
diff changeset
346 Source.Table (S).All_Checksums_Match := True;
kono
parents:
diff changeset
347
kono
parents:
diff changeset
348 -- In check source files mode, try to get time stamp from file
kono
parents:
diff changeset
349
kono
parents:
diff changeset
350 if Opt.Check_Source_Files then
kono
parents:
diff changeset
351 Stamp := Source_File_Stamp (F);
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 -- If we got the stamp, then set the stamp in the source
kono
parents:
diff changeset
354 -- table entry and mark it as set from the source so that
kono
parents:
diff changeset
355 -- it does not get subsequently changed.
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 if Stamp (Stamp'First) /= ' ' then
kono
parents:
diff changeset
358 Source.Table (S).Stamp := Stamp;
kono
parents:
diff changeset
359 Source.Table (S).Source_Found := True;
kono
parents:
diff changeset
360 Source.Table (S).Stamp_File := F;
kono
parents:
diff changeset
361
kono
parents:
diff changeset
362 -- If we could not find the file, then the stamp is set
kono
parents:
diff changeset
363 -- from the dependency table entry (to be possibly reset
kono
parents:
diff changeset
364 -- if we find a later stamp in subsequent processing)
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 else
kono
parents:
diff changeset
367 Source.Table (S).Stamp := Sdep.Table (D).Stamp;
kono
parents:
diff changeset
368 Source.Table (S).Source_Found := False;
kono
parents:
diff changeset
369 Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
kono
parents:
diff changeset
370
kono
parents:
diff changeset
371 -- In All_Sources mode, flag error of file not found
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 if Opt.All_Sources then
kono
parents:
diff changeset
374 Error_Msg_File_1 := F;
kono
parents:
diff changeset
375 Error_Msg ("cannot locate {");
kono
parents:
diff changeset
376 end if;
kono
parents:
diff changeset
377 end if;
kono
parents:
diff changeset
378
kono
parents:
diff changeset
379 -- First time for this source file, but Check_Source_Files
kono
parents:
diff changeset
380 -- is off, so simply initialize the stamp from the Sdep entry
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 else
kono
parents:
diff changeset
383 Source.Table (S).Stamp := Sdep.Table (D).Stamp;
kono
parents:
diff changeset
384 Source.Table (S).Source_Found := False;
kono
parents:
diff changeset
385 Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
kono
parents:
diff changeset
386 end if;
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 -- Here if this is not the first time for this source file,
kono
parents:
diff changeset
389 -- so that the source table entry is already constructed.
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 else
kono
parents:
diff changeset
392 S := Source_Id (Get_Name_Table_Int (F));
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 -- Update checksum flag
kono
parents:
diff changeset
395
kono
parents:
diff changeset
396 if not Checksums_Match
kono
parents:
diff changeset
397 (Sdep.Table (D).Checksum, Source.Table (S).Checksum)
kono
parents:
diff changeset
398 then
kono
parents:
diff changeset
399 Source.Table (S).All_Checksums_Match := False;
kono
parents:
diff changeset
400 end if;
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 -- Check for time stamp mismatch
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 if Sdep.Table (D).Stamp /= Source.Table (S).Stamp then
kono
parents:
diff changeset
405 Source.Table (S).All_Timestamps_Match := False;
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 -- When we have a time stamp mismatch, we go look for the
kono
parents:
diff changeset
408 -- source file even if Check_Source_Files is false, since
kono
parents:
diff changeset
409 -- if we find it, then we can use it to resolve which of the
kono
parents:
diff changeset
410 -- two timestamps in the ALI files is likely to be correct.
kono
parents:
diff changeset
411 -- We only look in the current directory, because when
kono
parents:
diff changeset
412 -- Check_Source_Files is false, other search directories are
kono
parents:
diff changeset
413 -- likely to be incorrect.
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 if not Check_Source_Files
kono
parents:
diff changeset
416 and then Is_Regular_File (Get_Name_String (F))
kono
parents:
diff changeset
417 then
kono
parents:
diff changeset
418 Stamp := Source_File_Stamp (F);
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 if Stamp (Stamp'First) /= ' ' then
kono
parents:
diff changeset
421 Source.Table (S).Stamp := Stamp;
kono
parents:
diff changeset
422 Source.Table (S).Source_Found := True;
kono
parents:
diff changeset
423 Source.Table (S).Stamp_File := F;
kono
parents:
diff changeset
424 end if;
kono
parents:
diff changeset
425 end if;
kono
parents:
diff changeset
426
kono
parents:
diff changeset
427 -- If the stamp in the source table entry was set from the
kono
parents:
diff changeset
428 -- source file, then we do not change it (the stamp in the
kono
parents:
diff changeset
429 -- source file is always taken as the "right" one).
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 if Source.Table (S).Source_Found then
kono
parents:
diff changeset
432 null;
kono
parents:
diff changeset
433
kono
parents:
diff changeset
434 -- Otherwise, we have no source file available, so we guess
kono
parents:
diff changeset
435 -- that the later of the two timestamps is the right one.
kono
parents:
diff changeset
436 -- Note that this guess only affects which error messages
kono
parents:
diff changeset
437 -- are issued later on, not correct functionality.
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 else
kono
parents:
diff changeset
440 if Sdep.Table (D).Stamp > Source.Table (S).Stamp then
kono
parents:
diff changeset
441 Source.Table (S).Stamp := Sdep.Table (D).Stamp;
kono
parents:
diff changeset
442 Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
kono
parents:
diff changeset
443 end if;
kono
parents:
diff changeset
444 end if;
kono
parents:
diff changeset
445 end if;
kono
parents:
diff changeset
446 end if;
kono
parents:
diff changeset
447
kono
parents:
diff changeset
448 -- Set the checksum value in the source table
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 S := Source_Id (Get_Name_Table_Int (F));
kono
parents:
diff changeset
451 Source.Table (S).Checksum := Sdep.Table (D).Checksum;
kono
parents:
diff changeset
452 end if;
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 end loop Sdep_Loop;
kono
parents:
diff changeset
455 end Set_Source_Table;
kono
parents:
diff changeset
456
kono
parents:
diff changeset
457 ----------------------
kono
parents:
diff changeset
458 -- Set_Source_Table --
kono
parents:
diff changeset
459 ----------------------
kono
parents:
diff changeset
460
kono
parents:
diff changeset
461 procedure Set_Source_Table is
kono
parents:
diff changeset
462 begin
kono
parents:
diff changeset
463 for A in ALIs.First .. ALIs.Last loop
kono
parents:
diff changeset
464 Set_Source_Table (A);
kono
parents:
diff changeset
465 end loop;
kono
parents:
diff changeset
466 end Set_Source_Table;
kono
parents:
diff changeset
467
kono
parents:
diff changeset
468 -------------------------
kono
parents:
diff changeset
469 -- Time_Stamp_Mismatch --
kono
parents:
diff changeset
470 -------------------------
kono
parents:
diff changeset
471
kono
parents:
diff changeset
472 function Time_Stamp_Mismatch
kono
parents:
diff changeset
473 (A : ALI_Id;
kono
parents:
diff changeset
474 Read_Only : Boolean := False) return File_Name_Type
kono
parents:
diff changeset
475 is
kono
parents:
diff changeset
476 Src : Source_Id;
kono
parents:
diff changeset
477 -- Source file Id for the current Sdep entry
kono
parents:
diff changeset
478
kono
parents:
diff changeset
479 begin
kono
parents:
diff changeset
480 for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop
kono
parents:
diff changeset
481 Src := Source_Id (Get_Name_Table_Int (Sdep.Table (D).Sfile));
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 if Opt.Minimal_Recompilation
kono
parents:
diff changeset
484 and then Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
kono
parents:
diff changeset
485 then
kono
parents:
diff changeset
486 -- If minimal recompilation is in action, replace the stamp
kono
parents:
diff changeset
487 -- of the source file in the table if checksums match.
kono
parents:
diff changeset
488
kono
parents:
diff changeset
489 -- ??? It is probably worth updating the ALI file with a new
kono
parents:
diff changeset
490 -- field to avoid recomputing it each time. In any case we ensure
kono
parents:
diff changeset
491 -- that we don't gobble up string table space by doing a mark
kono
parents:
diff changeset
492 -- release around this computation.
kono
parents:
diff changeset
493
kono
parents:
diff changeset
494 Stringt.Mark;
kono
parents:
diff changeset
495
kono
parents:
diff changeset
496 if Checksums_Match
kono
parents:
diff changeset
497 (Get_File_Checksum (Sdep.Table (D).Sfile),
kono
parents:
diff changeset
498 Source.Table (Src).Checksum)
kono
parents:
diff changeset
499 then
kono
parents:
diff changeset
500 if Verbose_Mode then
kono
parents:
diff changeset
501 Write_Str (" ");
kono
parents:
diff changeset
502 Write_Str (Get_Name_String (Sdep.Table (D).Sfile));
kono
parents:
diff changeset
503 Write_Str (": up to date, different timestamps " &
kono
parents:
diff changeset
504 "but same checksum");
kono
parents:
diff changeset
505 Write_Eol;
kono
parents:
diff changeset
506 end if;
kono
parents:
diff changeset
507
kono
parents:
diff changeset
508 Sdep.Table (D).Stamp := Source.Table (Src).Stamp;
kono
parents:
diff changeset
509 end if;
kono
parents:
diff changeset
510
kono
parents:
diff changeset
511 Stringt.Release;
kono
parents:
diff changeset
512 end if;
kono
parents:
diff changeset
513
kono
parents:
diff changeset
514 if (not Read_Only) or else Source.Table (Src).Source_Found then
kono
parents:
diff changeset
515 if not Source.Table (Src).Source_Found
kono
parents:
diff changeset
516 or else Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
kono
parents:
diff changeset
517 then
kono
parents:
diff changeset
518 -- If -dt debug flag set, output time stamp found/expected
kono
parents:
diff changeset
519
kono
parents:
diff changeset
520 if Source.Table (Src).Source_Found and then Debug_Flag_T then
kono
parents:
diff changeset
521 Write_Str ("Source: """);
kono
parents:
diff changeset
522 Get_Name_String (Sdep.Table (D).Sfile);
kono
parents:
diff changeset
523 Write_Str (Name_Buffer (1 .. Name_Len));
kono
parents:
diff changeset
524 Write_Line ("""");
kono
parents:
diff changeset
525
kono
parents:
diff changeset
526 Write_Str (" time stamp expected: ");
kono
parents:
diff changeset
527 Write_Line (String (Sdep.Table (D).Stamp));
kono
parents:
diff changeset
528
kono
parents:
diff changeset
529 Write_Str (" time stamp found: ");
kono
parents:
diff changeset
530 Write_Line (String (Source.Table (Src).Stamp));
kono
parents:
diff changeset
531 end if;
kono
parents:
diff changeset
532
kono
parents:
diff changeset
533 -- Return the source file
kono
parents:
diff changeset
534
kono
parents:
diff changeset
535 return Source.Table (Src).Sfile;
kono
parents:
diff changeset
536 end if;
kono
parents:
diff changeset
537 end if;
kono
parents:
diff changeset
538 end loop;
kono
parents:
diff changeset
539
kono
parents:
diff changeset
540 return No_File;
kono
parents:
diff changeset
541 end Time_Stamp_Mismatch;
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 end ALI.Util;