2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / gcc / ada / ali.adb
blob83bf2b99065e47734d54ac745c0c40c2cfa46b04
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2015, 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 GNATprove_Mode_Specified := False;
115 Normalize_Scalars_Specified := False;
116 Partition_Elaboration_Policy_Specified := ' ';
117 Queuing_Policy_Specified := ' ';
118 SSO_Default_Specified := False;
119 Static_Elaboration_Model_Used := False;
120 Task_Dispatching_Policy_Specified := ' ';
121 Unreserve_All_Interrupts_Specified := False;
122 Zero_Cost_Exceptions_Specified := False;
123 end Initialize_ALI;
125 --------------
126 -- Scan_ALI --
127 --------------
129 function Scan_ALI
130 (F : File_Name_Type;
131 T : Text_Buffer_Ptr;
132 Ignore_ED : Boolean;
133 Err : Boolean;
134 Read_Xref : Boolean := False;
135 Read_Lines : String := "";
136 Ignore_Lines : String := "X";
137 Ignore_Errors : Boolean := False;
138 Directly_Scanned : Boolean := False) return ALI_Id
140 P : Text_Ptr := T'First;
141 Line : Logical_Line_Number := 1;
142 Id : ALI_Id;
143 C : Character;
144 NS_Found : Boolean;
145 First_Arg : Arg_Id;
147 Ignore : array (Character range 'A' .. 'Z') of Boolean;
148 -- Ignore (X) is set to True if lines starting with X are to
149 -- be ignored by Scan_ALI and skipped, and False if the lines
150 -- are to be read and processed.
152 Bad_ALI_Format : exception;
153 -- Exception raised by Fatal_Error if Err is True
155 function At_Eol return Boolean;
156 -- Test if at end of line
158 function At_End_Of_Field return Boolean;
159 -- Test if at end of line, or if at blank or horizontal tab
161 procedure Check_At_End_Of_Field;
162 -- Check if we are at end of field, fatal error if not
164 procedure Checkc (C : Character);
165 -- Check next character is C. If so bump past it, if not fatal error
167 procedure Check_Unknown_Line;
168 -- If Ignore_Errors mode, then checks C to make sure that it is not
169 -- an unknown ALI line type characters, and if so, skips lines
170 -- until the first character of the line is one of these characters,
171 -- at which point it does a Getc to put that character in C. The
172 -- call has no effect if C is already an appropriate character.
173 -- If not in Ignore_Errors mode, a fatal error is signalled if the
174 -- line is unknown. Note that if C is an EOL on entry, the line is
175 -- skipped (it is assumed that blank lines are never significant).
176 -- If C is EOF on entry, the call has no effect (it is assumed that
177 -- the caller will properly handle this case).
179 procedure Fatal_Error;
180 -- Generate fatal error message for badly formatted ALI file if
181 -- Err is false, or raise Bad_ALI_Format if Err is True.
183 procedure Fatal_Error_Ignore;
184 pragma Inline (Fatal_Error_Ignore);
185 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
187 function Getc return Character;
188 -- Get next character, bumping P past the character obtained
190 function Get_File_Name
191 (Lower : Boolean := False;
192 May_Be_Quoted : Boolean := False) return File_Name_Type;
193 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
194 -- with length in Name_Len, as well as returning a File_Name_Type value.
195 -- If May_Be_Quoted is True and the first non blank character is '"',
196 -- then remove starting and ending quotes and undoubled internal quotes.
197 -- If lower is false, the case is unchanged, if Lower is True then the
198 -- result is forced to all lower case for systems where file names are
199 -- not case sensitive. This ensures that gnatbind works correctly
200 -- regardless of the case of the file name on all systems. The scan
201 -- is terminated by a end of line, space or horizontal tab. Any other
202 -- special characters are included in the returned name.
204 function Get_Name
205 (Ignore_Spaces : Boolean := False;
206 Ignore_Special : Boolean := False;
207 May_Be_Quoted : Boolean := False) return Name_Id;
208 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
209 -- length in Name_Len, as well as being returned in Name_Id form).
210 -- If Lower is set to True then the Name_Buffer will be converted to
211 -- all lower case, for systems where file names are not case sensitive.
212 -- This ensures that gnatbind works correctly regardless of the case
213 -- of the file name on all systems. The termination condition depends
214 -- on the settings of Ignore_Spaces and Ignore_Special:
216 -- If Ignore_Spaces is False (normal case), then scan is terminated
217 -- by the normal end of field condition (EOL, space, horizontal tab)
219 -- If Ignore_Special is False (normal case), the scan is terminated by
220 -- a typeref bracket or an equal sign except for the special case of
221 -- an operator name starting with a double quote which is terminated
222 -- by another double quote.
224 -- If May_Be_Quoted is True and the first non blank character is '"'
225 -- the name is 'unquoted'. In this case Ignore_Special is ignored and
226 -- assumed to be True.
228 -- It is an error to set both Ignore_Spaces and Ignore_Special to True.
229 -- This function handles wide characters properly.
231 function Get_Nat return Nat;
232 -- Skip blanks, then scan out an unsigned integer value in Nat range
233 -- raises ALI_Reading_Error if the encoutered type is not natural.
235 function Get_Stamp return Time_Stamp_Type;
236 -- Skip blanks, then scan out a time stamp
238 function Get_Unit_Name return Unit_Name_Type;
239 -- Skip blanks, then scan out a file name (name is left in Name_Buffer
240 -- with length in Name_Len, as well as returning a Unit_Name_Type value.
241 -- The case is unchanged and terminated by a normal end of field.
243 function Nextc return Character;
244 -- Return current character without modifying pointer P
246 procedure Get_Typeref
247 (Current_File_Num : Sdep_Id;
248 Ref : out Tref_Kind;
249 File_Num : out Sdep_Id;
250 Line : out Nat;
251 Ref_Type : out Character;
252 Col : out Nat;
253 Standard_Entity : out Name_Id);
254 -- Parse the definition of a typeref (<...>, {...} or (...))
256 procedure Skip_Eol;
257 -- Skip past spaces, then skip past end of line (fatal error if not
258 -- at end of line). Also skips past any following blank lines.
260 procedure Skip_Line;
261 -- Skip rest of current line and any following blank lines
263 procedure Skip_Space;
264 -- Skip past white space (blanks or horizontal tab)
266 procedure Skipc;
267 -- Skip past next character, does not affect value in C. This call
268 -- is like calling Getc and ignoring the returned result.
270 ---------------------
271 -- At_End_Of_Field --
272 ---------------------
274 function At_End_Of_Field return Boolean is
275 begin
276 return Nextc <= ' ';
277 end At_End_Of_Field;
279 ------------
280 -- At_Eol --
281 ------------
283 function At_Eol return Boolean is
284 begin
285 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
286 end At_Eol;
288 ---------------------------
289 -- Check_At_End_Of_Field --
290 ---------------------------
292 procedure Check_At_End_Of_Field is
293 begin
294 if not At_End_Of_Field then
295 if Ignore_Errors then
296 while Nextc > ' ' loop
297 P := P + 1;
298 end loop;
299 else
300 Fatal_Error;
301 end if;
302 end if;
303 end Check_At_End_Of_Field;
305 ------------------------
306 -- Check_Unknown_Line --
307 ------------------------
309 procedure Check_Unknown_Line is
310 begin
311 while C not in 'A' .. 'Z'
312 or else not Known_ALI_Lines (C)
313 loop
314 if C = CR or else C = LF then
315 Skip_Line;
316 C := Nextc;
318 elsif C = EOF then
319 return;
321 elsif Ignore_Errors then
322 Skip_Line;
323 C := Getc;
325 else
326 Fatal_Error;
327 end if;
328 end loop;
329 end Check_Unknown_Line;
331 ------------
332 -- Checkc --
333 ------------
335 procedure Checkc (C : Character) is
336 begin
337 if Nextc = C then
338 P := P + 1;
339 elsif Ignore_Errors then
340 P := P + 1;
341 else
342 Fatal_Error;
343 end if;
344 end Checkc;
346 -----------------
347 -- Fatal_Error --
348 -----------------
350 procedure Fatal_Error is
351 Ptr1 : Text_Ptr;
352 Ptr2 : Text_Ptr;
353 Col : Int;
355 procedure Wchar (C : Character);
356 -- Write a single character, replacing horizontal tab by spaces
358 procedure Wchar (C : Character) is
359 begin
360 if C = HT then
361 loop
362 Wchar (' ');
363 exit when Col mod 8 = 0;
364 end loop;
366 else
367 Write_Char (C);
368 Col := Col + 1;
369 end if;
370 end Wchar;
372 -- Start of processing for Fatal_Error
374 begin
375 if Err then
376 raise Bad_ALI_Format;
377 end if;
379 Set_Standard_Error;
380 Write_Str ("fatal error: file ");
381 Write_Name (F);
382 Write_Str (" is incorrectly formatted");
383 Write_Eol;
385 Write_Str ("make sure you are using consistent versions " &
387 -- Split the following line so that it can easily be transformed for
388 -- e.g. JVM/.NET back-ends where the compiler has a different name.
390 "of gcc/gnatbind");
392 Write_Eol;
394 -- Find start of line
396 Ptr1 := P;
397 while Ptr1 > T'First
398 and then T (Ptr1 - 1) /= CR
399 and then T (Ptr1 - 1) /= LF
400 loop
401 Ptr1 := Ptr1 - 1;
402 end loop;
404 Write_Int (Int (Line));
405 Write_Str (". ");
407 if Line < 100 then
408 Write_Char (' ');
409 end if;
411 if Line < 10 then
412 Write_Char (' ');
413 end if;
415 Col := 0;
416 Ptr2 := Ptr1;
418 while Ptr2 < T'Last
419 and then T (Ptr2) /= CR
420 and then T (Ptr2) /= LF
421 loop
422 Wchar (T (Ptr2));
423 Ptr2 := Ptr2 + 1;
424 end loop;
426 Write_Eol;
428 Write_Str (" ");
429 Col := 0;
431 while Ptr1 < P loop
432 if T (Ptr1) = HT then
433 Wchar (HT);
434 else
435 Wchar (' ');
436 end if;
438 Ptr1 := Ptr1 + 1;
439 end loop;
441 Wchar ('|');
442 Write_Eol;
444 Exit_Program (E_Fatal);
445 end Fatal_Error;
447 ------------------------
448 -- Fatal_Error_Ignore --
449 ------------------------
451 procedure Fatal_Error_Ignore is
452 begin
453 if not Ignore_Errors then
454 Fatal_Error;
455 end if;
456 end Fatal_Error_Ignore;
458 -------------------
459 -- Get_File_Name --
460 -------------------
462 function Get_File_Name
463 (Lower : Boolean := False;
464 May_Be_Quoted : Boolean := False) return File_Name_Type
466 F : Name_Id;
468 begin
469 F := Get_Name (Ignore_Special => True,
470 May_Be_Quoted => May_Be_Quoted);
472 -- Convert file name to all lower case if file names are not case
473 -- sensitive. This ensures that we handle names in the canonical
474 -- lower case format, regardless of the actual case.
476 if Lower and not File_Names_Case_Sensitive then
477 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
478 return Name_Find;
479 else
480 return File_Name_Type (F);
481 end if;
482 end Get_File_Name;
484 --------------
485 -- Get_Name --
486 --------------
488 function Get_Name
489 (Ignore_Spaces : Boolean := False;
490 Ignore_Special : Boolean := False;
491 May_Be_Quoted : Boolean := False) return Name_Id
493 Char : Character;
495 begin
496 Name_Len := 0;
497 Skip_Space;
499 if At_Eol then
500 if Ignore_Errors then
501 return Error_Name;
502 else
503 Fatal_Error;
504 end if;
505 end if;
507 Char := Getc;
509 -- Deal with quoted characters
511 if May_Be_Quoted and then Char = '"' then
512 loop
513 if At_Eol then
514 if Ignore_Errors then
515 return Error_Name;
516 else
517 Fatal_Error;
518 end if;
519 end if;
521 Char := Getc;
523 if Char = '"' then
524 if At_Eol then
525 exit;
527 else
528 Char := Getc;
530 if Char /= '"' then
531 P := P - 1;
532 exit;
533 end if;
534 end if;
535 end if;
537 Add_Char_To_Name_Buffer (Char);
538 end loop;
540 -- Other than case of quoted character
542 else
543 P := P - 1;
544 loop
545 Add_Char_To_Name_Buffer (Getc);
547 exit when At_End_Of_Field and then not Ignore_Spaces;
549 if not Ignore_Special then
550 if Name_Buffer (1) = '"' then
551 exit when Name_Len > 1
552 and then Name_Buffer (Name_Len) = '"';
554 else
555 -- Terminate on parens or angle brackets or equal sign
557 exit when Nextc = '(' or else Nextc = ')'
558 or else Nextc = '{' or else Nextc = '}'
559 or else Nextc = '<' or else Nextc = '>'
560 or else Nextc = '=';
562 -- Terminate on comma
564 exit when Nextc = ',';
566 -- Terminate if left bracket not part of wide char
567 -- sequence Note that we only recognize brackets
568 -- notation so far ???
570 exit when Nextc = '[' and then T (P + 1) /= '"';
572 -- Terminate if right bracket not part of wide char
573 -- sequence.
575 exit when Nextc = ']' and then T (P - 1) /= '"';
576 end if;
577 end if;
578 end loop;
579 end if;
581 return Name_Find;
582 end Get_Name;
584 -------------------
585 -- Get_Unit_Name --
586 -------------------
588 function Get_Unit_Name return Unit_Name_Type is
589 begin
590 return Unit_Name_Type (Get_Name);
591 end Get_Unit_Name;
593 -------------
594 -- Get_Nat --
595 -------------
597 function Get_Nat return Nat is
598 V : Nat;
600 begin
601 Skip_Space;
603 -- Check if we are on a number. In the case of bad ALI files, this
604 -- may not be true.
606 if not (Nextc in '0' .. '9') then
607 Fatal_Error;
608 end if;
610 V := 0;
611 loop
612 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
614 exit when At_End_Of_Field;
615 exit when Nextc < '0' or else Nextc > '9';
616 end loop;
618 return V;
619 end Get_Nat;
621 ---------------
622 -- Get_Stamp --
623 ---------------
625 function Get_Stamp return Time_Stamp_Type is
626 T : Time_Stamp_Type;
627 Start : Integer;
629 begin
630 Skip_Space;
632 if At_Eol then
633 if Ignore_Errors then
634 return Dummy_Time_Stamp;
635 else
636 Fatal_Error;
637 end if;
638 end if;
640 -- Following reads old style time stamp missing first two digits
642 if Nextc in '7' .. '9' then
643 T (1) := '1';
644 T (2) := '9';
645 Start := 3;
647 -- Normal case of full year in time stamp
649 else
650 Start := 1;
651 end if;
653 for J in Start .. T'Last loop
654 T (J) := Getc;
655 end loop;
657 return T;
658 end Get_Stamp;
660 -----------------
661 -- Get_Typeref --
662 -----------------
664 procedure Get_Typeref
665 (Current_File_Num : Sdep_Id;
666 Ref : out Tref_Kind;
667 File_Num : out Sdep_Id;
668 Line : out Nat;
669 Ref_Type : out Character;
670 Col : out Nat;
671 Standard_Entity : out Name_Id)
673 N : Nat;
674 begin
675 case Nextc is
676 when '<' => Ref := Tref_Derived;
677 when '(' => Ref := Tref_Access;
678 when '{' => Ref := Tref_Type;
679 when others => Ref := Tref_None;
680 end case;
682 -- Case of typeref field present
684 if Ref /= Tref_None then
685 P := P + 1; -- skip opening bracket
687 if Nextc in 'a' .. 'z' then
688 File_Num := No_Sdep_Id;
689 Line := 0;
690 Ref_Type := ' ';
691 Col := 0;
692 Standard_Entity := Get_Name (Ignore_Spaces => True);
693 else
694 N := Get_Nat;
696 if Nextc = '|' then
697 File_Num := Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
698 P := P + 1;
699 N := Get_Nat;
700 else
701 File_Num := Current_File_Num;
702 end if;
704 Line := N;
705 Ref_Type := Getc;
706 Col := Get_Nat;
707 Standard_Entity := No_Name;
708 end if;
710 -- ??? Temporary workaround for nested generics case:
711 -- 4i4 Directories{1|4I9[4|6[3|3]]}
712 -- See C918-002
714 declare
715 Nested_Brackets : Natural := 0;
717 begin
718 loop
719 case Nextc is
720 when '[' =>
721 Nested_Brackets := Nested_Brackets + 1;
722 when ']' =>
723 Nested_Brackets := Nested_Brackets - 1;
724 when others =>
725 if Nested_Brackets = 0 then
726 exit;
727 end if;
728 end case;
730 Skipc;
731 end loop;
732 end;
734 P := P + 1; -- skip closing bracket
735 Skip_Space;
737 -- No typeref entry present
739 else
740 File_Num := No_Sdep_Id;
741 Line := 0;
742 Ref_Type := ' ';
743 Col := 0;
744 Standard_Entity := No_Name;
745 end if;
746 end Get_Typeref;
748 ----------
749 -- Getc --
750 ----------
752 function Getc return Character is
753 begin
754 if P = T'Last then
755 return EOF;
756 else
757 P := P + 1;
758 return T (P - 1);
759 end if;
760 end Getc;
762 -----------
763 -- Nextc --
764 -----------
766 function Nextc return Character is
767 begin
768 return T (P);
769 end Nextc;
771 --------------
772 -- Skip_Eol --
773 --------------
775 procedure Skip_Eol is
776 begin
777 Skip_Space;
779 if not At_Eol then
780 if Ignore_Errors then
781 while not At_Eol loop
782 P := P + 1;
783 end loop;
784 else
785 Fatal_Error;
786 end if;
787 end if;
789 -- Loop to skip past blank lines (first time through skips this EOL)
791 while Nextc < ' ' and then Nextc /= EOF loop
792 if Nextc = LF then
793 Line := Line + 1;
794 end if;
796 P := P + 1;
797 end loop;
798 end Skip_Eol;
800 ---------------
801 -- Skip_Line --
802 ---------------
804 procedure Skip_Line is
805 begin
806 while not At_Eol loop
807 P := P + 1;
808 end loop;
810 Skip_Eol;
811 end Skip_Line;
813 ----------------
814 -- Skip_Space --
815 ----------------
817 procedure Skip_Space is
818 begin
819 while Nextc = ' ' or else Nextc = HT loop
820 P := P + 1;
821 end loop;
822 end Skip_Space;
824 -----------
825 -- Skipc --
826 -----------
828 procedure Skipc is
829 begin
830 if P /= T'Last then
831 P := P + 1;
832 end if;
833 end Skipc;
835 -- Start of processing for Scan_ALI
837 begin
838 First_Sdep_Entry := Sdep.Last + 1;
840 -- Acquire lines to be ignored
842 if Read_Xref then
843 Ignore :=
844 ('U' | 'W' | 'Y' | 'Z' | 'D' | 'X' => False, others => True);
846 -- Read_Lines parameter given
848 elsif Read_Lines /= "" then
849 Ignore := ('U' => False, others => True);
851 for J in Read_Lines'Range loop
852 Ignore (Read_Lines (J)) := False;
853 end loop;
855 -- Process Ignore_Lines parameter
857 else
858 Ignore := (others => False);
860 for J in Ignore_Lines'Range loop
861 pragma Assert (Ignore_Lines (J) /= 'U');
862 Ignore (Ignore_Lines (J)) := True;
863 end loop;
864 end if;
866 -- Setup ALI Table entry with appropriate defaults
868 ALIs.Increment_Last;
869 Id := ALIs.Last;
870 Set_Name_Table_Int (F, Int (Id));
872 ALIs.Table (Id) := (
873 Afile => F,
874 Compile_Errors => False,
875 First_Interrupt_State => Interrupt_States.Last + 1,
876 First_Sdep => No_Sdep_Id,
877 First_Specific_Dispatching => Specific_Dispatching.Last + 1,
878 First_Unit => No_Unit_Id,
879 GNATprove_Mode => False,
880 Last_Interrupt_State => Interrupt_States.Last,
881 Last_Sdep => No_Sdep_Id,
882 Last_Specific_Dispatching => Specific_Dispatching.Last,
883 Last_Unit => No_Unit_Id,
884 Locking_Policy => ' ',
885 Main_Priority => -1,
886 Main_CPU => -1,
887 Main_Program => None,
888 No_Object => False,
889 Normalize_Scalars => False,
890 Ofile_Full_Name => Full_Object_File_Name,
891 Partition_Elaboration_Policy => ' ',
892 Queuing_Policy => ' ',
893 Restrictions => No_Restrictions,
894 SAL_Interface => False,
895 Sfile => No_File,
896 SSO_Default => ' ',
897 Task_Dispatching_Policy => ' ',
898 Time_Slice_Value => -1,
899 WC_Encoding => 'b',
900 Unit_Exception_Table => False,
901 Ver => (others => ' '),
902 Ver_Len => 0,
903 Zero_Cost_Exceptions => False);
905 -- Now we acquire the input lines from the ALI file. Note that the
906 -- convention in the following code is that as we enter each section,
907 -- C is set to contain the first character of the following line.
909 C := Getc;
910 Check_Unknown_Line;
912 -- Acquire library version
914 if C /= 'V' then
916 -- The V line missing really indicates trouble, most likely it
917 -- means we don't have an ALI file at all, so here we give a
918 -- fatal error even if we are in Ignore_Errors mode.
920 Fatal_Error;
922 elsif Ignore ('V') then
923 Skip_Line;
925 else
926 Checkc (' ');
927 Skip_Space;
928 Checkc ('"');
930 for J in 1 .. Ver_Len_Max loop
931 C := Getc;
932 exit when C = '"';
933 ALIs.Table (Id).Ver (J) := C;
934 ALIs.Table (Id).Ver_Len := J;
935 end loop;
937 Skip_Eol;
938 end if;
940 C := Getc;
941 Check_Unknown_Line;
943 -- Acquire main program line if present
945 if C = 'M' then
946 if Ignore ('M') then
947 Skip_Line;
949 else
950 Checkc (' ');
951 Skip_Space;
953 C := Getc;
955 if C = 'F' then
956 ALIs.Table (Id).Main_Program := Func;
957 elsif C = 'P' then
958 ALIs.Table (Id).Main_Program := Proc;
959 else
960 P := P - 1;
961 Fatal_Error;
962 end if;
964 Skip_Space;
966 if not At_Eol then
967 if Nextc < 'A' then
968 ALIs.Table (Id).Main_Priority := Get_Nat;
969 end if;
971 Skip_Space;
973 if Nextc = 'T' then
974 P := P + 1;
975 Checkc ('=');
976 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
977 end if;
979 Skip_Space;
981 if Nextc = 'C' then
982 P := P + 1;
983 Checkc ('=');
984 ALIs.Table (Id).Main_CPU := Get_Nat;
985 end if;
987 Skip_Space;
989 Checkc ('W');
990 Checkc ('=');
991 ALIs.Table (Id).WC_Encoding := Getc;
992 end if;
994 Skip_Eol;
995 end if;
997 C := Getc;
998 end if;
1000 -- Acquire argument lines
1002 First_Arg := Args.Last + 1;
1004 A_Loop : loop
1005 Check_Unknown_Line;
1006 exit A_Loop when C /= 'A';
1008 if Ignore ('A') then
1009 Skip_Line;
1011 else
1012 Checkc (' ');
1014 -- Scan out argument
1016 Name_Len := 0;
1017 while not At_Eol loop
1018 Add_Char_To_Name_Buffer (Getc);
1019 end loop;
1021 -- If -fstack-check, record that it occurred. Note that an
1022 -- additional string parameter can be specified, in the form of
1023 -- -fstack-check={no|generic|specific}. "no" means no checking,
1024 -- "generic" means force the use of old-style checking, and
1025 -- "specific" means use the best checking method.
1027 if Name_Len >= 13
1028 and then Name_Buffer (1 .. 13) = "-fstack-check"
1029 and then Name_Buffer (1 .. Name_Len) /= "-fstack-check=no"
1030 then
1031 Stack_Check_Switch_Set := True;
1032 end if;
1034 -- Store the argument
1036 Args.Increment_Last;
1037 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
1039 Skip_Eol;
1040 end if;
1042 C := Getc;
1043 end loop A_Loop;
1045 -- Acquire P line
1047 Check_Unknown_Line;
1049 while C /= 'P' loop
1050 if Ignore_Errors then
1051 if C = EOF then
1052 Fatal_Error;
1053 else
1054 Skip_Line;
1055 C := Nextc;
1056 end if;
1057 else
1058 Fatal_Error;
1059 end if;
1060 end loop;
1062 if Ignore ('P') then
1063 Skip_Line;
1065 -- Process P line
1067 else
1068 NS_Found := False;
1070 while not At_Eol loop
1071 Checkc (' ');
1072 Skip_Space;
1073 C := Getc;
1075 -- Processing for CE
1077 if C = 'C' then
1078 Checkc ('E');
1079 ALIs.Table (Id).Compile_Errors := True;
1081 -- Processing for DB
1083 elsif C = 'D' then
1084 Checkc ('B');
1085 Detect_Blocking := True;
1087 -- Processing for Ex
1089 elsif C = 'E' then
1090 Partition_Elaboration_Policy_Specified := Getc;
1091 ALIs.Table (Id).Partition_Elaboration_Policy :=
1092 Partition_Elaboration_Policy_Specified;
1094 -- Processing for GP
1096 elsif C = 'G' then
1097 Checkc ('P');
1098 GNATprove_Mode_Specified := True;
1099 ALIs.Table (Id).GNATprove_Mode := True;
1101 -- Processing for Lx
1103 elsif C = 'L' then
1104 Locking_Policy_Specified := Getc;
1105 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
1107 -- Processing for flags starting with N
1109 elsif C = 'N' then
1110 C := Getc;
1112 -- Processing for NO
1114 if C = 'O' then
1115 ALIs.Table (Id).No_Object := True;
1116 No_Object_Specified := True;
1118 -- Processing for NR
1120 elsif C = 'R' then
1121 No_Run_Time_Mode := True;
1122 Configurable_Run_Time_Mode := True;
1124 -- Processing for NS
1126 elsif C = 'S' then
1127 ALIs.Table (Id).Normalize_Scalars := True;
1128 Normalize_Scalars_Specified := True;
1129 NS_Found := True;
1131 -- Invalid switch starting with N
1133 else
1134 Fatal_Error_Ignore;
1135 end if;
1137 -- Processing for OH/OL
1139 elsif C = 'O' then
1140 C := Getc;
1142 if C = 'L' or else C = 'H' then
1143 ALIs.Table (Id).SSO_Default := C;
1144 SSO_Default_Specified := True;
1146 else
1147 Fatal_Error_Ignore;
1148 end if;
1150 -- Processing for Qx
1152 elsif C = 'Q' then
1153 Queuing_Policy_Specified := Getc;
1154 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
1156 -- Processing for flags starting with S
1158 elsif C = 'S' then
1159 C := Getc;
1161 -- Processing for SL
1163 if C = 'L' then
1164 ALIs.Table (Id).SAL_Interface := True;
1166 -- Processing for SS
1168 elsif C = 'S' then
1169 Opt.Sec_Stack_Used := True;
1171 -- Invalid switch starting with S
1173 else
1174 Fatal_Error_Ignore;
1175 end if;
1177 -- Processing for Tx
1179 elsif C = 'T' then
1180 Task_Dispatching_Policy_Specified := Getc;
1181 ALIs.Table (Id).Task_Dispatching_Policy :=
1182 Task_Dispatching_Policy_Specified;
1184 -- Processing for switch starting with U
1186 elsif C = 'U' then
1187 C := Getc;
1189 -- Processing for UA
1191 if C = 'A' then
1192 Unreserve_All_Interrupts_Specified := True;
1194 -- Processing for UX
1196 elsif C = 'X' then
1197 ALIs.Table (Id).Unit_Exception_Table := True;
1199 -- Invalid switches starting with U
1201 else
1202 Fatal_Error_Ignore;
1203 end if;
1205 -- Processing for ZX
1207 elsif C = 'Z' then
1208 C := Getc;
1210 if C = 'X' then
1211 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1212 Zero_Cost_Exceptions_Specified := True;
1213 else
1214 Fatal_Error_Ignore;
1215 end if;
1217 -- Invalid parameter
1219 else
1220 C := Getc;
1221 Fatal_Error_Ignore;
1222 end if;
1223 end loop;
1225 if not NS_Found then
1226 No_Normalize_Scalars_Specified := True;
1227 end if;
1229 Skip_Eol;
1230 end if;
1232 C := Getc;
1233 Check_Unknown_Line;
1235 -- Loop to skip to first restrictions line
1237 while C /= 'R' loop
1238 if Ignore_Errors then
1239 if C = EOF then
1240 Fatal_Error;
1241 else
1242 Skip_Line;
1243 C := Nextc;
1244 end if;
1245 else
1246 Fatal_Error;
1247 end if;
1248 end loop;
1250 -- Ignore all 'R' lines if that is required
1252 if Ignore ('R') then
1253 while C = 'R' loop
1254 Skip_Line;
1255 C := Getc;
1256 end loop;
1258 -- Here we process the restrictions lines (other than unit name cases)
1260 else
1261 Scan_Restrictions : declare
1262 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1263 -- Save cumulative restrictions in case we have a fatal error
1265 Bad_R_Line : exception;
1266 -- Signal bad restrictions line (raised on unexpected character)
1268 Typ : Character;
1269 R : Restriction_Id;
1270 N : Natural;
1272 begin
1273 -- Named restriction case
1275 if Nextc = 'N' then
1276 Skip_Line;
1277 C := Getc;
1279 -- Loop through RR and RV lines
1281 while C = 'R' and then Nextc /= ' ' loop
1282 Typ := Getc;
1283 Checkc (' ');
1285 -- Acquire restriction name
1287 Name_Len := 0;
1288 while not At_Eol and then Nextc /= '=' loop
1289 Name_Len := Name_Len + 1;
1290 Name_Buffer (Name_Len) := Getc;
1291 end loop;
1293 -- Now search list of restrictions to find match
1295 declare
1296 RN : String renames Name_Buffer (1 .. Name_Len);
1298 begin
1299 R := Restriction_Id'First;
1300 while R /= Not_A_Restriction_Id loop
1301 if Restriction_Id'Image (R) = RN then
1302 goto R_Found;
1303 end if;
1305 R := Restriction_Id'Succ (R);
1306 end loop;
1308 -- We don't recognize the restriction. This might be
1309 -- thought of as an error, and it really is, but we
1310 -- want to allow building with inconsistent versions
1311 -- of the binder and ali files (see comments at the
1312 -- start of package System.Rident), so we just ignore
1313 -- this situation.
1315 goto Done_With_Restriction_Line;
1316 end;
1318 <<R_Found>>
1320 case R is
1322 -- Boolean restriction case
1324 when All_Boolean_Restrictions =>
1325 case Typ is
1326 when 'V' =>
1327 ALIs.Table (Id).Restrictions.Violated (R) :=
1328 True;
1329 Cumulative_Restrictions.Violated (R) := True;
1331 when 'R' =>
1332 ALIs.Table (Id).Restrictions.Set (R) := True;
1333 Cumulative_Restrictions.Set (R) := True;
1335 when others =>
1336 raise Bad_R_Line;
1337 end case;
1339 -- Parameter restriction case
1341 when All_Parameter_Restrictions =>
1342 if At_Eol or else Nextc /= '=' then
1343 raise Bad_R_Line;
1344 else
1345 Skipc;
1346 end if;
1348 N := Natural (Get_Nat);
1350 case Typ is
1352 -- Restriction set
1354 when 'R' =>
1355 ALIs.Table (Id).Restrictions.Set (R) := True;
1356 ALIs.Table (Id).Restrictions.Value (R) := N;
1358 if Cumulative_Restrictions.Set (R) then
1359 Cumulative_Restrictions.Value (R) :=
1360 Integer'Min
1361 (Cumulative_Restrictions.Value (R), N);
1362 else
1363 Cumulative_Restrictions.Set (R) := True;
1364 Cumulative_Restrictions.Value (R) := N;
1365 end if;
1367 -- Restriction violated
1369 when 'V' =>
1370 ALIs.Table (Id).Restrictions.Violated (R) :=
1371 True;
1372 Cumulative_Restrictions.Violated (R) := True;
1373 ALIs.Table (Id).Restrictions.Count (R) := N;
1375 -- Checked Max_Parameter case
1377 if R in Checked_Max_Parameter_Restrictions then
1378 Cumulative_Restrictions.Count (R) :=
1379 Integer'Max
1380 (Cumulative_Restrictions.Count (R), N);
1382 -- Other checked parameter cases
1384 else
1385 declare
1386 pragma Unsuppress (Overflow_Check);
1388 begin
1389 Cumulative_Restrictions.Count (R) :=
1390 Cumulative_Restrictions.Count (R) + N;
1392 exception
1393 when Constraint_Error =>
1395 -- A constraint error comes from the
1396 -- addition. We reset to the maximum
1397 -- and indicate that the real value
1398 -- is now unknown.
1400 Cumulative_Restrictions.Value (R) :=
1401 Integer'Last;
1402 Cumulative_Restrictions.Unknown (R) :=
1403 True;
1404 end;
1405 end if;
1407 -- Deal with + case
1409 if Nextc = '+' then
1410 Skipc;
1411 ALIs.Table (Id).Restrictions.Unknown (R) :=
1412 True;
1413 Cumulative_Restrictions.Unknown (R) := True;
1414 end if;
1416 -- Other than 'R' or 'V'
1418 when others =>
1419 raise Bad_R_Line;
1420 end case;
1422 if not At_Eol then
1423 raise Bad_R_Line;
1424 end if;
1426 -- Bizarre error case NOT_A_RESTRICTION
1428 when Not_A_Restriction_Id =>
1429 raise Bad_R_Line;
1430 end case;
1432 if not At_Eol then
1433 raise Bad_R_Line;
1434 end if;
1436 <<Done_With_Restriction_Line>>
1437 Skip_Line;
1438 C := Getc;
1439 end loop;
1441 -- Positional restriction case
1443 else
1444 Checkc (' ');
1445 Skip_Space;
1447 -- Acquire information for boolean restrictions
1449 for R in All_Boolean_Restrictions loop
1450 C := Getc;
1452 case C is
1453 when 'v' =>
1454 ALIs.Table (Id).Restrictions.Violated (R) := True;
1455 Cumulative_Restrictions.Violated (R) := True;
1457 when 'r' =>
1458 ALIs.Table (Id).Restrictions.Set (R) := True;
1459 Cumulative_Restrictions.Set (R) := True;
1461 when 'n' =>
1462 null;
1464 when others =>
1465 raise Bad_R_Line;
1466 end case;
1467 end loop;
1469 -- Acquire information for parameter restrictions
1471 for RP in All_Parameter_Restrictions loop
1472 case Getc is
1473 when 'n' =>
1474 null;
1476 when 'r' =>
1477 ALIs.Table (Id).Restrictions.Set (RP) := True;
1479 declare
1480 N : constant Integer := Integer (Get_Nat);
1481 begin
1482 ALIs.Table (Id).Restrictions.Value (RP) := N;
1484 if Cumulative_Restrictions.Set (RP) then
1485 Cumulative_Restrictions.Value (RP) :=
1486 Integer'Min
1487 (Cumulative_Restrictions.Value (RP), N);
1488 else
1489 Cumulative_Restrictions.Set (RP) := True;
1490 Cumulative_Restrictions.Value (RP) := N;
1491 end if;
1492 end;
1494 when others =>
1495 raise Bad_R_Line;
1496 end case;
1498 -- Acquire restrictions violations information
1500 case Getc is
1502 when 'n' =>
1503 null;
1505 when 'v' =>
1506 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1507 Cumulative_Restrictions.Violated (RP) := True;
1509 declare
1510 N : constant Integer := Integer (Get_Nat);
1512 begin
1513 ALIs.Table (Id).Restrictions.Count (RP) := N;
1515 if RP in Checked_Max_Parameter_Restrictions then
1516 Cumulative_Restrictions.Count (RP) :=
1517 Integer'Max
1518 (Cumulative_Restrictions.Count (RP), N);
1520 else
1521 declare
1522 pragma Unsuppress (Overflow_Check);
1524 begin
1525 Cumulative_Restrictions.Count (RP) :=
1526 Cumulative_Restrictions.Count (RP) + N;
1528 exception
1529 when Constraint_Error =>
1531 -- A constraint error comes from the add. We
1532 -- reset to the maximum and indicate that the
1533 -- real value is now unknown.
1535 Cumulative_Restrictions.Value (RP) :=
1536 Integer'Last;
1537 Cumulative_Restrictions.Unknown (RP) := True;
1538 end;
1539 end if;
1541 if Nextc = '+' then
1542 Skipc;
1543 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1544 Cumulative_Restrictions.Unknown (RP) := True;
1545 end if;
1546 end;
1548 when others =>
1549 raise Bad_R_Line;
1550 end case;
1551 end loop;
1553 if not At_Eol then
1554 raise Bad_R_Line;
1555 else
1556 Skip_Line;
1557 C := Getc;
1558 end if;
1559 end if;
1561 -- Here if error during scanning of restrictions line
1563 exception
1564 when Bad_R_Line =>
1566 -- In Ignore_Errors mode, undo any changes to restrictions
1567 -- from this unit, and continue on, skipping remaining R
1568 -- lines for this unit.
1570 if Ignore_Errors then
1571 Cumulative_Restrictions := Save_R;
1572 ALIs.Table (Id).Restrictions := No_Restrictions;
1574 loop
1575 Skip_Eol;
1576 C := Getc;
1577 exit when C /= 'R';
1578 end loop;
1580 -- In normal mode, this is a fatal error
1582 else
1583 Fatal_Error;
1584 end if;
1585 end Scan_Restrictions;
1586 end if;
1588 -- Acquire additional restrictions (No_Dependence) lines if present
1590 while C = 'R' loop
1591 if Ignore ('R') then
1592 Skip_Line;
1593 else
1594 Skip_Space;
1595 No_Deps.Append ((Id, Get_Name));
1596 Skip_Eol;
1597 end if;
1599 C := Getc;
1600 end loop;
1602 -- Acquire 'I' lines if present
1604 Check_Unknown_Line;
1606 while C = 'I' loop
1607 if Ignore ('I') then
1608 Skip_Line;
1610 else
1611 declare
1612 Int_Num : Nat;
1613 I_State : Character;
1614 Line_No : Nat;
1616 begin
1617 Int_Num := Get_Nat;
1618 Skip_Space;
1619 I_State := Getc;
1620 Line_No := Get_Nat;
1622 Interrupt_States.Append (
1623 (Interrupt_Id => Int_Num,
1624 Interrupt_State => I_State,
1625 IS_Pragma_Line => Line_No));
1627 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1628 Skip_Eol;
1629 end;
1630 end if;
1632 C := Getc;
1633 end loop;
1635 -- Acquire 'S' lines if present
1637 Check_Unknown_Line;
1639 while C = 'S' loop
1640 if Ignore ('S') then
1641 Skip_Line;
1643 else
1644 declare
1645 Policy : Character;
1646 First_Prio : Nat;
1647 Last_Prio : Nat;
1648 Line_No : Nat;
1650 begin
1651 Checkc (' ');
1652 Skip_Space;
1654 Policy := Getc;
1655 Skip_Space;
1656 First_Prio := Get_Nat;
1657 Last_Prio := Get_Nat;
1658 Line_No := Get_Nat;
1660 Specific_Dispatching.Append (
1661 (Dispatching_Policy => Policy,
1662 First_Priority => First_Prio,
1663 Last_Priority => Last_Prio,
1664 PSD_Pragma_Line => Line_No));
1666 ALIs.Table (Id).Last_Specific_Dispatching :=
1667 Specific_Dispatching.Last;
1669 Skip_Eol;
1670 end;
1671 end if;
1673 C := Getc;
1674 end loop;
1676 -- Loop to acquire unit entries
1678 U_Loop : loop
1679 Check_Unknown_Line;
1680 exit U_Loop when C /= 'U';
1682 -- Note: as per spec, we never ignore U lines
1684 Checkc (' ');
1685 Skip_Space;
1686 Units.Increment_Last;
1688 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1689 ALIs.Table (Id).First_Unit := Units.Last;
1690 end if;
1692 declare
1693 UL : Unit_Record renames Units.Table (Units.Last);
1695 begin
1696 UL.Uname := Get_Unit_Name;
1697 UL.Predefined := Is_Predefined_Unit;
1698 UL.Internal := Is_Internal_Unit;
1699 UL.My_ALI := Id;
1700 UL.Sfile := Get_File_Name (Lower => True);
1701 UL.Pure := False;
1702 UL.Preelab := False;
1703 UL.No_Elab := False;
1704 UL.Shared_Passive := False;
1705 UL.RCI := False;
1706 UL.Remote_Types := False;
1707 UL.Serious_Errors := False;
1708 UL.Has_RACW := False;
1709 UL.Init_Scalars := False;
1710 UL.Is_Generic := False;
1711 UL.Icasing := Mixed_Case;
1712 UL.Kcasing := All_Lower_Case;
1713 UL.Dynamic_Elab := False;
1714 UL.Elaborate_Body := False;
1715 UL.Set_Elab_Entity := False;
1716 UL.Version := "00000000";
1717 UL.First_With := Withs.Last + 1;
1718 UL.First_Arg := First_Arg;
1719 UL.Elab_Position := 0;
1720 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1721 UL.Directly_Scanned := Directly_Scanned;
1722 UL.Body_Needed_For_SAL := False;
1723 UL.Elaborate_Body_Desirable := False;
1724 UL.Optimize_Alignment := 'O';
1725 UL.Has_Finalizer := False;
1727 if Debug_Flag_U then
1728 Write_Str (" ----> reading unit ");
1729 Write_Int (Int (Units.Last));
1730 Write_Str (" ");
1731 Write_Unit_Name (UL.Uname);
1732 Write_Str (" from file ");
1733 Write_Name (UL.Sfile);
1734 Write_Eol;
1735 end if;
1736 end;
1738 -- Check for duplicated unit in different files
1740 declare
1741 Info : constant Int := Get_Name_Table_Int
1742 (Units.Table (Units.Last).Uname);
1743 begin
1744 if Info /= 0
1745 and then Units.Table (Units.Last).Sfile /=
1746 Units.Table (Unit_Id (Info)).Sfile
1747 then
1748 -- If Err is set then ignore duplicate unit name. This is the
1749 -- case of a call from gnatmake, where the situation can arise
1750 -- from substitution of source files. In such situations, the
1751 -- processing in gnatmake will always result in any required
1752 -- recompilations in any case, and if we consider this to be
1753 -- an error we get strange cases (for example when a generic
1754 -- instantiation is replaced by a normal package) where we
1755 -- read the old ali file, decide to recompile, and then decide
1756 -- that the old and new ali files are incompatible.
1758 if Err then
1759 null;
1761 -- If Err is not set, then this is a fatal error. This is
1762 -- the case of being called from the binder, where we must
1763 -- definitely diagnose this as an error.
1765 else
1766 Set_Standard_Error;
1767 Write_Str ("error: duplicate unit name: ");
1768 Write_Eol;
1770 Write_Str ("error: unit """);
1771 Write_Unit_Name (Units.Table (Units.Last).Uname);
1772 Write_Str (""" found in file """);
1773 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1774 Write_Char ('"');
1775 Write_Eol;
1777 Write_Str ("error: unit """);
1778 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1779 Write_Str (""" found in file """);
1780 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1781 Write_Char ('"');
1782 Write_Eol;
1784 Exit_Program (E_Fatal);
1785 end if;
1786 end if;
1787 end;
1789 Set_Name_Table_Int
1790 (Units.Table (Units.Last).Uname, Int (Units.Last));
1792 -- Scan out possible version and other parameters
1794 loop
1795 Skip_Space;
1796 exit when At_Eol;
1797 C := Getc;
1799 -- Version field
1801 if C in '0' .. '9' or else C in 'a' .. 'f' then
1802 Units.Table (Units.Last).Version (1) := C;
1804 for J in 2 .. 8 loop
1805 C := Getc;
1806 Units.Table (Units.Last).Version (J) := C;
1807 end loop;
1809 -- BD/BN parameters
1811 elsif C = 'B' then
1812 C := Getc;
1814 if C = 'D' then
1815 Check_At_End_Of_Field;
1816 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1818 elsif C = 'N' then
1819 Check_At_End_Of_Field;
1820 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1822 else
1823 Fatal_Error_Ignore;
1824 end if;
1826 -- DE parameter (Dynamic elaboration checks)
1828 elsif C = 'D' then
1829 C := Getc;
1831 if C = 'E' then
1832 Check_At_End_Of_Field;
1833 Units.Table (Units.Last).Dynamic_Elab := True;
1834 Dynamic_Elaboration_Checks_Specified := True;
1835 else
1836 Fatal_Error_Ignore;
1837 end if;
1839 -- EB/EE parameters
1841 elsif C = 'E' then
1842 C := Getc;
1844 if C = 'B' then
1845 Units.Table (Units.Last).Elaborate_Body := True;
1846 elsif C = 'E' then
1847 Units.Table (Units.Last).Set_Elab_Entity := True;
1848 else
1849 Fatal_Error_Ignore;
1850 end if;
1852 Check_At_End_Of_Field;
1854 -- GE parameter (generic)
1856 elsif C = 'G' then
1857 C := Getc;
1859 if C = 'E' then
1860 Check_At_End_Of_Field;
1861 Units.Table (Units.Last).Is_Generic := True;
1862 else
1863 Fatal_Error_Ignore;
1864 end if;
1866 -- IL/IS/IU parameters
1868 elsif C = 'I' then
1869 C := Getc;
1871 if C = 'L' then
1872 Units.Table (Units.Last).Icasing := All_Lower_Case;
1873 elsif C = 'S' then
1874 Units.Table (Units.Last).Init_Scalars := True;
1875 Initialize_Scalars_Used := True;
1876 elsif C = 'U' then
1877 Units.Table (Units.Last).Icasing := All_Upper_Case;
1878 else
1879 Fatal_Error_Ignore;
1880 end if;
1882 Check_At_End_Of_Field;
1884 -- KM/KU parameters
1886 elsif C = 'K' then
1887 C := Getc;
1889 if C = 'M' then
1890 Units.Table (Units.Last).Kcasing := Mixed_Case;
1891 elsif C = 'U' then
1892 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1893 else
1894 Fatal_Error_Ignore;
1895 end if;
1897 Check_At_End_Of_Field;
1899 -- NE parameter
1901 elsif C = 'N' then
1902 C := Getc;
1904 if C = 'E' then
1905 Units.Table (Units.Last).No_Elab := True;
1906 Check_At_End_Of_Field;
1907 else
1908 Fatal_Error_Ignore;
1909 end if;
1911 -- PF/PR/PU/PK parameters
1913 elsif C = 'P' then
1914 C := Getc;
1916 if C = 'F' then
1917 Units.Table (Units.Last).Has_Finalizer := True;
1918 elsif C = 'R' then
1919 Units.Table (Units.Last).Preelab := True;
1920 elsif C = 'U' then
1921 Units.Table (Units.Last).Pure := True;
1922 elsif C = 'K' then
1923 Units.Table (Units.Last).Unit_Kind := 'p';
1924 else
1925 Fatal_Error_Ignore;
1926 end if;
1928 Check_At_End_Of_Field;
1930 -- OL/OO/OS/OT parameters
1932 elsif C = 'O' then
1933 C := Getc;
1935 if C = 'L' or else C = 'O' or else C = 'S' or else C = 'T' then
1936 Units.Table (Units.Last).Optimize_Alignment := C;
1937 else
1938 Fatal_Error_Ignore;
1939 end if;
1941 Check_At_End_Of_Field;
1943 -- RC/RT parameters
1945 elsif C = 'R' then
1946 C := Getc;
1948 if C = 'C' then
1949 Units.Table (Units.Last).RCI := True;
1950 elsif C = 'T' then
1951 Units.Table (Units.Last).Remote_Types := True;
1952 elsif C = 'A' then
1953 Units.Table (Units.Last).Has_RACW := True;
1954 else
1955 Fatal_Error_Ignore;
1956 end if;
1958 Check_At_End_Of_Field;
1960 -- SE/SP/SU parameters
1962 elsif C = 'S' then
1963 C := Getc;
1965 if C = 'E' then
1966 Units.Table (Units.Last).Serious_Errors := True;
1967 elsif C = 'P' then
1968 Units.Table (Units.Last).Shared_Passive := True;
1969 elsif C = 'U' then
1970 Units.Table (Units.Last).Unit_Kind := 's';
1971 else
1972 Fatal_Error_Ignore;
1973 end if;
1975 Check_At_End_Of_Field;
1977 else
1978 C := Getc;
1979 Fatal_Error_Ignore;
1980 end if;
1981 end loop;
1983 Skip_Eol;
1985 -- Check if static elaboration model used
1987 if not Units.Table (Units.Last).Dynamic_Elab
1988 and then not Units.Table (Units.Last).Internal
1989 then
1990 Static_Elaboration_Model_Used := True;
1991 end if;
1993 C := Getc;
1995 -- Scan out With lines for this unit
1997 With_Loop : loop
1998 Check_Unknown_Line;
1999 exit With_Loop when C /= 'W' and then C /= 'Y' and then C /= 'Z';
2001 if Ignore ('W') then
2002 Skip_Line;
2004 else
2005 Checkc (' ');
2006 Skip_Space;
2007 Withs.Increment_Last;
2008 Withs.Table (Withs.Last).Uname := Get_Unit_Name;
2009 Withs.Table (Withs.Last).Elaborate := False;
2010 Withs.Table (Withs.Last).Elaborate_All := False;
2011 Withs.Table (Withs.Last).Elab_Desirable := False;
2012 Withs.Table (Withs.Last).Elab_All_Desirable := False;
2013 Withs.Table (Withs.Last).SAL_Interface := False;
2014 Withs.Table (Withs.Last).Limited_With := (C = 'Y');
2015 Withs.Table (Withs.Last).Implicit_With_From_Instantiation
2016 := (C = 'Z');
2018 -- Generic case with no object file available
2020 if At_Eol then
2021 Withs.Table (Withs.Last).Sfile := No_File;
2022 Withs.Table (Withs.Last).Afile := No_File;
2024 -- Normal case
2026 else
2027 Withs.Table (Withs.Last).Sfile := Get_File_Name
2028 (Lower => True);
2029 Withs.Table (Withs.Last).Afile := Get_File_Name
2030 (Lower => True);
2032 -- Scan out possible E, EA, ED, and AD parameters
2034 while not At_Eol loop
2035 Skip_Space;
2037 if Nextc = 'A' then
2038 P := P + 1;
2039 Checkc ('D');
2040 Check_At_End_Of_Field;
2042 -- Store AD indication unless ignore required
2044 if not Ignore_ED then
2045 Withs.Table (Withs.Last).Elab_All_Desirable :=
2046 True;
2047 end if;
2049 elsif Nextc = 'E' then
2050 P := P + 1;
2052 if At_End_Of_Field then
2053 Withs.Table (Withs.Last).Elaborate := True;
2055 elsif Nextc = 'A' then
2056 P := P + 1;
2057 Check_At_End_Of_Field;
2058 Withs.Table (Withs.Last).Elaborate_All := True;
2060 else
2061 Checkc ('D');
2062 Check_At_End_Of_Field;
2064 -- Store ED indication unless ignore required
2066 if not Ignore_ED then
2067 Withs.Table (Withs.Last).Elab_Desirable :=
2068 True;
2069 end if;
2070 end if;
2072 else
2073 Fatal_Error;
2074 end if;
2075 end loop;
2076 end if;
2078 Skip_Eol;
2079 end if;
2081 C := Getc;
2082 end loop With_Loop;
2084 Units.Table (Units.Last).Last_With := Withs.Last;
2085 Units.Table (Units.Last).Last_Arg := Args.Last;
2087 -- If there are linker options lines present, scan them
2089 Name_Len := 0;
2091 Linker_Options_Loop : loop
2092 Check_Unknown_Line;
2093 exit Linker_Options_Loop when C /= 'L';
2095 if Ignore ('L') then
2096 Skip_Line;
2098 else
2099 Checkc (' ');
2100 Skip_Space;
2101 Checkc ('"');
2103 loop
2104 C := Getc;
2106 if C < Character'Val (16#20#)
2107 or else C > Character'Val (16#7E#)
2108 then
2109 Fatal_Error_Ignore;
2111 elsif C = '{' then
2112 C := Character'Val (0);
2114 declare
2115 V : Natural;
2117 begin
2118 V := 0;
2119 for J in 1 .. 2 loop
2120 C := Getc;
2122 if C in '0' .. '9' then
2123 V := V * 16 +
2124 Character'Pos (C) -
2125 Character'Pos ('0');
2127 elsif C in 'A' .. 'F' then
2128 V := V * 16 +
2129 Character'Pos (C) -
2130 Character'Pos ('A') +
2133 else
2134 Fatal_Error_Ignore;
2135 end if;
2136 end loop;
2138 Checkc ('}');
2139 Add_Char_To_Name_Buffer (Character'Val (V));
2140 end;
2142 else
2143 if C = '"' then
2144 exit when Nextc /= '"';
2145 C := Getc;
2146 end if;
2148 Add_Char_To_Name_Buffer (C);
2149 end if;
2150 end loop;
2152 Add_Char_To_Name_Buffer (NUL);
2153 Skip_Eol;
2154 end if;
2156 C := Getc;
2157 end loop Linker_Options_Loop;
2159 -- Store the linker options entry if one was found
2161 if Name_Len /= 0 then
2162 Linker_Options.Increment_Last;
2164 Linker_Options.Table (Linker_Options.Last).Name :=
2165 Name_Enter;
2167 Linker_Options.Table (Linker_Options.Last).Unit :=
2168 Units.Last;
2170 Linker_Options.Table (Linker_Options.Last).Internal_File :=
2171 Is_Internal_File_Name (F);
2173 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
2174 Linker_Options.Last;
2175 end if;
2177 -- If there are notes present, scan them
2179 Notes_Loop : loop
2180 Check_Unknown_Line;
2181 exit Notes_Loop when C /= 'N';
2183 if Ignore ('N') then
2184 Skip_Line;
2186 else
2187 Checkc (' ');
2189 Notes.Increment_Last;
2190 Notes.Table (Notes.Last).Pragma_Type := Getc;
2191 Notes.Table (Notes.Last).Pragma_Line := Get_Nat;
2192 Checkc (':');
2193 Notes.Table (Notes.Last).Pragma_Col := Get_Nat;
2195 if not At_Eol and then Nextc = ':' then
2196 Checkc (':');
2197 Notes.Table (Notes.Last).Pragma_Source_File :=
2198 Get_File_Name (Lower => True);
2199 else
2200 Notes.Table (Notes.Last).Pragma_Source_File :=
2201 Units.Table (Units.Last).Sfile;
2202 end if;
2204 if At_Eol then
2205 Notes.Table (Notes.Last).Pragma_Args := No_Name;
2207 else
2208 -- Note: can't use Get_Name here as the remainder of the
2209 -- line is unstructured text whose syntax depends on the
2210 -- particular pragma used.
2212 Checkc (' ');
2214 Name_Len := 0;
2215 while not At_Eol loop
2216 Add_Char_To_Name_Buffer (Getc);
2217 end loop;
2218 end if;
2220 Skip_Eol;
2221 end if;
2223 C := Getc;
2224 end loop Notes_Loop;
2225 end loop U_Loop;
2227 -- End loop through units for one ALI file
2229 ALIs.Table (Id).Last_Unit := Units.Last;
2230 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
2232 -- Set types of the units (there can be at most 2 of them)
2234 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
2235 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
2236 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
2238 else
2239 -- Deal with body only and spec only cases, note that the reason we
2240 -- do our own checking of the name (rather than using Is_Body_Name)
2241 -- is that Uname drags in far too much compiler junk.
2243 Get_Name_String (Units.Table (Units.Last).Uname);
2245 if Name_Buffer (Name_Len) = 'b' then
2246 Units.Table (Units.Last).Utype := Is_Body_Only;
2247 else
2248 Units.Table (Units.Last).Utype := Is_Spec_Only;
2249 end if;
2250 end if;
2252 -- Scan out external version references and put in hash table
2254 E_Loop : loop
2255 Check_Unknown_Line;
2256 exit E_Loop when C /= 'E';
2258 if Ignore ('E') then
2259 Skip_Line;
2261 else
2262 Checkc (' ');
2263 Skip_Space;
2265 Name_Len := 0;
2266 Name_Len := 0;
2267 loop
2268 C := Getc;
2270 if C < ' ' then
2271 Fatal_Error;
2272 end if;
2274 exit when At_End_Of_Field;
2275 Add_Char_To_Name_Buffer (C);
2276 end loop;
2278 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
2279 Skip_Eol;
2280 end if;
2282 C := Getc;
2283 end loop E_Loop;
2285 -- Scan out source dependency lines for this ALI file
2287 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
2289 D_Loop : loop
2290 Check_Unknown_Line;
2291 exit D_Loop when C /= 'D';
2293 if Ignore ('D') then
2294 Skip_Line;
2296 else
2297 Checkc (' ');
2298 Skip_Space;
2299 Sdep.Increment_Last;
2301 -- In the following call, Lower is not set to True, this is either
2302 -- a bug, or it deserves a special comment as to why this is so???
2304 -- The file/path name may be quoted
2306 Sdep.Table (Sdep.Last).Sfile :=
2307 Get_File_Name (May_Be_Quoted => True);
2309 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
2310 Sdep.Table (Sdep.Last).Dummy_Entry :=
2311 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
2313 -- Acquire checksum value
2315 Skip_Space;
2317 declare
2318 Ctr : Natural;
2319 Chk : Word;
2321 begin
2322 Ctr := 0;
2323 Chk := 0;
2325 loop
2326 exit when At_Eol or else Ctr = 8;
2328 if Nextc in '0' .. '9' then
2329 Chk := Chk * 16 +
2330 Character'Pos (Nextc) - Character'Pos ('0');
2332 elsif Nextc in 'a' .. 'f' then
2333 Chk := Chk * 16 +
2334 Character'Pos (Nextc) - Character'Pos ('a') + 10;
2336 else
2337 exit;
2338 end if;
2340 Ctr := Ctr + 1;
2341 P := P + 1;
2342 end loop;
2344 if Ctr = 8 and then At_End_Of_Field then
2345 Sdep.Table (Sdep.Last).Checksum := Chk;
2346 else
2347 Fatal_Error;
2348 end if;
2349 end;
2351 -- Acquire (sub)unit and reference file name entries
2353 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
2354 Sdep.Table (Sdep.Last).Unit_Name := No_Name;
2355 Sdep.Table (Sdep.Last).Rfile :=
2356 Sdep.Table (Sdep.Last).Sfile;
2357 Sdep.Table (Sdep.Last).Start_Line := 1;
2359 if not At_Eol then
2360 Skip_Space;
2362 -- Here for (sub)unit name
2364 if Nextc not in '0' .. '9' then
2365 Name_Len := 0;
2366 while not At_End_Of_Field loop
2367 Add_Char_To_Name_Buffer (Getc);
2368 end loop;
2370 -- Set the (sub)unit name. Note that we use Name_Find rather
2371 -- than Name_Enter here as the subunit name may already
2372 -- have been put in the name table by the Project Manager.
2374 if Name_Len <= 2
2375 or else Name_Buffer (Name_Len - 1) /= '%'
2376 then
2377 Sdep.Table (Sdep.Last).Subunit_Name := Name_Find;
2378 else
2379 Name_Len := Name_Len - 2;
2380 Sdep.Table (Sdep.Last).Unit_Name := Name_Find;
2381 end if;
2383 Skip_Space;
2384 end if;
2386 -- Here for reference file name entry
2388 if Nextc in '0' .. '9' then
2389 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
2390 Checkc (':');
2392 Name_Len := 0;
2394 while not At_End_Of_Field loop
2395 Add_Char_To_Name_Buffer (Getc);
2396 end loop;
2398 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
2399 end if;
2400 end if;
2402 Skip_Eol;
2403 end if;
2405 C := Getc;
2406 end loop D_Loop;
2408 ALIs.Table (Id).Last_Sdep := Sdep.Last;
2410 -- We must at this stage be at an Xref line or the end of file
2412 if C = EOF then
2413 return Id;
2414 end if;
2416 Check_Unknown_Line;
2418 if C /= 'X' then
2419 Fatal_Error;
2420 end if;
2422 -- If we are ignoring Xref sections we are done (we ignore all
2423 -- remaining lines since only xref related lines follow X).
2425 if Ignore ('X') and then not Debug_Flag_X then
2426 return Id;
2427 end if;
2429 -- Loop through Xref sections
2431 X_Loop : loop
2432 Check_Unknown_Line;
2433 exit X_Loop when C /= 'X';
2435 -- Make new entry in section table
2437 Xref_Section.Increment_Last;
2439 Read_Refs_For_One_File : declare
2440 XS : Xref_Section_Record renames
2441 Xref_Section.Table (Xref_Section.Last);
2443 Current_File_Num : Sdep_Id;
2444 -- Keeps track of the current file number (changed by nn|)
2446 begin
2447 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
2448 XS.File_Name := Get_File_Name;
2449 XS.First_Entity := Xref_Entity.Last + 1;
2451 Current_File_Num := XS.File_Num;
2453 Skip_Space;
2455 Skip_Eol;
2456 C := Nextc;
2458 -- Loop through Xref entities
2460 while C /= 'X' and then C /= EOF loop
2461 Xref_Entity.Increment_Last;
2463 Read_Refs_For_One_Entity : declare
2464 XE : Xref_Entity_Record renames
2465 Xref_Entity.Table (Xref_Entity.Last);
2466 N : Nat;
2468 procedure Read_Instantiation_Reference;
2469 -- Acquire instantiation reference. Caller has checked
2470 -- that current character is '[' and on return the cursor
2471 -- is skipped past the corresponding closing ']'.
2473 ----------------------------------
2474 -- Read_Instantiation_Reference --
2475 ----------------------------------
2477 procedure Read_Instantiation_Reference is
2478 Local_File_Num : Sdep_Id := Current_File_Num;
2480 begin
2481 Xref.Increment_Last;
2483 declare
2484 XR : Xref_Record renames Xref.Table (Xref.Last);
2486 begin
2487 P := P + 1; -- skip [
2488 N := Get_Nat;
2490 if Nextc = '|' then
2491 XR.File_Num :=
2492 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2493 Local_File_Num := XR.File_Num;
2494 P := P + 1;
2495 N := Get_Nat;
2497 else
2498 XR.File_Num := Local_File_Num;
2499 end if;
2501 XR.Line := N;
2502 XR.Rtype := ' ';
2503 XR.Col := 0;
2505 -- Recursive call for next reference
2507 if Nextc = '[' then
2508 pragma Warnings (Off); -- kill recursion warning
2509 Read_Instantiation_Reference;
2510 pragma Warnings (On);
2511 end if;
2513 -- Skip closing bracket after recursive call
2515 P := P + 1;
2516 end;
2517 end Read_Instantiation_Reference;
2519 -- Start of processing for Read_Refs_For_One_Entity
2521 begin
2522 XE.Line := Get_Nat;
2523 XE.Etype := Getc;
2524 XE.Col := Get_Nat;
2526 case Getc is
2527 when '*' =>
2528 XE.Visibility := Global;
2529 when '+' =>
2530 XE.Visibility := Static;
2531 when others =>
2532 XE.Visibility := Other;
2533 end case;
2535 XE.Entity := Get_Name;
2537 -- Handle the information about generic instantiations
2539 if Nextc = '[' then
2540 Skipc; -- Opening '['
2541 N := Get_Nat;
2543 if Nextc /= '|' then
2544 XE.Iref_File_Num := Current_File_Num;
2545 XE.Iref_Line := N;
2546 else
2547 XE.Iref_File_Num :=
2548 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2549 Skipc;
2550 XE.Iref_Line := Get_Nat;
2551 end if;
2553 if Getc /= ']' then
2554 Fatal_Error;
2555 end if;
2557 else
2558 XE.Iref_File_Num := No_Sdep_Id;
2559 XE.Iref_Line := 0;
2560 end if;
2562 Current_File_Num := XS.File_Num;
2564 -- Renaming reference is present
2566 if Nextc = '=' then
2567 P := P + 1;
2568 XE.Rref_Line := Get_Nat;
2570 if Getc /= ':' then
2571 Fatal_Error;
2572 end if;
2574 XE.Rref_Col := Get_Nat;
2576 -- No renaming reference present
2578 else
2579 XE.Rref_Line := 0;
2580 XE.Rref_Col := 0;
2581 end if;
2583 Skip_Space;
2585 XE.Oref_File_Num := No_Sdep_Id;
2586 XE.Tref_File_Num := No_Sdep_Id;
2587 XE.Tref := Tref_None;
2588 XE.First_Xref := Xref.Last + 1;
2590 -- Loop to check for additional info present
2592 loop
2593 declare
2594 Ref : Tref_Kind;
2595 File : Sdep_Id;
2596 Line : Nat;
2597 Typ : Character;
2598 Col : Nat;
2599 Std : Name_Id;
2601 begin
2602 Get_Typeref
2603 (Current_File_Num, Ref, File, Line, Typ, Col, Std);
2604 exit when Ref = Tref_None;
2606 -- Do we have an overriding procedure?
2608 if Ref = Tref_Derived and then Typ = 'p' then
2609 XE.Oref_File_Num := File;
2610 XE.Oref_Line := Line;
2611 XE.Oref_Col := Col;
2613 -- Arrays never override anything, and <> points to
2614 -- the index types instead
2616 elsif Ref = Tref_Derived and then XE.Etype = 'A' then
2618 -- Index types are stored in the list of references
2620 Xref.Increment_Last;
2622 declare
2623 XR : Xref_Record renames Xref.Table (Xref.Last);
2624 begin
2625 XR.File_Num := File;
2626 XR.Line := Line;
2627 XR.Rtype := Array_Index_Reference;
2628 XR.Col := Col;
2629 XR.Name := Std;
2630 end;
2632 -- Interfaces are stored in the list of references,
2633 -- although the parent type itself is stored in XE.
2634 -- The first interface (when there are only
2635 -- interfaces) is stored in XE.Tref*)
2637 elsif Ref = Tref_Derived
2638 and then Typ = 'R'
2639 and then XE.Tref_File_Num /= No_Sdep_Id
2640 then
2641 Xref.Increment_Last;
2643 declare
2644 XR : Xref_Record renames Xref.Table (Xref.Last);
2645 begin
2646 XR.File_Num := File;
2647 XR.Line := Line;
2648 XR.Rtype := Interface_Reference;
2649 XR.Col := Col;
2650 XR.Name := Std;
2651 end;
2653 else
2654 XE.Tref := Ref;
2655 XE.Tref_File_Num := File;
2656 XE.Tref_Line := Line;
2657 XE.Tref_Type := Typ;
2658 XE.Tref_Col := Col;
2659 XE.Tref_Standard_Entity := Std;
2660 end if;
2661 end;
2662 end loop;
2664 -- Loop through cross-references for this entity
2666 loop
2667 Skip_Space;
2669 if At_Eol then
2670 Skip_Eol;
2671 exit when Nextc /= '.';
2672 P := P + 1;
2673 end if;
2675 Xref.Increment_Last;
2677 declare
2678 XR : Xref_Record renames Xref.Table (Xref.Last);
2680 begin
2681 N := Get_Nat;
2683 if Nextc = '|' then
2684 XR.File_Num :=
2685 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2686 Current_File_Num := XR.File_Num;
2687 P := P + 1;
2688 N := Get_Nat;
2689 else
2690 XR.File_Num := Current_File_Num;
2691 end if;
2693 XR.Line := N;
2694 XR.Rtype := Getc;
2696 -- Imported entities reference as in:
2697 -- 494b<c,__gnat_copy_attribs>25
2699 if Nextc = '<' then
2700 Skipc;
2701 XR.Imported_Lang := Get_Name;
2703 pragma Assert (Nextc = ',');
2704 Skipc;
2706 XR.Imported_Name := Get_Name;
2708 pragma Assert (Nextc = '>');
2709 Skipc;
2711 else
2712 XR.Imported_Lang := No_Name;
2713 XR.Imported_Name := No_Name;
2714 end if;
2716 XR.Col := Get_Nat;
2718 if Nextc = '[' then
2719 Read_Instantiation_Reference;
2720 end if;
2721 end;
2722 end loop;
2724 -- Record last cross-reference
2726 XE.Last_Xref := Xref.Last;
2727 C := Nextc;
2729 exception
2730 when Bad_ALI_Format =>
2732 -- If ignoring errors, then we skip a line with an
2733 -- unexpected error, and try to continue subsequent
2734 -- xref lines.
2736 if Ignore_Errors then
2737 Xref_Entity.Decrement_Last;
2738 Skip_Line;
2739 C := Nextc;
2741 -- Otherwise, we reraise the fatal exception
2743 else
2744 raise;
2745 end if;
2746 end Read_Refs_For_One_Entity;
2747 end loop;
2749 -- Record last entity
2751 XS.Last_Entity := Xref_Entity.Last;
2753 end Read_Refs_For_One_File;
2755 C := Getc;
2756 end loop X_Loop;
2758 -- Here after dealing with xref sections
2760 -- Ignore remaining lines, which belong to an additional section of the
2761 -- ALI file not considered here (like SCO or SPARK information).
2763 Check_Unknown_Line;
2765 return Id;
2767 exception
2768 when Bad_ALI_Format =>
2769 return No_ALI_Id;
2770 end Scan_ALI;
2772 ---------
2773 -- SEq --
2774 ---------
2776 function SEq (F1, F2 : String_Ptr) return Boolean is
2777 begin
2778 return F1.all = F2.all;
2779 end SEq;
2781 -----------
2782 -- SHash --
2783 -----------
2785 function SHash (S : String_Ptr) return Vindex is
2786 H : Word;
2788 begin
2789 H := 0;
2790 for J in S.all'Range loop
2791 H := H * 2 + Character'Pos (S (J));
2792 end loop;
2794 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));
2795 end SHash;
2797 end ALI;