Fix typos in riscv register save/restore.
[official-gcc.git] / gcc / ada / ali.adb
blob959b30587280b809442c1acf3f8502c34293d90a
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 'T' => True, -- task stack information
62 others => False);
64 --------------------
65 -- Initialize_ALI --
66 --------------------
68 procedure Initialize_ALI is
69 begin
70 -- When (re)initializing ALI data structures the ALI user expects to
71 -- get a fresh set of data structures. Thus we first need to erase the
72 -- marks put in the name table by the previous set of ALI routine calls.
73 -- These two loops are empty and harmless the first time in.
75 for J in ALIs.First .. ALIs.Last loop
76 Set_Name_Table_Int (ALIs.Table (J).Afile, 0);
77 end loop;
79 for J in Units.First .. Units.Last loop
80 Set_Name_Table_Int (Units.Table (J).Uname, 0);
81 end loop;
83 -- Free argument table strings
85 for J in Args.First .. Args.Last loop
86 Free (Args.Table (J));
87 end loop;
89 -- Initialize all tables
91 ALIs.Init;
92 No_Deps.Init;
93 Units.Init;
94 Withs.Init;
95 Sdep.Init;
96 Linker_Options.Init;
97 Notes.Init;
98 Xref_Section.Init;
99 Xref_Entity.Init;
100 Xref.Init;
101 Version_Ref.Reset;
103 -- Add dummy zero'th item in Linker_Options and Notes for sort calls
105 Linker_Options.Increment_Last;
106 Notes.Increment_Last;
108 -- Initialize global variables recording cumulative options in all
109 -- ALI files that are read for a given processing run in gnatbind.
111 Dynamic_Elaboration_Checks_Specified := False;
112 Locking_Policy_Specified := ' ';
113 No_Normalize_Scalars_Specified := False;
114 No_Object_Specified := False;
115 No_Component_Reordering_Specified := False;
116 GNATprove_Mode_Specified := False;
117 Normalize_Scalars_Specified := False;
118 Partition_Elaboration_Policy_Specified := ' ';
119 Queuing_Policy_Specified := ' ';
120 SSO_Default_Specified := False;
121 Task_Dispatching_Policy_Specified := ' ';
122 Unreserve_All_Interrupts_Specified := False;
123 Frontend_Exceptions_Specified := False;
124 Zero_Cost_Exceptions_Specified := False;
125 end Initialize_ALI;
127 --------------
128 -- Scan_ALI --
129 --------------
131 function Scan_ALI
132 (F : File_Name_Type;
133 T : Text_Buffer_Ptr;
134 Ignore_ED : Boolean;
135 Err : Boolean;
136 Read_Xref : Boolean := False;
137 Read_Lines : String := "";
138 Ignore_Lines : String := "X";
139 Ignore_Errors : Boolean := False;
140 Directly_Scanned : Boolean := False) return ALI_Id
142 P : Text_Ptr := T'First;
143 Line : Logical_Line_Number := 1;
144 Id : ALI_Id;
145 C : Character;
146 NS_Found : Boolean;
147 First_Arg : Arg_Id;
149 Ignore : array (Character range 'A' .. 'Z') of Boolean;
150 -- Ignore (X) is set to True if lines starting with X are to
151 -- be ignored by Scan_ALI and skipped, and False if the lines
152 -- are to be read and processed.
154 Bad_ALI_Format : exception;
155 -- Exception raised by Fatal_Error if Err is True
157 function At_Eol return Boolean;
158 -- Test if at end of line
160 function At_End_Of_Field return Boolean;
161 -- Test if at end of line, or if at blank or horizontal tab
163 procedure Check_At_End_Of_Field;
164 -- Check if we are at end of field, fatal error if not
166 procedure Checkc (C : Character);
167 -- Check next character is C. If so bump past it, if not fatal error
169 procedure Check_Unknown_Line;
170 -- If Ignore_Errors mode, then checks C to make sure that it is not
171 -- an unknown ALI line type characters, and if so, skips lines
172 -- until the first character of the line is one of these characters,
173 -- at which point it does a Getc to put that character in C. The
174 -- call has no effect if C is already an appropriate character.
175 -- If not in Ignore_Errors mode, a fatal error is signalled if the
176 -- line is unknown. Note that if C is an EOL on entry, the line is
177 -- skipped (it is assumed that blank lines are never significant).
178 -- If C is EOF on entry, the call has no effect (it is assumed that
179 -- the caller will properly handle this case).
181 procedure Fatal_Error;
182 -- Generate fatal error message for badly formatted ALI file if
183 -- Err is false, or raise Bad_ALI_Format if Err is True.
185 procedure Fatal_Error_Ignore;
186 pragma Inline (Fatal_Error_Ignore);
187 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
189 function Getc return Character;
190 -- Get next character, bumping P past the character obtained
192 function Get_File_Name
193 (Lower : Boolean := False;
194 May_Be_Quoted : Boolean := False) return File_Name_Type;
195 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
196 -- with length in Name_Len, as well as returning a File_Name_Type value.
197 -- If May_Be_Quoted is True and the first non blank character is '"',
198 -- then remove starting and ending quotes and undoubled internal quotes.
199 -- If lower is false, the case is unchanged, if Lower is True then the
200 -- result is forced to all lower case for systems where file names are
201 -- not case sensitive. This ensures that gnatbind works correctly
202 -- regardless of the case of the file name on all systems. The scan
203 -- is terminated by a end of line, space or horizontal tab. Any other
204 -- special characters are included in the returned name.
206 function Get_Name
207 (Ignore_Spaces : Boolean := False;
208 Ignore_Special : Boolean := False;
209 May_Be_Quoted : Boolean := False) return Name_Id;
210 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
211 -- length in Name_Len, as well as being returned in Name_Id form).
212 -- If Lower is set to True then the Name_Buffer will be converted to
213 -- all lower case, for systems where file names are not case sensitive.
214 -- This ensures that gnatbind works correctly regardless of the case
215 -- of the file name on all systems. The termination condition depends
216 -- on the settings of Ignore_Spaces and Ignore_Special:
218 -- If Ignore_Spaces is False (normal case), then scan is terminated
219 -- by the normal end of field condition (EOL, space, horizontal tab)
221 -- If Ignore_Special is False (normal case), the scan is terminated by
222 -- a typeref bracket or an equal sign except for the special case of
223 -- an operator name starting with a double quote which is terminated
224 -- by another double quote.
226 -- If May_Be_Quoted is True and the first non blank character is '"'
227 -- the name is 'unquoted'. In this case Ignore_Special is ignored and
228 -- assumed to be True.
230 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
231 -- This function handles wide characters properly.
233 function Get_Nat return Nat;
234 -- Skip blanks, then scan out an unsigned integer value in Nat range
235 -- raises ALI_Reading_Error if the encoutered type is not natural.
237 function Get_Stamp return Time_Stamp_Type;
238 -- Skip blanks, then scan out a time stamp
240 function Get_Unit_Name return Unit_Name_Type;
241 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
242 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
243 -- The case is unchanged and terminated by a normal end of field.
245 function Nextc return Character;
246 -- Return current character without modifying pointer P
248 procedure Get_Typeref
249 (Current_File_Num : Sdep_Id;
250 Ref : out Tref_Kind;
251 File_Num : out Sdep_Id;
252 Line : out Nat;
253 Ref_Type : out Character;
254 Col : out Nat;
255 Standard_Entity : out Name_Id);
256 -- Parse the definition of a typeref (<...>, {...} or (...))
258 procedure Skip_Eol;
259 -- Skip past spaces, then skip past end of line (fatal error if not
260 -- at end of line). Also skips past any following blank lines.
262 procedure Skip_Line;
263 -- Skip rest of current line and any following blank lines
265 procedure Skip_Space;
266 -- Skip past white space (blanks or horizontal tab)
268 procedure Skipc;
269 -- Skip past next character, does not affect value in C. This call
270 -- is like calling Getc and ignoring the returned result.
272 ---------------------
273 -- At_End_Of_Field --
274 ---------------------
276 function At_End_Of_Field return Boolean is
277 begin
278 return Nextc <= ' ';
279 end At_End_Of_Field;
281 ------------
282 -- At_Eol --
283 ------------
285 function At_Eol return Boolean is
286 begin
287 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
288 end At_Eol;
290 ---------------------------
291 -- Check_At_End_Of_Field --
292 ---------------------------
294 procedure Check_At_End_Of_Field is
295 begin
296 if not At_End_Of_Field then
297 if Ignore_Errors then
298 while Nextc > ' ' loop
299 P := P + 1;
300 end loop;
301 else
302 Fatal_Error;
303 end if;
304 end if;
305 end Check_At_End_Of_Field;
307 ------------------------
308 -- Check_Unknown_Line --
309 ------------------------
311 procedure Check_Unknown_Line is
312 begin
313 while C not in 'A' .. 'Z'
314 or else not Known_ALI_Lines (C)
315 loop
316 if C = CR or else C = LF then
317 Skip_Line;
318 C := Nextc;
320 elsif C = EOF then
321 return;
323 elsif Ignore_Errors then
324 Skip_Line;
325 C := Getc;
327 else
328 Fatal_Error;
329 end if;
330 end loop;
331 end Check_Unknown_Line;
333 ------------
334 -- Checkc --
335 ------------
337 procedure Checkc (C : Character) is
338 begin
339 if Nextc = C then
340 P := P + 1;
341 elsif Ignore_Errors then
342 P := P + 1;
343 else
344 Fatal_Error;
345 end if;
346 end Checkc;
348 -----------------
349 -- Fatal_Error --
350 -----------------
352 procedure Fatal_Error is
353 Ptr1 : Text_Ptr;
354 Ptr2 : Text_Ptr;
355 Col : Int;
357 procedure Wchar (C : Character);
358 -- Write a single character, replacing horizontal tab by spaces
360 procedure Wchar (C : Character) is
361 begin
362 if C = HT then
363 loop
364 Wchar (' ');
365 exit when Col mod 8 = 0;
366 end loop;
368 else
369 Write_Char (C);
370 Col := Col + 1;
371 end if;
372 end Wchar;
374 -- Start of processing for Fatal_Error
376 begin
377 if Err then
378 raise Bad_ALI_Format;
379 end if;
381 Set_Standard_Error;
382 Write_Str ("fatal error: file ");
383 Write_Name (F);
384 Write_Str (" is incorrectly formatted");
385 Write_Eol;
387 Write_Str ("make sure you are using consistent versions " &
389 -- Split the following line so that it can easily be transformed for
390 -- other back-ends where the compiler might have a different name.
392 "of gcc/gnatbind");
394 Write_Eol;
396 -- Find start of line
398 Ptr1 := P;
399 while Ptr1 > T'First
400 and then T (Ptr1 - 1) /= CR
401 and then T (Ptr1 - 1) /= LF
402 loop
403 Ptr1 := Ptr1 - 1;
404 end loop;
406 Write_Int (Int (Line));
407 Write_Str (". ");
409 if Line < 100 then
410 Write_Char (' ');
411 end if;
413 if Line < 10 then
414 Write_Char (' ');
415 end if;
417 Col := 0;
418 Ptr2 := Ptr1;
420 while Ptr2 < T'Last
421 and then T (Ptr2) /= CR
422 and then T (Ptr2) /= LF
423 loop
424 Wchar (T (Ptr2));
425 Ptr2 := Ptr2 + 1;
426 end loop;
428 Write_Eol;
430 Write_Str (" ");
431 Col := 0;
433 while Ptr1 < P loop
434 if T (Ptr1) = HT then
435 Wchar (HT);
436 else
437 Wchar (' ');
438 end if;
440 Ptr1 := Ptr1 + 1;
441 end loop;
443 Wchar ('|');
444 Write_Eol;
446 Exit_Program (E_Fatal);
447 end Fatal_Error;
449 ------------------------
450 -- Fatal_Error_Ignore --
451 ------------------------
453 procedure Fatal_Error_Ignore is
454 begin
455 if not Ignore_Errors then
456 Fatal_Error;
457 end if;
458 end Fatal_Error_Ignore;
460 -------------------
461 -- Get_File_Name --
462 -------------------
464 function Get_File_Name
465 (Lower : Boolean := False;
466 May_Be_Quoted : Boolean := False) return File_Name_Type
468 F : Name_Id;
470 begin
471 F := Get_Name (Ignore_Special => True,
472 May_Be_Quoted => May_Be_Quoted);
474 -- Convert file name to all lower case if file names are not case
475 -- sensitive. This ensures that we handle names in the canonical
476 -- lower case format, regardless of the actual case.
478 if Lower and not File_Names_Case_Sensitive then
479 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
480 return Name_Find;
481 else
482 return File_Name_Type (F);
483 end if;
484 end Get_File_Name;
486 --------------
487 -- Get_Name --
488 --------------
490 function Get_Name
491 (Ignore_Spaces : Boolean := False;
492 Ignore_Special : Boolean := False;
493 May_Be_Quoted : Boolean := False) return Name_Id
495 Char : Character;
497 begin
498 Name_Len := 0;
499 Skip_Space;
501 if At_Eol then
502 if Ignore_Errors then
503 return Error_Name;
504 else
505 Fatal_Error;
506 end if;
507 end if;
509 Char := Getc;
511 -- Deal with quoted characters
513 if May_Be_Quoted and then Char = '"' then
514 loop
515 if At_Eol then
516 if Ignore_Errors then
517 return Error_Name;
518 else
519 Fatal_Error;
520 end if;
521 end if;
523 Char := Getc;
525 if Char = '"' then
526 if At_Eol then
527 exit;
529 else
530 Char := Getc;
532 if Char /= '"' then
533 P := P - 1;
534 exit;
535 end if;
536 end if;
537 end if;
539 Add_Char_To_Name_Buffer (Char);
540 end loop;
542 -- Other than case of quoted character
544 else
545 P := P - 1;
546 loop
547 Add_Char_To_Name_Buffer (Getc);
549 exit when At_End_Of_Field and then not Ignore_Spaces;
551 if not Ignore_Special then
552 if Name_Buffer (1) = '"' then
553 exit when Name_Len > 1
554 and then Name_Buffer (Name_Len) = '"';
556 else
557 -- Terminate on parens or angle brackets or equal sign
559 exit when Nextc = '(' or else Nextc = ')'
560 or else Nextc = '{' or else Nextc = '}'
561 or else Nextc = '<' or else Nextc = '>'
562 or else Nextc = '=';
564 -- Terminate on comma
566 exit when Nextc = ',';
568 -- Terminate if left bracket not part of wide char
569 -- sequence Note that we only recognize brackets
570 -- notation so far ???
572 exit when Nextc = '[' and then T (P + 1) /= '"';
574 -- Terminate if right bracket not part of wide char
575 -- sequence.
577 exit when Nextc = ']' and then T (P - 1) /= '"';
578 end if;
579 end if;
580 end loop;
581 end if;
583 return Name_Find;
584 end Get_Name;
586 -------------------
587 -- Get_Unit_Name --
588 -------------------
590 function Get_Unit_Name return Unit_Name_Type is
591 begin
592 return Unit_Name_Type (Get_Name);
593 end Get_Unit_Name;
595 -------------
596 -- Get_Nat --
597 -------------
599 function Get_Nat return Nat is
600 V : Nat;
602 begin
603 Skip_Space;
605 -- Check if we are on a number. In the case of bad ALI files, this
606 -- may not be true.
608 if not (Nextc in '0' .. '9') then
609 Fatal_Error;
610 end if;
612 V := 0;
613 loop
614 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
616 exit when At_End_Of_Field;
617 exit when Nextc < '0' or else Nextc > '9';
618 end loop;
620 return V;
621 end Get_Nat;
623 ---------------
624 -- Get_Stamp --
625 ---------------
627 function Get_Stamp return Time_Stamp_Type is
628 T : Time_Stamp_Type;
629 Start : Integer;
631 begin
632 Skip_Space;
634 if At_Eol then
635 if Ignore_Errors then
636 return Dummy_Time_Stamp;
637 else
638 Fatal_Error;
639 end if;
640 end if;
642 -- Following reads old style time stamp missing first two digits
644 if Nextc in '7' .. '9' then
645 T (1) := '1';
646 T (2) := '9';
647 Start := 3;
649 -- Normal case of full year in time stamp
651 else
652 Start := 1;
653 end if;
655 for J in Start .. T'Last loop
656 T (J) := Getc;
657 end loop;
659 return T;
660 end Get_Stamp;
662 -----------------
663 -- Get_Typeref --
664 -----------------
666 procedure Get_Typeref
667 (Current_File_Num : Sdep_Id;
668 Ref : out Tref_Kind;
669 File_Num : out Sdep_Id;
670 Line : out Nat;
671 Ref_Type : out Character;
672 Col : out Nat;
673 Standard_Entity : out Name_Id)
675 N : Nat;
676 begin
677 case Nextc is
678 when '<' => Ref := Tref_Derived;
679 when '(' => Ref := Tref_Access;
680 when '{' => Ref := Tref_Type;
681 when others => Ref := Tref_None;
682 end case;
684 -- Case of typeref field present
686 if Ref /= Tref_None then
687 P := P + 1; -- skip opening bracket
689 if Nextc in 'a' .. 'z' then
690 File_Num := No_Sdep_Id;
691 Line := 0;
692 Ref_Type := ' ';
693 Col := 0;
694 Standard_Entity := Get_Name (Ignore_Spaces => True);
695 else
696 N := Get_Nat;
698 if Nextc = '|' then
699 File_Num := Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
700 P := P + 1;
701 N := Get_Nat;
702 else
703 File_Num := Current_File_Num;
704 end if;
706 Line := N;
707 Ref_Type := Getc;
708 Col := Get_Nat;
709 Standard_Entity := No_Name;
710 end if;
712 -- ??? Temporary workaround for nested generics case:
713 -- 4i4 Directories{1|4I9[4|6[3|3]]}
714 -- See C918-002
716 declare
717 Nested_Brackets : Natural := 0;
719 begin
720 loop
721 case Nextc is
722 when '[' =>
723 Nested_Brackets := Nested_Brackets + 1;
724 when ']' =>
725 Nested_Brackets := Nested_Brackets - 1;
726 when others =>
727 if Nested_Brackets = 0 then
728 exit;
729 end if;
730 end case;
732 Skipc;
733 end loop;
734 end;
736 P := P + 1; -- skip closing bracket
737 Skip_Space;
739 -- No typeref entry present
741 else
742 File_Num := No_Sdep_Id;
743 Line := 0;
744 Ref_Type := ' ';
745 Col := 0;
746 Standard_Entity := No_Name;
747 end if;
748 end Get_Typeref;
750 ----------
751 -- Getc --
752 ----------
754 function Getc return Character is
755 begin
756 if P = T'Last then
757 return EOF;
758 else
759 P := P + 1;
760 return T (P - 1);
761 end if;
762 end Getc;
764 -----------
765 -- Nextc --
766 -----------
768 function Nextc return Character is
769 begin
770 return T (P);
771 end Nextc;
773 --------------
774 -- Skip_Eol --
775 --------------
777 procedure Skip_Eol is
778 begin
779 Skip_Space;
781 if not At_Eol then
782 if Ignore_Errors then
783 while not At_Eol loop
784 P := P + 1;
785 end loop;
786 else
787 Fatal_Error;
788 end if;
789 end if;
791 -- Loop to skip past blank lines (first time through skips this EOL)
793 while Nextc < ' ' and then Nextc /= EOF loop
794 if Nextc = LF then
795 Line := Line + 1;
796 end if;
798 P := P + 1;
799 end loop;
800 end Skip_Eol;
802 ---------------
803 -- Skip_Line --
804 ---------------
806 procedure Skip_Line is
807 begin
808 while not At_Eol loop
809 P := P + 1;
810 end loop;
812 Skip_Eol;
813 end Skip_Line;
815 ----------------
816 -- Skip_Space --
817 ----------------
819 procedure Skip_Space is
820 begin
821 while Nextc = ' ' or else Nextc = HT loop
822 P := P + 1;
823 end loop;
824 end Skip_Space;
826 -----------
827 -- Skipc --
828 -----------
830 procedure Skipc is
831 begin
832 if P /= T'Last then
833 P := P + 1;
834 end if;
835 end Skipc;
837 -- Start of processing for Scan_ALI
839 begin
840 First_Sdep_Entry := Sdep.Last + 1;
842 -- Acquire lines to be ignored
844 if Read_Xref then
845 Ignore :=
846 ('T' | 'U' | 'W' | 'Y' | 'Z' | 'D' | 'X' => False, others => True);
848 -- Read_Lines parameter given
850 elsif Read_Lines /= "" then
851 Ignore := ('U' => False, others => True);
853 for J in Read_Lines'Range loop
854 Ignore (Read_Lines (J)) := False;
855 end loop;
857 -- Process Ignore_Lines parameter
859 else
860 Ignore := (others => False);
862 for J in Ignore_Lines'Range loop
863 pragma Assert (Ignore_Lines (J) /= 'U');
864 Ignore (Ignore_Lines (J)) := True;
865 end loop;
866 end if;
868 -- Setup ALI Table entry with appropriate defaults
870 ALIs.Increment_Last;
871 Id := ALIs.Last;
872 Set_Name_Table_Int (F, Int (Id));
874 ALIs.Table (Id) := (
875 Afile => F,
876 Compile_Errors => False,
877 First_Interrupt_State => Interrupt_States.Last + 1,
878 First_Sdep => No_Sdep_Id,
879 First_Specific_Dispatching => Specific_Dispatching.Last + 1,
880 First_Unit => No_Unit_Id,
881 GNATprove_Mode => False,
882 Last_Interrupt_State => Interrupt_States.Last,
883 Last_Sdep => No_Sdep_Id,
884 Last_Specific_Dispatching => Specific_Dispatching.Last,
885 Last_Unit => No_Unit_Id,
886 Locking_Policy => ' ',
887 Main_Priority => -1,
888 Main_CPU => -1,
889 Main_Program => None,
890 No_Component_Reordering => False,
891 No_Object => False,
892 Normalize_Scalars => False,
893 Ofile_Full_Name => Full_Object_File_Name,
894 Partition_Elaboration_Policy => ' ',
895 Queuing_Policy => ' ',
896 Restrictions => No_Restrictions,
897 SAL_Interface => False,
898 Sfile => No_File,
899 SSO_Default => ' ',
900 Task_Dispatching_Policy => ' ',
901 Time_Slice_Value => -1,
902 WC_Encoding => 'b',
903 Unit_Exception_Table => False,
904 Ver => (others => ' '),
905 Ver_Len => 0,
906 Frontend_Exceptions => False,
907 Zero_Cost_Exceptions => False);
909 -- Now we acquire the input lines from the ALI file. Note that the
910 -- convention in the following code is that as we enter each section,
911 -- C is set to contain the first character of the following line.
913 C := Getc;
914 Check_Unknown_Line;
916 -- Acquire library version
918 if C /= 'V' then
920 -- The V line missing really indicates trouble, most likely it
921 -- means we don't have an ALI file at all, so here we give a
922 -- fatal error even if we are in Ignore_Errors mode.
924 Fatal_Error;
926 elsif Ignore ('V') then
927 Skip_Line;
929 else
930 Checkc (' ');
931 Skip_Space;
932 Checkc ('"');
934 for J in 1 .. Ver_Len_Max loop
935 C := Getc;
936 exit when C = '"';
937 ALIs.Table (Id).Ver (J) := C;
938 ALIs.Table (Id).Ver_Len := J;
939 end loop;
941 Skip_Eol;
942 end if;
944 C := Getc;
945 Check_Unknown_Line;
947 -- Acquire main program line if present
949 if C = 'M' then
950 if Ignore ('M') then
951 Skip_Line;
953 else
954 Checkc (' ');
955 Skip_Space;
957 C := Getc;
959 if C = 'F' then
960 ALIs.Table (Id).Main_Program := Func;
961 elsif C = 'P' then
962 ALIs.Table (Id).Main_Program := Proc;
963 else
964 P := P - 1;
965 Fatal_Error;
966 end if;
968 Skip_Space;
970 if not At_Eol then
971 if Nextc < 'A' then
972 ALIs.Table (Id).Main_Priority := Get_Nat;
973 end if;
975 Skip_Space;
977 if Nextc = 'T' then
978 P := P + 1;
979 Checkc ('=');
980 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
981 end if;
983 Skip_Space;
985 if Nextc = 'C' then
986 P := P + 1;
987 Checkc ('=');
988 ALIs.Table (Id).Main_CPU := Get_Nat;
989 end if;
991 Skip_Space;
993 Checkc ('W');
994 Checkc ('=');
995 ALIs.Table (Id).WC_Encoding := Getc;
996 end if;
998 Skip_Eol;
999 end if;
1001 C := Getc;
1002 end if;
1004 -- Acquire argument lines
1006 First_Arg := Args.Last + 1;
1008 A_Loop : loop
1009 Check_Unknown_Line;
1010 exit A_Loop when C /= 'A';
1012 if Ignore ('A') then
1013 Skip_Line;
1015 else
1016 Checkc (' ');
1018 -- Scan out argument
1020 Name_Len := 0;
1021 while not At_Eol loop
1022 Add_Char_To_Name_Buffer (Getc);
1023 end loop;
1025 -- If -fstack-check, record that it occurred. Note that an
1026 -- additional string parameter can be specified, in the form of
1027 -- -fstack-check={no|generic|specific}. "no" means no checking,
1028 -- "generic" means force the use of old-style checking, and
1029 -- "specific" means use the best checking method.
1031 if Name_Len >= 13
1032 and then Name_Buffer (1 .. 13) = "-fstack-check"
1033 and then Name_Buffer (1 .. Name_Len) /= "-fstack-check=no"
1034 then
1035 Stack_Check_Switch_Set := True;
1036 end if;
1038 -- Store the argument
1040 Args.Increment_Last;
1041 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
1043 Skip_Eol;
1044 end if;
1046 C := Getc;
1047 end loop A_Loop;
1049 -- Acquire P line
1051 Check_Unknown_Line;
1053 while C /= 'P' loop
1054 if Ignore_Errors then
1055 if C = EOF then
1056 Fatal_Error;
1057 else
1058 Skip_Line;
1059 C := Nextc;
1060 end if;
1061 else
1062 Fatal_Error;
1063 end if;
1064 end loop;
1066 if Ignore ('P') then
1067 Skip_Line;
1069 -- Process P line
1071 else
1072 NS_Found := False;
1074 while not At_Eol loop
1075 Checkc (' ');
1076 Skip_Space;
1077 C := Getc;
1079 -- Processing for CE
1081 if C = 'C' then
1082 Checkc ('E');
1083 ALIs.Table (Id).Compile_Errors := True;
1085 -- Processing for DB
1087 elsif C = 'D' then
1088 Checkc ('B');
1089 Detect_Blocking := True;
1091 -- Processing for Ex
1093 elsif C = 'E' then
1094 Partition_Elaboration_Policy_Specified := Getc;
1095 ALIs.Table (Id).Partition_Elaboration_Policy :=
1096 Partition_Elaboration_Policy_Specified;
1098 -- Processing for FX
1100 elsif C = 'F' then
1101 C := Getc;
1103 if C = 'X' then
1104 ALIs.Table (Id).Frontend_Exceptions := True;
1105 Frontend_Exceptions_Specified := True;
1106 else
1107 Fatal_Error_Ignore;
1108 end if;
1110 -- Processing for GP
1112 elsif C = 'G' then
1113 Checkc ('P');
1114 GNATprove_Mode_Specified := True;
1115 ALIs.Table (Id).GNATprove_Mode := True;
1117 -- Processing for Lx
1119 elsif C = 'L' then
1120 Locking_Policy_Specified := Getc;
1121 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1123 -- Processing for flags starting with N
1125 elsif C = 'N' then
1126 C := Getc;
1128 -- Processing for NC
1130 if C = 'C' then
1131 ALIs.Table (Id).No_Component_Reordering := True;
1132 No_Component_Reordering_Specified := True;
1134 -- Processing for NO
1136 elsif C = 'O' then
1137 ALIs.Table (Id).No_Object := True;
1138 No_Object_Specified := True;
1140 -- Processing for NR
1142 elsif C = 'R' then
1143 No_Run_Time_Mode := True;
1144 Configurable_Run_Time_Mode := True;
1146 -- Processing for NS
1148 elsif C = 'S' then
1149 ALIs.Table (Id).Normalize_Scalars := True;
1150 Normalize_Scalars_Specified := True;
1151 NS_Found := True;
1153 -- Invalid switch starting with N
1155 else
1156 Fatal_Error_Ignore;
1157 end if;
1159 -- Processing for OH/OL
1161 elsif C = 'O' then
1162 C := Getc;
1164 if C = 'L' or else C = 'H' then
1165 ALIs.Table (Id).SSO_Default := C;
1166 SSO_Default_Specified := True;
1168 else
1169 Fatal_Error_Ignore;
1170 end if;
1172 -- Processing for Qx
1174 elsif C = 'Q' then
1175 Queuing_Policy_Specified := Getc;
1176 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1178 -- Processing for flags starting with S
1180 elsif C = 'S' then
1181 C := Getc;
1183 -- Processing for SL
1185 if C = 'L' then
1186 ALIs.Table (Id).SAL_Interface := True;
1188 -- Processing for SS
1190 elsif C = 'S' then
1191 Opt.Sec_Stack_Used := True;
1193 -- Invalid switch starting with S
1195 else
1196 Fatal_Error_Ignore;
1197 end if;
1199 -- Processing for Tx
1201 elsif C = 'T' then
1202 Task_Dispatching_Policy_Specified := Getc;
1203 ALIs.Table (Id).Task_Dispatching_Policy :=
1204 Task_Dispatching_Policy_Specified;
1206 -- Processing for switch starting with U
1208 elsif C = 'U' then
1209 C := Getc;
1211 -- Processing for UA
1213 if C = 'A' then
1214 Unreserve_All_Interrupts_Specified := True;
1216 -- Processing for UX
1218 elsif C = 'X' then
1219 ALIs.Table (Id).Unit_Exception_Table := True;
1221 -- Invalid switches starting with U
1223 else
1224 Fatal_Error_Ignore;
1225 end if;
1227 -- Processing for ZX
1229 elsif C = 'Z' then
1230 C := Getc;
1232 if C = 'X' then
1233 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1234 Zero_Cost_Exceptions_Specified := True;
1235 else
1236 Fatal_Error_Ignore;
1237 end if;
1239 -- Invalid parameter
1241 else
1242 C := Getc;
1243 Fatal_Error_Ignore;
1244 end if;
1245 end loop;
1247 if not NS_Found then
1248 No_Normalize_Scalars_Specified := True;
1249 end if;
1251 Skip_Eol;
1252 end if;
1254 C := Getc;
1255 Check_Unknown_Line;
1257 -- Loop to skip to first restrictions line
1259 while C /= 'R' loop
1260 if Ignore_Errors then
1261 if C = EOF then
1262 Fatal_Error;
1263 else
1264 Skip_Line;
1265 C := Nextc;
1266 end if;
1267 else
1268 Fatal_Error;
1269 end if;
1270 end loop;
1272 -- Ignore all 'R' lines if that is required
1274 if Ignore ('R') then
1275 while C = 'R' loop
1276 Skip_Line;
1277 C := Getc;
1278 end loop;
1280 -- Here we process the restrictions lines (other than unit name cases)
1282 else
1283 Scan_Restrictions : declare
1284 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1285 -- Save cumulative restrictions in case we have a fatal error
1287 Bad_R_Line : exception;
1288 -- Signal bad restrictions line (raised on unexpected character)
1290 Typ : Character;
1291 R : Restriction_Id;
1292 N : Natural;
1294 begin
1295 -- Named restriction case
1297 if Nextc = 'N' then
1298 Skip_Line;
1299 C := Getc;
1301 -- Loop through RR and RV lines
1303 while C = 'R' and then Nextc /= ' ' loop
1304 Typ := Getc;
1305 Checkc (' ');
1307 -- Acquire restriction name
1309 Name_Len := 0;
1310 while not At_Eol and then Nextc /= '=' loop
1311 Name_Len := Name_Len + 1;
1312 Name_Buffer (Name_Len) := Getc;
1313 end loop;
1315 -- Now search list of restrictions to find match
1317 declare
1318 RN : String renames Name_Buffer (1 .. Name_Len);
1320 begin
1321 R := Restriction_Id'First;
1322 while R /= Not_A_Restriction_Id loop
1323 if Restriction_Id'Image (R) = RN then
1324 goto R_Found;
1325 end if;
1327 R := Restriction_Id'Succ (R);
1328 end loop;
1330 -- We don't recognize the restriction. This might be
1331 -- thought of as an error, and it really is, but we
1332 -- want to allow building with inconsistent versions
1333 -- of the binder and ali files (see comments at the
1334 -- start of package System.Rident), so we just ignore
1335 -- this situation.
1337 goto Done_With_Restriction_Line;
1338 end;
1340 <<R_Found>>
1342 case R is
1344 -- Boolean restriction case
1346 when All_Boolean_Restrictions =>
1347 case Typ is
1348 when 'V' =>
1349 ALIs.Table (Id).Restrictions.Violated (R) :=
1350 True;
1351 Cumulative_Restrictions.Violated (R) := True;
1353 when 'R' =>
1354 ALIs.Table (Id).Restrictions.Set (R) := True;
1355 Cumulative_Restrictions.Set (R) := True;
1357 when others =>
1358 raise Bad_R_Line;
1359 end case;
1361 -- Parameter restriction case
1363 when All_Parameter_Restrictions =>
1364 if At_Eol or else Nextc /= '=' then
1365 raise Bad_R_Line;
1366 else
1367 Skipc;
1368 end if;
1370 N := Natural (Get_Nat);
1372 case Typ is
1374 -- Restriction set
1376 when 'R' =>
1377 ALIs.Table (Id).Restrictions.Set (R) := True;
1378 ALIs.Table (Id).Restrictions.Value (R) := N;
1380 if Cumulative_Restrictions.Set (R) then
1381 Cumulative_Restrictions.Value (R) :=
1382 Integer'Min
1383 (Cumulative_Restrictions.Value (R), N);
1384 else
1385 Cumulative_Restrictions.Set (R) := True;
1386 Cumulative_Restrictions.Value (R) := N;
1387 end if;
1389 -- Restriction violated
1391 when 'V' =>
1392 ALIs.Table (Id).Restrictions.Violated (R) :=
1393 True;
1394 Cumulative_Restrictions.Violated (R) := True;
1395 ALIs.Table (Id).Restrictions.Count (R) := N;
1397 -- Checked Max_Parameter case
1399 if R in Checked_Max_Parameter_Restrictions then
1400 Cumulative_Restrictions.Count (R) :=
1401 Integer'Max
1402 (Cumulative_Restrictions.Count (R), N);
1404 -- Other checked parameter cases
1406 else
1407 declare
1408 pragma Unsuppress (Overflow_Check);
1410 begin
1411 Cumulative_Restrictions.Count (R) :=
1412 Cumulative_Restrictions.Count (R) + N;
1414 exception
1415 when Constraint_Error =>
1417 -- A constraint error comes from the
1418 -- addition. We reset to the maximum
1419 -- and indicate that the real value
1420 -- is now unknown.
1422 Cumulative_Restrictions.Value (R) :=
1423 Integer'Last;
1424 Cumulative_Restrictions.Unknown (R) :=
1425 True;
1426 end;
1427 end if;
1429 -- Deal with + case
1431 if Nextc = '+' then
1432 Skipc;
1433 ALIs.Table (Id).Restrictions.Unknown (R) :=
1434 True;
1435 Cumulative_Restrictions.Unknown (R) := True;
1436 end if;
1438 -- Other than 'R' or 'V'
1440 when others =>
1441 raise Bad_R_Line;
1442 end case;
1444 if not At_Eol then
1445 raise Bad_R_Line;
1446 end if;
1448 -- Bizarre error case NOT_A_RESTRICTION
1450 when Not_A_Restriction_Id =>
1451 raise Bad_R_Line;
1452 end case;
1454 if not At_Eol then
1455 raise Bad_R_Line;
1456 end if;
1458 <<Done_With_Restriction_Line>>
1459 Skip_Line;
1460 C := Getc;
1461 end loop;
1463 -- Positional restriction case
1465 else
1466 Checkc (' ');
1467 Skip_Space;
1469 -- Acquire information for boolean restrictions
1471 for R in All_Boolean_Restrictions loop
1472 C := Getc;
1474 case C is
1475 when 'v' =>
1476 ALIs.Table (Id).Restrictions.Violated (R) := True;
1477 Cumulative_Restrictions.Violated (R) := True;
1479 when 'r' =>
1480 ALIs.Table (Id).Restrictions.Set (R) := True;
1481 Cumulative_Restrictions.Set (R) := True;
1483 when 'n' =>
1484 null;
1486 when others =>
1487 raise Bad_R_Line;
1488 end case;
1489 end loop;
1491 -- Acquire information for parameter restrictions
1493 for RP in All_Parameter_Restrictions loop
1494 case Getc is
1495 when 'n' =>
1496 null;
1498 when 'r' =>
1499 ALIs.Table (Id).Restrictions.Set (RP) := True;
1501 declare
1502 N : constant Integer := Integer (Get_Nat);
1503 begin
1504 ALIs.Table (Id).Restrictions.Value (RP) := N;
1506 if Cumulative_Restrictions.Set (RP) then
1507 Cumulative_Restrictions.Value (RP) :=
1508 Integer'Min
1509 (Cumulative_Restrictions.Value (RP), N);
1510 else
1511 Cumulative_Restrictions.Set (RP) := True;
1512 Cumulative_Restrictions.Value (RP) := N;
1513 end if;
1514 end;
1516 when others =>
1517 raise Bad_R_Line;
1518 end case;
1520 -- Acquire restrictions violations information
1522 case Getc is
1524 when 'n' =>
1525 null;
1527 when 'v' =>
1528 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1529 Cumulative_Restrictions.Violated (RP) := True;
1531 declare
1532 N : constant Integer := Integer (Get_Nat);
1534 begin
1535 ALIs.Table (Id).Restrictions.Count (RP) := N;
1537 if RP in Checked_Max_Parameter_Restrictions then
1538 Cumulative_Restrictions.Count (RP) :=
1539 Integer'Max
1540 (Cumulative_Restrictions.Count (RP), N);
1542 else
1543 declare
1544 pragma Unsuppress (Overflow_Check);
1546 begin
1547 Cumulative_Restrictions.Count (RP) :=
1548 Cumulative_Restrictions.Count (RP) + N;
1550 exception
1551 when Constraint_Error =>
1553 -- A constraint error comes from the add. We
1554 -- reset to the maximum and indicate that the
1555 -- real value is now unknown.
1557 Cumulative_Restrictions.Value (RP) :=
1558 Integer'Last;
1559 Cumulative_Restrictions.Unknown (RP) := True;
1560 end;
1561 end if;
1563 if Nextc = '+' then
1564 Skipc;
1565 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1566 Cumulative_Restrictions.Unknown (RP) := True;
1567 end if;
1568 end;
1570 when others =>
1571 raise Bad_R_Line;
1572 end case;
1573 end loop;
1575 if not At_Eol then
1576 raise Bad_R_Line;
1577 else
1578 Skip_Line;
1579 C := Getc;
1580 end if;
1581 end if;
1583 -- Here if error during scanning of restrictions line
1585 exception
1586 when Bad_R_Line =>
1588 -- In Ignore_Errors mode, undo any changes to restrictions
1589 -- from this unit, and continue on, skipping remaining R
1590 -- lines for this unit.
1592 if Ignore_Errors then
1593 Cumulative_Restrictions := Save_R;
1594 ALIs.Table (Id).Restrictions := No_Restrictions;
1596 loop
1597 Skip_Eol;
1598 C := Getc;
1599 exit when C /= 'R';
1600 end loop;
1602 -- In normal mode, this is a fatal error
1604 else
1605 Fatal_Error;
1606 end if;
1607 end Scan_Restrictions;
1608 end if;
1610 -- Acquire additional restrictions (No_Dependence) lines if present
1612 while C = 'R' loop
1613 if Ignore ('R') then
1614 Skip_Line;
1615 else
1616 Skip_Space;
1617 No_Deps.Append ((Id, Get_Name));
1618 Skip_Eol;
1619 end if;
1621 C := Getc;
1622 end loop;
1624 -- Acquire 'I' lines if present
1626 Check_Unknown_Line;
1628 while C = 'I' loop
1629 if Ignore ('I') then
1630 Skip_Line;
1632 else
1633 declare
1634 Int_Num : Nat;
1635 I_State : Character;
1636 Line_No : Nat;
1638 begin
1639 Int_Num := Get_Nat;
1640 Skip_Space;
1641 I_State := Getc;
1642 Line_No := Get_Nat;
1644 Interrupt_States.Append (
1645 (Interrupt_Id => Int_Num,
1646 Interrupt_State => I_State,
1647 IS_Pragma_Line => Line_No));
1649 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1650 Skip_Eol;
1651 end;
1652 end if;
1654 C := Getc;
1655 end loop;
1657 -- Acquire 'S' lines if present
1659 Check_Unknown_Line;
1661 while C = 'S' loop
1662 if Ignore ('S') then
1663 Skip_Line;
1665 else
1666 declare
1667 Policy : Character;
1668 First_Prio : Nat;
1669 Last_Prio : Nat;
1670 Line_No : Nat;
1672 begin
1673 Checkc (' ');
1674 Skip_Space;
1676 Policy := Getc;
1677 Skip_Space;
1678 First_Prio := Get_Nat;
1679 Last_Prio := Get_Nat;
1680 Line_No := Get_Nat;
1682 Specific_Dispatching.Append (
1683 (Dispatching_Policy => Policy,
1684 First_Priority => First_Prio,
1685 Last_Priority => Last_Prio,
1686 PSD_Pragma_Line => Line_No));
1688 ALIs.Table (Id).Last_Specific_Dispatching :=
1689 Specific_Dispatching.Last;
1691 Skip_Eol;
1692 end;
1693 end if;
1695 C := Getc;
1696 end loop;
1698 -- Loop to acquire unit entries
1700 U_Loop : loop
1701 Check_Unknown_Line;
1702 exit U_Loop when C /= 'U';
1704 -- Note: as per spec, we never ignore U lines
1706 Checkc (' ');
1707 Skip_Space;
1708 Units.Increment_Last;
1710 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1711 ALIs.Table (Id).First_Unit := Units.Last;
1712 end if;
1714 declare
1715 UL : Unit_Record renames Units.Table (Units.Last);
1717 begin
1718 UL.Uname := Get_Unit_Name;
1719 UL.Predefined := Is_Predefined_Unit;
1720 UL.Internal := Is_Internal_Unit;
1721 UL.My_ALI := Id;
1722 UL.Sfile := Get_File_Name (Lower => True);
1723 UL.Pure := False;
1724 UL.Preelab := False;
1725 UL.No_Elab := False;
1726 UL.Shared_Passive := False;
1727 UL.RCI := False;
1728 UL.Remote_Types := False;
1729 UL.Serious_Errors := False;
1730 UL.Has_RACW := False;
1731 UL.Init_Scalars := False;
1732 UL.Is_Generic := False;
1733 UL.Icasing := Mixed_Case;
1734 UL.Kcasing := All_Lower_Case;
1735 UL.Dynamic_Elab := False;
1736 UL.Elaborate_Body := False;
1737 UL.Set_Elab_Entity := False;
1738 UL.Version := "00000000";
1739 UL.First_With := Withs.Last + 1;
1740 UL.First_Arg := First_Arg;
1741 UL.Elab_Position := 0;
1742 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1743 UL.Directly_Scanned := Directly_Scanned;
1744 UL.Body_Needed_For_SAL := False;
1745 UL.Elaborate_Body_Desirable := False;
1746 UL.Optimize_Alignment := 'O';
1747 UL.Has_Finalizer := False;
1748 UL.Primary_Stack_Count := 0;
1749 UL.Sec_Stack_Count := 0;
1751 if Debug_Flag_U then
1752 Write_Str (" ----> reading unit ");
1753 Write_Int (Int (Units.Last));
1754 Write_Str (" ");
1755 Write_Unit_Name (UL.Uname);
1756 Write_Str (" from file ");
1757 Write_Name (UL.Sfile);
1758 Write_Eol;
1759 end if;
1760 end;
1762 -- Check for duplicated unit in different files
1764 declare
1765 Info : constant Int := Get_Name_Table_Int
1766 (Units.Table (Units.Last).Uname);
1767 begin
1768 if Info /= 0
1769 and then Units.Table (Units.Last).Sfile /=
1770 Units.Table (Unit_Id (Info)).Sfile
1771 then
1772 -- If Err is set then ignore duplicate unit name. This is the
1773 -- case of a call from gnatmake, where the situation can arise
1774 -- from substitution of source files. In such situations, the
1775 -- processing in gnatmake will always result in any required
1776 -- recompilations in any case, and if we consider this to be
1777 -- an error we get strange cases (for example when a generic
1778 -- instantiation is replaced by a normal package) where we
1779 -- read the old ali file, decide to recompile, and then decide
1780 -- that the old and new ali files are incompatible.
1782 if Err then
1783 null;
1785 -- If Err is not set, then this is a fatal error. This is
1786 -- the case of being called from the binder, where we must
1787 -- definitely diagnose this as an error.
1789 else
1790 Set_Standard_Error;
1791 Write_Str ("error: duplicate unit name: ");
1792 Write_Eol;
1794 Write_Str ("error: unit """);
1795 Write_Unit_Name (Units.Table (Units.Last).Uname);
1796 Write_Str (""" found in file """);
1797 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1798 Write_Char ('"');
1799 Write_Eol;
1801 Write_Str ("error: unit """);
1802 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1803 Write_Str (""" found in file """);
1804 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1805 Write_Char ('"');
1806 Write_Eol;
1808 Exit_Program (E_Fatal);
1809 end if;
1810 end if;
1811 end;
1813 Set_Name_Table_Int
1814 (Units.Table (Units.Last).Uname, Int (Units.Last));
1816 -- Scan out possible version and other parameters
1818 loop
1819 Skip_Space;
1820 exit when At_Eol;
1821 C := Getc;
1823 -- Version field
1825 if C in '0' .. '9' or else C in 'a' .. 'f' then
1826 Units.Table (Units.Last).Version (1) := C;
1828 for J in 2 .. 8 loop
1829 C := Getc;
1830 Units.Table (Units.Last).Version (J) := C;
1831 end loop;
1833 -- BD/BN parameters
1835 elsif C = 'B' then
1836 C := Getc;
1838 if C = 'D' then
1839 Check_At_End_Of_Field;
1840 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1842 elsif C = 'N' then
1843 Check_At_End_Of_Field;
1844 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1846 else
1847 Fatal_Error_Ignore;
1848 end if;
1850 -- DE parameter (Dynamic elaboration checks)
1852 elsif C = 'D' then
1853 C := Getc;
1855 if C = 'E' then
1856 Check_At_End_Of_Field;
1857 Units.Table (Units.Last).Dynamic_Elab := True;
1858 Dynamic_Elaboration_Checks_Specified := True;
1859 else
1860 Fatal_Error_Ignore;
1861 end if;
1863 -- EB/EE parameters
1865 elsif C = 'E' then
1866 C := Getc;
1868 if C = 'B' then
1869 Units.Table (Units.Last).Elaborate_Body := True;
1870 elsif C = 'E' then
1871 Units.Table (Units.Last).Set_Elab_Entity := True;
1872 else
1873 Fatal_Error_Ignore;
1874 end if;
1876 Check_At_End_Of_Field;
1878 -- GE parameter (generic)
1880 elsif C = 'G' then
1881 C := Getc;
1883 if C = 'E' then
1884 Check_At_End_Of_Field;
1885 Units.Table (Units.Last).Is_Generic := True;
1886 else
1887 Fatal_Error_Ignore;
1888 end if;
1890 -- IL/IS/IU parameters
1892 elsif C = 'I' then
1893 C := Getc;
1895 if C = 'L' then
1896 Units.Table (Units.Last).Icasing := All_Lower_Case;
1897 elsif C = 'S' then
1898 Units.Table (Units.Last).Init_Scalars := True;
1899 Initialize_Scalars_Used := True;
1900 elsif C = 'U' then
1901 Units.Table (Units.Last).Icasing := All_Upper_Case;
1902 else
1903 Fatal_Error_Ignore;
1904 end if;
1906 Check_At_End_Of_Field;
1908 -- KM/KU parameters
1910 elsif C = 'K' then
1911 C := Getc;
1913 if C = 'M' then
1914 Units.Table (Units.Last).Kcasing := Mixed_Case;
1915 elsif C = 'U' then
1916 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1917 else
1918 Fatal_Error_Ignore;
1919 end if;
1921 Check_At_End_Of_Field;
1923 -- NE parameter
1925 elsif C = 'N' then
1926 C := Getc;
1928 if C = 'E' then
1929 Units.Table (Units.Last).No_Elab := True;
1930 Check_At_End_Of_Field;
1931 else
1932 Fatal_Error_Ignore;
1933 end if;
1935 -- PF/PR/PU/PK parameters
1937 elsif C = 'P' then
1938 C := Getc;
1940 if C = 'F' then
1941 Units.Table (Units.Last).Has_Finalizer := True;
1942 elsif C = 'R' then
1943 Units.Table (Units.Last).Preelab := True;
1944 elsif C = 'U' then
1945 Units.Table (Units.Last).Pure := True;
1946 elsif C = 'K' then
1947 Units.Table (Units.Last).Unit_Kind := 'p';
1948 else
1949 Fatal_Error_Ignore;
1950 end if;
1952 Check_At_End_Of_Field;
1954 -- OL/OO/OS/OT parameters
1956 elsif C = 'O' then
1957 C := Getc;
1959 if C = 'L' or else C = 'O' or else C = 'S' or else C = 'T' then
1960 Units.Table (Units.Last).Optimize_Alignment := C;
1961 else
1962 Fatal_Error_Ignore;
1963 end if;
1965 Check_At_End_Of_Field;
1967 -- RC/RT parameters
1969 elsif C = 'R' then
1970 C := Getc;
1972 if C = 'C' then
1973 Units.Table (Units.Last).RCI := True;
1974 elsif C = 'T' then
1975 Units.Table (Units.Last).Remote_Types := True;
1976 elsif C = 'A' then
1977 Units.Table (Units.Last).Has_RACW := True;
1978 else
1979 Fatal_Error_Ignore;
1980 end if;
1982 Check_At_End_Of_Field;
1984 -- SE/SP/SU parameters
1986 elsif C = 'S' then
1987 C := Getc;
1989 if C = 'E' then
1990 Units.Table (Units.Last).Serious_Errors := True;
1991 elsif C = 'P' then
1992 Units.Table (Units.Last).Shared_Passive := True;
1993 elsif C = 'U' then
1994 Units.Table (Units.Last).Unit_Kind := 's';
1995 else
1996 Fatal_Error_Ignore;
1997 end if;
1999 Check_At_End_Of_Field;
2001 else
2002 C := Getc;
2003 Fatal_Error_Ignore;
2004 end if;
2005 end loop;
2007 Skip_Eol;
2009 C := Getc;
2011 -- Scan out With lines for this unit
2013 With_Loop : loop
2014 Check_Unknown_Line;
2015 exit With_Loop when C /= 'W' and then C /= 'Y' and then C /= 'Z';
2017 if Ignore ('W') then
2018 Skip_Line;
2020 else
2021 Checkc (' ');
2022 Skip_Space;
2023 Withs.Increment_Last;
2024 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
2025 Withs.Table (Withs.Last).Elaborate := False;
2026 Withs.Table (Withs.Last).Elaborate_All := False;
2027 Withs.Table (Withs.Last).Elab_Desirable := False;
2028 Withs.Table (Withs.Last).Elab_All_Desirable := False;
2029 Withs.Table (Withs.Last).SAL_Interface := False;
2030 Withs.Table (Withs.Last).Limited_With := (C = 'Y');
2031 Withs.Table (Withs.Last).Implicit_With_From_Instantiation
2032 := (C = 'Z');
2034 -- Generic case with no object file available
2036 if At_Eol then
2037 Withs.Table (Withs.Last).Sfile := No_File;
2038 Withs.Table (Withs.Last).Afile := No_File;
2040 -- Normal case
2042 else
2043 Withs.Table (Withs.Last).Sfile := Get_File_Name
2044 (Lower => True);
2045 Withs.Table (Withs.Last).Afile := Get_File_Name
2046 (Lower => True);
2048 -- Scan out possible E, EA, ED, and AD parameters
2050 while not At_Eol loop
2051 Skip_Space;
2053 if Nextc = 'A' then
2054 P := P + 1;
2055 Checkc ('D');
2056 Check_At_End_Of_Field;
2058 -- Store AD indication unless ignore required
2060 if not Ignore_ED then
2061 Withs.Table (Withs.Last).Elab_All_Desirable := True;
2062 end if;
2064 elsif Nextc = 'E' then
2065 P := P + 1;
2067 if At_End_Of_Field then
2068 Withs.Table (Withs.Last).Elaborate := True;
2070 elsif Nextc = 'A' then
2071 P := P + 1;
2072 Check_At_End_Of_Field;
2073 Withs.Table (Withs.Last).Elaborate_All := True;
2075 else
2076 Checkc ('D');
2077 Check_At_End_Of_Field;
2079 -- Store ED indication unless ignore required
2081 if not Ignore_ED then
2082 Withs.Table (Withs.Last).Elab_Desirable :=
2083 True;
2084 end if;
2085 end if;
2087 else
2088 Fatal_Error;
2089 end if;
2090 end loop;
2091 end if;
2093 Skip_Eol;
2094 end if;
2096 C := Getc;
2097 end loop With_Loop;
2099 Units.Table (Units.Last).Last_With := Withs.Last;
2100 Units.Table (Units.Last).Last_Arg := Args.Last;
2102 -- Scan out task stack information for the unit if present
2104 Check_Unknown_Line;
2106 if C = 'T' then
2107 if Ignore ('T') then
2108 Skip_Line;
2110 else
2111 Checkc (' ');
2112 Skip_Space;
2114 Units.Table (Units.Last).Primary_Stack_Count := Get_Nat;
2115 Skip_Space;
2116 Units.Table (Units.Last).Sec_Stack_Count := Get_Nat;
2117 Skip_Space;
2118 Skip_Eol;
2119 end if;
2121 C := Getc;
2122 end if;
2124 -- If there are linker options lines present, scan them
2126 Name_Len := 0;
2128 Linker_Options_Loop : loop
2129 Check_Unknown_Line;
2130 exit Linker_Options_Loop when C /= 'L';
2132 if Ignore ('L') then
2133 Skip_Line;
2135 else
2136 Checkc (' ');
2137 Skip_Space;
2138 Checkc ('"');
2140 loop
2141 C := Getc;
2143 if C < Character'Val (16#20#)
2144 or else C > Character'Val (16#7E#)
2145 then
2146 Fatal_Error_Ignore;
2148 elsif C = '{' then
2149 C := Character'Val (0);
2151 declare
2152 V : Natural;
2154 begin
2155 V := 0;
2156 for J in 1 .. 2 loop
2157 C := Getc;
2159 if C in '0' .. '9' then
2160 V := V * 16 +
2161 Character'Pos (C) -
2162 Character'Pos ('0');
2164 elsif C in 'A' .. 'F' then
2165 V := V * 16 +
2166 Character'Pos (C) -
2167 Character'Pos ('A') +
2170 else
2171 Fatal_Error_Ignore;
2172 end if;
2173 end loop;
2175 Checkc ('}');
2176 Add_Char_To_Name_Buffer (Character'Val (V));
2177 end;
2179 else
2180 if C = '"' then
2181 exit when Nextc /= '"';
2182 C := Getc;
2183 end if;
2185 Add_Char_To_Name_Buffer (C);
2186 end if;
2187 end loop;
2189 Add_Char_To_Name_Buffer (NUL);
2190 Skip_Eol;
2191 end if;
2193 C := Getc;
2194 end loop Linker_Options_Loop;
2196 -- Store the linker options entry if one was found
2198 if Name_Len /= 0 then
2199 Linker_Options.Increment_Last;
2201 Linker_Options.Table (Linker_Options.Last).Name :=
2202 Name_Enter;
2204 Linker_Options.Table (Linker_Options.Last).Unit :=
2205 Units.Last;
2207 Linker_Options.Table (Linker_Options.Last).Internal_File :=
2208 Is_Internal_File_Name (F);
2210 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
2211 Linker_Options.Last;
2212 end if;
2214 -- If there are notes present, scan them
2216 Notes_Loop : loop
2217 Check_Unknown_Line;
2218 exit Notes_Loop when C /= 'N';
2220 if Ignore ('N') then
2221 Skip_Line;
2223 else
2224 Checkc (' ');
2226 Notes.Increment_Last;
2227 Notes.Table (Notes.Last).Pragma_Type := Getc;
2228 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
2229 Checkc (':');
2230 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
2232 if not At_Eol and then Nextc = ':' then
2233 Checkc (':');
2234 Notes.Table (Notes.Last).Pragma_Source_File :=
2235 Get_File_Name (Lower => True);
2236 else
2237 Notes.Table (Notes.Last).Pragma_Source_File :=
2238 Units.Table (Units.Last).Sfile;
2239 end if;
2241 if At_Eol then
2242 Notes.Table (Notes.Last).Pragma_Args := No_Name;
2244 else
2245 -- Note: can't use Get_Name here as the remainder of the
2246 -- line is unstructured text whose syntax depends on the
2247 -- particular pragma used.
2249 Checkc (' ');
2251 Name_Len := 0;
2252 while not At_Eol loop
2253 Add_Char_To_Name_Buffer (Getc);
2254 end loop;
2255 end if;
2257 Skip_Eol;
2258 end if;
2260 C := Getc;
2261 end loop Notes_Loop;
2262 end loop U_Loop;
2264 -- End loop through units for one ALI file
2266 ALIs.Table (Id).Last_Unit := Units.Last;
2267 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
2269 -- Set types of the units (there can be at most 2 of them)
2271 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
2272 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
2273 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
2275 else
2276 -- Deal with body only and spec only cases, note that the reason we
2277 -- do our own checking of the name (rather than using Is_Body_Name)
2278 -- is that Uname drags in far too much compiler junk.
2280 Get_Name_String (Units.Table (Units.Last).Uname);
2282 if Name_Buffer (Name_Len) = 'b' then
2283 Units.Table (Units.Last).Utype := Is_Body_Only;
2284 else
2285 Units.Table (Units.Last).Utype := Is_Spec_Only;
2286 end if;
2287 end if;
2289 -- Scan out external version references and put in hash table
2291 E_Loop : loop
2292 Check_Unknown_Line;
2293 exit E_Loop when C /= 'E';
2295 if Ignore ('E') then
2296 Skip_Line;
2298 else
2299 Checkc (' ');
2300 Skip_Space;
2302 Name_Len := 0;
2303 Name_Len := 0;
2304 loop
2305 C := Getc;
2307 if C < ' ' then
2308 Fatal_Error;
2309 end if;
2311 exit when At_End_Of_Field;
2312 Add_Char_To_Name_Buffer (C);
2313 end loop;
2315 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
2316 Skip_Eol;
2317 end if;
2319 C := Getc;
2320 end loop E_Loop;
2322 -- Scan out source dependency lines for this ALI file
2324 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
2326 D_Loop : loop
2327 Check_Unknown_Line;
2328 exit D_Loop when C /= 'D';
2330 if Ignore ('D') then
2331 Skip_Line;
2333 else
2334 Checkc (' ');
2335 Skip_Space;
2336 Sdep.Increment_Last;
2338 -- In the following call, Lower is not set to True, this is either
2339 -- a bug, or it deserves a special comment as to why this is so???
2341 -- The file/path name may be quoted
2343 Sdep.Table (Sdep.Last).Sfile :=
2344 Get_File_Name (May_Be_Quoted => True);
2346 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2347 Sdep.Table (Sdep.Last).Dummy_Entry :=
2348 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2350 -- Acquire checksum value
2352 Skip_Space;
2354 declare
2355 Ctr : Natural;
2356 Chk : Word;
2358 begin
2359 Ctr := 0;
2360 Chk := 0;
2362 loop
2363 exit when At_Eol or else Ctr = 8;
2365 if Nextc in '0' .. '9' then
2366 Chk := Chk * 16 +
2367 Character'Pos (Nextc) - Character'Pos ('0');
2369 elsif Nextc in 'a' .. 'f' then
2370 Chk := Chk * 16 +
2371 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2373 else
2374 exit;
2375 end if;
2377 Ctr := Ctr + 1;
2378 P := P + 1;
2379 end loop;
2381 if Ctr = 8 and then At_End_Of_Field then
2382 Sdep.Table (Sdep.Last).Checksum := Chk;
2383 else
2384 Fatal_Error;
2385 end if;
2386 end;
2388 -- Acquire (sub)unit and reference file name entries
2390 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2391 Sdep.Table (Sdep.Last).Unit_Name := No_Name;
2392 Sdep.Table (Sdep.Last).Rfile :=
2393 Sdep.Table (Sdep.Last).Sfile;
2394 Sdep.Table (Sdep.Last).Start_Line := 1;
2396 if not At_Eol then
2397 Skip_Space;
2399 -- Here for (sub)unit name
2401 if Nextc not in '0' .. '9' then
2402 Name_Len := 0;
2403 while not At_End_Of_Field loop
2404 Add_Char_To_Name_Buffer (Getc);
2405 end loop;
2407 -- Set the (sub)unit name. Note that we use Name_Find rather
2408 -- than Name_Enter here as the subunit name may already
2409 -- have been put in the name table by the Project Manager.
2411 if Name_Len <= 2
2412 or else Name_Buffer (Name_Len - 1) /= '%'
2413 then
2414 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2415 else
2416 Name_Len := Name_Len - 2;
2417 Sdep.Table (Sdep.Last).Unit_Name := Name_Find;
2418 end if;
2420 Skip_Space;
2421 end if;
2423 -- Here for reference file name entry
2425 if Nextc in '0' .. '9' then
2426 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2427 Checkc (':');
2429 Name_Len := 0;
2431 while not At_End_Of_Field loop
2432 Add_Char_To_Name_Buffer (Getc);
2433 end loop;
2435 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2436 end if;
2437 end if;
2439 Skip_Eol;
2440 end if;
2442 C := Getc;
2443 end loop D_Loop;
2445 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2447 -- We must at this stage be at an Xref line or the end of file
2449 if C = EOF then
2450 return Id;
2451 end if;
2453 Check_Unknown_Line;
2455 if C /= 'X' then
2456 Fatal_Error;
2457 end if;
2459 -- If we are ignoring Xref sections we are done (we ignore all
2460 -- remaining lines since only xref related lines follow X).
2462 if Ignore ('X') and then not Debug_Flag_X then
2463 return Id;
2464 end if;
2466 -- Loop through Xref sections
2468 X_Loop : loop
2469 Check_Unknown_Line;
2470 exit X_Loop when C /= 'X';
2472 -- Make new entry in section table
2474 Xref_Section.Increment_Last;
2476 Read_Refs_For_One_File : declare
2477 XS : Xref_Section_Record renames
2478 Xref_Section.Table (Xref_Section.Last);
2480 Current_File_Num : Sdep_Id;
2481 -- Keeps track of the current file number (changed by nn|)
2483 begin
2484 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2485 XS.File_Name := Get_File_Name;
2486 XS.First_Entity := Xref_Entity.Last + 1;
2488 Current_File_Num := XS.File_Num;
2490 Skip_Space;
2492 Skip_Eol;
2493 C := Nextc;
2495 -- Loop through Xref entities
2497 while C /= 'X' and then C /= EOF loop
2498 Xref_Entity.Increment_Last;
2500 Read_Refs_For_One_Entity : declare
2501 XE : Xref_Entity_Record renames
2502 Xref_Entity.Table (Xref_Entity.Last);
2503 N : Nat;
2505 procedure Read_Instantiation_Reference;
2506 -- Acquire instantiation reference. Caller has checked
2507 -- that current character is '[' and on return the cursor
2508 -- is skipped past the corresponding closing ']'.
2510 ----------------------------------
2511 -- Read_Instantiation_Reference --
2512 ----------------------------------
2514 procedure Read_Instantiation_Reference is
2515 Local_File_Num : Sdep_Id := Current_File_Num;
2517 begin
2518 Xref.Increment_Last;
2520 declare
2521 XR : Xref_Record renames Xref.Table (Xref.Last);
2523 begin
2524 P := P + 1; -- skip [
2525 N := Get_Nat;
2527 if Nextc = '|' then
2528 XR.File_Num :=
2529 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2530 Local_File_Num := XR.File_Num;
2531 P := P + 1;
2532 N := Get_Nat;
2534 else
2535 XR.File_Num := Local_File_Num;
2536 end if;
2538 XR.Line := N;
2539 XR.Rtype := ' ';
2540 XR.Col := 0;
2542 -- Recursive call for next reference
2544 if Nextc = '[' then
2545 pragma Warnings (Off); -- kill recursion warning
2546 Read_Instantiation_Reference;
2547 pragma Warnings (On);
2548 end if;
2550 -- Skip closing bracket after recursive call
2552 P := P + 1;
2553 end;
2554 end Read_Instantiation_Reference;
2556 -- Start of processing for Read_Refs_For_One_Entity
2558 begin
2559 XE.Line := Get_Nat;
2560 XE.Etype := Getc;
2561 XE.Col := Get_Nat;
2563 case Getc is
2564 when '*' =>
2565 XE.Visibility := Global;
2566 when '+' =>
2567 XE.Visibility := Static;
2568 when others =>
2569 XE.Visibility := Other;
2570 end case;
2572 XE.Entity := Get_Name;
2574 -- Handle the information about generic instantiations
2576 if Nextc = '[' then
2577 Skipc; -- Opening '['
2578 N := Get_Nat;
2580 if Nextc /= '|' then
2581 XE.Iref_File_Num := Current_File_Num;
2582 XE.Iref_Line := N;
2583 else
2584 XE.Iref_File_Num :=
2585 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2586 Skipc;
2587 XE.Iref_Line := Get_Nat;
2588 end if;
2590 if Getc /= ']' then
2591 Fatal_Error;
2592 end if;
2594 else
2595 XE.Iref_File_Num := No_Sdep_Id;
2596 XE.Iref_Line := 0;
2597 end if;
2599 Current_File_Num := XS.File_Num;
2601 -- Renaming reference is present
2603 if Nextc = '=' then
2604 P := P + 1;
2605 XE.Rref_Line := Get_Nat;
2607 if Getc /= ':' then
2608 Fatal_Error;
2609 end if;
2611 XE.Rref_Col := Get_Nat;
2613 -- No renaming reference present
2615 else
2616 XE.Rref_Line := 0;
2617 XE.Rref_Col := 0;
2618 end if;
2620 Skip_Space;
2622 XE.Oref_File_Num := No_Sdep_Id;
2623 XE.Tref_File_Num := No_Sdep_Id;
2624 XE.Tref := Tref_None;
2625 XE.First_Xref := Xref.Last + 1;
2627 -- Loop to check for additional info present
2629 loop
2630 declare
2631 Ref : Tref_Kind;
2632 File : Sdep_Id;
2633 Line : Nat;
2634 Typ : Character;
2635 Col : Nat;
2636 Std : Name_Id;
2638 begin
2639 Get_Typeref
2640 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2641 exit when Ref = Tref_None;
2643 -- Do we have an overriding procedure?
2645 if Ref = Tref_Derived and then Typ = 'p' then
2646 XE.Oref_File_Num := File;
2647 XE.Oref_Line := Line;
2648 XE.Oref_Col := Col;
2650 -- Arrays never override anything, and <> points to
2651 -- the index types instead
2653 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2655 -- Index types are stored in the list of references
2657 Xref.Increment_Last;
2659 declare
2660 XR : Xref_Record renames Xref.Table (Xref.Last);
2661 begin
2662 XR.File_Num := File;
2663 XR.Line := Line;
2664 XR.Rtype := Array_Index_Reference;
2665 XR.Col := Col;
2666 XR.Name := Std;
2667 end;
2669 -- Interfaces are stored in the list of references,
2670 -- although the parent type itself is stored in XE.
2671 -- The first interface (when there are only
2672 -- interfaces) is stored in XE.Tref*)
2674 elsif Ref = Tref_Derived
2675 and then Typ = 'R'
2676 and then XE.Tref_File_Num /= No_Sdep_Id
2677 then
2678 Xref.Increment_Last;
2680 declare
2681 XR : Xref_Record renames Xref.Table (Xref.Last);
2682 begin
2683 XR.File_Num := File;
2684 XR.Line := Line;
2685 XR.Rtype := Interface_Reference;
2686 XR.Col := Col;
2687 XR.Name := Std;
2688 end;
2690 else
2691 XE.Tref := Ref;
2692 XE.Tref_File_Num := File;
2693 XE.Tref_Line := Line;
2694 XE.Tref_Type := Typ;
2695 XE.Tref_Col := Col;
2696 XE.Tref_Standard_Entity := Std;
2697 end if;
2698 end;
2699 end loop;
2701 -- Loop through cross-references for this entity
2703 loop
2704 Skip_Space;
2706 if At_Eol then
2707 Skip_Eol;
2708 exit when Nextc /= '.';
2709 P := P + 1;
2710 end if;
2712 Xref.Increment_Last;
2714 declare
2715 XR : Xref_Record renames Xref.Table (Xref.Last);
2717 begin
2718 N := Get_Nat;
2720 if Nextc = '|' then
2721 XR.File_Num :=
2722 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2723 Current_File_Num := XR.File_Num;
2724 P := P + 1;
2725 N := Get_Nat;
2726 else
2727 XR.File_Num := Current_File_Num;
2728 end if;
2730 XR.Line := N;
2731 XR.Rtype := Getc;
2733 -- Imported entities reference as in:
2734 -- 494b<c,__gnat_copy_attribs>25
2736 if Nextc = '<' then
2737 Skipc;
2738 XR.Imported_Lang := Get_Name;
2740 pragma Assert (Nextc = ',');
2741 Skipc;
2743 XR.Imported_Name := Get_Name;
2745 pragma Assert (Nextc = '>');
2746 Skipc;
2748 else
2749 XR.Imported_Lang := No_Name;
2750 XR.Imported_Name := No_Name;
2751 end if;
2753 XR.Col := Get_Nat;
2755 if Nextc = '[' then
2756 Read_Instantiation_Reference;
2757 end if;
2758 end;
2759 end loop;
2761 -- Record last cross-reference
2763 XE.Last_Xref := Xref.Last;
2764 C := Nextc;
2766 exception
2767 when Bad_ALI_Format =>
2769 -- If ignoring errors, then we skip a line with an
2770 -- unexpected error, and try to continue subsequent
2771 -- xref lines.
2773 if Ignore_Errors then
2774 Xref_Entity.Decrement_Last;
2775 Skip_Line;
2776 C := Nextc;
2778 -- Otherwise, we reraise the fatal exception
2780 else
2781 raise;
2782 end if;
2783 end Read_Refs_For_One_Entity;
2784 end loop;
2786 -- Record last entity
2788 XS.Last_Entity := Xref_Entity.Last;
2790 end Read_Refs_For_One_File;
2792 C := Getc;
2793 end loop X_Loop;
2795 -- Here after dealing with xref sections
2797 -- Ignore remaining lines, which belong to an additional section of the
2798 -- ALI file not considered here (like SCO or SPARK information).
2800 Check_Unknown_Line;
2802 return Id;
2804 exception
2805 when Bad_ALI_Format =>
2806 return No_ALI_Id;
2807 end Scan_ALI;
2809 ---------
2810 -- SEq --
2811 ---------
2813 function SEq (F1, F2 : String_Ptr) return Boolean is
2814 begin
2815 return F1.all = F2.all;
2816 end SEq;
2818 -----------
2819 -- SHash --
2820 -----------
2822 function SHash (S : String_Ptr) return Vindex is
2823 H : Word;
2825 begin
2826 H := 0;
2827 for J in S.all'Range loop
2828 H := H * 2 + Character'Pos (S (J));
2829 end loop;
2831 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));
2832 end SHash;
2834 end ALI;