1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
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. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Butil; use Butil;
28 with Debug; use Debug;
29 with Fname; use Fname;
30 with Namet; use Namet;
32 with Osint; use Osint;
33 with Output; use Output;
38 -- Make control characters visible
44 procedure Initialize_ALI is
46 -- When (re)initializing ALI data structures the ALI user expects to
47 -- get a fresh set of data structures. Thus we first need to erase the
48 -- marks put in the name table by the previous set of ALI routine calls.
49 -- These two loops are empty and harmless the first time in.
51 for J in ALIs.First .. ALIs.Last loop
52 Set_Name_Table_Info (ALIs.Table (J).Afile, 0);
55 for J in Units.First .. Units.Last loop
56 Set_Name_Table_Info (Units.Table (J).Uname, 0);
59 -- Free argument table strings
61 for J in Args.First .. Args.Last loop
62 Free (Args.Table (J));
65 -- Initialize all tables
77 -- Add dummy zero'th item in Linker_Options for the sort function
79 Linker_Options.Increment_Last;
81 -- Initialize global variables recording cumulative options in all
82 -- ALI files that are read for a given processing run in gnatbind.
84 Dynamic_Elaboration_Checks_Specified := False;
85 Float_Format_Specified := ' ';
86 Locking_Policy_Specified := ' ';
87 No_Normalize_Scalars_Specified := False;
88 No_Object_Specified := False;
89 Normalize_Scalars_Specified := False;
90 Queuing_Policy_Specified := ' ';
91 Static_Elaboration_Model_Used := False;
92 Task_Dispatching_Policy_Specified := ' ';
93 Unreserve_All_Interrupts_Specified := False;
94 Zero_Cost_Exceptions_Specified := False;
106 Read_Xref : Boolean := False;
107 Read_Lines : String := "";
108 Ignore_Lines : String := "X")
111 P : Text_Ptr := T'First;
112 Line : Logical_Line_Number := 1;
118 Ignore : array (Character range 'A' .. 'Z') of Boolean;
119 -- Ignore (X) is set to True if lines starting with X are to
120 -- be ignored by Scan_ALI and skipped, and False if the lines
121 -- are to be read and processed.
123 Restrictions_Initial : Rident.Restrictions_Info;
124 pragma Warnings (Off, Restrictions_Initial);
125 -- This variable, which should really be a constant (but that's not
126 -- allowed by the language) is used only for initialization, and the
127 -- reason we are declaring it is to get the default initialization
128 -- set for the object.
130 Bad_ALI_Format : exception;
131 -- Exception raised by Fatal_Error if Err is True
133 function At_Eol return Boolean;
134 -- Test if at end of line
136 function At_End_Of_Field return Boolean;
137 -- Test if at end of line, or if at blank or horizontal tab
139 procedure Check_At_End_Of_Field;
140 -- Check if we are at end of field, fatal error if not
142 procedure Checkc (C : Character);
143 -- Check next character is C. If so bump past it, if not fatal error
145 procedure Fatal_Error;
146 -- Generate fatal error message for badly formatted ALI file if
147 -- Err is false, or raise Bad_ALI_Format if Err is True.
149 function Getc return Character;
150 -- Get next character, bumping P past the character obtained
153 (Lower : Boolean := False;
154 Ignore_Spaces : Boolean := False) return Name_Id;
155 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
156 -- length in Name_Len, as well as being returned in Name_Id form).
157 -- If Lower is set to True then the Name_Buffer will be converted to
158 -- all lower case, for systems where file names are not case sensitive.
159 -- This ensures that gnatbind works correctly regardless of the case
160 -- of the file name on all systems. The name is terminated by a either
161 -- white space (when Ignore_Spaces is False) or a typeref bracket or
162 -- an equal sign except for the special case of an operator name
163 -- starting with a double quite which is terminated by another double
166 function Get_Nat return Nat;
167 -- Skip blanks, then scan out an unsigned integer value in Nat range.
169 function Get_Stamp return Time_Stamp_Type;
170 -- Skip blanks, then scan out a time stamp
172 function Nextc return Character;
173 -- Return current character without modifying pointer P
176 -- Skip past spaces, then skip past end of line (fatal error if not
177 -- at end of line). Also skips past any following blank lines.
180 -- Skip rest of current line and any following blank lines.
182 procedure Skip_Space;
183 -- Skip past white space (blanks or horizontal tab)
186 -- Skip past next character, does not affect value in C. This call
187 -- is like calling Getc and ignoring the returned result.
189 ---------------------
190 -- At_End_Of_Field --
191 ---------------------
193 function At_End_Of_Field return Boolean is
202 function At_Eol return Boolean is
204 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
207 ---------------------------
208 -- Check_At_End_Of_Field --
209 ---------------------------
211 procedure Check_At_End_Of_Field is
213 if not At_End_Of_Field then
216 end Check_At_End_Of_Field;
222 procedure Checkc (C : Character) is
235 procedure Fatal_Error is
240 procedure Wchar (C : Character);
241 -- Write a single character, replacing horizontal tab by spaces
243 procedure Wchar (C : Character) is
248 exit when Col mod 8 = 0;
257 -- Start of processing for Fatal_Error
261 raise Bad_ALI_Format;
265 Write_Str ("fatal error: file ");
267 Write_Str (" is incorrectly formatted");
270 ("make sure you are using consistent versions of gcc/gnatbind");
273 -- Find start of line
278 and then T (Ptr1 - 1) /= CR
279 and then T (Ptr1 - 1) /= LF
284 Write_Int (Int (Line));
299 and then T (Ptr2) /= CR
300 and then T (Ptr2) /= LF
312 if T (Ptr1) = HT then
324 Exit_Program (E_Fatal);
331 function Get_Name (Lower : Boolean := False;
332 Ignore_Spaces : Boolean := False) return Name_Id is
342 Name_Len := Name_Len + 1;
343 Name_Buffer (Name_Len) := Getc;
345 exit when At_End_Of_Field and not Ignore_Spaces;
347 if Name_Buffer (1) = '"' then
348 exit when Name_Len > 1 and then Name_Buffer (Name_Len) = '"';
351 exit when (At_End_Of_Field and not Ignore_Spaces)
352 or else Nextc = '(' or else Nextc = ')'
353 or else Nextc = '{' or else Nextc = '}'
354 or else Nextc = '<' or else Nextc = '>'
359 -- Convert file name to all lower case if file names are not case
360 -- sensitive. This ensures that we handle names in the canonical
361 -- lower case format, regardless of the actual case.
363 if Lower and not File_Names_Case_Sensitive then
364 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
374 function Get_Nat return Nat is
382 V := V * 10 + (Character'Pos (Getc) - Character'Pos ('0'));
383 exit when At_End_Of_Field;
384 exit when Nextc < '0' or Nextc > '9';
394 function Get_Stamp return Time_Stamp_Type is
405 -- Following reads old style time stamp missing first two digits
407 if Nextc in '7' .. '9' then
412 -- Normal case of full year in time stamp
418 for J in Start .. T'Last loop
429 function Getc return Character is
443 function Nextc return Character is
452 procedure Skip_Eol is
456 if not At_Eol then Fatal_Error; end if;
458 -- Loop to skip past blank lines (first time through skips this EOL)
460 while Nextc < ' ' and then Nextc /= EOF loop
473 procedure Skip_Line is
475 while not At_Eol loop
486 procedure Skip_Space is
488 while Nextc = ' ' or else Nextc = HT loop
504 -- Start of processing for Scan_ALI
507 -- Acquire lines to be ignored
510 Ignore := ('U' | 'W' | 'D' | 'X' => False, others => True);
512 -- Read_Lines parameter given
514 elsif Read_Lines /= "" then
515 Ignore := ('U' => False, others => True);
517 for J in Read_Lines'Range loop
518 Ignore (Read_Lines (J)) := False;
521 -- Process Ignore_Lines parameter
524 Ignore := (others => False);
526 for J in Ignore_Lines'Range loop
527 pragma Assert (Ignore_Lines (J) /= 'U');
528 Ignore (Ignore_Lines (J)) := True;
532 -- Setup ALI Table entry with appropriate defaults
536 Set_Name_Table_Info (F, Int (Id));
540 Compile_Errors => False,
541 First_Interrupt_State => Interrupt_States.Last + 1,
542 First_Sdep => No_Sdep_Id,
543 First_Unit => No_Unit_Id,
545 Last_Interrupt_State => Interrupt_States.Last,
546 Last_Sdep => No_Sdep_Id,
547 Last_Unit => No_Unit_Id,
548 Locking_Policy => ' ',
550 Main_Program => None,
552 Normalize_Scalars => False,
553 Ofile_Full_Name => Full_Object_File_Name,
554 Queuing_Policy => ' ',
555 Restrictions => Restrictions_Initial,
557 Task_Dispatching_Policy => ' ',
558 Time_Slice_Value => -1,
560 Unit_Exception_Table => False,
561 Ver => (others => ' '),
564 Zero_Cost_Exceptions => False);
566 -- Now we acquire the input lines from the ALI file. Note that the
567 -- convention in the following code is that as we enter each section,
568 -- C is set to contain the first character of the following line.
572 -- Acquire library version
577 elsif Ignore ('V') then
585 for J in 1 .. Ver_Len_Max loop
588 ALIs.Table (Id).Ver (J) := C;
589 ALIs.Table (Id).Ver_Len := J;
597 -- Acquire main program line if present
610 ALIs.Table (Id).Main_Program := Func;
612 ALIs.Table (Id).Main_Program := Proc;
622 ALIs.Table (Id).Main_Priority := Get_Nat;
630 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
637 ALIs.Table (Id).WC_Encoding := Getc;
646 -- Acquire argument lines
648 First_Arg := Args.Last + 1;
650 Arg_Loop : while C = 'A' loop
658 while not At_Eol loop
659 Name_Len := Name_Len + 1;
660 Name_Buffer (Name_Len) := Getc;
664 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
677 elsif Ignore ('P') then
683 while not At_Eol loop
692 ALIs.Table (Id).Compile_Errors := True;
694 -- Processing for FD/FG/FI
697 Float_Format_Specified := Getc;
698 ALIs.Table (Id).Float_Format := Float_Format_Specified;
703 Locking_Policy_Specified := Getc;
704 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
706 -- Processing for flags starting with N
714 ALIs.Table (Id).No_Object := True;
715 No_Object_Specified := True;
720 No_Run_Time_Mode := True;
721 Configurable_Run_Time_Mode := True;
726 ALIs.Table (Id).Normalize_Scalars := True;
727 Normalize_Scalars_Specified := True;
730 -- Invalid switch starting with N
739 Queuing_Policy_Specified := Getc;
740 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
742 -- Processing for flags starting with S
750 ALIs.Table (Id).Interface := True;
755 Opt.Sec_Stack_Used := True;
757 -- Invalid switch starting with S
766 Task_Dispatching_Policy_Specified := Getc;
767 ALIs.Table (Id).Task_Dispatching_Policy :=
768 Task_Dispatching_Policy_Specified;
770 -- Processing for switch starting with U
778 Unreserve_All_Interrupts_Specified := True;
783 ALIs.Table (Id).Unit_Exception_Table := True;
785 -- Invalid switches starting with U
795 ALIs.Table (Id).Zero_Cost_Exceptions := True;
796 Zero_Cost_Exceptions_Specified := True;
804 No_Normalize_Scalars_Specified := True;
812 -- Acquire first restrictions line
817 elsif Ignore ('R') then
824 for R in All_Boolean_Restrictions loop
829 ALIs.Table (Id).Restrictions.Violated (R) := True;
830 Cumulative_Restrictions.Violated (R) := True;
833 ALIs.Table (Id).Restrictions.Set (R) := True;
834 Cumulative_Restrictions.Set (R) := True;
849 -- See if we have a second R line
853 -- If not, just ignore, and leave the restrictions variables
854 -- unchanged. This is useful for dealing with old format ALI
855 -- files with only one R line (this can be removed later on,
856 -- but is useful for transitional purposes).
860 -- Here we have a second R line, ignore it if ignore flag set
862 elsif Ignore ('R') then
866 -- Otherwise acquire second R line
872 for RP in All_Parameter_Restrictions loop
874 -- Acquire restrictions pragma information
881 ALIs.Table (Id).Restrictions.Set (RP) := True;
884 N : constant Integer := Integer (Get_Nat);
886 ALIs.Table (Id).Restrictions.Value (RP) := N;
888 if Cumulative_Restrictions.Set (RP) then
889 Cumulative_Restrictions.Value (RP) :=
890 Integer'Min (Cumulative_Restrictions.Value (RP), N);
892 Cumulative_Restrictions.Set (RP) := True;
893 Cumulative_Restrictions.Value (RP) := N;
901 -- Acquire restrictions violations information
908 ALIs.Table (Id).Restrictions.Violated (RP) := True;
909 Cumulative_Restrictions.Violated (RP) := True;
912 N : constant Integer := Integer (Get_Nat);
913 pragma Unsuppress (Overflow_Check);
916 ALIs.Table (Id).Restrictions.Count (RP) := N;
918 if RP in Checked_Max_Parameter_Restrictions then
919 Cumulative_Restrictions.Count (RP) :=
920 Integer'Max (Cumulative_Restrictions.Count (RP), N);
922 Cumulative_Restrictions.Count (RP) :=
923 Cumulative_Restrictions.Count (RP) + N;
927 when Constraint_Error =>
929 -- A constraint error comes from the addition in
930 -- the else branch. We reset to the maximum and
931 -- indicate that the real value is now unknown.
933 Cumulative_Restrictions.Value (RP) := Integer'Last;
934 Cumulative_Restrictions.Unknown (RP) := True;
939 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
940 Cumulative_Restrictions.Unknown (RP) := True;
952 -- Acquire 'I' lines if present
970 Interrupt_States.Append (
971 (Interrupt_Id => Int_Num,
972 Interrupt_State => I_State,
973 IS_Pragma_Line => Line_No));
975 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
983 -- Loop to acquire unit entries
985 Unit_Loop : while C = 'U' loop
987 -- Note: as per spec, we never ignore U lines
991 Units.Increment_Last;
993 if ALIs.Table (Id).First_Unit = No_Unit_Id then
994 ALIs.Table (Id).First_Unit := Units.Last;
997 Units.Table (Units.Last).Uname := Get_Name;
998 Units.Table (Units.Last).Predefined := Is_Predefined_Unit;
999 Units.Table (Units.Last).Internal := Is_Internal_Unit;
1000 Units.Table (Units.Last).My_ALI := Id;
1001 Units.Table (Units.Last).Sfile := Get_Name (Lower => True);
1002 Units.Table (Units.Last).Pure := False;
1003 Units.Table (Units.Last).Preelab := False;
1004 Units.Table (Units.Last).No_Elab := False;
1005 Units.Table (Units.Last).Shared_Passive := False;
1006 Units.Table (Units.Last).RCI := False;
1007 Units.Table (Units.Last).Remote_Types := False;
1008 Units.Table (Units.Last).Has_RACW := False;
1009 Units.Table (Units.Last).Init_Scalars := False;
1010 Units.Table (Units.Last).Is_Generic := False;
1011 Units.Table (Units.Last).Icasing := Mixed_Case;
1012 Units.Table (Units.Last).Kcasing := All_Lower_Case;
1013 Units.Table (Units.Last).Dynamic_Elab := False;
1014 Units.Table (Units.Last).Elaborate_Body := False;
1015 Units.Table (Units.Last).Set_Elab_Entity := False;
1016 Units.Table (Units.Last).Version := "00000000";
1017 Units.Table (Units.Last).First_With := Withs.Last + 1;
1018 Units.Table (Units.Last).First_Arg := First_Arg;
1019 Units.Table (Units.Last).Elab_Position := 0;
1020 Units.Table (Units.Last).Interface := ALIs.Table (Id).Interface;
1022 if Debug_Flag_U then
1023 Write_Str (" ----> reading unit ");
1024 Write_Int (Int (Units.Last));
1026 Write_Unit_Name (Units.Table (Units.Last).Uname);
1027 Write_Str (" from file ");
1028 Write_Name (Units.Table (Units.Last).Sfile);
1032 -- Check for duplicated unit in different files
1035 Info : constant Int := Get_Name_Table_Info
1036 (Units.Table (Units.Last).Uname);
1039 and then Units.Table (Units.Last).Sfile /=
1040 Units.Table (Unit_Id (Info)).Sfile
1042 -- If Err is set then ignore duplicate unit name. This is the
1043 -- case of a call from gnatmake, where the situation can arise
1044 -- from substitution of source files. In such situations, the
1045 -- processing in gnatmake will always result in any required
1046 -- recompilations in any case, and if we consider this to be
1047 -- an error we get strange cases (for example when a generic
1048 -- instantiation is replaced by a normal package) where we
1049 -- read the old ali file, decide to recompile, and then decide
1050 -- that the old and new ali files are incompatible.
1055 -- If Err is not set, then this is a fatal error. This is
1056 -- the case of being called from the binder, where we must
1057 -- definitely diagnose this as an error.
1061 Write_Str ("error: duplicate unit name: ");
1064 Write_Str ("error: unit """);
1065 Write_Unit_Name (Units.Table (Units.Last).Uname);
1066 Write_Str (""" found in file """);
1067 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1071 Write_Str ("error: unit """);
1072 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1073 Write_Str (""" found in file """);
1074 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1078 Exit_Program (E_Fatal);
1084 (Units.Table (Units.Last).Uname, Int (Units.Last));
1086 -- Scan out possible version and other parameters
1095 if C in '0' .. '9' or else C in 'a' .. 'f' then
1096 Units.Table (Units.Last).Version (1) := C;
1098 for J in 2 .. 8 loop
1100 Units.Table (Units.Last).Version (J) := C;
1103 -- BN parameter (Body needed)
1107 Check_At_End_Of_Field;
1108 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1110 -- DE parameter (Dynamic elaboration checks
1114 Check_At_End_Of_Field;
1115 Units.Table (Units.Last).Dynamic_Elab := True;
1116 Dynamic_Elaboration_Checks_Specified := True;
1124 Units.Table (Units.Last).Elaborate_Body := True;
1127 Units.Table (Units.Last).Set_Elab_Entity := True;
1133 Check_At_End_Of_Field;
1135 -- GE parameter (generic)
1139 Check_At_End_Of_Field;
1140 Units.Table (Units.Last).Is_Generic := True;
1142 -- IL/IS/IU parameters
1148 Units.Table (Units.Last).Icasing := All_Lower_Case;
1151 Units.Table (Units.Last).Init_Scalars := True;
1152 Initialize_Scalars_Used := True;
1155 Units.Table (Units.Last).Icasing := All_Upper_Case;
1161 Check_At_End_Of_Field;
1169 Units.Table (Units.Last).Kcasing := Mixed_Case;
1172 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1178 Check_At_End_Of_Field;
1184 Units.Table (Units.Last).No_Elab := True;
1185 Check_At_End_Of_Field;
1187 -- PR/PU/PK parameters
1192 -- PR parameter (preelaborate)
1195 Units.Table (Units.Last).Preelab := True;
1197 -- PU parameter (pure)
1200 Units.Table (Units.Last).Pure := True;
1202 -- PK indicates unit is package
1205 Units.Table (Units.Last).Unit_Kind := 'p';
1211 Check_At_End_Of_Field;
1218 -- RC parameter (remote call interface)
1221 Units.Table (Units.Last).RCI := True;
1223 -- RT parameter (remote types)
1226 Units.Table (Units.Last).Remote_Types := True;
1228 -- RA parameter (remote access to class wide type)
1231 Units.Table (Units.Last).Has_RACW := True;
1237 Check_At_End_Of_Field;
1242 -- SP parameter (shared passive)
1245 Units.Table (Units.Last).Shared_Passive := True;
1247 -- SU parameter indicates unit is subprogram
1250 Units.Table (Units.Last).Unit_Kind := 's';
1256 Check_At_End_Of_Field;
1265 -- Check if static elaboration model used
1267 if not Units.Table (Units.Last).Dynamic_Elab
1268 and then not Units.Table (Units.Last).Internal
1270 Static_Elaboration_Model_Used := True;
1275 -- Scan out With lines for this unit
1277 With_Loop : while C = 'W' loop
1278 if Ignore ('W') then
1284 Withs.Increment_Last;
1285 Withs.Table (Withs.Last).Uname := Get_Name;
1286 Withs.Table (Withs.Last).Elaborate := False;
1287 Withs.Table (Withs.Last).Elaborate_All := False;
1288 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1289 Withs.Table (Withs.Last).Interface := False;
1291 -- Generic case with no object file available
1294 Withs.Table (Withs.Last).Sfile := No_File;
1295 Withs.Table (Withs.Last).Afile := No_File;
1300 Withs.Table (Withs.Last).Sfile := Get_Name (Lower => True);
1301 Withs.Table (Withs.Last).Afile := Get_Name;
1303 -- Scan out possible E, EA, and NE parameters
1305 while not At_Eol loop
1311 if At_End_Of_Field then
1312 Withs.Table (Withs.Last).Elaborate := True;
1314 elsif Nextc = 'A' then
1316 Check_At_End_Of_Field;
1317 Withs.Table (Withs.Last).Elaborate_All := True;
1321 Check_At_End_Of_Field;
1323 -- Store ED indication unless ignore required
1325 if not Ignore_ED then
1326 Withs.Table (Withs.Last).Elab_All_Desirable :=
1340 Units.Table (Units.Last).Last_With := Withs.Last;
1341 Units.Table (Units.Last).Last_Arg := Args.Last;
1343 -- If there are linker options lines present, scan them
1347 Linker_Options_Loop : while C = 'L' loop
1349 if Ignore ('L') then
1360 if C < Character'Val (16#20#)
1361 or else C > Character'Val (16#7E#)
1366 C := Character'Val (0);
1373 for J in 1 .. 2 loop
1376 if C in '0' .. '9' then
1379 Character'Pos ('0');
1381 elsif C in 'A' .. 'F' then
1384 Character'Pos ('A') +
1393 Add_Char_To_Name_Buffer (Character'Val (V));
1398 exit when Nextc /= '"';
1402 Add_Char_To_Name_Buffer (C);
1406 Add_Char_To_Name_Buffer (nul);
1411 end loop Linker_Options_Loop;
1413 -- Store the linker options entry if one was found
1415 if Name_Len /= 0 then
1416 Linker_Options.Increment_Last;
1418 Linker_Options.Table (Linker_Options.Last).Name :=
1421 Linker_Options.Table (Linker_Options.Last).Unit :=
1424 Linker_Options.Table (Linker_Options.Last).Internal_File :=
1425 Is_Internal_File_Name (F);
1427 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
1428 Linker_Options.Last;
1432 -- End loop through units for one ALI file
1434 ALIs.Table (Id).Last_Unit := Units.Last;
1435 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
1437 -- Set types of the units (there can be at most 2 of them)
1439 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
1440 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
1441 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
1444 -- Deal with body only and spec only cases, note that the reason we
1445 -- do our own checking of the name (rather than using Is_Body_Name)
1446 -- is that Uname drags in far too much compiler junk!
1448 Get_Name_String (Units.Table (Units.Last).Uname);
1450 if Name_Buffer (Name_Len) = 'b' then
1451 Units.Table (Units.Last).Utype := Is_Body_Only;
1453 Units.Table (Units.Last).Utype := Is_Spec_Only;
1457 -- Scan out external version references and put in hash table
1460 if Ignore ('E') then
1476 exit when At_End_Of_Field;
1477 Add_Char_To_Name_Buffer (C);
1480 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
1487 -- Scan out source dependency lines for this ALI file
1489 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
1492 if Ignore ('D') then
1498 Sdep.Increment_Last;
1499 Sdep.Table (Sdep.Last).Sfile := Get_Name (Lower => True);
1500 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
1501 Sdep.Table (Sdep.Last).Dummy_Entry :=
1502 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
1504 -- Acquire checksum value
1517 exit when At_Eol or else Ctr = 8;
1519 if Nextc in '0' .. '9' then
1521 Character'Pos (Nextc) - Character'Pos ('0');
1523 elsif Nextc in 'a' .. 'f' then
1525 Character'Pos (Nextc) - Character'Pos ('a') + 10;
1535 if Ctr = 8 and then At_End_Of_Field then
1536 Sdep.Table (Sdep.Last).Checksum := Chk;
1542 -- Acquire subunit and reference file name entries
1544 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
1545 Sdep.Table (Sdep.Last).Rfile :=
1546 Sdep.Table (Sdep.Last).Sfile;
1547 Sdep.Table (Sdep.Last).Start_Line := 1;
1552 -- Here for subunit name
1554 if Nextc not in '0' .. '9' then
1557 while not At_End_Of_Field loop
1558 Name_Len := Name_Len + 1;
1559 Name_Buffer (Name_Len) := Getc;
1562 Sdep.Table (Sdep.Last).Subunit_Name := Name_Enter;
1566 -- Here for reference file name entry
1568 if Nextc in '0' .. '9' then
1569 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
1574 while not At_End_Of_Field loop
1575 Name_Len := Name_Len + 1;
1576 Name_Buffer (Name_Len) := Getc;
1579 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
1589 ALIs.Table (Id).Last_Sdep := Sdep.Last;
1591 -- We must at this stage be at an Xref line or the end of file
1593 if C /= EOF and then C /= 'X' then
1597 -- If we are ignoring Xref sections we are done (we ignore all
1598 -- remaining lines since only xref related lines follow X).
1600 if Ignore ('X') and then not Debug_Flag_X then
1604 -- Loop through Xref sections
1608 -- Make new entry in section table
1610 Xref_Section.Increment_Last;
1612 Read_Refs_For_One_File : declare
1613 XS : Xref_Section_Record renames
1614 Xref_Section.Table (Xref_Section.Last);
1616 Current_File_Num : Sdep_Id;
1617 -- Keeps track of the current file number (changed by nn|)
1620 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
1621 XS.File_Name := Get_Name;
1622 XS.First_Entity := Xref_Entity.Last + 1;
1624 Current_File_Num := XS.File_Num;
1631 -- Loop through Xref entities
1633 while C /= 'X' and then C /= EOF loop
1634 Xref_Entity.Increment_Last;
1636 Read_Refs_For_One_Entity : declare
1637 XE : Xref_Entity_Record renames
1638 Xref_Entity.Table (Xref_Entity.Last);
1641 procedure Read_Instantiation_Reference;
1642 -- Acquire instantiation reference. Caller has checked
1643 -- that current character is '[' and on return the cursor
1644 -- is skipped past the corresponding closing ']'.
1646 ----------------------------------
1647 -- Read_Instantiation_Reference --
1648 ----------------------------------
1650 procedure Read_Instantiation_Reference is
1652 Xref.Increment_Last;
1655 XR : Xref_Record renames Xref.Table (Xref.Last);
1658 P := P + 1; -- skip [
1663 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1664 Current_File_Num := XR.File_Num;
1669 XR.File_Num := Current_File_Num;
1676 -- Recursive call for next reference
1679 pragma Warnings (Off); -- kill recursion warning
1680 Read_Instantiation_Reference;
1681 pragma Warnings (On);
1684 -- Skip closing bracket after recursive call
1688 end Read_Instantiation_Reference;
1690 -- Start of processing for Read_Refs_For_One_Entity
1696 XE.Lib := (Getc = '*');
1697 XE.Entity := Get_Name;
1699 Current_File_Num := XS.File_Num;
1701 -- Renaming reference is present
1705 XE.Rref_Line := Get_Nat;
1711 XE.Rref_Col := Get_Nat;
1713 -- No renaming reference present
1722 -- See if type reference present
1725 when '<' => XE.Tref := Tref_Derived;
1726 when '(' => XE.Tref := Tref_Access;
1727 when '{' => XE.Tref := Tref_Type;
1728 when others => XE.Tref := Tref_None;
1731 -- Case of typeref field present
1733 if XE.Tref /= Tref_None then
1734 P := P + 1; -- skip opening bracket
1736 if Nextc in 'a' .. 'z' then
1737 XE.Tref_File_Num := No_Sdep_Id;
1739 XE.Tref_Type := ' ';
1741 XE.Tref_Standard_Entity :=
1742 Get_Name (Ignore_Spaces => True);
1749 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1754 XE.Tref_File_Num := Current_File_Num;
1758 XE.Tref_Type := Getc;
1759 XE.Tref_Col := Get_Nat;
1760 XE.Tref_Standard_Entity := No_Name;
1763 -- ??? Temporary workaround for nested generics case:
1764 -- 4i4 Directories{1|4I9[4|6[3|3]]}
1768 Nested_Brackets : Natural := 0;
1774 Nested_Brackets := Nested_Brackets + 1;
1776 Nested_Brackets := Nested_Brackets - 1;
1778 if Nested_Brackets = 0 then
1787 P := P + 1; -- skip closing bracket
1790 -- No typeref entry present
1793 XE.Tref_File_Num := No_Sdep_Id;
1795 XE.Tref_Type := ' ';
1797 XE.Tref_Standard_Entity := No_Name;
1800 XE.First_Xref := Xref.Last + 1;
1802 -- Loop through cross-references for this entity
1809 exit when Nextc /= '.';
1813 Xref.Increment_Last;
1816 XR : Xref_Record renames Xref.Table (Xref.Last);
1823 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1824 Current_File_Num := XR.File_Num;
1828 XR.File_Num := Current_File_Num;
1834 -- Imported entities reference as in:
1835 -- 494b<c,__gnat_copy_attribs>25
1836 -- ??? Simply skipped for now
1839 while Getc /= '>' loop
1847 Read_Instantiation_Reference;
1852 -- Record last cross-reference
1854 XE.Last_Xref := Xref.Last;
1856 end Read_Refs_For_One_Entity;
1859 -- Record last entity
1861 XS.Last_Entity := Xref_Entity.Last;
1863 end Read_Refs_For_One_File;
1868 -- Here after dealing with xref sections
1870 if C /= EOF and then C /= 'X' then
1877 when Bad_ALI_Format =>
1886 function SEq (F1, F2 : String_Ptr) return Boolean is
1888 return F1.all = F2.all;
1895 function SHash (S : String_Ptr) return Vindex is
1900 for J in S.all'Range loop
1901 H := H * 2 + Character'Pos (S (J));
1904 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));