1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2003 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 package body Prj.Tree is
29 use Tree_Private_Part;
31 --------------------------------
32 -- Associative_Array_Index_Of --
33 --------------------------------
35 function Associative_Array_Index_Of
36 (Node : Project_Node_Id)
43 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
45 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
46 return Project_Nodes.Table (Node).Value;
47 end Associative_Array_Index_Of;
49 ----------------------------
50 -- Associative_Package_Of --
51 ----------------------------
53 function Associative_Package_Of
54 (Node : Project_Node_Id)
55 return Project_Node_Id
61 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
62 return Project_Nodes.Table (Node).Field3;
63 end Associative_Package_Of;
65 ----------------------------
66 -- Associative_Project_Of --
67 ----------------------------
69 function Associative_Project_Of
70 (Node : Project_Node_Id)
71 return Project_Node_Id
77 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
78 return Project_Nodes.Table (Node).Field2;
79 end Associative_Project_Of;
81 ----------------------
82 -- Case_Insensitive --
83 ----------------------
85 function Case_Insensitive (Node : Project_Node_Id) return Boolean is
90 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
92 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
93 return Project_Nodes.Table (Node).Case_Insensitive;
96 --------------------------------
97 -- Case_Variable_Reference_Of --
98 --------------------------------
100 function Case_Variable_Reference_Of
101 (Node : Project_Node_Id)
102 return Project_Node_Id
108 Project_Nodes.Table (Node).Kind = N_Case_Construction);
109 return Project_Nodes.Table (Node).Field1;
110 end Case_Variable_Reference_Of;
112 -----------------------
113 -- Current_Item_Node --
114 -----------------------
116 function Current_Item_Node
117 (Node : Project_Node_Id)
118 return Project_Node_Id
124 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
125 return Project_Nodes.Table (Node).Field1;
126 end Current_Item_Node;
132 function Current_Term
133 (Node : Project_Node_Id)
134 return Project_Node_Id
140 Project_Nodes.Table (Node).Kind = N_Term);
141 return Project_Nodes.Table (Node).Field1;
144 --------------------------
145 -- Default_Project_Node --
146 --------------------------
148 function Default_Project_Node
149 (Of_Kind : Project_Node_Kind;
150 And_Expr_Kind : Variable_Kind := Undefined)
151 return Project_Node_Id
154 Project_Nodes.Increment_Last;
155 Project_Nodes.Table (Project_Nodes.Last) :=
157 Location => No_Location,
158 Directory => No_Name,
159 Expr_Kind => And_Expr_Kind,
160 Variables => Empty_Node,
161 Packages => Empty_Node,
162 Pkg_Id => Empty_Package,
164 Path_Name => No_Name,
166 Field1 => Empty_Node,
167 Field2 => Empty_Node,
168 Field3 => Empty_Node,
169 Case_Insensitive => False,
170 Extending_All => False);
171 return Project_Nodes.Last;
172 end Default_Project_Node;
178 function Directory_Of (Node : Project_Node_Id) return Name_Id is
183 Project_Nodes.Table (Node).Kind = N_Project);
184 return Project_Nodes.Table (Node).Directory;
187 ------------------------
188 -- Expression_Kind_Of --
189 ------------------------
191 function Expression_Kind_Of (Node : Project_Node_Id) return Variable_Kind is
196 (Project_Nodes.Table (Node).Kind = N_Literal_String
198 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
200 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
202 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
204 Project_Nodes.Table (Node).Kind = N_Package_Declaration
206 Project_Nodes.Table (Node).Kind = N_Expression
208 Project_Nodes.Table (Node).Kind = N_Term
210 Project_Nodes.Table (Node).Kind = N_Variable_Reference
212 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
214 return Project_Nodes.Table (Node).Expr_Kind;
215 end Expression_Kind_Of;
221 function Expression_Of
222 (Node : Project_Node_Id)
223 return Project_Node_Id
229 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
231 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
233 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
235 return Project_Nodes.Table (Node).Field1;
238 -------------------------
239 -- Extended_Project_Of --
240 -------------------------
242 function Extended_Project_Of
243 (Node : Project_Node_Id)
244 return Project_Node_Id
250 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
251 return Project_Nodes.Table (Node).Field2;
252 end Extended_Project_Of;
254 ------------------------------
255 -- Extended_Project_Path_Of --
256 ------------------------------
258 function Extended_Project_Path_Of
259 (Node : Project_Node_Id)
266 Project_Nodes.Table (Node).Kind = N_Project);
267 return Project_Nodes.Table (Node).Value;
268 end Extended_Project_Path_Of;
270 --------------------------
271 -- Extending_Project_Of --
272 --------------------------
273 function Extending_Project_Of
274 (Node : Project_Node_Id)
275 return Project_Node_Id
281 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
282 return Project_Nodes.Table (Node).Field3;
283 end Extending_Project_Of;
285 ---------------------------
286 -- External_Reference_Of --
287 ---------------------------
289 function External_Reference_Of
290 (Node : Project_Node_Id)
291 return Project_Node_Id
297 Project_Nodes.Table (Node).Kind = N_External_Value);
298 return Project_Nodes.Table (Node).Field1;
299 end External_Reference_Of;
301 -------------------------
302 -- External_Default_Of --
303 -------------------------
305 function External_Default_Of
306 (Node : Project_Node_Id)
307 return Project_Node_Id
313 Project_Nodes.Table (Node).Kind = N_External_Value);
314 return Project_Nodes.Table (Node).Field2;
315 end External_Default_Of;
317 ------------------------
318 -- First_Case_Item_Of --
319 ------------------------
321 function First_Case_Item_Of
322 (Node : Project_Node_Id)
323 return Project_Node_Id
329 Project_Nodes.Table (Node).Kind = N_Case_Construction);
330 return Project_Nodes.Table (Node).Field2;
331 end First_Case_Item_Of;
333 ---------------------
334 -- First_Choice_Of --
335 ---------------------
337 function First_Choice_Of
338 (Node : Project_Node_Id)
339 return Project_Node_Id
345 Project_Nodes.Table (Node).Kind = N_Case_Item);
346 return Project_Nodes.Table (Node).Field1;
349 -------------------------------
350 -- First_Declarative_Item_Of --
351 -------------------------------
353 function First_Declarative_Item_Of
354 (Node : Project_Node_Id)
355 return Project_Node_Id
361 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
363 Project_Nodes.Table (Node).Kind = N_Case_Item
365 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
367 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
368 return Project_Nodes.Table (Node).Field1;
370 return Project_Nodes.Table (Node).Field2;
372 end First_Declarative_Item_Of;
374 ------------------------------
375 -- First_Expression_In_List --
376 ------------------------------
378 function First_Expression_In_List
379 (Node : Project_Node_Id)
380 return Project_Node_Id
386 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
387 return Project_Nodes.Table (Node).Field1;
388 end First_Expression_In_List;
390 --------------------------
391 -- First_Literal_String --
392 --------------------------
394 function First_Literal_String
395 (Node : Project_Node_Id)
396 return Project_Node_Id
402 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
403 return Project_Nodes.Table (Node).Field1;
404 end First_Literal_String;
406 ----------------------
407 -- First_Package_Of --
408 ----------------------
410 function First_Package_Of
411 (Node : Project_Node_Id)
412 return Package_Declaration_Id
418 Project_Nodes.Table (Node).Kind = N_Project);
419 return Project_Nodes.Table (Node).Packages;
420 end First_Package_Of;
422 --------------------------
423 -- First_String_Type_Of --
424 --------------------------
426 function First_String_Type_Of
427 (Node : Project_Node_Id)
428 return Project_Node_Id
434 Project_Nodes.Table (Node).Kind = N_Project);
435 return Project_Nodes.Table (Node).Field3;
436 end First_String_Type_Of;
443 (Node : Project_Node_Id)
444 return Project_Node_Id
450 Project_Nodes.Table (Node).Kind = N_Expression);
451 return Project_Nodes.Table (Node).Field1;
454 -----------------------
455 -- First_Variable_Of --
456 -----------------------
458 function First_Variable_Of
459 (Node : Project_Node_Id)
460 return Variable_Node_Id
466 (Project_Nodes.Table (Node).Kind = N_Project
468 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
470 return Project_Nodes.Table (Node).Variables;
471 end First_Variable_Of;
473 --------------------------
474 -- First_With_Clause_Of --
475 --------------------------
477 function First_With_Clause_Of
478 (Node : Project_Node_Id)
479 return Project_Node_Id
485 Project_Nodes.Table (Node).Kind = N_Project);
486 return Project_Nodes.Table (Node).Field1;
487 end First_With_Clause_Of;
489 ----------------------
490 -- Is_Extending_All --
491 ----------------------
493 function Is_Extending_All (Node : Project_Node_Id) return Boolean is
498 Project_Nodes.Table (Node).Kind = N_Project);
499 return Project_Nodes.Table (Node).Extending_All;
500 end Is_Extending_All;
506 function Hash (N : Project_Node_Id) return Header_Num is
508 return Header_Num (N mod Project_Node_Id (Header_Num'Last));
511 -------------------------------------
512 -- Imported_Or_Extended_Project_Of --
513 -------------------------------------
515 function Imported_Or_Extended_Project_Of
516 (Project : Project_Node_Id;
518 return Project_Node_Id
520 With_Clause : Project_Node_Id := First_With_Clause_Of (Project);
521 Result : Project_Node_Id := Empty_Node;
524 -- First check all the imported projects
526 while With_Clause /= Empty_Node loop
528 -- Only non limited imported project may be used as prefix
529 -- of variable or attributes.
531 Result := Non_Limited_Project_Node_Of (With_Clause);
532 exit when Result /= Empty_Node and then Name_Of (Result) = With_Name;
533 With_Clause := Next_With_Clause_Of (With_Clause);
536 -- If it is not an imported project, it might be the imported project
538 if With_Clause = Empty_Node then
539 Result := Extended_Project_Of (Project_Declaration_Of (Project));
541 if Result /= Empty_Node
542 and then Name_Of (Result) /= With_Name
544 Result := Empty_Node;
549 end Imported_Or_Extended_Project_Of;
555 procedure Initialize is
557 Project_Nodes.Set_Last (Empty_Node);
558 Projects_Htable.Reset;
565 function Kind_Of (Node : Project_Node_Id) return Project_Node_Kind is
567 pragma Assert (Node /= Empty_Node);
568 return Project_Nodes.Table (Node).Kind;
575 function Location_Of (Node : Project_Node_Id) return Source_Ptr is
577 pragma Assert (Node /= Empty_Node);
578 return Project_Nodes.Table (Node).Location;
585 function Name_Of (Node : Project_Node_Id) return Name_Id is
587 pragma Assert (Node /= Empty_Node);
588 return Project_Nodes.Table (Node).Name;
595 function Next_Case_Item
596 (Node : Project_Node_Id)
597 return Project_Node_Id
603 Project_Nodes.Table (Node).Kind = N_Case_Item);
604 return Project_Nodes.Table (Node).Field3;
607 ---------------------------
608 -- Next_Declarative_Item --
609 ---------------------------
611 function Next_Declarative_Item
612 (Node : Project_Node_Id)
613 return Project_Node_Id
619 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
620 return Project_Nodes.Table (Node).Field2;
621 end Next_Declarative_Item;
623 -----------------------------
624 -- Next_Expression_In_List --
625 -----------------------------
627 function Next_Expression_In_List
628 (Node : Project_Node_Id)
629 return Project_Node_Id
635 Project_Nodes.Table (Node).Kind = N_Expression);
636 return Project_Nodes.Table (Node).Field2;
637 end Next_Expression_In_List;
639 -------------------------
640 -- Next_Literal_String --
641 -------------------------
643 function Next_Literal_String
644 (Node : Project_Node_Id)
645 return Project_Node_Id
651 Project_Nodes.Table (Node).Kind = N_Literal_String);
652 return Project_Nodes.Table (Node).Field1;
653 end Next_Literal_String;
655 -----------------------------
656 -- Next_Package_In_Project --
657 -----------------------------
659 function Next_Package_In_Project
660 (Node : Project_Node_Id)
661 return Project_Node_Id
667 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
668 return Project_Nodes.Table (Node).Field3;
669 end Next_Package_In_Project;
671 ----------------------
672 -- Next_String_Type --
673 ----------------------
675 function Next_String_Type
676 (Node : Project_Node_Id)
677 return Project_Node_Id
683 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
684 return Project_Nodes.Table (Node).Field2;
685 end Next_String_Type;
692 (Node : Project_Node_Id)
693 return Project_Node_Id
699 Project_Nodes.Table (Node).Kind = N_Term);
700 return Project_Nodes.Table (Node).Field2;
707 function Next_Variable
708 (Node : Project_Node_Id)
709 return Project_Node_Id
715 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
717 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
719 return Project_Nodes.Table (Node).Field3;
722 -------------------------
723 -- Next_With_Clause_Of --
724 -------------------------
726 function Next_With_Clause_Of
727 (Node : Project_Node_Id)
728 return Project_Node_Id
734 Project_Nodes.Table (Node).Kind = N_With_Clause);
735 return Project_Nodes.Table (Node).Field2;
736 end Next_With_Clause_Of;
738 ---------------------------------
739 -- Non_Limited_Project_Node_Of --
740 ---------------------------------
742 function Non_Limited_Project_Node_Of
743 (Node : Project_Node_Id)
744 return Project_Node_Id
750 (Project_Nodes.Table (Node).Kind = N_With_Clause));
751 return Project_Nodes.Table (Node).Field3;
752 end Non_Limited_Project_Node_Of;
757 function Package_Id_Of (Node : Project_Node_Id) return Package_Node_Id is
762 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
763 return Project_Nodes.Table (Node).Pkg_Id;
766 ---------------------
767 -- Package_Node_Of --
768 ---------------------
770 function Package_Node_Of
771 (Node : Project_Node_Id)
772 return Project_Node_Id
778 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
780 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
781 return Project_Nodes.Table (Node).Field2;
788 function Path_Name_Of (Node : Project_Node_Id) return Name_Id is
793 (Project_Nodes.Table (Node).Kind = N_Project
795 Project_Nodes.Table (Node).Kind = N_With_Clause));
796 return Project_Nodes.Table (Node).Path_Name;
799 ----------------------------
800 -- Project_Declaration_Of --
801 ----------------------------
803 function Project_Declaration_Of
804 (Node : Project_Node_Id)
805 return Project_Node_Id
811 Project_Nodes.Table (Node).Kind = N_Project);
812 return Project_Nodes.Table (Node).Field2;
813 end Project_Declaration_Of;
815 ---------------------
816 -- Project_Node_Of --
817 ---------------------
819 function Project_Node_Of
820 (Node : Project_Node_Id)
821 return Project_Node_Id
827 (Project_Nodes.Table (Node).Kind = N_With_Clause
829 Project_Nodes.Table (Node).Kind = N_Variable_Reference
831 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
832 return Project_Nodes.Table (Node).Field1;
835 -----------------------------------
836 -- Project_Of_Renamed_Package_Of --
837 -----------------------------------
839 function Project_Of_Renamed_Package_Of
840 (Node : Project_Node_Id)
841 return Project_Node_Id
847 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
848 return Project_Nodes.Table (Node).Field1;
849 end Project_Of_Renamed_Package_Of;
851 ------------------------------------
852 -- Set_Associative_Array_Index_Of --
853 ------------------------------------
855 procedure Set_Associative_Array_Index_Of
856 (Node : Project_Node_Id;
863 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
865 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
866 Project_Nodes.Table (Node).Value := To;
867 end Set_Associative_Array_Index_Of;
869 --------------------------------
870 -- Set_Associative_Package_Of --
871 --------------------------------
873 procedure Set_Associative_Package_Of
874 (Node : Project_Node_Id;
875 To : Project_Node_Id)
881 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration);
882 Project_Nodes.Table (Node).Field3 := To;
883 end Set_Associative_Package_Of;
885 --------------------------------
886 -- Set_Associative_Project_Of --
887 --------------------------------
889 procedure Set_Associative_Project_Of
890 (Node : Project_Node_Id;
891 To : Project_Node_Id)
897 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
898 Project_Nodes.Table (Node).Field2 := To;
899 end Set_Associative_Project_Of;
901 --------------------------
902 -- Set_Case_Insensitive --
903 --------------------------
905 procedure Set_Case_Insensitive
906 (Node : Project_Node_Id;
913 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
915 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
916 Project_Nodes.Table (Node).Case_Insensitive := To;
917 end Set_Case_Insensitive;
919 ------------------------------------
920 -- Set_Case_Variable_Reference_Of --
921 ------------------------------------
923 procedure Set_Case_Variable_Reference_Of
924 (Node : Project_Node_Id;
925 To : Project_Node_Id)
931 Project_Nodes.Table (Node).Kind = N_Case_Construction);
932 Project_Nodes.Table (Node).Field1 := To;
933 end Set_Case_Variable_Reference_Of;
935 ---------------------------
936 -- Set_Current_Item_Node --
937 ---------------------------
939 procedure Set_Current_Item_Node
940 (Node : Project_Node_Id;
941 To : Project_Node_Id)
947 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
948 Project_Nodes.Table (Node).Field1 := To;
949 end Set_Current_Item_Node;
951 ----------------------
952 -- Set_Current_Term --
953 ----------------------
955 procedure Set_Current_Term
956 (Node : Project_Node_Id;
957 To : Project_Node_Id)
963 Project_Nodes.Table (Node).Kind = N_Term);
964 Project_Nodes.Table (Node).Field1 := To;
965 end Set_Current_Term;
967 ----------------------
968 -- Set_Directory_Of --
969 ----------------------
971 procedure Set_Directory_Of
972 (Node : Project_Node_Id;
979 Project_Nodes.Table (Node).Kind = N_Project);
980 Project_Nodes.Table (Node).Directory := To;
981 end Set_Directory_Of;
983 ----------------------------
984 -- Set_Expression_Kind_Of --
985 ----------------------------
987 procedure Set_Expression_Kind_Of
988 (Node : Project_Node_Id;
995 (Project_Nodes.Table (Node).Kind = N_Literal_String
997 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
999 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
1001 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1003 Project_Nodes.Table (Node).Kind = N_Package_Declaration
1005 Project_Nodes.Table (Node).Kind = N_Expression
1007 Project_Nodes.Table (Node).Kind = N_Term
1009 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1011 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1012 Project_Nodes.Table (Node).Expr_Kind := To;
1013 end Set_Expression_Kind_Of;
1015 -----------------------
1016 -- Set_Expression_Of --
1017 -----------------------
1019 procedure Set_Expression_Of
1020 (Node : Project_Node_Id;
1021 To : Project_Node_Id)
1027 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1029 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1031 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1032 Project_Nodes.Table (Node).Field1 := To;
1033 end Set_Expression_Of;
1035 -------------------------------
1036 -- Set_External_Reference_Of --
1037 -------------------------------
1039 procedure Set_External_Reference_Of
1040 (Node : Project_Node_Id;
1041 To : Project_Node_Id)
1047 Project_Nodes.Table (Node).Kind = N_External_Value);
1048 Project_Nodes.Table (Node).Field1 := To;
1049 end Set_External_Reference_Of;
1051 -----------------------------
1052 -- Set_External_Default_Of --
1053 -----------------------------
1055 procedure Set_External_Default_Of
1056 (Node : Project_Node_Id;
1057 To : Project_Node_Id)
1063 Project_Nodes.Table (Node).Kind = N_External_Value);
1064 Project_Nodes.Table (Node).Field2 := To;
1065 end Set_External_Default_Of;
1067 ----------------------------
1068 -- Set_First_Case_Item_Of --
1069 ----------------------------
1071 procedure Set_First_Case_Item_Of
1072 (Node : Project_Node_Id;
1073 To : Project_Node_Id)
1079 Project_Nodes.Table (Node).Kind = N_Case_Construction);
1080 Project_Nodes.Table (Node).Field2 := To;
1081 end Set_First_Case_Item_Of;
1083 -------------------------
1084 -- Set_First_Choice_Of --
1085 -------------------------
1087 procedure Set_First_Choice_Of
1088 (Node : Project_Node_Id;
1089 To : Project_Node_Id)
1095 Project_Nodes.Table (Node).Kind = N_Case_Item);
1096 Project_Nodes.Table (Node).Field1 := To;
1097 end Set_First_Choice_Of;
1099 ------------------------
1100 -- Set_Next_Case_Item --
1101 ------------------------
1103 procedure Set_Next_Case_Item
1104 (Node : Project_Node_Id;
1105 To : Project_Node_Id)
1111 Project_Nodes.Table (Node).Kind = N_Case_Item);
1112 Project_Nodes.Table (Node).Field3 := To;
1113 end Set_Next_Case_Item;
1115 -----------------------------------
1116 -- Set_First_Declarative_Item_Of --
1117 -----------------------------------
1119 procedure Set_First_Declarative_Item_Of
1120 (Node : Project_Node_Id;
1121 To : Project_Node_Id)
1127 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
1129 Project_Nodes.Table (Node).Kind = N_Case_Item
1131 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1133 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
1134 Project_Nodes.Table (Node).Field1 := To;
1136 Project_Nodes.Table (Node).Field2 := To;
1138 end Set_First_Declarative_Item_Of;
1140 ----------------------------------
1141 -- Set_First_Expression_In_List --
1142 ----------------------------------
1144 procedure Set_First_Expression_In_List
1145 (Node : Project_Node_Id;
1146 To : Project_Node_Id)
1152 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
1153 Project_Nodes.Table (Node).Field1 := To;
1154 end Set_First_Expression_In_List;
1156 ------------------------------
1157 -- Set_First_Literal_String --
1158 ------------------------------
1160 procedure Set_First_Literal_String
1161 (Node : Project_Node_Id;
1162 To : Project_Node_Id)
1168 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1169 Project_Nodes.Table (Node).Field1 := To;
1170 end Set_First_Literal_String;
1172 --------------------------
1173 -- Set_First_Package_Of --
1174 --------------------------
1176 procedure Set_First_Package_Of
1177 (Node : Project_Node_Id;
1178 To : Package_Declaration_Id)
1184 Project_Nodes.Table (Node).Kind = N_Project);
1185 Project_Nodes.Table (Node).Packages := To;
1186 end Set_First_Package_Of;
1188 ------------------------------
1189 -- Set_First_String_Type_Of --
1190 ------------------------------
1192 procedure Set_First_String_Type_Of
1193 (Node : Project_Node_Id;
1194 To : Project_Node_Id)
1200 Project_Nodes.Table (Node).Kind = N_Project);
1201 Project_Nodes.Table (Node).Field3 := To;
1202 end Set_First_String_Type_Of;
1204 --------------------
1205 -- Set_First_Term --
1206 --------------------
1208 procedure Set_First_Term
1209 (Node : Project_Node_Id;
1210 To : Project_Node_Id)
1216 Project_Nodes.Table (Node).Kind = N_Expression);
1217 Project_Nodes.Table (Node).Field1 := To;
1220 ---------------------------
1221 -- Set_First_Variable_Of --
1222 ---------------------------
1224 procedure Set_First_Variable_Of
1225 (Node : Project_Node_Id;
1226 To : Variable_Node_Id)
1232 (Project_Nodes.Table (Node).Kind = N_Project
1234 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1235 Project_Nodes.Table (Node).Variables := To;
1236 end Set_First_Variable_Of;
1238 ------------------------------
1239 -- Set_First_With_Clause_Of --
1240 ------------------------------
1242 procedure Set_First_With_Clause_Of
1243 (Node : Project_Node_Id;
1244 To : Project_Node_Id)
1250 Project_Nodes.Table (Node).Kind = N_Project);
1251 Project_Nodes.Table (Node).Field1 := To;
1252 end Set_First_With_Clause_Of;
1254 --------------------------
1255 -- Set_Is_Extending_All --
1256 --------------------------
1258 procedure Set_Is_Extending_All (Node : Project_Node_Id) is
1263 Project_Nodes.Table (Node).Kind = N_Project);
1264 Project_Nodes.Table (Node).Extending_All := True;
1265 end Set_Is_Extending_All;
1271 procedure Set_Kind_Of
1272 (Node : Project_Node_Id;
1273 To : Project_Node_Kind)
1276 pragma Assert (Node /= Empty_Node);
1277 Project_Nodes.Table (Node).Kind := To;
1280 ---------------------
1281 -- Set_Location_Of --
1282 ---------------------
1284 procedure Set_Location_Of
1285 (Node : Project_Node_Id;
1289 pragma Assert (Node /= Empty_Node);
1290 Project_Nodes.Table (Node).Location := To;
1291 end Set_Location_Of;
1293 -----------------------------
1294 -- Set_Extended_Project_Of --
1295 -----------------------------
1297 procedure Set_Extended_Project_Of
1298 (Node : Project_Node_Id;
1299 To : Project_Node_Id)
1305 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
1306 Project_Nodes.Table (Node).Field2 := To;
1307 end Set_Extended_Project_Of;
1309 ----------------------------------
1310 -- Set_Extended_Project_Path_Of --
1311 ----------------------------------
1313 procedure Set_Extended_Project_Path_Of
1314 (Node : Project_Node_Id;
1321 Project_Nodes.Table (Node).Kind = N_Project);
1322 Project_Nodes.Table (Node).Value := To;
1323 end Set_Extended_Project_Path_Of;
1325 ------------------------------
1326 -- Set_Extending_Project_Of --
1327 ------------------------------
1329 procedure Set_Extending_Project_Of
1330 (Node : Project_Node_Id;
1331 To : Project_Node_Id)
1337 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
1338 Project_Nodes.Table (Node).Field3 := To;
1339 end Set_Extending_Project_Of;
1345 procedure Set_Name_Of
1346 (Node : Project_Node_Id;
1350 pragma Assert (Node /= Empty_Node);
1351 Project_Nodes.Table (Node).Name := To;
1354 -------------------------------
1355 -- Set_Next_Declarative_Item --
1356 -------------------------------
1358 procedure Set_Next_Declarative_Item
1359 (Node : Project_Node_Id;
1360 To : Project_Node_Id)
1366 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
1367 Project_Nodes.Table (Node).Field2 := To;
1368 end Set_Next_Declarative_Item;
1370 ---------------------------------
1371 -- Set_Next_Expression_In_List --
1372 ---------------------------------
1374 procedure Set_Next_Expression_In_List
1375 (Node : Project_Node_Id;
1376 To : Project_Node_Id)
1382 Project_Nodes.Table (Node).Kind = N_Expression);
1383 Project_Nodes.Table (Node).Field2 := To;
1384 end Set_Next_Expression_In_List;
1386 -----------------------------
1387 -- Set_Next_Literal_String --
1388 -----------------------------
1390 procedure Set_Next_Literal_String
1391 (Node : Project_Node_Id;
1392 To : Project_Node_Id)
1398 Project_Nodes.Table (Node).Kind = N_Literal_String);
1399 Project_Nodes.Table (Node).Field1 := To;
1400 end Set_Next_Literal_String;
1402 ---------------------------------
1403 -- Set_Next_Package_In_Project --
1404 ---------------------------------
1406 procedure Set_Next_Package_In_Project
1407 (Node : Project_Node_Id;
1408 To : Project_Node_Id)
1414 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1415 Project_Nodes.Table (Node).Field3 := To;
1416 end Set_Next_Package_In_Project;
1418 --------------------------
1419 -- Set_Next_String_Type --
1420 --------------------------
1422 procedure Set_Next_String_Type
1423 (Node : Project_Node_Id;
1424 To : Project_Node_Id)
1430 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1431 Project_Nodes.Table (Node).Field2 := To;
1432 end Set_Next_String_Type;
1438 procedure Set_Next_Term
1439 (Node : Project_Node_Id;
1440 To : Project_Node_Id)
1446 Project_Nodes.Table (Node).Kind = N_Term);
1447 Project_Nodes.Table (Node).Field2 := To;
1450 -----------------------
1451 -- Set_Next_Variable --
1452 -----------------------
1454 procedure Set_Next_Variable
1455 (Node : Project_Node_Id;
1456 To : Project_Node_Id)
1462 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1464 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1465 Project_Nodes.Table (Node).Field3 := To;
1466 end Set_Next_Variable;
1468 -----------------------------
1469 -- Set_Next_With_Clause_Of --
1470 -----------------------------
1472 procedure Set_Next_With_Clause_Of
1473 (Node : Project_Node_Id;
1474 To : Project_Node_Id)
1480 Project_Nodes.Table (Node).Kind = N_With_Clause);
1481 Project_Nodes.Table (Node).Field2 := To;
1482 end Set_Next_With_Clause_Of;
1484 -----------------------
1485 -- Set_Package_Id_Of --
1486 -----------------------
1488 procedure Set_Package_Id_Of
1489 (Node : Project_Node_Id;
1490 To : Package_Node_Id)
1496 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1497 Project_Nodes.Table (Node).Pkg_Id := To;
1498 end Set_Package_Id_Of;
1500 -------------------------
1501 -- Set_Package_Node_Of --
1502 -------------------------
1504 procedure Set_Package_Node_Of
1505 (Node : Project_Node_Id;
1506 To : Project_Node_Id)
1512 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1514 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1515 Project_Nodes.Table (Node).Field2 := To;
1516 end Set_Package_Node_Of;
1518 ----------------------
1519 -- Set_Path_Name_Of --
1520 ----------------------
1522 procedure Set_Path_Name_Of
1523 (Node : Project_Node_Id;
1530 (Project_Nodes.Table (Node).Kind = N_Project
1532 Project_Nodes.Table (Node).Kind = N_With_Clause));
1533 Project_Nodes.Table (Node).Path_Name := To;
1534 end Set_Path_Name_Of;
1536 --------------------------------
1537 -- Set_Project_Declaration_Of --
1538 --------------------------------
1540 procedure Set_Project_Declaration_Of
1541 (Node : Project_Node_Id;
1542 To : Project_Node_Id)
1548 Project_Nodes.Table (Node).Kind = N_Project);
1549 Project_Nodes.Table (Node).Field2 := To;
1550 end Set_Project_Declaration_Of;
1552 -------------------------
1553 -- Set_Project_Node_Of --
1554 -------------------------
1556 procedure Set_Project_Node_Of
1557 (Node : Project_Node_Id;
1558 To : Project_Node_Id;
1559 Limited_With : Boolean := False)
1565 (Project_Nodes.Table (Node).Kind = N_With_Clause
1567 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1569 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1570 Project_Nodes.Table (Node).Field1 := To;
1572 if Project_Nodes.Table (Node).Kind = N_With_Clause
1573 and then not Limited_With
1575 Project_Nodes.Table (Node).Field3 := To;
1577 end Set_Project_Node_Of;
1579 ---------------------------------------
1580 -- Set_Project_Of_Renamed_Package_Of --
1581 ---------------------------------------
1583 procedure Set_Project_Of_Renamed_Package_Of
1584 (Node : Project_Node_Id;
1585 To : Project_Node_Id)
1591 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1592 Project_Nodes.Table (Node).Field1 := To;
1593 end Set_Project_Of_Renamed_Package_Of;
1595 ------------------------
1596 -- Set_String_Type_Of --
1597 ------------------------
1599 procedure Set_String_Type_Of
1600 (Node : Project_Node_Id;
1601 To : Project_Node_Id)
1607 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1609 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration)
1611 Project_Nodes.Table (To).Kind = N_String_Type_Declaration);
1613 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
1614 Project_Nodes.Table (Node).Field3 := To;
1616 Project_Nodes.Table (Node).Field2 := To;
1618 end Set_String_Type_Of;
1620 -------------------------
1621 -- Set_String_Value_Of --
1622 -------------------------
1624 procedure Set_String_Value_Of
1625 (Node : Project_Node_Id;
1632 (Project_Nodes.Table (Node).Kind = N_With_Clause
1634 Project_Nodes.Table (Node).Kind = N_Literal_String));
1635 Project_Nodes.Table (Node).Value := To;
1636 end Set_String_Value_Of;
1638 --------------------
1639 -- String_Type_Of --
1640 --------------------
1642 function String_Type_Of (Node : Project_Node_Id)
1643 return Project_Node_Id is
1648 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1650 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration));
1652 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
1653 return Project_Nodes.Table (Node).Field3;
1655 return Project_Nodes.Table (Node).Field2;
1659 ---------------------
1660 -- String_Value_Of --
1661 ---------------------
1663 function String_Value_Of (Node : Project_Node_Id) return Name_Id is
1668 (Project_Nodes.Table (Node).Kind = N_With_Clause
1670 Project_Nodes.Table (Node).Kind = N_Literal_String));
1671 return Project_Nodes.Table (Node).Value;
1672 end String_Value_Of;
1674 --------------------
1675 -- Value_Is_Valid --
1676 --------------------
1678 function Value_Is_Valid
1679 (For_Typed_Variable : Project_Node_Id;
1685 (For_Typed_Variable /= Empty_Node
1687 (Project_Nodes.Table (For_Typed_Variable).Kind =
1688 N_Typed_Variable_Declaration));
1691 Current_String : Project_Node_Id :=
1692 First_Literal_String
1693 (String_Type_Of (For_Typed_Variable));
1696 while Current_String /= Empty_Node
1698 String_Value_Of (Current_String) /= Value
1701 Next_Literal_String (Current_String);
1704 return Current_String /= Empty_Node;