1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
11 -- Copyright (C) 2001 Free Software Foundation, Inc. --
13 -- GNAT is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNAT; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
24 -- GNAT was originally developed by the GNAT team at New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
27 ------------------------------------------------------------------------------
29 with Errout; use Errout;
30 with Namet; use Namet;
32 with Output; use Output;
33 with Prj.Attr; use Prj.Attr;
34 with Prj.Com; use Prj.Com;
35 with Prj.Ext; use Prj.Ext;
36 with Prj.Nmsc; use Prj.Nmsc;
37 with Stringt; use Stringt;
41 package body Prj.Proc is
43 Error_Report : Put_Line_Access := null;
45 package Processed_Projects is new GNAT.HTable.Simple_HTable
46 (Header_Num => Header_Num,
47 Element => Project_Id,
48 No_Element => No_Project,
52 -- This hash table contains all processed projects
54 procedure Add (To_Exp : in out String_Id; Str : String_Id);
55 -- Concatenate two strings and returns another string if both
56 -- arguments are not null string.
58 procedure Add_Attributes
59 (Decl : in out Declarations;
60 First : Attribute_Node_Id);
61 -- Add all attributes, starting with First, with their default
62 -- values to the package or project with declarations Decl.
65 (Project : Project_Id;
66 From_Project_Node : Project_Node_Id;
68 First_Term : Project_Node_Id;
70 return Variable_Value;
71 -- From N_Expression project node From_Project_Node, compute the value
72 -- of an expression and return it as a Variable_Value.
74 function Imported_Or_Modified_Project_From
75 (Project : Project_Id;
78 -- Find an imported or modified project of Project whose name is With_Name.
81 (Project : Project_Id;
84 -- Find the package of Project whose name is With_Name.
86 procedure Process_Declarative_Items
87 (Project : Project_Id;
88 From_Project_Node : Project_Node_Id;
90 Item : Project_Node_Id);
91 -- Process declarative items starting with From_Project_Node, and put them
92 -- in declarations Decl. This is a recursive procedure; it calls itself for
93 -- a package declaration or a case construction.
95 procedure Recursive_Process
96 (Project : out Project_Id;
97 From_Project_Node : Project_Node_Id;
98 Modified_By : Project_Id);
99 -- Process project with node From_Project_Node in the tree.
100 -- Do nothing if From_Project_Node is Empty_Node.
101 -- If project has already been processed, simply return its project id.
102 -- Otherwise create a new project id, mark it as processed, call itself
103 -- recursively for all imported projects and a modified project, if any.
104 -- Then process the declarative items of the project.
106 procedure Check (Project : in out Project_Id);
107 -- Set all projects to not checked, then call Recursive_Check for
108 -- the main project Project.
109 -- Project is set to No_Project if errors occurred.
111 procedure Recursive_Check (Project : Project_Id);
112 -- If Project is marked as not checked, mark it as checked,
113 -- call Check_Naming_Scheme for the project, then call itself
114 -- for a possible modified project and all the imported projects
121 procedure Add (To_Exp : in out String_Id; Str : String_Id) is
123 if To_Exp = Types.No_String or else String_Length (To_Exp) = 0 then
125 -- To_Exp is nil or empty. The result is Str.
129 -- If Str is nil, then do not change To_Ext
131 elsif Str /= No_String then
132 Start_String (To_Exp);
133 Store_String_Chars (Str);
134 To_Exp := End_String;
142 procedure Add_Attributes
143 (Decl : in out Declarations;
144 First : Attribute_Node_Id) is
145 The_Attribute : Attribute_Node_Id := First;
146 Attribute_Data : Attribute_Record;
149 while The_Attribute /= Empty_Attribute loop
150 Attribute_Data := Attributes.Table (The_Attribute);
152 if Attribute_Data.Kind_2 /= Associative_Array then
154 New_Attribute : Variable_Value;
157 case Attribute_Data.Kind_1 is
159 -- Undefined should not happen
163 (False, "attribute with an undefined kind");
166 -- Single attributes have a default value of empty string
171 Location => No_Location,
173 Value => Empty_String);
175 -- List attributes have a default value of nil list
180 Location => No_Location,
182 Values => Nil_String);
186 Variable_Elements.Increment_Last;
187 Variable_Elements.Table (Variable_Elements.Last) :=
188 (Next => Decl.Attributes,
189 Name => Attribute_Data.Name,
190 Value => New_Attribute);
191 Decl.Attributes := Variable_Elements.Last;
195 The_Attribute := Attributes.Table (The_Attribute).Next;
204 procedure Check (Project : in out Project_Id) is
206 -- Make sure that all projects are marked as not checked.
208 for Index in 1 .. Projects.Last loop
209 Projects.Table (Index).Checked := False;
212 Recursive_Check (Project);
214 if Errout.Errors_Detected > 0 then
215 Project := No_Project;
225 (Project : Project_Id;
226 From_Project_Node : Project_Node_Id;
228 First_Term : Project_Node_Id;
229 Kind : Variable_Kind)
230 return Variable_Value
232 The_Term : Project_Node_Id := First_Term;
233 -- The term in the expression list
235 The_Current_Term : Project_Node_Id := Empty_Node;
236 -- The current term node id
238 Term_Kind : Variable_Kind;
239 -- The kind of the current term
241 Result : Variable_Value (Kind => Kind);
242 -- The returned result
244 Last : String_List_Id := Nil_String;
245 -- Reference to the last string elements in Result, when Kind is List.
248 Result.Location := Location_Of (From_Project_Node);
250 -- Process each term of the expression, starting with First_Term
252 while The_Term /= Empty_Node loop
254 -- We get the term data and kind ...
256 Term_Kind := Expression_Kind_Of (The_Term);
258 The_Current_Term := Current_Term (The_Term);
260 case Kind_Of (The_Current_Term) is
262 when N_Literal_String =>
268 -- Should never happen
270 pragma Assert (False, "Undefined expression kind");
274 Add (Result.Value, String_Value_Of (The_Current_Term));
278 String_Elements.Increment_Last;
280 if Last = Nil_String then
282 -- This can happen in an expression such as
285 Result.Values := String_Elements.Last;
288 String_Elements.Table (Last).Next :=
289 String_Elements.Last;
292 Last := String_Elements.Last;
293 String_Elements.Table (Last) :=
294 (Value => String_Value_Of (The_Current_Term),
295 Location => Location_Of (The_Current_Term),
300 when N_Literal_String_List =>
303 String_Node : Project_Node_Id :=
304 First_Expression_In_List (The_Current_Term);
306 Value : Variable_Value;
309 if String_Node /= Empty_Node then
311 -- If String_Node is nil, it is an empty list,
312 -- there is nothing to do
316 From_Project_Node => From_Project_Node,
318 First_Term => Tree.First_Term (String_Node),
320 String_Elements.Increment_Last;
322 if Result.Values = Nil_String then
324 -- This literal string list is the first term
325 -- in a string list expression
327 Result.Values := String_Elements.Last;
330 String_Elements.Table (Last).Next :=
331 String_Elements.Last;
334 Last := String_Elements.Last;
335 String_Elements.Table (Last) :=
336 (Value => Value.Value,
337 Location => Value.Location,
341 -- Add the other element of the literal string list
342 -- one after the other
345 Next_Expression_In_List (String_Node);
347 exit when String_Node = Empty_Node;
352 From_Project_Node => From_Project_Node,
354 First_Term => Tree.First_Term (String_Node),
357 String_Elements.Increment_Last;
358 String_Elements.Table (Last).Next :=
359 String_Elements.Last;
360 Last := String_Elements.Last;
361 String_Elements.Table (Last) :=
362 (Value => Value.Value,
363 Location => Value.Location,
371 when N_Variable_Reference | N_Attribute_Reference =>
374 The_Project : Project_Id := Project;
375 The_Package : Package_Id := Pkg;
376 The_Name : Name_Id := No_Name;
377 The_Variable_Id : Variable_Id := No_Variable;
378 The_Variable : Variable;
379 Term_Project : constant Project_Node_Id :=
380 Project_Node_Of (The_Current_Term);
381 Term_Package : constant Project_Node_Id :=
382 Package_Node_Of (The_Current_Term);
385 if Term_Project /= Empty_Node and then
386 Term_Project /= From_Project_Node
388 -- This variable or attribute comes from another project
390 The_Name := Name_Of (Term_Project);
391 The_Project := Imported_Or_Modified_Project_From
392 (Project => Project, With_Name => The_Name);
395 if Term_Package /= Empty_Node then
397 -- This is an attribute of a package
399 The_Name := Name_Of (Term_Package);
400 The_Package := Projects.Table (The_Project).Decl.Packages;
402 while The_Package /= No_Package
403 and then Packages.Table (The_Package).Name /= The_Name
405 The_Package := Packages.Table (The_Package).Next;
409 (The_Package /= No_Package,
410 "package not found.");
412 elsif Kind_Of (The_Current_Term) = N_Attribute_Reference then
413 The_Package := No_Package;
416 The_Name := Name_Of (The_Current_Term);
418 if The_Package /= No_Package then
420 -- First, if there is a package, look into the package
422 if Kind_Of (The_Current_Term) = N_Variable_Reference then
424 Packages.Table (The_Package).Decl.Variables;
428 Packages.Table (The_Package).Decl.Attributes;
431 while The_Variable_Id /= No_Variable
433 Variable_Elements.Table (The_Variable_Id).Name /=
437 Variable_Elements.Table (The_Variable_Id).Next;
442 if The_Variable_Id = No_Variable then
444 -- If we have not found it, look into the project
446 if Kind_Of (The_Current_Term) = N_Variable_Reference then
448 Projects.Table (The_Project).Decl.Variables;
452 Projects.Table (The_Project).Decl.Attributes;
455 while The_Variable_Id /= No_Variable
457 Variable_Elements.Table (The_Variable_Id).Name /=
461 Variable_Elements.Table (The_Variable_Id).Next;
466 pragma Assert (The_Variable_Id /= No_Variable,
467 "variable or attribute not found");
469 The_Variable := Variable_Elements.Table (The_Variable_Id);
475 -- Should never happen
477 pragma Assert (False, "undefined expression kind");
482 case The_Variable.Value.Kind is
488 Add (Result.Value, The_Variable.Value.Value);
492 -- Should never happen
496 "list cannot appear in single " &
497 "string expression");
503 case The_Variable.Value.Kind is
509 String_Elements.Increment_Last;
511 if Last = Nil_String then
513 -- This can happen in an expression such as
516 Result.Values := String_Elements.Last;
519 String_Elements.Table (Last).Next :=
520 String_Elements.Last;
523 Last := String_Elements.Last;
524 String_Elements.Table (Last) :=
525 (Value => The_Variable.Value.Value,
526 Location => Location_Of (The_Current_Term),
532 The_List : String_List_Id :=
533 The_Variable.Value.Values;
536 while The_List /= Nil_String loop
537 String_Elements.Increment_Last;
539 if Last = Nil_String then
540 Result.Values := String_Elements.Last;
543 String_Elements.Table (Last).Next :=
544 String_Elements.Last;
548 Last := String_Elements.Last;
549 String_Elements.Table (Last) :=
551 String_Elements.Table
553 Location => Location_Of
557 String_Elements.Table (The_List).Next;
565 when N_External_Value =>
566 String_To_Name_Buffer
567 (String_Value_Of (External_Reference_Of (The_Current_Term)));
570 Name : constant Name_Id := Name_Find;
571 Default : String_Id := No_String;
572 Value : String_Id := No_String;
574 Default_Node : constant Project_Node_Id :=
575 External_Default_Of (The_Current_Term);
578 if Default_Node /= Empty_Node then
579 Default := String_Value_Of (Default_Node);
582 Value := Prj.Ext.Value_Of (Name, Default);
584 if Value = No_String then
585 if Error_Report = null then
587 ("undefined external reference",
588 Location_Of (The_Current_Term));
592 ("""" & Get_Name_String (Name) &
593 """ is an undefined external reference");
596 Value := Empty_String;
606 Add (Result.Value, Value);
609 String_Elements.Increment_Last;
611 if Last = Nil_String then
612 Result.Values := String_Elements.Last;
615 String_Elements.Table (Last).Next :=
616 String_Elements.Last;
619 Last := String_Elements.Last;
620 String_Elements.Table (Last) :=
622 Location => Location_Of (The_Current_Term),
631 -- Should never happen
635 "illegal node kind in an expression");
640 The_Term := Next_Term (The_Term);
646 ---------------------------------------
647 -- Imported_Or_Modified_Project_From --
648 ---------------------------------------
650 function Imported_Or_Modified_Project_From
651 (Project : Project_Id;
655 Data : constant Project_Data := Projects.Table (Project);
656 List : Project_List := Data.Imported_Projects;
659 -- First check if it is the name of a modified project
661 if Data.Modifies /= No_Project
662 and then Projects.Table (Data.Modifies).Name = With_Name
664 return Data.Modifies;
667 -- Then check the name of each imported project
669 while List /= Empty_Project_List
672 (Project_Lists.Table (List).Project).Name /= With_Name
675 List := Project_Lists.Table (List).Next;
679 (List /= Empty_Project_List,
680 "project not found");
682 return Project_Lists.Table (List).Project;
685 end Imported_Or_Modified_Project_From;
691 function Package_From
692 (Project : Project_Id;
696 Data : constant Project_Data := Projects.Table (Project);
697 Result : Package_Id := Data.Decl.Packages;
700 -- Check the name of each existing package of Project
702 while Result /= No_Package
704 Packages.Table (Result).Name /= With_Name
706 Result := Packages.Table (Result).Next;
709 if Result = No_Package then
710 -- Should never happen
711 Write_Line ("package """ & Get_Name_String (With_Name) &
725 (Project : out Project_Id;
726 From_Project_Node : Project_Node_Id;
727 Report_Error : Put_Line_Access)
730 Error_Report := Report_Error;
732 -- Make sure there is no projects in the data structure
734 Projects.Set_Last (No_Project);
735 Processed_Projects.Reset;
737 -- And process the main project and all of the projects it depends on,
742 From_Project_Node => From_Project_Node,
743 Modified_By => No_Project);
745 if Errout.Errors_Detected > 0 then
746 Project := No_Project;
749 if Project /= No_Project then
755 -------------------------------
756 -- Process_Declarative_Items --
757 -------------------------------
759 procedure Process_Declarative_Items
760 (Project : Project_Id;
761 From_Project_Node : Project_Node_Id;
763 Item : Project_Node_Id) is
765 Current_Declarative_Item : Project_Node_Id := Item;
767 Current_Item : Project_Node_Id := Empty_Node;
770 -- For each declarative item
772 while Current_Declarative_Item /= Empty_Node loop
776 Current_Item := Current_Item_Node (Current_Declarative_Item);
778 -- And set Current_Declarative_Item to the next declarative item
779 -- ready for the next iteration
781 Current_Declarative_Item := Next_Declarative_Item
782 (Current_Declarative_Item);
784 case Kind_Of (Current_Item) is
786 when N_Package_Declaration =>
787 Packages.Increment_Last;
790 New_Pkg : constant Package_Id := Packages.Last;
791 The_New_Package : Package_Element;
793 Project_Of_Renamed_Package : constant Project_Node_Id :=
794 Project_Of_Renamed_Package_Of
798 The_New_Package.Name := Name_Of (Current_Item);
800 if Pkg /= No_Package then
801 The_New_Package.Next :=
802 Packages.Table (Pkg).Decl.Packages;
803 Packages.Table (Pkg).Decl.Packages := New_Pkg;
805 The_New_Package.Next :=
806 Projects.Table (Project).Decl.Packages;
807 Projects.Table (Project).Decl.Packages := New_Pkg;
810 Packages.Table (New_Pkg) := The_New_Package;
812 if Project_Of_Renamed_Package /= Empty_Node then
817 Project_Name : constant Name_Id :=
819 (Project_Of_Renamed_Package);
821 Renamed_Project : constant Project_Id :=
822 Imported_Or_Modified_Project_From
823 (Project, Project_Name);
825 Renamed_Package : constant Package_Id :=
828 Name_Of (Current_Item));
831 Packages.Table (New_Pkg).Decl :=
832 Packages.Table (Renamed_Package).Decl;
836 -- Set the default values of the attributes
839 (Packages.Table (New_Pkg).Decl,
840 Package_Attributes.Table
841 (Package_Id_Of (Current_Item)).First_Attribute);
843 Process_Declarative_Items
845 From_Project_Node => From_Project_Node,
847 Item => First_Declarative_Item_Of
853 when N_String_Type_Declaration =>
855 -- There is nothing to process
859 when N_Attribute_Declaration |
860 N_Typed_Variable_Declaration |
861 N_Variable_Declaration =>
863 pragma Assert (Expression_Of (Current_Item) /= Empty_Node,
864 "no expression for an object declaration");
867 New_Value : constant Variable_Value :=
870 From_Project_Node => From_Project_Node,
873 Tree.First_Term (Expression_Of
876 Expression_Kind_Of (Current_Item));
878 The_Variable : Variable_Id := No_Variable;
880 Current_Item_Name : constant Name_Id :=
881 Name_Of (Current_Item);
884 if Kind_Of (Current_Item) = N_Typed_Variable_Declaration then
886 if String_Equal (New_Value.Value, Empty_String) then
887 Error_Msg_Name_1 := Name_Of (Current_Item);
889 if Error_Report = null then
891 ("no value defined for %",
892 Location_Of (Current_Item));
896 ("no value defined for " &
897 Get_Name_String (Error_Msg_Name_1));
902 Current_String : Project_Node_Id :=
908 while Current_String /= Empty_Node
909 and then not String_Equal
910 (String_Value_Of (Current_String),
914 Next_Literal_String (Current_String);
917 if Current_String = Empty_Node then
918 String_To_Name_Buffer (New_Value.Value);
919 Error_Msg_Name_1 := Name_Find;
920 Error_Msg_Name_2 := Name_Of (Current_Item);
922 if Error_Report = null then
924 ("value { is illegal for typed string %",
925 Location_Of (Current_Item));
930 Get_Name_String (Error_Msg_Name_1) &
931 """ is illegal for typed string """ &
932 Get_Name_String (Error_Msg_Name_2) &
940 if Kind_Of (Current_Item) /= N_Attribute_Declaration
942 Associative_Array_Index_Of (Current_Item) = No_String
946 -- Code below really needs more comments ???
948 if Kind_Of (Current_Item) = N_Attribute_Declaration then
949 if Pkg /= No_Package then
951 Packages.Table (Pkg).Decl.Attributes;
955 Projects.Table (Project).Decl.Attributes;
959 if Pkg /= No_Package then
961 Packages.Table (Pkg).Decl.Variables;
965 Projects.Table (Project).Decl.Variables;
971 The_Variable /= No_Variable
973 Variable_Elements.Table (The_Variable).Name /=
977 Variable_Elements.Table (The_Variable).Next;
980 if The_Variable = No_Variable then
982 (Kind_Of (Current_Item) /= N_Attribute_Declaration,
983 "illegal attribute declaration");
985 Variable_Elements.Increment_Last;
986 The_Variable := Variable_Elements.Last;
988 if Pkg /= No_Package then
989 Variable_Elements.Table (The_Variable) :=
991 Packages.Table (Pkg).Decl.Variables,
992 Name => Current_Item_Name,
994 Packages.Table (Pkg).Decl.Variables := The_Variable;
997 Variable_Elements.Table (The_Variable) :=
999 Projects.Table (Project).Decl.Variables,
1000 Name => Current_Item_Name,
1001 Value => New_Value);
1002 Projects.Table (Project).Decl.Variables :=
1007 Variable_Elements.Table (The_Variable).Value :=
1013 -- Associative array attribute
1015 String_To_Name_Buffer
1016 (Associative_Array_Index_Of (Current_Item));
1019 The_Array : Array_Id;
1021 The_Array_Element : Array_Element_Id :=
1024 Index_Name : constant Name_Id := Name_Find;
1028 if Pkg /= No_Package then
1029 The_Array := Packages.Table (Pkg).Decl.Arrays;
1032 The_Array := Projects.Table (Project).Decl.Arrays;
1036 The_Array /= No_Array
1037 and then Arrays.Table (The_Array).Name /=
1040 The_Array := Arrays.Table (The_Array).Next;
1043 if The_Array = No_Array then
1044 Arrays.Increment_Last;
1045 The_Array := Arrays.Last;
1047 if Pkg /= No_Package then
1048 Arrays.Table (The_Array) :=
1049 (Name => Current_Item_Name,
1050 Value => No_Array_Element,
1051 Next => Packages.Table (Pkg).Decl.Arrays);
1052 Packages.Table (Pkg).Decl.Arrays := The_Array;
1055 Arrays.Table (The_Array) :=
1056 (Name => Current_Item_Name,
1057 Value => No_Array_Element,
1059 Projects.Table (Project).Decl.Arrays);
1060 Projects.Table (Project).Decl.Arrays :=
1065 The_Array_Element := Arrays.Table (The_Array).Value;
1068 while The_Array_Element /= No_Array_Element
1070 Array_Elements.Table (The_Array_Element).Index /=
1073 The_Array_Element :=
1074 Array_Elements.Table (The_Array_Element).Next;
1077 if The_Array_Element = No_Array_Element then
1078 Array_Elements.Increment_Last;
1079 The_Array_Element := Array_Elements.Last;
1080 Array_Elements.Table (The_Array_Element) :=
1081 (Index => Index_Name,
1083 Next => Arrays.Table (The_Array).Value);
1084 Arrays.Table (The_Array).Value := The_Array_Element;
1087 Array_Elements.Table (The_Array_Element).Value :=
1094 when N_Case_Construction =>
1096 The_Project : Project_Id := Project;
1097 The_Package : Package_Id := Pkg;
1098 The_Variable : Variable_Value := Nil_Variable_Value;
1099 Case_Value : String_Id := No_String;
1100 Case_Item : Project_Node_Id := Empty_Node;
1101 Choice_String : Project_Node_Id := Empty_Node;
1102 Decl_Item : Project_Node_Id := Empty_Node;
1106 Variable_Node : constant Project_Node_Id :=
1107 Case_Variable_Reference_Of
1110 Var_Id : Variable_Id := No_Variable;
1111 Name : Name_Id := No_Name;
1114 if Project_Node_Of (Variable_Node) /= Empty_Node then
1115 Name := Name_Of (Project_Node_Of (Variable_Node));
1117 Imported_Or_Modified_Project_From (Project, Name);
1120 if Package_Node_Of (Variable_Node) /= Empty_Node then
1121 Name := Name_Of (Package_Node_Of (Variable_Node));
1122 The_Package := Package_From (The_Project, Name);
1125 Name := Name_Of (Variable_Node);
1127 if The_Package /= No_Package then
1128 Var_Id := Packages.Table (The_Package).Decl.Variables;
1129 Name := Name_Of (Variable_Node);
1130 while Var_Id /= No_Variable
1132 Variable_Elements.Table (Var_Id).Name /= Name
1134 Var_Id := Variable_Elements.Table (Var_Id).Next;
1138 if Var_Id = No_Variable
1139 and then Package_Node_Of (Variable_Node) = Empty_Node
1141 Var_Id := Projects.Table (The_Project).Decl.Variables;
1142 while Var_Id /= No_Variable
1144 Variable_Elements.Table (Var_Id).Name /= Name
1146 Var_Id := Variable_Elements.Table (Var_Id).Next;
1150 if Var_Id = No_Variable then
1152 -- Should never happen
1154 Write_Line ("variable """ &
1155 Get_Name_String (Name) &
1157 raise Program_Error;
1160 The_Variable := Variable_Elements.Table (Var_Id).Value;
1162 if The_Variable.Kind /= Single then
1164 -- Should never happen
1166 Write_Line ("variable""" &
1167 Get_Name_String (Name) &
1168 """ is not a single string variable");
1169 raise Program_Error;
1172 Case_Value := The_Variable.Value;
1175 Case_Item := First_Case_Item_Of (Current_Item);
1177 while Case_Item /= Empty_Node loop
1178 Choice_String := First_Choice_Of (Case_Item);
1180 if Choice_String = Empty_Node then
1181 Decl_Item := First_Declarative_Item_Of (Case_Item);
1182 exit Case_Item_Loop;
1186 while Choice_String /= Empty_Node loop
1187 if String_Equal (Case_Value,
1188 String_Value_Of (Choice_String))
1191 First_Declarative_Item_Of (Case_Item);
1192 exit Case_Item_Loop;
1196 Next_Literal_String (Choice_String);
1197 end loop Choice_Loop;
1198 Case_Item := Next_Case_Item (Case_Item);
1199 end loop Case_Item_Loop;
1201 if Decl_Item /= Empty_Node then
1202 Process_Declarative_Items
1203 (Project => Project,
1204 From_Project_Node => From_Project_Node,
1212 -- Should never happen
1214 Write_Line ("Illegal declarative item: " &
1215 Project_Node_Kind'Image (Kind_Of (Current_Item)));
1216 raise Program_Error;
1219 end Process_Declarative_Items;
1221 ---------------------
1222 -- Recursive_Check --
1223 ---------------------
1225 procedure Recursive_Check (Project : Project_Id) is
1226 Data : Project_Data;
1227 Imported_Project_List : Project_List := Empty_Project_List;
1230 -- Do nothing if Project is No_Project, or Project has already
1231 -- been marked as checked.
1233 if Project /= No_Project
1234 and then not Projects.Table (Project).Checked
1236 Data := Projects.Table (Project);
1238 -- Call itself for a possible modified project.
1239 -- (if there is no modified project, then nothing happens).
1241 Recursive_Check (Data.Modifies);
1243 -- Call itself for all imported projects
1245 Imported_Project_List := Data.Imported_Projects;
1246 while Imported_Project_List /= Empty_Project_List loop
1248 (Project_Lists.Table (Imported_Project_List).Project);
1249 Imported_Project_List :=
1250 Project_Lists.Table (Imported_Project_List).Next;
1253 -- Mark project as checked
1255 Projects.Table (Project).Checked := True;
1257 if Opt.Verbose_Mode then
1258 Write_Str ("Checking project file """);
1259 Write_Str (Get_Name_String (Data.Name));
1263 Prj.Nmsc.Check_Naming_Scheme (Project, Error_Report);
1266 end Recursive_Check;
1268 -----------------------
1269 -- Recursive_Process --
1270 -----------------------
1272 procedure Recursive_Process
1273 (Project : out Project_Id;
1274 From_Project_Node : Project_Node_Id;
1275 Modified_By : Project_Id)
1277 With_Clause : Project_Node_Id;
1280 if From_Project_Node = Empty_Node then
1281 Project := No_Project;
1285 Processed_Data : Project_Data := Empty_Project;
1286 Imported : Project_List := Empty_Project_List;
1287 Declaration_Node : Project_Node_Id := Empty_Node;
1288 Name : constant Name_Id :=
1289 Name_Of (From_Project_Node);
1292 Project := Processed_Projects.Get (Name);
1294 if Project /= No_Project then
1298 Projects.Increment_Last;
1299 Project := Projects.Last;
1300 Processed_Projects.Set (Name, Project);
1301 Processed_Data.Name := Name;
1302 Processed_Data.Path_Name := Path_Name_Of (From_Project_Node);
1303 Processed_Data.Location := Location_Of (From_Project_Node);
1304 Processed_Data.Directory := Directory_Of (From_Project_Node);
1305 Processed_Data.Modified_By := Modified_By;
1306 Add_Attributes (Processed_Data.Decl, Attribute_First);
1307 With_Clause := First_With_Clause_Of (From_Project_Node);
1309 while With_Clause /= Empty_Node loop
1311 New_Project : Project_Id;
1312 New_Data : Project_Data;
1316 (Project => New_Project,
1317 From_Project_Node => Project_Node_Of (With_Clause),
1318 Modified_By => No_Project);
1319 New_Data := Projects.Table (New_Project);
1321 -- If we were the first project to import it,
1322 -- set First_Referred_By to us.
1324 if New_Data.First_Referred_By = No_Project then
1325 New_Data.First_Referred_By := Project;
1326 Projects.Table (New_Project) := New_Data;
1329 -- Add this project to our list of imported projects
1331 Project_Lists.Increment_Last;
1332 Project_Lists.Table (Project_Lists.Last) :=
1333 (Project => New_Project, Next => Empty_Project_List);
1335 -- Imported is the id of the last imported project.
1336 -- If it is nil, then this imported project is our first.
1338 if Imported = Empty_Project_List then
1339 Processed_Data.Imported_Projects := Project_Lists.Last;
1342 Project_Lists.Table (Imported).Next := Project_Lists.Last;
1345 Imported := Project_Lists.Last;
1347 With_Clause := Next_With_Clause_Of (With_Clause);
1351 Declaration_Node := Project_Declaration_Of (From_Project_Node);
1354 (Project => Processed_Data.Modifies,
1355 From_Project_Node => Modified_Project_Of (Declaration_Node),
1356 Modified_By => Project);
1358 Projects.Table (Project) := Processed_Data;
1360 Process_Declarative_Items
1361 (Project => Project,
1362 From_Project_Node => From_Project_Node,
1364 Item => First_Declarative_Item_Of
1365 (Declaration_Node));
1369 end Recursive_Process;