-- --
-- B o d y --
-- --
--- Copyright (C) 2003-2005, Free Software Foundation, Inc. --
+-- Copyright (C) 2003-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
--- ware Foundation; either version 2, or (at your option) any later ver- --
+-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
--- Public License distributed with GNAT; see file COPYING. If not, write --
--- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
--- Boston, MA 02110-1301, USA. --
+-- Public License distributed with GNAT; see file COPYING3. If not, go to --
+-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
with Ada.Unchecked_Deallocation;
with Errout; use Errout;
-with Namet; use Namet;
with Lib.Writ; use Lib.Writ;
with Opt; use Opt;
with Osint; use Osint;
with Sinput.L; use Sinput.L;
with Stringt; use Stringt;
with Table;
+with Types; use Types;
package body Prepcomp is
No_Preprocessing : Boolean := True;
- -- Set to True if there is at least one source that needs to be
+ -- Set to False if there is at least one source that needs to be
-- preprocessed.
Source_Index_Of_Preproc_Data_File : Source_File_Index := No_Source_File;
- -- The following variable should be a constant, but this is not
- -- possible. Warnings are Off because it is never assigned a value.
+ -- The following variable should be a constant, but this is not possible
+ -- because its type GNAT.Dynamic_Tables.Instance has a component P of
+ -- unitialized private type GNAT.Dynamic_Tables.Table_Private and there
+ -- are no exported values for this private type. Warnings are Off because
+ -- it is never assigned a value.
pragma Warnings (Off);
No_Mapping : Prep.Symbol_Table.Instance;
type Preproc_Data is record
Mapping : Symbol_Table.Instance;
- File_Name : Name_Id := No_Name;
- Deffile : String_Id := No_String;
- Undef_False : Boolean := False;
- Always_Blank : Boolean := False;
- Comments : Boolean := False;
- List_Symbols : Boolean := False;
- Processed : Boolean := False;
+ File_Name : File_Name_Type := No_File;
+ Deffile : String_Id := No_String;
+ Undef_False : Boolean := False;
+ Always_Blank : Boolean := False;
+ Comments : Boolean := False;
+ List_Symbols : Boolean := False;
+ Processed : Boolean := False;
end record;
-- Structure to keep the preprocessing data for a file name or for the
-- default (when Name_Id = No_Name).
No_Preproc_Data : constant Preproc_Data :=
(Mapping => No_Mapping,
- File_Name => No_Name,
+ File_Name => No_File,
Deffile => No_String,
Undef_False => False,
Always_Blank => False,
Table_Index_Type => Int,
Table_Low_Bound => 1,
Table_Initial => 5,
- Table_Increment => 5,
+ Table_Increment => 100,
Table_Name => "Prepcomp.Preproc_Data_Table");
-- Table to store the specific preprocessing data
(Table_Component_Type => Source_File_Index,
Table_Index_Type => Int,
Table_Low_Bound => 1,
- Table_Initial => 5,
- Table_Increment => 5,
+ Table_Initial => 10,
+ Table_Increment => 100,
Table_Name => "Prepcomp.Dependencies");
-- Table to store the dependencies on preprocessing files
procedure Add_Command_Line_Symbols;
- -- Add the command line symbol definitions, if any, to the
- -- Prep.Mapping table.
+ -- Add the command line symbol definitions, if any, to Prep.Mapping table
procedure Skip_To_End_Of_Line;
-- Ignore errors and scan up to the next end of line or the end of file
if Source_Index_Of_Preproc_Data_File = No_Source_File then
Get_Name_String (N);
- Fail ("preprocessing data file """,
- Name_Buffer (1 .. Name_Len),
- """ not found");
+ Fail ("preprocessing data file """
+ & Name_Buffer (1 .. Name_Len)
+ & """ not found");
end if;
- -- Initialize the sanner and set its behavior for a processing data file
+ -- Initialize scanner and set its behavior for processing a data file
- Scn.Scanner.Initialize_Scanner
- (No_Unit, Source_Index_Of_Preproc_Data_File);
+ Scn.Scanner.Initialize_Scanner (Source_Index_Of_Preproc_Data_File);
Scn.Scanner.Set_End_Of_Line_As_Token (True);
Scn.Scanner.Reset_Special_Characters;
if Current_Data.File_Name =
Preproc_Data_Table.Table (Index).File_Name
then
- Error_Msg_Name_1 := Current_Data.File_Name;
+ Error_Msg_File_1 := Current_Data.File_Name;
Error_Msg
("multiple preprocessing data for{", Token_Ptr);
OK := False;
-- with an underline or a digit.
if Name_Buffer (2) = '_'
- or Name_Buffer (2) in '0' .. '9'
+ or else Name_Buffer (2) in '0' .. '9'
then
Error_Msg ("symbol expected", Token_Ptr + 1);
Skip_To_End_Of_Line;
-- Record Current_Data
- if Current_Data.File_Name = No_Name then
+ if Current_Data.File_Name = No_File then
Default_Data := Current_Data;
else
-- Fail if there were errors in the preprocessing data file
if Total_Errors_Detected > T then
- Errout.Finalize;
- Fail ("errors found in preprocessing data file """,
- Get_Name_String (N),
- """");
+ Errout.Finalize (Last_Call => True);
+ Errout.Output_Messages;
+ Fail ("errors found in preprocessing data file """
+ & Get_Name_String (N) & """");
end if;
-- Record the dependency on the preprocessor data file
String_To_Name_Buffer (Current_Data.Deffile);
declare
- N : constant Name_Id := Name_Find;
- Deffile : constant Source_File_Index := Load_Definition_File (N);
- Add_Deffile : Boolean := True;
- T : constant Nat := Total_Errors_Detected;
+ N : constant File_Name_Type := Name_Find;
+ Deffile : constant Source_File_Index :=
+ Load_Definition_File (N);
+ Add_Deffile : Boolean := True;
+ T : constant Nat := Total_Errors_Detected;
begin
if Deffile = No_Source_File then
- Fail ("definition file """,
- Get_Name_String (N),
- """ cannot be found");
+ Fail ("definition file """
+ & Get_Name_String (N)
+ & """ not found");
end if;
-- Initialize the preprocessor and set the characteristics of the
-- scanner for a definition file.
- Prep.Initialize
+ Prep.Setup_Hooks
(Error_Msg => Errout.Error_Msg'Access,
Scan => Scn.Scanner.Scan'Access,
Set_Ignore_Errors => Errout.Set_Ignore_Errors'Access,
-- Initialize the scanner and process the definition file
- Scn.Scanner.Initialize_Scanner (No_Unit, Deffile);
+ Scn.Scanner.Initialize_Scanner (Deffile);
Prep.Parse_Def_File;
-- Reset the behaviour of the scanner to the default
-- Fail if errors were found while processing the definition file
if T /= Total_Errors_Detected then
- Errout.Finalize;
- Fail ("errors found in definition file """,
- Get_Name_String (N),
- """");
+ Errout.Finalize (Last_Call => True);
+ Errout.Output_Messages;
+ Fail ("errors found in definition file """
+ & Get_Name_String (N)
+ & """");
end if;
for Index in 1 .. Dependencies.Last loop
Check_Command_Line_Symbol_Definition
(Definition => Symbol_Definitions (Index).all,
- Data => Symbol_Data);
+ Data => Symbol_Data);
Found := False;
-- If there is already a definition for this symbol, replace the old