diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-05-21 15:01:59 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-05-21 15:01:59 +0200 |
commit | 0df5ae93e08e17fbe36bfcd1bda8ea24af968a64 (patch) | |
tree | 160aed62a8b7dc8baaecb1c3e3d236c979273971 /gcc/ada/prj.adb | |
parent | 9db78a423bbd92dfbfcaa5b33b040da21540d647 (diff) | |
download | gcc-0df5ae93e08e17fbe36bfcd1bda8ea24af968a64.zip gcc-0df5ae93e08e17fbe36bfcd1bda8ea24af968a64.tar.gz gcc-0df5ae93e08e17fbe36bfcd1bda8ea24af968a64.tar.bz2 |
[multiple changes]
2014-05-21 Robert Dewar <dewar@adacore.com>
* sem_ch13.adb (Analyze_Aspect_Specifications):
Insert_Delayed_Pragma is now used for the case of Attach_Handler.
* sem_prag.adb: Minor comment improvements.
2014-05-21 Ed Schonberg <schonberg@adacore.com>
* sem_ch12.adb (Install_Body): When checking whether freezing of
instantiation must be delayed, verify that the common enclosing
subprogram to generic and instance is in fact an overloadable
entity.
2014-05-21 Vincent Celier <celier@adacore.com>
* makeutl.adb (Mains.Complete_Mains.Do_Complete): Look for all
mains with the same name and fail if there is more than one.
* prj.ads, prj.adb (Find_All_Sources): New function
From-SVN: r210702
Diffstat (limited to 'gcc/ada/prj.adb')
-rw-r--r-- | gcc/ada/prj.adb | 104 |
1 files changed, 103 insertions, 1 deletions
diff --git a/gcc/ada/prj.adb b/gcc/ada/prj.adb index 6a0a830..a50823e 100644 --- a/gcc/ada/prj.adb +++ b/gcc/ada/prj.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2014, 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- -- @@ -889,6 +889,104 @@ package body Prj is return Result; end Find_Source; + ---------------------- + -- Find_All_Sources -- + ---------------------- + + function Find_All_Sources + (In_Tree : Project_Tree_Ref; + Project : Project_Id; + In_Imported_Only : Boolean := False; + In_Extended_Only : Boolean := False; + Base_Name : File_Name_Type; + Index : Int := 0) return Source_Ids + is + Result : Source_Ids (1 .. 1_000); + Last : Natural := 0; + + type Empty_State is null record; + No_State : Empty_State; + + procedure Look_For_Sources + (Proj : Project_Id; + Tree : Project_Tree_Ref; + State : in out Empty_State); + -- Look for Base_Name in the sources of Proj + + ---------------------- + -- Look_For_Sources -- + ---------------------- + + procedure Look_For_Sources + (Proj : Project_Id; + Tree : Project_Tree_Ref; + State : in out Empty_State) + is + Iterator : Source_Iterator; + Src : Source_Id; + + begin + State := No_State; + + Iterator := For_Each_Source (In_Tree => Tree, Project => Proj); + while Element (Iterator) /= No_Source loop + if Element (Iterator).File = Base_Name + and then (Index = 0 + or else + (Element (Iterator).Unit /= No_Unit_Index + and then + Element (Iterator).Index = Index)) + then + Src := Element (Iterator); + + -- If the source has been excluded, continue looking. We will + -- get the excluded source only if there is no other source + -- with the same base name that is not locally removed. + + if not Element (Iterator).Locally_Removed then + Last := Last + 1; + Result (Last) := Src; + end if; + end if; + + Next (Iterator); + end loop; + end Look_For_Sources; + + procedure For_Imported_Projects is new For_Every_Project_Imported + (State => Empty_State, Action => Look_For_Sources); + + Proj : Project_Id; + + -- Start of processing for Find_All_Sources + + begin + if In_Extended_Only then + Proj := Project; + while Proj /= No_Project loop + Look_For_Sources (Proj, In_Tree, No_State); + exit when Last > 0; + Proj := Proj.Extends; + end loop; + + elsif In_Imported_Only then + Look_For_Sources (Project, In_Tree, No_State); + + if Last = 0 then + For_Imported_Projects + (By => Project, + Tree => In_Tree, + Include_Aggregated => False, + With_State => No_State); + end if; + + else + Look_For_Sources (No_Project, In_Tree, No_State); + end if; + + return Result (1 .. Last); + end Find_All_Sources; + ---------- -- Hash -- ---------- @@ -896,6 +994,10 @@ package body Prj is function Hash is new GNAT.HTable.Hash (Header_Num => Header_Num); -- Used in implementation of other functions Hash below + ---------- + -- Hash -- + ---------- + function Hash (Name : File_Name_Type) return Header_Num is begin return Hash (Get_Name_String (Name)); |