Commit 5d993afd by Vincent Celier Committed by Arnaud Charlet

gnatbind.adb: Call Scan_ALI with Directly_Scanned set to True for all the ALI files on the...

2010-06-14  Vincent Celier  <celier@adacore.com>

	* gnatbind.adb: Call Scan_ALI with Directly_Scanned set to True for all
	the ALI files on the command line.

	* ali.adb (Scan_ALI): Set component Directly_Scanned of the unit(s) to
	the same value as the parameter of the same name.
	* ali.ads (Scan_ALI): New Boolean parameter Directly_Scanned, defaulted
	to False.
	* bindgen.adb (Gen_Versions_Ada): Never emit version symbols for
	Stand-Alone Library interfaces. When binding Stand-Alone Libraries,
	emit version symbols only for the units of the library.
	(Gen_Versions_C): Ditto.

From-SVN: r160715
parent 49d140bb
2010-06-14 Vincent Celier <celier@adacore.com>
* gnatbind.adb: Call Scan_ALI with Directly_Scanned set to True for all
the ALI files on the command line.
* ali.adb (Scan_ALI): Set component Directly_Scanned of the unit(s) to
the same value as the parameter of the same name.
* ali.ads (Scan_ALI): New Boolean parameter Directly_Scanned, defaulted
to False.
* bindgen.adb (Gen_Versions_Ada): Never emit version symbols for
Stand-Alone Library interfaces. When binding Stand-Alone Libraries,
emit version symbols only for the units of the library.
(Gen_Versions_C): Ditto.
2010-06-14 Gary Dismukes <dismukes@adacore.com> 2010-06-14 Gary Dismukes <dismukes@adacore.com>
* sem_ch4.adb: Fix typo. * sem_ch4.adb: Fix typo.
......
...@@ -119,14 +119,15 @@ package body ALI is ...@@ -119,14 +119,15 @@ package body ALI is
-------------- --------------
function Scan_ALI function Scan_ALI
(F : File_Name_Type; (F : File_Name_Type;
T : Text_Buffer_Ptr; T : Text_Buffer_Ptr;
Ignore_ED : Boolean; Ignore_ED : Boolean;
Err : Boolean; Err : Boolean;
Read_Xref : Boolean := False; Read_Xref : Boolean := False;
Read_Lines : String := ""; Read_Lines : String := "";
Ignore_Lines : String := "X"; Ignore_Lines : String := "X";
Ignore_Errors : Boolean := False) return ALI_Id Ignore_Errors : Boolean := False;
Directly_Scanned : Boolean := False) return ALI_Id
is is
P : Text_Ptr := T'First; P : Text_Ptr := T'First;
Line : Logical_Line_Number := 1; Line : Logical_Line_Number := 1;
...@@ -1415,6 +1416,7 @@ package body ALI is ...@@ -1415,6 +1416,7 @@ package body ALI is
UL.First_Arg := First_Arg; UL.First_Arg := First_Arg;
UL.Elab_Position := 0; UL.Elab_Position := 0;
UL.SAL_Interface := ALIs.Table (Id).SAL_Interface; UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
UL.Directly_Scanned := Directly_Scanned;
UL.Body_Needed_For_SAL := False; UL.Body_Needed_For_SAL := False;
UL.Elaborate_Body_Desirable := False; UL.Elaborate_Body_Desirable := False;
UL.Optimize_Alignment := 'O'; UL.Optimize_Alignment := 'O';
......
...@@ -342,6 +342,9 @@ package ALI is ...@@ -342,6 +342,9 @@ package ALI is
SAL_Interface : Boolean; SAL_Interface : Boolean;
-- Set True when this is an interface to a standalone library -- Set True when this is an interface to a standalone library
Directly_Scanned : Boolean;
-- True iff it is a unit from an ALI file specified to gnatbind
Body_Needed_For_SAL : Boolean; Body_Needed_For_SAL : Boolean;
-- Indicates that the source for the body of the unit (subprogram, -- Indicates that the source for the body of the unit (subprogram,
-- package, or generic unit) must be included in a standalone library. -- package, or generic unit) must be included in a standalone library.
...@@ -933,14 +936,15 @@ package ALI is ...@@ -933,14 +936,15 @@ package ALI is
-- Initialize the ALI tables. Also resets all switch values to defaults -- Initialize the ALI tables. Also resets all switch values to defaults
function Scan_ALI function Scan_ALI
(F : File_Name_Type; (F : File_Name_Type;
T : Text_Buffer_Ptr; T : Text_Buffer_Ptr;
Ignore_ED : Boolean; Ignore_ED : Boolean;
Err : Boolean; Err : Boolean;
Read_Xref : Boolean := False; Read_Xref : Boolean := False;
Read_Lines : String := ""; Read_Lines : String := "";
Ignore_Lines : String := "X"; Ignore_Lines : String := "X";
Ignore_Errors : Boolean := False) return ALI_Id; Ignore_Errors : Boolean := False;
Directly_Scanned : Boolean := False) return ALI_Id;
-- Given the text, T, of an ALI file, F, scan and store the information -- Given the text, T, of an ALI file, F, scan and store the information
-- from the file, and return the Id of the resulting entry in the ALI -- from the file, and return the Id of the resulting entry in the ALI
-- table. Switch settings may be modified as described above in the -- table. Switch settings may be modified as described above in the
...@@ -986,5 +990,11 @@ package ALI is ...@@ -986,5 +990,11 @@ package ALI is
-- Scan_ALI was completely unable to process the file (e.g. it did not -- Scan_ALI was completely unable to process the file (e.g. it did not
-- look like an ALI file at all). Ignore_Errors is intended to improve -- look like an ALI file at all). Ignore_Errors is intended to improve
-- the downward compatibility of new compilers with old tools. -- the downward compatibility of new compilers with old tools.
--
-- Directly_Scanned is normally False. If it is set to True, then the
-- units (spec and/or body) corresponding to the ALI file are marked as
-- such. It is used to decide for what units gnatbind should generate
-- the symbols corresponding to 'Version or 'Body_Version in
-- Stand-Alone Libraries.
end ALI; end ALI;
...@@ -2969,12 +2969,9 @@ package body Bindgen is ...@@ -2969,12 +2969,9 @@ package body Bindgen is
-- Gen_Versions_Ada -- -- Gen_Versions_Ada --
---------------------- ----------------------
-- This routine generates two sets of lines. The first set has the form: -- This routine generates lines such as:
-- unnnnn : constant Integer := 16#hhhhhhhh#; -- unnnnn : constant Integer := 16#hhhhhhhh#;
-- The second set has the form
-- pragma Export (C, unnnnn, unam); -- pragma Export (C, unnnnn, unam);
-- for each unit, where unam is the unit name suffixed by either B or -- for each unit, where unam is the unit name suffixed by either B or
...@@ -2999,57 +2996,44 @@ package body Bindgen is ...@@ -2999,57 +2996,44 @@ package body Bindgen is
-- Start of processing for Gen_Versions_Ada -- Start of processing for Gen_Versions_Ada
begin begin
if Bind_For_Library then
-- When building libraries, the version number of each unit can
-- not be computed, since the binder does not know the full list
-- of units. Therefore, the 'Version and 'Body_Version
-- attributes cannot supported in this case.
return;
end if;
WBI (""); WBI ("");
WBI (" type Version_32 is mod 2 ** 32;"); WBI (" type Version_32 is mod 2 ** 32;");
for U in Units.First .. Units.Last loop for U in Units.First .. Units.Last loop
Increment_Ubuf; if not Units.Table (U).SAL_Interface and then
WBI (" " & Ubuf & " : constant Version_32 := 16#" & ((not Bind_For_Library) or else Units.Table (U).Directly_Scanned)
Units.Table (U).Version & "#;"); then
end loop; Increment_Ubuf;
WBI (" " & Ubuf & " : constant Version_32 := 16#" &
WBI (""); Units.Table (U).Version & "#;");
Ubuf := "u00000"; Set_String (" pragma Export (C, ");
Set_String (Ubuf);
Set_String (", """);
for U in Units.First .. Units.Last loop Get_Name_String (Units.Table (U).Uname);
Increment_Ubuf;
Set_String (" pragma Export (C, ");
Set_String (Ubuf);
Set_String (", """);
Get_Name_String (Units.Table (U).Uname); for K in 1 .. Name_Len loop
if Name_Buffer (K) = '.' then
Set_Char ('_');
Set_Char ('_');
for K in 1 .. Name_Len loop elsif Name_Buffer (K) = '%' then
if Name_Buffer (K) = '.' then exit;
Set_Char ('_');
Set_Char ('_');
elsif Name_Buffer (K) = '%' then else
exit; Set_Char (Name_Buffer (K));
end if;
end loop;
if Name_Buffer (Name_Len) = 's' then
Set_Char ('S');
else else
Set_Char (Name_Buffer (K)); Set_Char ('B');
end if; end if;
end loop;
if Name_Buffer (Name_Len) = 's' then Set_String (""");");
Set_Char ('S'); Write_Statement_Buffer;
else
Set_Char ('B');
end if; end if;
Set_String (""");");
Write_Statement_Buffer;
end loop; end loop;
end Gen_Versions_Ada; end Gen_Versions_Ada;
...@@ -3067,43 +3051,37 @@ package body Bindgen is ...@@ -3067,43 +3051,37 @@ package body Bindgen is
procedure Gen_Versions_C is procedure Gen_Versions_C is
begin begin
if Bind_For_Library then
-- When building libraries, the version number of each unit can
-- not be computed, since the binder does not know the full list
-- of units. Therefore, the 'Version and 'Body_Version
-- attributes cannot supported.
return;
end if;
for U in Units.First .. Units.Last loop for U in Units.First .. Units.Last loop
Set_String ("unsigned "); if not Units.Table (U).SAL_Interface and then
((not Bind_For_Library) or else Units.Table (U).Directly_Scanned)
then
Set_String ("unsigned ");
Get_Name_String (Units.Table (U).Uname); Get_Name_String (Units.Table (U).Uname);
for K in 1 .. Name_Len loop for K in 1 .. Name_Len loop
if Name_Buffer (K) = '.' then if Name_Buffer (K) = '.' then
Set_String ("__"); Set_String ("__");
elsif Name_Buffer (K) = '%' then elsif Name_Buffer (K) = '%' then
exit; exit;
else
Set_Char (Name_Buffer (K));
end if;
end loop;
if Name_Buffer (Name_Len) = 's' then
Set_Char ('S');
else else
Set_Char (Name_Buffer (K)); Set_Char ('B');
end if; end if;
end loop;
if Name_Buffer (Name_Len) = 's' then Set_String (" = 0x");
Set_Char ('S'); Set_String (Units.Table (U).Version);
else Set_Char (';');
Set_Char ('B'); Write_Statement_Buffer;
end if; end if;
Set_String (" = 0x");
Set_String (Units.Table (U).Version);
Set_Char (';');
Write_Statement_Buffer;
end loop; end loop;
end Gen_Versions_C; end Gen_Versions_C;
......
...@@ -671,11 +671,12 @@ begin ...@@ -671,11 +671,12 @@ begin
begin begin
Id := Scan_ALI Id := Scan_ALI
(F => Main_Lib_File, (F => Main_Lib_File,
T => Text, T => Text,
Ignore_ED => False, Ignore_ED => False,
Err => False, Err => False,
Ignore_Errors => Debug_Flag_I); Ignore_Errors => Debug_Flag_I,
Directly_Scanned => True);
end; end;
Free (Text); Free (Text);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment