+2009-04-24 Robert Dewar <dewar@adacore.com>
+
+ * prj-env.adb, prj-proc.adb, prj.adb, prj.ads,
+ rtsfind.adb: Minor reformatting.
+ Minor code reorganization
+
2009-04-24 Arnaud Charlet <charlet@adacore.com>
* mlib-prj.adb: Use friendlier english identifier.
procedure Add (Project : Project_Id; Dummy : in out Boolean) is
pragma Unreferenced (Dummy);
Path : constant Path_Name_Type :=
- Get_Object_Directory
- (In_Tree, Project,
- Including_Libraries => Including_Libraries,
- Only_If_Ada => False);
+ Get_Object_Directory
+ (In_Tree, Project,
+ Including_Libraries => Including_Libraries,
+ Only_If_Ada => False);
begin
if Path /= No_Path then
Add_To_Path (Get_Name_String (Path), In_Tree);
procedure For_Project (Prj : Project_Id; Dummy : in out Integer) is
pragma Unreferenced (Dummy);
+
Data : Project_Data renames In_Tree.Projects.Table (Prj);
+
begin
-- ??? Set_Ada_Paths has a different behavior for library project
-- files, should we have the same ?
procedure For_Project (Prj : Project_Id; Dummy : in out Integer) is
pragma Unreferenced (Dummy);
+
Data : Project_Data renames In_Tree.Projects.Table (Prj);
Current : String_List_Id := Data.Source_Dirs;
The_String : String_Element;
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
Including_Libraries : Boolean)
+
is
Source_FD : File_Descriptor := Invalid_FD;
Object_FD : File_Descriptor := Invalid_FD;
procedure Recursive_Add (Project : Project_Id; Dummy : in out Boolean) is
pragma Unreferenced (Dummy);
+
Data : constant Project_Data := In_Tree.Projects.Table (Project);
Path : Path_Name_Type;
+
begin
-- ??? This is almost the equivalent of For_All_Source_Dirs
+
if Process_Source_Dirs then
- -- Add to path all source directories of this project if
- -- there are Ada sources.
+ -- Add to path all source directories of this project if there are
+ -- Ada sources.
if Has_Ada_Sources (In_Tree.Projects.Table (Project)) then
Add_To_Source_Path (Data.Source_Dirs, In_Tree);
-- Start of processing for Set_Ada_Paths
begin
- -- If it is the first time we call this procedure for
- -- this project, compute the source path and/or the object path.
+ -- If it is the first time we call this procedure for this project,
+ -- compute the source path and/or the object path.
if In_Tree.Projects.Table (Project).Include_Path_File = No_Path then
Process_Source_Dirs := True;
procedure Check_All_Projects is new
For_Every_Project_Imported (Recursive_Check_Data, Recursive_Check);
+
Data : Recursive_Check_Data :=
(In_Tree, Dir'Unchecked_Access, When_No_Sources);
+
begin
Check_All_Projects (Project, In_Tree, Data, Imported_First => True);
Naming_Restricted : Boolean;
In_Tree : Project_Tree_Ref)
is
- V1 : Variable_Id := From.Attributes;
- V2 : Variable_Id := No_Variable;
+ V1 : Variable_Id;
+ V2 : Variable_Id := No_Variable;
Var : Variable;
- A1 : Array_Id := From.Arrays;
- A2 : Array_Id := No_Array;
+ A1 : Array_Id;
+ A2 : Array_Id := No_Array;
Arr : Array_Data;
E1 : Array_Element_Id;
E2 : Array_Element_Id := No_Array_Element;
-- First single attributes
+ V1 := From.Attributes;
while V1 /= No_Variable loop
-- Copy the attribute
-- Then the associated array attributes
+ A1 := From.Arrays;
while A1 /= No_Array loop
-
Arr := In_Tree.Arrays.Table (A1);
A1 := Arr.Next;
if not Naming_Restricted or else
(Arr.Name /= Snames.Name_Body
- and then Arr.Name /= Snames.Name_Spec
- and then Arr.Name /= Snames.Name_Implementation
- and then Arr.Name /= Snames.Name_Specification)
+ and then Arr.Name /= Snames.Name_Spec
+ and then Arr.Name /= Snames.Name_Implementation
+ and then Arr.Name /= Snames.Name_Specification)
then
-- Remove the Next component
end if;
Last := String_Element_Table.Last
- (In_Tree.String_Elements);
+ (In_Tree.String_Elements);
+
In_Tree.String_Elements.Table (Last) :=
- (Value =>
- String_Value_Of
- (The_Current_Term,
- From_Project_Node_Tree),
- Index =>
- Source_Index_Of
- (The_Current_Term, From_Project_Node_Tree),
+ (Value => String_Value_Of
+ (The_Current_Term,
+ From_Project_Node_Tree),
+ Index => Source_Index_Of
+ (The_Current_Term,
+ From_Project_Node_Tree),
Display_Value => No_Name,
- Location =>
- Location_Of
- (The_Current_Term,
- From_Project_Node_Tree),
- Flag => False,
- Next => Nil_String);
+ Location => Location_Of
+ (The_Current_Term,
+ From_Project_Node_Tree),
+ Flag => False,
+ Next => Nil_String);
end case;
when N_Literal_String_List =>
begin
if Present (String_Node) then
- -- If String_Node is nil, it is an empty list,
- -- there is nothing to do
+ -- If String_Node is nil, it is an empty list, there is
+ -- nothing to do
Value := Expression
(Project => Project,
if Result.Values = Nil_String then
- -- This literal string list is the first term
- -- in a string list expression
+ -- This literal string list is the first term in a
+ -- string list expression
Result.Values :=
String_Element_Table.Last (In_Tree.String_Elements);
--------------------------------
procedure For_Every_Project_Imported
- (By : Project_Id;
- In_Tree : Project_Tree_Ref;
- With_State : in out State;
+ (By : Project_Id;
+ In_Tree : Project_Tree_Ref;
+ With_State : in out State;
Imported_First : Boolean := False)
is
use Project_Boolean_Htable;
procedure Recursive_Check (Project : Project_Id) is
Data : Project_Data renames In_Tree.Projects.Table (Project);
List : Project_List;
+
begin
if not Get (Seen, Project) then
Set (Seen, Project, True);
---------------------
function Has_Ada_Sources (Data : Project_Data) return Boolean is
- Lang : Language_Ptr := Data.Languages;
+ Lang : Language_Ptr;
+
begin
if Data.Ada_Sources /= Nil_String then
return True;
end if;
+ Lang := Data.Languages;
while Lang /= No_Language_Index loop
if Lang.Name = Name_Ada then
return Lang.First_Source /= No_Source;
-------------------------
function Has_Foreign_Sources (Data : Project_Data) return Boolean is
- Lang : Language_Ptr := Data.Languages;
+ Lang : Language_Ptr;
+
begin
+ Lang := Data.Languages;
while Lang /= No_Language_Index loop
if Lang.Name /= Name_Ada
and then Lang.First_Source /= No_Source
then
return True;
end if;
+
Lang := Lang.Next;
end loop;
function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean is
Dir_Name : constant String := Get_Name_String (Dir);
- Direct : Dir_Type;
- Name : String (1 .. 1_000);
- Last : Natural;
- Result : Boolean := False;
+ Direct : Dir_Type;
+ Name : String (1 .. 1_000);
+ Last : Natural;
+ Result : Boolean := False;
begin
Open (Direct, Dir_Name);
return Result;
exception
- -- If there is any problem, close the directory if open and return
- -- True; the library directory will be added to the path.
+ -- If there is any problem, close the directory if open and return True.
+ -- The library directory will be added to the path.
when others =>
if Is_Open (Direct) then
Only_If_Ada : Boolean := False) return Path_Name_Type
is
Data : Project_Data renames In_Tree.Projects.Table (Project);
+
begin
if (Data.Library and Including_Libraries)
or else
(Data.Object_Directory /= No_Path_Information
- and then (not Including_Libraries or else not Data.Library))
+ and then (not Including_Libraries or else not Data.Library))
then
-- For a library project, add the library ALI directory if there is
-- no object directory or if the library ALI directory contains ALI
elsif not Data.Virtual then
declare
- Add_Object_Dir : Boolean := not Only_If_Ada;
- Prj : Project_Id := Project;
+ Add_Object_Dir : Boolean;
+ Prj : Project_Id;
begin
+ Add_Object_Dir := not Only_If_Ada;
+ Prj := Project;
while not Add_Object_Dir and then Prj /= No_Project loop
if Has_Ada_Sources (In_Tree.Projects.Table (Prj)) then
Add_Object_Dir := True;
end;
end if;
end if;
+
return No_Path;
end Get_Object_Directory;
-----------------------------------
function Ultimate_Extending_Project_Of
- (Proj : Project_Id; In_Tree : Project_Tree_Ref) return Project_Id
+ (Proj : Project_Id;
+ In_Tree : Project_Tree_Ref) return Project_Id
is
- Prj : Project_Id := Proj;
+ Prj : Project_Id;
+
begin
+ Prj := Proj;
while In_Tree.Projects.Table (Prj).Extended_By /= No_Project loop
Prj := In_Tree.Projects.Table (Prj).Extended_By;
end loop;
procedure Add_To_List (Prj : Project_Id) is
Element : constant Project_Element :=
- (Prj, In_Tree.Projects.Table (Project).All_Imported_Projects);
- List : Project_List;
+ (Prj,
+ In_Tree.Projects.Table (Project).All_Imported_Projects);
+ List : Project_List;
+
begin
-- Check that the project is not already in the list. We know the one
-- passed to Recursive_Add have never been visited before, but the
procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean) is
pragma Unreferenced (Dummy);
+
Prj2 : Project_Id;
+
begin
-- A project is not importing itself
+
if Project /= Prj then
Prj2 := Ultimate_Extending_Project_Of (Prj, In_Tree);
Add_To_List (Prj2);
(Project : Project_Id;
With_State : in out State);
procedure For_Every_Project_Imported
- (By : Project_Id;
- In_Tree : Project_Tree_Ref;
- With_State : in out State;
+ (By : Project_Id;
+ In_Tree : Project_Tree_Ref;
+ With_State : in out State;
Imported_First : Boolean := False);
-- Call Action for each project imported directly or indirectly by project
-- By, as well as extended projects.
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2008, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-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- --
Name_Modular_IO => Ada_Wide_Wide_Text_IO_Modular_IO);
begin
- -- Nothing to do if name is not identifier or a selected component
+ -- Nothing to do if name is not an identifier or a selected component
-- whose selector_name is not an identifier.
if Nkind (Nam) = N_Identifier then