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>
* sem_ch4.adb: Fix typo.
......
......@@ -119,14 +119,15 @@ package body ALI is
--------------
function Scan_ALI
(F : File_Name_Type;
T : Text_Buffer_Ptr;
Ignore_ED : Boolean;
Err : Boolean;
Read_Xref : Boolean := False;
Read_Lines : String := "";
Ignore_Lines : String := "X";
Ignore_Errors : Boolean := False) return ALI_Id
(F : File_Name_Type;
T : Text_Buffer_Ptr;
Ignore_ED : Boolean;
Err : Boolean;
Read_Xref : Boolean := False;
Read_Lines : String := "";
Ignore_Lines : String := "X";
Ignore_Errors : Boolean := False;
Directly_Scanned : Boolean := False) return ALI_Id
is
P : Text_Ptr := T'First;
Line : Logical_Line_Number := 1;
......@@ -1415,6 +1416,7 @@ package body ALI is
UL.First_Arg := First_Arg;
UL.Elab_Position := 0;
UL.SAL_Interface := ALIs.Table (Id).SAL_Interface;
UL.Directly_Scanned := Directly_Scanned;
UL.Body_Needed_For_SAL := False;
UL.Elaborate_Body_Desirable := False;
UL.Optimize_Alignment := 'O';
......
......@@ -342,6 +342,9 @@ package ALI is
SAL_Interface : Boolean;
-- 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;
-- Indicates that the source for the body of the unit (subprogram,
-- package, or generic unit) must be included in a standalone library.
......@@ -933,14 +936,15 @@ package ALI is
-- Initialize the ALI tables. Also resets all switch values to defaults
function Scan_ALI
(F : File_Name_Type;
T : Text_Buffer_Ptr;
Ignore_ED : Boolean;
Err : Boolean;
Read_Xref : Boolean := False;
Read_Lines : String := "";
Ignore_Lines : String := "X";
Ignore_Errors : Boolean := False) return ALI_Id;
(F : File_Name_Type;
T : Text_Buffer_Ptr;
Ignore_ED : Boolean;
Err : Boolean;
Read_Xref : Boolean := False;
Read_Lines : String := "";
Ignore_Lines : String := "X";
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
-- 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
......@@ -986,5 +990,11 @@ package ALI is
-- 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
-- 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;
......@@ -2969,12 +2969,9 @@ package body Bindgen is
-- 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#;
-- The second set has the form
-- pragma Export (C, unnnnn, unam);
-- for each unit, where unam is the unit name suffixed by either B or
......@@ -2999,57 +2996,44 @@ package body Bindgen is
-- Start of processing for Gen_Versions_Ada
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 (" type Version_32 is mod 2 ** 32;");
for U in Units.First .. Units.Last loop
Increment_Ubuf;
WBI (" " & Ubuf & " : constant Version_32 := 16#" &
Units.Table (U).Version & "#;");
end loop;
WBI ("");
Ubuf := "u00000";
if not Units.Table (U).SAL_Interface and then
((not Bind_For_Library) or else Units.Table (U).Directly_Scanned)
then
Increment_Ubuf;
WBI (" " & Ubuf & " : constant Version_32 := 16#" &
Units.Table (U).Version & "#;");
Set_String (" pragma Export (C, ");
Set_String (Ubuf);
Set_String (", """);
for U in Units.First .. Units.Last loop
Increment_Ubuf;
Set_String (" pragma Export (C, ");
Set_String (Ubuf);
Set_String (", """);
Get_Name_String (Units.Table (U).Uname);
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
if Name_Buffer (K) = '.' then
Set_Char ('_');
Set_Char ('_');
elsif Name_Buffer (K) = '%' then
exit;
elsif Name_Buffer (K) = '%' then
exit;
else
Set_Char (Name_Buffer (K));
end if;
end loop;
if Name_Buffer (Name_Len) = 's' then
Set_Char ('S');
else
Set_Char (Name_Buffer (K));
Set_Char ('B');
end if;
end loop;
if Name_Buffer (Name_Len) = 's' then
Set_Char ('S');
else
Set_Char ('B');
Set_String (""");");
Write_Statement_Buffer;
end if;
Set_String (""");");
Write_Statement_Buffer;
end loop;
end Gen_Versions_Ada;
......@@ -3067,43 +3051,37 @@ package body Bindgen is
procedure Gen_Versions_C is
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
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
if Name_Buffer (K) = '.' then
Set_String ("__");
for K in 1 .. Name_Len loop
if Name_Buffer (K) = '.' then
Set_String ("__");
elsif Name_Buffer (K) = '%' then
exit;
elsif Name_Buffer (K) = '%' then
exit;
else
Set_Char (Name_Buffer (K));
end if;
end loop;
if Name_Buffer (Name_Len) = 's' then
Set_Char ('S');
else
Set_Char (Name_Buffer (K));
Set_Char ('B');
end if;
end loop;
if Name_Buffer (Name_Len) = 's' then
Set_Char ('S');
else
Set_Char ('B');
Set_String (" = 0x");
Set_String (Units.Table (U).Version);
Set_Char (';');
Write_Statement_Buffer;
end if;
Set_String (" = 0x");
Set_String (Units.Table (U).Version);
Set_Char (';');
Write_Statement_Buffer;
end loop;
end Gen_Versions_C;
......
......@@ -671,11 +671,12 @@ begin
begin
Id := Scan_ALI
(F => Main_Lib_File,
T => Text,
Ignore_ED => False,
Err => False,
Ignore_Errors => Debug_Flag_I);
(F => Main_Lib_File,
T => Text,
Ignore_ED => False,
Err => False,
Ignore_Errors => Debug_Flag_I,
Directly_Scanned => True);
end;
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