1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2009, 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;
27 with Ada.Unchecked_Deallocation;
30 with Output; use Output;
31 with Osint; use Osint;
34 with Prj.Err; use Prj.Err;
35 with Snames; use Snames;
37 with Uintp; use Uintp;
39 with System.Case_Util; use System.Case_Util;
44 Object_Suffix : constant String := Get_Target_Object_Suffix.all;
45 -- File suffix for object files
47 Initial_Buffer_Size : constant := 100;
48 -- Initial size for extensible buffer used in Add_To_Buffer
50 Current_Mode : Mode := Ada_Only;
52 Configuration_Mode : Boolean := False;
54 The_Empty_String : Name_Id;
56 Default_Ada_Spec_Suffix_Id : File_Name_Type;
57 Default_Ada_Body_Suffix_Id : File_Name_Type;
58 Slash_Id : Path_Name_Type;
59 -- Initialized in Prj.Initialize, then never modified
61 subtype Known_Casing is Casing_Type range All_Upper_Case .. Mixed_Case;
63 The_Casing_Images : constant array (Known_Casing) of String_Access :=
64 (All_Lower_Case => new String'("lowercase"),
65 All_Upper_Case => new String'("UPPERCASE"),
66 Mixed_Case => new String'("MixedCase"));
68 Initialized : Boolean := False;
70 Standard_Dot_Replacement : constant File_Name_Type :=
72 (First_Name_Id + Character'Pos ('-'));
74 Std_Naming_Data : constant Naming_Data :=
75 (Dot_Replacement => Standard_Dot_Replacement,
76 Casing => All_Lower_Case,
77 Spec_Suffix => No_Array_Element,
78 Body_Suffix => No_Array_Element,
79 Separate_Suffix => No_File,
80 Specs => No_Array_Element,
81 Bodies => No_Array_Element,
82 Specification_Exceptions => No_Array_Element,
83 Implementation_Exceptions => No_Array_Element);
85 Project_Empty : constant Project_Data :=
86 (Qualifier => Unspecified,
87 Externally_Built => False,
88 Config => Default_Project_Config,
89 Languages => No_Name_List,
91 Display_Name => No_Name,
92 Path => No_Path_Information,
94 Location => No_Location,
96 Directory => No_Path_Information,
99 Library_Dir => No_Path_Information,
100 Library_Src_Dir => No_Path_Information,
101 Library_ALI_Dir => No_Path_Information,
102 Library_Name => No_Name,
103 Library_Kind => Static,
104 Lib_Internal_Name => No_Name,
105 Standalone_Library => False,
106 Lib_Interface_ALIs => Nil_String,
107 Lib_Auto_Init => False,
108 Libgnarl_Needed => Unknown,
109 Symbol_Data => No_Symbols,
110 Ada_Sources_Present => True,
111 Other_Sources_Present => True,
112 Ada_Sources => Nil_String,
113 First_Source => No_Source,
114 Last_Source => No_Source,
115 Interfaces_Defined => False,
116 Unit_Based_Language_Name => No_Name,
117 Unit_Based_Language_Index => No_Language_Index,
118 Imported_Directories_Switches => null,
119 Include_Path => null,
120 Include_Data_Set => False,
121 Include_Language => No_Language_Index,
122 Source_Dirs => Nil_String,
123 Known_Order_Of_Source_Dirs => True,
124 Object_Directory => No_Path_Information,
125 Library_TS => Empty_Time_Stamp,
126 Exec_Directory => No_Path_Information,
127 Extends => No_Project,
128 Extended_By => No_Project,
129 Naming => Std_Naming_Data,
130 First_Language_Processing => No_Language_Index,
131 Decl => No_Declarations,
132 Imported_Projects => Empty_Project_List,
133 All_Imported_Projects => Empty_Project_List,
134 Ada_Include_Path => null,
135 Ada_Objects_Path => null,
136 Objects_Path => null,
137 Include_Path_File => No_Path,
138 Objects_Path_File_With_Libs => No_Path,
139 Objects_Path_File_Without_Libs => No_Path,
140 Config_File_Name => No_Path,
141 Config_File_Temp => False,
142 Config_Checked => False,
145 Need_To_Build_Lib => False,
147 Unkept_Comments => False);
149 package Temp_Files is new Table.Table
150 (Table_Component_Type => Path_Name_Type,
151 Table_Index_Type => Integer,
152 Table_Low_Bound => 1,
154 Table_Increment => 100,
155 Table_Name => "Makegpr.Temp_Files");
156 -- Table to store the path name of all the created temporary files, so that
157 -- they can be deleted at the end, or when the program is interrupted.
159 procedure Free (Project : in out Project_Data);
160 -- Free memory allocated for Project
166 procedure Add_To_Buffer
168 To : in out String_Access;
169 Last : in out Natural)
173 To := new String (1 .. Initial_Buffer_Size);
177 -- If Buffer is too small, double its size
179 while Last + S'Length > To'Last loop
181 New_Buffer : constant String_Access :=
182 new String (1 .. 2 * Last);
185 New_Buffer (1 .. Last) := To (1 .. Last);
191 To (Last + 1 .. Last + S'Length) := S;
192 Last := Last + S'Length;
195 -----------------------
196 -- Body_Suffix_Id_Of --
197 -----------------------
199 function Body_Suffix_Id_Of
200 (In_Tree : Project_Tree_Ref;
202 Naming : Naming_Data) return File_Name_Type
204 Language_Id : Name_Id;
208 Add_Str_To_Name_Buffer (Language);
209 To_Lower (Name_Buffer (1 .. Name_Len));
210 Language_Id := Name_Find;
215 Language_Id => Language_Id,
217 end Body_Suffix_Id_Of;
219 -----------------------
220 -- Body_Suffix_Id_Of --
221 -----------------------
223 function Body_Suffix_Id_Of
224 (In_Tree : Project_Tree_Ref;
225 Language_Id : Name_Id;
226 Naming : Naming_Data) return File_Name_Type
228 Element_Id : Array_Element_Id;
229 Element : Array_Element;
230 Suffix : File_Name_Type := No_File;
231 Lang : Language_Index;
234 -- ??? This seems to be only for Ada_Only mode...
235 Element_Id := Naming.Body_Suffix;
236 while Element_Id /= No_Array_Element loop
237 Element := In_Tree.Array_Elements.Table (Element_Id);
239 if Element.Index = Language_Id then
240 return File_Name_Type (Element.Value.Value);
243 Element_Id := Element.Next;
246 if Current_Mode = Multi_Language then
247 Lang := In_Tree.First_Language;
248 while Lang /= No_Language_Index loop
249 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
251 In_Tree.Languages_Data.Table
252 (Lang).Config.Naming_Data.Body_Suffix;
256 Lang := In_Tree.Languages_Data.Table (Lang).Next;
261 end Body_Suffix_Id_Of;
267 function Body_Suffix_Of
268 (In_Tree : Project_Tree_Ref;
270 Naming : Naming_Data) return String
272 Language_Id : Name_Id;
273 Element_Id : Array_Element_Id;
274 Element : Array_Element;
275 Suffix : File_Name_Type := No_File;
276 Lang : Language_Index;
280 Add_Str_To_Name_Buffer (Language);
281 To_Lower (Name_Buffer (1 .. Name_Len));
282 Language_Id := Name_Find;
284 Element_Id := Naming.Body_Suffix;
285 while Element_Id /= No_Array_Element loop
286 Element := In_Tree.Array_Elements.Table (Element_Id);
288 if Element.Index = Language_Id then
289 return Get_Name_String (Element.Value.Value);
292 Element_Id := Element.Next;
295 if Current_Mode = Multi_Language then
296 Lang := In_Tree.First_Language;
297 while Lang /= No_Language_Index loop
298 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
301 (In_Tree.Languages_Data.Table
302 (Lang).Config.Naming_Data.Body_Suffix);
306 Lang := In_Tree.Languages_Data.Table (Lang).Next;
309 if Suffix /= No_File then
310 return Get_Name_String (Suffix);
317 -----------------------------
318 -- Default_Ada_Body_Suffix --
319 -----------------------------
321 function Default_Ada_Body_Suffix return File_Name_Type is
323 return Default_Ada_Body_Suffix_Id;
324 end Default_Ada_Body_Suffix;
326 -----------------------------
327 -- Default_Ada_Spec_Suffix --
328 -----------------------------
330 function Default_Ada_Spec_Suffix return File_Name_Type is
332 return Default_Ada_Spec_Suffix_Id;
333 end Default_Ada_Spec_Suffix;
335 ---------------------------
336 -- Delete_All_Temp_Files --
337 ---------------------------
339 procedure Delete_All_Temp_Files is
341 pragma Warnings (Off, Dont_Care);
343 if not Debug.Debug_Flag_N then
344 for Index in 1 .. Temp_Files.Last loop
346 (Get_Name_String (Temp_Files.Table (Index)), Dont_Care);
349 end Delete_All_Temp_Files;
351 ---------------------
352 -- Dependency_Name --
353 ---------------------
355 function Dependency_Name
356 (Source_File_Name : File_Name_Type;
357 Dependency : Dependency_File_Kind) return File_Name_Type
368 (Source_File_Name, Makefile_Dependency_Suffix));
374 (Source_File_Name, ALI_Dependency_Suffix));
378 ---------------------------
379 -- Display_Language_Name --
380 ---------------------------
382 procedure Display_Language_Name
383 (In_Tree : Project_Tree_Ref;
384 Language : Language_Index)
387 Get_Name_String (In_Tree.Languages_Data.Table (Language).Display_Name);
388 Write_Str (Name_Buffer (1 .. Name_Len));
389 end Display_Language_Name;
395 function Empty_File return File_Name_Type is
397 return File_Name_Type (The_Empty_String);
404 function Empty_Project (Tree : Project_Tree_Ref) return Project_Data is
405 Value : Project_Data;
408 Prj.Initialize (Tree => No_Project_Tree);
409 Value := Project_Empty;
410 Value.Naming := Tree.Private_Part.Default_Naming;
419 function Empty_String return Name_Id is
421 return The_Empty_String;
428 procedure Expect (The_Token : Token_Type; Token_Image : String) is
430 if Token /= The_Token then
431 Error_Msg (Token_Image & " expected", Token_Ptr);
440 (File : File_Name_Type;
441 With_Suffix : String) return File_Name_Type
446 Get_Name_String (File);
447 Last := Name_Len + 1;
449 while Name_Len /= 0 and then Name_Buffer (Name_Len) /= '.' loop
450 Name_Len := Name_Len - 1;
453 if Name_Len <= 1 then
457 for J in With_Suffix'Range loop
458 Name_Buffer (Name_Len) := With_Suffix (J);
459 Name_Len := Name_Len + 1;
462 Name_Len := Name_Len - 1;
467 --------------------------------
468 -- For_Every_Project_Imported --
469 --------------------------------
471 procedure For_Every_Project_Imported
473 In_Tree : Project_Tree_Ref;
474 With_State : in out State)
477 procedure Recursive_Check (Project : Project_Id);
478 -- Check if a project has already been seen. If not seen, mark it as
479 -- Seen, Call Action, and check all its imported projects.
481 ---------------------
482 -- Recursive_Check --
483 ---------------------
485 procedure Recursive_Check (Project : Project_Id) is
488 if not In_Tree.Projects.Table (Project).Seen then
489 In_Tree.Projects.Table (Project).Seen := True;
490 Action (Project, With_State);
492 List := In_Tree.Projects.Table (Project).Imported_Projects;
493 while List /= Empty_Project_List loop
494 Recursive_Check (In_Tree.Project_Lists.Table (List).Project);
495 List := In_Tree.Project_Lists.Table (List).Next;
500 -- Start of processing for For_Every_Project_Imported
503 for Project in Project_Table.First ..
504 Project_Table.Last (In_Tree.Projects)
506 In_Tree.Projects.Table (Project).Seen := False;
509 Recursive_Check (Project => By);
510 end For_Every_Project_Imported;
516 function Get_Mode return Mode is
525 function Hash is new System.HTable.Hash (Header_Num => Header_Num);
526 -- Used in implementation of other functions Hash below
528 function Hash (Name : File_Name_Type) return Header_Num is
530 return Hash (Get_Name_String (Name));
533 function Hash (Name : Name_Id) return Header_Num is
535 return Hash (Get_Name_String (Name));
538 function Hash (Name : Path_Name_Type) return Header_Num is
540 return Hash (Get_Name_String (Name));
543 function Hash (Project : Project_Id) return Header_Num is
545 return Header_Num (Project mod Max_Header_Num);
552 function Image (Casing : Casing_Type) return String is
554 return The_Casing_Images (Casing).all;
557 ----------------------
558 -- In_Configuration --
559 ----------------------
561 function In_Configuration return Boolean is
563 return Configuration_Mode;
564 end In_Configuration;
570 procedure Initialize (Tree : Project_Tree_Ref) is
572 if not Initialized then
576 The_Empty_String := Name_Find;
577 Empty_Name := The_Empty_String;
578 Empty_File_Name := File_Name_Type (The_Empty_String);
580 Name_Buffer (1 .. 4) := ".ads";
581 Default_Ada_Spec_Suffix_Id := Name_Find;
583 Name_Buffer (1 .. 4) := ".adb";
584 Default_Ada_Body_Suffix_Id := Name_Find;
586 Name_Buffer (1) := '/';
587 Slash_Id := Name_Find;
591 Set_Name_Table_Byte (Name_Project, Token_Type'Pos (Tok_Project));
592 Set_Name_Table_Byte (Name_Extends, Token_Type'Pos (Tok_Extends));
593 Set_Name_Table_Byte (Name_External, Token_Type'Pos (Tok_External));
596 if Tree /= No_Project_Tree then
605 function Is_A_Language
606 (Tree : Project_Tree_Ref;
608 Language_Name : Name_Id) return Boolean
611 if Get_Mode = Ada_Only then
613 List : Name_List_Index := Data.Languages;
615 while List /= No_Name_List loop
616 if Tree.Name_Lists.Table (List).Name = Language_Name then
619 List := Tree.Name_Lists.Table (List).Next;
626 Lang_Ind : Language_Index := Data.First_Language_Processing;
627 Lang_Data : Language_Data;
630 while Lang_Ind /= No_Language_Index loop
631 Lang_Data := Tree.Languages_Data.Table (Lang_Ind);
633 if Lang_Data.Name = Language_Name then
637 Lang_Ind := Lang_Data.Next;
649 function Is_Extending
650 (Extending : Project_Id;
651 Extended : Project_Id;
652 In_Tree : Project_Tree_Ref) return Boolean
658 while Proj /= No_Project loop
659 if Proj = Extended then
663 Proj := In_Tree.Projects.Table (Proj).Extends;
669 -----------------------
670 -- Objects_Exist_For --
671 -----------------------
673 function Objects_Exist_For
675 In_Tree : Project_Tree_Ref) return Boolean
677 Language_Id : Name_Id;
678 Lang : Language_Index;
681 if Current_Mode = Multi_Language then
683 Add_Str_To_Name_Buffer (Language);
684 To_Lower (Name_Buffer (1 .. Name_Len));
685 Language_Id := Name_Find;
687 Lang := In_Tree.First_Language;
688 while Lang /= No_Language_Index loop
689 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
691 In_Tree.Languages_Data.Table
692 (Lang).Config.Object_Generated;
695 Lang := In_Tree.Languages_Data.Table (Lang).Next;
700 end Objects_Exist_For;
707 (Source_File_Name : File_Name_Type;
708 Object_File_Suffix : Name_Id := No_Name)
709 return File_Name_Type
712 if Object_File_Suffix = No_Name then
714 (Source_File_Name, Object_Suffix);
717 (Source_File_Name, Get_Name_String (Object_File_Suffix));
721 ----------------------
722 -- Record_Temp_File --
723 ----------------------
725 procedure Record_Temp_File (Path : Path_Name_Type) is
727 Temp_Files.Increment_Last;
728 Temp_Files.Table (Temp_Files.Last) := Path;
729 end Record_Temp_File;
731 ------------------------------------
732 -- Register_Default_Naming_Scheme --
733 ------------------------------------
735 procedure Register_Default_Naming_Scheme
737 Default_Spec_Suffix : File_Name_Type;
738 Default_Body_Suffix : File_Name_Type;
739 In_Tree : Project_Tree_Ref)
742 Suffix : Array_Element_Id;
743 Found : Boolean := False;
744 Element : Array_Element;
747 -- Get the language name in small letters
749 Get_Name_String (Language);
750 Name_Buffer (1 .. Name_Len) := To_Lower (Name_Buffer (1 .. Name_Len));
753 -- Look for an element of the spec suffix array indexed by the language
754 -- name. If one is found, put the default value.
756 Suffix := In_Tree.Private_Part.Default_Naming.Spec_Suffix;
758 while Suffix /= No_Array_Element and then not Found loop
759 Element := In_Tree.Array_Elements.Table (Suffix);
761 if Element.Index = Lang then
763 Element.Value.Value := Name_Id (Default_Spec_Suffix);
764 In_Tree.Array_Elements.Table (Suffix) := Element;
767 Suffix := Element.Next;
771 -- If none can be found, create a new one
777 Index_Case_Sensitive => False,
778 Value => (Project => No_Project,
780 Location => No_Location,
782 Value => Name_Id (Default_Spec_Suffix),
784 Next => In_Tree.Private_Part.Default_Naming.Spec_Suffix);
785 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
786 In_Tree.Array_Elements.Table
787 (Array_Element_Table.Last (In_Tree.Array_Elements)) :=
789 In_Tree.Private_Part.Default_Naming.Spec_Suffix :=
790 Array_Element_Table.Last (In_Tree.Array_Elements);
793 -- Look for an element of the body suffix array indexed by the language
794 -- name. If one is found, put the default value.
796 Suffix := In_Tree.Private_Part.Default_Naming.Body_Suffix;
798 while Suffix /= No_Array_Element and then not Found loop
799 Element := In_Tree.Array_Elements.Table (Suffix);
801 if Element.Index = Lang then
803 Element.Value.Value := Name_Id (Default_Body_Suffix);
804 In_Tree.Array_Elements.Table (Suffix) := Element;
807 Suffix := Element.Next;
811 -- If none can be found, create a new one
817 Index_Case_Sensitive => False,
818 Value => (Project => No_Project,
820 Location => No_Location,
822 Value => Name_Id (Default_Body_Suffix),
824 Next => In_Tree.Private_Part.Default_Naming.Body_Suffix);
825 Array_Element_Table.Increment_Last
826 (In_Tree.Array_Elements);
827 In_Tree.Array_Elements.Table
828 (Array_Element_Table.Last (In_Tree.Array_Elements))
830 In_Tree.Private_Part.Default_Naming.Body_Suffix :=
831 Array_Element_Table.Last (In_Tree.Array_Elements);
833 end Register_Default_Naming_Scheme;
839 procedure Free (Project : in out Project_Data) is
841 Free (Project.Dir_Path);
842 Free (Project.Include_Path);
843 Free (Project.Ada_Include_Path);
844 Free (Project.Objects_Path);
845 Free (Project.Ada_Objects_Path);
852 procedure Free (Tree : in out Project_Tree_Ref) is
853 procedure Unchecked_Free is new Ada.Unchecked_Deallocation
854 (Project_Tree_Data, Project_Tree_Ref);
857 Language_Data_Table.Free (Tree.Languages_Data);
858 Name_List_Table.Free (Tree.Name_Lists);
859 String_Element_Table.Free (Tree.String_Elements);
860 Variable_Element_Table.Free (Tree.Variable_Elements);
861 Array_Element_Table.Free (Tree.Array_Elements);
862 Array_Table.Free (Tree.Arrays);
863 Package_Table.Free (Tree.Packages);
864 Project_List_Table.Free (Tree.Project_Lists);
865 Source_Data_Table.Free (Tree.Sources);
866 Alternate_Language_Table.Free (Tree.Alt_Langs);
867 Unit_Table.Free (Tree.Units);
868 Units_Htable.Reset (Tree.Units_HT);
869 Files_Htable.Reset (Tree.Files_HT);
870 Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
871 Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT);
873 for P in Project_Table.First ..
874 Project_Table.Last (Tree.Projects)
876 Free (Tree.Projects.Table (P));
879 Project_Table.Free (Tree.Projects);
883 Naming_Table.Free (Tree.Private_Part.Namings);
884 Path_File_Table.Free (Tree.Private_Part.Path_Files);
885 Source_Path_Table.Free (Tree.Private_Part.Source_Paths);
886 Object_Path_Table.Free (Tree.Private_Part.Object_Paths);
888 -- Naming data (nothing to free ?)
891 Unchecked_Free (Tree);
899 procedure Reset (Tree : Project_Tree_Ref) is
905 Language_Data_Table.Init (Tree.Languages_Data);
906 Name_List_Table.Init (Tree.Name_Lists);
907 String_Element_Table.Init (Tree.String_Elements);
908 Variable_Element_Table.Init (Tree.Variable_Elements);
909 Array_Element_Table.Init (Tree.Array_Elements);
910 Array_Table.Init (Tree.Arrays);
911 Package_Table.Init (Tree.Packages);
912 Project_List_Table.Init (Tree.Project_Lists);
913 Source_Data_Table.Init (Tree.Sources);
914 Alternate_Language_Table.Init (Tree.Alt_Langs);
915 Unit_Table.Init (Tree.Units);
916 Units_Htable.Reset (Tree.Units_HT);
917 Files_Htable.Reset (Tree.Files_HT);
918 Source_Paths_Htable.Reset (Tree.Source_Paths_HT);
919 Unit_Sources_Htable.Reset (Tree.Unit_Sources_HT);
921 if not Project_Table."=" (Tree.Projects.Table, null) then
922 for P in Project_Table.First ..
923 Project_Table.Last (Tree.Projects)
925 Free (Tree.Projects.Table (P));
929 Project_Table.Init (Tree.Projects);
931 -- Private part table
933 Naming_Table.Init (Tree.Private_Part.Namings);
934 Naming_Table.Increment_Last (Tree.Private_Part.Namings);
935 Tree.Private_Part.Namings.Table
936 (Naming_Table.Last (Tree.Private_Part.Namings)) := Std_Naming_Data;
937 Path_File_Table.Init (Tree.Private_Part.Path_Files);
938 Source_Path_Table.Init (Tree.Private_Part.Source_Paths);
939 Object_Path_Table.Init (Tree.Private_Part.Object_Paths);
940 Tree.Private_Part.Default_Naming := Std_Naming_Data;
942 if Current_Mode = Ada_Only then
943 Register_Default_Naming_Scheme
944 (Language => Name_Ada,
945 Default_Spec_Suffix => Default_Ada_Spec_Suffix,
946 Default_Body_Suffix => Default_Ada_Body_Suffix,
948 Tree.Private_Part.Default_Naming.Separate_Suffix :=
949 Default_Ada_Body_Suffix;
953 ------------------------
954 -- Same_Naming_Scheme --
955 ------------------------
957 function Same_Naming_Scheme
958 (Left, Right : Naming_Data) return Boolean
961 return Left.Dot_Replacement = Right.Dot_Replacement
962 and then Left.Casing = Right.Casing
963 and then Left.Separate_Suffix = Right.Separate_Suffix;
964 end Same_Naming_Scheme;
966 ---------------------
967 -- Set_Body_Suffix --
968 ---------------------
970 procedure Set_Body_Suffix
971 (In_Tree : Project_Tree_Ref;
973 Naming : in out Naming_Data;
974 Suffix : File_Name_Type)
976 Language_Id : Name_Id;
977 Element : Array_Element;
981 Add_Str_To_Name_Buffer (Language);
982 To_Lower (Name_Buffer (1 .. Name_Len));
983 Language_Id := Name_Find;
986 (Index => Language_Id,
988 Index_Case_Sensitive => False,
991 Project => No_Project,
992 Location => No_Location,
994 Value => Name_Id (Suffix),
996 Next => Naming.Body_Suffix);
998 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
999 Naming.Body_Suffix :=
1000 Array_Element_Table.Last (In_Tree.Array_Elements);
1001 In_Tree.Array_Elements.Table (Naming.Body_Suffix) := Element;
1002 end Set_Body_Suffix;
1004 --------------------------
1005 -- Set_In_Configuration --
1006 --------------------------
1008 procedure Set_In_Configuration (Value : Boolean) is
1010 Configuration_Mode := Value;
1011 end Set_In_Configuration;
1017 procedure Set_Mode (New_Mode : Mode) is
1019 Current_Mode := New_Mode;
1022 Default_Language_Is_Ada := True;
1023 Must_Check_Configuration := False;
1024 when Multi_Language =>
1025 Default_Language_Is_Ada := False;
1026 Must_Check_Configuration := True;
1030 ---------------------
1031 -- Set_Spec_Suffix --
1032 ---------------------
1034 procedure Set_Spec_Suffix
1035 (In_Tree : Project_Tree_Ref;
1037 Naming : in out Naming_Data;
1038 Suffix : File_Name_Type)
1040 Language_Id : Name_Id;
1041 Element : Array_Element;
1045 Add_Str_To_Name_Buffer (Language);
1046 To_Lower (Name_Buffer (1 .. Name_Len));
1047 Language_Id := Name_Find;
1050 (Index => Language_Id,
1052 Index_Case_Sensitive => False,
1055 Project => No_Project,
1056 Location => No_Location,
1058 Value => Name_Id (Suffix),
1060 Next => Naming.Spec_Suffix);
1062 Array_Element_Table.Increment_Last (In_Tree.Array_Elements);
1063 Naming.Spec_Suffix :=
1064 Array_Element_Table.Last (In_Tree.Array_Elements);
1065 In_Tree.Array_Elements.Table (Naming.Spec_Suffix) := Element;
1066 end Set_Spec_Suffix;
1072 function Slash return Path_Name_Type is
1077 -----------------------
1078 -- Spec_Suffix_Id_Of --
1079 -----------------------
1081 function Spec_Suffix_Id_Of
1082 (In_Tree : Project_Tree_Ref;
1084 Naming : Naming_Data) return File_Name_Type
1086 Language_Id : Name_Id;
1090 Add_Str_To_Name_Buffer (Language);
1091 To_Lower (Name_Buffer (1 .. Name_Len));
1092 Language_Id := Name_Find;
1096 (In_Tree => In_Tree,
1097 Language_Id => Language_Id,
1099 end Spec_Suffix_Id_Of;
1101 -----------------------
1102 -- Spec_Suffix_Id_Of --
1103 -----------------------
1105 function Spec_Suffix_Id_Of
1106 (In_Tree : Project_Tree_Ref;
1107 Language_Id : Name_Id;
1108 Naming : Naming_Data) return File_Name_Type
1110 Element_Id : Array_Element_Id;
1111 Element : Array_Element;
1112 Suffix : File_Name_Type := No_File;
1113 Lang : Language_Index;
1116 Element_Id := Naming.Spec_Suffix;
1117 while Element_Id /= No_Array_Element loop
1118 Element := In_Tree.Array_Elements.Table (Element_Id);
1120 if Element.Index = Language_Id then
1121 return File_Name_Type (Element.Value.Value);
1124 Element_Id := Element.Next;
1127 if Current_Mode = Multi_Language then
1128 Lang := In_Tree.First_Language;
1129 while Lang /= No_Language_Index loop
1130 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
1132 In_Tree.Languages_Data.Table
1133 (Lang).Config.Naming_Data.Spec_Suffix;
1137 Lang := In_Tree.Languages_Data.Table (Lang).Next;
1142 end Spec_Suffix_Id_Of;
1144 --------------------
1145 -- Spec_Suffix_Of --
1146 --------------------
1148 function Spec_Suffix_Of
1149 (In_Tree : Project_Tree_Ref;
1151 Naming : Naming_Data) return String
1153 Language_Id : Name_Id;
1154 Element_Id : Array_Element_Id;
1155 Element : Array_Element;
1156 Suffix : File_Name_Type := No_File;
1157 Lang : Language_Index;
1161 Add_Str_To_Name_Buffer (Language);
1162 To_Lower (Name_Buffer (1 .. Name_Len));
1163 Language_Id := Name_Find;
1165 Element_Id := Naming.Spec_Suffix;
1166 while Element_Id /= No_Array_Element loop
1167 Element := In_Tree.Array_Elements.Table (Element_Id);
1169 if Element.Index = Language_Id then
1170 return Get_Name_String (Element.Value.Value);
1173 Element_Id := Element.Next;
1176 if Current_Mode = Multi_Language then
1177 Lang := In_Tree.First_Language;
1178 while Lang /= No_Language_Index loop
1179 if In_Tree.Languages_Data.Table (Lang).Name = Language_Id then
1182 (In_Tree.Languages_Data.Table
1183 (Lang).Config.Naming_Data.Spec_Suffix);
1187 Lang := In_Tree.Languages_Data.Table (Lang).Next;
1190 if Suffix /= No_File then
1191 return Get_Name_String (Suffix);
1198 --------------------------
1199 -- Standard_Naming_Data --
1200 --------------------------
1202 function Standard_Naming_Data
1203 (Tree : Project_Tree_Ref := No_Project_Tree) return Naming_Data
1206 if Tree = No_Project_Tree then
1207 Prj.Initialize (Tree => No_Project_Tree);
1208 return Std_Naming_Data;
1210 return Tree.Private_Part.Default_Naming;
1212 end Standard_Naming_Data;
1218 function Switches_Name
1219 (Source_File_Name : File_Name_Type) return File_Name_Type
1222 return Extend_Name (Source_File_Name, Switches_Dependency_Suffix);
1229 function Value (Image : String) return Casing_Type is
1231 for Casing in The_Casing_Images'Range loop
1232 if To_Lower (Image) = To_Lower (The_Casing_Images (Casing).all) then
1237 raise Constraint_Error;
1241 -- Make sure that the standard config and user project file extensions are
1242 -- compatible with canonical case file naming.
1244 Canonical_Case_File_Name (Config_Project_File_Extension);
1245 Canonical_Case_File_Name (Project_File_Extension);