diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-24 16:35:21 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2009-04-24 16:35:21 +0200 |
commit | 3563739bcd2982f43e3c9c5818c8e0d2ad971394 (patch) | |
tree | fb3fc87fa6c935ed02ccd6b3f65c3a662b29c471 /gcc/ada/prj.adb | |
parent | 806b956fed0026c5431340ee15e770dd513684a8 (diff) | |
download | gcc-3563739bcd2982f43e3c9c5818c8e0d2ad971394.zip gcc-3563739bcd2982f43e3c9c5818c8e0d2ad971394.tar.gz gcc-3563739bcd2982f43e3c9c5818c8e0d2ad971394.tar.bz2 |
[multiple changes]
2009-04-24 Emmanuel Briot <briot@adacore.com>
* prj-proc.adb, make.adb, mlib-prj.adb, prj.adb, prj.ads, clean.adb,
prj-nmsc.adb, prj-env.adb (Project_List_Table, Project_Element):
removed. Lists of projects are now implemented via standard malloc
rather than through the table.
2009-04-24 Thomas Quinot <quinot@adacore.com>
* sem_ch12.adb: Minor reformatting
* g-trasym.adb: Minor reformatting
* exp_ch6.adb: Minor reformatting
2009-04-24 Robert Dewar <dewar@adacore.com>
* layout.adb (Layout_Type): For packed array type, copy unset
size/alignment fields from the referenced Packed_Array_Type.
2009-04-24 Bob Duff <duff@adacore.com>
* lib-load.adb (Make_Instance_Unit): Revert previous change, no
longer needed after sem_ch12 changes.
* sem.adb (Walk_Library_Items): Include with's in some debugging
printouts.
From-SVN: r146727
Diffstat (limited to 'gcc/ada/prj.adb')
-rw-r--r-- | gcc/ada/prj.adb | 106 |
1 files changed, 55 insertions, 51 deletions
diff --git a/gcc/ada/prj.adb b/gcc/ada/prj.adb index 2cebd1a..d6a98b4 100644 --- a/gcc/ada/prj.adb +++ b/gcc/ada/prj.adb @@ -118,8 +118,8 @@ package body Prj is Naming => Std_Naming_Data, Languages => No_Language_Index, Decl => No_Declarations, - Imported_Projects => Empty_Project_List, - All_Imported_Projects => Empty_Project_List, + Imported_Projects => null, + All_Imported_Projects => null, Ada_Include_Path => null, Ada_Objects_Path => null, Objects_Path => null, @@ -143,11 +143,12 @@ package body Prj is -- Table to store the path name of all the created temporary files, so that -- they can be deleted at the end, or when the program is interrupted. - procedure Free (Project : in out Project_Data); + procedure Free (Project : in out Project_Data; Reset_Only : Boolean); -- Free memory allocated for Project procedure Free_List (Languages : in out Language_Ptr); procedure Free_List (Source : in out Source_Id); + procedure Free_List (List : in out Project_List); -- Free memory allocated for the list of languages or sources procedure Language_Changed (Iter : in out Source_Iterator); @@ -532,9 +533,9 @@ package body Prj is -- Visited all imported projects List := Data.Imported_Projects; - while List /= Empty_Project_List loop - Recursive_Check (In_Tree.Project_Lists.Table (List).Project); - List := In_Tree.Project_Lists.Table (List).Next; + while List /= null loop + Recursive_Check (List.Project); + List := List.Next; end loop; if Imported_First then @@ -821,12 +822,19 @@ package body Prj is -- Free -- ---------- - procedure Free (Project : in out Project_Data) is + procedure Free (Project : in out Project_Data; Reset_Only : Boolean) is begin Free (Project.Include_Path); Free (Project.Ada_Include_Path); Free (Project.Objects_Path); Free (Project.Ada_Objects_Path); + + Free_List (Project.Imported_Projects); + Free_List (Project.All_Imported_Projects); + + if not Reset_Only then + Free_List (Project.Languages); + end if; end Free; --------------- @@ -849,6 +857,22 @@ package body Prj is -- Free_List -- --------------- + procedure Free_List (List : in out Project_List) is + procedure Unchecked_Free is new Ada.Unchecked_Deallocation + (Project_List_Element, Project_List); + Tmp : Project_List; + begin + while List /= null loop + Tmp := List.Next; + Unchecked_Free (List); + List := Tmp; + end loop; + end Free_List; + + --------------- + -- Free_List -- + --------------- + procedure Free_List (Languages : in out Language_Ptr) is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Language_Data, Language_Ptr); @@ -878,19 +902,16 @@ package body Prj is Array_Element_Table.Free (Tree.Array_Elements); Array_Table.Free (Tree.Arrays); Package_Table.Free (Tree.Packages); - Project_List_Table.Free (Tree.Project_Lists); Alternate_Language_Table.Free (Tree.Alt_Langs); Unit_Table.Free (Tree.Units); Units_Htable.Reset (Tree.Units_HT); - Files_Htable.Reset (Tree.Files_HT); Source_Paths_Htable.Reset (Tree.Source_Paths_HT); Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT); for P in Project_Table.First .. Project_Table.Last (Tree.Projects) loop - Free_List (Tree.Projects.Table (P).Languages); - Free (Tree.Projects.Table (P)); + Free (Tree.Projects.Table (P), Reset_Only => False); end loop; Project_Table.Free (Tree.Projects); @@ -923,11 +944,9 @@ package body Prj is Array_Element_Table.Init (Tree.Array_Elements); Array_Table.Init (Tree.Arrays); Package_Table.Init (Tree.Packages); - Project_List_Table.Init (Tree.Project_Lists); Alternate_Language_Table.Init (Tree.Alt_Langs); Unit_Table.Init (Tree.Units); Units_Htable.Reset (Tree.Units_HT); - Files_Htable.Reset (Tree.Files_HT); Source_Paths_Htable.Reset (Tree.Source_Paths_HT); Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT); @@ -935,7 +954,7 @@ package body Prj is for P in Project_Table.First .. Project_Table.Last (Tree.Projects) loop - Free (Tree.Projects.Table (P)); + Free (Tree.Projects.Table (P), Reset_Only => True); end loop; end if; @@ -1366,51 +1385,19 @@ package body Prj is procedure Compute_All_Imported_Projects (Project : Project_Id; In_Tree : Project_Tree_Ref) is - procedure Add_To_List (Prj : Project_Id); - -- Add a project to the list All_Imported_Projects of project Project + Data : Project_Data renames In_Tree.Projects.Table (Project); procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean); -- Recursively add the projects imported by project Project, but not -- those that are extended. - ----------------- - -- Add_To_List -- - ----------------- - - procedure Add_To_List (Prj : Project_Id) is - Element : constant Project_Element := - (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 - -- one passed it are the extended projects. - - List := In_Tree.Projects.Table (Project).All_Imported_Projects; - while List /= Empty_Project_List loop - if In_Tree.Project_Lists.Table (List).Project = Prj then - return; - end if; - List := In_Tree.Project_Lists.Table (List).Next; - end loop; - - -- Add it to the list - - Project_List_Table.Increment_Last (In_Tree.Project_Lists); - List := Project_List_Table.Last (In_Tree.Project_Lists); - In_Tree.Project_Lists.Table (List) := Element; - In_Tree.Projects.Table (Project).All_Imported_Projects := List; - end Add_To_List; - ------------------- -- Recursive_Add -- ------------------- procedure Recursive_Add (Prj : Project_Id; Dummy : in out Boolean) is pragma Unreferenced (Dummy); - + List : Project_List; Prj2 : Project_Id; begin @@ -1418,7 +1405,25 @@ package body Prj is if Project /= Prj then Prj2 := Ultimate_Extending_Project_Of (Prj, In_Tree); - Add_To_List (Prj2); + + -- 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 one passed it are the extended projects. + + List := Data.All_Imported_Projects; + while List /= null loop + if List.Project = Prj2 then + return; + end if; + List := List.Next; + end loop; + + -- Add it to the list + + Data.All_Imported_Projects := + new Project_List_Element' + (Project => Prj2, + Next => Data.All_Imported_Projects); end if; end Recursive_Add; @@ -1427,8 +1432,7 @@ package body Prj is Dummy : Boolean := False; begin - In_Tree.Projects.Table (Project).All_Imported_Projects := - Empty_Project_List; + Free_List (Data.All_Imported_Projects); For_All_Projects (Project, In_Tree, Dummy); end Compute_All_Imported_Projects; |