1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2008, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Ada.Characters.Handling; use Ada.Characters.Handling;
29 with Output; use Output;
30 with Osint; use Osint;
33 with Prj.Err; use Prj.Err;
34 with Snames; use Snames;
36 with Uintp; use Uintp;
38 with System.Case_Util; use System.Case_Util;
43 Object_Suffix : constant String := Get_Target_Object_Suffix.all;
44 -- File suffix for object files
46 Initial_Buffer_Size : constant := 100;
47 -- Initial size for extensible buffer used in Add_To_Buffer
49 Current_Mode : Mode := Ada_Only;
51 Configuration_Mode : Boolean := False;
53 The_Empty_String : Name_Id;
55 Default_Ada_Spec_Suffix_Id : File_Name_Type;
56 Default_Ada_Body_Suffix_Id : File_Name_Type;
57 Slash_Id : Path_Name_Type;
58 -- Initialized in Prj.Initialize, then never modified
60 subtype Known_Casing is Casing_Type range All_Upper_Case .. Mixed_Case;
62 The_Casing_Images : constant array (Known_Casing) of String_Access :=
63 (All_Lower_Case => new String'("lowercase"),
64 All_Upper_Case => new String'("UPPERCASE"),
65 Mixed_Case => new String'("MixedCase"));
67 Initialized : Boolean := False;
69 Standard_Dot_Replacement : constant File_Name_Type :=
71 (First_Name_Id + Character'Pos ('-'));
73 Std_Naming_Data : constant Naming_Data :=
74 (Dot_Replacement => Standard_Dot_Replacement,
75 Dot_Repl_Loc => No_Location,
76 Casing => All_Lower_Case,
77 Spec_Suffix => No_Array_Element,
78 Ada_Spec_Suffix_Loc => No_Location,
79 Body_Suffix => No_Array_Element,
80 Ada_Body_Suffix_Loc => No_Location,
81 Separate_Suffix => No_File,
82 Sep_Suffix_Loc => No_Location,
83 Specs => No_Array_Element,
84 Bodies => No_Array_Element,
85 Specification_Exceptions => No_Array_Element,
86 Implementation_Exceptions => No_Array_Element);
88 Project_Empty : constant Project_Data :=
89 (Qualifier => Unspecified,
90 Externally_Built => False,
91 Config => Default_Project_Config,
92 Languages => No_Name_List,
93 First_Referred_By => No_Project,
95 Display_Name => No_Name,
96 Path => No_Path_Information,
98 Location => No_Location,
100 Directory => No_Path_Information,
103 Library_Dir => No_Path_Information,
104 Library_Src_Dir => No_Path_Information,
105 Library_ALI_Dir => No_Path_Information,
106 Library_Name => No_Name,
107 Library_Kind => Static,
108 Lib_Internal_Name => No_Name,
109 Standalone_Library => False,
110 Lib_Interface_ALIs => Nil_String,
111 Lib_Auto_Init => False,
112 Libgnarl_Needed => Unknown,
113 Symbol_Data => No_Symbols,
114 Ada_Sources_Present => True,
115 Other_Sources_Present => True,
116 Ada_Sources => Nil_String,
117 First_Source => No_Source,
118 Last_Source => No_Source,
119 Interfaces_Defined => False,
120 Unit_Based_Language_Name => No_Name,
121 Unit_Based_Language_Index => No_Language_Index,
122 Imported_Directories_Switches => null,
123 Include_Path => null,
124 Include_Data_Set => False,
125 Include_Language => No_Language_Index,
126 Source_Dirs => Nil_String,
127 Known_Order_Of_Source_Dirs => True,
128 Object_Directory => No_Path_Information,
129 Library_TS => Empty_Time_Stamp,
130 Exec_Directory => No_Path_Information,
131 Extends => No_Project,
132 Extended_By => No_Project,
133 Naming => Std_Naming_Data,
134 First_Language_Processing => No_Language_Index,
135 Decl => No_Declarations,
136 Imported_Projects => Empty_Project_List,
137 All_Imported_Projects => Empty_Project_List,
138 Ada_Include_Path => null,
139 Ada_Objects_Path => null,
140 Objects_Path => null,
141 Include_Path_File => No_Path,
142 Objects_Path_File_With_Libs => No_Path,
143 Objects_Path_File_Without_Libs => No_Path,
144 Config_File_Name => No_Path,
145 Config_File_Temp => False,
146 Linker_Name => No_File,
147 Linker_Path => No_Path,
148 Minimum_Linker_Options => No_Name_List,
149 Config_Checked => False,
152 Need_To_Build_Lib => False,
154 Unkept_Comments => False);
156 package Temp_Files is new Table.Table
157 (Table_Component_Type => Path_Name_Type,
158 Table_Index_Type => Integer,
159 Table_Low_Bound => 1,
161 Table_Increment => 100,
162 Table_Name => "Makegpr.Temp_Files");
163 -- Table to store the path name of all the created temporary files, so that
164 -- they can be deleted at the end, or when the program is interrupted.
170 procedure Add_To_Buffer
172 To : in out String_Access;
173 Last : in out Natural)
177 To := new String (1 .. Initial_Buffer_Size);
181 -- If Buffer is too small, double its size
183 while Last + S'Length > To'Last loop
185 New_Buffer : constant String_Access :=
186 new String (1 .. 2 * Last);
189 New_Buffer (1 .. Last) := To (1 .. Last);
195 To (Last + 1 .. Last + S'Length) := S;
196 Last := Last + S'Length;
199 -----------------------
200 -- Body_Suffix_Id_Of --
201 -----------------------
203 function Body_Suffix_Id_Of
204 (In_Tree : Project_Tree_Ref;
206 Naming : Naming_Data) return File_Name_Type
208 Language_Id : Name_Id;
212 Add_Str_To_Name_Buffer (Language);
213 To_Lower (Name_Buffer (1 .. Name_Len));
214 Language_Id := Name_Find;
219 Language_Id => Language_Id,
221 end Body_Suffix_Id_Of;
223 -----------------------
224 -- Body_Suffix_Id_Of --
225 -----------------------
227 function Body_Suffix_Id_Of
228 (In_Tree : Project_Tree_Ref;
229 Language_Id : Name_Id;
230 Naming : Naming_Data) return File_Name_Type
232 Element_Id : Array_Element_Id;
233 Element : Array_Element;
234 Suffix : File_Name_Type := No_File;
235 Lang : Language_Index;
238 -- ??? This seems to be only for Ada_Only mode...
239 Element_Id := Naming.Body_Suffix;
240 while Element_Id /= No_Array_Element loop
241 Element := In_Tree.Array_Elements.Table (Element_Id);
243 if Element.Index = Language_Id then
244 return File_Name_Type (Element.Value.Value);
247 Element_Id := Element.Next;
250 if Current_Mode = Multi_Language then
251 Lang := In_Tree.First_Language;
252 while Lang /= No_Language_Index loop
253 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
255 In_Tree.Languages_Data.Table
256 (Lang).Config.Naming_Data.Body_Suffix;
260 Lang := In_Tree.Languages_Data.Table (Lang).Next;
265 end Body_Suffix_Id_Of;
271 function Body_Suffix_Of
272 (In_Tree : Project_Tree_Ref;
274 Naming : Naming_Data) return String
276 Language_Id : Name_Id;
277 Element_Id : Array_Element_Id;
278 Element : Array_Element;
279 Suffix : File_Name_Type := No_File;
280 Lang : Language_Index;
284 Add_Str_To_Name_Buffer (Language);
285 To_Lower (Name_Buffer (1 .. Name_Len));
286 Language_Id := Name_Find;
288 Element_Id := Naming.Body_Suffix;
289 while Element_Id /= No_Array_Element loop
290 Element := In_Tree.Array_Elements.Table (Element_Id);
292 if Element.Index = Language_Id then
293 return Get_Name_String (Element.Value.Value);
296 Element_Id := Element.Next;
299 if Current_Mode = Multi_Language then
300 Lang := In_Tree.First_Language;
301 while Lang /= No_Language_Index loop
302 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
305 (In_Tree.Languages_Data.Table
306 (Lang).Config.Naming_Data.Body_Suffix);
310 Lang := In_Tree.Languages_Data.Table (Lang).Next;
313 if Suffix /= No_File then
314 return Get_Name_String (Suffix);
321 -----------------------------
322 -- Default_Ada_Body_Suffix --
323 -----------------------------
325 function Default_Ada_Body_Suffix return File_Name_Type is
327 return Default_Ada_Body_Suffix_Id;
328 end Default_Ada_Body_Suffix;
330 -----------------------------
331 -- Default_Ada_Spec_Suffix --
332 -----------------------------
334 function Default_Ada_Spec_Suffix return File_Name_Type is
336 return Default_Ada_Spec_Suffix_Id;
337 end Default_Ada_Spec_Suffix;
339 ---------------------------
340 -- Delete_All_Temp_Files --
341 ---------------------------
343 procedure Delete_All_Temp_Files is
345 pragma Warnings (Off, Dont_Care);
347 if not Debug.Debug_Flag_N then
348 for Index in 1 .. Temp_Files.Last loop
350 (Get_Name_String (Temp_Files.Table (Index)), Dont_Care);
353 end Delete_All_Temp_Files;
355 ---------------------
356 -- Dependency_Name --
357 ---------------------
359 function Dependency_Name
360 (Source_File_Name : File_Name_Type;
361 Dependency : Dependency_File_Kind) return File_Name_Type
372 (Source_File_Name, Makefile_Dependency_Suffix));
378 (Source_File_Name, ALI_Dependency_Suffix));
382 ---------------------------
383 -- Display_Language_Name --
384 ---------------------------
386 procedure Display_Language_Name
387 (In_Tree : Project_Tree_Ref;
388 Language : Language_Index)
391 Get_Name_String (In_Tree.Languages_Data.Table (Language).Display_Name);
392 Write_Str (Name_Buffer (1 .. Name_Len));
393 end Display_Language_Name;
399 function Empty_File return File_Name_Type is
401 return File_Name_Type (The_Empty_String);
408 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data is
409 Value : Project_Data;
412 Prj.Initialize (Tree => No_Project_Tree);
413 Value := Project_Empty;
414 Value.Naming := Tree.Private_Part.Default_Naming;
423 function Empty_String return Name_Id is
425 return The_Empty_String;
432 procedure Expect (The_Token : Token_Type; Token_Image : String) is
434 if Token /= The_Token then
435 Error_Msg (Token_Image & " expected", Token_Ptr);
444 (File : File_Name_Type;
445 With_Suffix : String) return File_Name_Type
450 Get_Name_String (File);
451 Last := Name_Len + 1;
453 while Name_Len /= 0 and then Name_Buffer (Name_Len) /= '.' loop
454 Name_Len := Name_Len - 1;
457 if Name_Len <= 1 then
461 for J in With_Suffix'Range loop
462 Name_Buffer (Name_Len) := With_Suffix (J);
463 Name_Len := Name_Len + 1;
466 Name_Len := Name_Len - 1;
471 --------------------------------
472 -- For_Every_Project_Imported --
473 --------------------------------
475 procedure For_Every_Project_Imported
477 In_Tree : Project_Tree_Ref;
478 With_State : in out State)
481 procedure Recursive_Check (Project : Project_Id);
482 -- Check if a project has already been seen. If not seen, mark it as
483 -- Seen, Call Action, and check all its imported projects.
485 ---------------------
486 -- Recursive_Check --
487 ---------------------
489 procedure Recursive_Check (Project : Project_Id) is
492 if not In_Tree.Projects.Table (Project).Seen then
493 In_Tree.Projects.Table (Project).Seen := True;
494 Action (Project, With_State);
496 List := In_Tree.Projects.Table (Project).Imported_Projects;
497 while List /= Empty_Project_List loop
498 Recursive_Check (In_Tree.Project_Lists.Table (List).Project);
499 List := In_Tree.Project_Lists.Table (List).Next;
504 -- Start of processing for For_Every_Project_Imported
507 for Project in Project_Table.First ..
508 Project_Table.Last (In_Tree.Projects)
510 In_Tree.Projects.Table (Project).Seen := False;
513 Recursive_Check (Project => By);
514 end For_Every_Project_Imported;
520 function Get_Mode return Mode is
529 function Hash is new System.HTable.Hash (Header_Num => Header_Num);
530 -- Used in implementation of other functions Hash below
532 function Hash (Name : File_Name_Type) return Header_Num is
534 return Hash (Get_Name_String (Name));
537 function Hash (Name : Name_Id) return Header_Num is
539 return Hash (Get_Name_String (Name));
542 function Hash (Name : Path_Name_Type) return Header_Num is
544 return Hash (Get_Name_String (Name));
547 function Hash (Project : Project_Id) return Header_Num is
549 return Header_Num (Project mod Max_Header_Num);
556 function Image (Casing : Casing_Type) return String is
558 return The_Casing_Images (Casing).all;
561 ----------------------
562 -- In_Configuration --
563 ----------------------
565 function In_Configuration return Boolean is
567 return Configuration_Mode;
568 end In_Configuration;
574 procedure Initialize (Tree : Project_Tree_Ref) is
576 if not Initialized then
580 The_Empty_String := Name_Find;
581 Empty_Name := The_Empty_String;
582 Empty_File_Name := File_Name_Type (The_Empty_String);
584 Name_Buffer (1 .. 4) := ".ads";
585 Default_Ada_Spec_Suffix_Id := Name_Find;
587 Name_Buffer (1 .. 4) := ".adb";
588 Default_Ada_Body_Suffix_Id := Name_Find;
590 Name_Buffer (1) := '/';
591 Slash_Id := Name_Find;
595 Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project));
596 Set_Name_Table_Byte (Name_Extends, Token_Type'Pos (Tok_Extends));
597 Set_Name_Table_Byte (Name_External, Token_Type'Pos (Tok_External));
600 if Tree /= No_Project_Tree then
609 function Is_A_Language
610 (Tree : Project_Tree_Ref;
612 Language_Name : Name_Id) return Boolean
615 if Get_Mode = Ada_Only then
617 List : Name_List_Index := Data.Languages;
619 while List /= No_Name_List loop
620 if Tree.Name_Lists.Table (List).Name = Language_Name then
623 List := Tree.Name_Lists.Table (List).Next;
630 Lang_Ind : Language_Index := Data.First_Language_Processing;
631 Lang_Data : Language_Data;
634 while Lang_Ind /= No_Language_Index loop
635 Lang_Data := Tree.Languages_Data.Table (Lang_Ind);
637 if Lang_Data.Name = Language_Name then
641 Lang_Ind := Lang_Data.Next;
653 function Is_Extending
654 (Extending : Project_Id;
655 Extended : Project_Id;
656 In_Tree : Project_Tree_Ref) return Boolean
662 while Proj /= No_Project loop
663 if Proj = Extended then
667 Proj := In_Tree.Projects.Table (Proj).Extends;
673 -----------------------
674 -- Objects_Exist_For --
675 -----------------------
677 function Objects_Exist_For
679 In_Tree : Project_Tree_Ref) return Boolean
681 Language_Id : Name_Id;
682 Lang : Language_Index;
685 if Current_Mode = Multi_Language then
687 Add_Str_To_Name_Buffer (Language);
688 To_Lower (Name_Buffer (1 .. Name_Len));
689 Language_Id := Name_Find;
691 Lang := In_Tree.First_Language;
692 while Lang /= No_Language_Index loop
693 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
695 In_Tree.Languages_Data.Table
696 (Lang).Config.Objects_Generated;
699 Lang := In_Tree.Languages_Data.Table (Lang).Next;
704 end Objects_Exist_For;
711 (Source_File_Name : File_Name_Type)
712 return File_Name_Type
715 return Extend_Name (Source_File_Name, Object_Suffix);
718 ----------------------
719 -- Record_Temp_File --
720 ----------------------
722 procedure Record_Temp_File (Path : Path_Name_Type) is
724 Temp_Files.Increment_Last;
725 Temp_Files.Table (Temp_Files.Last) := Path;
726 end Record_Temp_File;
728 ------------------------------------
729 -- Register_Default_Naming_Scheme --
730 ------------------------------------
732 procedure Register_Default_Naming_Scheme
734 Default_Spec_Suffix : File_Name_Type;
735 Default_Body_Suffix : File_Name_Type;
736 In_Tree : Project_Tree_Ref)
739 Suffix : Array_Element_Id;
740 Found : Boolean := False;
741 Element : Array_Element;
744 -- Get the language name in small letters
746 Get_Name_String (Language);
747 Name_Buffer (1 .. Name_Len) := To_Lower (Name_Buffer (1 .. Name_Len));
750 -- Look for an element of the spec suffix array indexed by the language
751 -- name. If one is found, put the default value.
753 Suffix := In_Tree.Private_Part.Default_Naming.Spec_Suffix;
755 while Suffix /= No_Array_Element and then not Found loop
756 Element := In_Tree.Array_Elements.Table (Suffix);
758 if Element.Index = Lang then
760 Element.Value.Value := Name_Id (Default_Spec_Suffix);
761 In_Tree.Array_Elements.Table (Suffix) := Element;
764 Suffix := Element.Next;
768 -- If none can be found, create a new one
774 Index_Case_Sensitive => False,
775 Value => (Project => No_Project,
777 Location => No_Location,
779 Value => Name_Id (Default_Spec_Suffix),
781 Next => In_Tree.Private_Part.Default_Naming.Spec_Suffix);
782 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
783 In_Tree.Array_Elements.Table
784 (Array_Element_Table.Last (In_Tree.Array_Elements)) :=
786 In_Tree.Private_Part.Default_Naming.Spec_Suffix :=
787 Array_Element_Table.Last (In_Tree.Array_Elements);
790 -- Look for an element of the body suffix array indexed by the language
791 -- name. If one is found, put the default value.
793 Suffix := In_Tree.Private_Part.Default_Naming.Body_Suffix;
795 while Suffix /= No_Array_Element and then not Found loop
796 Element := In_Tree.Array_Elements.Table (Suffix);
798 if Element.Index = Lang then
800 Element.Value.Value := Name_Id (Default_Body_Suffix);
801 In_Tree.Array_Elements.Table (Suffix) := Element;
804 Suffix := Element.Next;
808 -- If none can be found, create a new one
814 Index_Case_Sensitive => False,
815 Value => (Project => No_Project,
817 Location => No_Location,
819 Value => Name_Id (Default_Body_Suffix),
821 Next => In_Tree.Private_Part.Default_Naming.Body_Suffix);
822 Array_Element_Table.Increment_Last
823 (In_Tree.Array_Elements);
824 In_Tree.Array_Elements.Table
825 (Array_Element_Table.Last (In_Tree.Array_Elements))
827 In_Tree.Private_Part.Default_Naming.Body_Suffix :=
828 Array_Element_Table.Last (In_Tree.Array_Elements);
830 end Register_Default_Naming_Scheme;
836 procedure Reset (Tree : Project_Tree_Ref) is
838 -- Def_Lang : constant Name_Node :=
839 -- (Name => Name_Ada,
840 -- Next => No_Name_List);
841 -- Why is the above commented out ???
848 Language_Data_Table.Init (Tree.Languages_Data);
849 Name_List_Table.Init (Tree.Name_Lists);
850 String_Element_Table.Init (Tree.String_Elements);
851 Variable_Element_Table.Init (Tree.Variable_Elements);
852 Array_Element_Table.Init (Tree.Array_Elements);
853 Array_Table.Init (Tree.Arrays);
854 Package_Table.Init (Tree.Packages);
855 Project_List_Table.Init (Tree.Project_Lists);
856 Project_Table.Init (Tree.Projects);
857 Source_Data_Table.Init (Tree.Sources);
858 Alternate_Language_Table.Init (Tree.Alt_Langs);
859 Unit_Table.Init (Tree.Units);
860 Units_Htable.Reset (Tree.Units_HT);
861 Files_Htable.Reset (Tree.Files_HT);
862 Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
864 -- Private part table
866 Naming_Table.Init (Tree.Private_Part.Namings);
867 Naming_Table.Increment_Last (Tree.Private_Part.Namings);
868 Tree.Private_Part.Namings.Table
869 (Naming_Table.Last (Tree.Private_Part.Namings)) := Std_Naming_Data;
870 Path_File_Table.Init (Tree.Private_Part.Path_Files);
871 Source_Path_Table.Init (Tree.Private_Part.Source_Paths);
872 Object_Path_Table.Init (Tree.Private_Part.Object_Paths);
873 Tree.Private_Part.Default_Naming := Std_Naming_Data;
875 if Current_Mode = Ada_Only then
876 Register_Default_Naming_Scheme
877 (Language => Name_Ada,
878 Default_Spec_Suffix => Default_Ada_Spec_Suffix,
879 Default_Body_Suffix => Default_Ada_Body_Suffix,
881 Tree.Private_Part.Default_Naming.Separate_Suffix :=
882 Default_Ada_Body_Suffix;
886 ------------------------
887 -- Same_Naming_Scheme --
888 ------------------------
890 function Same_Naming_Scheme
891 (Left, Right : Naming_Data) return Boolean
894 return Left.Dot_Replacement = Right.Dot_Replacement
895 and then Left.Casing = Right.Casing
896 and then Left.Separate_Suffix = Right.Separate_Suffix;
897 end Same_Naming_Scheme;
899 ---------------------
900 -- Set_Body_Suffix --
901 ---------------------
903 procedure Set_Body_Suffix
904 (In_Tree : Project_Tree_Ref;
906 Naming : in out Naming_Data;
907 Suffix : File_Name_Type)
909 Language_Id : Name_Id;
910 Element : Array_Element;
914 Add_Str_To_Name_Buffer (Language);
915 To_Lower (Name_Buffer (1 .. Name_Len));
916 Language_Id := Name_Find;
919 (Index => Language_Id,
921 Index_Case_Sensitive => False,
924 Project => No_Project,
925 Location => No_Location,
927 Value => Name_Id (Suffix),
929 Next => Naming.Body_Suffix);
931 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
932 Naming.Body_Suffix :=
933 Array_Element_Table.Last (In_Tree.Array_Elements);
934 In_Tree.Array_Elements.Table (Naming.Body_Suffix) := Element;
937 --------------------------
938 -- Set_In_Configuration --
939 --------------------------
941 procedure Set_In_Configuration (Value : Boolean) is
943 Configuration_Mode := Value;
944 end Set_In_Configuration;
950 procedure Set_Mode (New_Mode : Mode) is
952 Current_Mode := New_Mode;
955 Default_Language_Is_Ada := True;
956 Must_Check_Configuration := False;
957 when Multi_Language =>
958 Default_Language_Is_Ada := False;
959 Must_Check_Configuration := True;
963 ---------------------
964 -- Set_Spec_Suffix --
965 ---------------------
967 procedure Set_Spec_Suffix
968 (In_Tree : Project_Tree_Ref;
970 Naming : in out Naming_Data;
971 Suffix : File_Name_Type)
973 Language_Id : Name_Id;
974 Element : Array_Element;
978 Add_Str_To_Name_Buffer (Language);
979 To_Lower (Name_Buffer (1 .. Name_Len));
980 Language_Id := Name_Find;
983 (Index => Language_Id,
985 Index_Case_Sensitive => False,
988 Project => No_Project,
989 Location => No_Location,
991 Value => Name_Id (Suffix),
993 Next => Naming.Spec_Suffix);
995 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
996 Naming.Spec_Suffix :=
997 Array_Element_Table.Last (In_Tree.Array_Elements);
998 In_Tree.Array_Elements.Table (Naming.Spec_Suffix) := Element;
1005 function Slash return Path_Name_Type is
1010 -----------------------
1011 -- Spec_Suffix_Id_Of --
1012 -----------------------
1014 function Spec_Suffix_Id_Of
1015 (In_Tree : Project_Tree_Ref;
1017 Naming : Naming_Data) return File_Name_Type
1019 Language_Id : Name_Id;
1023 Add_Str_To_Name_Buffer (Language);
1024 To_Lower (Name_Buffer (1 .. Name_Len));
1025 Language_Id := Name_Find;
1029 (In_Tree => In_Tree,
1030 Language_Id => Language_Id,
1032 end Spec_Suffix_Id_Of;
1034 -----------------------
1035 -- Spec_Suffix_Id_Of --
1036 -----------------------
1038 function Spec_Suffix_Id_Of
1039 (In_Tree : Project_Tree_Ref;
1040 Language_Id : Name_Id;
1041 Naming : Naming_Data) return File_Name_Type
1043 Element_Id : Array_Element_Id;
1044 Element : Array_Element;
1045 Suffix : File_Name_Type := No_File;
1046 Lang : Language_Index;
1049 Element_Id := Naming.Spec_Suffix;
1050 while Element_Id /= No_Array_Element loop
1051 Element := In_Tree.Array_Elements.Table (Element_Id);
1053 if Element.Index = Language_Id then
1054 return File_Name_Type (Element.Value.Value);
1057 Element_Id := Element.Next;
1060 if Current_Mode = Multi_Language then
1061 Lang := In_Tree.First_Language;
1062 while Lang /= No_Language_Index loop
1063 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
1065 In_Tree.Languages_Data.Table
1066 (Lang).Config.Naming_Data.Spec_Suffix;
1070 Lang := In_Tree.Languages_Data.Table (Lang).Next;
1075 end Spec_Suffix_Id_Of;
1077 --------------------
1078 -- Spec_Suffix_Of --
1079 --------------------
1081 function Spec_Suffix_Of
1082 (In_Tree : Project_Tree_Ref;
1084 Naming : Naming_Data) return String
1086 Language_Id : Name_Id;
1087 Element_Id : Array_Element_Id;
1088 Element : Array_Element;
1089 Suffix : File_Name_Type := No_File;
1090 Lang : Language_Index;
1094 Add_Str_To_Name_Buffer (Language);
1095 To_Lower (Name_Buffer (1 .. Name_Len));
1096 Language_Id := Name_Find;
1098 Element_Id := Naming.Spec_Suffix;
1099 while Element_Id /= No_Array_Element loop
1100 Element := In_Tree.Array_Elements.Table (Element_Id);
1102 if Element.Index = Language_Id then
1103 return Get_Name_String (Element.Value.Value);
1106 Element_Id := Element.Next;
1109 if Current_Mode = Multi_Language then
1110 Lang := In_Tree.First_Language;
1111 while Lang /= No_Language_Index loop
1112 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
1115 (In_Tree.Languages_Data.Table
1116 (Lang).Config.Naming_Data.Spec_Suffix);
1120 Lang := In_Tree.Languages_Data.Table (Lang).Next;
1123 if Suffix /= No_File then
1124 return Get_Name_String (Suffix);
1131 --------------------------
1132 -- Standard_Naming_Data --
1133 --------------------------
1135 function Standard_Naming_Data
1136 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data
1139 if Tree = No_Project_Tree then
1140 Prj.Initialize (Tree => No_Project_Tree);
1141 return Std_Naming_Data;
1143 return Tree.Private_Part.Default_Naming;
1145 end Standard_Naming_Data;
1151 function Switches_Name
1152 (Source_File_Name : File_Name_Type) return File_Name_Type
1155 return Extend_Name (Source_File_Name, Switches_Dependency_Suffix);
1158 ---------------------------
1159 -- There_Are_Ada_Sources --
1160 ---------------------------
1162 function There_Are_Ada_Sources
1163 (In_Tree : Project_Tree_Ref;
1164 Project : Project_Id) return Boolean
1170 while Prj /= No_Project loop
1171 if In_Tree.Projects.Table (Prj).Ada_Sources /= Nil_String then
1175 Prj := In_Tree.Projects.Table (Prj).Extends;
1179 end There_Are_Ada_Sources;
1185 function Value (Image : String) return Casing_Type is
1187 for Casing in The_Casing_Images'Range loop
1188 if To_Lower (Image) = To_Lower (The_Casing_Images (Casing).all) then
1193 raise Constraint_Error;
1197 -- Make sure that the standard config and user project file extensions are
1198 -- compatible with canonical case file naming.
1200 Canonical_Case_File_Name (Config_Project_File_Extension);
1201 Canonical_Case_File_Name (Project_File_Extension);