aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/prj-proc.adb
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ada/prj-proc.adb')
-rw-r--r--gcc/ada/prj-proc.adb257
1 files changed, 100 insertions, 157 deletions
diff --git a/gcc/ada/prj-proc.adb b/gcc/ada/prj-proc.adb
index a10d7fe..0ddc9ce 100644
--- a/gcc/ada/prj-proc.adb
+++ b/gcc/ada/prj-proc.adb
@@ -111,7 +111,6 @@ package body Prj.Proc is
function Imported_Or_Extended_Project_From
(Project : Project_Id;
- In_Tree : Project_Tree_Ref;
With_Name : Name_Id) return Project_Id;
-- Find an imported or extended project of Project whose name is With_Name
@@ -295,7 +294,7 @@ package body Prj.Proc is
Data.When_No_Sources := When_No_Sources;
Initialize (Data.Proc_Data);
- Check_All_Projects (Project, In_Tree, Data, Imported_First => True);
+ Check_All_Projects (Project, Data, Imported_First => True);
-- Set the Other_Part field for the units
@@ -683,7 +682,6 @@ package body Prj.Proc is
Name_Of (Term_Project, From_Project_Node_Tree);
The_Project := Imported_Or_Extended_Project_From
(Project => Project,
- In_Tree => In_Tree,
With_Name => The_Name);
end if;
@@ -693,8 +691,7 @@ package body Prj.Proc is
The_Name :=
Name_Of (Term_Package, From_Project_Node_Tree);
- The_Package := In_Tree.Projects.Table
- (The_Project).Decl.Packages;
+ The_Package := The_Project.Decl.Packages;
while The_Package /= No_Package
and then In_Tree.Packages.Table
@@ -767,13 +764,9 @@ package body Prj.Proc is
if Kind_Of (The_Current_Term, From_Project_Node_Tree) =
N_Variable_Reference
then
- The_Variable_Id :=
- In_Tree.Projects.Table
- (The_Project).Decl.Variables;
+ The_Variable_Id := The_Project.Decl.Variables;
else
- The_Variable_Id :=
- In_Tree.Projects.Table
- (The_Project).Decl.Attributes;
+ The_Variable_Id := The_Project.Decl.Attributes;
end if;
while The_Variable_Id /= No_Variable
@@ -811,9 +804,7 @@ package body Prj.Proc is
In_Tree.Packages.Table
(The_Package).Decl.Arrays;
else
- The_Array :=
- In_Tree.Projects.Table
- (The_Project).Decl.Arrays;
+ The_Array := The_Project.Decl.Arrays;
end if;
while The_Array /= No_Array
@@ -1137,10 +1128,8 @@ package body Prj.Proc is
function Imported_Or_Extended_Project_From
(Project : Project_Id;
- In_Tree : Project_Tree_Ref;
With_Name : Name_Id) return Project_Id
is
- Data : constant Project_Data := In_Tree.Projects.Table (Project);
List : Project_List;
Result : Project_Id;
Temp_Result : Project_Id;
@@ -1148,25 +1137,25 @@ package body Prj.Proc is
begin
-- First check if it is the name of an extended project
- Result := Data.Extends;
+ Result := Project.Extends;
while Result /= No_Project loop
- if In_Tree.Projects.Table (Result).Name = With_Name then
+ if Result.Name = With_Name then
return Result;
else
- Result := In_Tree.Projects.Table (Result).Extends;
+ Result := Result.Extends;
end if;
end loop;
-- Then check the name of each imported project
Temp_Result := No_Project;
- List := Data.Imported_Projects;
+ List := Project.Imported_Projects;
while List /= null loop
Result := List.Project;
-- If the project is directly imported, then returns its ID
- if In_Tree.Projects.Table (Result).Name = With_Name then
+ if Result.Name = With_Name then
return Result;
end if;
@@ -1175,16 +1164,16 @@ package body Prj.Proc is
-- if the project is not imported directly.
declare
- Proj : Project_Id := In_Tree.Projects.Table (Result).Extends;
+ Proj : Project_Id := Result.Extends;
begin
while Proj /= No_Project loop
- if In_Tree.Projects.Table (Proj).Name = With_Name then
+ if Proj.Name = With_Name then
Temp_Result := Result;
exit;
end if;
- Proj := In_Tree.Projects.Table (Proj).Extends;
+ Proj := Proj.Extends;
end loop;
end;
@@ -1204,9 +1193,7 @@ package body Prj.Proc is
In_Tree : Project_Tree_Ref;
With_Name : Name_Id) return Package_Id
is
- Data : constant Project_Data :=
- In_Tree.Projects.Table (Project);
- Result : Package_Id := Data.Decl.Packages;
+ Result : Package_Id := Project.Decl.Packages;
begin
-- Check the name of each existing package of Project
@@ -1342,10 +1329,8 @@ package body Prj.Proc is
New_Pkg;
else
- The_New_Package.Next :=
- In_Tree.Projects.Table (Project).Decl.Packages;
- In_Tree.Projects.Table (Project).Decl.Packages :=
- New_Pkg;
+ The_New_Package.Next := Project.Decl.Packages;
+ Project.Decl.Packages := New_Pkg;
end if;
In_Tree.Packages.Table (New_Pkg) :=
@@ -1364,7 +1349,7 @@ package body Prj.Proc is
Renamed_Project :
constant Project_Id :=
Imported_Or_Extended_Project_From
- (Project, In_Tree, Project_Name);
+ (Project, Project_Name);
Renamed_Package : constant Package_Id :=
Package_From
@@ -1398,9 +1383,8 @@ package body Prj.Proc is
Add_Attributes
(Project,
- In_Tree.Projects.Table (Project).Name,
- Name_Id
- (In_Tree.Projects.Table (Project).Directory.Name),
+ Project.Name,
+ Name_Id (Project.Directory.Name),
In_Tree,
In_Tree.Packages.Table (New_Pkg).Decl,
First_Attribute_Of
@@ -1488,6 +1472,8 @@ package body Prj.Proc is
-- associative array attribute may already have been
-- declared, and the array elements declared are reused.
+ Prj : Project_List;
+
begin
-- First find if the associative array attribute already
-- has elements declared.
@@ -1497,8 +1483,7 @@ package body Prj.Proc is
(Pkg).Decl.Arrays;
else
- New_Array := In_Tree.Projects.Table
- (Project).Decl.Arrays;
+ New_Array := Project.Decl.Arrays;
end if;
while New_Array /= No_Array
@@ -1531,11 +1516,9 @@ package body Prj.Proc is
(Name => Current_Item_Name,
Location => Current_Location,
Value => No_Array_Element,
- Next => In_Tree.Projects.Table
- (Project).Decl.Arrays);
+ Next => Project.Decl.Arrays);
- In_Tree.Projects.Table (Project).Decl.Arrays :=
- New_Array;
+ Project.Decl.Arrays := New_Array;
end if;
end if;
@@ -1547,16 +1530,13 @@ package body Prj.Proc is
(Current_Item, From_Project_Node_Tree),
From_Project_Node_Tree);
- for Index in Project_Table.First ..
- Project_Table.Last
- (In_Tree.Projects)
- loop
- if In_Tree.Projects.Table (Index).Name =
- Orig_Project_Name
- then
- Orig_Project := Index;
+ Prj := In_Tree.Projects;
+ while Prj /= null loop
+ if Prj.Project.Name = Orig_Project_Name then
+ Orig_Project := Prj.Project;
exit;
end if;
+ Prj := Prj.Next;
end loop;
pragma Assert (Orig_Project /= No_Project,
@@ -1565,9 +1545,7 @@ package body Prj.Proc is
if No (Associative_Package_Of
(Current_Item, From_Project_Node_Tree))
then
- Orig_Array :=
- In_Tree.Projects.Table
- (Orig_Project).Decl.Arrays;
+ Orig_Array := Orig_Project.Decl.Arrays;
else
-- If in a package, find the package where the value
@@ -1579,9 +1557,7 @@ package body Prj.Proc is
(Current_Item, From_Project_Node_Tree),
From_Project_Node_Tree);
- Orig_Package :=
- In_Tree.Projects.Table
- (Orig_Project).Decl.Packages;
+ Orig_Package := Orig_Project.Decl.Packages;
pragma Assert (Orig_Package /= No_Package,
"original package not found");
@@ -1848,9 +1824,7 @@ package body Prj.Proc is
In_Tree.Packages.Table
(Pkg).Decl.Attributes;
else
- The_Variable :=
- In_Tree.Projects.Table
- (Project).Decl.Attributes;
+ The_Variable := Project.Decl.Attributes;
end if;
else
@@ -1859,9 +1833,7 @@ package body Prj.Proc is
In_Tree.Packages.Table
(Pkg).Decl.Variables;
else
- The_Variable :=
- In_Tree.Projects.Table
- (Project).Decl.Variables;
+ The_Variable := Project.Decl.Variables;
end if;
end if;
@@ -1911,14 +1883,10 @@ package body Prj.Proc is
else
In_Tree.Variable_Elements.Table (The_Variable) :=
- (Next =>
- In_Tree.Projects.Table
- (Project).Decl.Variables,
+ (Next => Project.Decl.Variables,
Name => Current_Item_Name,
Value => New_Value);
- In_Tree.Projects.Table
- (Project).Decl.Variables :=
- The_Variable;
+ Project.Decl.Variables := The_Variable;
end if;
-- If the variable/attribute has already been
@@ -1986,8 +1954,7 @@ package body Prj.Proc is
In_Tree.Packages.Table (Pkg).Decl.Arrays;
else
- The_Array :=
- In_Tree.Projects.Table (Project).Decl.Arrays;
+ The_Array := Project.Decl.Arrays;
end if;
while
@@ -2025,11 +1992,9 @@ package body Prj.Proc is
(Name => Current_Item_Name,
Location => Current_Location,
Value => No_Array_Element,
- Next => In_Tree.Projects.Table
- (Project).Decl.Arrays);
+ Next => Project.Decl.Arrays);
- In_Tree.Projects.Table
- (Project).Decl.Arrays := The_Array;
+ Project.Decl.Arrays := The_Array;
end if;
-- Otherwise initialize The_Array_Element as the
@@ -2131,8 +2096,7 @@ package body Prj.Proc is
(Variable_Node, From_Project_Node_Tree),
From_Project_Node_Tree);
The_Project :=
- Imported_Or_Extended_Project_From
- (Project, In_Tree, Name);
+ Imported_Or_Extended_Project_From (Project, Name);
end if;
-- If a package were specified for the case variable,
@@ -2178,8 +2142,7 @@ package body Prj.Proc is
No (Package_Node_Of
(Variable_Node, From_Project_Node_Tree))
then
- Var_Id := In_Tree.Projects.Table
- (The_Project).Decl.Variables;
+ Var_Id := The_Project.Decl.Variables;
while Var_Id /= No_Variable
and then
In_Tree.Variable_Elements.Table
@@ -2309,7 +2272,7 @@ package body Prj.Proc is
-- Make sure there are no projects in the data structure
- Project_Table.Set_Last (In_Tree.Projects, No_Project);
+ Free_List (In_Tree.Projects, Free_Project => True);
end if;
Processed_Projects.Reset;
@@ -2347,6 +2310,7 @@ package body Prj.Proc is
Obj_Dir : Path_Name_Type;
Extending : Project_Id;
Extending2 : Project_Id;
+ Prj : Project_List;
-- Start of processing for Process_Project_Tree_Phase_2
@@ -2368,16 +2332,14 @@ package body Prj.Proc is
then
declare
Object_Dir : constant Path_Name_Type :=
- In_Tree.Projects.Table
- (Project).Object_Directory.Name;
+ Project.Object_Directory.Name;
begin
- for Index in
- Project_Table.First .. Project_Table.Last (In_Tree.Projects)
- loop
- if In_Tree.Projects.Table (Index).Virtual then
- In_Tree.Projects.Table (Index).Object_Directory.Name :=
- Object_Dir;
+ Prj := In_Tree.Projects;
+ while Prj /= null loop
+ if Prj.Project.Virtual then
+ Prj.Project.Object_Directory.Name := Object_Dir;
end if;
+ Prj := Prj.Next;
end loop;
end;
end if;
@@ -2386,13 +2348,12 @@ package body Prj.Proc is
-- the project(s) it extends.
if Project /= No_Project then
- for Proj in
- Project_Table.First .. Project_Table.Last (In_Tree.Projects)
- loop
- Extending := In_Tree.Projects.Table (Proj).Extended_By;
+ Prj := In_Tree.Projects;
+ while Prj /= null loop
+ Extending := Prj.Project.Extended_By;
if Extending /= No_Project then
- Obj_Dir := In_Tree.Projects.Table (Proj).Object_Directory.Name;
+ Obj_Dir := Prj.Project.Object_Directory.Name;
-- Check that a project being extended does not share its
-- object directory with any project that extends it, directly
@@ -2402,20 +2363,17 @@ package body Prj.Proc is
Extending2 := Extending;
while Extending2 /= No_Project loop
- if Has_Ada_Sources (In_Tree.Projects.Table (Extending2))
- and then
- In_Tree.Projects.Table
- (Extending2).Object_Directory.Name = Obj_Dir
+ if Has_Ada_Sources (Extending2)
+ and then Extending2.Object_Directory.Name = Obj_Dir
then
- if In_Tree.Projects.Table (Extending2).Virtual then
- Error_Msg_Name_1 :=
- In_Tree.Projects.Table (Proj).Display_Name;
+ if Extending2.Virtual then
+ Error_Msg_Name_1 := Prj.Project.Display_Name;
if Error_Report = null then
Error_Msg
("project %% cannot be extended by a virtual" &
" project with the same object directory",
- In_Tree.Projects.Table (Proj).Location);
+ Prj.Project.Location);
else
Error_Report
("project """ &
@@ -2426,18 +2384,16 @@ package body Prj.Proc is
end if;
else
- Error_Msg_Name_1 :=
- In_Tree.Projects.Table (Extending2).Display_Name;
- Error_Msg_Name_2 :=
- In_Tree.Projects.Table (Proj).Display_Name;
+ Error_Msg_Name_1 := Extending2.Display_Name;
+ Error_Msg_Name_2 := Prj.Project.Display_Name;
if Error_Report = null then
Error_Msg
("project %% cannot extend project %%",
- In_Tree.Projects.Table (Extending2).Location);
+ Extending2.Location);
Error_Msg
("\they share the same object directory",
- In_Tree.Projects.Table (Extending2).Location);
+ Extending2.Location);
else
Error_Report
@@ -2455,10 +2411,11 @@ package body Prj.Proc is
-- Continue with the next extending project, if any
- Extending2 :=
- In_Tree.Projects.Table (Extending2).Extended_By;
+ Extending2 := Extending2.Extended_By;
end loop;
end if;
+
+ Prj := Prj.Next;
end loop;
end if;
@@ -2479,8 +2436,7 @@ package body Prj.Proc is
begin
if Verbose_Mode then
Write_Str ("Checking project file """);
- Write_Str
- (Get_Name_String (Data.In_Tree.Projects.Table (Project).Name));
+ Write_Str (Get_Name_String (Project.Name));
Write_Line ("""");
end if;
@@ -2546,12 +2502,11 @@ package body Prj.Proc is
-- it is nil, then this imported project is our first.
if Imported = null then
- In_Tree.Projects.Table (Project).Imported_Projects :=
+ Project.Imported_Projects :=
new Project_List_Element'
(Project => New_Project,
Next => null);
- Imported :=
- In_Tree.Projects.Table (Project).Imported_Projects;
+ Imported := Project.Imported_Projects;
else
Imported.Next := new Project_List_Element'
(Project => New_Project,
@@ -2573,7 +2528,6 @@ package body Prj.Proc is
else
declare
- Processed_Data : Project_Data := Empty_Project (In_Tree);
Imported : Project_List;
Declaration_Node : Project_Node_Id := Empty_Node;
Tref : Source_Buffer_Ptr;
@@ -2595,22 +2549,22 @@ package body Prj.Proc is
-- This is for virtually extended projects.
if Extended_By /= No_Project then
- In_Tree.Projects.Table (Project).Extended_By := Extended_By;
+ Project.Extended_By := Extended_By;
end if;
return;
end if;
- Project_Table.Increment_Last (In_Tree.Projects);
- Project := Project_Table.Last (In_Tree.Projects);
+ Project := new Project_Data'(Empty_Project (In_Tree));
+ In_Tree.Projects := new Project_List_Element'
+ (Project => Project,
+ Next => In_Tree.Projects);
+
Processed_Projects.Set (Name, Project);
- Processed_Data.Name := Name;
- Processed_Data.Qualifier :=
+ Project.Name := Name;
+ Project.Qualifier :=
Project_Qualifier_Of (From_Project_Node, From_Project_Node_Tree);
- In_Tree.Projects.Table (Project).Name := Name;
- In_Tree.Projects.Table (Project).Qualifier :=
- Processed_Data.Qualifier;
Get_Name_String (Name);
@@ -2621,15 +2575,15 @@ package body Prj.Proc is
and then Name_Buffer (1 .. Virtual_Prefix'Length) =
Virtual_Prefix
then
- Processed_Data.Virtual := True;
- Processed_Data.Display_Name := Name;
+ Project.Virtual := True;
+ Project.Display_Name := Name;
-- If there is no file, for example when the project node tree is
-- built in memory by GPS, the Display_Name cannot be found in
-- the source, so its value is the same as Name.
elsif Location = No_Location then
- Processed_Data.Display_Name := Name;
+ Project.Display_Name := Name;
-- Get the spelling of the project name from the project file
@@ -2641,37 +2595,35 @@ package body Prj.Proc is
Location := Location + 1;
end loop;
- Processed_Data.Display_Name := Name_Find;
+ Project.Display_Name := Name_Find;
end if;
- Processed_Data.Path.Display_Name :=
+ Project.Path.Display_Name :=
Path_Name_Of (From_Project_Node, From_Project_Node_Tree);
- Get_Name_String (Processed_Data.Path.Display_Name);
+ Get_Name_String (Project.Path.Display_Name);
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
- Processed_Data.Path.Name := Name_Find;
+ Project.Path.Name := Name_Find;
- Processed_Data.Location :=
+ Project.Location :=
Location_Of (From_Project_Node, From_Project_Node_Tree);
- Processed_Data.Directory.Display_Name :=
+ Project.Directory.Display_Name :=
Directory_Of (From_Project_Node, From_Project_Node_Tree);
- Get_Name_String (Processed_Data.Directory.Display_Name);
+ Get_Name_String (Project.Directory.Display_Name);
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
- Processed_Data.Directory.Name := Name_Find;
+ Project.Directory.Name := Name_Find;
- Processed_Data.Extended_By := Extended_By;
+ Project.Extended_By := Extended_By;
Add_Attributes
(Project,
Name,
- Name_Id (Processed_Data.Directory.Name),
+ Name_Id (Project.Directory.Name),
In_Tree,
- Processed_Data.Decl,
+ Project.Decl,
Prj.Attr.Attribute_First,
Project_Level => True);
- In_Tree.Projects.Table (Project) := Processed_Data;
-
Process_Imported_Projects (Imported, Limited_With => False);
Declaration_Node :=
@@ -2680,7 +2632,7 @@ package body Prj.Proc is
Recursive_Process
(In_Tree => In_Tree,
- Project => In_Tree.Projects.Table (Project).Extends,
+ Project => Project.Extends,
From_Project_Node => Extended_Project_Of
(Declaration_Node,
From_Project_Node_Tree),
@@ -2702,27 +2654,22 @@ package body Prj.Proc is
-- or renamed. Also inherit the languages, if attribute Languages
-- is not explicitly defined.
- Processed_Data := In_Tree.Projects.Table (Project);
-
- if Processed_Data.Extends /= No_Project then
+ if Project.Extends /= No_Project then
declare
Extended_Pkg : Package_Id;
Current_Pkg : Package_Id;
Element : Package_Element;
First : constant Package_Id :=
- Processed_Data.Decl.Packages;
+ Project.Decl.Packages;
Attribute1 : Variable_Id;
Attribute2 : Variable_Id;
Attr_Value1 : Variable;
Attr_Value2 : Variable;
begin
- Extended_Pkg :=
- In_Tree.Projects.Table
- (Processed_Data.Extends).Decl.Packages;
+ Extended_Pkg := Project.Extends.Decl.Packages;
while Extended_Pkg /= No_Package loop
- Element :=
- In_Tree.Packages.Table (Extended_Pkg);
+ Element := In_Tree.Packages.Table (Extended_Pkg);
Current_Pkg := First;
while Current_Pkg /= No_Package
@@ -2741,8 +2688,8 @@ package body Prj.Proc is
(Name => Element.Name,
Decl => No_Declarations,
Parent => No_Package,
- Next => Processed_Data.Decl.Packages);
- Processed_Data.Decl.Packages := Current_Pkg;
+ Next => Project.Decl.Packages);
+ Project.Decl.Packages := Current_Pkg;
Copy_Package_Declarations
(From => Element.Decl,
To =>
@@ -2759,7 +2706,7 @@ package body Prj.Proc is
-- Check if attribute Languages is declared in the
-- extending project.
- Attribute1 := Processed_Data.Decl.Attributes;
+ Attribute1 := Project.Decl.Attributes;
while Attribute1 /= No_Variable loop
Attr_Value1 := In_Tree.Variable_Elements.
Table (Attribute1);
@@ -2774,9 +2721,7 @@ package body Prj.Proc is
-- project. Check if it is declared in the project being
-- extended.
- Attribute2 :=
- In_Tree.Projects.Table
- (Processed_Data.Extends).Decl.Attributes;
+ Attribute2 := Project.Extends.Decl.Attributes;
while Attribute2 /= No_Variable loop
Attr_Value2 := In_Tree.Variable_Elements.
Table (Attribute2);
@@ -2796,8 +2741,8 @@ package body Prj.Proc is
(In_Tree.Variable_Elements);
Attribute1 := Variable_Element_Table.Last
(In_Tree.Variable_Elements);
- Attr_Value1.Next := Processed_Data.Decl.Attributes;
- Processed_Data.Decl.Attributes := Attribute1;
+ Attr_Value1.Next := Project.Decl.Attributes;
+ Project.Decl.Attributes := Attribute1;
end if;
Attr_Value1.Name := Snames.Name_Languages;
@@ -2807,8 +2752,6 @@ package body Prj.Proc is
end if;
end if;
end;
-
- In_Tree.Projects.Table (Project) := Processed_Data;
end if;
Process_Imported_Projects (Imported, Limited_With => True);