* config/rs6000/rs6000.md: Document why a pattern is not
[official-gcc.git] / gcc / ada / ali.adb
blob9561a11b143cf2a626f5b8b8709a64e7a1f0a46b
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- A L I --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1992-2004 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 with Butil; use Butil;
28 with Debug; use Debug;
29 with Fname; use Fname;
30 with Namet; use Namet;
31 with Opt; use Opt;
32 with Osint; use Osint;
33 with Output; use Output;
35 package body ALI is
37 use ASCII;
38 -- Make control characters visible
40 -- The following variable records which characters currently are
41 -- used as line type markers in the ALI file. This is used in
42 -- Scan_ALI to detect (or skip) invalid lines.
44 Known_ALI_Lines : constant array (Character range 'A' .. 'Z') of Boolean :=
45 ('V' => True, -- version
46 'M' => True, -- main program
47 'A' => True, -- argument
48 'P' => True, -- program
49 'R' => True, -- restriction
50 'I' => True, -- interrupt
51 'U' => True, -- unit
52 'W' => True, -- with
53 'L' => True, -- linker option
54 'E' => True, -- external
55 'D' => True, -- dependency
56 'X' => True, -- xref
57 others => False);
59 --------------------
60 -- Initialize_ALI --
61 --------------------
63 procedure Initialize_ALI is
64 begin
65 -- When (re)initializing ALI data structures the ALI user expects to
66 -- get a fresh set of data structures. Thus we first need to erase the
67 -- marks put in the name table by the previous set of ALI routine calls.
68 -- These two loops are empty and harmless the first time in.
70 for J in ALIs.First .. ALIs.Last loop
71 Set_Name_Table_Info (ALIs.Table (J).Afile, 0);
72 end loop;
74 for J in Units.First .. Units.Last loop
75 Set_Name_Table_Info (Units.Table (J).Uname, 0);
76 end loop;
78 -- Free argument table strings
80 for J in Args.First .. Args.Last loop
81 Free (Args.Table (J));
82 end loop;
84 -- Initialize all tables
86 ALIs.Init;
87 Units.Init;
88 Withs.Init;
89 Sdep.Init;
90 Linker_Options.Init;
91 Xref_Section.Init;
92 Xref_Entity.Init;
93 Xref.Init;
94 Version_Ref.Reset;
96 -- Add dummy zero'th item in Linker_Options for the sort function
98 Linker_Options.Increment_Last;
100 -- Initialize global variables recording cumulative options in all
101 -- ALI files that are read for a given processing run in gnatbind.
103 Dynamic_Elaboration_Checks_Specified := False;
104 Float_Format_Specified := ' ';
105 Locking_Policy_Specified := ' ';
106 No_Normalize_Scalars_Specified := False;
107 No_Object_Specified := False;
108 Normalize_Scalars_Specified := False;
109 Queuing_Policy_Specified := ' ';
110 Static_Elaboration_Model_Used := False;
111 Task_Dispatching_Policy_Specified := ' ';
112 Unreserve_All_Interrupts_Specified := False;
113 Zero_Cost_Exceptions_Specified := False;
114 end Initialize_ALI;
116 --------------
117 -- Scan_ALI --
118 --------------
120 function Scan_ALI
121 (F : File_Name_Type;
122 T : Text_Buffer_Ptr;
123 Ignore_ED : Boolean;
124 Err : Boolean;
125 Read_Xref : Boolean := False;
126 Read_Lines : String := "";
127 Ignore_Lines : String := "X";
128 Ignore_Errors : Boolean := False) return ALI_Id
130 P : Text_Ptr := T'First;
131 Line : Logical_Line_Number := 1;
132 Id : ALI_Id;
133 C : Character;
134 NS_Found : Boolean;
135 First_Arg : Arg_Id;
137 Ignore : array (Character range 'A' .. 'Z') of Boolean;
138 -- Ignore (X) is set to True if lines starting with X are to
139 -- be ignored by Scan_ALI and skipped, and False if the lines
140 -- are to be read and processed.
142 Restrictions_Initial : Rident.Restrictions_Info;
143 pragma Warnings (Off, Restrictions_Initial);
144 -- This variable, which should really be a constant (but that's not
145 -- allowed by the language) is used only for initialization, and the
146 -- reason we are declaring it is to get the default initialization
147 -- set for the object.
149 Bad_ALI_Format : exception;
150 -- Exception raised by Fatal_Error if Err is True
152 function At_Eol return Boolean;
153 -- Test if at end of line
155 function At_End_Of_Field return Boolean;
156 -- Test if at end of line, or if at blank or horizontal tab
158 procedure Check_At_End_Of_Field;
159 -- Check if we are at end of field, fatal error if not
161 procedure Checkc (C : Character);
162 -- Check next character is C. If so bump past it, if not fatal error
164 procedure Check_Unknown_Line;
165 -- If Ignore_Errors mode, then checks C to make sure that it is not
166 -- an unknown ALI line type characters, and if so, skips lines
167 -- until the first character of the line is one of these characters,
168 -- at which point it does a Getc to put that character in C. The
169 -- call has no effect if C is already an appropriate character.
170 -- If not in Ignore_Errors mode, a fatal error is signalled if the
171 -- line is unknown. Note that if C is an EOL on entry, the line is
172 -- skipped (it is assumed that blank lines are never significant).
173 -- If C is EOF on entry, the call has no effect (it is assumed that
174 -- the caller will properly handle this case).
176 procedure Fatal_Error;
177 -- Generate fatal error message for badly formatted ALI file if
178 -- Err is false, or raise Bad_ALI_Format if Err is True.
180 procedure Fatal_Error_Ignore;
181 pragma Inline (Fatal_Error_Ignore);
182 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
184 function Getc return Character;
185 -- Get next character, bumping P past the character obtained
187 function Get_Name
188 (Lower : Boolean := False;
189 Ignore_Spaces : Boolean := False) return Name_Id;
190 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
191 -- length in Name_Len, as well as being returned in Name_Id form).
192 -- If Lower is set to True then the Name_Buffer will be converted to
193 -- all lower case, for systems where file names are not case sensitive.
194 -- This ensures that gnatbind works correctly regardless of the case
195 -- of the file name on all systems. The name is terminated by a either
196 -- white space (when Ignore_Spaces is False) or a typeref bracket or
197 -- an equal sign except for the special case of an operator name
198 -- starting with a double quite which is terminated by another double
199 -- quote.
201 function Get_Nat return Nat;
202 -- Skip blanks, then scan out an unsigned integer value in Nat range.
204 function Get_Stamp return Time_Stamp_Type;
205 -- Skip blanks, then scan out a time stamp
207 function Nextc return Character;
208 -- Return current character without modifying pointer P
210 procedure Skip_Eol;
211 -- Skip past spaces, then skip past end of line (fatal error if not
212 -- at end of line). Also skips past any following blank lines.
214 procedure Skip_Line;
215 -- Skip rest of current line and any following blank lines.
217 procedure Skip_Space;
218 -- Skip past white space (blanks or horizontal tab)
220 procedure Skipc;
221 -- Skip past next character, does not affect value in C. This call
222 -- is like calling Getc and ignoring the returned result.
224 ---------------------
225 -- At_End_Of_Field --
226 ---------------------
228 function At_End_Of_Field return Boolean is
229 begin
230 return Nextc <= ' ';
231 end At_End_Of_Field;
233 ------------
234 -- At_Eol --
235 ------------
237 function At_Eol return Boolean is
238 begin
239 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
240 end At_Eol;
242 ---------------------------
243 -- Check_At_End_Of_Field --
244 ---------------------------
246 procedure Check_At_End_Of_Field is
247 begin
248 if not At_End_Of_Field then
249 if Ignore_Errors then
250 while Nextc > ' ' loop
251 P := P + 1;
252 end loop;
253 else
254 Fatal_Error;
255 end if;
256 end if;
257 end Check_At_End_Of_Field;
259 ------------
260 -- Checkc --
261 ------------
263 procedure Checkc (C : Character) is
264 begin
265 if Nextc = C then
266 P := P + 1;
267 elsif Ignore_Errors then
268 P := P + 1;
269 else
270 Fatal_Error;
271 end if;
272 end Checkc;
274 ------------------------
275 -- Check_Unknown_Line --
276 ------------------------
278 procedure Check_Unknown_Line is
279 begin
280 while C not in 'A' .. 'Z'
281 or else not Known_ALI_Lines (C)
282 loop
283 if C = CR or else C = LF then
284 Skip_Line;
286 elsif C = EOF then
287 return;
289 elsif Ignore_Errors then
290 Skip_Line;
291 C := Getc;
293 else
294 Fatal_Error;
295 end if;
296 end loop;
297 end Check_Unknown_Line;
299 -----------------
300 -- Fatal_Error --
301 -----------------
303 procedure Fatal_Error is
304 Ptr1 : Text_Ptr;
305 Ptr2 : Text_Ptr;
306 Col : Int;
308 procedure Wchar (C : Character);
309 -- Write a single character, replacing horizontal tab by spaces
311 procedure Wchar (C : Character) is
312 begin
313 if C = HT then
314 loop
315 Wchar (' ');
316 exit when Col mod 8 = 0;
317 end loop;
319 else
320 Write_Char (C);
321 Col := Col + 1;
322 end if;
323 end Wchar;
325 -- Start of processing for Fatal_Error
327 begin
328 if Err then
329 raise Bad_ALI_Format;
330 end if;
332 Set_Standard_Error;
333 Write_Str ("fatal error: file ");
334 Write_Name (F);
335 Write_Str (" is incorrectly formatted");
336 Write_Eol;
337 Write_Str
338 ("make sure you are using consistent versions of gcc/gnatbind");
339 Write_Eol;
341 -- Find start of line
343 Ptr1 := P;
345 while Ptr1 > T'First
346 and then T (Ptr1 - 1) /= CR
347 and then T (Ptr1 - 1) /= LF
348 loop
349 Ptr1 := Ptr1 - 1;
350 end loop;
352 Write_Int (Int (Line));
353 Write_Str (". ");
355 if Line < 100 then
356 Write_Char (' ');
357 end if;
359 if Line < 10 then
360 Write_Char (' ');
361 end if;
363 Col := 0;
364 Ptr2 := Ptr1;
366 while Ptr2 < T'Last
367 and then T (Ptr2) /= CR
368 and then T (Ptr2) /= LF
369 loop
370 Wchar (T (Ptr2));
371 Ptr2 := Ptr2 + 1;
372 end loop;
374 Write_Eol;
376 Write_Str (" ");
377 Col := 0;
379 while Ptr1 < P loop
380 if T (Ptr1) = HT then
381 Wchar (HT);
382 else
383 Wchar (' ');
384 end if;
386 Ptr1 := Ptr1 + 1;
387 end loop;
389 Wchar ('|');
390 Write_Eol;
392 Exit_Program (E_Fatal);
393 end Fatal_Error;
395 ------------------------
396 -- Fatal_Error_Ignore --
397 ------------------------
399 procedure Fatal_Error_Ignore is
400 begin
401 if not Ignore_Errors then
402 Fatal_Error;
403 end if;
404 end Fatal_Error_Ignore;
406 --------------
407 -- Get_Name --
408 --------------
410 function Get_Name
411 (Lower : Boolean := False;
412 Ignore_Spaces : Boolean := False) return Name_Id
414 begin
415 Name_Len := 0;
416 Skip_Space;
418 if At_Eol then
419 if Ignore_Errors then
420 return Error_Name;
421 else
422 Fatal_Error;
423 end if;
424 end if;
426 loop
427 Name_Len := Name_Len + 1;
428 Name_Buffer (Name_Len) := Getc;
430 exit when At_End_Of_Field and not Ignore_Spaces;
432 if Name_Buffer (1) = '"' then
433 exit when Name_Len > 1 and then Name_Buffer (Name_Len) = '"';
435 else
436 exit when (At_End_Of_Field and not Ignore_Spaces)
437 or else Nextc = '(' or else Nextc = ')'
438 or else Nextc = '{' or else Nextc = '}'
439 or else Nextc = '<' or else Nextc = '>'
440 or else Nextc = '=';
441 end if;
442 end loop;
444 -- Convert file name to all lower case if file names are not case
445 -- sensitive. This ensures that we handle names in the canonical
446 -- lower case format, regardless of the actual case.
448 if Lower and not File_Names_Case_Sensitive then
449 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
450 end if;
452 return Name_Find;
453 end Get_Name;
455 -------------
456 -- Get_Nat --
457 -------------
459 function Get_Nat return Nat is
460 V : Nat;
462 begin
463 Skip_Space;
465 V := 0;
466 loop
467 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
468 exit when At_End_Of_Field;
469 exit when Nextc < '0' or Nextc > '9';
470 end loop;
472 return V;
473 end Get_Nat;
475 ---------------
476 -- Get_Stamp --
477 ---------------
479 function Get_Stamp return Time_Stamp_Type is
480 T : Time_Stamp_Type;
481 Start : Integer;
483 begin
484 Skip_Space;
486 if At_Eol then
487 if Ignore_Errors then
488 return Dummy_Time_Stamp;
489 else
490 Fatal_Error;
491 end if;
492 end if;
494 -- Following reads old style time stamp missing first two digits
496 if Nextc in '7' .. '9' then
497 T (1) := '1';
498 T (2) := '9';
499 Start := 3;
501 -- Normal case of full year in time stamp
503 else
504 Start := 1;
505 end if;
507 for J in Start .. T'Last loop
508 T (J) := Getc;
509 end loop;
511 return T;
512 end Get_Stamp;
514 ----------
515 -- Getc --
516 ----------
518 function Getc return Character is
519 begin
520 if P = T'Last then
521 return EOF;
522 else
523 P := P + 1;
524 return T (P - 1);
525 end if;
526 end Getc;
528 -----------
529 -- Nextc --
530 -----------
532 function Nextc return Character is
533 begin
534 return T (P);
535 end Nextc;
537 --------------
538 -- Skip_Eol --
539 --------------
541 procedure Skip_Eol is
542 begin
543 Skip_Space;
545 if not At_Eol then
546 if Ignore_Errors then
547 while not At_Eol loop
548 P := P + 1;
549 end loop;
550 else
551 Fatal_Error;
552 end if;
553 end if;
555 -- Loop to skip past blank lines (first time through skips this EOL)
557 while Nextc < ' ' and then Nextc /= EOF loop
558 if Nextc = LF then
559 Line := Line + 1;
560 end if;
562 P := P + 1;
563 end loop;
564 end Skip_Eol;
566 ---------------
567 -- Skip_Line --
568 ---------------
570 procedure Skip_Line is
571 begin
572 while not At_Eol loop
573 P := P + 1;
574 end loop;
576 Skip_Eol;
577 end Skip_Line;
579 ----------------
580 -- Skip_Space --
581 ----------------
583 procedure Skip_Space is
584 begin
585 while Nextc = ' ' or else Nextc = HT loop
586 P := P + 1;
587 end loop;
588 end Skip_Space;
590 -----------
591 -- Skipc --
592 -----------
594 procedure Skipc is
595 begin
596 if P /= T'Last then
597 P := P + 1;
598 end if;
599 end Skipc;
601 -- Start of processing for Scan_ALI
603 begin
604 First_Sdep_Entry := Sdep.Last + 1;
606 -- Acquire lines to be ignored
608 if Read_Xref then
609 Ignore := ('U' | 'W' | 'D' | 'X' => False, others => True);
611 -- Read_Lines parameter given
613 elsif Read_Lines /= "" then
614 Ignore := ('U' => False, others => True);
616 for J in Read_Lines'Range loop
617 Ignore (Read_Lines (J)) := False;
618 end loop;
620 -- Process Ignore_Lines parameter
622 else
623 Ignore := (others => False);
625 for J in Ignore_Lines'Range loop
626 pragma Assert (Ignore_Lines (J) /= 'U');
627 Ignore (Ignore_Lines (J)) := True;
628 end loop;
629 end if;
631 -- Setup ALI Table entry with appropriate defaults
633 ALIs.Increment_Last;
634 Id := ALIs.Last;
635 Set_Name_Table_Info (F, Int (Id));
637 ALIs.Table (Id) := (
638 Afile => F,
639 Compile_Errors => False,
640 First_Interrupt_State => Interrupt_States.Last + 1,
641 First_Sdep => No_Sdep_Id,
642 First_Unit => No_Unit_Id,
643 Float_Format => 'I',
644 Last_Interrupt_State => Interrupt_States.Last,
645 Last_Sdep => No_Sdep_Id,
646 Last_Unit => No_Unit_Id,
647 Locking_Policy => ' ',
648 Main_Priority => -1,
649 Main_Program => None,
650 No_Object => False,
651 Normalize_Scalars => False,
652 Ofile_Full_Name => Full_Object_File_Name,
653 Queuing_Policy => ' ',
654 Restrictions => Restrictions_Initial,
655 Sfile => No_Name,
656 Task_Dispatching_Policy => ' ',
657 Time_Slice_Value => -1,
658 WC_Encoding => '8',
659 Unit_Exception_Table => False,
660 Ver => (others => ' '),
661 Ver_Len => 0,
662 Interface => False,
663 Zero_Cost_Exceptions => False);
665 -- Now we acquire the input lines from the ALI file. Note that the
666 -- convention in the following code is that as we enter each section,
667 -- C is set to contain the first character of the following line.
669 C := Getc;
670 Check_Unknown_Line;
672 -- Acquire library version
674 if C /= 'V' then
676 -- The V line missing really indicates trouble, most likely it
677 -- means we don't have an ALI file at all, so here we give a
678 -- fatal error even if we are in Ignore_Errors mode.
680 Fatal_Error;
682 elsif Ignore ('V') then
683 Skip_Line;
685 else
686 Checkc (' ');
687 Skip_Space;
688 Checkc ('"');
690 for J in 1 .. Ver_Len_Max loop
691 C := Getc;
692 exit when C = '"';
693 ALIs.Table (Id).Ver (J) := C;
694 ALIs.Table (Id).Ver_Len := J;
695 end loop;
697 Skip_Eol;
698 end if;
700 C := Getc;
701 Check_Unknown_Line;
703 -- Acquire main program line if present
705 if C = 'M' then
706 if Ignore ('M') then
707 Skip_Line;
709 else
710 Checkc (' ');
711 Skip_Space;
713 C := Getc;
715 if C = 'F' then
716 ALIs.Table (Id).Main_Program := Func;
717 elsif C = 'P' then
718 ALIs.Table (Id).Main_Program := Proc;
719 else
720 P := P - 1;
721 Fatal_Error;
722 end if;
724 Skip_Space;
726 if not At_Eol then
727 if Nextc < 'A' then
728 ALIs.Table (Id).Main_Priority := Get_Nat;
729 end if;
731 Skip_Space;
733 if Nextc = 'T' then
734 P := P + 1;
735 Checkc ('=');
736 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
737 end if;
739 Skip_Space;
741 Checkc ('W');
742 Checkc ('=');
743 ALIs.Table (Id).WC_Encoding := Getc;
744 end if;
746 Skip_Eol;
747 end if;
749 C := Getc;
750 end if;
752 -- Acquire argument lines
754 First_Arg := Args.Last + 1;
756 A_Loop : loop
757 Check_Unknown_Line;
758 exit A_Loop when C /= 'A';
760 if Ignore ('A') then
761 Skip_Line;
763 else
764 Checkc (' ');
765 Name_Len := 0;
767 while not At_Eol loop
768 Name_Len := Name_Len + 1;
769 Name_Buffer (Name_Len) := Getc;
770 end loop;
772 Args.Increment_Last;
773 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
775 Skip_Eol;
776 end if;
778 C := Getc;
779 end loop A_Loop;
781 -- Acquire P line
783 Check_Unknown_Line;
785 while C /= 'P' loop
786 if Ignore_Errors then
787 if C = EOF then
788 Fatal_Error;
789 else
790 Skip_Line;
791 end if;
792 else
793 Fatal_Error;
794 end if;
795 end loop;
797 if Ignore ('P') then
798 Skip_Line;
800 -- Process P line
802 else
803 NS_Found := False;
805 while not At_Eol loop
806 Checkc (' ');
807 Skip_Space;
808 C := Getc;
810 -- Processing for CE
812 if C = 'C' then
813 Checkc ('E');
814 ALIs.Table (Id).Compile_Errors := True;
816 -- Processing for FD/FG/FI
818 elsif C = 'F' then
819 Float_Format_Specified := Getc;
820 ALIs.Table (Id).Float_Format := Float_Format_Specified;
822 -- Processing for Lx
824 elsif C = 'L' then
825 Locking_Policy_Specified := Getc;
826 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
828 -- Processing for flags starting with N
830 elsif C = 'N' then
831 C := Getc;
833 -- Processing for NO
835 if C = 'O' then
836 ALIs.Table (Id).No_Object := True;
837 No_Object_Specified := True;
839 -- Processing for NR
841 elsif C = 'R' then
842 No_Run_Time_Mode := True;
843 Configurable_Run_Time_Mode := True;
845 -- Processing for NS
847 elsif C = 'S' then
848 ALIs.Table (Id).Normalize_Scalars := True;
849 Normalize_Scalars_Specified := True;
850 NS_Found := True;
852 -- Invalid switch starting with N
854 else
855 Fatal_Error_Ignore;
856 end if;
858 -- Processing for Qx
860 elsif C = 'Q' then
861 Queuing_Policy_Specified := Getc;
862 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
864 -- Processing for flags starting with S
866 elsif C = 'S' then
867 C := Getc;
869 -- Processing for SL
871 if C = 'L' then
872 ALIs.Table (Id).Interface := True;
874 -- Processing for SS
876 elsif C = 'S' then
877 Opt.Sec_Stack_Used := True;
879 -- Invalid switch starting with S
881 else
882 Fatal_Error_Ignore;
883 end if;
885 -- Processing for Tx
887 elsif C = 'T' then
888 Task_Dispatching_Policy_Specified := Getc;
889 ALIs.Table (Id).Task_Dispatching_Policy :=
890 Task_Dispatching_Policy_Specified;
892 -- Processing for switch starting with U
894 elsif C = 'U' then
895 C := Getc;
897 -- Processing for UA
899 if C = 'A' then
900 Unreserve_All_Interrupts_Specified := True;
902 -- Processing for UX
904 elsif C = 'X' then
905 ALIs.Table (Id).Unit_Exception_Table := True;
907 -- Invalid switches starting with U
909 else
910 Fatal_Error_Ignore;
911 end if;
913 -- Processing for ZX
915 elsif C = 'Z' then
916 C := Getc;
918 if C = 'X' then
919 ALIs.Table (Id).Zero_Cost_Exceptions := True;
920 Zero_Cost_Exceptions_Specified := True;
921 else
922 Fatal_Error_Ignore;
923 end if;
925 -- Invalid parameter
927 else
928 C := Getc;
929 Fatal_Error_Ignore;
930 end if;
931 end loop;
933 if not NS_Found then
934 No_Normalize_Scalars_Specified := True;
935 end if;
937 Skip_Eol;
938 end if;
940 C := Getc;
941 Check_Unknown_Line;
943 -- Acquire restrictions line
945 while C /= 'R' loop
946 if Ignore_Errors then
947 if C = EOF then
948 Fatal_Error;
949 else
950 Skip_Line;
951 end if;
952 else
953 Fatal_Error;
954 end if;
955 end loop;
957 if Ignore ('R') then
958 Skip_Line;
960 -- Process restrictions line
962 else
963 Scan_Restrictions : declare
964 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
965 -- Save cumulative restrictions in case we have a fatal error
967 Bad_R_Line : exception;
968 -- Signal bad restrictions line
970 begin
971 Checkc (' ');
972 Skip_Space;
974 -- Acquire information for boolean restrictions
976 for R in All_Boolean_Restrictions loop
977 C := Getc;
979 case C is
980 when 'v' =>
981 ALIs.Table (Id).Restrictions.Violated (R) := True;
982 Cumulative_Restrictions.Violated (R) := True;
984 when 'r' =>
985 ALIs.Table (Id).Restrictions.Set (R) := True;
986 Cumulative_Restrictions.Set (R) := True;
988 when 'n' =>
989 null;
991 when others =>
992 Fatal_Error;
993 end case;
994 end loop;
996 -- Acquire information for parameter restrictions
998 for RP in All_Parameter_Restrictions loop
1000 -- Acquire restrictions pragma information
1002 case Getc is
1003 when 'n' =>
1004 null;
1006 when 'r' =>
1007 ALIs.Table (Id).Restrictions.Set (RP) := True;
1009 declare
1010 N : constant Integer := Integer (Get_Nat);
1011 begin
1012 ALIs.Table (Id).Restrictions.Value (RP) := N;
1014 if Cumulative_Restrictions.Set (RP) then
1015 Cumulative_Restrictions.Value (RP) :=
1016 Integer'Min
1017 (Cumulative_Restrictions.Value (RP), N);
1018 else
1019 Cumulative_Restrictions.Set (RP) := True;
1020 Cumulative_Restrictions.Value (RP) := N;
1021 end if;
1022 end;
1024 when others =>
1025 Fatal_Error;
1026 end case;
1028 -- Acquire restrictions violations information
1030 case Getc is
1031 when 'n' =>
1032 null;
1034 when 'v' =>
1035 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1036 Cumulative_Restrictions.Violated (RP) := True;
1038 declare
1039 N : constant Integer := Integer (Get_Nat);
1040 pragma Unsuppress (Overflow_Check);
1042 begin
1043 ALIs.Table (Id).Restrictions.Count (RP) := N;
1045 if RP in Checked_Max_Parameter_Restrictions then
1046 Cumulative_Restrictions.Count (RP) :=
1047 Integer'Max
1048 (Cumulative_Restrictions.Count (RP), N);
1049 else
1050 Cumulative_Restrictions.Count (RP) :=
1051 Cumulative_Restrictions.Count (RP) + N;
1052 end if;
1054 exception
1055 when Constraint_Error =>
1057 -- A constraint error comes from the addition in
1058 -- the else branch. We reset to the maximum and
1059 -- indicate that the real value is now unknown.
1061 Cumulative_Restrictions.Value (RP) := Integer'Last;
1062 Cumulative_Restrictions.Unknown (RP) := True;
1063 end;
1065 if Nextc = '+' then
1066 Skipc;
1067 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1068 Cumulative_Restrictions.Unknown (RP) := True;
1069 end if;
1071 when others =>
1072 Fatal_Error;
1073 end case;
1074 end loop;
1076 Skip_Eol;
1078 -- Here if error during scanning of restrictions line
1080 exception
1081 when Bad_R_Line =>
1083 -- In Ignore_Errors mode, undo any changes to restrictions
1084 -- from this unit, and continue on.
1086 if Ignore_Errors then
1087 Cumulative_Restrictions := Save_R;
1088 ALIs.Table (Id).Restrictions := Restrictions_Initial;
1090 -- In normal mode, this is a fatal error
1092 else
1093 Fatal_Error;
1094 end if;
1096 end Scan_Restrictions;
1097 end if;
1099 -- Acquire 'I' lines if present
1101 C := Getc;
1102 Check_Unknown_Line;
1104 while C = 'I' loop
1105 if Ignore ('I') then
1106 Skip_Line;
1108 else
1109 declare
1110 Int_Num : Nat;
1111 I_State : Character;
1112 Line_No : Nat;
1114 begin
1115 Int_Num := Get_Nat;
1116 Skip_Space;
1117 I_State := Getc;
1118 Line_No := Get_Nat;
1120 Interrupt_States.Append (
1121 (Interrupt_Id => Int_Num,
1122 Interrupt_State => I_State,
1123 IS_Pragma_Line => Line_No));
1125 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1126 Skip_Eol;
1127 end;
1128 end if;
1130 C := Getc;
1131 end loop;
1133 -- Loop to acquire unit entries
1135 U_Loop : loop
1136 Check_Unknown_Line;
1137 exit U_Loop when C /= 'U';
1139 -- Note: as per spec, we never ignore U lines
1141 Checkc (' ');
1142 Skip_Space;
1143 Units.Increment_Last;
1145 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1146 ALIs.Table (Id).First_Unit := Units.Last;
1147 end if;
1149 Units.Table (Units.Last).Uname := Get_Name;
1150 Units.Table (Units.Last).Predefined := Is_Predefined_Unit;
1151 Units.Table (Units.Last).Internal := Is_Internal_Unit;
1152 Units.Table (Units.Last).My_ALI := Id;
1153 Units.Table (Units.Last).Sfile := Get_Name (Lower => True);
1154 Units.Table (Units.Last).Pure := False;
1155 Units.Table (Units.Last).Preelab := False;
1156 Units.Table (Units.Last).No_Elab := False;
1157 Units.Table (Units.Last).Shared_Passive := False;
1158 Units.Table (Units.Last).RCI := False;
1159 Units.Table (Units.Last).Remote_Types := False;
1160 Units.Table (Units.Last).Has_RACW := False;
1161 Units.Table (Units.Last).Init_Scalars := False;
1162 Units.Table (Units.Last).Is_Generic := False;
1163 Units.Table (Units.Last).Icasing := Mixed_Case;
1164 Units.Table (Units.Last).Kcasing := All_Lower_Case;
1165 Units.Table (Units.Last).Dynamic_Elab := False;
1166 Units.Table (Units.Last).Elaborate_Body := False;
1167 Units.Table (Units.Last).Set_Elab_Entity := False;
1168 Units.Table (Units.Last).Version := "00000000";
1169 Units.Table (Units.Last).First_With := Withs.Last + 1;
1170 Units.Table (Units.Last).First_Arg := First_Arg;
1171 Units.Table (Units.Last).Elab_Position := 0;
1172 Units.Table (Units.Last).Interface := ALIs.Table (Id).Interface;
1174 if Debug_Flag_U then
1175 Write_Str (" ----> reading unit ");
1176 Write_Int (Int (Units.Last));
1177 Write_Str (" ");
1178 Write_Unit_Name (Units.Table (Units.Last).Uname);
1179 Write_Str (" from file ");
1180 Write_Name (Units.Table (Units.Last).Sfile);
1181 Write_Eol;
1182 end if;
1184 -- Check for duplicated unit in different files
1186 declare
1187 Info : constant Int := Get_Name_Table_Info
1188 (Units.Table (Units.Last).Uname);
1189 begin
1190 if Info /= 0
1191 and then Units.Table (Units.Last).Sfile /=
1192 Units.Table (Unit_Id (Info)).Sfile
1193 then
1194 -- If Err is set then ignore duplicate unit name. This is the
1195 -- case of a call from gnatmake, where the situation can arise
1196 -- from substitution of source files. In such situations, the
1197 -- processing in gnatmake will always result in any required
1198 -- recompilations in any case, and if we consider this to be
1199 -- an error we get strange cases (for example when a generic
1200 -- instantiation is replaced by a normal package) where we
1201 -- read the old ali file, decide to recompile, and then decide
1202 -- that the old and new ali files are incompatible.
1204 if Err then
1205 null;
1207 -- If Err is not set, then this is a fatal error. This is
1208 -- the case of being called from the binder, where we must
1209 -- definitely diagnose this as an error.
1211 else
1212 Set_Standard_Error;
1213 Write_Str ("error: duplicate unit name: ");
1214 Write_Eol;
1216 Write_Str ("error: unit """);
1217 Write_Unit_Name (Units.Table (Units.Last).Uname);
1218 Write_Str (""" found in file """);
1219 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1220 Write_Char ('"');
1221 Write_Eol;
1223 Write_Str ("error: unit """);
1224 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1225 Write_Str (""" found in file """);
1226 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1227 Write_Char ('"');
1228 Write_Eol;
1230 Exit_Program (E_Fatal);
1231 end if;
1232 end if;
1233 end;
1235 Set_Name_Table_Info
1236 (Units.Table (Units.Last).Uname, Int (Units.Last));
1238 -- Scan out possible version and other parameters
1240 loop
1241 Skip_Space;
1242 exit when At_Eol;
1243 C := Getc;
1245 -- Version field
1247 if C in '0' .. '9' or else C in 'a' .. 'f' then
1248 Units.Table (Units.Last).Version (1) := C;
1250 for J in 2 .. 8 loop
1251 C := Getc;
1252 Units.Table (Units.Last).Version (J) := C;
1253 end loop;
1255 -- BN parameter (Body needed)
1257 elsif C = 'B' then
1258 C := Getc;
1260 if C = 'N' then
1261 Check_At_End_Of_Field;
1262 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1263 else
1264 Fatal_Error_Ignore;
1265 end if;
1268 -- DE parameter (Dynamic elaboration checks)
1270 elsif C = 'D' then
1271 C := Getc;
1273 if C = 'E' then
1274 Check_At_End_Of_Field;
1275 Units.Table (Units.Last).Dynamic_Elab := True;
1276 Dynamic_Elaboration_Checks_Specified := True;
1277 else
1278 Fatal_Error_Ignore;
1279 end if;
1281 -- EB/EE parameters
1283 elsif C = 'E' then
1284 C := Getc;
1286 if C = 'B' then
1287 Units.Table (Units.Last).Elaborate_Body := True;
1288 elsif C = 'E' then
1289 Units.Table (Units.Last).Set_Elab_Entity := True;
1290 else
1291 Fatal_Error_Ignore;
1292 end if;
1294 Check_At_End_Of_Field;
1296 -- GE parameter (generic)
1298 elsif C = 'G' then
1299 C := Getc;
1301 if C = 'E' then
1302 Check_At_End_Of_Field;
1303 Units.Table (Units.Last).Is_Generic := True;
1304 else
1305 Fatal_Error_Ignore;
1306 end if;
1308 -- IL/IS/IU parameters
1310 elsif C = 'I' then
1311 C := Getc;
1313 if C = 'L' then
1314 Units.Table (Units.Last).Icasing := All_Lower_Case;
1315 elsif C = 'S' then
1316 Units.Table (Units.Last).Init_Scalars := True;
1317 Initialize_Scalars_Used := True;
1318 elsif C = 'U' then
1319 Units.Table (Units.Last).Icasing := All_Upper_Case;
1320 else
1321 Fatal_Error_Ignore;
1322 end if;
1324 Check_At_End_Of_Field;
1326 -- KM/KU parameters
1328 elsif C = 'K' then
1329 C := Getc;
1331 if C = 'M' then
1332 Units.Table (Units.Last).Kcasing := Mixed_Case;
1333 elsif C = 'U' then
1334 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1335 else
1336 Fatal_Error_Ignore;
1337 end if;
1339 Check_At_End_Of_Field;
1341 -- NE parameter
1343 elsif C = 'N' then
1344 C := Getc;
1346 if C = 'E' then
1347 Units.Table (Units.Last).No_Elab := True;
1348 Check_At_End_Of_Field;
1349 else
1350 Fatal_Error_Ignore;
1351 end if;
1354 -- PR/PU/PK parameters
1356 elsif C = 'P' then
1357 C := Getc;
1359 if C = 'R' then
1360 Units.Table (Units.Last).Preelab := True;
1361 elsif C = 'U' then
1362 Units.Table (Units.Last).Pure := True;
1363 elsif C = 'K' then
1364 Units.Table (Units.Last).Unit_Kind := 'p';
1365 else
1366 Fatal_Error_Ignore;
1367 end if;
1369 Check_At_End_Of_Field;
1371 -- RC/RT parameters
1373 elsif C = 'R' then
1374 C := Getc;
1376 if C = 'C' then
1377 Units.Table (Units.Last).RCI := True;
1378 elsif C = 'T' then
1379 Units.Table (Units.Last).Remote_Types := True;
1380 elsif C = 'A' then
1381 Units.Table (Units.Last).Has_RACW := True;
1382 else
1383 Fatal_Error_Ignore;
1384 end if;
1386 Check_At_End_Of_Field;
1388 elsif C = 'S' then
1389 C := Getc;
1391 if C = 'P' then
1392 Units.Table (Units.Last).Shared_Passive := True;
1393 elsif C = 'U' then
1394 Units.Table (Units.Last).Unit_Kind := 's';
1395 else
1396 Fatal_Error_Ignore;
1397 end if;
1399 Check_At_End_Of_Field;
1401 else
1402 C := Getc;
1403 Fatal_Error_Ignore;
1404 end if;
1405 end loop;
1407 Skip_Eol;
1409 -- Check if static elaboration model used
1411 if not Units.Table (Units.Last).Dynamic_Elab
1412 and then not Units.Table (Units.Last).Internal
1413 then
1414 Static_Elaboration_Model_Used := True;
1415 end if;
1417 C := Getc;
1419 -- Scan out With lines for this unit
1421 With_Loop : loop
1422 Check_Unknown_Line;
1423 exit With_Loop when C /= 'W';
1425 if Ignore ('W') then
1426 Skip_Line;
1428 else
1429 Checkc (' ');
1430 Skip_Space;
1431 Withs.Increment_Last;
1432 Withs.Table (Withs.Last).Uname := Get_Name;
1433 Withs.Table (Withs.Last).Elaborate := False;
1434 Withs.Table (Withs.Last).Elaborate_All := False;
1435 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1436 Withs.Table (Withs.Last).Interface := False;
1438 -- Generic case with no object file available
1440 if At_Eol then
1441 Withs.Table (Withs.Last).Sfile := No_File;
1442 Withs.Table (Withs.Last).Afile := No_File;
1444 -- Normal case
1446 else
1447 Withs.Table (Withs.Last).Sfile := Get_Name (Lower => True);
1448 Withs.Table (Withs.Last).Afile := Get_Name;
1450 -- Scan out possible E, EA, and NE parameters
1452 while not At_Eol loop
1453 Skip_Space;
1455 if Nextc = 'E' then
1456 P := P + 1;
1458 if At_End_Of_Field then
1459 Withs.Table (Withs.Last).Elaborate := True;
1461 elsif Nextc = 'A' then
1462 P := P + 1;
1463 Check_At_End_Of_Field;
1464 Withs.Table (Withs.Last).Elaborate_All := True;
1466 else
1467 Checkc ('D');
1468 Check_At_End_Of_Field;
1470 -- Store ED indication unless ignore required
1472 if not Ignore_ED then
1473 Withs.Table (Withs.Last).Elab_All_Desirable :=
1474 True;
1475 end if;
1476 end if;
1477 end if;
1478 end loop;
1479 end if;
1481 Skip_Eol;
1482 end if;
1484 C := Getc;
1485 end loop With_Loop;
1487 Units.Table (Units.Last).Last_With := Withs.Last;
1488 Units.Table (Units.Last).Last_Arg := Args.Last;
1490 -- If there are linker options lines present, scan them
1492 Name_Len := 0;
1494 Linker_Options_Loop : loop
1495 Check_Unknown_Line;
1496 exit Linker_Options_Loop when C /= 'L';
1498 if Ignore ('L') then
1499 Skip_Line;
1501 else
1502 Checkc (' ');
1503 Skip_Space;
1504 Checkc ('"');
1506 loop
1507 C := Getc;
1509 if C < Character'Val (16#20#)
1510 or else C > Character'Val (16#7E#)
1511 then
1512 Fatal_Error_Ignore;
1514 elsif C = '{' then
1515 C := Character'Val (0);
1517 declare
1518 V : Natural;
1520 begin
1521 V := 0;
1522 for J in 1 .. 2 loop
1523 C := Getc;
1525 if C in '0' .. '9' then
1526 V := V * 16 +
1527 Character'Pos (C) -
1528 Character'Pos ('0');
1530 elsif C in 'A' .. 'F' then
1531 V := V * 16 +
1532 Character'Pos (C) -
1533 Character'Pos ('A') +
1536 else
1537 Fatal_Error_Ignore;
1538 end if;
1539 end loop;
1541 Checkc ('}');
1542 Add_Char_To_Name_Buffer (Character'Val (V));
1543 end;
1545 else
1546 if C = '"' then
1547 exit when Nextc /= '"';
1548 C := Getc;
1549 end if;
1551 Add_Char_To_Name_Buffer (C);
1552 end if;
1553 end loop;
1555 Add_Char_To_Name_Buffer (nul);
1556 Skip_Eol;
1557 end if;
1559 C := Getc;
1560 end loop Linker_Options_Loop;
1562 -- Store the linker options entry if one was found
1564 if Name_Len /= 0 then
1565 Linker_Options.Increment_Last;
1567 Linker_Options.Table (Linker_Options.Last).Name :=
1568 Name_Enter;
1570 Linker_Options.Table (Linker_Options.Last).Unit :=
1571 Units.Last;
1573 Linker_Options.Table (Linker_Options.Last).Internal_File :=
1574 Is_Internal_File_Name (F);
1576 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
1577 Linker_Options.Last;
1578 end if;
1579 end loop U_Loop;
1581 -- End loop through units for one ALI file
1583 ALIs.Table (Id).Last_Unit := Units.Last;
1584 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
1586 -- Set types of the units (there can be at most 2 of them)
1588 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
1589 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
1590 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
1592 else
1593 -- Deal with body only and spec only cases, note that the reason we
1594 -- do our own checking of the name (rather than using Is_Body_Name)
1595 -- is that Uname drags in far too much compiler junk!
1597 Get_Name_String (Units.Table (Units.Last).Uname);
1599 if Name_Buffer (Name_Len) = 'b' then
1600 Units.Table (Units.Last).Utype := Is_Body_Only;
1601 else
1602 Units.Table (Units.Last).Utype := Is_Spec_Only;
1603 end if;
1604 end if;
1606 -- Scan out external version references and put in hash table
1608 E_Loop : loop
1609 Check_Unknown_Line;
1610 exit E_Loop when C /= 'E';
1612 if Ignore ('E') then
1613 Skip_Line;
1615 else
1616 Checkc (' ');
1617 Skip_Space;
1619 Name_Len := 0;
1620 Name_Len := 0;
1621 loop
1622 C := Getc;
1624 if C < ' ' then
1625 Fatal_Error;
1626 end if;
1628 exit when At_End_Of_Field;
1629 Add_Char_To_Name_Buffer (C);
1630 end loop;
1632 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
1633 Skip_Eol;
1634 end if;
1636 C := Getc;
1637 end loop E_Loop;
1639 -- Scan out source dependency lines for this ALI file
1641 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
1643 D_Loop : loop
1644 Check_Unknown_Line;
1645 exit D_Loop when C /= 'D';
1647 if Ignore ('D') then
1648 Skip_Line;
1650 else
1651 Checkc (' ');
1652 Skip_Space;
1653 Sdep.Increment_Last;
1654 Sdep.Table (Sdep.Last).Sfile := Get_Name (Lower => True);
1655 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
1656 Sdep.Table (Sdep.Last).Dummy_Entry :=
1657 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
1659 -- Acquire checksum value
1661 Skip_Space;
1663 declare
1664 Ctr : Natural;
1665 Chk : Word;
1667 begin
1668 Ctr := 0;
1669 Chk := 0;
1671 loop
1672 exit when At_Eol or else Ctr = 8;
1674 if Nextc in '0' .. '9' then
1675 Chk := Chk * 16 +
1676 Character'Pos (Nextc) - Character'Pos ('0');
1678 elsif Nextc in 'a' .. 'f' then
1679 Chk := Chk * 16 +
1680 Character'Pos (Nextc) - Character'Pos ('a') + 10;
1682 else
1683 exit;
1684 end if;
1686 Ctr := Ctr + 1;
1687 P := P + 1;
1688 end loop;
1690 if Ctr = 8 and then At_End_Of_Field then
1691 Sdep.Table (Sdep.Last).Checksum := Chk;
1692 else
1693 Fatal_Error;
1694 end if;
1695 end;
1697 -- Acquire subunit and reference file name entries
1699 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
1700 Sdep.Table (Sdep.Last).Rfile :=
1701 Sdep.Table (Sdep.Last).Sfile;
1702 Sdep.Table (Sdep.Last).Start_Line := 1;
1704 if not At_Eol then
1705 Skip_Space;
1707 -- Here for subunit name
1709 if Nextc not in '0' .. '9' then
1710 Name_Len := 0;
1712 while not At_End_Of_Field loop
1713 Name_Len := Name_Len + 1;
1714 Name_Buffer (Name_Len) := Getc;
1715 end loop;
1717 Sdep.Table (Sdep.Last).Subunit_Name := Name_Enter;
1718 Skip_Space;
1719 end if;
1721 -- Here for reference file name entry
1723 if Nextc in '0' .. '9' then
1724 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
1725 Checkc (':');
1727 Name_Len := 0;
1729 while not At_End_Of_Field loop
1730 Name_Len := Name_Len + 1;
1731 Name_Buffer (Name_Len) := Getc;
1732 end loop;
1734 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
1735 end if;
1736 end if;
1738 Skip_Eol;
1739 end if;
1741 C := Getc;
1742 end loop D_Loop;
1744 ALIs.Table (Id).Last_Sdep := Sdep.Last;
1746 -- We must at this stage be at an Xref line or the end of file
1748 if C = EOF then
1749 return Id;
1750 end if;
1752 Check_Unknown_Line;
1754 if C /= 'X' then
1755 Fatal_Error;
1756 end if;
1758 -- If we are ignoring Xref sections we are done (we ignore all
1759 -- remaining lines since only xref related lines follow X).
1761 if Ignore ('X') and then not Debug_Flag_X then
1762 return Id;
1763 end if;
1765 -- Loop through Xref sections
1767 X_Loop : loop
1768 Check_Unknown_Line;
1769 exit X_Loop when C /= 'X';
1771 -- Make new entry in section table
1773 Xref_Section.Increment_Last;
1775 Read_Refs_For_One_File : declare
1776 XS : Xref_Section_Record renames
1777 Xref_Section.Table (Xref_Section.Last);
1779 Current_File_Num : Sdep_Id;
1780 -- Keeps track of the current file number (changed by nn|)
1782 begin
1783 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
1784 XS.File_Name := Get_Name;
1785 XS.First_Entity := Xref_Entity.Last + 1;
1787 Current_File_Num := XS.File_Num;
1789 Skip_Space;
1791 Skip_Eol;
1792 C := Nextc;
1794 -- Loop through Xref entities
1796 while C /= 'X' and then C /= EOF loop
1797 Xref_Entity.Increment_Last;
1799 Read_Refs_For_One_Entity : declare
1800 XE : Xref_Entity_Record renames
1801 Xref_Entity.Table (Xref_Entity.Last);
1802 N : Nat;
1804 procedure Read_Instantiation_Reference;
1805 -- Acquire instantiation reference. Caller has checked
1806 -- that current character is '[' and on return the cursor
1807 -- is skipped past the corresponding closing ']'.
1809 ----------------------------------
1810 -- Read_Instantiation_Reference --
1811 ----------------------------------
1813 procedure Read_Instantiation_Reference is
1814 Local_File_Num : Sdep_Id := Current_File_Num;
1816 begin
1817 Xref.Increment_Last;
1819 declare
1820 XR : Xref_Record renames Xref.Table (Xref.Last);
1822 begin
1823 P := P + 1; -- skip [
1824 N := Get_Nat;
1826 if Nextc = '|' then
1827 XR.File_Num :=
1828 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1829 Local_File_Num := XR.File_Num;
1830 P := P + 1;
1831 N := Get_Nat;
1833 else
1834 XR.File_Num := Local_File_Num;
1835 end if;
1837 XR.Line := N;
1838 XR.Rtype := ' ';
1839 XR.Col := 0;
1841 -- Recursive call for next reference
1843 if Nextc = '[' then
1844 pragma Warnings (Off); -- kill recursion warning
1845 Read_Instantiation_Reference;
1846 pragma Warnings (On);
1847 end if;
1849 -- Skip closing bracket after recursive call
1851 P := P + 1;
1852 end;
1853 end Read_Instantiation_Reference;
1855 -- Start of processing for Read_Refs_For_One_Entity
1857 begin
1858 XE.Line := Get_Nat;
1859 XE.Etype := Getc;
1860 XE.Col := Get_Nat;
1861 XE.Lib := (Getc = '*');
1862 XE.Entity := Get_Name;
1864 Current_File_Num := XS.File_Num;
1866 -- Renaming reference is present
1868 if Nextc = '=' then
1869 P := P + 1;
1870 XE.Rref_Line := Get_Nat;
1872 if Getc /= ':' then
1873 Fatal_Error;
1874 end if;
1876 XE.Rref_Col := Get_Nat;
1878 -- No renaming reference present
1880 else
1881 XE.Rref_Line := 0;
1882 XE.Rref_Col := 0;
1883 end if;
1885 Skip_Space;
1887 -- See if type reference present
1889 case Nextc is
1890 when '<' => XE.Tref := Tref_Derived;
1891 when '(' => XE.Tref := Tref_Access;
1892 when '{' => XE.Tref := Tref_Type;
1893 when others => XE.Tref := Tref_None;
1894 end case;
1896 -- Case of typeref field present
1898 if XE.Tref /= Tref_None then
1899 P := P + 1; -- skip opening bracket
1901 if Nextc in 'a' .. 'z' then
1902 XE.Tref_File_Num := No_Sdep_Id;
1903 XE.Tref_Line := 0;
1904 XE.Tref_Type := ' ';
1905 XE.Tref_Col := 0;
1906 XE.Tref_Standard_Entity :=
1907 Get_Name (Ignore_Spaces => True);
1909 else
1910 N := Get_Nat;
1912 if Nextc = '|' then
1913 XE.Tref_File_Num :=
1914 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1915 P := P + 1;
1916 N := Get_Nat;
1918 else
1919 XE.Tref_File_Num := Current_File_Num;
1920 end if;
1922 XE.Tref_Line := N;
1923 XE.Tref_Type := Getc;
1924 XE.Tref_Col := Get_Nat;
1925 XE.Tref_Standard_Entity := No_Name;
1926 end if;
1928 -- ??? Temporary workaround for nested generics case:
1929 -- 4i4 Directories{1|4I9[4|6[3|3]]}
1930 -- See C918-002
1932 declare
1933 Nested_Brackets : Natural := 0;
1935 begin
1936 loop
1937 case Nextc is
1938 when '[' =>
1939 Nested_Brackets := Nested_Brackets + 1;
1940 when ']' =>
1941 Nested_Brackets := Nested_Brackets - 1;
1942 when others =>
1943 if Nested_Brackets = 0 then
1944 exit;
1945 end if;
1946 end case;
1948 Skipc;
1949 end loop;
1950 end;
1952 P := P + 1; -- skip closing bracket
1953 Skip_Space;
1955 -- No typeref entry present
1957 else
1958 XE.Tref_File_Num := No_Sdep_Id;
1959 XE.Tref_Line := 0;
1960 XE.Tref_Type := ' ';
1961 XE.Tref_Col := 0;
1962 XE.Tref_Standard_Entity := No_Name;
1963 end if;
1965 XE.First_Xref := Xref.Last + 1;
1967 -- Loop through cross-references for this entity
1969 loop
1970 Skip_Space;
1972 if At_Eol then
1973 Skip_Eol;
1974 exit when Nextc /= '.';
1975 P := P + 1;
1976 end if;
1978 Xref.Increment_Last;
1980 declare
1981 XR : Xref_Record renames Xref.Table (Xref.Last);
1983 begin
1984 N := Get_Nat;
1986 if Nextc = '|' then
1987 XR.File_Num :=
1988 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1989 Current_File_Num := XR.File_Num;
1990 P := P + 1;
1991 N := Get_Nat;
1992 else
1993 XR.File_Num := Current_File_Num;
1994 end if;
1996 XR.Line := N;
1997 XR.Rtype := Getc;
1999 -- Imported entities reference as in:
2000 -- 494b<c,__gnat_copy_attribs>25
2001 -- ??? Simply skipped for now
2003 if Nextc = '<' then
2004 while Getc /= '>' loop
2005 null;
2006 end loop;
2007 end if;
2009 XR.Col := Get_Nat;
2011 if Nextc = '[' then
2012 Read_Instantiation_Reference;
2013 end if;
2014 end;
2015 end loop;
2017 -- Record last cross-reference
2019 XE.Last_Xref := Xref.Last;
2020 C := Nextc;
2021 end Read_Refs_For_One_Entity;
2022 end loop;
2024 -- Record last entity
2026 XS.Last_Entity := Xref_Entity.Last;
2028 end Read_Refs_For_One_File;
2030 C := Getc;
2031 end loop X_Loop;
2033 -- Here after dealing with xref sections
2035 if C /= EOF and then C /= 'X' then
2036 Fatal_Error;
2037 end if;
2039 return Id;
2041 exception
2042 when Bad_ALI_Format =>
2043 return No_ALI_Id;
2045 end Scan_ALI;
2047 ---------
2048 -- SEq --
2049 ---------
2051 function SEq (F1, F2 : String_Ptr) return Boolean is
2052 begin
2053 return F1.all = F2.all;
2054 end SEq;
2056 -----------
2057 -- SHash --
2058 -----------
2060 function SHash (S : String_Ptr) return Vindex is
2061 H : Word;
2063 begin
2064 H := 0;
2065 for J in S.all'Range loop
2066 H := H * 2 + Character'Pos (S (J));
2067 end loop;
2069 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));
2070 end SHash;
2072 end ALI;