procedure Load_Naming_Exceptions
(Project : Project_Id;
- In_Tree : Project_Tree_Ref;
- Data : in out Project_Data);
+ In_Tree : Project_Tree_Ref);
-- All source files in Data.First_Source are considered as naming
-- exceptions, and copied into the Source_Names and Unit_Exceptions tables
-- as appropriate.
procedure Add_Source
(Id : out Source_Id;
- Data : in out Project_Data;
In_Tree : Project_Tree_Ref;
Project : Project_Id;
- Lang : Name_Id;
Lang_Id : Language_Ptr;
Kind : Source_Kind;
File_Name : File_Name_Type;
Spec_Suffix : File_Name_Type;
Casing : Casing_Type;
Kind : out Source_Kind;
- Unit : out Name_Id);
+ Unit : out Name_Id;
+ In_Tree : Project_Tree_Ref);
-- Check whether the file matches the naming scheme. If it does,
-- compute its unit name. If Unit is set to No_Name on exit, none of the
-- other out parameters are relevant.
procedure Remove_Source
(Id : Source_Id;
- Replaced_By : Source_Id;
- Project : Project_Id;
- Data : in out Project_Data;
- In_Tree : Project_Tree_Ref);
+ Replaced_By : Source_Id);
-- ??? needs comment
procedure Report_No_Sources
procedure Add_Source
(Id : out Source_Id;
- Data : in out Project_Data;
In_Tree : Project_Tree_Ref;
Project : Project_Id;
- Lang : Name_Id;
Lang_Id : Language_Ptr;
Kind : Source_Kind;
File_Name : File_Name_Type;
Index : Int := 0;
Source_To_Replace : Source_Id := No_Source)
is
- Source : constant Source_Id := Data.Last_Source;
- Src_Data : Source_Data := No_Source_Data;
Config : constant Language_Config := Lang_Id.Config;
begin
- -- This is a new source so create an entry for it in the Sources table
-
- Source_Data_Table.Increment_Last (In_Tree.Sources);
- Id := Source_Data_Table.Last (In_Tree.Sources);
+ Id := new Source_Data;
if Current_Verbosity = High then
- Write_Str ("Adding source #");
- Write_Str (Id'Img);
- Write_Str (", File : ");
+ Write_Str ("Adding source File: ");
Write_Str (Get_Name_String (File_Name));
if Lang_Kind = Unit_Based then
- Write_Str (", Unit : ");
- Write_Str (Get_Name_String (Unit));
+ Write_Str (" Unit: ");
+ -- ??? in gprclean, it seems we sometimes pass an empty Unit name
+ -- (see test extended_projects)
+ if Unit /= No_Name then
+ Write_Str (Get_Name_String (Unit));
+ end if;
+ Write_Str (" Kind: ");
+ Write_Str (Source_Kind'Image (Kind));
end if;
Write_Eol;
end if;
- Src_Data.Project := Project;
- Src_Data.Language := Lang_Id;
- Src_Data.Lang_Kind := Lang_Kind;
- Src_Data.Compiled :=
- Lang_Id.Config.Compiler_Driver /= Empty_File_Name;
- Src_Data.Kind := Kind;
- Src_Data.Alternate_Languages := Alternate_Languages;
- Src_Data.Other_Part := Other_Part;
+ Id.Project := Project;
+ Id.Language := Lang_Id;
+ Id.Lang_Kind := Lang_Kind;
+ Id.Compiled := Lang_Id.Config.Compiler_Driver /=
+ Empty_File_Name;
+ Id.Kind := Kind;
+ Id.Alternate_Languages := Alternate_Languages;
+ Id.Other_Part := Other_Part;
- Src_Data.Object_Exists := Config.Object_Generated;
- Src_Data.Object_Linked := Config.Objects_Linked;
+ Id.Object_Exists := Config.Object_Generated;
+ Id.Object_Linked := Config.Objects_Linked;
if Other_Part /= No_Source then
- In_Tree.Sources.Table (Other_Part).Other_Part := Id;
+ Other_Part.Other_Part := Id;
end if;
- Src_Data.Unit := Unit;
- Src_Data.Index := Index;
- Src_Data.File := File_Name;
- Src_Data.Display_File := Display_File;
- Src_Data.Dependency := Lang_Id.Config.Dependency_Kind;
- Src_Data.Dep_Name := Dependency_Name
- (File_Name, Src_Data.Dependency);
- Src_Data.Naming_Exception := Naming_Exception;
-
- if Src_Data.Compiled and then Src_Data.Object_Exists then
- Src_Data.Object :=
- Object_Name (File_Name, Config.Object_File_Suffix);
- Src_Data.Switches := Switches_Name (File_Name);
+ Id.Unit := Unit;
+ Id.Index := Index;
+ Id.File := File_Name;
+ Id.Display_File := Display_File;
+ Id.Dependency := Lang_Id.Config.Dependency_Kind;
+ Id.Dep_Name := Dependency_Name (File_Name, Id.Dependency);
+ Id.Naming_Exception := Naming_Exception;
+
+ if Id.Compiled and then Id.Object_Exists then
+ Id.Object := Object_Name (File_Name, Config.Object_File_Suffix);
+ Id.Switches := Switches_Name (File_Name);
end if;
if Path /= No_Path then
- Src_Data.Path := (Path, Display_Path);
+ Id.Path := (Path, Display_Path);
Source_Paths_Htable.Set (In_Tree.Source_Paths_HT, Path, Id);
end if;
Unit_Sources_Htable.Set (In_Tree.Unit_Sources_HT, Unit, Id);
end if;
- -- Add the source to the global list
-
- Src_Data.Next_In_Sources := In_Tree.First_Source;
- In_Tree.First_Source := Id;
-
- -- Add the source to the project list
-
- if Source = No_Source then
- Data.First_Source := Id;
- else
- In_Tree.Sources.Table (Source).Next_In_Project := Id;
- end if;
-
- Data.Last_Source := Id;
-
-- Add the source to the language list
- Src_Data.Next_In_Lang := Lang_Id.First_Source;
+ Id.Next_In_Lang := Lang_Id.First_Source;
Lang_Id.First_Source := Id;
- In_Tree.Sources.Table (Id) := Src_Data;
-
if Source_To_Replace /= No_Source then
- Remove_Source (Source_To_Replace, Id, Project, Data, In_Tree);
+ Remove_Source (Source_To_Replace, Id);
end if;
end Add_Source;
When_No_Sources : Error_Warning;
Current_Dir : String)
is
- Data : Project_Data := In_Tree.Projects.Table (Project);
+ Data : Project_Data renames In_Tree.Projects.Table (Project);
Extending : Boolean := False;
begin
Alt_Lang : Alternate_Language_Id;
Alt_Lang_Data : Alternate_Language_Data;
Continuation : Boolean := False;
+ Iter : Source_Iterator;
begin
Language := Data.Languages;
while Language /= No_Language_Index loop
- Source := Data.First_Source;
- Source_Loop : while Source /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Source);
- begin
- exit Source_Loop when Src_Data.Language = Language;
+ -- If there are no sources for this language, check whether
+ -- there are sources for which this is an alternate
+ -- language.
+
+ if Language.First_Source = No_Source then
+ Iter := For_Each_Source (In_Tree => In_Tree,
+ Project => Project);
+ Source_Loop : loop
+ Source := Element (Iter);
+ exit Source_Loop when Source = No_Source
+ or else Source.Language = Language;
- Alt_Lang := Src_Data.Alternate_Languages;
+ Alt_Lang := Source.Alternate_Languages;
Alternate_Loop :
while Alt_Lang /= No_Alternate_Language loop
- Alt_Lang_Data :=
- In_Tree.Alt_Langs.Table (Alt_Lang);
+ Alt_Lang_Data := In_Tree.Alt_Langs.Table (Alt_Lang);
exit Source_Loop
when Alt_Lang_Data.Language = Language;
Alt_Lang := Alt_Lang_Data.Next;
end loop Alternate_Loop;
- Source := Src_Data.Next_In_Project;
- end;
- end loop Source_Loop;
+ Next (Iter);
+ end loop Source_Loop;
- if Source = No_Source then
- Report_No_Sources
- (Project,
- Get_Name_String (Language.Display_Name),
- In_Tree,
- Data.Location,
- Continuation);
- Continuation := True;
+ if Source = No_Source then
+ Report_No_Sources
+ (Project,
+ Get_Name_String (Language.Display_Name),
+ In_Tree,
+ Data.Location,
+ Continuation);
+ Continuation := True;
+ end if;
end if;
Language := Language.Next;
Data.Decl.Attributes,
In_Tree);
- List : String_List_Id;
- Element : String_Element;
- Name : File_Name_Type;
-
- Source : Source_Id;
-
+ List : String_List_Id;
+ Element : String_Element;
+ Name : File_Name_Type;
+ Iter : Source_Iterator;
+ Source : Source_Id;
Project_2 : Project_Id;
- Data_2 : Project_Data;
begin
if not Interfaces.Default then
-- later for the sources in the Interfaces list.
Project_2 := Project;
- Data_2 := Data;
- loop
- Source := Data_2.First_Source;
- while Source /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Source);
- begin
- Src_Data.In_Interfaces := False;
- Source := Src_Data.Next_In_Project;
- end;
- end loop;
-
- Project_2 := Data_2.Extends;
+ while Project_2 /= No_Project loop
+ Iter := For_Each_Source (In_Tree, Project_2);
- exit when Project_2 = No_Project;
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
+ Source.In_Interfaces := False;
+ Next (Iter);
+ end loop;
- Data_2 := In_Tree.Projects.Table (Project_2);
+ Project_2 := In_Tree.Projects.Table (Project_2).Extends;
end loop;
List := Interfaces.Values;
Name := Canonical_Case_File_Name (Element.Value);
Project_2 := Project;
- Data_2 := Data;
Big_Loop :
- loop
- Source := Data_2.First_Source;
- while Source /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Source);
+ while Project_2 /= No_Project loop
+ Iter := For_Each_Source (In_Tree, Project_2);
- begin
- if Src_Data.File = Name then
- if not Src_Data.Locally_Removed then
- Src_Data.In_Interfaces := True;
- Src_Data.Declared_In_Interfaces := True;
-
- if Src_Data.Other_Part /= No_Source then
- In_Tree.Sources.Table
- (Src_Data.Other_Part).In_Interfaces := True;
- In_Tree.Sources.Table
- (Src_Data.Other_Part).Declared_In_Interfaces :=
- True;
- end if;
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
- if Current_Verbosity = High then
- Write_Str (" interface: ");
- Write_Line
- (Get_Name_String (Src_Data.Path.Name));
- end if;
+ if Source.File = Name then
+ if not Source.Locally_Removed then
+ Source.In_Interfaces := True;
+ Source.Declared_In_Interfaces := True;
+
+ if Source.Other_Part /= No_Source then
+ Source.Other_Part.In_Interfaces := True;
+ Source.Other_Part.Declared_In_Interfaces := True;
end if;
- exit Big_Loop;
+ if Current_Verbosity = High then
+ Write_Str (" interface: ");
+ Write_Line (Get_Name_String (Source.Path.Name));
+ end if;
end if;
- Source := Src_Data.Next_In_Project;
- end;
- end loop;
-
- Project_2 := Data_2.Extends;
+ exit Big_Loop;
+ end if;
- exit Big_Loop when Project_2 = No_Project;
+ Next (Iter);
+ end loop;
- Data_2 := In_Tree.Projects.Table (Project_2);
+ Project_2 := In_Tree.Projects.Table (Project_2).Extends;
end loop Big_Loop;
if Source = No_Source then
In_Tree.Projects.Table (Data.Extends).Interfaces_Defined;
if Data.Interfaces_Defined then
- Source := Data.First_Source;
- while Source /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Source);
+ Iter := For_Each_Source (In_Tree, Project);
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
- begin
- if not Src_Data.Declared_In_Interfaces then
- Src_Data.In_Interfaces := False;
- end if;
+ if not Source.Declared_In_Interfaces then
+ Source.In_Interfaces := False;
+ end if;
- Source := Src_Data.Next_In_Project;
- end;
+ Next (Iter);
end loop;
end if;
end if;
-----------------------------------
procedure Process_Exceptions_File_Based
- (Lang_Id : Language_Ptr;
- Kind : Source_Kind)
+ (Lang_Id : Language_Ptr;
+ Kind : Source_Kind)
is
Lang : constant Name_Id := Lang_Id.Name;
Exceptions : Array_Element_Id;
Element : String_Element;
File_Name : File_Name_Type;
Source : Source_Id;
+ Iter : Source_Iterator;
begin
case Kind is
Element := In_Tree.String_Elements.Table (Element_Id);
File_Name := Canonical_Case_File_Name (Element.Value);
- Source := Data.First_Source;
- while Source /= No_Source
- and then In_Tree.Sources.Table (Source).File /= File_Name
+ Iter := For_Each_Source (In_Tree, Project);
loop
- Source := In_Tree.Sources.Table (Source).Next_In_Project;
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source or else Source.File = File_Name;
+ Next (Iter);
end loop;
if Source = No_Source then
Add_Source
(Id => Source,
- Data => Data,
In_Tree => In_Tree,
Project => Project,
- Lang => Lang,
Lang_Id => Lang_Id,
Kind => Kind,
File_Name => File_Name,
-- Check if the file name is already recorded for another
-- language or another kind.
- if In_Tree.Sources.Table (Source).Language /= Lang_Id then
+ if Source.Language /= Lang_Id then
Error_Msg
(Project,
In_Tree,
"the same file cannot be a source of two languages",
Element.Location);
- elsif In_Tree.Sources.Table (Source).Kind /= Kind then
+ elsif Source.Kind /= Kind then
Error_Msg
(Project,
In_Tree,
-----------------------------------
procedure Process_Exceptions_Unit_Based
- (Lang_Id : Language_Ptr;
- Kind : Source_Kind)
+ (Lang_Id : Language_Ptr;
+ Kind : Source_Kind)
is
Lang : constant Name_Id := Lang_Id.Name;
Exceptions : Array_Element_Id;
Source_To_Replace : Source_Id := No_Source;
Other_Project : Project_Id;
Other_Part : Source_Id := No_Source;
+ Iter : Source_Iterator;
begin
case Kind is
-- Check if the source already exists
- Source := In_Tree.First_Source;
Source_To_Replace := No_Source;
+ Iter := For_Each_Source (In_Tree);
- while Source /= No_Source and then
- (In_Tree.Sources.Table (Source).Unit /= Unit or else
- In_Tree.Sources.Table (Source).Index /= Index)
loop
- Source := In_Tree.Sources.Table (Source).Next_In_Sources;
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source
+ or else (Source.Unit = Unit and then Source.Index = Index);
+ Next (Iter);
end loop;
if Source /= No_Source then
- if In_Tree.Sources.Table (Source).Kind /= Kind then
+ if Source.Kind /= Kind then
Other_Part := Source;
loop
- Source :=
- In_Tree.Sources.Table (Source).Next_In_Sources;
+ Next (Iter);
+ Source := Prj.Element (Iter);
exit when Source = No_Source or else
- (In_Tree.Sources.Table (Source).Unit = Unit
- and then
- In_Tree.Sources.Table (Source).Index = Index);
+ (Source.Unit = Unit and then Source.Index = Index);
end loop;
end if;
if Source /= No_Source then
- Other_Project := In_Tree.Sources.Table (Source).Project;
+ Other_Project := Source.Project;
if Is_Extending (Project, Other_Project, In_Tree) then
- Other_Part :=
- In_Tree.Sources.Table (Source).Other_Part;
+ Other_Part := Source.Other_Part;
-- Record the source to be removed
if Source = No_Source then
Add_Source
(Id => Source,
- Data => Data,
In_Tree => In_Tree,
Project => Project,
- Lang => Lang,
Lang_Id => Lang_Id,
Kind => Kind,
File_Name => File_Name,
procedure Check_Library (Proj : Project_Id; Extends : Boolean) is
Proj_Data : Project_Data;
Src_Id : Source_Id;
+ Iter : Source_Iterator;
begin
if Proj /= No_Project then
-- have no sources. However, header files from non-Ada
-- languages are OK, as there is nothing to compile.
- Src_Id := Proj_Data.First_Source;
- while Src_Id /= No_Source loop
- declare
- Src : Source_Data renames In_Tree.Sources.Table (Src_Id);
- begin
- exit when Src.Lang_Kind /= File_Based
- or else Src.Kind /= Spec;
- Src_Id := Src.Next_In_Project;
- end;
+ Iter := For_Each_Source (In_Tree, Proj);
+ loop
+ Src_Id := Prj.Element (Iter);
+ exit when Src_Id = No_Source
+ or else Src_Id.Lang_Kind /= File_Based
+ or else Src_Id.Kind /= Spec;
+ Next (Iter);
end loop;
if Src_Id /= No_Source then
Continuation := Continuation_String'Access;
end if;
- elsif Data.Library_Kind /= Static then
+ elsif (not Unchecked_Shared_Lib_Imports)
+ and then Data.Library_Kind /= Static
+ then
Error_Msg
(Project, In_Tree,
Continuation.all &
"shared library project %% cannot extend static " &
"library project %%",
Data.Location);
+ Continuation := Continuation_String'Access;
- else
+ elsif not Unchecked_Shared_Lib_Imports then
Error_Msg
(Project, In_Tree,
Continuation.all &
"shared library project %% cannot import static " &
"library project %%",
Data.Location);
+ Continuation := Continuation_String'Access;
end if;
- Continuation := Continuation_String'Access;
end if;
end if;
end Check_Library;
Prj.Util.Value_Of
(Name_Default_Language, Data.Decl.Attributes, In_Tree);
- -- ??? Shouldn't these be set to False by default, and only set to True
- -- when we actually find some source file ?
-
- Data.Ada_Sources_Present := Data.Source_Dirs /= Nil_String;
- Data.Other_Sources_Present := Data.Source_Dirs /= Nil_String;
+ -- Shouldn't these be set to False by default, and only set to True when
+ -- we actually find some source file???
if Data.Source_Dirs /= Nil_String then
Data.Languages.Config.Kind := Unit_Based;
Data.Languages.Config.Dependency_Kind :=
ALI_File;
-
- -- Attribute Languages is not specified. So, it defaults to
- -- a project of language Ada only. No sources of languages
- -- other than Ada
-
- Data.Other_Sources_Present := False;
-
else
Data.Languages.Config.Kind := File_Based;
end if;
NL_Id : Language_Ptr;
begin
- -- Assume there are no language declared
-
- Data.Ada_Sources_Present := False;
- Data.Other_Sources_Present := False;
-
-- If there are no languages declared, there are no sources
if Current = Nil_String then
Lang_Name := Name_Find;
-- If the language was not already specified (duplicates
- -- are simply ignored)
+ -- are simply ignored).
+
NL_Id := Data.Languages;
while NL_Id /= No_Language_Index loop
exit when Lang_Name = NL_Id.Name;
end loop;
if NL_Id = No_Language_Index then
- if Get_Mode = Ada_Only then
- -- Check for language Ada
-
- if Lang_Name = Name_Ada then
- Data.Ada_Sources_Present := True;
-
- else
- Data.Other_Sources_Present := True;
- end if;
- end if;
-
Index := new Language_Data'(No_Language_Data);
Index.Name := Lang_Name;
Index.Display_Name := Element.Value;
if Lang_Name = Name_Ada then
Index.Config.Kind := Unit_Based;
Index.Config.Dependency_Kind := ALI_File;
+
else
Index.Config.Kind := File_Based;
Index.Config.Dependency_Kind := None;
OK : Boolean := True;
Source : Source_Id;
Next_Proj : Project_Id;
+ Iter : Source_Iterator;
begin
if Get_Mode = Multi_Language then
Project, In_Tree, Extending)
then
-- There is a body for this unit.
- -- If there is no spec, we need to check
- -- that it is not a subunit.
+ -- If there is no spec, we need to check that it
+ -- is not a subunit.
if The_Unit_Data.File_Names
(Specification).Name = No_File
end;
end if;
- -- The unit is not a subunit, so we add
- -- to the Interface ALIs the ALI file
- -- corresponding to the body.
+ -- The unit is not a subunit, so we add the
+ -- ALI file for its body to the Interface ALIs.
Add_ALI_For
(The_Unit_Data.File_Names (Body_Part).Name);
end if;
elsif The_Unit_Data.File_Names
- (Specification).Name /= No_File
+ (Specification).Name /= No_File
and then The_Unit_Data.File_Names
- (Specification).Path.Name /= Slash
+ (Specification).Path.Name /= Slash
and then Check_Project
- (The_Unit_Data.File_Names
- (Specification).Project,
- Project, In_Tree, Extending)
+ (The_Unit_Data.File_Names
+ (Specification).Project,
+ Project, In_Tree, Extending)
then
- -- The unit is part of the project, it has
- -- a spec, but no body. We add to the Interface
- -- ALIs the ALI file corresponding to the spec.
+ -- The unit is part of the project, it has a spec,
+ -- but no body. We add the ALI for its spec to the
+ -- Interface ALIs.
Add_ALI_For
(The_Unit_Data.File_Names (Specification).Name);
-- Multi_Language mode
Next_Proj := Data.Extends;
- Source := Data.First_Source;
+
+ Iter := For_Each_Source (In_Tree, Project);
loop
- while Source /= No_Source and then
- In_Tree.Sources.Table (Source).Unit /= Unit
+ while Prj.Element (Iter) /= No_Source and then
+ Prj.Element (Iter).Unit /= Unit
loop
- Source :=
- In_Tree.Sources.Table (Source).Next_In_Project;
+ Next (Iter);
end loop;
+ Source := Prj.Element (Iter);
exit when Source /= No_Source or else
Next_Proj = No_Project;
- Source :=
- In_Tree.Projects.Table (Next_Proj).First_Source;
+ Iter := For_Each_Source (In_Tree, Next_Proj);
Next_Proj :=
In_Tree.Projects.Table (Next_Proj).Extends;
end loop;
if Source /= No_Source then
- if In_Tree.Sources.Table (Source).Kind = Sep then
+ if Source.Kind = Sep then
Source := No_Source;
- elsif In_Tree.Sources.Table (Source).Kind = Spec
- and then
- In_Tree.Sources.Table (Source).Other_Part /=
- No_Source
+ elsif Source.Kind = Spec
+ and then Source.Other_Part /= No_Source
then
- Source := In_Tree.Sources.Table (Source).Other_Part;
+ Source := Source.Other_Part;
end if;
end if;
if Source /= No_Source then
- if In_Tree.Sources.Table (Source).Project /= Project
+ if Source.Project /= Project
and then
- not Is_Extending
- (Project,
- In_Tree.Sources.Table (Source).Project,
- In_Tree)
+ not Is_Extending (Project, Source.Project, In_Tree)
then
Source := No_Source;
end if;
(Interfaces).Location);
else
- if In_Tree.Sources.Table (Source).Kind = Spec and then
- In_Tree.Sources.Table (Source).Other_Part /=
- No_Source
+ if Source.Kind = Spec and then
+ Source.Other_Part /= No_Source
then
- Source := In_Tree.Sources.Table (Source).Other_Part;
+ Source := Source.Other_Part;
end if;
String_Element_Table.Increment_Last
In_Tree.String_Elements.Table
(String_Element_Table.Last
(In_Tree.String_Elements)) :=
- (Value =>
- Name_Id (In_Tree.Sources.Table (Source).Dep_Name),
+ (Value => Name_Id (Source.Dep_Name),
Index => 0,
- Display_Value =>
- Name_Id (In_Tree.Sources.Table (Source).Dep_Name),
+ Display_Value => Name_Id (Source.Dep_Name),
Location =>
In_Tree.String_Elements.Table
(Interfaces).Location,
else
-- Library_Auto_Init cannot be "true" if auto init is not
- -- supported
+ -- supported.
Error_Msg
(Project, In_Tree,
Spec_Suffix : File_Name_Type;
Casing : Casing_Type;
Kind : out Source_Kind;
- Unit : out Name_Id)
+ Unit : out Name_Id;
+ In_Tree : Project_Tree_Ref)
is
Filename : constant String := Get_Name_String (File_Name);
Last : Integer := Filename'Last;
-- If it is potentially a run time source, disable filling
-- of the mapping file to avoid warnings.
- Set_Mapping_File_Initial_State_To_Empty;
+ Set_Mapping_File_Initial_State_To_Empty (In_Tree);
end if;
end if;
end;
Spec_Suffix => Spec_Suffix_Id_Of (In_Tree, Name_Ada, Naming),
Casing => Naming.Casing,
Kind => Kind,
- Unit => Unit_Name);
+ Unit => Unit_Name,
+ In_Tree => In_Tree);
case Kind is
when Spec => Unit_Kind := Specification;
Name : File_Name_Type;
begin
- if Get_Mode = Ada_Only then
- Data.Ada_Sources_Present := Current /= Nil_String;
- end if;
-
if Get_Mode = Multi_Language then
if Current = Nil_String then
Data.Languages := No_Language_Index;
declare
Source : Source_Id;
+ Iter : Source_Iterator;
begin
- Source := Data.First_Source;
- while Source /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Source);
-
- begin
- if Src_Data.Naming_Exception
- and then Src_Data.Path = No_Path_Information
- then
- if Src_Data.Unit /= No_Name then
- Error_Msg_Name_1 := Name_Id (Src_Data.Display_File);
- Error_Msg_Name_2 := Name_Id (Src_Data.Unit);
- Error_Msg
- (Project, In_Tree,
- "source file %% for unit %% not found",
- No_Location);
- end if;
+ Iter := For_Each_Source (In_Tree, Project);
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
- Remove_Source (Source, No_Source, Project, Data, In_Tree);
+ if Source.Naming_Exception
+ and then Source.Path = No_Path_Information
+ then
+ if Source.Unit /= No_Name then
+ Error_Msg_Name_1 := Name_Id (Source.Display_File);
+ Error_Msg_Name_2 := Name_Id (Source.Unit);
+ Error_Msg
+ (Project, In_Tree,
+ "source file %% for unit %% not found",
+ No_Location);
end if;
- Source := Src_Data.Next_In_Project;
- end;
+ Remove_Source (Source, No_Source);
+ end if;
+
+ Next (Iter);
end loop;
end;
then
-- We should have found at least one source, if not report an error
- if Data.Ada_Sources = Nil_String then
+ if not Has_Ada_Sources (Data) then
Report_No_Sources
(Project, "Ada", In_Tree, Source_List_File.Location);
end if;
Spec_Suffix => Config.Naming_Data.Spec_Suffix,
Casing => Config.Naming_Data.Casing,
Kind => Kind,
- Unit => Unit);
+ Unit => Unit,
+ In_Tree => In_Tree);
if Unit /= No_Name then
Language := Tmp_Lang;
Display_Language_Name : Name_Id;
Lang_Kind : Language_Kind;
Kind : Source_Kind := Spec;
+ Iter : Source_Iterator;
begin
Name_Len := Display_Path'Length;
Check_Name := True;
else
- In_Tree.Sources.Table (Name_Loc.Source).Path :=
- (Path_Id, Display_Path_Id);
+ Name_Loc.Source.Path := (Path_Id, Display_Path_Id);
Source_Paths_Htable.Set
(In_Tree.Source_Paths_HT,
-- Check if this is a subunit
- if In_Tree.Sources.Table (Name_Loc.Source).Unit /= No_Name
- and then
- In_Tree.Sources.Table (Name_Loc.Source).Kind = Impl
+ if Name_Loc.Source.Unit /= No_Name
+ and then Name_Loc.Source.Kind = Impl
then
Src_Ind := Sinput.P.Load_Project_File
(Get_Name_String (Path_Id));
if Sinput.P.Source_File_Is_Subunit (Src_Ind) then
- In_Tree.Sources.Table (Name_Loc.Source).Kind := Sep;
+ Name_Loc.Source.Kind := Sep;
end if;
end if;
end if;
else
-- Check if the same file name or unit is used in the prj tree
- Source := In_Tree.First_Source;
+ Iter := For_Each_Source (In_Tree);
Add_Src := True;
- while Source /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Source);
-
- begin
- if Unit /= No_Name
- and then Src_Data.Unit = Unit
- and then
- ((Src_Data.Kind = Spec and then Kind = Impl)
- or else
- (Src_Data.Kind = Impl and then Kind = Spec))
- then
- Other_Part := Source;
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
- elsif (Unit /= No_Name
- and then Src_Data.Unit = Unit
- and then
- (Src_Data.Kind = Kind
- or else
- (Src_Data.Kind = Sep and then Kind = Impl)
- or else
- (Src_Data.Kind = Impl and then Kind = Sep)))
+ if Unit /= No_Name
+ and then Source.Unit = Unit
+ and then
+ ((Source.Kind = Spec and then Kind = Impl)
or else
- (Unit = No_Name and then Src_Data.File = File_Name)
- then
- -- Duplication of file/unit in same project is only
- -- allowed if order of source directories is known.
-
- if Project = Src_Data.Project then
- if Data.Known_Order_Of_Source_Dirs then
- Add_Src := False;
-
- elsif Unit /= No_Name then
- Error_Msg_Name_1 := Unit;
- Error_Msg
- (Project, In_Tree, "duplicate unit %%",
- No_Location);
- Add_Src := False;
-
- else
- Error_Msg_File_1 := File_Name;
- Error_Msg
- (Project, In_Tree, "duplicate source file name {",
- No_Location);
- Add_Src := False;
- end if;
-
- -- Do not allow the same unit name in different
- -- projects, except if one is extending the other.
+ (Source.Kind = Impl and then Kind = Spec))
+ then
+ Other_Part := Source;
- -- For a file based language, the same file name
- -- replaces a file in a project being extended, but
- -- it is allowed to have the same file name in
- -- unrelated projects.
+ elsif (Unit /= No_Name
+ and then Source.Unit = Unit
+ and then
+ (Source.Kind = Kind
+ or else
+ (Source.Kind = Sep and then Kind = Impl)
+ or else
+ (Source.Kind = Impl and then Kind = Sep)))
+ or else
+ (Unit = No_Name and then Source.File = File_Name)
+ then
+ -- Duplication of file/unit in same project is only
+ -- allowed if order of source directories is known.
- elsif Is_Extending
- (Project, Src_Data.Project, In_Tree)
- then
- Source_To_Replace := Source;
+ if Project = Source.Project then
+ if Data.Known_Order_Of_Source_Dirs then
+ Add_Src := False;
- elsif Unit /= No_Name
- and then not Src_Data.Locally_Removed
- then
+ elsif Unit /= No_Name then
Error_Msg_Name_1 := Unit;
Error_Msg
- (Project, In_Tree,
- "unit %% cannot belong to several projects",
+ (Project, In_Tree, "duplicate unit %%",
No_Location);
+ Add_Src := False;
- Error_Msg_Name_1 :=
- In_Tree.Projects.Table (Project).Name;
- Error_Msg_Name_2 := Name_Id (Display_Path_Id);
- Error_Msg
- (Project, In_Tree, "\ project %%, %%", No_Location);
-
- Error_Msg_Name_1 :=
- In_Tree.Projects.Table (Src_Data.Project).Name;
- Error_Msg_Name_2 :=
- Name_Id (Src_Data.Path.Display_Name);
+ else
+ Error_Msg_File_1 := File_Name;
Error_Msg
- (Project, In_Tree, "\ project %%, %%", No_Location);
-
+ (Project, In_Tree, "duplicate source file name {",
+ No_Location);
Add_Src := False;
end if;
+
+ -- Do not allow the same unit name in different
+ -- projects, except if one is extending the other.
+
+ -- For a file based language, the same file name
+ -- replaces a file in a project being extended, but
+ -- it is allowed to have the same file name in
+ -- unrelated projects.
+
+ elsif Is_Extending
+ (Project, Source.Project, In_Tree)
+ then
+ Source_To_Replace := Source;
+
+ elsif Unit /= No_Name
+ and then not Source.Locally_Removed
+ then
+ Error_Msg_Name_1 := Unit;
+ Error_Msg
+ (Project, In_Tree,
+ "unit %% cannot belong to several projects",
+ No_Location);
+
+ Error_Msg_Name_1 :=
+ In_Tree.Projects.Table (Project).Name;
+ Error_Msg_Name_2 := Name_Id (Display_Path_Id);
+ Error_Msg
+ (Project, In_Tree, "\ project %%, %%", No_Location);
+
+ Error_Msg_Name_1 :=
+ In_Tree.Projects.Table (Source.Project).Name;
+ Error_Msg_Name_2 := Name_Id (Source.Path.Display_Name);
+ Error_Msg
+ (Project, In_Tree, "\ project %%, %%", No_Location);
+
+ Add_Src := False;
end if;
+ end if;
- Source := Src_Data.Next_In_Sources;
- end;
+ Next (Iter);
end loop;
if Add_Src then
Add_Source
(Id => Source,
- Data => Data,
In_Tree => In_Tree,
Project => Project,
- Lang => Language_Name,
Lang_Id => Language,
Lang_Kind => Lang_Kind,
Kind => Kind,
procedure Load_Naming_Exceptions
(Project : Project_Id;
- In_Tree : Project_Tree_Ref;
- Data : in out Project_Data)
+ In_Tree : Project_Tree_Ref)
is
Source : Source_Id;
- File : File_Name_Type;
- Unit : Name_Id;
+ Iter : Source_Iterator;
begin
Unit_Exceptions.Reset;
- Source := Data.First_Source;
- while Source /= No_Source loop
- File := In_Tree.Sources.Table (Source).File;
- Unit := In_Tree.Sources.Table (Source).Unit;
+ Iter := For_Each_Source (In_Tree, Project);
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
-- An excluded file cannot also be an exception file name
- if Excluded_Sources_Htable.Get (File) /= No_File_Found then
- Error_Msg_File_1 := File;
+ if Excluded_Sources_Htable.Get (Source.File) /= No_File_Found then
+ Error_Msg_File_1 := Source.File;
Error_Msg
(Project, In_Tree,
"{ cannot be both excluded and an exception file name",
end if;
if Current_Verbosity = High then
- Write_Str ("Naming exception: Putting source #");
- Write_Str (Source'Img);
- Write_Str (", file ");
- Write_Str (Get_Name_String (File));
+ Write_Str ("Naming exception: Putting source file ");
+ Write_Str (Get_Name_String (Source.File));
Write_Line (" in Source_Names");
end if;
Source_Names.Set
- (K => File,
+ (K => Source.File,
E => Name_Location'
- (Name => File,
+ (Name => Source.File,
Location => No_Location,
Source => Source,
- Except => Unit /= No_Name,
+ Except => Source.Unit /= No_Name,
Found => False));
-- If this is an Ada exception, record in table Unit_Exceptions
- if Unit /= No_Name then
+ if Source.Unit /= No_Name then
declare
- Unit_Except : Unit_Exception := Unit_Exceptions.Get (Unit);
+ Unit_Except : Unit_Exception :=
+ Unit_Exceptions.Get (Source.Unit);
begin
- Unit_Except.Name := Unit;
+ Unit_Except.Name := Source.Unit;
- if In_Tree.Sources.Table (Source).Kind = Spec then
- Unit_Except.Spec := File;
+ if Source.Kind = Spec then
+ Unit_Except.Spec := Source.File;
else
- Unit_Except.Impl := File;
+ Unit_Except.Impl := Source.File;
end if;
- Unit_Exceptions.Set (Unit, Unit_Except);
+ Unit_Exceptions.Set (Source.Unit, Unit_Except);
end;
end if;
- Source := In_Tree.Sources.Table (Source).Next_In_Project;
+ Next (Iter);
end loop;
end Load_Naming_Exceptions;
Data : in out Project_Data;
Current_Dir : String)
is
+ Iter : Source_Iterator;
+
procedure Process_Sources_In_Multi_Language_Mode;
-- Find all source files when in multi language mode
end if;
if Source /= No_Source then
- In_Tree.Sources.Table (Source).Locally_Removed := True;
- In_Tree.Sources.Table (Source).In_Interfaces := False;
+ Source.Locally_Removed := True;
+ Source.In_Interfaces := False;
end if;
if Current_Verbosity = High then
end loop For_Each_Unit;
when Multi_Language =>
- Source := In_Tree.First_Source;
- while Source /= No_Source loop
- if In_Tree.Sources.Table (Source).File = Excluded.File then
- Exclude
- (In_Tree.Sources.Table (Source).Project,
- No_Unit_Index, Specification);
+ Iter := For_Each_Source (In_Tree);
+ loop
+ Source := Prj.Element (Iter);
+ exit when Source = No_Source;
+
+ if Source.File = Excluded.File then
+ Exclude (Source.Project, No_Unit_Index, Specification);
exit;
end if;
- Source := In_Tree.Sources.Table (Source).Next_In_Sources;
+ Next (Iter);
end loop;
OK := OK or Excluded.Found;
--------------------------------------------
procedure Process_Sources_In_Multi_Language_Mode is
+ Iter : Source_Iterator;
begin
-- Check that two sources of this project do not have the same object
-- file name.
Src_Id : Source_Id;
Source_Name : File_Name_Type;
- procedure Check_Object (Src_Data : Source_Data);
+ procedure Check_Object (Src : Source_Id);
-- Check if object file name of the current source is already in
-- hash table Object_File_Names. If it is, report an error. If it
-- is not, put it there with the file name of the current source.
-- Check_Object --
------------------
- procedure Check_Object (Src_Data : Source_Data) is
+ procedure Check_Object (Src : Source_Id) is
begin
- Source_Name := Object_File_Names.Get (Src_Data.Object);
+ Source_Name := Object_File_Names.Get (Src.Object);
if Source_Name /= No_File then
- Error_Msg_File_1 := Src_Data.File;
+ Error_Msg_File_1 := Src.File;
Error_Msg_File_2 := Source_Name;
Error_Msg
(Project,
No_Location);
else
- Object_File_Names.Set (Src_Data.Object, Src_Data.File);
+ Object_File_Names.Set (Src.Object, Src.File);
end if;
end Check_Object;
begin
Object_File_Names.Reset;
- Src_Id := In_Tree.First_Source;
- while Src_Id /= No_Source loop
- declare
- Src_Data : Source_Data renames
- In_Tree.Sources.Table (Src_Id);
-
- begin
- if Src_Data.Compiled and then Src_Data.Object_Exists
- and then Is_Extending (Project, Src_Data.Project, In_Tree)
- then
- if Src_Data.Unit = No_Name then
- if Src_Data.Kind = Impl then
- Check_Object (Src_Data);
- end if;
+ Iter := For_Each_Source (In_Tree);
+ loop
+ Src_Id := Prj.Element (Iter);
+ exit when Src_Id = No_Source;
- else
- case Src_Data.Kind is
- when Spec =>
- if Src_Data.Other_Part = No_Source then
- Check_Object (Src_Data);
- end if;
+ if Src_Id.Compiled and then Src_Id.Object_Exists
+ and then Is_Extending (Project, Src_Id.Project, In_Tree)
+ then
+ if Src_Id.Unit = No_Name then
+ if Src_Id.Kind = Impl then
+ Check_Object (Src_Id);
+ end if;
- when Sep =>
- null;
+ else
+ case Src_Id.Kind is
+ when Spec =>
+ if Src_Id.Other_Part = No_Source then
+ Check_Object (Src_Id);
+ end if;
- when Impl =>
- if Src_Data.Other_Part /= No_Source then
- Check_Object (Src_Data);
+ when Sep =>
+ null;
- else
- -- Check if it is a subunit
+ when Impl =>
+ if Src_Id.Other_Part /= No_Source then
+ Check_Object (Src_Id);
- declare
- Src_Ind : constant Source_File_Index :=
- Sinput.P.Load_Project_File
- (Get_Name_String
- (Src_Data.Path.Name));
- begin
- if Sinput.P.Source_File_Is_Subunit
- (Src_Ind)
- then
- In_Tree.Sources.Table (Src_Id).Kind :=
- Sep;
- else
- Check_Object (Src_Data);
- end if;
- end;
- end if;
- end case;
- end if;
+ else
+ -- Check if it is a subunit
+
+ declare
+ Src_Ind : constant Source_File_Index :=
+ Sinput.P.Load_Project_File
+ (Get_Name_String
+ (Src_Id.Path.Name));
+ begin
+ if Sinput.P.Source_File_Is_Subunit
+ (Src_Ind)
+ then
+ Src_Id.Kind := Sep;
+ else
+ Check_Object (Src_Id);
+ end if;
+ end;
+ end if;
+ end case;
end if;
+ end if;
- Src_Id := Src_Data.Next_In_Sources;
- end;
+ Next (Iter);
end loop;
end Check_Object_File_Names;
end Process_Sources_In_Multi_Language_Mode;
and then Data.Languages /= No_Language_Index)
then
if Get_Mode = Multi_Language then
- Load_Naming_Exceptions (Project, In_Tree, Data);
+ Load_Naming_Exceptions (Project, In_Tree);
end if;
Find_Explicit_Sources (Current_Dir, Project, In_Tree, Data);
procedure Remove_Source
(Id : Source_Id;
- Replaced_By : Source_Id;
- Project : Project_Id;
- Data : in out Project_Data;
- In_Tree : Project_Tree_Ref)
+ Replaced_By : Source_Id)
is
- Src_Data : constant Source_Data := In_Tree.Sources.Table (Id);
Source : Source_Id;
begin
if Current_Verbosity = High then
- Write_Str ("Removing source #");
- Write_Line (Id'Img);
+ Write_Str ("Removing source ");
+ Write_Line (Get_Name_String (Id.File));
end if;
if Replaced_By /= No_Source then
- In_Tree.Sources.Table (Id).Replaced_By := Replaced_By;
- In_Tree.Sources.Table (Replaced_By).Declared_In_Interfaces :=
- In_Tree.Sources.Table (Id).Declared_In_Interfaces;
- end if;
-
- -- Remove the source from the global source list
-
- Source := In_Tree.First_Source;
-
- if Source = Id then
- In_Tree.First_Source := Src_Data.Next_In_Sources;
-
- else
- while In_Tree.Sources.Table (Source).Next_In_Sources /= Id loop
- Source := In_Tree.Sources.Table (Source).Next_In_Sources;
- end loop;
-
- In_Tree.Sources.Table (Source).Next_In_Sources :=
- Src_Data.Next_In_Sources;
- end if;
-
- -- Remove the source from the project list
-
- if Src_Data.Project = Project then
- Source := Data.First_Source;
-
- if Source = Id then
- Data.First_Source := Src_Data.Next_In_Project;
-
- if Src_Data.Next_In_Project = No_Source then
- Data.Last_Source := No_Source;
- end if;
-
- else
- while In_Tree.Sources.Table (Source).Next_In_Project /= Id loop
- Source := In_Tree.Sources.Table (Source).Next_In_Project;
- end loop;
-
- In_Tree.Sources.Table (Source).Next_In_Project :=
- Src_Data.Next_In_Project;
-
- if Src_Data.Next_In_Project = No_Source then
- In_Tree.Projects.Table (Src_Data.Project).Last_Source := Source;
- end if;
- end if;
-
- else
- Source := In_Tree.Projects.Table (Src_Data.Project).First_Source;
-
- if Source = Id then
- In_Tree.Projects.Table (Src_Data.Project).First_Source :=
- Src_Data.Next_In_Project;
-
- if Src_Data.Next_In_Project = No_Source then
- In_Tree.Projects.Table (Src_Data.Project).Last_Source :=
- No_Source;
- end if;
-
- else
- while In_Tree.Sources.Table (Source).Next_In_Project /= Id loop
- Source := In_Tree.Sources.Table (Source).Next_In_Project;
- end loop;
-
- In_Tree.Sources.Table (Source).Next_In_Project :=
- Src_Data.Next_In_Project;
-
- if Src_Data.Next_In_Project = No_Source then
- In_Tree.Projects.Table (Src_Data.Project).Last_Source := Source;
- end if;
- end if;
+ Id.Replaced_By := Replaced_By;
+ Replaced_By.Declared_In_Interfaces := Id.Declared_In_Interfaces;
end if;
- -- Remove source from the language list
-
- Source := Src_Data.Language.First_Source;
+ Source := Id.Language.First_Source;
if Source = Id then
- Src_Data.Language.First_Source := Src_Data.Next_In_Lang;
+ Id.Language.First_Source := Id.Next_In_Lang;
else
- while In_Tree.Sources.Table (Source).Next_In_Lang /= Id loop
- Source := In_Tree.Sources.Table (Source).Next_In_Lang;
+ while Source.Next_In_Lang /= Id loop
+ Source := Source.Next_In_Lang;
end loop;
- In_Tree.Sources.Table (Source).Next_In_Lang :=
- Src_Data.Next_In_Lang;
+ Source.Next_In_Lang := Id.Next_In_Lang;
end if;
end Remove_Source;