1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2007, 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;
35 with Uintp; use Uintp;
37 with System.Case_Util; use System.Case_Util;
41 Object_Suffix : constant String := Get_Target_Object_Suffix.all;
42 -- File suffix for object files
44 Initial_Buffer_Size : constant := 100;
45 -- Initial size for extensible buffer used in Add_To_Buffer
47 Current_Mode : Mode := Ada_Only;
49 Configuration_Mode : Boolean := False;
51 The_Empty_String : Name_Id;
53 Name_C_Plus_Plus : 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,
87 Impl_Suffixes => No_Impl_Suffixes,
88 Supp_Suffixes => No_Supp_Language_Index);
90 Project_Empty : constant Project_Data :=
91 (Externally_Built => False,
92 Config => Default_Project_Config,
93 Languages => No_Name_List,
94 First_Referred_By => No_Project,
96 Display_Name => No_Name,
98 Display_Path_Name => No_Path,
100 Location => No_Location,
102 Directory => No_Path,
103 Display_Directory => No_Path,
106 Library_Dir => No_Path,
107 Display_Library_Dir => No_Path,
108 Library_Src_Dir => No_Path,
109 Display_Library_Src_Dir => No_Path,
110 Library_ALI_Dir => No_Path,
111 Display_Library_ALI_Dir => No_Path,
112 Library_Name => No_Name,
113 Library_Kind => Static,
114 Lib_Internal_Name => No_Name,
115 Standalone_Library => False,
116 Lib_Interface_ALIs => Nil_String,
117 Lib_Auto_Init => False,
118 Libgnarl_Needed => Unknown,
119 Symbol_Data => No_Symbols,
120 Ada_Sources => Nil_String,
121 Sources => Nil_String,
122 First_Source => No_Source,
123 Last_Source => No_Source,
124 Unit_Based_Language_Name => No_Name,
125 Unit_Based_Language_Index => No_Language_Index,
126 Imported_Directories_Switches => null,
127 Include_Path => null,
128 Include_Data_Set => False,
129 Include_Language => No_Language_Index,
130 Source_Dirs => Nil_String,
131 Known_Order_Of_Source_Dirs => True,
132 Object_Directory => No_Path,
133 Display_Object_Dir => No_Path,
134 Library_TS => Empty_Time_Stamp,
135 Exec_Directory => No_Path,
136 Display_Exec_Dir => No_Path,
137 Extends => No_Project,
138 Extended_By => No_Project,
139 Naming => Std_Naming_Data,
140 First_Language_Processing => No_Language_Index,
141 Decl => No_Declarations,
142 Imported_Projects => Empty_Project_List,
143 All_Imported_Projects => Empty_Project_List,
144 Ada_Include_Path => null,
145 Ada_Objects_Path => null,
146 Objects_Path => null,
147 Include_Path_File => No_Path,
148 Objects_Path_File_With_Libs => No_Path,
149 Objects_Path_File_Without_Libs => No_Path,
150 Config_File_Name => No_Path,
151 Config_File_Temp => False,
152 Linker_Name => No_File,
153 Linker_Path => No_Path,
154 Minimum_Linker_Options => No_Name_List,
155 Config_Checked => False,
158 Need_To_Build_Lib => False,
160 Unkept_Comments => False,
161 Langs => No_Languages,
162 Supp_Languages => No_Supp_Language_Index,
163 Ada_Sources_Present => True,
164 Other_Sources_Present => True,
165 First_Other_Source => No_Other_Source,
166 Last_Other_Source => No_Other_Source,
167 First_Lang_Processing => Default_First_Language_Processing_Data,
168 Supp_Language_Processing => No_Supp_Language_Index);
170 package Temp_Files is new Table.Table
171 (Table_Component_Type => Path_Name_Type,
172 Table_Index_Type => Integer,
173 Table_Low_Bound => 1,
175 Table_Increment => 100,
176 Table_Name => "Makegpr.Temp_Files");
177 -- Table to store the path name of all the created temporary files, so that
178 -- they can be deleted at the end, or when the program is interrupted.
180 -----------------------
181 -- Add_Language_Name --
182 -----------------------
184 procedure Add_Language_Name (Name : Name_Id) is
186 Last_Language_Index := Last_Language_Index + 1;
187 Language_Indexes.Set (Name, Last_Language_Index);
188 Language_Names.Increment_Last;
189 Language_Names.Table (Last_Language_Index) := Name;
190 end Add_Language_Name;
196 procedure Add_To_Buffer
198 To : in out String_Access;
199 Last : in out Natural)
203 To := new String (1 .. Initial_Buffer_Size);
207 -- If Buffer is too small, double its size
209 while Last + S'Length > To'Last loop
211 New_Buffer : constant String_Access :=
212 new String (1 .. 2 * Last);
215 New_Buffer (1 .. Last) := To (1 .. Last);
221 To (Last + 1 .. Last + S'Length) := S;
222 Last := Last + S'Length;
225 -----------------------
226 -- Body_Suffix_Id_Of --
227 -----------------------
229 function Body_Suffix_Id_Of
230 (In_Tree : Project_Tree_Ref;
232 Naming : Naming_Data) return File_Name_Type
234 Language_Id : Name_Id;
235 Element_Id : Array_Element_Id;
236 Element : Array_Element;
237 Suffix : File_Name_Type := No_File;
238 Lang : Language_Index;
242 Add_Str_To_Name_Buffer (Language);
243 To_Lower (Name_Buffer (1 .. Name_Len));
244 Language_Id := Name_Find;
246 Element_Id := Naming.Body_Suffix;
247 while Element_Id /= No_Array_Element loop
248 Element := In_Tree.Array_Elements.Table (Element_Id);
250 if Element.Index = Language_Id then
251 return File_Name_Type (Element.Value.Value);
254 Element_Id := Element.Next;
257 if Current_Mode = Multi_Language then
258 Lang := In_Tree.First_Language;
259 while Lang /= No_Language_Index loop
260 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
262 In_Tree.Languages_Data.Table
263 (Lang).Config.Naming_Data.Body_Suffix;
267 Lang := In_Tree.Languages_Data.Table (Lang).Next;
272 end Body_Suffix_Id_Of;
278 function Body_Suffix_Of
279 (In_Tree : Project_Tree_Ref;
281 Naming : Naming_Data) return String
283 Language_Id : Name_Id;
284 Element_Id : Array_Element_Id;
285 Element : Array_Element;
286 Suffix : File_Name_Type := No_File;
287 Lang : Language_Index;
291 Add_Str_To_Name_Buffer (Language);
292 To_Lower (Name_Buffer (1 .. Name_Len));
293 Language_Id := Name_Find;
295 Element_Id := Naming.Body_Suffix;
296 while Element_Id /= No_Array_Element loop
297 Element := In_Tree.Array_Elements.Table (Element_Id);
299 if Element.Index = Language_Id then
300 return Get_Name_String (Element.Value.Value);
303 Element_Id := Element.Next;
306 if Current_Mode = Multi_Language then
307 Lang := In_Tree.First_Language;
308 while Lang /= No_Language_Index loop
309 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
312 (In_Tree.Languages_Data.Table
313 (Lang).Config.Naming_Data.Body_Suffix);
317 Lang := In_Tree.Languages_Data.Table (Lang).Next;
320 if Suffix /= No_File then
321 return Get_Name_String (Suffix);
328 function Body_Suffix_Of
329 (Language : Language_Index;
330 In_Project : Project_Data;
331 In_Tree : Project_Tree_Ref) return String
333 Suffix_Id : constant File_Name_Type :=
334 Suffix_Of (Language, In_Project, In_Tree);
336 if Suffix_Id /= No_File then
337 return Get_Name_String (Suffix_Id);
339 return "." & Get_Name_String (Language_Names.Table (Language));
343 -----------------------------
344 -- Default_Ada_Body_Suffix --
345 -----------------------------
347 function Default_Ada_Body_Suffix return File_Name_Type is
349 return Default_Ada_Body_Suffix_Id;
350 end Default_Ada_Body_Suffix;
352 -----------------------------
353 -- Default_Ada_Spec_Suffix --
354 -----------------------------
356 function Default_Ada_Spec_Suffix return File_Name_Type is
358 return Default_Ada_Spec_Suffix_Id;
359 end Default_Ada_Spec_Suffix;
361 ---------------------------
362 -- Delete_All_Temp_Files --
363 ---------------------------
365 procedure Delete_All_Temp_Files is
367 pragma Warnings (Off, Dont_Care);
369 if not Debug.Debug_Flag_N then
370 for Index in 1 .. Temp_Files.Last loop
372 (Get_Name_String (Temp_Files.Table (Index)), Dont_Care);
375 end Delete_All_Temp_Files;
377 ---------------------
378 -- Dependency_Name --
379 ---------------------
381 function Dependency_Name
382 (Source_File_Name : File_Name_Type;
383 Dependency : Dependency_File_Kind) return File_Name_Type
394 (Source_File_Name, Makefile_Dependency_Suffix));
400 (Source_File_Name, ALI_Dependency_Suffix));
404 ---------------------------
405 -- Display_Language_Name --
406 ---------------------------
408 procedure Display_Language_Name
409 (In_Tree : Project_Tree_Ref;
410 Language : Language_Index)
413 Get_Name_String (In_Tree.Languages_Data.Table (Language).Display_Name);
414 Write_Str (Name_Buffer (1 .. Name_Len));
415 end Display_Language_Name;
417 ---------------------------
418 -- Display_Language_Name --
419 ---------------------------
421 procedure Display_Language_Name (Language : Language_Index) is
423 Get_Name_String (Language_Names.Table (Language));
424 To_Upper (Name_Buffer (1 .. 1));
425 Write_Str (Name_Buffer (1 .. Name_Len));
426 end Display_Language_Name;
432 function Empty_File return File_Name_Type is
434 return File_Name_Type (The_Empty_String);
441 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data is
442 Value : Project_Data;
445 Prj.Initialize (Tree => No_Project_Tree);
446 Value := Project_Empty;
447 Value.Naming := Tree.Private_Part.Default_Naming;
456 function Empty_String return Name_Id is
458 return The_Empty_String;
465 procedure Expect (The_Token : Token_Type; Token_Image : String) is
467 if Token /= The_Token then
468 Error_Msg (Token_Image & " expected", Token_Ptr);
477 (File : File_Name_Type;
478 With_Suffix : String) return File_Name_Type
483 Get_Name_String (File);
484 Last := Name_Len + 1;
486 while Name_Len /= 0 and then Name_Buffer (Name_Len) /= '.' loop
487 Name_Len := Name_Len - 1;
490 if Name_Len <= 1 then
494 for J in With_Suffix'Range loop
495 Name_Buffer (Name_Len) := With_Suffix (J);
496 Name_Len := Name_Len + 1;
499 Name_Len := Name_Len - 1;
504 --------------------------------
505 -- For_Every_Project_Imported --
506 --------------------------------
508 procedure For_Every_Project_Imported
510 In_Tree : Project_Tree_Ref;
511 With_State : in out State)
514 procedure Recursive_Check (Project : Project_Id);
515 -- Check if a project has already been seen. If not seen, mark it as
516 -- Seen, Call Action, and check all its imported projects.
518 ---------------------
519 -- Recursive_Check --
520 ---------------------
522 procedure Recursive_Check (Project : Project_Id) is
525 if not In_Tree.Projects.Table (Project).Seen then
526 In_Tree.Projects.Table (Project).Seen := True;
527 Action (Project, With_State);
530 In_Tree.Projects.Table (Project).Imported_Projects;
531 while List /= Empty_Project_List loop
532 Recursive_Check (In_Tree.Project_Lists.Table (List).Project);
533 List := In_Tree.Project_Lists.Table (List).Next;
538 -- Start of processing for For_Every_Project_Imported
541 for Project in Project_Table.First ..
542 Project_Table.Last (In_Tree.Projects)
544 In_Tree.Projects.Table (Project).Seen := False;
547 Recursive_Check (Project => By);
548 end For_Every_Project_Imported;
554 function Get_Mode return Mode is
563 function Hash (Name : File_Name_Type) return Header_Num is
565 return Hash (Get_Name_String (Name));
568 function Hash (Name : Name_Id) return Header_Num is
570 return Hash (Get_Name_String (Name));
573 function Hash (Name : Path_Name_Type) return Header_Num is
575 return Hash (Get_Name_String (Name));
582 function Image (Casing : Casing_Type) return String is
584 return The_Casing_Images (Casing).all;
587 ----------------------
588 -- In_Configuration --
589 ----------------------
591 function In_Configuration return Boolean is
593 return Configuration_Mode;
594 end In_Configuration;
600 procedure Initialize (Tree : Project_Tree_Ref) is
602 if not Initialized then
606 The_Empty_String := Name_Find;
607 Empty_Name := The_Empty_String;
609 Name_Buffer (1 .. 4) := ".ads";
610 Default_Ada_Spec_Suffix_Id := Name_Find;
612 Name_Buffer (1 .. 4) := ".adb";
613 Default_Ada_Body_Suffix_Id := Name_Find;
615 Name_Buffer (1) := '/';
616 Slash_Id := Name_Find;
618 Name_Buffer (1 .. 3) := "c++";
619 Name_C_Plus_Plus := Name_Find;
623 Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project));
624 Set_Name_Table_Byte (Name_Extends, Token_Type'Pos (Tok_Extends));
625 Set_Name_Table_Byte (Name_External, Token_Type'Pos (Tok_External));
627 Language_Indexes.Reset;
628 Last_Language_Index := No_Language_Index;
630 Add_Language_Name (Name_Ada);
631 Add_Language_Name (Name_C);
632 Add_Language_Name (Name_C_Plus_Plus);
635 if Tree /= No_Project_Tree then
644 function Is_A_Language
645 (Tree : Project_Tree_Ref;
647 Language_Name : String) return Boolean
653 Add_Str_To_Name_Buffer (Language_Name);
654 To_Lower (Name_Buffer (1 .. Name_Len));
655 Lang_Id := Name_Find;
657 if Get_Mode = Ada_Only then
659 List : Name_List_Index := Data.Languages;
662 while List /= No_Name_List loop
663 if Tree.Name_Lists.Table (List).Name = Lang_Id then
667 List := Tree.Name_Lists.Table (List).Next;
674 Lang_Ind : Language_Index;
675 Lang_Data : Language_Data;
678 Lang_Ind := Data.First_Language_Processing;
679 while Lang_Ind /= No_Language_Index loop
680 Lang_Data := Tree.Languages_Data.Table (Lang_Ind);
682 if Lang_Data.Name = Lang_Id then
686 Lang_Ind := Lang_Data.Next;
698 function Is_Extending
699 (Extending : Project_Id;
700 Extended : Project_Id;
701 In_Tree : Project_Tree_Ref) return Boolean
707 while Proj /= No_Project loop
708 if Proj = Extended then
712 Proj := In_Tree.Projects.Table (Proj).Extends;
723 (Language : Language_Index;
724 In_Project : Project_Data;
725 In_Tree : Project_Tree_Ref) return Boolean
729 when No_Language_Index =>
732 when First_Language_Indexes =>
733 return In_Project.Langs (Language);
737 Supp : Supp_Language;
738 Supp_Index : Supp_Language_Index := In_Project.Supp_Languages;
741 while Supp_Index /= No_Supp_Language_Index loop
742 Supp := In_Tree.Present_Languages.Table (Supp_Index);
744 if Supp.Index = Language then
748 Supp_Index := Supp.Next;
756 ---------------------------------
757 -- Language_Processing_Data_Of --
758 ---------------------------------
760 function Language_Processing_Data_Of
761 (Language : Language_Index;
762 In_Project : Project_Data;
763 In_Tree : Project_Tree_Ref) return Language_Processing_Data
767 when No_Language_Index =>
768 return Default_Language_Processing_Data;
770 when First_Language_Indexes =>
771 return In_Project.First_Lang_Processing (Language);
775 Supp : Supp_Language_Data;
776 Supp_Index : Supp_Language_Index :=
777 In_Project.Supp_Language_Processing;
780 while Supp_Index /= No_Supp_Language_Index loop
781 Supp := In_Tree.Supp_Languages.Table (Supp_Index);
783 if Supp.Index = Language then
787 Supp_Index := Supp.Next;
790 return Default_Language_Processing_Data;
793 end Language_Processing_Data_Of;
795 -----------------------
796 -- Objects_Exist_For --
797 -----------------------
799 function Objects_Exist_For
801 In_Tree : Project_Tree_Ref) return Boolean
803 Language_Id : Name_Id;
804 Lang : Language_Index;
807 if Current_Mode = Multi_Language then
809 Add_Str_To_Name_Buffer (Language);
810 To_Lower (Name_Buffer (1 .. Name_Len));
811 Language_Id := Name_Find;
813 Lang := In_Tree.First_Language;
815 while Lang /= No_Language_Index loop
816 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
818 In_Tree.Languages_Data.Table
819 (Lang).Config.Objects_Generated;
822 Lang := In_Tree.Languages_Data.Table (Lang).Next;
827 end Objects_Exist_For;
834 (Source_File_Name : File_Name_Type)
835 return File_Name_Type
838 return Extend_Name (Source_File_Name, Object_Suffix);
841 ----------------------
842 -- Record_Temp_File --
843 ----------------------
845 procedure Record_Temp_File (Path : Path_Name_Type) is
847 Temp_Files.Increment_Last;
848 Temp_Files.Table (Temp_Files.Last) := Path;
849 end Record_Temp_File;
851 ------------------------------------
852 -- Register_Default_Naming_Scheme --
853 ------------------------------------
855 procedure Register_Default_Naming_Scheme
857 Default_Spec_Suffix : File_Name_Type;
858 Default_Body_Suffix : File_Name_Type;
859 In_Tree : Project_Tree_Ref)
862 Suffix : Array_Element_Id;
863 Found : Boolean := False;
864 Element : Array_Element;
867 -- Get the language name in small letters
869 Get_Name_String (Language);
870 Name_Buffer (1 .. Name_Len) := To_Lower (Name_Buffer (1 .. Name_Len));
873 Suffix := In_Tree.Private_Part.Default_Naming.Spec_Suffix;
876 -- Look for an element of the spec sufix array indexed by the language
877 -- name. If one is found, put the default value.
879 while Suffix /= No_Array_Element and then not Found loop
880 Element := In_Tree.Array_Elements.Table (Suffix);
882 if Element.Index = Lang then
884 Element.Value.Value := Name_Id (Default_Spec_Suffix);
885 In_Tree.Array_Elements.Table (Suffix) := Element;
888 Suffix := Element.Next;
892 -- If none can be found, create a new one
898 Index_Case_Sensitive => False,
899 Value => (Project => No_Project,
901 Location => No_Location,
903 Value => Name_Id (Default_Spec_Suffix),
905 Next => In_Tree.Private_Part.Default_Naming.Spec_Suffix);
906 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
907 In_Tree.Array_Elements.Table
908 (Array_Element_Table.Last (In_Tree.Array_Elements)) :=
910 In_Tree.Private_Part.Default_Naming.Spec_Suffix :=
911 Array_Element_Table.Last (In_Tree.Array_Elements);
914 Suffix := In_Tree.Private_Part.Default_Naming.Body_Suffix;
917 -- Look for an element of the body sufix array indexed by the language
918 -- name. If one is found, put the default value.
920 while Suffix /= No_Array_Element and then not Found loop
921 Element := In_Tree.Array_Elements.Table (Suffix);
923 if Element.Index = Lang then
925 Element.Value.Value := Name_Id (Default_Body_Suffix);
926 In_Tree.Array_Elements.Table (Suffix) := Element;
929 Suffix := Element.Next;
933 -- If none can be found, create a new one
939 Index_Case_Sensitive => False,
940 Value => (Project => No_Project,
942 Location => No_Location,
944 Value => Name_Id (Default_Body_Suffix),
946 Next => In_Tree.Private_Part.Default_Naming.Body_Suffix);
947 Array_Element_Table.Increment_Last
948 (In_Tree.Array_Elements);
949 In_Tree.Array_Elements.Table
950 (Array_Element_Table.Last (In_Tree.Array_Elements))
952 In_Tree.Private_Part.Default_Naming.Body_Suffix :=
953 Array_Element_Table.Last (In_Tree.Array_Elements);
955 end Register_Default_Naming_Scheme;
961 procedure Reset (Tree : Project_Tree_Ref) is
963 -- Def_Lang : constant Name_Node :=
964 -- (Name => Name_Ada,
965 -- Next => No_Name_List);
966 -- Why is the above commented out ???
973 Present_Language_Table.Init (Tree.Present_Languages);
974 Supp_Suffix_Table.Init (Tree.Supp_Suffixes);
975 Supp_Language_Table.Init (Tree.Supp_Languages);
976 Other_Source_Table.Init (Tree.Other_Sources);
980 Language_Data_Table.Init (Tree.Languages_Data);
981 Name_List_Table.Init (Tree.Name_Lists);
982 String_Element_Table.Init (Tree.String_Elements);
983 Variable_Element_Table.Init (Tree.Variable_Elements);
984 Array_Element_Table.Init (Tree.Array_Elements);
985 Array_Table.Init (Tree.Arrays);
986 Package_Table.Init (Tree.Packages);
987 Project_List_Table.Init (Tree.Project_Lists);
988 Project_Table.Init (Tree.Projects);
989 Source_Data_Table.Init (Tree.Sources);
990 Alternate_Language_Table.Init (Tree.Alt_Langs);
991 Unit_Table.Init (Tree.Units);
992 Units_Htable.Reset (Tree.Units_HT);
993 Files_Htable.Reset (Tree.Files_HT);
994 Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
996 -- Private part table
998 Naming_Table.Init (Tree.Private_Part.Namings);
999 Naming_Table.Increment_Last (Tree.Private_Part.Namings);
1000 Tree.Private_Part.Namings.Table
1001 (Naming_Table.Last (Tree.Private_Part.Namings)) := Std_Naming_Data;
1002 Path_File_Table.Init (Tree.Private_Part.Path_Files);
1003 Source_Path_Table.Init (Tree.Private_Part.Source_Paths);
1004 Object_Path_Table.Init (Tree.Private_Part.Object_Paths);
1005 Tree.Private_Part.Default_Naming := Std_Naming_Data;
1007 if Current_Mode = Ada_Only then
1008 Register_Default_Naming_Scheme
1009 (Language => Name_Ada,
1010 Default_Spec_Suffix => Default_Ada_Spec_Suffix,
1011 Default_Body_Suffix => Default_Ada_Body_Suffix,
1013 Tree.Private_Part.Default_Naming.Separate_Suffix :=
1014 Default_Ada_Body_Suffix;
1018 ------------------------
1019 -- Same_Naming_Scheme --
1020 ------------------------
1022 function Same_Naming_Scheme
1023 (Left, Right : Naming_Data) return Boolean
1026 return Left.Dot_Replacement = Right.Dot_Replacement
1027 and then Left.Casing = Right.Casing
1028 and then Left.Separate_Suffix = Right.Separate_Suffix;
1029 end Same_Naming_Scheme;
1036 (Language : Language_Index;
1038 In_Project : in out Project_Data;
1039 In_Tree : Project_Tree_Ref)
1043 when No_Language_Index =>
1046 when First_Language_Indexes =>
1047 In_Project.Langs (Language) := Present;
1051 Supp : Supp_Language;
1052 Supp_Index : Supp_Language_Index := In_Project.Supp_Languages;
1055 while Supp_Index /= No_Supp_Language_Index loop
1056 Supp := In_Tree.Present_Languages.Table
1059 if Supp.Index = Language then
1060 In_Tree.Present_Languages.Table
1061 (Supp_Index).Present := Present;
1065 Supp_Index := Supp.Next;
1068 Supp := (Index => Language, Present => Present,
1069 Next => In_Project.Supp_Languages);
1070 Present_Language_Table.Increment_Last
1071 (In_Tree.Present_Languages);
1072 Supp_Index := Present_Language_Table.Last
1073 (In_Tree.Present_Languages);
1074 In_Tree.Present_Languages.Table (Supp_Index) :=
1076 In_Project.Supp_Languages := Supp_Index;
1082 (Language_Processing : Language_Processing_Data;
1083 For_Language : Language_Index;
1084 In_Project : in out Project_Data;
1085 In_Tree : Project_Tree_Ref)
1088 case For_Language is
1089 when No_Language_Index =>
1092 when First_Language_Indexes =>
1093 In_Project.First_Lang_Processing (For_Language) :=
1094 Language_Processing;
1098 Supp : Supp_Language_Data;
1099 Supp_Index : Supp_Language_Index;
1102 Supp_Index := In_Project.Supp_Language_Processing;
1103 while Supp_Index /= No_Supp_Language_Index loop
1104 Supp := In_Tree.Supp_Languages.Table (Supp_Index);
1106 if Supp.Index = For_Language then
1107 In_Tree.Supp_Languages.Table
1108 (Supp_Index).Data := Language_Processing;
1112 Supp_Index := Supp.Next;
1115 Supp := (Index => For_Language, Data => Language_Processing,
1116 Next => In_Project.Supp_Language_Processing);
1117 Supp_Language_Table.Increment_Last
1118 (In_Tree.Supp_Languages);
1119 Supp_Index := Supp_Language_Table.Last
1120 (In_Tree.Supp_Languages);
1121 In_Tree.Supp_Languages.Table (Supp_Index) := Supp;
1122 In_Project.Supp_Language_Processing := Supp_Index;
1128 (Suffix : File_Name_Type;
1129 For_Language : Language_Index;
1130 In_Project : in out Project_Data;
1131 In_Tree : Project_Tree_Ref)
1134 case For_Language is
1135 when No_Language_Index =>
1138 when First_Language_Indexes =>
1139 In_Project.Naming.Impl_Suffixes (For_Language) := Suffix;
1144 Supp_Index : Supp_Language_Index :=
1145 In_Project.Naming.Supp_Suffixes;
1148 while Supp_Index /= No_Supp_Language_Index loop
1149 Supp := In_Tree.Supp_Suffixes.Table
1152 if Supp.Index = For_Language then
1153 In_Tree.Supp_Suffixes.Table
1154 (Supp_Index).Suffix := Suffix;
1158 Supp_Index := Supp.Next;
1161 Supp := (Index => For_Language, Suffix => Suffix,
1162 Next => In_Project.Naming.Supp_Suffixes);
1163 Supp_Suffix_Table.Increment_Last
1164 (In_Tree.Supp_Suffixes);
1165 Supp_Index := Supp_Suffix_Table.Last
1166 (In_Tree.Supp_Suffixes);
1167 In_Tree.Supp_Suffixes.Table (Supp_Index) := Supp;
1168 In_Project.Naming.Supp_Suffixes := Supp_Index;
1173 ---------------------
1174 -- Set_Body_Suffix --
1175 ---------------------
1177 procedure Set_Body_Suffix
1178 (In_Tree : Project_Tree_Ref;
1180 Naming : in out Naming_Data;
1181 Suffix : File_Name_Type)
1183 Language_Id : Name_Id;
1184 Element : Array_Element;
1188 Add_Str_To_Name_Buffer (Language);
1189 To_Lower (Name_Buffer (1 .. Name_Len));
1190 Language_Id := Name_Find;
1193 (Index => Language_Id,
1195 Index_Case_Sensitive => False,
1198 Project => No_Project,
1199 Location => No_Location,
1201 Value => Name_Id (Suffix),
1203 Next => Naming.Body_Suffix);
1205 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
1206 Naming.Body_Suffix :=
1207 Array_Element_Table.Last (In_Tree.Array_Elements);
1208 In_Tree.Array_Elements.Table (Naming.Body_Suffix) := Element;
1209 end Set_Body_Suffix;
1211 --------------------------
1212 -- Set_In_Configuration --
1213 --------------------------
1215 procedure Set_In_Configuration (Value : Boolean) is
1217 Configuration_Mode := Value;
1218 end Set_In_Configuration;
1224 procedure Set_Mode (New_Mode : Mode) is
1226 Current_Mode := New_Mode;
1229 ---------------------
1230 -- Set_Spec_Suffix --
1231 ---------------------
1233 procedure Set_Spec_Suffix
1234 (In_Tree : Project_Tree_Ref;
1236 Naming : in out Naming_Data;
1237 Suffix : File_Name_Type)
1239 Language_Id : Name_Id;
1240 Element : Array_Element;
1244 Add_Str_To_Name_Buffer (Language);
1245 To_Lower (Name_Buffer (1 .. Name_Len));
1246 Language_Id := Name_Find;
1249 (Index => Language_Id,
1251 Index_Case_Sensitive => False,
1254 Project => No_Project,
1255 Location => No_Location,
1257 Value => Name_Id (Suffix),
1259 Next => Naming.Spec_Suffix);
1261 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
1262 Naming.Spec_Suffix :=
1263 Array_Element_Table.Last (In_Tree.Array_Elements);
1264 In_Tree.Array_Elements.Table (Naming.Spec_Suffix) := Element;
1265 end Set_Spec_Suffix;
1271 function Slash return Path_Name_Type is
1276 -----------------------
1277 -- Spec_Suffix_Id_Of --
1278 -----------------------
1280 function Spec_Suffix_Id_Of
1281 (In_Tree : Project_Tree_Ref;
1283 Naming : Naming_Data) return File_Name_Type
1285 Language_Id : Name_Id;
1286 Element_Id : Array_Element_Id;
1287 Element : Array_Element;
1288 Suffix : File_Name_Type := No_File;
1289 Lang : Language_Index;
1293 Add_Str_To_Name_Buffer (Language);
1294 To_Lower (Name_Buffer (1 .. Name_Len));
1295 Language_Id := Name_Find;
1297 Element_Id := Naming.Spec_Suffix;
1299 while Element_Id /= No_Array_Element loop
1300 Element := In_Tree.Array_Elements.Table (Element_Id);
1302 if Element.Index = Language_Id then
1303 return File_Name_Type (Element.Value.Value);
1306 Element_Id := Element.Next;
1309 if Current_Mode = Multi_Language then
1310 Lang := In_Tree.First_Language;
1312 while Lang /= No_Language_Index loop
1313 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
1315 In_Tree.Languages_Data.Table
1316 (Lang).Config.Naming_Data.Spec_Suffix;
1320 Lang := In_Tree.Languages_Data.Table (Lang).Next;
1325 end Spec_Suffix_Id_Of;
1327 --------------------
1328 -- Spec_Suffix_Of --
1329 --------------------
1331 function Spec_Suffix_Of
1332 (In_Tree : Project_Tree_Ref;
1334 Naming : Naming_Data) return String
1336 Language_Id : Name_Id;
1337 Element_Id : Array_Element_Id;
1338 Element : Array_Element;
1339 Suffix : File_Name_Type := No_File;
1340 Lang : Language_Index;
1344 Add_Str_To_Name_Buffer (Language);
1345 To_Lower (Name_Buffer (1 .. Name_Len));
1346 Language_Id := Name_Find;
1348 Element_Id := Naming.Spec_Suffix;
1350 while Element_Id /= No_Array_Element loop
1351 Element := In_Tree.Array_Elements.Table (Element_Id);
1353 if Element.Index = Language_Id then
1354 return Get_Name_String (Element.Value.Value);
1357 Element_Id := Element.Next;
1360 if Current_Mode = Multi_Language then
1361 Lang := In_Tree.First_Language;
1363 while Lang /= No_Language_Index loop
1364 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
1367 (In_Tree.Languages_Data.Table
1368 (Lang).Config.Naming_Data.Spec_Suffix);
1372 Lang := In_Tree.Languages_Data.Table (Lang).Next;
1375 if Suffix /= No_File then
1376 return Get_Name_String (Suffix);
1383 --------------------------
1384 -- Standard_Naming_Data --
1385 --------------------------
1387 function Standard_Naming_Data
1388 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data
1391 if Tree = No_Project_Tree then
1392 Prj.Initialize (Tree => No_Project_Tree);
1393 return Std_Naming_Data;
1396 return Tree.Private_Part.Default_Naming;
1398 end Standard_Naming_Data;
1405 (Language : Language_Index;
1406 In_Project : Project_Data;
1407 In_Tree : Project_Tree_Ref) return File_Name_Type
1411 when No_Language_Index =>
1414 when First_Language_Indexes =>
1415 return In_Project.Naming.Impl_Suffixes (Language);
1420 Supp_Index : Supp_Language_Index :=
1421 In_Project.Naming.Supp_Suffixes;
1424 while Supp_Index /= No_Supp_Language_Index loop
1425 Supp := In_Tree.Supp_Suffixes.Table (Supp_Index);
1427 if Supp.Index = Language then
1431 Supp_Index := Supp.Next;
1443 function Switches_Name
1444 (Source_File_Name : File_Name_Type) return File_Name_Type
1447 return Extend_Name (Source_File_Name, Switches_Dependency_Suffix);
1450 ---------------------------
1451 -- There_Are_Ada_Sources --
1452 ---------------------------
1454 function There_Are_Ada_Sources
1455 (In_Tree : Project_Tree_Ref;
1456 Project : Project_Id) return Boolean
1462 while Prj /= No_Project loop
1463 if In_Tree.Projects.Table (Prj).Ada_Sources /= Nil_String then
1467 Prj := In_Tree.Projects.Table (Prj).Extends;
1471 end There_Are_Ada_Sources;
1477 function Value (Image : String) return Casing_Type is
1479 for Casing in The_Casing_Images'Range loop
1480 if To_Lower (Image) = To_Lower (The_Casing_Images (Casing).all) then
1485 raise Constraint_Error;
1489 -- Make sure that the standard config and user project file extensions are
1490 -- compatible with canonical case file naming.
1492 Canonical_Case_File_Name (Config_Project_File_Extension);
1493 Canonical_Case_File_Name (Project_File_Extension);