1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 1992-2006, 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, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, 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
57 'S' => True, -- specific dispatching
64 procedure Initialize_ALI
is
66 -- When (re)initializing ALI data structures the ALI user expects to
67 -- get a fresh set of data structures. Thus we first need to erase the
68 -- marks put in the name table by the previous set of ALI routine calls.
69 -- These two loops are empty and harmless the first time in.
71 for J
in ALIs
.First
.. ALIs
.Last
loop
72 Set_Name_Table_Info
(ALIs
.Table
(J
).Afile
, 0);
75 for J
in Units
.First
.. Units
.Last
loop
76 Set_Name_Table_Info
(Units
.Table
(J
).Uname
, 0);
79 -- Free argument table strings
81 for J
in Args
.First
.. Args
.Last
loop
82 Free
(Args
.Table
(J
));
85 -- Initialize all tables
98 -- Add dummy zero'th item in Linker_Options for the sort function
100 Linker_Options
.Increment_Last
;
102 -- Initialize global variables recording cumulative options in all
103 -- ALI files that are read for a given processing run in gnatbind.
105 Dynamic_Elaboration_Checks_Specified
:= False;
106 Float_Format_Specified
:= ' ';
107 Locking_Policy_Specified
:= ' ';
108 No_Normalize_Scalars_Specified
:= False;
109 No_Object_Specified
:= False;
110 Normalize_Scalars_Specified
:= False;
111 Queuing_Policy_Specified
:= ' ';
112 Static_Elaboration_Model_Used
:= False;
113 Task_Dispatching_Policy_Specified
:= ' ';
114 Unreserve_All_Interrupts_Specified
:= False;
115 Zero_Cost_Exceptions_Specified
:= False;
127 Read_Xref
: Boolean := False;
128 Read_Lines
: String := "";
129 Ignore_Lines
: String := "X";
130 Ignore_Errors
: Boolean := False) return ALI_Id
132 P
: Text_Ptr
:= T
'First;
133 Line
: Logical_Line_Number
:= 1;
139 Ignore
: array (Character range 'A' .. 'Z') of Boolean;
140 -- Ignore (X) is set to True if lines starting with X are to
141 -- be ignored by Scan_ALI and skipped, and False if the lines
142 -- are to be read and processed.
144 Bad_ALI_Format
: exception;
145 -- Exception raised by Fatal_Error if Err is True
147 function At_Eol
return Boolean;
148 -- Test if at end of line
150 function At_End_Of_Field
return Boolean;
151 -- Test if at end of line, or if at blank or horizontal tab
153 procedure Check_At_End_Of_Field
;
154 -- Check if we are at end of field, fatal error if not
156 procedure Checkc
(C
: Character);
157 -- Check next character is C. If so bump past it, if not fatal error
159 procedure Check_Unknown_Line
;
160 -- If Ignore_Errors mode, then checks C to make sure that it is not
161 -- an unknown ALI line type characters, and if so, skips lines
162 -- until the first character of the line is one of these characters,
163 -- at which point it does a Getc to put that character in C. The
164 -- call has no effect if C is already an appropriate character.
165 -- If not in Ignore_Errors mode, a fatal error is signalled if the
166 -- line is unknown. Note that if C is an EOL on entry, the line is
167 -- skipped (it is assumed that blank lines are never significant).
168 -- If C is EOF on entry, the call has no effect (it is assumed that
169 -- the caller will properly handle this case).
171 procedure Fatal_Error
;
172 -- Generate fatal error message for badly formatted ALI file if
173 -- Err is false, or raise Bad_ALI_Format if Err is True.
175 procedure Fatal_Error_Ignore
;
176 pragma Inline
(Fatal_Error_Ignore
);
177 -- In Ignore_Errors mode, has no effect, otherwise same as Fatal_Error
179 function Getc
return Character;
180 -- Get next character, bumping P past the character obtained
183 (Lower
: Boolean := False;
184 Ignore_Spaces
: Boolean := False) return Name_Id
;
185 -- Skip blanks, then scan out a name (name is left in Name_Buffer with
186 -- length in Name_Len, as well as being returned in Name_Id form).
187 -- If Lower is set to True then the Name_Buffer will be converted to
188 -- all lower case, for systems where file names are not case sensitive.
189 -- This ensures that gnatbind works correctly regardless of the case
190 -- of the file name on all systems. The name is terminated by a either
191 -- white space (when Ignore_Spaces is False) or a typeref bracket or
192 -- an equal sign except for the special case of an operator name
193 -- starting with a double quite which is terminated by another double
194 -- quote. This function handles wide characters properly.
196 function Get_Nat
return Nat
;
197 -- Skip blanks, then scan out an unsigned integer value in Nat range
199 function Get_Stamp
return Time_Stamp_Type
;
200 -- Skip blanks, then scan out a time stamp
202 function Nextc
return Character;
203 -- Return current character without modifying pointer P
205 procedure Get_Typeref
206 (Current_File_Num
: Sdep_Id
;
208 File_Num
: out Sdep_Id
;
210 Ref_Type
: out Character;
212 Standard_Entity
: out Name_Id
);
213 -- Parse the definition of a typeref (<...>, {...} or (...))
216 -- Skip past spaces, then skip past end of line (fatal error if not
217 -- at end of line). Also skips past any following blank lines.
220 -- Skip rest of current line and any following blank lines
222 procedure Skip_Space
;
223 -- Skip past white space (blanks or horizontal tab)
226 -- Skip past next character, does not affect value in C. This call
227 -- is like calling Getc and ignoring the returned result.
229 ---------------------
230 -- At_End_Of_Field --
231 ---------------------
233 function At_End_Of_Field
return Boolean is
242 function At_Eol
return Boolean is
244 return Nextc
= EOF
or else Nextc
= CR
or else Nextc
= LF
;
247 ---------------------------
248 -- Check_At_End_Of_Field --
249 ---------------------------
251 procedure Check_At_End_Of_Field
is
253 if not At_End_Of_Field
then
254 if Ignore_Errors
then
255 while Nextc
> ' ' loop
262 end Check_At_End_Of_Field
;
264 ------------------------
265 -- Check_Unknown_Line --
266 ------------------------
268 procedure Check_Unknown_Line
is
270 while C
not in 'A' .. 'Z'
271 or else not Known_ALI_Lines
(C
)
273 if C
= CR
or else C
= LF
then
280 elsif Ignore_Errors
then
288 end Check_Unknown_Line
;
294 procedure Checkc
(C
: Character) is
298 elsif Ignore_Errors
then
309 procedure Fatal_Error
is
314 procedure Wchar
(C
: Character);
315 -- Write a single character, replacing horizontal tab by spaces
317 procedure Wchar
(C
: Character) is
322 exit when Col
mod 8 = 0;
331 -- Start of processing for Fatal_Error
335 raise Bad_ALI_Format
;
339 Write_Str
("fatal error: file ");
341 Write_Str
(" is incorrectly formatted");
344 ("make sure you are using consistent versions of gcc/gnatbind");
347 -- Find start of line
352 and then T
(Ptr1
- 1) /= CR
353 and then T
(Ptr1
- 1) /= LF
358 Write_Int
(Int
(Line
));
373 and then T
(Ptr2
) /= CR
374 and then T
(Ptr2
) /= LF
386 if T
(Ptr1
) = HT
then
398 Exit_Program
(E_Fatal
);
401 ------------------------
402 -- Fatal_Error_Ignore --
403 ------------------------
405 procedure Fatal_Error_Ignore
is
407 if not Ignore_Errors
then
410 end Fatal_Error_Ignore
;
417 (Lower
: Boolean := False;
418 Ignore_Spaces
: Boolean := False) return Name_Id
425 if Ignore_Errors
then
433 Name_Len
:= Name_Len
+ 1;
434 Name_Buffer
(Name_Len
) := Getc
;
436 exit when At_End_Of_Field
and not Ignore_Spaces
;
438 if Name_Buffer
(1) = '"' then
439 exit when Name_Len
> 1 and then Name_Buffer
(Name_Len
) = '"';
442 -- Terminate on parens or angle brackets or equal sign
444 exit when Nextc
= '(' or else Nextc
= ')'
445 or else Nextc
= '{' or else Nextc
= '}'
446 or else Nextc
= '<' or else Nextc
= '>'
449 -- Terminate if left bracket not part of wide char sequence
450 -- Note that we only recognize brackets notation so far ???
452 exit when Nextc
= '[' and then T
(P
+ 1) /= '"';
454 -- Terminate if right bracket not part of wide char sequence
456 exit when Nextc
= ']' and then T
(P
- 1) /= '"';
460 -- Convert file name to all lower case if file names are not case
461 -- sensitive. This ensures that we handle names in the canonical
462 -- lower case format, regardless of the actual case.
464 if Lower
and not File_Names_Case_Sensitive
then
465 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
475 function Get_Nat
return Nat
is
483 V
:= V
* 10 + (Character'Pos (Getc
) - Character'Pos ('0'));
484 exit when At_End_Of_Field
;
485 exit when Nextc
< '0' or Nextc
> '9';
495 function Get_Stamp
return Time_Stamp_Type
is
503 if Ignore_Errors
then
504 return Dummy_Time_Stamp
;
510 -- Following reads old style time stamp missing first two digits
512 if Nextc
in '7' .. '9' then
517 -- Normal case of full year in time stamp
523 for J
in Start
.. T
'Last loop
534 procedure Get_Typeref
535 (Current_File_Num
: Sdep_Id
;
537 File_Num
: out Sdep_Id
;
539 Ref_Type
: out Character;
541 Standard_Entity
: out Name_Id
)
546 when '<' => Ref
:= Tref_Derived
;
547 when '(' => Ref
:= Tref_Access
;
548 when '{' => Ref
:= Tref_Type
;
549 when others => Ref
:= Tref_None
;
552 -- Case of typeref field present
554 if Ref
/= Tref_None
then
555 P
:= P
+ 1; -- skip opening bracket
557 if Nextc
in 'a' .. 'z' then
558 File_Num
:= No_Sdep_Id
;
562 Standard_Entity
:= Get_Name
(Ignore_Spaces
=> True);
567 File_Num
:= Sdep_Id
(N
+ Nat
(First_Sdep_Entry
) - 1);
571 File_Num
:= Current_File_Num
;
577 Standard_Entity
:= No_Name
;
580 -- ??? Temporary workaround for nested generics case:
581 -- 4i4 Directories{1|4I9[4|6[3|3]]}
585 Nested_Brackets
: Natural := 0;
591 Nested_Brackets
:= Nested_Brackets
+ 1;
593 Nested_Brackets
:= Nested_Brackets
- 1;
595 if Nested_Brackets
= 0 then
604 P
:= P
+ 1; -- skip closing bracket
607 -- No typeref entry present
610 File_Num
:= No_Sdep_Id
;
614 Standard_Entity
:= No_Name
;
622 function Getc
return Character is
636 function Nextc
return Character is
645 procedure Skip_Eol
is
650 if Ignore_Errors
then
651 while not At_Eol
loop
659 -- Loop to skip past blank lines (first time through skips this EOL)
661 while Nextc
< ' ' and then Nextc
/= EOF
loop
674 procedure Skip_Line
is
676 while not At_Eol
loop
687 procedure Skip_Space
is
689 while Nextc
= ' ' or else Nextc
= HT
loop
705 -- Start of processing for Scan_ALI
708 First_Sdep_Entry
:= Sdep
.Last
+ 1;
710 -- Acquire lines to be ignored
713 Ignore
:= ('U' |
'W' |
'D' |
'X' => False, others => True);
715 -- Read_Lines parameter given
717 elsif Read_Lines
/= "" then
718 Ignore
:= ('U' => False, others => True);
720 for J
in Read_Lines
'Range loop
721 Ignore
(Read_Lines
(J
)) := False;
724 -- Process Ignore_Lines parameter
727 Ignore
:= (others => False);
729 for J
in Ignore_Lines
'Range loop
730 pragma Assert
(Ignore_Lines
(J
) /= 'U');
731 Ignore
(Ignore_Lines
(J
)) := True;
735 -- Setup ALI Table entry with appropriate defaults
739 Set_Name_Table_Info
(F
, Int
(Id
));
743 Compile_Errors
=> False,
744 First_Interrupt_State
=> Interrupt_States
.Last
+ 1,
745 First_Sdep
=> No_Sdep_Id
,
746 First_Specific_Dispatching
=> Specific_Dispatching
.Last
+ 1,
747 First_Unit
=> No_Unit_Id
,
749 Last_Interrupt_State
=> Interrupt_States
.Last
,
750 Last_Sdep
=> No_Sdep_Id
,
751 Last_Specific_Dispatching
=> Specific_Dispatching
.Last
,
752 Last_Unit
=> No_Unit_Id
,
753 Locking_Policy
=> ' ',
755 Main_Program
=> None
,
757 Normalize_Scalars
=> False,
758 Ofile_Full_Name
=> Full_Object_File_Name
,
759 Queuing_Policy
=> ' ',
760 Restrictions
=> No_Restrictions
,
761 SAL_Interface
=> False,
763 Task_Dispatching_Policy
=> ' ',
764 Time_Slice_Value
=> -1,
766 Unit_Exception_Table
=> False,
767 Ver
=> (others => ' '),
769 Zero_Cost_Exceptions
=> False);
771 -- Now we acquire the input lines from the ALI file. Note that the
772 -- convention in the following code is that as we enter each section,
773 -- C is set to contain the first character of the following line.
778 -- Acquire library version
782 -- The V line missing really indicates trouble, most likely it
783 -- means we don't have an ALI file at all, so here we give a
784 -- fatal error even if we are in Ignore_Errors mode.
788 elsif Ignore
('V') then
796 for J
in 1 .. Ver_Len_Max
loop
799 ALIs
.Table
(Id
).Ver
(J
) := C
;
800 ALIs
.Table
(Id
).Ver_Len
:= J
;
809 -- Acquire main program line if present
822 ALIs
.Table
(Id
).Main_Program
:= Func
;
824 ALIs
.Table
(Id
).Main_Program
:= Proc
;
834 ALIs
.Table
(Id
).Main_Priority
:= Get_Nat
;
842 ALIs
.Table
(Id
).Time_Slice_Value
:= Get_Nat
;
849 ALIs
.Table
(Id
).WC_Encoding
:= Getc
;
858 -- Acquire argument lines
860 First_Arg
:= Args
.Last
+ 1;
864 exit A_Loop
when C
/= 'A';
873 while not At_Eol
loop
874 Name_Len
:= Name_Len
+ 1;
875 Name_Buffer
(Name_Len
) := Getc
;
879 Args
.Table
(Args
.Last
) := new String'(Name_Buffer (1 .. Name_Len));
892 if Ignore_Errors then
912 while not At_Eol loop
921 ALIs.Table (Id).Compile_Errors := True;
927 Detect_Blocking := True;
929 -- Processing for FD/FG/FI
932 Float_Format_Specified := Getc;
933 ALIs.Table (Id).Float_Format := Float_Format_Specified;
938 Locking_Policy_Specified := Getc;
939 ALIs.Table (Id).Locking_Policy := Locking_Policy_Specified;
941 -- Processing for flags starting with N
949 ALIs.Table (Id).No_Object := True;
950 No_Object_Specified := True;
955 No_Run_Time_Mode := True;
956 Configurable_Run_Time_Mode := True;
961 ALIs.Table (Id).Normalize_Scalars := True;
962 Normalize_Scalars_Specified := True;
965 -- Invalid switch starting with N
974 Queuing_Policy_Specified := Getc;
975 ALIs.Table (Id).Queuing_Policy := Queuing_Policy_Specified;
977 -- Processing for flags starting with S
985 ALIs.Table (Id).SAL_Interface := True;
990 Opt.Sec_Stack_Used := True;
992 -- Invalid switch starting with S
1001 Task_Dispatching_Policy_Specified := Getc;
1002 ALIs.Table (Id).Task_Dispatching_Policy :=
1003 Task_Dispatching_Policy_Specified;
1005 -- Processing for switch starting with U
1010 -- Processing for UA
1013 Unreserve_All_Interrupts_Specified := True;
1015 -- Processing for UX
1018 ALIs.Table (Id).Unit_Exception_Table := True;
1020 -- Invalid switches starting with U
1026 -- Processing for ZX
1032 ALIs.Table (Id).Zero_Cost_Exceptions := True;
1033 Zero_Cost_Exceptions_Specified := True;
1038 -- Invalid parameter
1046 if not NS_Found then
1047 No_Normalize_Scalars_Specified := True;
1056 -- Acquire first restrictions line
1059 if Ignore_Errors then
1071 if Ignore ('R
') then
1074 -- Process restrictions line
1077 Scan_Restrictions : declare
1078 Save_R : constant Restrictions_Info := Cumulative_Restrictions;
1079 -- Save cumulative restrictions in case we have a fatal error
1081 Bad_R_Line : exception;
1082 -- Signal bad restrictions line (raised on unexpected character)
1088 -- Acquire information for boolean restrictions
1090 for R in All_Boolean_Restrictions loop
1095 ALIs.Table (Id).Restrictions.Violated (R) := True;
1096 Cumulative_Restrictions.Violated (R) := True;
1099 ALIs.Table (Id).Restrictions.Set (R) := True;
1100 Cumulative_Restrictions.Set (R) := True;
1110 -- Acquire information for parameter restrictions
1112 for RP in All_Parameter_Restrictions loop
1114 -- Acquire restrictions pragma information
1121 ALIs.Table (Id).Restrictions.Set (RP) := True;
1124 N : constant Integer := Integer (Get_Nat);
1126 ALIs.Table (Id).Restrictions.Value (RP) := N;
1128 if Cumulative_Restrictions.Set (RP) then
1129 Cumulative_Restrictions.Value (RP) :=
1131 (Cumulative_Restrictions.Value (RP), N);
1133 Cumulative_Restrictions.Set (RP) := True;
1134 Cumulative_Restrictions.Value (RP) := N;
1142 -- Acquire restrictions violations information
1149 ALIs.Table (Id).Restrictions.Violated (RP) := True;
1150 Cumulative_Restrictions.Violated (RP) := True;
1153 N : constant Integer := Integer (Get_Nat);
1154 pragma Unsuppress (Overflow_Check);
1157 ALIs.Table (Id).Restrictions.Count (RP) := N;
1159 if RP in Checked_Max_Parameter_Restrictions then
1160 Cumulative_Restrictions.Count (RP) :=
1162 (Cumulative_Restrictions.Count (RP), N);
1164 Cumulative_Restrictions.Count (RP) :=
1165 Cumulative_Restrictions.Count (RP) + N;
1169 when Constraint_Error =>
1171 -- A constraint error comes from the addition in
1172 -- the else branch. We reset to the maximum and
1173 -- indicate that the real value is now unknown.
1175 Cumulative_Restrictions.Value (RP) := Integer'Last;
1176 Cumulative_Restrictions.Unknown (RP) := True;
1181 ALIs.Table (Id).Restrictions.Unknown (RP) := True;
1182 Cumulative_Restrictions.Unknown (RP) := True;
1192 -- Here if error during scanning of restrictions line
1197 -- In Ignore_Errors mode, undo any changes to restrictions
1198 -- from this unit, and continue on.
1200 if Ignore_Errors then
1201 Cumulative_Restrictions := Save_R;
1202 ALIs.Table (Id).Restrictions := No_Restrictions;
1205 -- In normal mode, this is a fatal error
1211 end Scan_Restrictions;
1214 -- Acquire additional restrictions (No_Dependence) lines if present
1218 if Ignore ('R
') then
1222 No_Deps.Append ((Id, Get_Name));
1229 -- Acquire 'I
' lines if present
1234 if Ignore ('I
') then
1240 I_State : Character;
1249 Interrupt_States.Append (
1250 (Interrupt_Id => Int_Num,
1251 Interrupt_State => I_State,
1252 IS_Pragma_Line => Line_No));
1254 ALIs.Table (Id).Last_Interrupt_State := Interrupt_States.Last;
1262 -- Acquire 'S
' lines if present
1267 if Ignore ('S
') then
1283 First_Prio := Get_Nat;
1284 Last_Prio := Get_Nat;
1287 Specific_Dispatching.Append (
1288 (Dispatching_Policy => Policy,
1289 First_Priority => First_Prio,
1290 Last_Priority => Last_Prio,
1291 PSD_Pragma_Line => Line_No));
1293 ALIs.Table (Id).Last_Specific_Dispatching :=
1294 Specific_Dispatching.Last;
1303 -- Loop to acquire unit entries
1307 exit U_Loop when C /= 'U
';
1309 -- Note: as per spec, we never ignore U lines
1313 Units.Increment_Last;
1315 if ALIs.Table (Id).First_Unit = No_Unit_Id then
1316 ALIs.Table (Id).First_Unit := Units.Last;
1320 UL : Unit_Record renames Units.Table (Units.Last);
1323 UL.Uname := Get_Name;
1324 UL.Predefined := Is_Predefined_Unit;
1325 UL.Internal := Is_Internal_Unit;
1327 UL.Sfile := Get_Name (Lower => True);
1329 UL.Preelab := False;
1330 UL.No_Elab := False;
1331 UL.Shared_Passive := False;
1333 UL.Remote_Types := False;
1334 UL.Has_RACW := False;
1335 UL.Init_Scalars := False;
1336 UL.Is_Generic := False;
1337 UL.Icasing := Mixed_Case;
1338 UL.Kcasing := All_Lower_Case;
1339 UL.Dynamic_Elab := False;
1340 UL.Elaborate_Body := False;
1341 UL.Set_Elab_Entity := False;
1342 UL.Version := "00000000";
1343 UL.First_With := Withs.Last + 1;
1344 UL.First_Arg := First_Arg;
1345 UL.Elab_Position := 0;
1346 UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
1347 UL.Body_Needed_For_SAL := False;
1348 UL.Elaborate_Body_Desirable := False;
1350 if Debug_Flag_U then
1351 Write_Str (" ----> reading unit ");
1352 Write_Int (Int (Units.Last));
1354 Write_Unit_Name (UL.Uname);
1355 Write_Str (" from file ");
1356 Write_Name (UL.Sfile);
1361 -- Check for duplicated unit in different files
1364 Info : constant Int := Get_Name_Table_Info
1365 (Units.Table (Units.Last).Uname);
1368 and then Units.Table (Units.Last).Sfile /=
1369 Units.Table (Unit_Id (Info)).Sfile
1371 -- If Err is set then ignore duplicate unit name. This is the
1372 -- case of a call from gnatmake, where the situation can arise
1373 -- from substitution of source files. In such situations, the
1374 -- processing in gnatmake will always result in any required
1375 -- recompilations in any case, and if we consider this to be
1376 -- an error we get strange cases (for example when a generic
1377 -- instantiation is replaced by a normal package) where we
1378 -- read the old ali file, decide to recompile, and then decide
1379 -- that the old and new ali files are incompatible.
1384 -- If Err is not set, then this is a fatal error. This is
1385 -- the case of being called from the binder, where we must
1386 -- definitely diagnose this as an error.
1390 Write_Str ("error: duplicate unit name: ");
1393 Write_Str ("error: unit """);
1394 Write_Unit_Name (Units.Table (Units.Last).Uname);
1395 Write_Str (""" found in file """);
1396 Write_Name_Decoded (Units.Table (Units.Last).Sfile);
1400 Write_Str ("error
: unit
""");
1401 Write_Unit_Name (Units.Table (Unit_Id (Info)).Uname);
1402 Write_Str (""" found
in file
""");
1403 Write_Name_Decoded (Units.Table (Unit_Id (Info)).Sfile);
1407 Exit_Program (E_Fatal);
1413 (Units.Table (Units.Last).Uname, Int (Units.Last));
1415 -- Scan out possible version and other parameters
1424 if C in '0' .. '9' or else C in 'a
' .. 'f
' then
1425 Units.Table (Units.Last).Version (1) := C;
1427 for J in 2 .. 8 loop
1429 Units.Table (Units.Last).Version (J) := C;
1438 Check_At_End_Of_Field;
1439 Units.Table (Units.Last).Elaborate_Body_Desirable := True;
1442 Check_At_End_Of_Field;
1443 Units.Table (Units.Last).Body_Needed_For_SAL := True;
1449 -- DE parameter (Dynamic elaboration checks)
1455 Check_At_End_Of_Field;
1456 Units.Table (Units.Last).Dynamic_Elab := True;
1457 Dynamic_Elaboration_Checks_Specified := True;
1468 Units.Table (Units.Last).Elaborate_Body := True;
1470 Units.Table (Units.Last).Set_Elab_Entity := True;
1475 Check_At_End_Of_Field;
1477 -- GE parameter (generic)
1483 Check_At_End_Of_Field;
1484 Units.Table (Units.Last).Is_Generic := True;
1489 -- IL/IS/IU parameters
1495 Units.Table (Units.Last).Icasing := All_Lower_Case;
1497 Units.Table (Units.Last).Init_Scalars := True;
1498 Initialize_Scalars_Used := True;
1500 Units.Table (Units.Last).Icasing := All_Upper_Case;
1505 Check_At_End_Of_Field;
1513 Units.Table (Units.Last).Kcasing := Mixed_Case;
1515 Units.Table (Units.Last).Kcasing := All_Upper_Case;
1520 Check_At_End_Of_Field;
1528 Units.Table (Units.Last).No_Elab := True;
1529 Check_At_End_Of_Field;
1534 -- PR/PU/PK parameters
1540 Units.Table (Units.Last).Preelab := True;
1542 Units.Table (Units.Last).Pure := True;
1544 Units.Table (Units.Last).Unit_Kind := 'p
';
1549 Check_At_End_Of_Field;
1557 Units.Table (Units.Last).RCI := True;
1559 Units.Table (Units.Last).Remote_Types := True;
1561 Units.Table (Units.Last).Has_RACW := True;
1566 Check_At_End_Of_Field;
1572 Units.Table (Units.Last).Shared_Passive := True;
1574 Units.Table (Units.Last).Unit_Kind := 's
';
1579 Check_At_End_Of_Field;
1589 -- Check if static elaboration model used
1591 if not Units.Table (Units.Last).Dynamic_Elab
1592 and then not Units.Table (Units.Last).Internal
1594 Static_Elaboration_Model_Used := True;
1599 -- Scan out With lines for this unit
1603 exit With_Loop when C /= 'W
';
1605 if Ignore ('W
') then
1611 Withs.Increment_Last;
1612 Withs.Table (Withs.Last).Uname := Get_Name;
1613 Withs.Table (Withs.Last).Elaborate := False;
1614 Withs.Table (Withs.Last).Elaborate_All := False;
1615 Withs.Table (Withs.Last).Elab_Desirable := False;
1616 Withs.Table (Withs.Last).Elab_All_Desirable := False;
1617 Withs.Table (Withs.Last).SAL_Interface := False;
1619 -- Generic case with no object file available
1622 Withs.Table (Withs.Last).Sfile := No_File;
1623 Withs.Table (Withs.Last).Afile := No_File;
1628 Withs.Table (Withs.Last).Sfile := Get_Name (Lower => True);
1629 Withs.Table (Withs.Last).Afile := Get_Name;
1631 -- Scan out possible E, EA, ED, and AD parameters
1633 while not At_Eol loop
1639 Check_At_End_Of_Field;
1641 -- Store AD indication unless ignore required
1643 if not Ignore_ED then
1644 Withs.Table (Withs.Last).Elab_All_Desirable :=
1648 elsif Nextc = 'E
' then
1651 if At_End_Of_Field then
1652 Withs.Table (Withs.Last).Elaborate := True;
1654 elsif Nextc = 'A
' then
1656 Check_At_End_Of_Field;
1657 Withs.Table (Withs.Last).Elaborate_All := True;
1661 Check_At_End_Of_Field;
1663 -- Store ED indication unless ignore required
1665 if not Ignore_ED then
1666 Withs.Table (Withs.Last).Elab_Desirable :=
1680 Units.Table (Units.Last).Last_With := Withs.Last;
1681 Units.Table (Units.Last).Last_Arg := Args.Last;
1683 -- If there are linker options lines present, scan them
1687 Linker_Options_Loop : loop
1689 exit Linker_Options_Loop when C /= 'L
';
1691 if Ignore ('L
') then
1702 if C < Character'Val (16#20#)
1703 or else C > Character'Val (16#7E#)
1708 C := Character'Val (0);
1715 for J in 1 .. 2 loop
1718 if C in '0' .. '9' then
1721 Character'Pos ('0');
1723 elsif C in 'A' .. 'F' then
1726 Character'Pos ('A') +
1735 Add_Char_To_Name_Buffer (Character'Val (V));
1740 exit when Nextc /= '"';
1744 Add_Char_To_Name_Buffer (C);
1748 Add_Char_To_Name_Buffer (nul);
1753 end loop Linker_Options_Loop;
1755 -- Store the linker options entry if one was found
1757 if Name_Len /= 0 then
1758 Linker_Options.Increment_Last;
1760 Linker_Options.Table (Linker_Options.Last).Name :=
1763 Linker_Options.Table (Linker_Options.Last).Unit :=
1766 Linker_Options.Table (Linker_Options.Last).Internal_File :=
1767 Is_Internal_File_Name (F);
1769 Linker_Options.Table (Linker_Options.Last).Original_Pos :=
1770 Linker_Options.Last;
1774 -- End loop through units for one ALI file
1776 ALIs.Table (Id).Last_Unit := Units.Last;
1777 ALIs.Table (Id).Sfile := Units.Table (ALIs.Table (Id).First_Unit).Sfile;
1779 -- Set types of the units (there can be at most 2 of them)
1781 if ALIs.Table (Id).First_Unit /= ALIs.Table (Id).Last_Unit then
1782 Units.Table (ALIs.Table (Id).First_Unit).Utype := Is_Body;
1783 Units.Table (ALIs.Table (Id).Last_Unit).Utype := Is_Spec;
1786 -- Deal with body only and spec only cases, note that the reason we
1787 -- do our own checking of the name (rather than using Is_Body_Name)
1788 -- is that Uname drags in far too much compiler junk!
1790 Get_Name_String (Units.Table (Units.Last).Uname);
1792 if Name_Buffer (Name_Len) = 'b' then
1793 Units.Table (Units.Last).Utype := Is_Body_Only;
1795 Units.Table (Units.Last).Utype := Is_Spec_Only;
1799 -- Scan out external version references and put in hash table
1803 exit E_Loop when C /= 'E';
1805 if Ignore ('E') then
1821 exit when At_End_Of_Field;
1822 Add_Char_To_Name_Buffer (C);
1825 Version_Ref.Set (new String'(Name_Buffer (1 .. Name_Len)), True);
1832 -- Scan out source dependency lines for this ALI file
1834 ALIs.Table (Id).First_Sdep := Sdep.Last + 1;
1838 exit D_Loop when C /= 'D';
1840 if Ignore ('D') then
1846 Sdep.Increment_Last;
1847 Sdep.Table (Sdep.Last).Sfile := Get_Name (Lower => True);
1848 Sdep.Table (Sdep.Last).Stamp := Get_Stamp;
1849 Sdep.Table (Sdep.Last).Dummy_Entry :=
1850 (Sdep.Table (Sdep.Last).Stamp = Dummy_Time_Stamp);
1852 -- Acquire checksum value
1865 exit when At_Eol or else Ctr = 8;
1867 if Nextc in '0' .. '9' then
1869 Character'Pos (Nextc) - Character'Pos ('0');
1871 elsif Nextc in 'a' .. 'f' then
1873 Character'Pos (Nextc) - Character'Pos ('a') + 10;
1883 if Ctr = 8 and then At_End_Of_Field then
1884 Sdep.Table (Sdep.Last).Checksum := Chk;
1890 -- Acquire subunit and reference file name entries
1892 Sdep.Table (Sdep.Last).Subunit_Name := No_Name;
1893 Sdep.Table (Sdep.Last).Rfile :=
1894 Sdep.Table (Sdep.Last).Sfile;
1895 Sdep.Table (Sdep.Last).Start_Line := 1;
1900 -- Here for subunit name
1902 if Nextc not in '0' .. '9' then
1905 while not At_End_Of_Field loop
1906 Name_Len := Name_Len + 1;
1907 Name_Buffer (Name_Len) := Getc;
1910 Sdep.Table (Sdep.Last).Subunit_Name := Name_Enter;
1914 -- Here for reference file name entry
1916 if Nextc in '0' .. '9' then
1917 Sdep.Table (Sdep.Last).Start_Line := Get_Nat;
1922 while not At_End_Of_Field loop
1923 Name_Len := Name_Len + 1;
1924 Name_Buffer (Name_Len) := Getc;
1927 Sdep.Table (Sdep.Last).Rfile := Name_Enter;
1937 ALIs.Table (Id).Last_Sdep := Sdep.Last;
1939 -- We must at this stage be at an Xref line or the end of file
1951 -- If we are ignoring Xref sections we are done (we ignore all
1952 -- remaining lines since only xref related lines follow X).
1954 if Ignore ('X') and then not Debug_Flag_X then
1958 -- Loop through Xref sections
1962 exit X_Loop when C /= 'X';
1964 -- Make new entry in section table
1966 Xref_Section.Increment_Last;
1968 Read_Refs_For_One_File : declare
1969 XS : Xref_Section_Record renames
1970 Xref_Section.Table (Xref_Section.Last);
1972 Current_File_Num : Sdep_Id;
1973 -- Keeps track of the current file number (changed by nn|)
1976 XS.File_Num := Sdep_Id (Get_Nat + Nat (First_Sdep_Entry) - 1);
1977 XS.File_Name := Get_Name;
1978 XS.First_Entity := Xref_Entity.Last + 1;
1980 Current_File_Num := XS.File_Num;
1987 -- Loop through Xref entities
1989 while C /= 'X' and then C /= EOF loop
1990 Xref_Entity.Increment_Last;
1992 Read_Refs_For_One_Entity : declare
1993 XE : Xref_Entity_Record renames
1994 Xref_Entity.Table (Xref_Entity.Last);
1997 procedure Read_Instantiation_Reference;
1998 -- Acquire instantiation reference. Caller has checked
1999 -- that current character is '[' and on return the cursor
2000 -- is skipped past the corresponding closing ']'.
2002 ----------------------------------
2003 -- Read_Instantiation_Reference --
2004 ----------------------------------
2006 procedure Read_Instantiation_Reference is
2007 Local_File_Num : Sdep_Id := Current_File_Num;
2010 Xref.Increment_Last;
2013 XR : Xref_Record renames Xref.Table (Xref.Last);
2016 P := P + 1; -- skip [
2021 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2022 Local_File_Num := XR.File_Num;
2027 XR.File_Num := Local_File_Num;
2034 -- Recursive call for next reference
2037 pragma Warnings (Off); -- kill recursion warning
2038 Read_Instantiation_Reference;
2039 pragma Warnings (On);
2042 -- Skip closing bracket after recursive call
2046 end Read_Instantiation_Reference;
2048 -- Start of processing for Read_Refs_For_One_Entity
2054 XE.Lib := (Getc = '*');
2055 XE.Entity := Get_Name;
2057 -- Handle the information about generic instantiations
2060 Skipc; -- Opening '['
2063 if Nextc /= '|' then
2064 XE.Iref_File_Num := Current_File_Num;
2068 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2070 XE.Iref_Line := Get_Nat;
2078 XE.Iref_File_Num := No_Sdep_Id;
2082 Current_File_Num := XS.File_Num;
2084 -- Renaming reference is present
2088 XE.Rref_Line := Get_Nat;
2094 XE.Rref_Col := Get_Nat;
2096 -- No renaming reference present
2105 -- See if type reference present
2108 (Current_File_Num, XE.Tref, XE.Tref_File_Num, XE.Tref_Line,
2109 XE.Tref_Type, XE.Tref_Col, XE.Tref_Standard_Entity);
2111 -- Do we have an overriding procedure, instead ?
2112 if XE.Tref_Type = 'p' then
2113 XE.Oref_File_Num := XE.Tref_File_Num;
2114 XE.Oref_Line := XE.Tref_Line;
2115 XE.Oref_Col := XE.Tref_Col;
2116 XE.Tref_File_Num := No_Sdep_Id;
2117 XE.Tref := Tref_None;
2119 -- We might have additional information about the
2120 -- overloaded subprograms
2124 Standard_Entity : Name_Id;
2128 Ref, XE.Oref_File_Num,
2129 XE.Oref_Line, Typ, XE.Oref_Col, Standard_Entity);
2133 XE.First_Xref := Xref.Last + 1;
2135 -- Loop through cross-references for this entity
2142 exit when Nextc /= '.';
2146 Xref.Increment_Last;
2149 XR : Xref_Record renames Xref.Table (Xref.Last);
2156 Sdep_Id (N + Nat (First_Sdep_Entry) - 1);
2157 Current_File_Num := XR.File_Num;
2161 XR.File_Num := Current_File_Num;
2167 -- Imported entities reference as in:
2168 -- 494b<c,__gnat_copy_attribs>25
2169 -- ??? Simply skipped for now
2172 while Getc /= '>' loop
2180 Read_Instantiation_Reference;
2185 -- Record last cross-reference
2187 XE.Last_Xref := Xref.Last;
2189 end Read_Refs_For_One_Entity;
2192 -- Record last entity
2194 XS.Last_Entity := Xref_Entity.Last;
2196 end Read_Refs_For_One_File;
2201 -- Here after dealing with xref sections
2203 if C /= EOF and then C /= 'X' then
2210 when Bad_ALI_Format =>
2219 function SEq (F1, F2 : String_Ptr) return Boolean is
2221 return F1.all = F2.all;
2228 function SHash (S : String_Ptr) return Vindex is
2233 for J in S.all'Range loop
2234 H := H * 2 + Character'Pos (S (J));
2237 return Vindex (Vindex'First + Vindex (H mod Vindex'Range_Length));