OSDN Git Service

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