annotate gcc/ada/ali-util.adb @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
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 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
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
kono
parents:
diff changeset
218 procedure Read_Withed_ALIs
kono
parents:
diff changeset
219 (Id : ALI_Id;
kono
parents:
diff changeset
220 Ignore_Errors : Boolean := False)
kono
parents:
diff changeset
221 is
kono
parents:
diff changeset
222 Afile : File_Name_Type;
kono
parents:
diff changeset
223 Text : Text_Buffer_Ptr;
kono
parents:
diff changeset
224 Idread : ALI_Id;
kono
parents:
diff changeset
225
kono
parents:
diff changeset
226 begin
kono
parents:
diff changeset
227 -- Process all dependent units
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 for U in ALIs.Table (Id).First_Unit .. ALIs.Table (Id).Last_Unit loop
kono
parents:
diff changeset
230 for
kono
parents:
diff changeset
231 W in Units.Table (U).First_With .. Units.Table (U).Last_With
kono
parents:
diff changeset
232 loop
kono
parents:
diff changeset
233 Afile := Withs.Table (W).Afile;
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 -- Only process if not a generic (Afile /= No_File) and if
kono
parents:
diff changeset
236 -- file has not been processed already.
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 if Afile /= No_File
kono
parents:
diff changeset
239 and then Get_Name_Table_Int (Afile) = 0
kono
parents:
diff changeset
240 then
kono
parents:
diff changeset
241 Text := Read_Library_Info (Afile);
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 -- Unless Ignore_Errors is true, return with an error if source
kono
parents:
diff changeset
244 -- cannot be found. We used to skip this check when we did not
kono
parents:
diff changeset
245 -- compile library generics separately, but we now always do,
kono
parents:
diff changeset
246 -- so there is no special case here anymore.
kono
parents:
diff changeset
247
kono
parents:
diff changeset
248 if Text = null then
kono
parents:
diff changeset
249
kono
parents:
diff changeset
250 if not Ignore_Errors then
kono
parents:
diff changeset
251 Error_Msg_File_1 := Afile;
kono
parents:
diff changeset
252 Error_Msg_File_2 := Withs.Table (W).Sfile;
kono
parents:
diff changeset
253 Error_Msg ("{ not found, { must be compiled");
kono
parents:
diff changeset
254 Set_Name_Table_Int (Afile, Int (No_Unit_Id));
kono
parents:
diff changeset
255 return;
kono
parents:
diff changeset
256 end if;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 else
kono
parents:
diff changeset
259 -- Enter in ALIs table
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 Idread :=
kono
parents:
diff changeset
262 Scan_ALI
kono
parents:
diff changeset
263 (F => Afile,
kono
parents:
diff changeset
264 T => Text,
kono
parents:
diff changeset
265 Ignore_ED => False,
kono
parents:
diff changeset
266 Err => False);
kono
parents:
diff changeset
267
kono
parents:
diff changeset
268 Free (Text);
kono
parents:
diff changeset
269
kono
parents:
diff changeset
270 if ALIs.Table (Idread).Compile_Errors
kono
parents:
diff changeset
271 and then not Ignore_Errors
kono
parents:
diff changeset
272 then
kono
parents:
diff changeset
273 Error_Msg_File_1 := Withs.Table (W).Sfile;
kono
parents:
diff changeset
274 Error_Msg ("{ had errors, must be fixed, and recompiled");
kono
parents:
diff changeset
275 Set_Name_Table_Int (Afile, Int (No_Unit_Id));
kono
parents:
diff changeset
276
kono
parents:
diff changeset
277 -- In GNATprove mode, object files are never generated, so
kono
parents:
diff changeset
278 -- No_Object=True is not considered an error.
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 elsif ALIs.Table (Idread).No_Object
kono
parents:
diff changeset
281 and then not GNATprove_Mode
kono
parents:
diff changeset
282 and then not Ignore_Errors
kono
parents:
diff changeset
283 then
kono
parents:
diff changeset
284 Error_Msg_File_1 := Withs.Table (W).Sfile;
kono
parents:
diff changeset
285 Error_Msg ("{ must be recompiled");
kono
parents:
diff changeset
286 Set_Name_Table_Int (Afile, Int (No_Unit_Id));
kono
parents:
diff changeset
287 end if;
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 -- If the Unit is an Interface to a Stand-Alone Library,
kono
parents:
diff changeset
290 -- set the Interface flag in the Withs table, so that its
kono
parents:
diff changeset
291 -- dependant are not considered for elaboration order.
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 if ALIs.Table (Idread).SAL_Interface then
kono
parents:
diff changeset
294 Withs.Table (W).SAL_Interface := True;
kono
parents:
diff changeset
295 Interface_Library_Unit := True;
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 -- Set the entry in the Interfaces hash table, so that
kono
parents:
diff changeset
298 -- other units that import this unit will set the flag
kono
parents:
diff changeset
299 -- in their entry in the Withs table.
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 Interfaces.Set (Afile, True);
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 else
kono
parents:
diff changeset
304 -- Otherwise, recurse to get new dependents
kono
parents:
diff changeset
305
kono
parents:
diff changeset
306 Read_Withed_ALIs (Idread);
kono
parents:
diff changeset
307 end if;
kono
parents:
diff changeset
308 end if;
kono
parents:
diff changeset
309
kono
parents:
diff changeset
310 -- If the ALI file has already been processed and is an interface,
kono
parents:
diff changeset
311 -- set the flag in the entry of the Withs table.
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 elsif Interface_Library_Unit and then Interfaces.Get (Afile) then
kono
parents:
diff changeset
314 Withs.Table (W).SAL_Interface := True;
kono
parents:
diff changeset
315 end if;
kono
parents:
diff changeset
316 end loop;
kono
parents:
diff changeset
317 end loop;
kono
parents:
diff changeset
318 end Read_Withed_ALIs;
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 ----------------------
kono
parents:
diff changeset
321 -- Set_Source_Table --
kono
parents:
diff changeset
322 ----------------------
kono
parents:
diff changeset
323
kono
parents:
diff changeset
324 procedure Set_Source_Table (A : ALI_Id) is
kono
parents:
diff changeset
325 F : File_Name_Type;
kono
parents:
diff changeset
326 S : Source_Id;
kono
parents:
diff changeset
327 Stamp : Time_Stamp_Type;
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 begin
kono
parents:
diff changeset
330 Sdep_Loop : for D in
kono
parents:
diff changeset
331 ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep
kono
parents:
diff changeset
332 loop
kono
parents:
diff changeset
333 F := Sdep.Table (D).Sfile;
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 if F /= No_File then
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 -- If this is the first time we are seeing this source file,
kono
parents:
diff changeset
338 -- then make a new entry in the source table.
kono
parents:
diff changeset
339
kono
parents:
diff changeset
340 if Get_Name_Table_Int (F) = 0 then
kono
parents:
diff changeset
341 Source.Increment_Last;
kono
parents:
diff changeset
342 S := Source.Last;
kono
parents:
diff changeset
343 Set_Name_Table_Int (F, Int (S));
kono
parents:
diff changeset
344 Source.Table (S).Sfile := F;
kono
parents:
diff changeset
345 Source.Table (S).All_Timestamps_Match := True;
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 -- Initialize checksum fields
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 Source.Table (S).Checksum := Sdep.Table (D).Checksum;
kono
parents:
diff changeset
350 Source.Table (S).All_Checksums_Match := True;
kono
parents:
diff changeset
351
kono
parents:
diff changeset
352 -- In check source files mode, try to get time stamp from file
kono
parents:
diff changeset
353
kono
parents:
diff changeset
354 if Opt.Check_Source_Files then
kono
parents:
diff changeset
355 Stamp := Source_File_Stamp (F);
kono
parents:
diff changeset
356
kono
parents:
diff changeset
357 -- If we got the stamp, then set the stamp in the source
kono
parents:
diff changeset
358 -- table entry and mark it as set from the source so that
kono
parents:
diff changeset
359 -- it does not get subsequently changed.
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 if Stamp (Stamp'First) /= ' ' then
kono
parents:
diff changeset
362 Source.Table (S).Stamp := Stamp;
kono
parents:
diff changeset
363 Source.Table (S).Source_Found := True;
kono
parents:
diff changeset
364 Source.Table (S).Stamp_File := F;
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 -- If we could not find the file, then the stamp is set
kono
parents:
diff changeset
367 -- from the dependency table entry (to be possibly reset
kono
parents:
diff changeset
368 -- if we find a later stamp in subsequent processing)
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 else
kono
parents:
diff changeset
371 Source.Table (S).Stamp := Sdep.Table (D).Stamp;
kono
parents:
diff changeset
372 Source.Table (S).Source_Found := False;
kono
parents:
diff changeset
373 Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 -- In All_Sources mode, flag error of file not found
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 if Opt.All_Sources then
kono
parents:
diff changeset
378 Error_Msg_File_1 := F;
kono
parents:
diff changeset
379 Error_Msg ("cannot locate {");
kono
parents:
diff changeset
380 end if;
kono
parents:
diff changeset
381 end if;
kono
parents:
diff changeset
382
kono
parents:
diff changeset
383 -- First time for this source file, but Check_Source_Files
kono
parents:
diff changeset
384 -- is off, so simply initialize the stamp from the Sdep entry
kono
parents:
diff changeset
385
kono
parents:
diff changeset
386 else
kono
parents:
diff changeset
387 Source.Table (S).Stamp := Sdep.Table (D).Stamp;
kono
parents:
diff changeset
388 Source.Table (S).Source_Found := False;
kono
parents:
diff changeset
389 Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
kono
parents:
diff changeset
390 end if;
kono
parents:
diff changeset
391
kono
parents:
diff changeset
392 -- Here if this is not the first time for this source file,
kono
parents:
diff changeset
393 -- so that the source table entry is already constructed.
kono
parents:
diff changeset
394
kono
parents:
diff changeset
395 else
kono
parents:
diff changeset
396 S := Source_Id (Get_Name_Table_Int (F));
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 -- Update checksum flag
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 if not Checksums_Match
kono
parents:
diff changeset
401 (Sdep.Table (D).Checksum, Source.Table (S).Checksum)
kono
parents:
diff changeset
402 then
kono
parents:
diff changeset
403 Source.Table (S).All_Checksums_Match := False;
kono
parents:
diff changeset
404 end if;
kono
parents:
diff changeset
405
kono
parents:
diff changeset
406 -- Check for time stamp mismatch
kono
parents:
diff changeset
407
kono
parents:
diff changeset
408 if Sdep.Table (D).Stamp /= Source.Table (S).Stamp then
kono
parents:
diff changeset
409 Source.Table (S).All_Timestamps_Match := False;
kono
parents:
diff changeset
410
kono
parents:
diff changeset
411 -- When we have a time stamp mismatch, we go look for the
kono
parents:
diff changeset
412 -- source file even if Check_Source_Files is false, since
kono
parents:
diff changeset
413 -- if we find it, then we can use it to resolve which of the
kono
parents:
diff changeset
414 -- two timestamps in the ALI files is likely to be correct.
kono
parents:
diff changeset
415 -- We only look in the current directory, because when
kono
parents:
diff changeset
416 -- Check_Source_Files is false, other search directories are
kono
parents:
diff changeset
417 -- likely to be incorrect.
kono
parents:
diff changeset
418
kono
parents:
diff changeset
419 if not Check_Source_Files
kono
parents:
diff changeset
420 and then Is_Regular_File (Get_Name_String (F))
kono
parents:
diff changeset
421 then
kono
parents:
diff changeset
422 Stamp := Source_File_Stamp (F);
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 if Stamp (Stamp'First) /= ' ' then
kono
parents:
diff changeset
425 Source.Table (S).Stamp := Stamp;
kono
parents:
diff changeset
426 Source.Table (S).Source_Found := True;
kono
parents:
diff changeset
427 Source.Table (S).Stamp_File := F;
kono
parents:
diff changeset
428 end if;
kono
parents:
diff changeset
429 end if;
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 -- If the stamp in the source table entry was set from the
kono
parents:
diff changeset
432 -- source file, then we do not change it (the stamp in the
kono
parents:
diff changeset
433 -- source file is always taken as the "right" one).
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 if Source.Table (S).Source_Found then
kono
parents:
diff changeset
436 null;
kono
parents:
diff changeset
437
kono
parents:
diff changeset
438 -- Otherwise, we have no source file available, so we guess
kono
parents:
diff changeset
439 -- that the later of the two timestamps is the right one.
kono
parents:
diff changeset
440 -- Note that this guess only affects which error messages
kono
parents:
diff changeset
441 -- are issued later on, not correct functionality.
kono
parents:
diff changeset
442
kono
parents:
diff changeset
443 else
kono
parents:
diff changeset
444 if Sdep.Table (D).Stamp > Source.Table (S).Stamp then
kono
parents:
diff changeset
445 Source.Table (S).Stamp := Sdep.Table (D).Stamp;
kono
parents:
diff changeset
446 Source.Table (S).Stamp_File := ALIs.Table (A).Afile;
kono
parents:
diff changeset
447 end if;
kono
parents:
diff changeset
448 end if;
kono
parents:
diff changeset
449 end if;
kono
parents:
diff changeset
450 end if;
kono
parents:
diff changeset
451
kono
parents:
diff changeset
452 -- Set the checksum value in the source table
kono
parents:
diff changeset
453
kono
parents:
diff changeset
454 S := Source_Id (Get_Name_Table_Int (F));
kono
parents:
diff changeset
455 Source.Table (S).Checksum := Sdep.Table (D).Checksum;
kono
parents:
diff changeset
456 end if;
kono
parents:
diff changeset
457
kono
parents:
diff changeset
458 end loop Sdep_Loop;
kono
parents:
diff changeset
459 end Set_Source_Table;
kono
parents:
diff changeset
460
kono
parents:
diff changeset
461 ----------------------
kono
parents:
diff changeset
462 -- Set_Source_Table --
kono
parents:
diff changeset
463 ----------------------
kono
parents:
diff changeset
464
kono
parents:
diff changeset
465 procedure Set_Source_Table is
kono
parents:
diff changeset
466 begin
kono
parents:
diff changeset
467 for A in ALIs.First .. ALIs.Last loop
kono
parents:
diff changeset
468 Set_Source_Table (A);
kono
parents:
diff changeset
469 end loop;
kono
parents:
diff changeset
470 end Set_Source_Table;
kono
parents:
diff changeset
471
kono
parents:
diff changeset
472 -------------------------
kono
parents:
diff changeset
473 -- Time_Stamp_Mismatch --
kono
parents:
diff changeset
474 -------------------------
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 function Time_Stamp_Mismatch
kono
parents:
diff changeset
477 (A : ALI_Id;
kono
parents:
diff changeset
478 Read_Only : Boolean := False) return File_Name_Type
kono
parents:
diff changeset
479 is
kono
parents:
diff changeset
480 Src : Source_Id;
kono
parents:
diff changeset
481 -- Source file Id for the current Sdep entry
kono
parents:
diff changeset
482
kono
parents:
diff changeset
483 begin
kono
parents:
diff changeset
484 for D in ALIs.Table (A).First_Sdep .. ALIs.Table (A).Last_Sdep loop
kono
parents:
diff changeset
485 Src := Source_Id (Get_Name_Table_Int (Sdep.Table (D).Sfile));
kono
parents:
diff changeset
486
kono
parents:
diff changeset
487 if Opt.Minimal_Recompilation
kono
parents:
diff changeset
488 and then Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
kono
parents:
diff changeset
489 then
kono
parents:
diff changeset
490 -- If minimal recompilation is in action, replace the stamp
kono
parents:
diff changeset
491 -- of the source file in the table if checksums match.
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 -- ??? It is probably worth updating the ALI file with a new
kono
parents:
diff changeset
494 -- field to avoid recomputing it each time. In any case we ensure
kono
parents:
diff changeset
495 -- that we don't gobble up string table space by doing a mark
kono
parents:
diff changeset
496 -- release around this computation.
kono
parents:
diff changeset
497
kono
parents:
diff changeset
498 Stringt.Mark;
kono
parents:
diff changeset
499
kono
parents:
diff changeset
500 if Checksums_Match
kono
parents:
diff changeset
501 (Get_File_Checksum (Sdep.Table (D).Sfile),
kono
parents:
diff changeset
502 Source.Table (Src).Checksum)
kono
parents:
diff changeset
503 then
kono
parents:
diff changeset
504 if Verbose_Mode then
kono
parents:
diff changeset
505 Write_Str (" ");
kono
parents:
diff changeset
506 Write_Str (Get_Name_String (Sdep.Table (D).Sfile));
kono
parents:
diff changeset
507 Write_Str (": up to date, different timestamps " &
kono
parents:
diff changeset
508 "but same checksum");
kono
parents:
diff changeset
509 Write_Eol;
kono
parents:
diff changeset
510 end if;
kono
parents:
diff changeset
511
kono
parents:
diff changeset
512 Sdep.Table (D).Stamp := Source.Table (Src).Stamp;
kono
parents:
diff changeset
513 end if;
kono
parents:
diff changeset
514
kono
parents:
diff changeset
515 Stringt.Release;
kono
parents:
diff changeset
516 end if;
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 if (not Read_Only) or else Source.Table (Src).Source_Found then
kono
parents:
diff changeset
519 if not Source.Table (Src).Source_Found
kono
parents:
diff changeset
520 or else Sdep.Table (D).Stamp /= Source.Table (Src).Stamp
kono
parents:
diff changeset
521 then
kono
parents:
diff changeset
522 -- If -dt debug flag set, output time stamp found/expected
kono
parents:
diff changeset
523
kono
parents:
diff changeset
524 if Source.Table (Src).Source_Found and then Debug_Flag_T then
kono
parents:
diff changeset
525 Write_Str ("Source: """);
kono
parents:
diff changeset
526 Get_Name_String (Sdep.Table (D).Sfile);
kono
parents:
diff changeset
527 Write_Str (Name_Buffer (1 .. Name_Len));
kono
parents:
diff changeset
528 Write_Line ("""");
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 Write_Str (" time stamp expected: ");
kono
parents:
diff changeset
531 Write_Line (String (Sdep.Table (D).Stamp));
kono
parents:
diff changeset
532
kono
parents:
diff changeset
533 Write_Str (" time stamp found: ");
kono
parents:
diff changeset
534 Write_Line (String (Source.Table (Src).Stamp));
kono
parents:
diff changeset
535 end if;
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 -- Return the source file
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 return Source.Table (Src).Sfile;
kono
parents:
diff changeset
540 end if;
kono
parents:
diff changeset
541 end if;
kono
parents:
diff changeset
542 end loop;
kono
parents:
diff changeset
543
kono
parents:
diff changeset
544 return No_File;
kono
parents:
diff changeset
545 end Time_Stamp_Mismatch;
kono
parents:
diff changeset
546
kono
parents:
diff changeset
547 end ALI.Util;