From 4c3c04756a8649638033e53f6c6395acf7156cde Mon Sep 17 00:00:00 2001 From: charlet Date: Fri, 8 Oct 2010 10:22:31 +0000 Subject: 2010-10-08 Robert Dewar * sem_ch3.adb: Minor reformatting. 2010-10-08 Vincent Celier * ali-util.adb (Get_File_Checksum): Make sure that external_as_list is not a reserved word. * prj-proc.adb (Expression): Process string list external references. * prj-strt.adb (External_Reference): Parse external_as_list external references. * prj-tree.ads (Expression_Kind_Of): Allowed for N_External_Value nodes (Set_Expression_Kind_Of): Ditto * prj.adb (Initialize): Set external_as_list as a reserved word * projects.texi: Document new string external reference external_as_list * scans.ads (Token_Type): New token Tok_External_As_List * snames.ads-tmpl: New standard name Name_External_As_List git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165157 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/prj-proc.adb | 234 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 196 insertions(+), 38 deletions(-) (limited to 'gcc/ada/prj-proc.adb') diff --git a/gcc/ada/prj-proc.adb b/gcc/ada/prj-proc.adb index c517a47147b..0553d33ff8a 100644 --- a/gcc/ada/prj-proc.adb +++ b/gcc/ada/prj-proc.adb @@ -33,6 +33,8 @@ with Prj.Ext; use Prj.Ext; with Prj.Nmsc; use Prj.Nmsc; with Snames; +with Ada.Strings.Fixed; use Ada.Strings.Fixed; + with GNAT.Case_Util; use GNAT.Case_Util; with GNAT.HTable; @@ -1021,15 +1023,17 @@ package body Prj.Proc is From_Project_Node_Tree)); declare - Name : constant Name_Id := Name_Find; - Default : Name_Id := No_Name; - Value : Name_Id := No_Name; - - Def_Var : Variable_Value; + Name : constant Name_Id := Name_Find; + Default : Name_Id := No_Name; + Value : Name_Id := No_Name; + Ext_List : Boolean := False; + Str_List : String_List_Access := null; + Def_Var : Variable_Value; Default_Node : constant Project_Node_Id := - External_Default_Of - (The_Current_Term, From_Project_Node_Tree); + External_Default_Of + (The_Current_Term, + From_Project_Node_Tree); begin -- If there is a default value for the external reference, @@ -1053,19 +1057,132 @@ package body Prj.Proc is end if; end if; - Value := - Prj.Ext.Value_Of (From_Project_Node_Tree, Name, Default); + Ext_List := Expression_Kind_Of + (The_Current_Term, + From_Project_Node_Tree) = List; - if Value = No_Name then - if not Quiet_Output then - Error_Msg - (Flags, "?undefined external reference", - Location_Of - (The_Current_Term, From_Project_Node_Tree), - Project); + if Ext_List then + Value := + Prj.Ext.Value_Of + (From_Project_Node_Tree, Name, No_Name); + + if Value /= No_Name then + declare + Sep : constant String := + Get_Name_String (Default); + First : Positive := 1; + Lst : Natural; + Done : Boolean := False; + Nmb : Natural; + + begin + Get_Name_String (Value); + + if Name_Len = 0 + or else Sep'Length = 0 + or else Name_Buffer (1 .. Name_Len) = Sep + then + Done := True; + end if; + + if not Done and then Name_Len < Sep'Length then + Str_List := + new String_List' + (1 => new String' + (Name_Buffer (1 .. Name_Len))); + Done := True; + end if; + + if not Done then + if Name_Buffer (1 .. Sep'Length) = Sep then + First := Sep'Length + 1; + end if; + + if Name_Len - First + 1 >= Sep'Length + and then + Name_Buffer (Name_Len - Sep'Length + 1 .. + Name_Len) = Sep + then + Name_Len := Name_Len - Sep'Length; + end if; + + if Name_Len = 0 then + Str_List := + new String_List'(1 => new String'("")); + Done := True; + end if; + end if; + + if not Done then + -- Count the number of string + + declare + Saved : constant Positive := First; + begin + + Nmb := 1; + loop + Lst := + Index + (Source => + Name_Buffer (First .. Name_Len), + Pattern => Sep); + exit when Lst = 0; + Nmb := Nmb + 1; + First := Lst + Sep'Length; + end loop; + + First := Saved; + end; + + Str_List := new String_List (1 .. Nmb); + + -- Populate the string list + + Nmb := 1; + loop + Lst := + Index + (Source => + Name_Buffer (First .. Name_Len), + Pattern => Sep); + + if Lst = 0 then + Str_List (Nmb) := + new String' + (Name_Buffer (First .. Name_Len)); + exit; + + else + Str_List (Nmb) := + new String' + (Name_Buffer (First .. Lst - 1)); + Nmb := Nmb + 1; + First := Lst + Sep'Length; + end if; + end loop; + end if; + end; end if; - Value := Empty_String; + else + -- Get the value + + Value := + Prj.Ext.Value_Of + (From_Project_Node_Tree, Name, Default); + + if Value = No_Name then + if not Quiet_Output then + Error_Msg + (Flags, "?undefined external reference", + Location_Of + (The_Current_Term, From_Project_Node_Tree), + Project); + end if; + + Value := Empty_String; + end if; end if; case Kind is @@ -1074,34 +1191,75 @@ package body Prj.Proc is null; when Single => - Add (Result.Value, Value); + if Ext_List then + null; -- error - when List => - String_Element_Table.Increment_Last - (In_Tree.String_Elements); + else + Add (Result.Value, Value); + end if; - if Last = Nil_String then - Result.Values := String_Element_Table.Last + when List => + if not Ext_List or else Str_List /= null then + String_Element_Table.Increment_Last (In_Tree.String_Elements); - else - In_Tree.String_Elements.Table - (Last).Next := String_Element_Table.Last - (In_Tree.String_Elements); - end if; + if Last = Nil_String then + Result.Values := + String_Element_Table.Last + (In_Tree.String_Elements); - Last := String_Element_Table.Last + else + In_Tree.String_Elements.Table (Last).Next := + String_Element_Table.Last (In_Tree.String_Elements); - In_Tree.String_Elements.Table (Last) := - (Value => Value, - Display_Value => No_Name, - Location => - Location_Of - (The_Current_Term, From_Project_Node_Tree), - Flag => False, - Next => Nil_String, - Index => 0); + end if; + Last := + String_Element_Table.Last + (In_Tree.String_Elements); + + if Ext_List then + for Ind in Str_List'Range loop + Name_Len := 0; + Add_Str_To_Name_Buffer (Str_List (Ind).all); + Value := Name_Find; + In_Tree.String_Elements.Table (Last) := + (Value => Value, + Display_Value => No_Name, + Location => + Location_Of + (The_Current_Term, + From_Project_Node_Tree), + Flag => False, + Next => Nil_String, + Index => 0); + + if Ind /= Str_List'Last then + String_Element_Table.Increment_Last + (In_Tree.String_Elements); + In_Tree.String_Elements.Table + (Last).Next := + String_Element_Table.Last + (In_Tree.String_Elements); + Last := + String_Element_Table.Last + (In_Tree.String_Elements); + end if; + end loop; + + else + In_Tree.String_Elements.Table (Last) := + (Value => Value, + Display_Value => No_Name, + Location => + Location_Of + (The_Current_Term, + From_Project_Node_Tree), + Flag => False, + Next => Nil_String, + Index => 0); + end if; + end if; end case; end; -- cgit v1.2.1