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
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
53 'L' => True, -- linker option
54 'E' => True, -- external
55 'D' => True, -- dependency
63 procedure Initialize_ALI is
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);
74 for J in Units.First .. Units.Last loop
75 Set_Name_Table_Info (Units.Table (J).Uname, 0);
78 -- Free argument table strings
80 for J in Args.First .. Args.Last loop
81 Free (Args.Table (J));
84 -- Initialize all tables
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;
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;
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
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
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
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.
215 -- Skip rest of current line and any following blank lines.
217 procedure Skip_Space;
218 -- Skip past white space (blanks or horizontal tab)
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
237 function At_Eol return Boolean is
239 return Nextc = EOF or else Nextc = CR or else Nextc = LF;
242 ---------------------------
243 -- Check_At_End_Of_Field --
244 ---------------------------
246 procedure Check_At_End_Of_Field is
248 if not At_End_Of_Field then
249 if Ignore_Errors then
250 while Nextc > ' ' loop
257 end Check_At_End_Of_Field;
263 procedure Checkc (C : Character) is
267 elsif Ignore_Errors then
274 ------------------------
275 -- Check_Unknown_Line --
276 ------------------------
278 procedure Check_Unknown_Line is
280 while C not in 'A' .. 'Z'
281 or else not Known_ALI_Lines (C)
283 if C = CR or else C = LF then
289 elsif Ignore_Errors then
297 end Check_Unknown_Line;
303 procedure Fatal_Error is
308 procedure Wchar (C : Character);
309 -- Write a single character, replacing horizontal tab by spaces
311 procedure Wchar (C : Character) is
316 exit when Col mod 8 = 0;
325 -- Start of processing for Fatal_Error
329 raise Bad_ALI_Format;
333 Write_Str ("fatal error: file ");
335 Write_Str (" is incorrectly formatted");
338 ("make sure you are using consistent versions of gcc/gnatbind");
341 -- Find start of line
346 and then T (Ptr1 - 1) /= CR
347 and then T (Ptr1 - 1) /= LF
352 Write_Int (Int (Line));
367 and then T (Ptr2) /= CR
368 and then T (Ptr2) /= LF
380 if T (Ptr1) = HT then
392 Exit_Program (E_Fatal);
395 ------------------------
396 -- Fatal_Error_Ignore --
397 ------------------------
399 procedure Fatal_Error_Ignore is
401 if not Ignore_Errors then
404 end Fatal_Error_Ignore;
411 (Lower : Boolean := False;
412 Ignore_Spaces : Boolean := False) return Name_Id
419 if Ignore_Errors then
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) = '"';
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 = '>'
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));
459 function Get_Nat return Nat is
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';
479 function Get_Stamp return Time_Stamp_Type is
487 if Ignore_Errors then
488 return Dummy_Time_Stamp;
494 -- Following reads old style time stamp missing first two digits
496 if Nextc in '7' .. '9' then
501 -- Normal case of full year in time stamp
507 for J in Start .. T'Last loop
518 function Getc return Character is
532 function Nextc return Character is
541 procedure Skip_Eol is
546 if Ignore_Errors then
547 while not At_Eol loop
555 -- Loop to skip past blank lines (first time through skips this EOL)
557 while Nextc < ' ' and then Nextc /= EOF loop
570 procedure Skip_Line is
572 while not At_Eol loop
583 procedure Skip_Space is
585 while Nextc = ' ' or else Nextc = HT loop
601 -- Start of processing for Scan_ALI
604 -- Acquire lines to be ignored
607 Ignore := ('U' | 'W' | 'D' | 'X' => False, others => True);
609 -- Read_Lines parameter given
611 elsif Read_Lines /= "" then
612 Ignore := ('U' => False, others => True);
614 for J in Read_Lines'Range loop
615 Ignore (Read_Lines (J)) := False;
618 -- Process Ignore_Lines parameter
621 Ignore := (others => False);
623 for J in Ignore_Lines'Range loop
624 pragma Assert (Ignore_Lines (J) /= 'U');
625 Ignore (Ignore_Lines (J)) := True;
629 -- Setup ALI Table entry with appropriate defaults
633 Set_Name_Table_Info (F, Int (Id));
637 Compile_Errors => False,
638 First_Interrupt_State => Interrupt_States.Last + 1,
639 First_Sdep => No_Sdep_Id,
640 First_Unit => No_Unit_Id,
642 Last_Interrupt_State => Interrupt_States.Last,
643 Last_Sdep => No_Sdep_Id,
644 Last_Unit => No_Unit_Id,
645 Locking_Policy => ' ',
647 Main_Program => None,
649 Normalize_Scalars => False,
650 Ofile_Full_Name => Full_Object_File_Name,
651 Queuing_Policy => ' ',
652 Restrictions => Restrictions_Initial,
654 Task_Dispatching_Policy => ' ',
655 Time_Slice_Value => -1,
657 Unit_Exception_Table => False,
658 Ver => (others => ' '),
661 Zero_Cost_Exceptions => False);
663 -- Now we acquire the input lines from the ALI file. Note that the
664 -- convention in the following code is that as we enter each section,
665 -- C is set to contain the first character of the following line.
670 -- Acquire library version
674 -- The V line missing really indicates trouble, most likely it
675 -- means we don't have an ALI file at all, so here we give a
676 -- fatal error even if we are in Ignore_Errors mode.
680 elsif Ignore ('V') then
688 for J in 1 .. Ver_Len_Max loop
691 ALIs.Table (Id).Ver (J) := C;
692 ALIs.Table (Id).Ver_Len := J;
701 -- Acquire main program line if present
714 ALIs.Table (Id).Main_Program := Func;
716 ALIs.Table (Id).Main_Program := Proc;
726 ALIs.Table (Id).Main_Priority := Get_Nat;
734 ALIs.Table (Id).Time_Slice_Value := Get_Nat;
741 ALIs.Table (Id).WC_Encoding := Getc;
750 -- Acquire argument lines
752 First_Arg := Args.Last + 1;
756 exit A_Loop when C /= 'A';
765 while not At_Eol loop
766 Name_Len := Name_Len + 1;
767 Name_Buffer (Name_Len) := Getc;
771 Args.Table (Args.Last) := new String'(Name_Buffer (1 .. Name_Len));
784 if Ignore_Errors then
803 while not At_Eol loop
812 ALIs.Table (Id).Compile_Errors := True;
814 -- Processing for FD/FG/FI
817 Float_Format_Specified := Getc;
818 ALIs.Table (Id).Float_Format := Float_Format_Specified;
823 Locking_Policy_Specified := Getc;
824 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
826 -- Processing for flags starting with N
834 ALIs.Table (Id).No_Object := True;
835 No_Object_Specified := True;
840 No_Run_Time_Mode := True;
841 Configurable_Run_Time_Mode := True;
846 ALIs.Table (Id).Normalize_Scalars := True;
847 Normalize_Scalars_Specified := True;
850 -- Invalid switch starting with N
859 Queuing_Policy_Specified := Getc;
860 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
862 -- Processing for flags starting with S
870 ALIs.Table (Id).Interface := True;
875 Opt.Sec_Stack_Used := True;
877 -- Invalid switch starting with S
886 Task_Dispatching_Policy_Specified := Getc;
887 ALIs.Table (Id).Task_Dispatching_Policy :=
888 Task_Dispatching_Policy_Specified;
890 -- Processing for switch starting with U
898 Unreserve_All_Interrupts_Specified := True;
903 ALIs.Table (Id).Unit_Exception_Table := True;
905 -- Invalid switches starting with U
917 ALIs.Table (Id).Zero_Cost_Exceptions := True;
918 Zero_Cost_Exceptions_Specified := True;
932 No_Normalize_Scalars_Specified := True;
941 -- Acquire restrictions line
944 if Ignore_Errors then
958 -- Process restrictions line
961 Scan_Restrictions : declare
962 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
963 -- Save cumulative restrictions in case we have a fatal error
965 Bad_R_Line : exception;
966 -- Signal bad restrictions line
972 -- Acquire information for boolean restrictions
974 for R in All_Boolean_Restrictions loop
979 ALIs.Table (Id).Restrictions.Violated (R) := True;
980 Cumulative_Restrictions.Violated (R) := True;
983 ALIs.Table (Id).Restrictions.Set (R) := True;
984 Cumulative_Restrictions.Set (R) := True;
994 -- Skip separating space
998 -- Acquire information for parameter restrictions
1000 for RP in All_Parameter_Restrictions loop
1002 -- Acquire restrictions pragma information
1009 ALIs.Table (Id).Restrictions.Set (RP) := True;
1012 N : constant Integer := Integer (Get_Nat);
1014 ALIs.Table (Id).Restrictions.Value (RP) := N;
1016 if Cumulative_Restrictions.Set (RP) then
1017 Cumulative_Restrictions.Value (RP) :=
1019 (Cumulative_Restrictions.Value (RP), N);
1021 Cumulative_Restrictions.Set (RP) := True;
1022 Cumulative_Restrictions.Value (RP) := N;
1030 -- Acquire restrictions violations information
1037 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1038 Cumulative_Restrictions.Violated (RP) := True;
1041 N : constant Integer := Integer (Get_Nat);
1042 pragma Unsuppress (Overflow_Check);
1045 ALIs.Table (Id).Restrictions.Count (RP) := N;
1047 if RP in Checked_Max_Parameter_Restrictions then
1048 Cumulative_Restrictions.Count (RP) :=
1050 (Cumulative_Restrictions.Count (RP), N);
1052 Cumulative_Restrictions.Count (RP) :=
1053 Cumulative_Restrictions.Count (RP) + N;
1057 when Constraint_Error =>
1059 -- A constraint error comes from the addition in
1060 -- the else branch. We reset to the maximum and
1061 -- indicate that the real value is now unknown.
1063 Cumulative_Restrictions.Value (RP) := Integer'Last;
1064 Cumulative_Restrictions.Unknown (RP) := True;
1069 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1070 Cumulative_Restrictions.Unknown (RP) := True;
1080 -- Here if error during scanning of restrictions line
1085 -- In Ignore_Errors mode, undo any changes to restrictions
1086 -- from this unit, and continue on.
1088 if Ignore_Errors then
1089 Cumulative_Restrictions := Save_R;
1090 ALIs.Table (Id).Restrictions := Restrictions_Initial;
1092 -- In normal mode, this is a fatal error
1098 end Scan_Restrictions;
1101 -- Acquire 'I' lines if present
1107 if Ignore ('I') then
1113 I_State : Character;
1122 Interrupt_States.Append (
1123 (Interrupt_Id => Int_Num,
1124 Interrupt_State => I_State,
1125 IS_Pragma_Line => Line_No));
1127 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1135 -- Loop to acquire unit entries
1139 exit U_Loop when C /= 'U';
1141 -- Note: as per spec, we never ignore U lines
1145 Units.Increment_Last;
1147 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1148 ALIs.Table (Id).First_Unit := Units.Last;
1151 Units.Table (Units.Last).Uname := Get_Name;
1152 Units.Table (Units.Last).Predefined := Is_Predefined_Unit;
1153 Units.Table (Units.Last).Internal := Is_Internal_Unit;
1154 Units.Table (Units.Last).My_ALI := Id;
1155 Units.Table (Units.Last).Sfile := Get_Name (Lower => True);
1156 Units.Table (Units.Last).Pure := False;
1157 Units.Table (Units.Last).Preelab := False;
1158 Units.Table (Units.Last).No_Elab := False;
1159 Units.Table (Units.Last).Shared_Passive := False;
1160 Units.Table (Units.Last).RCI := False;
1161 Units.Table (Units.Last).Remote_Types := False;
1162 Units.Table (Units.Last).Has_RACW := False;
1163 Units.Table (Units.Last).Init_Scalars := False;
1164 Units.Table (Units.Last).Is_Generic := False;
1165 Units.Table (Units.Last).Icasing := Mixed_Case;
1166 Units.Table (Units.Last).Kcasing := All_Lower_Case;
1167 Units.Table (Units.Last).Dynamic_Elab := False;
1168 Units.Table (Units.Last).Elaborate_Body := False;
1169 Units.Table (Units.Last).Set_Elab_Entity := False;
1170 Units.Table (Units.Last).Version := "00000000";
1171 Units.Table (Units.Last).First_With := Withs.Last + 1;
1172 Units.Table (Units.Last).First_Arg := First_Arg;
1173 Units.Table (Units.Last).Elab_Position := 0;
1174 Units.Table (Units.Last).Interface := ALIs.Table (Id).Interface;
1176 if Debug_Flag_U then
1177 Write_Str (" ----> reading unit ");
1178 Write_Int (Int (Units.Last));
1180 Write_Unit_Name (Units.Table (Units.Last).Uname);
1181 Write_Str (" from file ");
1182 Write_Name (Units.Table (Units.Last).Sfile);
1186 -- Check for duplicated unit in different files
1189 Info : constant Int := Get_Name_Table_Info
1190 (Units.Table (Units.Last).Uname);
1193 and then Units.Table (Units.Last).Sfile /=
1194 Units.Table (Unit_Id (Info)).Sfile
1196 -- If Err is set then ignore duplicate unit name. This is the
1197 -- case of a call from gnatmake, where the situation can arise
1198 -- from substitution of source files. In such situations, the
1199 -- processing in gnatmake will always result in any required
1200 -- recompilations in any case, and if we consider this to be
1201 -- an error we get strange cases (for example when a generic
1202 -- instantiation is replaced by a normal package) where we
1203 -- read the old ali file, decide to recompile, and then decide
1204 -- that the old and new ali files are incompatible.
1209 -- If Err is not set, then this is a fatal error. This is
1210 -- the case of being called from the binder, where we must
1211 -- definitely diagnose this as an error.
1215 Write_Str ("error: duplicate unit name: ");
1218 Write_Str ("error: unit """);
1219 Write_Unit_Name (Units.Table (Units.Last).Uname);
1220 Write_Str (""" found in file """);
1221 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1225 Write_Str ("error: unit """);
1226 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1227 Write_Str (""" found in file """);
1228 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1232 Exit_Program (E_Fatal);
1238 (Units.Table (Units.Last).Uname, Int (Units.Last));
1240 -- Scan out possible version and other parameters
1249 if C in '0' .. '9' or else C in 'a' .. 'f' then
1250 Units.Table (Units.Last).Version (1) := C;
1252 for J in 2 .. 8 loop
1254 Units.Table (Units.Last).Version (J) := C;
1257 -- BN parameter (Body needed)
1263 Check_At_End_Of_Field;
1264 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1270 -- DE parameter (Dynamic elaboration checks)
1276 Check_At_End_Of_Field;
1277 Units.Table (Units.Last).Dynamic_Elab := True;
1278 Dynamic_Elaboration_Checks_Specified := True;
1289 Units.Table (Units.Last).Elaborate_Body := True;
1291 Units.Table (Units.Last).Set_Elab_Entity := True;
1296 Check_At_End_Of_Field;
1298 -- GE parameter (generic)
1304 Check_At_End_Of_Field;
1305 Units.Table (Units.Last).Is_Generic := True;
1310 -- IL/IS/IU parameters
1316 Units.Table (Units.Last).Icasing := All_Lower_Case;
1318 Units.Table (Units.Last).Init_Scalars := True;
1319 Initialize_Scalars_Used := True;
1321 Units.Table (Units.Last).Icasing := All_Upper_Case;
1326 Check_At_End_Of_Field;
1334 Units.Table (Units.Last).Kcasing := Mixed_Case;
1336 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1341 Check_At_End_Of_Field;
1349 Units.Table (Units.Last).No_Elab := True;
1350 Check_At_End_Of_Field;
1356 -- PR/PU/PK parameters
1362 Units.Table (Units.Last).Preelab := True;
1364 Units.Table (Units.Last).Pure := True;
1366 Units.Table (Units.Last).Unit_Kind := 'p';
1371 Check_At_End_Of_Field;
1379 Units.Table (Units.Last).RCI := True;
1381 Units.Table (Units.Last).Remote_Types := True;
1383 Units.Table (Units.Last).Has_RACW := True;
1388 Check_At_End_Of_Field;
1394 Units.Table (Units.Last).Shared_Passive := True;
1396 Units.Table (Units.Last).Unit_Kind := 's';
1401 Check_At_End_Of_Field;
1411 -- Check if static elaboration model used
1413 if not Units.Table (Units.Last).Dynamic_Elab
1414 and then not Units.Table (Units.Last).Internal
1416 Static_Elaboration_Model_Used := True;
1421 -- Scan out With lines for this unit
1425 exit With_Loop when C /= 'W';
1427 if Ignore ('W') then
1433 Withs.Increment_Last;
1434 Withs.Table (Withs.Last).Uname := Get_Name;
1435 Withs.Table (Withs.Last).Elaborate := False;
1436 Withs.Table (Withs.Last).Elaborate_All := False;
1437 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1438 Withs.Table (Withs.Last).Interface := False;
1440 -- Generic case with no object file available
1443 Withs.Table (Withs.Last).Sfile := No_File;
1444 Withs.Table (Withs.Last).Afile := No_File;
1449 Withs.Table (Withs.Last).Sfile := Get_Name (Lower => True);
1450 Withs.Table (Withs.Last).Afile := Get_Name;
1452 -- Scan out possible E, EA, and NE parameters
1454 while not At_Eol loop
1460 if At_End_Of_Field then
1461 Withs.Table (Withs.Last).Elaborate := True;
1463 elsif Nextc = 'A' then
1465 Check_At_End_Of_Field;
1466 Withs.Table (Withs.Last).Elaborate_All := True;
1470 Check_At_End_Of_Field;
1472 -- Store ED indication unless ignore required
1474 if not Ignore_ED then
1475 Withs.Table (Withs.Last).Elab_All_Desirable :=
1489 Units.Table (Units.Last).Last_With := Withs.Last;
1490 Units.Table (Units.Last).Last_Arg := Args.Last;
1492 -- If there are linker options lines present, scan them
1496 Linker_Options_Loop : loop
1498 exit Linker_Options_Loop when C /= 'L';
1500 if Ignore ('L') then
1511 if C < Character'Val (16#20#)
1512 or else C > Character'Val (16#7E#)
1517 C := Character'Val (0);
1524 for J in 1 .. 2 loop
1527 if C in '0' .. '9' then
1530 Character'Pos ('0');
1532 elsif C in 'A' .. 'F' then
1535 Character'Pos ('A') +
1544 Add_Char_To_Name_Buffer (Character'Val (V));
1549 exit when Nextc /= '"';
1553 Add_Char_To_Name_Buffer (C);
1557 Add_Char_To_Name_Buffer (nul);
1562 end loop Linker_Options_Loop;
1564 -- Store the linker options entry if one was found
1566 if Name_Len /= 0 then
1567 Linker_Options.Increment_Last;
1569 Linker_Options.Table (Linker_Options.Last).Name :=
1572 Linker_Options.Table (Linker_Options.Last).Unit :=
1575 Linker_Options.Table (Linker_Options.Last).Internal_File :=
1576 Is_Internal_File_Name (F);
1578 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
1579 Linker_Options.Last;
1583 -- End loop through units for one ALI file
1585 ALIs.Table (Id).Last_Unit := Units.Last;
1586 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
1588 -- Set types of the units (there can be at most 2 of them)
1590 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
1591 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
1592 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
1595 -- Deal with body only and spec only cases, note that the reason we
1596 -- do our own checking of the name (rather than using Is_Body_Name)
1597 -- is that Uname drags in far too much compiler junk!
1599 Get_Name_String (Units.Table (Units.Last).Uname);
1601 if Name_Buffer (Name_Len) = 'b' then
1602 Units.Table (Units.Last).Utype := Is_Body_Only;
1604 Units.Table (Units.Last).Utype := Is_Spec_Only;
1608 -- Scan out external version references and put in hash table
1612 exit E_Loop when C /= 'E';
1614 if Ignore ('E') then
1630 exit when At_End_Of_Field;
1631 Add_Char_To_Name_Buffer (C);
1634 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
1641 -- Scan out source dependency lines for this ALI file
1643 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
1647 exit D_Loop when C /= 'D';
1649 if Ignore ('D') then
1655 Sdep.Increment_Last;
1656 Sdep.Table (Sdep.Last).Sfile := Get_Name (Lower => True);
1657 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
1658 Sdep.Table (Sdep.Last).Dummy_Entry :=
1659 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
1661 -- Acquire checksum value
1674 exit when At_Eol or else Ctr = 8;
1676 if Nextc in '0' .. '9' then
1678 Character'Pos (Nextc) - Character'Pos ('0');
1680 elsif Nextc in 'a' .. 'f' then
1682 Character'Pos (Nextc) - Character'Pos ('a') + 10;
1692 if Ctr = 8 and then At_End_Of_Field then
1693 Sdep.Table (Sdep.Last).Checksum := Chk;
1699 -- Acquire subunit and reference file name entries
1701 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
1702 Sdep.Table (Sdep.Last).Rfile :=
1703 Sdep.Table (Sdep.Last).Sfile;
1704 Sdep.Table (Sdep.Last).Start_Line := 1;
1709 -- Here for subunit name
1711 if Nextc not in '0' .. '9' then
1714 while not At_End_Of_Field loop
1715 Name_Len := Name_Len + 1;
1716 Name_Buffer (Name_Len) := Getc;
1719 Sdep.Table (Sdep.Last).Subunit_Name := Name_Enter;
1723 -- Here for reference file name entry
1725 if Nextc in '0' .. '9' then
1726 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
1731 while not At_End_Of_Field loop
1732 Name_Len := Name_Len + 1;
1733 Name_Buffer (Name_Len) := Getc;
1736 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
1746 ALIs.Table (Id).Last_Sdep := Sdep.Last;
1748 -- We must at this stage be at an Xref line or the end of file
1760 -- If we are ignoring Xref sections we are done (we ignore all
1761 -- remaining lines since only xref related lines follow X).
1763 if Ignore ('X') and then not Debug_Flag_X then
1767 -- Loop through Xref sections
1771 exit X_Loop when C /= 'X';
1773 -- Make new entry in section table
1775 Xref_Section.Increment_Last;
1777 Read_Refs_For_One_File : declare
1778 XS : Xref_Section_Record renames
1779 Xref_Section.Table (Xref_Section.Last);
1781 Current_File_Num : Sdep_Id;
1782 -- Keeps track of the current file number (changed by nn|)
1785 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
1786 XS.File_Name := Get_Name;
1787 XS.First_Entity := Xref_Entity.Last + 1;
1789 Current_File_Num := XS.File_Num;
1796 -- Loop through Xref entities
1798 while C /= 'X' and then C /= EOF loop
1799 Xref_Entity.Increment_Last;
1801 Read_Refs_For_One_Entity : declare
1802 XE : Xref_Entity_Record renames
1803 Xref_Entity.Table (Xref_Entity.Last);
1806 procedure Read_Instantiation_Reference;
1807 -- Acquire instantiation reference. Caller has checked
1808 -- that current character is '[' and on return the cursor
1809 -- is skipped past the corresponding closing ']'.
1811 ----------------------------------
1812 -- Read_Instantiation_Reference --
1813 ----------------------------------
1815 procedure Read_Instantiation_Reference is
1817 Xref.Increment_Last;
1820 XR : Xref_Record renames Xref.Table (Xref.Last);
1823 P := P + 1; -- skip [
1828 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1829 Current_File_Num := XR.File_Num;
1834 XR.File_Num := Current_File_Num;
1841 -- Recursive call for next reference
1844 pragma Warnings (Off); -- kill recursion warning
1845 Read_Instantiation_Reference;
1846 pragma Warnings (On);
1849 -- Skip closing bracket after recursive call
1853 end Read_Instantiation_Reference;
1855 -- Start of processing for Read_Refs_For_One_Entity
1861 XE.Lib := (Getc = '*');
1862 XE.Entity := Get_Name;
1864 Current_File_Num := XS.File_Num;
1866 -- Renaming reference is present
1870 XE.Rref_Line := Get_Nat;
1876 XE.Rref_Col := Get_Nat;
1878 -- No renaming reference present
1887 -- See if type reference present
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;
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;
1904 XE.Tref_Type := ' ';
1906 XE.Tref_Standard_Entity :=
1907 Get_Name (Ignore_Spaces => True);
1914 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1919 XE.Tref_File_Num := Current_File_Num;
1923 XE.Tref_Type := Getc;
1924 XE.Tref_Col := Get_Nat;
1925 XE.Tref_Standard_Entity := No_Name;
1928 -- ??? Temporary workaround for nested generics case:
1929 -- 4i4 Directories{1|4I9[4|6[3|3]]}
1933 Nested_Brackets : Natural := 0;
1939 Nested_Brackets := Nested_Brackets + 1;
1941 Nested_Brackets := Nested_Brackets - 1;
1943 if Nested_Brackets = 0 then
1952 P := P + 1; -- skip closing bracket
1955 -- No typeref entry present
1958 XE.Tref_File_Num := No_Sdep_Id;
1960 XE.Tref_Type := ' ';
1962 XE.Tref_Standard_Entity := No_Name;
1965 XE.First_Xref := Xref.Last + 1;
1967 -- Loop through cross-references for this entity
1974 exit when Nextc /= '.';
1978 Xref.Increment_Last;
1981 XR : Xref_Record renames Xref.Table (Xref.Last);
1988 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
1989 Current_File_Num := XR.File_Num;
1993 XR.File_Num := Current_File_Num;
1999 -- Imported entities reference as in:
2000 -- 494b<c,__gnat_copy_attribs>25
2001 -- ??? Simply skipped for now
2004 while Getc /= '>' loop
2012 Read_Instantiation_Reference;
2017 -- Record last cross-reference
2019 XE.Last_Xref := Xref.Last;
2021 end Read_Refs_For_One_Entity;
2024 -- Record last entity
2026 XS.Last_Entity := Xref_Entity.Last;
2028 end Read_Refs_For_One_File;
2033 -- Here after dealing with xref sections
2035 if C /= EOF and then C /= 'X' then
2042 when Bad_ALI_Format =>
2051 function SEq (F1, F2 : String_Ptr) return Boolean is
2053 return F1.all = F2.all;
2060 function SHash (S : String_Ptr) return Vindex is
2065 for J in S.all'Range loop
2066 H := H * 2 + Character'Pos (S (J));
2069 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));