Commit 8eaf1723 by Robert Dewar Committed by Arnaud Charlet

prj-env.adb, [...]: Minor reformatting.

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

From-SVN: r146717
parent 879a4a01
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> 2009-04-24 Arnaud Charlet <charlet@adacore.com>
* mlib-prj.adb: Use friendlier english identifier. * mlib-prj.adb: Use friendlier english identifier.
......
...@@ -155,10 +155,10 @@ package body Prj.Env is ...@@ -155,10 +155,10 @@ package body Prj.Env is
procedure Add (Project : Project_Id; Dummy : in out Boolean) is procedure Add (Project : Project_Id; Dummy : in out Boolean) is
pragma Unreferenced (Dummy); pragma Unreferenced (Dummy);
Path : constant Path_Name_Type := Path : constant Path_Name_Type :=
Get_Object_Directory Get_Object_Directory
(In_Tree, Project, (In_Tree, Project,
Including_Libraries => Including_Libraries, Including_Libraries => Including_Libraries,
Only_If_Ada => False); Only_If_Ada => False);
begin begin
if Path /= No_Path then if Path /= No_Path then
Add_To_Path (Get_Name_String (Path), In_Tree); Add_To_Path (Get_Name_String (Path), In_Tree);
...@@ -1323,7 +1323,9 @@ package body Prj.Env is ...@@ -1323,7 +1323,9 @@ package body Prj.Env is
procedure For_Project (Prj : Project_Id; Dummy : in out Integer) is procedure For_Project (Prj : Project_Id; Dummy : in out Integer) is
pragma Unreferenced (Dummy); pragma Unreferenced (Dummy);
Data : Project_Data renames In_Tree.Projects.Table (Prj); Data : Project_Data renames In_Tree.Projects.Table (Prj);
begin begin
-- ??? Set_Ada_Paths has a different behavior for library project -- ??? Set_Ada_Paths has a different behavior for library project
-- files, should we have the same ? -- files, should we have the same ?
...@@ -1361,6 +1363,7 @@ package body Prj.Env is ...@@ -1361,6 +1363,7 @@ package body Prj.Env is
procedure For_Project (Prj : Project_Id; Dummy : in out Integer) is procedure For_Project (Prj : Project_Id; Dummy : in out Integer) is
pragma Unreferenced (Dummy); pragma Unreferenced (Dummy);
Data : Project_Data renames In_Tree.Projects.Table (Prj); Data : Project_Data renames In_Tree.Projects.Table (Prj);
Current : String_List_Id := Data.Source_Dirs; Current : String_List_Id := Data.Source_Dirs;
The_String : String_Element; The_String : String_Element;
...@@ -1656,6 +1659,7 @@ package body Prj.Env is ...@@ -1656,6 +1659,7 @@ package body Prj.Env is
(Project : Project_Id; (Project : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
Including_Libraries : Boolean) Including_Libraries : Boolean)
is is
Source_FD : File_Descriptor := Invalid_FD; Source_FD : File_Descriptor := Invalid_FD;
Object_FD : File_Descriptor := Invalid_FD; Object_FD : File_Descriptor := Invalid_FD;
...@@ -1678,14 +1682,17 @@ package body Prj.Env is ...@@ -1678,14 +1682,17 @@ package body Prj.Env is
procedure Recursive_Add (Project : Project_Id; Dummy : in out Boolean) is procedure Recursive_Add (Project : Project_Id; Dummy : in out Boolean) is
pragma Unreferenced (Dummy); pragma Unreferenced (Dummy);
Data : constant Project_Data := In_Tree.Projects.Table (Project); Data : constant Project_Data := In_Tree.Projects.Table (Project);
Path : Path_Name_Type; Path : Path_Name_Type;
begin begin
-- ??? This is almost the equivalent of For_All_Source_Dirs -- ??? This is almost the equivalent of For_All_Source_Dirs
if Process_Source_Dirs then if Process_Source_Dirs then
-- Add to path all source directories of this project if -- Add to path all source directories of this project if there are
-- there are Ada sources. -- Ada sources.
if Has_Ada_Sources (In_Tree.Projects.Table (Project)) then if Has_Ada_Sources (In_Tree.Projects.Table (Project)) then
Add_To_Source_Path (Data.Source_Dirs, In_Tree); Add_To_Source_Path (Data.Source_Dirs, In_Tree);
...@@ -1711,8 +1718,8 @@ package body Prj.Env is ...@@ -1711,8 +1718,8 @@ package body Prj.Env is
-- Start of processing for Set_Ada_Paths -- Start of processing for Set_Ada_Paths
begin begin
-- If it is the first time we call this procedure for -- If it is the first time we call this procedure for this project,
-- this project, compute the source path and/or the object path. -- compute the source path and/or the object path.
if In_Tree.Projects.Table (Project).Include_Path_File = No_Path then if In_Tree.Projects.Table (Project).Include_Path_File = No_Path then
Process_Source_Dirs := True; Process_Source_Dirs := True;
......
...@@ -281,8 +281,10 @@ package body Prj.Proc is ...@@ -281,8 +281,10 @@ package body Prj.Proc is
procedure Check_All_Projects is new procedure Check_All_Projects is new
For_Every_Project_Imported (Recursive_Check_Data, Recursive_Check); For_Every_Project_Imported (Recursive_Check_Data, Recursive_Check);
Data : Recursive_Check_Data := Data : Recursive_Check_Data :=
(In_Tree, Dir'Unchecked_Access, When_No_Sources); (In_Tree, Dir'Unchecked_Access, When_No_Sources);
begin begin
Check_All_Projects (Project, In_Tree, Data, Imported_First => True); Check_All_Projects (Project, In_Tree, Data, Imported_First => True);
...@@ -333,11 +335,11 @@ package body Prj.Proc is ...@@ -333,11 +335,11 @@ package body Prj.Proc is
Naming_Restricted : Boolean; Naming_Restricted : Boolean;
In_Tree : Project_Tree_Ref) In_Tree : Project_Tree_Ref)
is is
V1 : Variable_Id := From.Attributes; V1 : Variable_Id;
V2 : Variable_Id := No_Variable; V2 : Variable_Id := No_Variable;
Var : Variable; Var : Variable;
A1 : Array_Id := From.Arrays; A1 : Array_Id;
A2 : Array_Id := No_Array; A2 : Array_Id := No_Array;
Arr : Array_Data; Arr : Array_Data;
E1 : Array_Element_Id; E1 : Array_Element_Id;
E2 : Array_Element_Id := No_Array_Element; E2 : Array_Element_Id := No_Array_Element;
...@@ -351,6 +353,7 @@ package body Prj.Proc is ...@@ -351,6 +353,7 @@ package body Prj.Proc is
-- First single attributes -- First single attributes
V1 := From.Attributes;
while V1 /= No_Variable loop while V1 /= No_Variable loop
-- Copy the attribute -- Copy the attribute
...@@ -384,16 +387,16 @@ package body Prj.Proc is ...@@ -384,16 +387,16 @@ package body Prj.Proc is
-- Then the associated array attributes -- Then the associated array attributes
A1 := From.Arrays;
while A1 /= No_Array loop while A1 /= No_Array loop
Arr := In_Tree.Arrays.Table (A1); Arr := In_Tree.Arrays.Table (A1);
A1 := Arr.Next; A1 := Arr.Next;
if not Naming_Restricted or else if not Naming_Restricted or else
(Arr.Name /= Snames.Name_Body (Arr.Name /= Snames.Name_Body
and then Arr.Name /= Snames.Name_Spec and then Arr.Name /= Snames.Name_Spec
and then Arr.Name /= Snames.Name_Implementation and then Arr.Name /= Snames.Name_Implementation
and then Arr.Name /= Snames.Name_Specification) and then Arr.Name /= Snames.Name_Specification)
then then
-- Remove the Next component -- Remove the Next component
...@@ -530,22 +533,21 @@ package body Prj.Proc is ...@@ -530,22 +533,21 @@ package body Prj.Proc is
end if; end if;
Last := String_Element_Table.Last Last := String_Element_Table.Last
(In_Tree.String_Elements); (In_Tree.String_Elements);
In_Tree.String_Elements.Table (Last) := In_Tree.String_Elements.Table (Last) :=
(Value => (Value => String_Value_Of
String_Value_Of (The_Current_Term,
(The_Current_Term, From_Project_Node_Tree),
From_Project_Node_Tree), Index => Source_Index_Of
Index => (The_Current_Term,
Source_Index_Of From_Project_Node_Tree),
(The_Current_Term, From_Project_Node_Tree),
Display_Value => No_Name, Display_Value => No_Name,
Location => Location => Location_Of
Location_Of (The_Current_Term,
(The_Current_Term, From_Project_Node_Tree),
From_Project_Node_Tree), Flag => False,
Flag => False, Next => Nil_String);
Next => Nil_String);
end case; end case;
when N_Literal_String_List => when N_Literal_String_List =>
...@@ -561,8 +563,8 @@ package body Prj.Proc is ...@@ -561,8 +563,8 @@ package body Prj.Proc is
begin begin
if Present (String_Node) then if Present (String_Node) then
-- If String_Node is nil, it is an empty list, -- If String_Node is nil, it is an empty list, there is
-- there is nothing to do -- nothing to do
Value := Expression Value := Expression
(Project => Project, (Project => Project,
...@@ -579,8 +581,8 @@ package body Prj.Proc is ...@@ -579,8 +581,8 @@ package body Prj.Proc is
if Result.Values = Nil_String then if Result.Values = Nil_String then
-- This literal string list is the first term -- This literal string list is the first term in a
-- in a string list expression -- string list expression
Result.Values := Result.Values :=
String_Element_Table.Last (In_Tree.String_Elements); String_Element_Table.Last (In_Tree.String_Elements);
......
...@@ -498,9 +498,9 @@ package body Prj is ...@@ -498,9 +498,9 @@ package body Prj is
-------------------------------- --------------------------------
procedure For_Every_Project_Imported procedure For_Every_Project_Imported
(By : Project_Id; (By : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
With_State : in out State; With_State : in out State;
Imported_First : Boolean := False) Imported_First : Boolean := False)
is is
use Project_Boolean_Htable; use Project_Boolean_Htable;
...@@ -517,6 +517,7 @@ package body Prj is ...@@ -517,6 +517,7 @@ package body Prj is
procedure Recursive_Check (Project : Project_Id) is procedure Recursive_Check (Project : Project_Id) is
Data : Project_Data renames In_Tree.Projects.Table (Project); Data : Project_Data renames In_Tree.Projects.Table (Project);
List : Project_List; List : Project_List;
begin begin
if not Get (Seen, Project) then if not Get (Seen, Project) then
Set (Seen, Project, True); Set (Seen, Project, True);
...@@ -1204,12 +1205,14 @@ package body Prj is ...@@ -1204,12 +1205,14 @@ package body Prj is
--------------------- ---------------------
function Has_Ada_Sources (Data : Project_Data) return Boolean is function Has_Ada_Sources (Data : Project_Data) return Boolean is
Lang : Language_Ptr := Data.Languages; Lang : Language_Ptr;
begin begin
if Data.Ada_Sources /= Nil_String then if Data.Ada_Sources /= Nil_String then
return True; return True;
end if; end if;
Lang := Data.Languages;
while Lang /= No_Language_Index loop while Lang /= No_Language_Index loop
if Lang.Name = Name_Ada then if Lang.Name = Name_Ada then
return Lang.First_Source /= No_Source; return Lang.First_Source /= No_Source;
...@@ -1225,14 +1228,17 @@ package body Prj is ...@@ -1225,14 +1228,17 @@ package body Prj is
------------------------- -------------------------
function Has_Foreign_Sources (Data : Project_Data) return Boolean is function Has_Foreign_Sources (Data : Project_Data) return Boolean is
Lang : Language_Ptr := Data.Languages; Lang : Language_Ptr;
begin begin
Lang := Data.Languages;
while Lang /= No_Language_Index loop while Lang /= No_Language_Index loop
if Lang.Name /= Name_Ada if Lang.Name /= Name_Ada
and then Lang.First_Source /= No_Source and then Lang.First_Source /= No_Source
then then
return True; return True;
end if; end if;
Lang := Lang.Next; Lang := Lang.Next;
end loop; end loop;
...@@ -1245,10 +1251,10 @@ package body Prj is ...@@ -1245,10 +1251,10 @@ package body Prj is
function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean is function Contains_ALI_Files (Dir : Path_Name_Type) return Boolean is
Dir_Name : constant String := Get_Name_String (Dir); Dir_Name : constant String := Get_Name_String (Dir);
Direct : Dir_Type; Direct : Dir_Type;
Name : String (1 .. 1_000); Name : String (1 .. 1_000);
Last : Natural; Last : Natural;
Result : Boolean := False; Result : Boolean := False;
begin begin
Open (Direct, Dir_Name); Open (Direct, Dir_Name);
...@@ -1267,8 +1273,8 @@ package body Prj is ...@@ -1267,8 +1273,8 @@ package body Prj is
return Result; return Result;
exception exception
-- If there is any problem, close the directory if open and return -- If there is any problem, close the directory if open and return True.
-- True; the library directory will be added to the path. -- The library directory will be added to the path.
when others => when others =>
if Is_Open (Direct) then if Is_Open (Direct) then
...@@ -1289,11 +1295,12 @@ package body Prj is ...@@ -1289,11 +1295,12 @@ package body Prj is
Only_If_Ada : Boolean := False) return Path_Name_Type Only_If_Ada : Boolean := False) return Path_Name_Type
is is
Data : Project_Data renames In_Tree.Projects.Table (Project); Data : Project_Data renames In_Tree.Projects.Table (Project);
begin begin
if (Data.Library and Including_Libraries) if (Data.Library and Including_Libraries)
or else or else
(Data.Object_Directory /= No_Path_Information (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 then
-- For a library project, add the library ALI directory if there is -- For a library project, add the library ALI directory if there is
-- no object directory or if the library ALI directory contains ALI -- no object directory or if the library ALI directory contains ALI
...@@ -1316,10 +1323,12 @@ package body Prj is ...@@ -1316,10 +1323,12 @@ package body Prj is
elsif not Data.Virtual then elsif not Data.Virtual then
declare declare
Add_Object_Dir : Boolean := not Only_If_Ada; Add_Object_Dir : Boolean;
Prj : Project_Id := Project; Prj : Project_Id;
begin begin
Add_Object_Dir := not Only_If_Ada;
Prj := Project;
while not Add_Object_Dir and then Prj /= No_Project loop while not Add_Object_Dir and then Prj /= No_Project loop
if Has_Ada_Sources (In_Tree.Projects.Table (Prj)) then if Has_Ada_Sources (In_Tree.Projects.Table (Prj)) then
Add_Object_Dir := True; Add_Object_Dir := True;
...@@ -1334,6 +1343,7 @@ package body Prj is ...@@ -1334,6 +1343,7 @@ package body Prj is
end; end;
end if; end if;
end if; end if;
return No_Path; return No_Path;
end Get_Object_Directory; end Get_Object_Directory;
...@@ -1342,10 +1352,13 @@ package body Prj is ...@@ -1342,10 +1352,13 @@ package body Prj is
----------------------------------- -----------------------------------
function Ultimate_Extending_Project_Of 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 is
Prj : Project_Id := Proj; Prj : Project_Id;
begin begin
Prj := Proj;
while In_Tree.Projects.Table (Prj).Extended_By /= No_Project loop while In_Tree.Projects.Table (Prj).Extended_By /= No_Project loop
Prj := In_Tree.Projects.Table (Prj).Extended_By; Prj := In_Tree.Projects.Table (Prj).Extended_By;
end loop; end loop;
...@@ -1373,8 +1386,10 @@ package body Prj is ...@@ -1373,8 +1386,10 @@ package body Prj is
procedure Add_To_List (Prj : Project_Id) is procedure Add_To_List (Prj : Project_Id) is
Element : constant Project_Element := Element : constant Project_Element :=
(Prj, In_Tree.Projects.Table (Project).All_Imported_Projects); (Prj,
List : Project_List; In_Tree.Projects.Table (Project).All_Imported_Projects);
List : Project_List;
begin begin
-- Check that the project is not already in the list. We know the one -- 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 -- passed to Recursive_Add have never been visited before, but the
...@@ -1402,9 +1417,12 @@ package body Prj is ...@@ -1402,9 +1417,12 @@ package body Prj is
procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean) is procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean) is
pragma Unreferenced (Dummy); pragma Unreferenced (Dummy);
Prj2 : Project_Id; Prj2 : Project_Id;
begin begin
-- A project is not importing itself -- A project is not importing itself
if Project /= Prj then if Project /= Prj then
Prj2 := Ultimate_Extending_Project_Of (Prj, In_Tree); Prj2 := Ultimate_Extending_Project_Of (Prj, In_Tree);
Add_To_List (Prj2); Add_To_List (Prj2);
......
...@@ -1527,9 +1527,9 @@ package Prj is ...@@ -1527,9 +1527,9 @@ package Prj is
(Project : Project_Id; (Project : Project_Id;
With_State : in out State); With_State : in out State);
procedure For_Every_Project_Imported procedure For_Every_Project_Imported
(By : Project_Id; (By : Project_Id;
In_Tree : Project_Tree_Ref; In_Tree : Project_Tree_Ref;
With_State : in out State; With_State : in out State;
Imported_First : Boolean := False); Imported_First : Boolean := False);
-- Call Action for each project imported directly or indirectly by project -- Call Action for each project imported directly or indirectly by project
-- By, as well as extended projects. -- By, as well as extended projects.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- 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 -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -1381,7 +1381,7 @@ package body Rtsfind is ...@@ -1381,7 +1381,7 @@ package body Rtsfind is
Name_Modular_IO => Ada_Wide_Wide_Text_IO_Modular_IO); Name_Modular_IO => Ada_Wide_Wide_Text_IO_Modular_IO);
begin 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. -- whose selector_name is not an identifier.
if Nkind (Nam) = N_Identifier then if Nkind (Nam) = N_Identifier then
......
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