PR c++/3637
[official-gcc.git] / gcc / ada / prj-tree.adb
blob9f0df4851fd3747bd9a9e7698ad04a98b5ccc340
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J . T R E E --
6 -- --
7 -- B o d y --
8 -- --
9 -- $Revision$
10 -- --
11 -- Copyright (C) 2001 Free Software Foundation, Inc. --
12 -- --
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. --
23 -- --
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). --
26 -- --
27 ------------------------------------------------------------------------------
29 with Stringt; use Stringt;
31 package body Prj.Tree is
33 use Tree_Private_Part;
35 --------------------------------
36 -- Associative_Array_Index_Of --
37 --------------------------------
39 function Associative_Array_Index_Of
40 (Node : Project_Node_Id)
41 return String_Id
43 begin
44 pragma Assert
45 (Node /= Empty_Node
46 and then
47 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
48 return Project_Nodes.Table (Node).Value;
49 end Associative_Array_Index_Of;
51 ----------------------
52 -- Case_Insensitive --
53 ----------------------
55 function Case_Insensitive (Node : Project_Node_Id) return Boolean is
56 begin
57 pragma Assert
58 (Node /= Empty_Node
59 and then
60 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
61 return Project_Nodes.Table (Node).Case_Insensitive;
62 end Case_Insensitive;
64 --------------------------------
65 -- Case_Variable_Reference_Of --
66 --------------------------------
68 function Case_Variable_Reference_Of
69 (Node : Project_Node_Id)
70 return Project_Node_Id
72 begin
73 pragma Assert
74 (Node /= Empty_Node
75 and then
76 Project_Nodes.Table (Node).Kind = N_Case_Construction);
77 return Project_Nodes.Table (Node).Field1;
78 end Case_Variable_Reference_Of;
80 -----------------------
81 -- Current_Item_Node --
82 -----------------------
84 function Current_Item_Node
85 (Node : Project_Node_Id)
86 return Project_Node_Id
88 begin
89 pragma Assert
90 (Node /= Empty_Node
91 and then
92 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
93 return Project_Nodes.Table (Node).Field1;
94 end Current_Item_Node;
96 ------------------
97 -- Current_Term --
98 ------------------
100 function Current_Term
101 (Node : Project_Node_Id)
102 return Project_Node_Id
104 begin
105 pragma Assert
106 (Node /= Empty_Node
107 and then
108 Project_Nodes.Table (Node).Kind = N_Term);
109 return Project_Nodes.Table (Node).Field1;
110 end Current_Term;
112 --------------------------
113 -- Default_Project_Node --
114 --------------------------
116 function Default_Project_Node
117 (Of_Kind : Project_Node_Kind;
118 And_Expr_Kind : Variable_Kind := Undefined)
119 return Project_Node_Id
121 begin
122 Project_Nodes.Increment_Last;
123 Project_Nodes.Table (Project_Nodes.Last) :=
124 (Kind => Of_Kind,
125 Location => No_Location,
126 Directory => No_Name,
127 Expr_Kind => And_Expr_Kind,
128 Variables => Empty_Node,
129 Packages => Empty_Node,
130 Pkg_Id => Empty_Package,
131 Name => No_Name,
132 Path_Name => No_Name,
133 Value => No_String,
134 Field1 => Empty_Node,
135 Field2 => Empty_Node,
136 Field3 => Empty_Node,
137 Case_Insensitive => False);
138 return Project_Nodes.Last;
139 end Default_Project_Node;
141 ------------------
142 -- Directory_Of --
143 ------------------
145 function Directory_Of (Node : Project_Node_Id) return Name_Id is
146 begin
147 pragma Assert
148 (Node /= Empty_Node
149 and then
150 Project_Nodes.Table (Node).Kind = N_Project);
151 return Project_Nodes.Table (Node).Directory;
152 end Directory_Of;
154 ------------------------
155 -- Expression_Kind_Of --
156 ------------------------
158 function Expression_Kind_Of (Node : Project_Node_Id) return Variable_Kind is
159 begin
160 pragma Assert
161 (Node /= Empty_Node
162 and then
163 (Project_Nodes.Table (Node).Kind = N_Literal_String
164 or else
165 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
166 or else
167 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
168 or else
169 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
170 or else
171 Project_Nodes.Table (Node).Kind = N_Expression
172 or else
173 Project_Nodes.Table (Node).Kind = N_Term
174 or else
175 Project_Nodes.Table (Node).Kind = N_Variable_Reference
176 or else
177 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
179 return Project_Nodes.Table (Node).Expr_Kind;
180 end Expression_Kind_Of;
182 -------------------
183 -- Expression_Of --
184 -------------------
186 function Expression_Of
187 (Node : Project_Node_Id)
188 return Project_Node_Id
190 begin
191 pragma Assert
192 (Node /= Empty_Node
193 and then
194 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
195 or else
196 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
197 or else
198 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
200 return Project_Nodes.Table (Node).Field1;
201 end Expression_Of;
203 ---------------------------
204 -- External_Reference_Of --
205 ---------------------------
207 function External_Reference_Of
208 (Node : Project_Node_Id)
209 return Project_Node_Id
211 begin
212 pragma Assert
213 (Node /= Empty_Node
214 and then
215 Project_Nodes.Table (Node).Kind = N_External_Value);
216 return Project_Nodes.Table (Node).Field1;
217 end External_Reference_Of;
219 -------------------------
220 -- External_Default_Of --
221 -------------------------
223 function External_Default_Of
224 (Node : Project_Node_Id)
225 return Project_Node_Id
227 begin
228 pragma Assert
229 (Node /= Empty_Node
230 and then
231 Project_Nodes.Table (Node).Kind = N_External_Value);
232 return Project_Nodes.Table (Node).Field2;
233 end External_Default_Of;
235 ------------------------
236 -- First_Case_Item_Of --
237 ------------------------
239 function First_Case_Item_Of
240 (Node : Project_Node_Id)
241 return Project_Node_Id
243 begin
244 pragma Assert
245 (Node /= Empty_Node
246 and then
247 Project_Nodes.Table (Node).Kind = N_Case_Construction);
248 return Project_Nodes.Table (Node).Field2;
249 end First_Case_Item_Of;
251 ---------------------
252 -- First_Choice_Of --
253 ---------------------
255 function First_Choice_Of
256 (Node : Project_Node_Id)
257 return Project_Node_Id
259 begin
260 pragma Assert
261 (Node /= Empty_Node
262 and then
263 Project_Nodes.Table (Node).Kind = N_Case_Item);
264 return Project_Nodes.Table (Node).Field1;
265 end First_Choice_Of;
267 -------------------------------
268 -- First_Declarative_Item_Of --
269 -------------------------------
271 function First_Declarative_Item_Of
272 (Node : Project_Node_Id)
273 return Project_Node_Id
275 begin
276 pragma Assert
277 (Node /= Empty_Node
278 and then
279 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
280 or else
281 Project_Nodes.Table (Node).Kind = N_Case_Item
282 or else
283 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
285 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
286 return Project_Nodes.Table (Node).Field1;
287 else
288 return Project_Nodes.Table (Node).Field2;
289 end if;
290 end First_Declarative_Item_Of;
292 ------------------------------
293 -- First_Expression_In_List --
294 ------------------------------
296 function First_Expression_In_List
297 (Node : Project_Node_Id)
298 return Project_Node_Id
300 begin
301 pragma Assert
302 (Node /= Empty_Node
303 and then
304 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
305 return Project_Nodes.Table (Node).Field1;
306 end First_Expression_In_List;
308 --------------------------
309 -- First_Literal_String --
310 --------------------------
312 function First_Literal_String
313 (Node : Project_Node_Id)
314 return Project_Node_Id
316 begin
317 pragma Assert
318 (Node /= Empty_Node
319 and then
320 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
321 return Project_Nodes.Table (Node).Field1;
322 end First_Literal_String;
324 ----------------------
325 -- First_Package_Of --
326 ----------------------
328 function First_Package_Of
329 (Node : Project_Node_Id)
330 return Package_Declaration_Id
332 begin
333 pragma Assert
334 (Node /= Empty_Node
335 and then
336 Project_Nodes.Table (Node).Kind = N_Project);
337 return Project_Nodes.Table (Node).Packages;
338 end First_Package_Of;
340 --------------------------
341 -- First_String_Type_Of --
342 --------------------------
344 function First_String_Type_Of
345 (Node : Project_Node_Id)
346 return Project_Node_Id
348 begin
349 pragma Assert
350 (Node /= Empty_Node
351 and then
352 Project_Nodes.Table (Node).Kind = N_Project);
353 return Project_Nodes.Table (Node).Field3;
354 end First_String_Type_Of;
356 ----------------
357 -- First_Term --
358 ----------------
360 function First_Term
361 (Node : Project_Node_Id)
362 return Project_Node_Id
364 begin
365 pragma Assert
366 (Node /= Empty_Node
367 and then
368 Project_Nodes.Table (Node).Kind = N_Expression);
369 return Project_Nodes.Table (Node).Field1;
370 end First_Term;
372 -----------------------
373 -- First_Variable_Of --
374 -----------------------
376 function First_Variable_Of
377 (Node : Project_Node_Id)
378 return Variable_Node_Id
380 begin
381 pragma Assert
382 (Node /= Empty_Node
383 and then
384 (Project_Nodes.Table (Node).Kind = N_Project
385 or else
386 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
388 return Project_Nodes.Table (Node).Variables;
389 end First_Variable_Of;
391 --------------------------
392 -- First_With_Clause_Of --
393 --------------------------
395 function First_With_Clause_Of
396 (Node : Project_Node_Id)
397 return Project_Node_Id
399 begin
400 pragma Assert
401 (Node /= Empty_Node
402 and then
403 Project_Nodes.Table (Node).Kind = N_Project);
404 return Project_Nodes.Table (Node).Field1;
405 end First_With_Clause_Of;
407 ----------------
408 -- Initialize --
409 ----------------
411 procedure Initialize is
412 begin
413 Project_Nodes.Set_Last (Empty_Node);
414 Projects_Htable.Reset;
415 end Initialize;
417 -------------
418 -- Kind_Of --
419 -------------
421 function Kind_Of (Node : Project_Node_Id) return Project_Node_Kind is
422 begin
423 pragma Assert (Node /= Empty_Node);
424 return Project_Nodes.Table (Node).Kind;
425 end Kind_Of;
427 -----------------
428 -- Location_Of --
429 -----------------
431 function Location_Of (Node : Project_Node_Id) return Source_Ptr is
432 begin
433 pragma Assert (Node /= Empty_Node);
434 return Project_Nodes.Table (Node).Location;
435 end Location_Of;
437 -------------------------
438 -- Modified_Project_Of --
439 -------------------------
441 function Modified_Project_Of
442 (Node : Project_Node_Id)
443 return Project_Node_Id
445 begin
446 pragma Assert
447 (Node /= Empty_Node
448 and then
449 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
450 return Project_Nodes.Table (Node).Field2;
451 end Modified_Project_Of;
453 ------------------------------
454 -- Modified_Project_Path_Of --
455 ------------------------------
457 function Modified_Project_Path_Of
458 (Node : Project_Node_Id)
459 return String_Id
461 begin
462 pragma Assert
463 (Node /= Empty_Node
464 and then
465 Project_Nodes.Table (Node).Kind = N_Project);
466 return Project_Nodes.Table (Node).Value;
467 end Modified_Project_Path_Of;
469 -------------
470 -- Name_Of --
471 -------------
473 function Name_Of (Node : Project_Node_Id) return Name_Id is
474 begin
475 pragma Assert (Node /= Empty_Node);
476 return Project_Nodes.Table (Node).Name;
477 end Name_Of;
479 --------------------
480 -- Next_Case_Item --
481 --------------------
483 function Next_Case_Item
484 (Node : Project_Node_Id)
485 return Project_Node_Id
487 begin
488 pragma Assert
489 (Node /= Empty_Node
490 and then
491 Project_Nodes.Table (Node).Kind = N_Case_Item);
492 return Project_Nodes.Table (Node).Field3;
493 end Next_Case_Item;
495 ---------------------------
496 -- Next_Declarative_Item --
497 ---------------------------
499 function Next_Declarative_Item
500 (Node : Project_Node_Id)
501 return Project_Node_Id
503 begin
504 pragma Assert
505 (Node /= Empty_Node
506 and then
507 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
508 return Project_Nodes.Table (Node).Field2;
509 end Next_Declarative_Item;
511 -----------------------------
512 -- Next_Expression_In_List --
513 -----------------------------
515 function Next_Expression_In_List
516 (Node : Project_Node_Id)
517 return Project_Node_Id
519 begin
520 pragma Assert
521 (Node /= Empty_Node
522 and then
523 Project_Nodes.Table (Node).Kind = N_Expression);
524 return Project_Nodes.Table (Node).Field2;
525 end Next_Expression_In_List;
527 -------------------------
528 -- Next_Literal_String --
529 -------------------------
531 function Next_Literal_String
532 (Node : Project_Node_Id)
533 return Project_Node_Id
535 begin
536 pragma Assert
537 (Node /= Empty_Node
538 and then
539 Project_Nodes.Table (Node).Kind = N_Literal_String);
540 return Project_Nodes.Table (Node).Field1;
541 end Next_Literal_String;
543 -----------------------------
544 -- Next_Package_In_Project --
545 -----------------------------
547 function Next_Package_In_Project
548 (Node : Project_Node_Id)
549 return Project_Node_Id
551 begin
552 pragma Assert
553 (Node /= Empty_Node
554 and then
555 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
556 return Project_Nodes.Table (Node).Field3;
557 end Next_Package_In_Project;
559 ----------------------
560 -- Next_String_Type --
561 ----------------------
563 function Next_String_Type
564 (Node : Project_Node_Id)
565 return Project_Node_Id
567 begin
568 pragma Assert
569 (Node /= Empty_Node
570 and then
571 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
572 return Project_Nodes.Table (Node).Field2;
573 end Next_String_Type;
575 ---------------
576 -- Next_Term --
577 ---------------
579 function Next_Term
580 (Node : Project_Node_Id)
581 return Project_Node_Id
583 begin
584 pragma Assert
585 (Node /= Empty_Node
586 and then
587 Project_Nodes.Table (Node).Kind = N_Term);
588 return Project_Nodes.Table (Node).Field2;
589 end Next_Term;
591 -------------------
592 -- Next_Variable --
593 -------------------
595 function Next_Variable
596 (Node : Project_Node_Id)
597 return Project_Node_Id
599 begin
600 pragma Assert
601 (Node /= Empty_Node
602 and then
603 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
604 or else
605 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
607 return Project_Nodes.Table (Node).Field3;
608 end Next_Variable;
610 -------------------------
611 -- Next_With_Clause_Of --
612 -------------------------
614 function Next_With_Clause_Of
615 (Node : Project_Node_Id)
616 return Project_Node_Id
618 begin
619 pragma Assert
620 (Node /= Empty_Node
621 and then
622 Project_Nodes.Table (Node).Kind = N_With_Clause);
623 return Project_Nodes.Table (Node).Field2;
624 end Next_With_Clause_Of;
626 -------------------
627 -- Package_Id_Of --
628 -------------------
630 function Package_Id_Of (Node : Project_Node_Id) return Package_Node_Id is
631 begin
632 pragma Assert
633 (Node /= Empty_Node
634 and then
635 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
636 return Project_Nodes.Table (Node).Pkg_Id;
637 end Package_Id_Of;
639 ---------------------
640 -- Package_Node_Of --
641 ---------------------
643 function Package_Node_Of
644 (Node : Project_Node_Id)
645 return Project_Node_Id
647 begin
648 pragma Assert
649 (Node /= Empty_Node
650 and then
651 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
652 or else
653 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
654 return Project_Nodes.Table (Node).Field2;
655 end Package_Node_Of;
657 ------------------
658 -- Path_Name_Of --
659 ------------------
661 function Path_Name_Of (Node : Project_Node_Id) return Name_Id is
662 begin
663 pragma Assert
664 (Node /= Empty_Node
665 and then
666 (Project_Nodes.Table (Node).Kind = N_Project
667 or else
668 Project_Nodes.Table (Node).Kind = N_With_Clause));
669 return Project_Nodes.Table (Node).Path_Name;
670 end Path_Name_Of;
672 ----------------------------
673 -- Project_Declaration_Of --
674 ----------------------------
676 function Project_Declaration_Of
677 (Node : Project_Node_Id)
678 return Project_Node_Id
680 begin
681 pragma Assert
682 (Node /= Empty_Node
683 and then
684 Project_Nodes.Table (Node).Kind = N_Project);
685 return Project_Nodes.Table (Node).Field2;
686 end Project_Declaration_Of;
688 ---------------------
689 -- Project_Node_Of --
690 ---------------------
692 function Project_Node_Of
693 (Node : Project_Node_Id)
694 return Project_Node_Id
696 begin
697 pragma Assert
698 (Node /= Empty_Node
699 and then
700 (Project_Nodes.Table (Node).Kind = N_With_Clause
701 or else
702 Project_Nodes.Table (Node).Kind = N_Variable_Reference
703 or else
704 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
705 return Project_Nodes.Table (Node).Field1;
706 end Project_Node_Of;
708 -----------------------------------
709 -- Project_Of_Renamed_Package_Of --
710 -----------------------------------
712 function Project_Of_Renamed_Package_Of
713 (Node : Project_Node_Id)
714 return Project_Node_Id
716 begin
717 pragma Assert
718 (Node /= Empty_Node
719 and then
720 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
721 return Project_Nodes.Table (Node).Field1;
722 end Project_Of_Renamed_Package_Of;
724 ------------------------------------
725 -- Set_Associative_Array_Index_Of --
726 ------------------------------------
728 procedure Set_Associative_Array_Index_Of
729 (Node : Project_Node_Id;
730 To : String_Id)
732 begin
733 pragma Assert
734 (Node /= Empty_Node
735 and then
736 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration);
737 Project_Nodes.Table (Node).Value := To;
738 end Set_Associative_Array_Index_Of;
740 --------------------------
741 -- Set_Case_Insensitive --
742 --------------------------
744 procedure Set_Case_Insensitive
745 (Node : Project_Node_Id;
746 To : Boolean)
748 begin
749 pragma Assert
750 (Node /= Empty_Node
751 and then
752 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration);
753 Project_Nodes.Table (Node).Case_Insensitive := To;
754 end Set_Case_Insensitive;
756 ------------------------------------
757 -- Set_Case_Variable_Reference_Of --
758 ------------------------------------
760 procedure Set_Case_Variable_Reference_Of
761 (Node : Project_Node_Id;
762 To : Project_Node_Id)
764 begin
765 pragma Assert
766 (Node /= Empty_Node
767 and then
768 Project_Nodes.Table (Node).Kind = N_Case_Construction);
769 Project_Nodes.Table (Node).Field1 := To;
770 end Set_Case_Variable_Reference_Of;
772 ---------------------------
773 -- Set_Current_Item_Node --
774 ---------------------------
776 procedure Set_Current_Item_Node
777 (Node : Project_Node_Id;
778 To : Project_Node_Id)
780 begin
781 pragma Assert
782 (Node /= Empty_Node
783 and then
784 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
785 Project_Nodes.Table (Node).Field1 := To;
786 end Set_Current_Item_Node;
788 ----------------------
789 -- Set_Current_Term --
790 ----------------------
792 procedure Set_Current_Term
793 (Node : Project_Node_Id;
794 To : Project_Node_Id)
796 begin
797 pragma Assert
798 (Node /= Empty_Node
799 and then
800 Project_Nodes.Table (Node).Kind = N_Term);
801 Project_Nodes.Table (Node).Field1 := To;
802 end Set_Current_Term;
804 ----------------------
805 -- Set_Directory_Of --
806 ----------------------
808 procedure Set_Directory_Of
809 (Node : Project_Node_Id;
810 To : Name_Id)
812 begin
813 pragma Assert
814 (Node /= Empty_Node
815 and then
816 Project_Nodes.Table (Node).Kind = N_Project);
817 Project_Nodes.Table (Node).Directory := To;
818 end Set_Directory_Of;
820 ----------------------------
821 -- Set_Expression_Kind_Of --
822 ----------------------------
824 procedure Set_Expression_Kind_Of
825 (Node : Project_Node_Id;
826 To : Variable_Kind)
828 begin
829 pragma Assert
830 (Node /= Empty_Node
831 and then
832 (Project_Nodes.Table (Node).Kind = N_Literal_String
833 or else
834 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
835 or else
836 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
837 or else
838 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
839 or else
840 Project_Nodes.Table (Node).Kind = N_Expression
841 or else
842 Project_Nodes.Table (Node).Kind = N_Term
843 or else
844 Project_Nodes.Table (Node).Kind = N_Variable_Reference
845 or else
846 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
847 Project_Nodes.Table (Node).Expr_Kind := To;
848 end Set_Expression_Kind_Of;
850 -----------------------
851 -- Set_Expression_Of --
852 -----------------------
854 procedure Set_Expression_Of
855 (Node : Project_Node_Id;
856 To : Project_Node_Id)
858 begin
859 pragma Assert
860 (Node /= Empty_Node
861 and then
862 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
863 or else
864 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
865 or else
866 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
867 Project_Nodes.Table (Node).Field1 := To;
868 end Set_Expression_Of;
870 -------------------------------
871 -- Set_External_Reference_Of --
872 -------------------------------
874 procedure Set_External_Reference_Of
875 (Node : Project_Node_Id;
876 To : Project_Node_Id)
878 begin
879 pragma Assert
880 (Node /= Empty_Node
881 and then
882 Project_Nodes.Table (Node).Kind = N_External_Value);
883 Project_Nodes.Table (Node).Field1 := To;
884 end Set_External_Reference_Of;
886 -----------------------------
887 -- Set_External_Default_Of --
888 -----------------------------
890 procedure Set_External_Default_Of
891 (Node : Project_Node_Id;
892 To : Project_Node_Id)
894 begin
895 pragma Assert
896 (Node /= Empty_Node
897 and then
898 Project_Nodes.Table (Node).Kind = N_External_Value);
899 Project_Nodes.Table (Node).Field2 := To;
900 end Set_External_Default_Of;
902 ----------------------------
903 -- Set_First_Case_Item_Of --
904 ----------------------------
906 procedure Set_First_Case_Item_Of
907 (Node : Project_Node_Id;
908 To : Project_Node_Id)
910 begin
911 pragma Assert
912 (Node /= Empty_Node
913 and then
914 Project_Nodes.Table (Node).Kind = N_Case_Construction);
915 Project_Nodes.Table (Node).Field2 := To;
916 end Set_First_Case_Item_Of;
918 -------------------------
919 -- Set_First_Choice_Of --
920 -------------------------
922 procedure Set_First_Choice_Of
923 (Node : Project_Node_Id;
924 To : Project_Node_Id)
926 begin
927 pragma Assert
928 (Node /= Empty_Node
929 and then
930 Project_Nodes.Table (Node).Kind = N_Case_Item);
931 Project_Nodes.Table (Node).Field1 := To;
932 end Set_First_Choice_Of;
934 ------------------------
935 -- Set_Next_Case_Item --
936 ------------------------
938 procedure Set_Next_Case_Item
939 (Node : Project_Node_Id;
940 To : Project_Node_Id)
942 begin
943 pragma Assert
944 (Node /= Empty_Node
945 and then
946 Project_Nodes.Table (Node).Kind = N_Case_Item);
947 Project_Nodes.Table (Node).Field3 := To;
948 end Set_Next_Case_Item;
950 -----------------------------------
951 -- Set_First_Declarative_Item_Of --
952 -----------------------------------
954 procedure Set_First_Declarative_Item_Of
955 (Node : Project_Node_Id;
956 To : Project_Node_Id)
958 begin
959 pragma Assert
960 (Node /= Empty_Node
961 and then
962 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
963 or else
964 Project_Nodes.Table (Node).Kind = N_Case_Item
965 or else
966 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
968 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
969 Project_Nodes.Table (Node).Field1 := To;
970 else
971 Project_Nodes.Table (Node).Field2 := To;
972 end if;
973 end Set_First_Declarative_Item_Of;
975 ----------------------------------
976 -- Set_First_Expression_In_List --
977 ----------------------------------
979 procedure Set_First_Expression_In_List
980 (Node : Project_Node_Id;
981 To : Project_Node_Id)
983 begin
984 pragma Assert
985 (Node /= Empty_Node
986 and then
987 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
988 Project_Nodes.Table (Node).Field1 := To;
989 end Set_First_Expression_In_List;
991 ------------------------------
992 -- Set_First_Literal_String --
993 ------------------------------
995 procedure Set_First_Literal_String
996 (Node : Project_Node_Id;
997 To : Project_Node_Id)
999 begin
1000 pragma Assert
1001 (Node /= Empty_Node
1002 and then
1003 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1004 Project_Nodes.Table (Node).Field1 := To;
1005 end Set_First_Literal_String;
1007 --------------------------
1008 -- Set_First_Package_Of --
1009 --------------------------
1011 procedure Set_First_Package_Of
1012 (Node : Project_Node_Id;
1013 To : Package_Declaration_Id)
1015 begin
1016 pragma Assert
1017 (Node /= Empty_Node
1018 and then
1019 Project_Nodes.Table (Node).Kind = N_Project);
1020 Project_Nodes.Table (Node).Packages := To;
1021 end Set_First_Package_Of;
1023 ------------------------------
1024 -- Set_First_String_Type_Of --
1025 ------------------------------
1027 procedure Set_First_String_Type_Of
1028 (Node : Project_Node_Id;
1029 To : Project_Node_Id)
1031 begin
1032 pragma Assert
1033 (Node /= Empty_Node
1034 and then
1035 Project_Nodes.Table (Node).Kind = N_Project);
1036 Project_Nodes.Table (Node).Field3 := To;
1037 end Set_First_String_Type_Of;
1039 --------------------
1040 -- Set_First_Term --
1041 --------------------
1043 procedure Set_First_Term
1044 (Node : Project_Node_Id;
1045 To : Project_Node_Id)
1047 begin
1048 pragma Assert
1049 (Node /= Empty_Node
1050 and then
1051 Project_Nodes.Table (Node).Kind = N_Expression);
1052 Project_Nodes.Table (Node).Field1 := To;
1053 end Set_First_Term;
1055 ---------------------------
1056 -- Set_First_Variable_Of --
1057 ---------------------------
1059 procedure Set_First_Variable_Of
1060 (Node : Project_Node_Id;
1061 To : Variable_Node_Id)
1063 begin
1064 pragma Assert
1065 (Node /= Empty_Node
1066 and then
1067 (Project_Nodes.Table (Node).Kind = N_Project
1068 or else
1069 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1070 Project_Nodes.Table (Node).Variables := To;
1071 end Set_First_Variable_Of;
1073 ------------------------------
1074 -- Set_First_With_Clause_Of --
1075 ------------------------------
1077 procedure Set_First_With_Clause_Of
1078 (Node : Project_Node_Id;
1079 To : Project_Node_Id)
1081 begin
1082 pragma Assert
1083 (Node /= Empty_Node
1084 and then
1085 Project_Nodes.Table (Node).Kind = N_Project);
1086 Project_Nodes.Table (Node).Field1 := To;
1087 end Set_First_With_Clause_Of;
1089 -----------------
1090 -- Set_Kind_Of --
1091 -----------------
1093 procedure Set_Kind_Of
1094 (Node : Project_Node_Id;
1095 To : Project_Node_Kind)
1097 begin
1098 pragma Assert (Node /= Empty_Node);
1099 Project_Nodes.Table (Node).Kind := To;
1100 end Set_Kind_Of;
1102 ---------------------
1103 -- Set_Location_Of --
1104 ---------------------
1106 procedure Set_Location_Of
1107 (Node : Project_Node_Id;
1108 To : Source_Ptr)
1110 begin
1111 pragma Assert (Node /= Empty_Node);
1112 Project_Nodes.Table (Node).Location := To;
1113 end Set_Location_Of;
1115 -----------------------------
1116 -- Set_Modified_Project_Of --
1117 -----------------------------
1119 procedure Set_Modified_Project_Of
1120 (Node : Project_Node_Id;
1121 To : Project_Node_Id)
1123 begin
1124 pragma Assert
1125 (Node /= Empty_Node
1126 and then
1127 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
1128 Project_Nodes.Table (Node).Field2 := To;
1129 end Set_Modified_Project_Of;
1131 ----------------------------------
1132 -- Set_Modified_Project_Path_Of --
1133 ----------------------------------
1135 procedure Set_Modified_Project_Path_Of
1136 (Node : Project_Node_Id;
1137 To : String_Id)
1139 begin
1140 pragma Assert
1141 (Node /= Empty_Node
1142 and then
1143 Project_Nodes.Table (Node).Kind = N_Project);
1144 Project_Nodes.Table (Node).Value := To;
1145 end Set_Modified_Project_Path_Of;
1147 -----------------
1148 -- Set_Name_Of --
1149 -----------------
1151 procedure Set_Name_Of
1152 (Node : Project_Node_Id;
1153 To : Name_Id)
1155 begin
1156 pragma Assert (Node /= Empty_Node);
1157 Project_Nodes.Table (Node).Name := To;
1158 end Set_Name_Of;
1160 -------------------------------
1161 -- Set_Next_Declarative_Item --
1162 -------------------------------
1164 procedure Set_Next_Declarative_Item
1165 (Node : Project_Node_Id;
1166 To : Project_Node_Id)
1168 begin
1169 pragma Assert
1170 (Node /= Empty_Node
1171 and then
1172 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
1173 Project_Nodes.Table (Node).Field2 := To;
1174 end Set_Next_Declarative_Item;
1176 ---------------------------------
1177 -- Set_Next_Expression_In_List --
1178 ---------------------------------
1180 procedure Set_Next_Expression_In_List
1181 (Node : Project_Node_Id;
1182 To : Project_Node_Id)
1184 begin
1185 pragma Assert
1186 (Node /= Empty_Node
1187 and then
1188 Project_Nodes.Table (Node).Kind = N_Expression);
1189 Project_Nodes.Table (Node).Field2 := To;
1190 end Set_Next_Expression_In_List;
1192 -----------------------------
1193 -- Set_Next_Literal_String --
1194 -----------------------------
1196 procedure Set_Next_Literal_String
1197 (Node : Project_Node_Id;
1198 To : Project_Node_Id)
1200 begin
1201 pragma Assert
1202 (Node /= Empty_Node
1203 and then
1204 Project_Nodes.Table (Node).Kind = N_Literal_String);
1205 Project_Nodes.Table (Node).Field1 := To;
1206 end Set_Next_Literal_String;
1208 ---------------------------------
1209 -- Set_Next_Package_In_Project --
1210 ---------------------------------
1212 procedure Set_Next_Package_In_Project
1213 (Node : Project_Node_Id;
1214 To : Project_Node_Id)
1216 begin
1217 pragma Assert
1218 (Node /= Empty_Node
1219 and then
1220 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1221 Project_Nodes.Table (Node).Field3 := To;
1222 end Set_Next_Package_In_Project;
1224 --------------------------
1225 -- Set_Next_String_Type --
1226 --------------------------
1228 procedure Set_Next_String_Type
1229 (Node : Project_Node_Id;
1230 To : Project_Node_Id)
1232 begin
1233 pragma Assert
1234 (Node /= Empty_Node
1235 and then
1236 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1237 Project_Nodes.Table (Node).Field2 := To;
1238 end Set_Next_String_Type;
1240 -------------------
1241 -- Set_Next_Term --
1242 -------------------
1244 procedure Set_Next_Term
1245 (Node : Project_Node_Id;
1246 To : Project_Node_Id)
1248 begin
1249 pragma Assert
1250 (Node /= Empty_Node
1251 and then
1252 Project_Nodes.Table (Node).Kind = N_Term);
1253 Project_Nodes.Table (Node).Field2 := To;
1254 end Set_Next_Term;
1256 -----------------------
1257 -- Set_Next_Variable --
1258 -----------------------
1260 procedure Set_Next_Variable
1261 (Node : Project_Node_Id;
1262 To : Project_Node_Id)
1264 begin
1265 pragma Assert
1266 (Node /= Empty_Node
1267 and then
1268 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1269 or else
1270 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1271 Project_Nodes.Table (Node).Field3 := To;
1272 end Set_Next_Variable;
1274 -----------------------------
1275 -- Set_Next_With_Clause_Of --
1276 -----------------------------
1278 procedure Set_Next_With_Clause_Of
1279 (Node : Project_Node_Id;
1280 To : Project_Node_Id)
1282 begin
1283 pragma Assert
1284 (Node /= Empty_Node
1285 and then
1286 Project_Nodes.Table (Node).Kind = N_With_Clause);
1287 Project_Nodes.Table (Node).Field2 := To;
1288 end Set_Next_With_Clause_Of;
1290 -----------------------
1291 -- Set_Package_Id_Of --
1292 -----------------------
1294 procedure Set_Package_Id_Of
1295 (Node : Project_Node_Id;
1296 To : Package_Node_Id)
1298 begin
1299 pragma Assert
1300 (Node /= Empty_Node
1301 and then
1302 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1303 Project_Nodes.Table (Node).Pkg_Id := To;
1304 end Set_Package_Id_Of;
1306 -------------------------
1307 -- Set_Package_Node_Of --
1308 -------------------------
1310 procedure Set_Package_Node_Of
1311 (Node : Project_Node_Id;
1312 To : Project_Node_Id)
1314 begin
1315 pragma Assert
1316 (Node /= Empty_Node
1317 and then
1318 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1319 or else
1320 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1321 Project_Nodes.Table (Node).Field2 := To;
1322 end Set_Package_Node_Of;
1324 ----------------------
1325 -- Set_Path_Name_Of --
1326 ----------------------
1328 procedure Set_Path_Name_Of
1329 (Node : Project_Node_Id;
1330 To : Name_Id)
1332 begin
1333 pragma Assert
1334 (Node /= Empty_Node
1335 and then
1336 (Project_Nodes.Table (Node).Kind = N_Project
1337 or else
1338 Project_Nodes.Table (Node).Kind = N_With_Clause));
1339 Project_Nodes.Table (Node).Path_Name := To;
1340 end Set_Path_Name_Of;
1342 --------------------------------
1343 -- Set_Project_Declaration_Of --
1344 --------------------------------
1346 procedure Set_Project_Declaration_Of
1347 (Node : Project_Node_Id;
1348 To : Project_Node_Id)
1350 begin
1351 pragma Assert
1352 (Node /= Empty_Node
1353 and then
1354 Project_Nodes.Table (Node).Kind = N_Project);
1355 Project_Nodes.Table (Node).Field2 := To;
1356 end Set_Project_Declaration_Of;
1358 -------------------------
1359 -- Set_Project_Node_Of --
1360 -------------------------
1362 procedure Set_Project_Node_Of
1363 (Node : Project_Node_Id;
1364 To : Project_Node_Id)
1366 begin
1367 pragma Assert
1368 (Node /= Empty_Node
1369 and then
1370 (Project_Nodes.Table (Node).Kind = N_With_Clause
1371 or else
1372 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1373 or else
1374 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1375 Project_Nodes.Table (Node).Field1 := To;
1376 end Set_Project_Node_Of;
1378 ---------------------------------------
1379 -- Set_Project_Of_Renamed_Package_Of --
1380 ---------------------------------------
1382 procedure Set_Project_Of_Renamed_Package_Of
1383 (Node : Project_Node_Id;
1384 To : Project_Node_Id)
1386 begin
1387 pragma Assert
1388 (Node /= Empty_Node
1389 and then
1390 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1391 Project_Nodes.Table (Node).Field1 := To;
1392 end Set_Project_Of_Renamed_Package_Of;
1394 ------------------------
1395 -- Set_String_Type_Of --
1396 ------------------------
1398 procedure Set_String_Type_Of
1399 (Node : Project_Node_Id;
1400 To : Project_Node_Id)
1402 begin
1403 pragma Assert
1404 (Node /= Empty_Node
1405 and then
1406 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1407 or else
1408 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration)
1409 and then
1410 Project_Nodes.Table (To).Kind = N_String_Type_Declaration);
1412 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
1413 Project_Nodes.Table (Node).Field3 := To;
1414 else
1415 Project_Nodes.Table (Node).Field2 := To;
1416 end if;
1417 end Set_String_Type_Of;
1419 -------------------------
1420 -- Set_String_Value_Of --
1421 -------------------------
1423 procedure Set_String_Value_Of
1424 (Node : Project_Node_Id;
1425 To : String_Id)
1427 begin
1428 pragma Assert
1429 (Node /= Empty_Node
1430 and then
1431 (Project_Nodes.Table (Node).Kind = N_With_Clause
1432 or else
1433 Project_Nodes.Table (Node).Kind = N_Literal_String));
1434 Project_Nodes.Table (Node).Value := To;
1435 end Set_String_Value_Of;
1437 --------------------
1438 -- String_Type_Of --
1439 --------------------
1441 function String_Type_Of (Node : Project_Node_Id)
1442 return Project_Node_Id is
1443 begin
1444 pragma Assert
1445 (Node /= Empty_Node
1446 and then
1447 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1448 or else
1449 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration));
1451 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
1452 return Project_Nodes.Table (Node).Field3;
1453 else
1454 return Project_Nodes.Table (Node).Field2;
1455 end if;
1456 end String_Type_Of;
1458 ---------------------
1459 -- String_Value_Of --
1460 ---------------------
1462 function String_Value_Of (Node : Project_Node_Id) return String_Id is
1463 begin
1464 pragma Assert
1465 (Node /= Empty_Node
1466 and then
1467 (Project_Nodes.Table (Node).Kind = N_With_Clause
1468 or else
1469 Project_Nodes.Table (Node).Kind = N_Literal_String));
1470 return Project_Nodes.Table (Node).Value;
1471 end String_Value_Of;
1473 --------------------
1474 -- Value_Is_Valid --
1475 --------------------
1477 function Value_Is_Valid
1478 (For_Typed_Variable : Project_Node_Id;
1479 Value : String_Id)
1480 return Boolean
1482 begin
1483 pragma Assert
1484 (For_Typed_Variable /= Empty_Node
1485 and then
1486 (Project_Nodes.Table (For_Typed_Variable).Kind =
1487 N_Typed_Variable_Declaration));
1489 declare
1490 Current_String : Project_Node_Id :=
1491 First_Literal_String
1492 (String_Type_Of (For_Typed_Variable));
1494 begin
1495 while Current_String /= Empty_Node
1496 and then
1497 not String_Equal (String_Value_Of (Current_String), Value)
1498 loop
1499 Current_String :=
1500 Next_Literal_String (Current_String);
1501 end loop;
1503 return Current_String /= Empty_Node;
1504 end;
1506 end Value_Is_Valid;
1508 end Prj.Tree;