Make more use of in_hard_reg_set_p
[official-gcc.git] / gcc / ada / ali.adb
blob2b1d472baba8a5f3f2c9660b76fe1b28943d4fe0
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2017, 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 ------------------------------------------------------------------------------
26 with Butil; use Butil;
27 with Debug; use Debug;
28 with Fname; use Fname;
29 with Opt; use Opt;
30 with Osint; use Osint;
31 with Output; use Output;
33 package body ALI is
35 use ASCII;
36 -- Make control characters visible
38 -- The following variable records which characters currently are
39 -- used as line type markers in the ALI file. This is used in
40 -- Scan_ALI to detect (or skip) invalid lines.
42 Known_ALI_Lines : constant array (Character range 'A' .. 'Z') of Boolean :=
43 ('V' => True, -- version
44 'M' => True, -- main program
45 'A' => True, -- argument
46 'P' => True, -- program
47 'R' => True, -- restriction
48 'I' => True, -- interrupt
49 'U' => True, -- unit
50 'W' => True, -- with
51 'L' => True, -- linker option
52 'N' => True, -- notes
53 'E' => True, -- external
54 'D' => True, -- dependency
55 'X' => True, -- xref
56 'S' => True, -- specific dispatching
57 'Y' => True, -- limited_with
58 'Z' => True, -- implicit with from instantiation
59 'C' => True, -- SCO information
60 'F' => True, -- SPARK cross-reference information
61 others => False);
63 --------------------
64 -- Initialize_ALI --
65 --------------------
67 procedure Initialize_ALI is
68 begin
69 -- When (re)initializing ALI data structures the ALI user expects to
70 -- get a fresh set of data structures. Thus we first need to erase the
71 -- marks put in the name table by the previous set of ALI routine calls.
72 -- These two loops are empty and harmless the first time in.
74 for J in ALIs.First .. ALIs.Last loop
75 Set_Name_Table_Int (ALIs.Table (J).Afile, 0);
76 end loop;
78 for J in Units.First .. Units.Last loop
79 Set_Name_Table_Int (Units.Table (J).Uname, 0);
80 end loop;
82 -- Free argument table strings
84 for J in Args.First .. Args.Last loop
85 Free (Args.Table (J));
86 end loop;
88 -- Initialize all tables
90 ALIs.Init;
91 No_Deps.Init;
92 Units.Init;
93 Withs.Init;
94 Sdep.Init;
95 Linker_Options.Init;
96 Notes.Init;
97 Xref_Section.Init;
98 Xref_Entity.Init;
99 Xref.Init;
100 Version_Ref.Reset;
102 -- Add dummy zero'th item in Linker_Options and Notes for sort calls
104 Linker_Options.Increment_Last;
105 Notes.Increment_Last;
107 -- Initialize global variables recording cumulative options in all
108 -- ALI files that are read for a given processing run in gnatbind.
110 Dynamic_Elaboration_Checks_Specified := False;
111 Locking_Policy_Specified := ' ';
112 No_Normalize_Scalars_Specified := False;
113 No_Object_Specified := False;
114 No_Component_Reordering_Specified := False;
115 GNATprove_Mode_Specified := False;
116 Normalize_Scalars_Specified := False;
117 Partition_Elaboration_Policy_Specified := ' ';
118 Queuing_Policy_Specified := ' ';
119 SSO_Default_Specified := False;
120 Task_Dispatching_Policy_Specified := ' ';
121 Unreserve_All_Interrupts_Specified := False;
122 Frontend_Exceptions_Specified := False;
123 Zero_Cost_Exceptions_Specified := False;
124 end Initialize_ALI;
126 --------------
127 -- Scan_ALI --
128 --------------
130 function Scan_ALI
131 (F : File_Name_Type;
132 T : Text_Buffer_Ptr;
133 Ignore_ED : Boolean;
134 Err : Boolean;
135 Read_Xref : Boolean := False;
136 Read_Lines : String := "";
137 Ignore_Lines : String := "X";
138 Ignore_Errors : Boolean := False;
139 Directly_Scanned : Boolean := False) return ALI_Id
141 P : Text_Ptr := T'First;
142 Line : Logical_Line_Number := 1;
143 Id : ALI_Id;
144 C : Character;
145 NS_Found : Boolean;
146 First_Arg : Arg_Id;
148 Ignore : array (Character range 'A' .. 'Z') of Boolean;
149 -- Ignore (X) is set to True if lines starting with X are to
150 -- be ignored by Scan_ALI and skipped, and False if the lines
151 -- are to be read and processed.
153 Bad_ALI_Format : exception;
154 -- Exception raised by Fatal_Error if Err is True
156 function At_Eol return Boolean;
157 -- Test if at end of line
159 function At_End_Of_Field return Boolean;
160 -- Test if at end of line, or if at blank or horizontal tab
162 procedure Check_At_End_Of_Field;
163 -- Check if we are at end of field, fatal error if not
165 procedure Checkc (C : Character);
166 -- Check next character is C. If so bump past it, if not fatal error
168 procedure Check_Unknown_Line;
169 -- If Ignore_Errors mode, then checks C to make sure that it is not
170 -- an unknown ALI line type characters, and if so, skips lines
171 -- until the first character of the line is one of these characters,
172 -- at which point it does a Getc to put that character in C. The
173 -- call has no effect if C is already an appropriate character.
174 -- If not in Ignore_Errors mode, a fatal error is signalled if the
175 -- line is unknown. Note that if C is an EOL on entry, the line is
176 -- skipped (it is assumed that blank lines are never significant).
177 -- If C is EOF on entry, the call has no effect (it is assumed that
178 -- the caller will properly handle this case).
180 procedure Fatal_Error;
181 -- Generate fatal error message for badly formatted ALI file if
182 -- Err is false, or raise Bad_ALI_Format if Err is True.
184 procedure Fatal_Error_Ignore;
185 pragma Inline (Fatal_Error_Ignore);
186 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
188 function Getc return Character;
189 -- Get next character, bumping P past the character obtained
191 function Get_File_Name
192 (Lower : Boolean := False;
193 May_Be_Quoted : Boolean := False) return File_Name_Type;
194 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
195 -- with length in Name_Len, as well as returning a File_Name_Type value.
196 -- If May_Be_Quoted is True and the first non blank character is '"',
197 -- then remove starting and ending quotes and undoubled internal quotes.
198 -- If lower is false, the case is unchanged, if Lower is True then the
199 -- result is forced to all lower case for systems where file names are
200 -- not case sensitive. This ensures that gnatbind works correctly
201 -- regardless of the case of the file name on all systems. The scan
202 -- is terminated by a end of line, space or horizontal tab. Any other
203 -- special characters are included in the returned name.
205 function Get_Name
206 (Ignore_Spaces : Boolean := False;
207 Ignore_Special : Boolean := False;
208 May_Be_Quoted : Boolean := False) return Name_Id;
209 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
210 -- length in Name_Len, as well as being returned in Name_Id form).
211 -- If Lower is set to True then the Name_Buffer will be converted to
212 -- all lower case, for systems where file names are not case sensitive.
213 -- This ensures that gnatbind works correctly regardless of the case
214 -- of the file name on all systems. The termination condition depends
215 -- on the settings of Ignore_Spaces and Ignore_Special:
217 -- If Ignore_Spaces is False (normal case), then scan is terminated
218 -- by the normal end of field condition (EOL, space, horizontal tab)
220 -- If Ignore_Special is False (normal case), the scan is terminated by
221 -- a typeref bracket or an equal sign except for the special case of
222 -- an operator name starting with a double quote which is terminated
223 -- by another double quote.
225 -- If May_Be_Quoted is True and the first non blank character is '"'
226 -- the name is 'unquoted'. In this case Ignore_Special is ignored and
227 -- assumed to be True.
229 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
230 -- This function handles wide characters properly.
232 function Get_Nat return Nat;
233 -- Skip blanks, then scan out an unsigned integer value in Nat range
234 -- raises ALI_Reading_Error if the encoutered type is not natural.
236 function Get_Stamp return Time_Stamp_Type;
237 -- Skip blanks, then scan out a time stamp
239 function Get_Unit_Name return Unit_Name_Type;
240 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
241 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
242 -- The case is unchanged and terminated by a normal end of field.
244 function Nextc return Character;
245 -- Return current character without modifying pointer P
247 procedure Get_Typeref
248 (Current_File_Num : Sdep_Id;
249 Ref : out Tref_Kind;
250 File_Num : out Sdep_Id;
251 Line : out Nat;
252 Ref_Type : out Character;
253 Col : out Nat;
254 Standard_Entity : out Name_Id);
255 -- Parse the definition of a typeref (<...>, {...} or (...))
257 procedure Skip_Eol;
258 -- Skip past spaces, then skip past end of line (fatal error if not
259 -- at end of line). Also skips past any following blank lines.
261 procedure Skip_Line;
262 -- Skip rest of current line and any following blank lines
264 procedure Skip_Space;
265 -- Skip past white space (blanks or horizontal tab)
267 procedure Skipc;
268 -- Skip past next character, does not affect value in C. This call
269 -- is like calling Getc and ignoring the returned result.
271 ---------------------
272 -- At_End_Of_Field --
273 ---------------------
275 function At_End_Of_Field return Boolean is
276 begin
277 return Nextc <= ' ';
278 end At_End_Of_Field;
280 ------------
281 -- At_Eol --
282 ------------
284 function At_Eol return Boolean is
285 begin
286 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
287 end At_Eol;
289 ---------------------------
290 -- Check_At_End_Of_Field --
291 ---------------------------
293 procedure Check_At_End_Of_Field is
294 begin
295 if not At_End_Of_Field then
296 if Ignore_Errors then
297 while Nextc > ' ' loop
298 P := P + 1;
299 end loop;
300 else
301 Fatal_Error;
302 end if;
303 end if;
304 end Check_At_End_Of_Field;
306 ------------------------
307 -- Check_Unknown_Line --
308 ------------------------
310 procedure Check_Unknown_Line is
311 begin
312 while C not in 'A' .. 'Z'
313 or else not Known_ALI_Lines (C)
314 loop
315 if C = CR or else C = LF then
316 Skip_Line;
317 C := Nextc;
319 elsif C = EOF then
320 return;
322 elsif Ignore_Errors then
323 Skip_Line;
324 C := Getc;
326 else
327 Fatal_Error;
328 end if;
329 end loop;
330 end Check_Unknown_Line;
332 ------------
333 -- Checkc --
334 ------------
336 procedure Checkc (C : Character) is
337 begin
338 if Nextc = C then
339 P := P + 1;
340 elsif Ignore_Errors then
341 P := P + 1;
342 else
343 Fatal_Error;
344 end if;
345 end Checkc;
347 -----------------
348 -- Fatal_Error --
349 -----------------
351 procedure Fatal_Error is
352 Ptr1 : Text_Ptr;
353 Ptr2 : Text_Ptr;
354 Col : Int;
356 procedure Wchar (C : Character);
357 -- Write a single character, replacing horizontal tab by spaces
359 procedure Wchar (C : Character) is
360 begin
361 if C = HT then
362 loop
363 Wchar (' ');
364 exit when Col mod 8 = 0;
365 end loop;
367 else
368 Write_Char (C);
369 Col := Col + 1;
370 end if;
371 end Wchar;
373 -- Start of processing for Fatal_Error
375 begin
376 if Err then
377 raise Bad_ALI_Format;
378 end if;
380 Set_Standard_Error;
381 Write_Str ("fatal error: file ");
382 Write_Name (F);
383 Write_Str (" is incorrectly formatted");
384 Write_Eol;
386 Write_Str ("make sure you are using consistent versions " &
388 -- Split the following line so that it can easily be transformed for
389 -- other back-ends where the compiler might have a different name.
391 "of gcc/gnatbind");
393 Write_Eol;
395 -- Find start of line
397 Ptr1 := P;
398 while Ptr1 > T'First
399 and then T (Ptr1 - 1) /= CR
400 and then T (Ptr1 - 1) /= LF
401 loop
402 Ptr1 := Ptr1 - 1;
403 end loop;
405 Write_Int (Int (Line));
406 Write_Str (". ");
408 if Line < 100 then
409 Write_Char (' ');
410 end if;
412 if Line < 10 then
413 Write_Char (' ');
414 end if;
416 Col := 0;
417 Ptr2 := Ptr1;
419 while Ptr2 < T'Last
420 and then T (Ptr2) /= CR
421 and then T (Ptr2) /= LF
422 loop
423 Wchar (T (Ptr2));
424 Ptr2 := Ptr2 + 1;
425 end loop;
427 Write_Eol;
429 Write_Str (" ");
430 Col := 0;
432 while Ptr1 < P loop
433 if T (Ptr1) = HT then
434 Wchar (HT);
435 else
436 Wchar (' ');
437 end if;
439 Ptr1 := Ptr1 + 1;
440 end loop;
442 Wchar ('|');
443 Write_Eol;
445 Exit_Program (E_Fatal);
446 end Fatal_Error;
448 ------------------------
449 -- Fatal_Error_Ignore --
450 ------------------------
452 procedure Fatal_Error_Ignore is
453 begin
454 if not Ignore_Errors then
455 Fatal_Error;
456 end if;
457 end Fatal_Error_Ignore;
459 -------------------
460 -- Get_File_Name --
461 -------------------
463 function Get_File_Name
464 (Lower : Boolean := False;
465 May_Be_Quoted : Boolean := False) return File_Name_Type
467 F : Name_Id;
469 begin
470 F := Get_Name (Ignore_Special => True,
471 May_Be_Quoted => May_Be_Quoted);
473 -- Convert file name to all lower case if file names are not case
474 -- sensitive. This ensures that we handle names in the canonical
475 -- lower case format, regardless of the actual case.
477 if Lower and not File_Names_Case_Sensitive then
478 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
479 return Name_Find;
480 else
481 return File_Name_Type (F);
482 end if;
483 end Get_File_Name;
485 --------------
486 -- Get_Name --
487 --------------
489 function Get_Name
490 (Ignore_Spaces : Boolean := False;
491 Ignore_Special : Boolean := False;
492 May_Be_Quoted : Boolean := False) return Name_Id
494 Char : Character;
496 begin
497 Name_Len := 0;
498 Skip_Space;
500 if At_Eol then
501 if Ignore_Errors then
502 return Error_Name;
503 else
504 Fatal_Error;
505 end if;
506 end if;
508 Char := Getc;
510 -- Deal with quoted characters
512 if May_Be_Quoted and then Char = '"' then
513 loop
514 if At_Eol then
515 if Ignore_Errors then
516 return Error_Name;
517 else
518 Fatal_Error;
519 end if;
520 end if;
522 Char := Getc;
524 if Char = '"' then
525 if At_Eol then
526 exit;
528 else
529 Char := Getc;
531 if Char /= '"' then
532 P := P - 1;
533 exit;
534 end if;
535 end if;
536 end if;
538 Add_Char_To_Name_Buffer (Char);
539 end loop;
541 -- Other than case of quoted character
543 else
544 P := P - 1;
545 loop
546 Add_Char_To_Name_Buffer (Getc);
548 exit when At_End_Of_Field and then not Ignore_Spaces;
550 if not Ignore_Special then
551 if Name_Buffer (1) = '"' then
552 exit when Name_Len > 1
553 and then Name_Buffer (Name_Len) = '"';
555 else
556 -- Terminate on parens or angle brackets or equal sign
558 exit when Nextc = '(' or else Nextc = ')'
559 or else Nextc = '{' or else Nextc = '}'
560 or else Nextc = '<' or else Nextc = '>'
561 or else Nextc = '=';
563 -- Terminate on comma
565 exit when Nextc = ',';
567 -- Terminate if left bracket not part of wide char
568 -- sequence Note that we only recognize brackets
569 -- notation so far ???
571 exit when Nextc = '[' and then T (P + 1) /= '"';
573 -- Terminate if right bracket not part of wide char
574 -- sequence.
576 exit when Nextc = ']' and then T (P - 1) /= '"';
577 end if;
578 end if;
579 end loop;
580 end if;
582 return Name_Find;
583 end Get_Name;
585 -------------------
586 -- Get_Unit_Name --
587 -------------------
589 function Get_Unit_Name return Unit_Name_Type is
590 begin
591 return Unit_Name_Type (Get_Name);
592 end Get_Unit_Name;
594 -------------
595 -- Get_Nat --
596 -------------
598 function Get_Nat return Nat is
599 V : Nat;
601 begin
602 Skip_Space;
604 -- Check if we are on a number. In the case of bad ALI files, this
605 -- may not be true.
607 if not (Nextc in '0' .. '9') then
608 Fatal_Error;
609 end if;
611 V := 0;
612 loop
613 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
615 exit when At_End_Of_Field;
616 exit when Nextc < '0' or else Nextc > '9';
617 end loop;
619 return V;
620 end Get_Nat;
622 ---------------
623 -- Get_Stamp --
624 ---------------
626 function Get_Stamp return Time_Stamp_Type is
627 T : Time_Stamp_Type;
628 Start : Integer;
630 begin
631 Skip_Space;
633 if At_Eol then
634 if Ignore_Errors then
635 return Dummy_Time_Stamp;
636 else
637 Fatal_Error;
638 end if;
639 end if;
641 -- Following reads old style time stamp missing first two digits
643 if Nextc in '7' .. '9' then
644 T (1) := '1';
645 T (2) := '9';
646 Start := 3;
648 -- Normal case of full year in time stamp
650 else
651 Start := 1;
652 end if;
654 for J in Start .. T'Last loop
655 T (J) := Getc;
656 end loop;
658 return T;
659 end Get_Stamp;
661 -----------------
662 -- Get_Typeref --
663 -----------------
665 procedure Get_Typeref
666 (Current_File_Num : Sdep_Id;
667 Ref : out Tref_Kind;
668 File_Num : out Sdep_Id;
669 Line : out Nat;
670 Ref_Type : out Character;
671 Col : out Nat;
672 Standard_Entity : out Name_Id)
674 N : Nat;
675 begin
676 case Nextc is
677 when '<' => Ref := Tref_Derived;
678 when '(' => Ref := Tref_Access;
679 when '{' => Ref := Tref_Type;
680 when others => Ref := Tref_None;
681 end case;
683 -- Case of typeref field present
685 if Ref /= Tref_None then
686 P := P + 1; -- skip opening bracket
688 if Nextc in 'a' .. 'z' then
689 File_Num := No_Sdep_Id;
690 Line := 0;
691 Ref_Type := ' ';
692 Col := 0;
693 Standard_Entity := Get_Name (Ignore_Spaces => True);
694 else
695 N := Get_Nat;
697 if Nextc = '|' then
698 File_Num := Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
699 P := P + 1;
700 N := Get_Nat;
701 else
702 File_Num := Current_File_Num;
703 end if;
705 Line := N;
706 Ref_Type := Getc;
707 Col := Get_Nat;
708 Standard_Entity := No_Name;
709 end if;
711 -- ??? Temporary workaround for nested generics case:
712 -- 4i4 Directories{1|4I9[4|6[3|3]]}
713 -- See C918-002
715 declare
716 Nested_Brackets : Natural := 0;
718 begin
719 loop
720 case Nextc is
721 when '[' =>
722 Nested_Brackets := Nested_Brackets + 1;
723 when ']' =>
724 Nested_Brackets := Nested_Brackets - 1;
725 when others =>
726 if Nested_Brackets = 0 then
727 exit;
728 end if;
729 end case;
731 Skipc;
732 end loop;
733 end;
735 P := P + 1; -- skip closing bracket
736 Skip_Space;
738 -- No typeref entry present
740 else
741 File_Num := No_Sdep_Id;
742 Line := 0;
743 Ref_Type := ' ';
744 Col := 0;
745 Standard_Entity := No_Name;
746 end if;
747 end Get_Typeref;
749 ----------
750 -- Getc --
751 ----------
753 function Getc return Character is
754 begin
755 if P = T'Last then
756 return EOF;
757 else
758 P := P + 1;
759 return T (P - 1);
760 end if;
761 end Getc;
763 -----------
764 -- Nextc --
765 -----------
767 function Nextc return Character is
768 begin
769 return T (P);
770 end Nextc;
772 --------------
773 -- Skip_Eol --
774 --------------
776 procedure Skip_Eol is
777 begin
778 Skip_Space;
780 if not At_Eol then
781 if Ignore_Errors then
782 while not At_Eol loop
783 P := P + 1;
784 end loop;
785 else
786 Fatal_Error;
787 end if;
788 end if;
790 -- Loop to skip past blank lines (first time through skips this EOL)
792 while Nextc < ' ' and then Nextc /= EOF loop
793 if Nextc = LF then
794 Line := Line + 1;
795 end if;
797 P := P + 1;
798 end loop;
799 end Skip_Eol;
801 ---------------
802 -- Skip_Line --
803 ---------------
805 procedure Skip_Line is
806 begin
807 while not At_Eol loop
808 P := P + 1;
809 end loop;
811 Skip_Eol;
812 end Skip_Line;
814 ----------------
815 -- Skip_Space --
816 ----------------
818 procedure Skip_Space is
819 begin
820 while Nextc = ' ' or else Nextc = HT loop
821 P := P + 1;
822 end loop;
823 end Skip_Space;
825 -----------
826 -- Skipc --
827 -----------
829 procedure Skipc is
830 begin
831 if P /= T'Last then
832 P := P + 1;
833 end if;
834 end Skipc;
836 -- Start of processing for Scan_ALI
838 begin
839 First_Sdep_Entry := Sdep.Last + 1;
841 -- Acquire lines to be ignored
843 if Read_Xref then
844 Ignore :=
845 ('U' | 'W' | 'Y' | 'Z' | 'D' | 'X' => False, others => True);
847 -- Read_Lines parameter given
849 elsif Read_Lines /= "" then
850 Ignore := ('U' => False, others => True);
852 for J in Read_Lines'Range loop
853 Ignore (Read_Lines (J)) := False;
854 end loop;
856 -- Process Ignore_Lines parameter
858 else
859 Ignore := (others => False);
861 for J in Ignore_Lines'Range loop
862 pragma Assert (Ignore_Lines (J) /= 'U');
863 Ignore (Ignore_Lines (J)) := True;
864 end loop;
865 end if;
867 -- Setup ALI Table entry with appropriate defaults
869 ALIs.Increment_Last;
870 Id := ALIs.Last;
871 Set_Name_Table_Int (F, Int (Id));
873 ALIs.Table (Id) := (
874 Afile => F,
875 Compile_Errors => False,
876 First_Interrupt_State => Interrupt_States.Last + 1,
877 First_Sdep => No_Sdep_Id,
878 First_Specific_Dispatching => Specific_Dispatching.Last + 1,
879 First_Unit => No_Unit_Id,
880 GNATprove_Mode => False,
881 Last_Interrupt_State => Interrupt_States.Last,
882 Last_Sdep => No_Sdep_Id,
883 Last_Specific_Dispatching => Specific_Dispatching.Last,
884 Last_Unit => No_Unit_Id,
885 Locking_Policy => ' ',
886 Main_Priority => -1,
887 Main_CPU => -1,
888 Main_Program => None,
889 No_Component_Reordering => False,
890 No_Object => False,
891 Normalize_Scalars => False,
892 Ofile_Full_Name => Full_Object_File_Name,
893 Partition_Elaboration_Policy => ' ',
894 Queuing_Policy => ' ',
895 Restrictions => No_Restrictions,
896 SAL_Interface => False,
897 Sfile => No_File,
898 SSO_Default => ' ',
899 Task_Dispatching_Policy => ' ',
900 Time_Slice_Value => -1,
901 WC_Encoding => 'b',
902 Unit_Exception_Table => False,
903 Ver => (others => ' '),
904 Ver_Len => 0,
905 Frontend_Exceptions => False,
906 Zero_Cost_Exceptions => False);
908 -- Now we acquire the input lines from the ALI file. Note that the
909 -- convention in the following code is that as we enter each section,
910 -- C is set to contain the first character of the following line.
912 C := Getc;
913 Check_Unknown_Line;
915 -- Acquire library version
917 if C /= 'V' then
919 -- The V line missing really indicates trouble, most likely it
920 -- means we don't have an ALI file at all, so here we give a
921 -- fatal error even if we are in Ignore_Errors mode.
923 Fatal_Error;
925 elsif Ignore ('V') then
926 Skip_Line;
928 else
929 Checkc (' ');
930 Skip_Space;
931 Checkc ('"');
933 for J in 1 .. Ver_Len_Max loop
934 C := Getc;
935 exit when C = '"';
936 ALIs.Table (Id).Ver (J) := C;
937 ALIs.Table (Id).Ver_Len := J;
938 end loop;
940 Skip_Eol;
941 end if;
943 C := Getc;
944 Check_Unknown_Line;
946 -- Acquire main program line if present
948 if C = 'M' then
949 if Ignore ('M') then
950 Skip_Line;
952 else
953 Checkc (' ');
954 Skip_Space;
956 C := Getc;
958 if C = 'F' then
959 ALIs.Table (Id).Main_Program := Func;
960 elsif C = 'P' then
961 ALIs.Table (Id).Main_Program := Proc;
962 else
963 P := P - 1;
964 Fatal_Error;
965 end if;
967 Skip_Space;
969 if not At_Eol then
970 if Nextc < 'A' then
971 ALIs.Table (Id).Main_Priority := Get_Nat;
972 end if;
974 Skip_Space;
976 if Nextc = 'T' then
977 P := P + 1;
978 Checkc ('=');
979 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
980 end if;
982 Skip_Space;
984 if Nextc = 'C' then
985 P := P + 1;
986 Checkc ('=');
987 ALIs.Table (Id).Main_CPU := Get_Nat;
988 end if;
990 Skip_Space;
992 Checkc ('W');
993 Checkc ('=');
994 ALIs.Table (Id).WC_Encoding := Getc;
995 end if;
997 Skip_Eol;
998 end if;
1000 C := Getc;
1001 end if;
1003 -- Acquire argument lines
1005 First_Arg := Args.Last + 1;
1007 A_Loop : loop
1008 Check_Unknown_Line;
1009 exit A_Loop when C /= 'A';
1011 if Ignore ('A') then
1012 Skip_Line;
1014 else
1015 Checkc (' ');
1017 -- Scan out argument
1019 Name_Len := 0;
1020 while not At_Eol loop
1021 Add_Char_To_Name_Buffer (Getc);
1022 end loop;
1024 -- If -fstack-check, record that it occurred. Note that an
1025 -- additional string parameter can be specified, in the form of
1026 -- -fstack-check={no|generic|specific}. "no" means no checking,
1027 -- "generic" means force the use of old-style checking, and
1028 -- "specific" means use the best checking method.
1030 if Name_Len >= 13
1031 and then Name_Buffer (1 .. 13) = "-fstack-check"
1032 and then Name_Buffer (1 .. Name_Len) /= "-fstack-check=no"
1033 then
1034 Stack_Check_Switch_Set := True;
1035 end if;
1037 -- Store the argument
1039 Args.Increment_Last;
1040 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
1042 Skip_Eol;
1043 end if;
1045 C := Getc;
1046 end loop A_Loop;
1048 -- Acquire P line
1050 Check_Unknown_Line;
1052 while C /= 'P' loop
1053 if Ignore_Errors then
1054 if C = EOF then
1055 Fatal_Error;
1056 else
1057 Skip_Line;
1058 C := Nextc;
1059 end if;
1060 else
1061 Fatal_Error;
1062 end if;
1063 end loop;
1065 if Ignore ('P') then
1066 Skip_Line;
1068 -- Process P line
1070 else
1071 NS_Found := False;
1073 while not At_Eol loop
1074 Checkc (' ');
1075 Skip_Space;
1076 C := Getc;
1078 -- Processing for CE
1080 if C = 'C' then
1081 Checkc ('E');
1082 ALIs.Table (Id).Compile_Errors := True;
1084 -- Processing for DB
1086 elsif C = 'D' then
1087 Checkc ('B');
1088 Detect_Blocking := True;
1090 -- Processing for Ex
1092 elsif C = 'E' then
1093 Partition_Elaboration_Policy_Specified := Getc;
1094 ALIs.Table (Id).Partition_Elaboration_Policy :=
1095 Partition_Elaboration_Policy_Specified;
1097 -- Processing for FX
1099 elsif C = 'F' then
1100 C := Getc;
1102 if C = 'X' then
1103 ALIs.Table (Id).Frontend_Exceptions := True;
1104 Frontend_Exceptions_Specified := True;
1105 else
1106 Fatal_Error_Ignore;
1107 end if;
1109 -- Processing for GP
1111 elsif C = 'G' then
1112 Checkc ('P');
1113 GNATprove_Mode_Specified := True;
1114 ALIs.Table (Id).GNATprove_Mode := True;
1116 -- Processing for Lx
1118 elsif C = 'L' then
1119 Locking_Policy_Specified := Getc;
1120 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1122 -- Processing for flags starting with N
1124 elsif C = 'N' then
1125 C := Getc;
1127 -- Processing for NC
1129 if C = 'C' then
1130 ALIs.Table (Id).No_Component_Reordering := True;
1131 No_Component_Reordering_Specified := True;
1133 -- Processing for NO
1135 elsif C = 'O' then
1136 ALIs.Table (Id).No_Object := True;
1137 No_Object_Specified := True;
1139 -- Processing for NR
1141 elsif C = 'R' then
1142 No_Run_Time_Mode := True;
1143 Configurable_Run_Time_Mode := True;
1145 -- Processing for NS
1147 elsif C = 'S' then
1148 ALIs.Table (Id).Normalize_Scalars := True;
1149 Normalize_Scalars_Specified := True;
1150 NS_Found := True;
1152 -- Invalid switch starting with N
1154 else
1155 Fatal_Error_Ignore;
1156 end if;
1158 -- Processing for OH/OL
1160 elsif C = 'O' then
1161 C := Getc;
1163 if C = 'L' or else C = 'H' then
1164 ALIs.Table (Id).SSO_Default := C;
1165 SSO_Default_Specified := True;
1167 else
1168 Fatal_Error_Ignore;
1169 end if;
1171 -- Processing for Qx
1173 elsif C = 'Q' then
1174 Queuing_Policy_Specified := Getc;
1175 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1177 -- Processing for flags starting with S
1179 elsif C = 'S' then
1180 C := Getc;
1182 -- Processing for SL
1184 if C = 'L' then
1185 ALIs.Table (Id).SAL_Interface := True;
1187 -- Processing for SS
1189 elsif C = 'S' then
1190 Opt.Sec_Stack_Used := True;
1192 -- Invalid switch starting with S
1194 else
1195 Fatal_Error_Ignore;
1196 end if;
1198 -- Processing for Tx
1200 elsif C = 'T' then
1201 Task_Dispatching_Policy_Specified := Getc;
1202 ALIs.Table (Id).Task_Dispatching_Policy :=
1203 Task_Dispatching_Policy_Specified;
1205 -- Processing for switch starting with U
1207 elsif C = 'U' then
1208 C := Getc;
1210 -- Processing for UA
1212 if C = 'A' then
1213 Unreserve_All_Interrupts_Specified := True;
1215 -- Processing for UX
1217 elsif C = 'X' then
1218 ALIs.Table (Id).Unit_Exception_Table := True;
1220 -- Invalid switches starting with U
1222 else
1223 Fatal_Error_Ignore;
1224 end if;
1226 -- Processing for ZX
1228 elsif C = 'Z' then
1229 C := Getc;
1231 if C = 'X' then
1232 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1233 Zero_Cost_Exceptions_Specified := True;
1234 else
1235 Fatal_Error_Ignore;
1236 end if;
1238 -- Invalid parameter
1240 else
1241 C := Getc;
1242 Fatal_Error_Ignore;
1243 end if;
1244 end loop;
1246 if not NS_Found then
1247 No_Normalize_Scalars_Specified := True;
1248 end if;
1250 Skip_Eol;
1251 end if;
1253 C := Getc;
1254 Check_Unknown_Line;
1256 -- Loop to skip to first restrictions line
1258 while C /= 'R' loop
1259 if Ignore_Errors then
1260 if C = EOF then
1261 Fatal_Error;
1262 else
1263 Skip_Line;
1264 C := Nextc;
1265 end if;
1266 else
1267 Fatal_Error;
1268 end if;
1269 end loop;
1271 -- Ignore all 'R' lines if that is required
1273 if Ignore ('R') then
1274 while C = 'R' loop
1275 Skip_Line;
1276 C := Getc;
1277 end loop;
1279 -- Here we process the restrictions lines (other than unit name cases)
1281 else
1282 Scan_Restrictions : declare
1283 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1284 -- Save cumulative restrictions in case we have a fatal error
1286 Bad_R_Line : exception;
1287 -- Signal bad restrictions line (raised on unexpected character)
1289 Typ : Character;
1290 R : Restriction_Id;
1291 N : Natural;
1293 begin
1294 -- Named restriction case
1296 if Nextc = 'N' then
1297 Skip_Line;
1298 C := Getc;
1300 -- Loop through RR and RV lines
1302 while C = 'R' and then Nextc /= ' ' loop
1303 Typ := Getc;
1304 Checkc (' ');
1306 -- Acquire restriction name
1308 Name_Len := 0;
1309 while not At_Eol and then Nextc /= '=' loop
1310 Name_Len := Name_Len + 1;
1311 Name_Buffer (Name_Len) := Getc;
1312 end loop;
1314 -- Now search list of restrictions to find match
1316 declare
1317 RN : String renames Name_Buffer (1 .. Name_Len);
1319 begin
1320 R := Restriction_Id'First;
1321 while R /= Not_A_Restriction_Id loop
1322 if Restriction_Id'Image (R) = RN then
1323 goto R_Found;
1324 end if;
1326 R := Restriction_Id'Succ (R);
1327 end loop;
1329 -- We don't recognize the restriction. This might be
1330 -- thought of as an error, and it really is, but we
1331 -- want to allow building with inconsistent versions
1332 -- of the binder and ali files (see comments at the
1333 -- start of package System.Rident), so we just ignore
1334 -- this situation.
1336 goto Done_With_Restriction_Line;
1337 end;
1339 <<R_Found>>
1341 case R is
1343 -- Boolean restriction case
1345 when All_Boolean_Restrictions =>
1346 case Typ is
1347 when 'V' =>
1348 ALIs.Table (Id).Restrictions.Violated (R) :=
1349 True;
1350 Cumulative_Restrictions.Violated (R) := True;
1352 when 'R' =>
1353 ALIs.Table (Id).Restrictions.Set (R) := True;
1354 Cumulative_Restrictions.Set (R) := True;
1356 when others =>
1357 raise Bad_R_Line;
1358 end case;
1360 -- Parameter restriction case
1362 when All_Parameter_Restrictions =>
1363 if At_Eol or else Nextc /= '=' then
1364 raise Bad_R_Line;
1365 else
1366 Skipc;
1367 end if;
1369 N := Natural (Get_Nat);
1371 case Typ is
1373 -- Restriction set
1375 when 'R' =>
1376 ALIs.Table (Id).Restrictions.Set (R) := True;
1377 ALIs.Table (Id).Restrictions.Value (R) := N;
1379 if Cumulative_Restrictions.Set (R) then
1380 Cumulative_Restrictions.Value (R) :=
1381 Integer'Min
1382 (Cumulative_Restrictions.Value (R), N);
1383 else
1384 Cumulative_Restrictions.Set (R) := True;
1385 Cumulative_Restrictions.Value (R) := N;
1386 end if;
1388 -- Restriction violated
1390 when 'V' =>
1391 ALIs.Table (Id).Restrictions.Violated (R) :=
1392 True;
1393 Cumulative_Restrictions.Violated (R) := True;
1394 ALIs.Table (Id).Restrictions.Count (R) := N;
1396 -- Checked Max_Parameter case
1398 if R in Checked_Max_Parameter_Restrictions then
1399 Cumulative_Restrictions.Count (R) :=
1400 Integer'Max
1401 (Cumulative_Restrictions.Count (R), N);
1403 -- Other checked parameter cases
1405 else
1406 declare
1407 pragma Unsuppress (Overflow_Check);
1409 begin
1410 Cumulative_Restrictions.Count (R) :=
1411 Cumulative_Restrictions.Count (R) + N;
1413 exception
1414 when Constraint_Error =>
1416 -- A constraint error comes from the
1417 -- addition. We reset to the maximum
1418 -- and indicate that the real value
1419 -- is now unknown.
1421 Cumulative_Restrictions.Value (R) :=
1422 Integer'Last;
1423 Cumulative_Restrictions.Unknown (R) :=
1424 True;
1425 end;
1426 end if;
1428 -- Deal with + case
1430 if Nextc = '+' then
1431 Skipc;
1432 ALIs.Table (Id).Restrictions.Unknown (R) :=
1433 True;
1434 Cumulative_Restrictions.Unknown (R) := True;
1435 end if;
1437 -- Other than 'R' or 'V'
1439 when others =>
1440 raise Bad_R_Line;
1441 end case;
1443 if not At_Eol then
1444 raise Bad_R_Line;
1445 end if;
1447 -- Bizarre error case NOT_A_RESTRICTION
1449 when Not_A_Restriction_Id =>
1450 raise Bad_R_Line;
1451 end case;
1453 if not At_Eol then
1454 raise Bad_R_Line;
1455 end if;
1457 <<Done_With_Restriction_Line>>
1458 Skip_Line;
1459 C := Getc;
1460 end loop;
1462 -- Positional restriction case
1464 else
1465 Checkc (' ');
1466 Skip_Space;
1468 -- Acquire information for boolean restrictions
1470 for R in All_Boolean_Restrictions loop
1471 C := Getc;
1473 case C is
1474 when 'v' =>
1475 ALIs.Table (Id).Restrictions.Violated (R) := True;
1476 Cumulative_Restrictions.Violated (R) := True;
1478 when 'r' =>
1479 ALIs.Table (Id).Restrictions.Set (R) := True;
1480 Cumulative_Restrictions.Set (R) := True;
1482 when 'n' =>
1483 null;
1485 when others =>
1486 raise Bad_R_Line;
1487 end case;
1488 end loop;
1490 -- Acquire information for parameter restrictions
1492 for RP in All_Parameter_Restrictions loop
1493 case Getc is
1494 when 'n' =>
1495 null;
1497 when 'r' =>
1498 ALIs.Table (Id).Restrictions.Set (RP) := True;
1500 declare
1501 N : constant Integer := Integer (Get_Nat);
1502 begin
1503 ALIs.Table (Id).Restrictions.Value (RP) := N;
1505 if Cumulative_Restrictions.Set (RP) then
1506 Cumulative_Restrictions.Value (RP) :=
1507 Integer'Min
1508 (Cumulative_Restrictions.Value (RP), N);
1509 else
1510 Cumulative_Restrictions.Set (RP) := True;
1511 Cumulative_Restrictions.Value (RP) := N;
1512 end if;
1513 end;
1515 when others =>
1516 raise Bad_R_Line;
1517 end case;
1519 -- Acquire restrictions violations information
1521 case Getc is
1523 when 'n' =>
1524 null;
1526 when 'v' =>
1527 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1528 Cumulative_Restrictions.Violated (RP) := True;
1530 declare
1531 N : constant Integer := Integer (Get_Nat);
1533 begin
1534 ALIs.Table (Id).Restrictions.Count (RP) := N;
1536 if RP in Checked_Max_Parameter_Restrictions then
1537 Cumulative_Restrictions.Count (RP) :=
1538 Integer'Max
1539 (Cumulative_Restrictions.Count (RP), N);
1541 else
1542 declare
1543 pragma Unsuppress (Overflow_Check);
1545 begin
1546 Cumulative_Restrictions.Count (RP) :=
1547 Cumulative_Restrictions.Count (RP) + N;
1549 exception
1550 when Constraint_Error =>
1552 -- A constraint error comes from the add. We
1553 -- reset to the maximum and indicate that the
1554 -- real value is now unknown.
1556 Cumulative_Restrictions.Value (RP) :=
1557 Integer'Last;
1558 Cumulative_Restrictions.Unknown (RP) := True;
1559 end;
1560 end if;
1562 if Nextc = '+' then
1563 Skipc;
1564 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1565 Cumulative_Restrictions.Unknown (RP) := True;
1566 end if;
1567 end;
1569 when others =>
1570 raise Bad_R_Line;
1571 end case;
1572 end loop;
1574 if not At_Eol then
1575 raise Bad_R_Line;
1576 else
1577 Skip_Line;
1578 C := Getc;
1579 end if;
1580 end if;
1582 -- Here if error during scanning of restrictions line
1584 exception
1585 when Bad_R_Line =>
1587 -- In Ignore_Errors mode, undo any changes to restrictions
1588 -- from this unit, and continue on, skipping remaining R
1589 -- lines for this unit.
1591 if Ignore_Errors then
1592 Cumulative_Restrictions := Save_R;
1593 ALIs.Table (Id).Restrictions := No_Restrictions;
1595 loop
1596 Skip_Eol;
1597 C := Getc;
1598 exit when C /= 'R';
1599 end loop;
1601 -- In normal mode, this is a fatal error
1603 else
1604 Fatal_Error;
1605 end if;
1606 end Scan_Restrictions;
1607 end if;
1609 -- Acquire additional restrictions (No_Dependence) lines if present
1611 while C = 'R' loop
1612 if Ignore ('R') then
1613 Skip_Line;
1614 else
1615 Skip_Space;
1616 No_Deps.Append ((Id, Get_Name));
1617 Skip_Eol;
1618 end if;
1620 C := Getc;
1621 end loop;
1623 -- Acquire 'I' lines if present
1625 Check_Unknown_Line;
1627 while C = 'I' loop
1628 if Ignore ('I') then
1629 Skip_Line;
1631 else
1632 declare
1633 Int_Num : Nat;
1634 I_State : Character;
1635 Line_No : Nat;
1637 begin
1638 Int_Num := Get_Nat;
1639 Skip_Space;
1640 I_State := Getc;
1641 Line_No := Get_Nat;
1643 Interrupt_States.Append (
1644 (Interrupt_Id => Int_Num,
1645 Interrupt_State => I_State,
1646 IS_Pragma_Line => Line_No));
1648 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1649 Skip_Eol;
1650 end;
1651 end if;
1653 C := Getc;
1654 end loop;
1656 -- Acquire 'S' lines if present
1658 Check_Unknown_Line;
1660 while C = 'S' loop
1661 if Ignore ('S') then
1662 Skip_Line;
1664 else
1665 declare
1666 Policy : Character;
1667 First_Prio : Nat;
1668 Last_Prio : Nat;
1669 Line_No : Nat;
1671 begin
1672 Checkc (' ');
1673 Skip_Space;
1675 Policy := Getc;
1676 Skip_Space;
1677 First_Prio := Get_Nat;
1678 Last_Prio := Get_Nat;
1679 Line_No := Get_Nat;
1681 Specific_Dispatching.Append (
1682 (Dispatching_Policy => Policy,
1683 First_Priority => First_Prio,
1684 Last_Priority => Last_Prio,
1685 PSD_Pragma_Line => Line_No));
1687 ALIs.Table (Id).Last_Specific_Dispatching :=
1688 Specific_Dispatching.Last;
1690 Skip_Eol;
1691 end;
1692 end if;
1694 C := Getc;
1695 end loop;
1697 -- Loop to acquire unit entries
1699 U_Loop : loop
1700 Check_Unknown_Line;
1701 exit U_Loop when C /= 'U';
1703 -- Note: as per spec, we never ignore U lines
1705 Checkc (' ');
1706 Skip_Space;
1707 Units.Increment_Last;
1709 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1710 ALIs.Table (Id).First_Unit := Units.Last;
1711 end if;
1713 declare
1714 UL : Unit_Record renames Units.Table (Units.Last);
1716 begin
1717 UL.Uname := Get_Unit_Name;
1718 UL.Predefined := Is_Predefined_Unit;
1719 UL.Internal := Is_Internal_Unit;
1720 UL.My_ALI := Id;
1721 UL.Sfile := Get_File_Name (Lower => True);
1722 UL.Pure := False;
1723 UL.Preelab := False;
1724 UL.No_Elab := False;
1725 UL.Shared_Passive := False;
1726 UL.RCI := False;
1727 UL.Remote_Types := False;
1728 UL.Serious_Errors := False;
1729 UL.Has_RACW := False;
1730 UL.Init_Scalars := False;
1731 UL.Is_Generic := False;
1732 UL.Icasing := Mixed_Case;
1733 UL.Kcasing := All_Lower_Case;
1734 UL.Dynamic_Elab := False;
1735 UL.Elaborate_Body := False;
1736 UL.Set_Elab_Entity := False;
1737 UL.Version := "00000000";
1738 UL.First_With := Withs.Last + 1;
1739 UL.First_Arg := First_Arg;
1740 UL.Elab_Position := 0;
1741 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1742 UL.Directly_Scanned := Directly_Scanned;
1743 UL.Body_Needed_For_SAL := False;
1744 UL.Elaborate_Body_Desirable := False;
1745 UL.Optimize_Alignment := 'O';
1746 UL.Has_Finalizer := False;
1748 if Debug_Flag_U then
1749 Write_Str (" ----> reading unit ");
1750 Write_Int (Int (Units.Last));
1751 Write_Str (" ");
1752 Write_Unit_Name (UL.Uname);
1753 Write_Str (" from file ");
1754 Write_Name (UL.Sfile);
1755 Write_Eol;
1756 end if;
1757 end;
1759 -- Check for duplicated unit in different files
1761 declare
1762 Info : constant Int := Get_Name_Table_Int
1763 (Units.Table (Units.Last).Uname);
1764 begin
1765 if Info /= 0
1766 and then Units.Table (Units.Last).Sfile /=
1767 Units.Table (Unit_Id (Info)).Sfile
1768 then
1769 -- If Err is set then ignore duplicate unit name. This is the
1770 -- case of a call from gnatmake, where the situation can arise
1771 -- from substitution of source files. In such situations, the
1772 -- processing in gnatmake will always result in any required
1773 -- recompilations in any case, and if we consider this to be
1774 -- an error we get strange cases (for example when a generic
1775 -- instantiation is replaced by a normal package) where we
1776 -- read the old ali file, decide to recompile, and then decide
1777 -- that the old and new ali files are incompatible.
1779 if Err then
1780 null;
1782 -- If Err is not set, then this is a fatal error. This is
1783 -- the case of being called from the binder, where we must
1784 -- definitely diagnose this as an error.
1786 else
1787 Set_Standard_Error;
1788 Write_Str ("error: duplicate unit name: ");
1789 Write_Eol;
1791 Write_Str ("error: unit """);
1792 Write_Unit_Name (Units.Table (Units.Last).Uname);
1793 Write_Str (""" found in file """);
1794 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1795 Write_Char ('"');
1796 Write_Eol;
1798 Write_Str ("error: unit """);
1799 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1800 Write_Str (""" found in file """);
1801 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1802 Write_Char ('"');
1803 Write_Eol;
1805 Exit_Program (E_Fatal);
1806 end if;
1807 end if;
1808 end;
1810 Set_Name_Table_Int
1811 (Units.Table (Units.Last).Uname, Int (Units.Last));
1813 -- Scan out possible version and other parameters
1815 loop
1816 Skip_Space;
1817 exit when At_Eol;
1818 C := Getc;
1820 -- Version field
1822 if C in '0' .. '9' or else C in 'a' .. 'f' then
1823 Units.Table (Units.Last).Version (1) := C;
1825 for J in 2 .. 8 loop
1826 C := Getc;
1827 Units.Table (Units.Last).Version (J) := C;
1828 end loop;
1830 -- BD/BN parameters
1832 elsif C = 'B' then
1833 C := Getc;
1835 if C = 'D' then
1836 Check_At_End_Of_Field;
1837 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1839 elsif C = 'N' then
1840 Check_At_End_Of_Field;
1841 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1843 else
1844 Fatal_Error_Ignore;
1845 end if;
1847 -- DE parameter (Dynamic elaboration checks)
1849 elsif C = 'D' then
1850 C := Getc;
1852 if C = 'E' then
1853 Check_At_End_Of_Field;
1854 Units.Table (Units.Last).Dynamic_Elab := True;
1855 Dynamic_Elaboration_Checks_Specified := True;
1856 else
1857 Fatal_Error_Ignore;
1858 end if;
1860 -- EB/EE parameters
1862 elsif C = 'E' then
1863 C := Getc;
1865 if C = 'B' then
1866 Units.Table (Units.Last).Elaborate_Body := True;
1867 elsif C = 'E' then
1868 Units.Table (Units.Last).Set_Elab_Entity := True;
1869 else
1870 Fatal_Error_Ignore;
1871 end if;
1873 Check_At_End_Of_Field;
1875 -- GE parameter (generic)
1877 elsif C = 'G' then
1878 C := Getc;
1880 if C = 'E' then
1881 Check_At_End_Of_Field;
1882 Units.Table (Units.Last).Is_Generic := True;
1883 else
1884 Fatal_Error_Ignore;
1885 end if;
1887 -- IL/IS/IU parameters
1889 elsif C = 'I' then
1890 C := Getc;
1892 if C = 'L' then
1893 Units.Table (Units.Last).Icasing := All_Lower_Case;
1894 elsif C = 'S' then
1895 Units.Table (Units.Last).Init_Scalars := True;
1896 Initialize_Scalars_Used := True;
1897 elsif C = 'U' then
1898 Units.Table (Units.Last).Icasing := All_Upper_Case;
1899 else
1900 Fatal_Error_Ignore;
1901 end if;
1903 Check_At_End_Of_Field;
1905 -- KM/KU parameters
1907 elsif C = 'K' then
1908 C := Getc;
1910 if C = 'M' then
1911 Units.Table (Units.Last).Kcasing := Mixed_Case;
1912 elsif C = 'U' then
1913 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1914 else
1915 Fatal_Error_Ignore;
1916 end if;
1918 Check_At_End_Of_Field;
1920 -- NE parameter
1922 elsif C = 'N' then
1923 C := Getc;
1925 if C = 'E' then
1926 Units.Table (Units.Last).No_Elab := True;
1927 Check_At_End_Of_Field;
1928 else
1929 Fatal_Error_Ignore;
1930 end if;
1932 -- PF/PR/PU/PK parameters
1934 elsif C = 'P' then
1935 C := Getc;
1937 if C = 'F' then
1938 Units.Table (Units.Last).Has_Finalizer := True;
1939 elsif C = 'R' then
1940 Units.Table (Units.Last).Preelab := True;
1941 elsif C = 'U' then
1942 Units.Table (Units.Last).Pure := True;
1943 elsif C = 'K' then
1944 Units.Table (Units.Last).Unit_Kind := 'p';
1945 else
1946 Fatal_Error_Ignore;
1947 end if;
1949 Check_At_End_Of_Field;
1951 -- OL/OO/OS/OT parameters
1953 elsif C = 'O' then
1954 C := Getc;
1956 if C = 'L' or else C = 'O' or else C = 'S' or else C = 'T' then
1957 Units.Table (Units.Last).Optimize_Alignment := C;
1958 else
1959 Fatal_Error_Ignore;
1960 end if;
1962 Check_At_End_Of_Field;
1964 -- RC/RT parameters
1966 elsif C = 'R' then
1967 C := Getc;
1969 if C = 'C' then
1970 Units.Table (Units.Last).RCI := True;
1971 elsif C = 'T' then
1972 Units.Table (Units.Last).Remote_Types := True;
1973 elsif C = 'A' then
1974 Units.Table (Units.Last).Has_RACW := True;
1975 else
1976 Fatal_Error_Ignore;
1977 end if;
1979 Check_At_End_Of_Field;
1981 -- SE/SP/SU parameters
1983 elsif C = 'S' then
1984 C := Getc;
1986 if C = 'E' then
1987 Units.Table (Units.Last).Serious_Errors := True;
1988 elsif C = 'P' then
1989 Units.Table (Units.Last).Shared_Passive := True;
1990 elsif C = 'U' then
1991 Units.Table (Units.Last).Unit_Kind := 's';
1992 else
1993 Fatal_Error_Ignore;
1994 end if;
1996 Check_At_End_Of_Field;
1998 else
1999 C := Getc;
2000 Fatal_Error_Ignore;
2001 end if;
2002 end loop;
2004 Skip_Eol;
2006 C := Getc;
2008 -- Scan out With lines for this unit
2010 With_Loop : loop
2011 Check_Unknown_Line;
2012 exit With_Loop when C /= 'W' and then C /= 'Y' and then C /= 'Z';
2014 if Ignore ('W') then
2015 Skip_Line;
2017 else
2018 Checkc (' ');
2019 Skip_Space;
2020 Withs.Increment_Last;
2021 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
2022 Withs.Table (Withs.Last).Elaborate := False;
2023 Withs.Table (Withs.Last).Elaborate_All := False;
2024 Withs.Table (Withs.Last).Elab_Desirable := False;
2025 Withs.Table (Withs.Last).Elab_All_Desirable := False;
2026 Withs.Table (Withs.Last).SAL_Interface := False;
2027 Withs.Table (Withs.Last).Limited_With := (C = 'Y');
2028 Withs.Table (Withs.Last).Implicit_With_From_Instantiation
2029 := (C = 'Z');
2031 -- Generic case with no object file available
2033 if At_Eol then
2034 Withs.Table (Withs.Last).Sfile := No_File;
2035 Withs.Table (Withs.Last).Afile := No_File;
2037 -- Normal case
2039 else
2040 Withs.Table (Withs.Last).Sfile := Get_File_Name
2041 (Lower => True);
2042 Withs.Table (Withs.Last).Afile := Get_File_Name
2043 (Lower => True);
2045 -- Scan out possible E, EA, ED, and AD parameters
2047 while not At_Eol loop
2048 Skip_Space;
2050 if Nextc = 'A' then
2051 P := P + 1;
2052 Checkc ('D');
2053 Check_At_End_Of_Field;
2055 -- Store AD indication unless ignore required
2057 if not Ignore_ED then
2058 Withs.Table (Withs.Last).Elab_All_Desirable := True;
2059 end if;
2061 elsif Nextc = 'E' then
2062 P := P + 1;
2064 if At_End_Of_Field then
2065 Withs.Table (Withs.Last).Elaborate := True;
2067 elsif Nextc = 'A' then
2068 P := P + 1;
2069 Check_At_End_Of_Field;
2070 Withs.Table (Withs.Last).Elaborate_All := True;
2072 else
2073 Checkc ('D');
2074 Check_At_End_Of_Field;
2076 -- Store ED indication unless ignore required
2078 if not Ignore_ED then
2079 Withs.Table (Withs.Last).Elab_Desirable :=
2080 True;
2081 end if;
2082 end if;
2084 else
2085 Fatal_Error;
2086 end if;
2087 end loop;
2088 end if;
2090 Skip_Eol;
2091 end if;
2093 C := Getc;
2094 end loop With_Loop;
2096 Units.Table (Units.Last).Last_With := Withs.Last;
2097 Units.Table (Units.Last).Last_Arg := Args.Last;
2099 -- If there are linker options lines present, scan them
2101 Name_Len := 0;
2103 Linker_Options_Loop : loop
2104 Check_Unknown_Line;
2105 exit Linker_Options_Loop when C /= 'L';
2107 if Ignore ('L') then
2108 Skip_Line;
2110 else
2111 Checkc (' ');
2112 Skip_Space;
2113 Checkc ('"');
2115 loop
2116 C := Getc;
2118 if C < Character'Val (16#20#)
2119 or else C > Character'Val (16#7E#)
2120 then
2121 Fatal_Error_Ignore;
2123 elsif C = '{' then
2124 C := Character'Val (0);
2126 declare
2127 V : Natural;
2129 begin
2130 V := 0;
2131 for J in 1 .. 2 loop
2132 C := Getc;
2134 if C in '0' .. '9' then
2135 V := V * 16 +
2136 Character'Pos (C) -
2137 Character'Pos ('0');
2139 elsif C in 'A' .. 'F' then
2140 V := V * 16 +
2141 Character'Pos (C) -
2142 Character'Pos ('A') +
2145 else
2146 Fatal_Error_Ignore;
2147 end if;
2148 end loop;
2150 Checkc ('}');
2151 Add_Char_To_Name_Buffer (Character'Val (V));
2152 end;
2154 else
2155 if C = '"' then
2156 exit when Nextc /= '"';
2157 C := Getc;
2158 end if;
2160 Add_Char_To_Name_Buffer (C);
2161 end if;
2162 end loop;
2164 Add_Char_To_Name_Buffer (NUL);
2165 Skip_Eol;
2166 end if;
2168 C := Getc;
2169 end loop Linker_Options_Loop;
2171 -- Store the linker options entry if one was found
2173 if Name_Len /= 0 then
2174 Linker_Options.Increment_Last;
2176 Linker_Options.Table (Linker_Options.Last).Name :=
2177 Name_Enter;
2179 Linker_Options.Table (Linker_Options.Last).Unit :=
2180 Units.Last;
2182 Linker_Options.Table (Linker_Options.Last).Internal_File :=
2183 Is_Internal_File_Name (F);
2185 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
2186 Linker_Options.Last;
2187 end if;
2189 -- If there are notes present, scan them
2191 Notes_Loop : loop
2192 Check_Unknown_Line;
2193 exit Notes_Loop when C /= 'N';
2195 if Ignore ('N') then
2196 Skip_Line;
2198 else
2199 Checkc (' ');
2201 Notes.Increment_Last;
2202 Notes.Table (Notes.Last).Pragma_Type := Getc;
2203 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
2204 Checkc (':');
2205 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
2207 if not At_Eol and then Nextc = ':' then
2208 Checkc (':');
2209 Notes.Table (Notes.Last).Pragma_Source_File :=
2210 Get_File_Name (Lower => True);
2211 else
2212 Notes.Table (Notes.Last).Pragma_Source_File :=
2213 Units.Table (Units.Last).Sfile;
2214 end if;
2216 if At_Eol then
2217 Notes.Table (Notes.Last).Pragma_Args := No_Name;
2219 else
2220 -- Note: can't use Get_Name here as the remainder of the
2221 -- line is unstructured text whose syntax depends on the
2222 -- particular pragma used.
2224 Checkc (' ');
2226 Name_Len := 0;
2227 while not At_Eol loop
2228 Add_Char_To_Name_Buffer (Getc);
2229 end loop;
2230 end if;
2232 Skip_Eol;
2233 end if;
2235 C := Getc;
2236 end loop Notes_Loop;
2237 end loop U_Loop;
2239 -- End loop through units for one ALI file
2241 ALIs.Table (Id).Last_Unit := Units.Last;
2242 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
2244 -- Set types of the units (there can be at most 2 of them)
2246 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
2247 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
2248 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
2250 else
2251 -- Deal with body only and spec only cases, note that the reason we
2252 -- do our own checking of the name (rather than using Is_Body_Name)
2253 -- is that Uname drags in far too much compiler junk.
2255 Get_Name_String (Units.Table (Units.Last).Uname);
2257 if Name_Buffer (Name_Len) = 'b' then
2258 Units.Table (Units.Last).Utype := Is_Body_Only;
2259 else
2260 Units.Table (Units.Last).Utype := Is_Spec_Only;
2261 end if;
2262 end if;
2264 -- Scan out external version references and put in hash table
2266 E_Loop : loop
2267 Check_Unknown_Line;
2268 exit E_Loop when C /= 'E';
2270 if Ignore ('E') then
2271 Skip_Line;
2273 else
2274 Checkc (' ');
2275 Skip_Space;
2277 Name_Len := 0;
2278 Name_Len := 0;
2279 loop
2280 C := Getc;
2282 if C < ' ' then
2283 Fatal_Error;
2284 end if;
2286 exit when At_End_Of_Field;
2287 Add_Char_To_Name_Buffer (C);
2288 end loop;
2290 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
2291 Skip_Eol;
2292 end if;
2294 C := Getc;
2295 end loop E_Loop;
2297 -- Scan out source dependency lines for this ALI file
2299 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
2301 D_Loop : loop
2302 Check_Unknown_Line;
2303 exit D_Loop when C /= 'D';
2305 if Ignore ('D') then
2306 Skip_Line;
2308 else
2309 Checkc (' ');
2310 Skip_Space;
2311 Sdep.Increment_Last;
2313 -- In the following call, Lower is not set to True, this is either
2314 -- a bug, or it deserves a special comment as to why this is so???
2316 -- The file/path name may be quoted
2318 Sdep.Table (Sdep.Last).Sfile :=
2319 Get_File_Name (May_Be_Quoted => True);
2321 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2322 Sdep.Table (Sdep.Last).Dummy_Entry :=
2323 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2325 -- Acquire checksum value
2327 Skip_Space;
2329 declare
2330 Ctr : Natural;
2331 Chk : Word;
2333 begin
2334 Ctr := 0;
2335 Chk := 0;
2337 loop
2338 exit when At_Eol or else Ctr = 8;
2340 if Nextc in '0' .. '9' then
2341 Chk := Chk * 16 +
2342 Character'Pos (Nextc) - Character'Pos ('0');
2344 elsif Nextc in 'a' .. 'f' then
2345 Chk := Chk * 16 +
2346 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2348 else
2349 exit;
2350 end if;
2352 Ctr := Ctr + 1;
2353 P := P + 1;
2354 end loop;
2356 if Ctr = 8 and then At_End_Of_Field then
2357 Sdep.Table (Sdep.Last).Checksum := Chk;
2358 else
2359 Fatal_Error;
2360 end if;
2361 end;
2363 -- Acquire (sub)unit and reference file name entries
2365 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2366 Sdep.Table (Sdep.Last).Unit_Name := No_Name;
2367 Sdep.Table (Sdep.Last).Rfile :=
2368 Sdep.Table (Sdep.Last).Sfile;
2369 Sdep.Table (Sdep.Last).Start_Line := 1;
2371 if not At_Eol then
2372 Skip_Space;
2374 -- Here for (sub)unit name
2376 if Nextc not in '0' .. '9' then
2377 Name_Len := 0;
2378 while not At_End_Of_Field loop
2379 Add_Char_To_Name_Buffer (Getc);
2380 end loop;
2382 -- Set the (sub)unit name. Note that we use Name_Find rather
2383 -- than Name_Enter here as the subunit name may already
2384 -- have been put in the name table by the Project Manager.
2386 if Name_Len <= 2
2387 or else Name_Buffer (Name_Len - 1) /= '%'
2388 then
2389 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2390 else
2391 Name_Len := Name_Len - 2;
2392 Sdep.Table (Sdep.Last).Unit_Name := Name_Find;
2393 end if;
2395 Skip_Space;
2396 end if;
2398 -- Here for reference file name entry
2400 if Nextc in '0' .. '9' then
2401 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2402 Checkc (':');
2404 Name_Len := 0;
2406 while not At_End_Of_Field loop
2407 Add_Char_To_Name_Buffer (Getc);
2408 end loop;
2410 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2411 end if;
2412 end if;
2414 Skip_Eol;
2415 end if;
2417 C := Getc;
2418 end loop D_Loop;
2420 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2422 -- We must at this stage be at an Xref line or the end of file
2424 if C = EOF then
2425 return Id;
2426 end if;
2428 Check_Unknown_Line;
2430 if C /= 'X' then
2431 Fatal_Error;
2432 end if;
2434 -- If we are ignoring Xref sections we are done (we ignore all
2435 -- remaining lines since only xref related lines follow X).
2437 if Ignore ('X') and then not Debug_Flag_X then
2438 return Id;
2439 end if;
2441 -- Loop through Xref sections
2443 X_Loop : loop
2444 Check_Unknown_Line;
2445 exit X_Loop when C /= 'X';
2447 -- Make new entry in section table
2449 Xref_Section.Increment_Last;
2451 Read_Refs_For_One_File : declare
2452 XS : Xref_Section_Record renames
2453 Xref_Section.Table (Xref_Section.Last);
2455 Current_File_Num : Sdep_Id;
2456 -- Keeps track of the current file number (changed by nn|)
2458 begin
2459 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2460 XS.File_Name := Get_File_Name;
2461 XS.First_Entity := Xref_Entity.Last + 1;
2463 Current_File_Num := XS.File_Num;
2465 Skip_Space;
2467 Skip_Eol;
2468 C := Nextc;
2470 -- Loop through Xref entities
2472 while C /= 'X' and then C /= EOF loop
2473 Xref_Entity.Increment_Last;
2475 Read_Refs_For_One_Entity : declare
2476 XE : Xref_Entity_Record renames
2477 Xref_Entity.Table (Xref_Entity.Last);
2478 N : Nat;
2480 procedure Read_Instantiation_Reference;
2481 -- Acquire instantiation reference. Caller has checked
2482 -- that current character is '[' and on return the cursor
2483 -- is skipped past the corresponding closing ']'.
2485 ----------------------------------
2486 -- Read_Instantiation_Reference --
2487 ----------------------------------
2489 procedure Read_Instantiation_Reference is
2490 Local_File_Num : Sdep_Id := Current_File_Num;
2492 begin
2493 Xref.Increment_Last;
2495 declare
2496 XR : Xref_Record renames Xref.Table (Xref.Last);
2498 begin
2499 P := P + 1; -- skip [
2500 N := Get_Nat;
2502 if Nextc = '|' then
2503 XR.File_Num :=
2504 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2505 Local_File_Num := XR.File_Num;
2506 P := P + 1;
2507 N := Get_Nat;
2509 else
2510 XR.File_Num := Local_File_Num;
2511 end if;
2513 XR.Line := N;
2514 XR.Rtype := ' ';
2515 XR.Col := 0;
2517 -- Recursive call for next reference
2519 if Nextc = '[' then
2520 pragma Warnings (Off); -- kill recursion warning
2521 Read_Instantiation_Reference;
2522 pragma Warnings (On);
2523 end if;
2525 -- Skip closing bracket after recursive call
2527 P := P + 1;
2528 end;
2529 end Read_Instantiation_Reference;
2531 -- Start of processing for Read_Refs_For_One_Entity
2533 begin
2534 XE.Line := Get_Nat;
2535 XE.Etype := Getc;
2536 XE.Col := Get_Nat;
2538 case Getc is
2539 when '*' =>
2540 XE.Visibility := Global;
2541 when '+' =>
2542 XE.Visibility := Static;
2543 when others =>
2544 XE.Visibility := Other;
2545 end case;
2547 XE.Entity := Get_Name;
2549 -- Handle the information about generic instantiations
2551 if Nextc = '[' then
2552 Skipc; -- Opening '['
2553 N := Get_Nat;
2555 if Nextc /= '|' then
2556 XE.Iref_File_Num := Current_File_Num;
2557 XE.Iref_Line := N;
2558 else
2559 XE.Iref_File_Num :=
2560 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2561 Skipc;
2562 XE.Iref_Line := Get_Nat;
2563 end if;
2565 if Getc /= ']' then
2566 Fatal_Error;
2567 end if;
2569 else
2570 XE.Iref_File_Num := No_Sdep_Id;
2571 XE.Iref_Line := 0;
2572 end if;
2574 Current_File_Num := XS.File_Num;
2576 -- Renaming reference is present
2578 if Nextc = '=' then
2579 P := P + 1;
2580 XE.Rref_Line := Get_Nat;
2582 if Getc /= ':' then
2583 Fatal_Error;
2584 end if;
2586 XE.Rref_Col := Get_Nat;
2588 -- No renaming reference present
2590 else
2591 XE.Rref_Line := 0;
2592 XE.Rref_Col := 0;
2593 end if;
2595 Skip_Space;
2597 XE.Oref_File_Num := No_Sdep_Id;
2598 XE.Tref_File_Num := No_Sdep_Id;
2599 XE.Tref := Tref_None;
2600 XE.First_Xref := Xref.Last + 1;
2602 -- Loop to check for additional info present
2604 loop
2605 declare
2606 Ref : Tref_Kind;
2607 File : Sdep_Id;
2608 Line : Nat;
2609 Typ : Character;
2610 Col : Nat;
2611 Std : Name_Id;
2613 begin
2614 Get_Typeref
2615 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2616 exit when Ref = Tref_None;
2618 -- Do we have an overriding procedure?
2620 if Ref = Tref_Derived and then Typ = 'p' then
2621 XE.Oref_File_Num := File;
2622 XE.Oref_Line := Line;
2623 XE.Oref_Col := Col;
2625 -- Arrays never override anything, and <> points to
2626 -- the index types instead
2628 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2630 -- Index types are stored in the list of references
2632 Xref.Increment_Last;
2634 declare
2635 XR : Xref_Record renames Xref.Table (Xref.Last);
2636 begin
2637 XR.File_Num := File;
2638 XR.Line := Line;
2639 XR.Rtype := Array_Index_Reference;
2640 XR.Col := Col;
2641 XR.Name := Std;
2642 end;
2644 -- Interfaces are stored in the list of references,
2645 -- although the parent type itself is stored in XE.
2646 -- The first interface (when there are only
2647 -- interfaces) is stored in XE.Tref*)
2649 elsif Ref = Tref_Derived
2650 and then Typ = 'R'
2651 and then XE.Tref_File_Num /= No_Sdep_Id
2652 then
2653 Xref.Increment_Last;
2655 declare
2656 XR : Xref_Record renames Xref.Table (Xref.Last);
2657 begin
2658 XR.File_Num := File;
2659 XR.Line := Line;
2660 XR.Rtype := Interface_Reference;
2661 XR.Col := Col;
2662 XR.Name := Std;
2663 end;
2665 else
2666 XE.Tref := Ref;
2667 XE.Tref_File_Num := File;
2668 XE.Tref_Line := Line;
2669 XE.Tref_Type := Typ;
2670 XE.Tref_Col := Col;
2671 XE.Tref_Standard_Entity := Std;
2672 end if;
2673 end;
2674 end loop;
2676 -- Loop through cross-references for this entity
2678 loop
2679 Skip_Space;
2681 if At_Eol then
2682 Skip_Eol;
2683 exit when Nextc /= '.';
2684 P := P + 1;
2685 end if;
2687 Xref.Increment_Last;
2689 declare
2690 XR : Xref_Record renames Xref.Table (Xref.Last);
2692 begin
2693 N := Get_Nat;
2695 if Nextc = '|' then
2696 XR.File_Num :=
2697 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2698 Current_File_Num := XR.File_Num;
2699 P := P + 1;
2700 N := Get_Nat;
2701 else
2702 XR.File_Num := Current_File_Num;
2703 end if;
2705 XR.Line := N;
2706 XR.Rtype := Getc;
2708 -- Imported entities reference as in:
2709 -- 494b<c,__gnat_copy_attribs>25
2711 if Nextc = '<' then
2712 Skipc;
2713 XR.Imported_Lang := Get_Name;
2715 pragma Assert (Nextc = ',');
2716 Skipc;
2718 XR.Imported_Name := Get_Name;
2720 pragma Assert (Nextc = '>');
2721 Skipc;
2723 else
2724 XR.Imported_Lang := No_Name;
2725 XR.Imported_Name := No_Name;
2726 end if;
2728 XR.Col := Get_Nat;
2730 if Nextc = '[' then
2731 Read_Instantiation_Reference;
2732 end if;
2733 end;
2734 end loop;
2736 -- Record last cross-reference
2738 XE.Last_Xref := Xref.Last;
2739 C := Nextc;
2741 exception
2742 when Bad_ALI_Format =>
2744 -- If ignoring errors, then we skip a line with an
2745 -- unexpected error, and try to continue subsequent
2746 -- xref lines.
2748 if Ignore_Errors then
2749 Xref_Entity.Decrement_Last;
2750 Skip_Line;
2751 C := Nextc;
2753 -- Otherwise, we reraise the fatal exception
2755 else
2756 raise;
2757 end if;
2758 end Read_Refs_For_One_Entity;
2759 end loop;
2761 -- Record last entity
2763 XS.Last_Entity := Xref_Entity.Last;
2765 end Read_Refs_For_One_File;
2767 C := Getc;
2768 end loop X_Loop;
2770 -- Here after dealing with xref sections
2772 -- Ignore remaining lines, which belong to an additional section of the
2773 -- ALI file not considered here (like SCO or SPARK information).
2775 Check_Unknown_Line;
2777 return Id;
2779 exception
2780 when Bad_ALI_Format =>
2781 return No_ALI_Id;
2782 end Scan_ALI;
2784 ---------
2785 -- SEq --
2786 ---------
2788 function SEq (F1, F2 : String_Ptr) return Boolean is
2789 begin
2790 return F1.all = F2.all;
2791 end SEq;
2793 -----------
2794 -- SHash --
2795 -----------
2797 function SHash (S : String_Ptr) return Vindex is
2798 H : Word;
2800 begin
2801 H := 0;
2802 for J in S.all'Range loop
2803 H := H * 2 + Character'Pos (S (J));
2804 end loop;
2806 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));
2807 end SHash;
2809 end ALI;