[multiple changes]
[gcc.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 -- Copyright (C) 2001-2004 Free Software Foundation, Inc. --
10 -- --
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. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
26
27 with Prj.Err;
28
29 package body Prj.Tree is
30
31 Node_With_Comments : constant array (Project_Node_Kind) of Boolean :=
32 (N_Project => True,
33 N_With_Clause => True,
34 N_Project_Declaration => False,
35 N_Declarative_Item => False,
36 N_Package_Declaration => True,
37 N_String_Type_Declaration => True,
38 N_Literal_String => False,
39 N_Attribute_Declaration => True,
40 N_Typed_Variable_Declaration => True,
41 N_Variable_Declaration => True,
42 N_Expression => False,
43 N_Term => False,
44 N_Literal_String_List => False,
45 N_Variable_Reference => False,
46 N_External_Value => False,
47 N_Attribute_Reference => False,
48 N_Case_Construction => True,
49 N_Case_Item => True,
50 N_Comment_Zones => True,
51 N_Comment => True);
52 -- Indicates the kinds of node that may have associated comments
53
54 package Next_End_Nodes is new Table.Table
55 (Table_Component_Type => Project_Node_Id,
56 Table_Index_Type => Natural,
57 Table_Low_Bound => 1,
58 Table_Initial => 10,
59 Table_Increment => 100,
60 Table_Name => "Next_End_Nodes");
61 -- A stack of nodes to indicates to what node the next "end" is associated
62
63 use Tree_Private_Part;
64
65 End_Of_Line_Node : Project_Node_Id := Empty_Node;
66 -- The node an end of line comment may be associated with
67
68 Previous_Line_Node : Project_Node_Id := Empty_Node;
69 -- The node an immediately following comment may be associated with
70
71 Previous_End_Node : Project_Node_Id := Empty_Node;
72 -- The node comments immediately following an "end" line may be
73 -- associated with.
74
75 Unkept_Comments : Boolean := False;
76 -- Set to True when some comments may not be associated with any node
77
78 function Comment_Zones_Of
79 (Node : Project_Node_Id) return Project_Node_Id;
80 -- Returns the ID of the N_Comment_Zones node associated with node Node.
81 -- If there is not already an N_Comment_Zones node, create one and
82 -- associate it with node Node.
83
84 ------------------
85 -- Add_Comments --
86 ------------------
87
88 procedure Add_Comments (To : Project_Node_Id; Where : Comment_Location) is
89 Zone : Project_Node_Id := Empty_Node;
90 Previous : Project_Node_Id := Empty_Node;
91
92 begin
93 pragma Assert
94 (To /= Empty_Node
95 and then
96 Project_Nodes.Table (To).Kind /= N_Comment);
97
98 Zone := Project_Nodes.Table (To).Comments;
99
100 if Zone = Empty_Node then
101
102 -- Create new N_Comment_Zones node
103
104 Project_Nodes.Increment_Last;
105 Project_Nodes.Table (Project_Nodes.Last) :=
106 (Kind => N_Comment_Zones,
107 Expr_Kind => Undefined,
108 Location => No_Location,
109 Directory => No_Name,
110 Variables => Empty_Node,
111 Packages => Empty_Node,
112 Pkg_Id => Empty_Package,
113 Name => No_Name,
114 Path_Name => No_Name,
115 Value => No_Name,
116 Field1 => Empty_Node,
117 Field2 => Empty_Node,
118 Field3 => Empty_Node,
119 Flag1 => False,
120 Flag2 => False,
121 Comments => Empty_Node);
122
123 Zone := Project_Nodes.Last;
124 Project_Nodes.Table (To).Comments := Zone;
125 end if;
126
127 if Where = End_Of_Line then
128 Project_Nodes.Table (Zone).Value := Comments.Table (1).Value;
129
130 else
131 -- Get each comments in the Comments table and link them to node To
132
133 for J in 1 .. Comments.Last loop
134
135 -- Create new N_Comment node
136
137 if (Where = After or else Where = After_End) and then
138 Token /= Tok_EOF and then
139 Comments.Table (J).Follows_Empty_Line
140 then
141 Comments.Table (1 .. Comments.Last - J + 1) :=
142 Comments.Table (J .. Comments.Last);
143 Comments.Set_Last (Comments.Last - J + 1);
144 return;
145 end if;
146
147 Project_Nodes.Increment_Last;
148 Project_Nodes.Table (Project_Nodes.Last) :=
149 (Kind => N_Comment,
150 Expr_Kind => Undefined,
151 Flag1 => Comments.Table (J).Follows_Empty_Line,
152 Flag2 =>
153 Comments.Table (J).Is_Followed_By_Empty_Line,
154 Location => No_Location,
155 Directory => No_Name,
156 Variables => Empty_Node,
157 Packages => Empty_Node,
158 Pkg_Id => Empty_Package,
159 Name => No_Name,
160 Path_Name => No_Name,
161 Value => Comments.Table (J).Value,
162 Field1 => Empty_Node,
163 Field2 => Empty_Node,
164 Field3 => Empty_Node,
165 Comments => Empty_Node);
166
167 -- If this is the first comment, put it in the right field of
168 -- the node Zone.
169
170 if Previous = Empty_Node then
171 case Where is
172 when Before =>
173 Project_Nodes.Table (Zone).Field1 := Project_Nodes.Last;
174
175 when After =>
176 Project_Nodes.Table (Zone).Field2 := Project_Nodes.Last;
177
178 when Before_End =>
179 Project_Nodes.Table (Zone).Field3 := Project_Nodes.Last;
180
181 when After_End =>
182 Project_Nodes.Table (Zone).Comments := Project_Nodes.Last;
183
184 when End_Of_Line =>
185 null;
186 end case;
187
188 else
189 -- When it is not the first, link it to the previous one
190
191 Project_Nodes.Table (Previous).Comments := Project_Nodes.Last;
192 end if;
193
194 -- This node becomes the previous one for the next comment, if
195 -- there is one.
196
197 Previous := Project_Nodes.Last;
198 end loop;
199 end if;
200
201 -- Empty the Comments table, so that there is no risk to link the same
202 -- comments to another node.
203
204 Comments.Set_Last (0);
205 end Add_Comments;
206
207
208 --------------------------------
209 -- Associative_Array_Index_Of --
210 --------------------------------
211
212 function Associative_Array_Index_Of
213 (Node : Project_Node_Id) return Name_Id
214 is
215 begin
216 pragma Assert
217 (Node /= Empty_Node
218 and then
219 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
220 or else
221 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
222 return Project_Nodes.Table (Node).Value;
223 end Associative_Array_Index_Of;
224
225 ----------------------------
226 -- Associative_Package_Of --
227 ----------------------------
228
229 function Associative_Package_Of
230 (Node : Project_Node_Id) return Project_Node_Id
231 is
232 begin
233 pragma Assert
234 (Node /= Empty_Node
235 and then
236 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
237 return Project_Nodes.Table (Node).Field3;
238 end Associative_Package_Of;
239
240 ----------------------------
241 -- Associative_Project_Of --
242 ----------------------------
243
244 function Associative_Project_Of
245 (Node : Project_Node_Id) return Project_Node_Id
246 is
247 begin
248 pragma Assert
249 (Node /= Empty_Node
250 and then
251 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
252 return Project_Nodes.Table (Node).Field2;
253 end Associative_Project_Of;
254
255 ----------------------
256 -- Case_Insensitive --
257 ----------------------
258
259 function Case_Insensitive (Node : Project_Node_Id) return Boolean is
260 begin
261 pragma Assert
262 (Node /= Empty_Node
263 and then
264 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
265 or else
266 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
267 return Project_Nodes.Table (Node).Flag1;
268 end Case_Insensitive;
269
270 --------------------------------
271 -- Case_Variable_Reference_Of --
272 --------------------------------
273
274 function Case_Variable_Reference_Of
275 (Node : Project_Node_Id) return Project_Node_Id
276 is
277 begin
278 pragma Assert
279 (Node /= Empty_Node
280 and then
281 Project_Nodes.Table (Node).Kind = N_Case_Construction);
282 return Project_Nodes.Table (Node).Field1;
283 end Case_Variable_Reference_Of;
284
285 ----------------------
286 -- Comment_Zones_Of --
287 ----------------------
288
289 function Comment_Zones_Of
290 (Node : Project_Node_Id) return Project_Node_Id
291 is
292 Zone : Project_Node_Id;
293
294 begin
295 pragma Assert (Node /= Empty_Node);
296 Zone := Project_Nodes.Table (Node).Comments;
297
298 -- If there is not already an N_Comment_Zones associated, create a new
299 -- one and associate it with node Node.
300
301 if Zone = Empty_Node then
302 Project_Nodes.Increment_Last;
303 Zone := Project_Nodes.Last;
304 Project_Nodes.Table (Zone) :=
305 (Kind => N_Comment_Zones,
306 Location => No_Location,
307 Directory => No_Name,
308 Expr_Kind => Undefined,
309 Variables => Empty_Node,
310 Packages => Empty_Node,
311 Pkg_Id => Empty_Package,
312 Name => No_Name,
313 Path_Name => No_Name,
314 Value => No_Name,
315 Field1 => Empty_Node,
316 Field2 => Empty_Node,
317 Field3 => Empty_Node,
318 Flag1 => False,
319 Flag2 => False,
320 Comments => Empty_Node);
321 Project_Nodes.Table (Node).Comments := Zone;
322 end if;
323
324 return Zone;
325 end Comment_Zones_Of;
326
327 -----------------------
328 -- Current_Item_Node --
329 -----------------------
330
331 function Current_Item_Node
332 (Node : Project_Node_Id) 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_Declarative_Item);
339 return Project_Nodes.Table (Node).Field1;
340 end Current_Item_Node;
341
342 ------------------
343 -- Current_Term --
344 ------------------
345
346 function Current_Term
347 (Node : Project_Node_Id) return Project_Node_Id
348 is
349 begin
350 pragma Assert
351 (Node /= Empty_Node
352 and then
353 Project_Nodes.Table (Node).Kind = N_Term);
354 return Project_Nodes.Table (Node).Field1;
355 end Current_Term;
356
357 --------------------------
358 -- Default_Project_Node --
359 --------------------------
360
361 function Default_Project_Node
362 (Of_Kind : Project_Node_Kind;
363 And_Expr_Kind : Variable_Kind := Undefined) return Project_Node_Id
364 is
365 Result : Project_Node_Id;
366 Zone : Project_Node_Id;
367 Previous : Project_Node_Id;
368
369 begin
370 -- Create new node with specified kind and expression kind
371
372 Project_Nodes.Increment_Last;
373 Project_Nodes.Table (Project_Nodes.Last) :=
374 (Kind => Of_Kind,
375 Location => No_Location,
376 Directory => No_Name,
377 Expr_Kind => And_Expr_Kind,
378 Variables => Empty_Node,
379 Packages => Empty_Node,
380 Pkg_Id => Empty_Package,
381 Name => No_Name,
382 Path_Name => No_Name,
383 Value => No_Name,
384 Field1 => Empty_Node,
385 Field2 => Empty_Node,
386 Field3 => Empty_Node,
387 Flag1 => False,
388 Flag2 => False,
389 Comments => Empty_Node);
390
391 -- Save the new node for the returned value
392
393 Result := Project_Nodes.Last;
394
395 if Comments.Last > 0 then
396
397 -- If this is not a node with comments, then set the flag
398
399 if not Node_With_Comments (Of_Kind) then
400 Unkept_Comments := True;
401
402 elsif Of_Kind /= N_Comment and then Of_Kind /= N_Comment_Zones then
403
404 Project_Nodes.Increment_Last;
405 Project_Nodes.Table (Project_Nodes.Last) :=
406 (Kind => N_Comment_Zones,
407 Expr_Kind => Undefined,
408 Location => No_Location,
409 Directory => No_Name,
410 Variables => Empty_Node,
411 Packages => Empty_Node,
412 Pkg_Id => Empty_Package,
413 Name => No_Name,
414 Path_Name => No_Name,
415 Value => No_Name,
416 Field1 => Empty_Node,
417 Field2 => Empty_Node,
418 Field3 => Empty_Node,
419 Flag1 => False,
420 Flag2 => False,
421 Comments => Empty_Node);
422
423 Zone := Project_Nodes.Last;
424 Project_Nodes.Table (Result).Comments := Zone;
425 Previous := Empty_Node;
426
427 for J in 1 .. Comments.Last loop
428
429 -- Create a new N_Comment node
430
431 Project_Nodes.Increment_Last;
432 Project_Nodes.Table (Project_Nodes.Last) :=
433 (Kind => N_Comment,
434 Expr_Kind => Undefined,
435 Flag1 => Comments.Table (J).Follows_Empty_Line,
436 Flag2 =>
437 Comments.Table (J).Is_Followed_By_Empty_Line,
438 Location => No_Location,
439 Directory => No_Name,
440 Variables => Empty_Node,
441 Packages => Empty_Node,
442 Pkg_Id => Empty_Package,
443 Name => No_Name,
444 Path_Name => No_Name,
445 Value => Comments.Table (J).Value,
446 Field1 => Empty_Node,
447 Field2 => Empty_Node,
448 Field3 => Empty_Node,
449 Comments => Empty_Node);
450
451 -- Link it to the N_Comment_Zones node, if it is the first,
452 -- otherwise to the previous one.
453
454 if Previous = Empty_Node then
455 Project_Nodes.Table (Zone).Field1 := Project_Nodes.Last;
456
457 else
458 Project_Nodes.Table (Previous).Comments :=
459 Project_Nodes.Last;
460 end if;
461
462 -- This new node will be the previous one for the next
463 -- N_Comment node, if there is one.
464
465 Previous := Project_Nodes.Last;
466 end loop;
467
468 -- Empty the Comments table after all comments have been processed
469
470 Comments.Set_Last (0);
471 end if;
472 end if;
473
474 return Result;
475 end Default_Project_Node;
476
477 ------------------
478 -- Directory_Of --
479 ------------------
480
481 function Directory_Of (Node : Project_Node_Id) return Name_Id is
482 begin
483 pragma Assert
484 (Node /= Empty_Node
485 and then
486 Project_Nodes.Table (Node).Kind = N_Project);
487 return Project_Nodes.Table (Node).Directory;
488 end Directory_Of;
489
490 -------------------------
491 -- End_Of_Line_Comment --
492 -------------------------
493
494 function End_Of_Line_Comment (Node : Project_Node_Id) return Name_Id is
495 Zone : Project_Node_Id := Empty_Node;
496
497 begin
498 pragma Assert (Node /= Empty_Node);
499 Zone := Project_Nodes.Table (Node).Comments;
500
501 if Zone = Empty_Node then
502 return No_Name;
503 else
504 return Project_Nodes.Table (Zone).Value;
505 end if;
506 end End_Of_Line_Comment;
507
508 ------------------------
509 -- Expression_Kind_Of --
510 ------------------------
511
512 function Expression_Kind_Of (Node : Project_Node_Id) return Variable_Kind is
513 begin
514 pragma Assert
515 (Node /= Empty_Node
516 and then
517 (Project_Nodes.Table (Node).Kind = N_Literal_String
518 or else
519 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
520 or else
521 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
522 or else
523 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
524 or else
525 Project_Nodes.Table (Node).Kind = N_Package_Declaration
526 or else
527 Project_Nodes.Table (Node).Kind = N_Expression
528 or else
529 Project_Nodes.Table (Node).Kind = N_Term
530 or else
531 Project_Nodes.Table (Node).Kind = N_Variable_Reference
532 or else
533 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
534
535 return Project_Nodes.Table (Node).Expr_Kind;
536 end Expression_Kind_Of;
537
538 -------------------
539 -- Expression_Of --
540 -------------------
541
542 function Expression_Of
543 (Node : Project_Node_Id) return Project_Node_Id
544 is
545 begin
546 pragma Assert
547 (Node /= Empty_Node
548 and then
549 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
550 or else
551 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
552 or else
553 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
554
555 return Project_Nodes.Table (Node).Field1;
556 end Expression_Of;
557
558 -------------------------
559 -- Extended_Project_Of --
560 -------------------------
561
562 function Extended_Project_Of
563 (Node : Project_Node_Id) return Project_Node_Id
564 is
565 begin
566 pragma Assert
567 (Node /= Empty_Node
568 and then
569 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
570 return Project_Nodes.Table (Node).Field2;
571 end Extended_Project_Of;
572
573 ------------------------------
574 -- Extended_Project_Path_Of --
575 ------------------------------
576
577 function Extended_Project_Path_Of
578 (Node : Project_Node_Id) return Name_Id
579 is
580 begin
581 pragma Assert
582 (Node /= Empty_Node
583 and then
584 Project_Nodes.Table (Node).Kind = N_Project);
585 return Project_Nodes.Table (Node).Value;
586 end Extended_Project_Path_Of;
587
588 --------------------------
589 -- Extending_Project_Of --
590 --------------------------
591 function Extending_Project_Of
592 (Node : Project_Node_Id) return Project_Node_Id
593 is
594 begin
595 pragma Assert
596 (Node /= Empty_Node
597 and then
598 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
599 return Project_Nodes.Table (Node).Field3;
600 end Extending_Project_Of;
601
602 ---------------------------
603 -- External_Reference_Of --
604 ---------------------------
605
606 function External_Reference_Of
607 (Node : Project_Node_Id) return Project_Node_Id
608 is
609 begin
610 pragma Assert
611 (Node /= Empty_Node
612 and then
613 Project_Nodes.Table (Node).Kind = N_External_Value);
614 return Project_Nodes.Table (Node).Field1;
615 end External_Reference_Of;
616
617 -------------------------
618 -- External_Default_Of --
619 -------------------------
620
621 function External_Default_Of
622 (Node : Project_Node_Id)
623 return Project_Node_Id
624 is
625 begin
626 pragma Assert
627 (Node /= Empty_Node
628 and then
629 Project_Nodes.Table (Node).Kind = N_External_Value);
630 return Project_Nodes.Table (Node).Field2;
631 end External_Default_Of;
632
633 ------------------------
634 -- First_Case_Item_Of --
635 ------------------------
636
637 function First_Case_Item_Of
638 (Node : Project_Node_Id) return Project_Node_Id
639 is
640 begin
641 pragma Assert
642 (Node /= Empty_Node
643 and then
644 Project_Nodes.Table (Node).Kind = N_Case_Construction);
645 return Project_Nodes.Table (Node).Field2;
646 end First_Case_Item_Of;
647
648 ---------------------
649 -- First_Choice_Of --
650 ---------------------
651
652 function First_Choice_Of
653 (Node : Project_Node_Id)
654 return Project_Node_Id
655 is
656 begin
657 pragma Assert
658 (Node /= Empty_Node
659 and then
660 Project_Nodes.Table (Node).Kind = N_Case_Item);
661 return Project_Nodes.Table (Node).Field1;
662 end First_Choice_Of;
663
664 -------------------------
665 -- First_Comment_After --
666 -------------------------
667
668 function First_Comment_After
669 (Node : Project_Node_Id) return Project_Node_Id
670 is
671 Zone : Project_Node_Id := Empty_Node;
672 begin
673 pragma Assert (Node /= Empty_Node);
674 Zone := Project_Nodes.Table (Node).Comments;
675
676 if Zone = Empty_Node then
677 return Empty_Node;
678
679 else
680 return Project_Nodes.Table (Zone).Field2;
681 end if;
682 end First_Comment_After;
683
684 -----------------------------
685 -- First_Comment_After_End --
686 -----------------------------
687
688 function First_Comment_After_End
689 (Node : Project_Node_Id)
690 return Project_Node_Id
691 is
692 Zone : Project_Node_Id := Empty_Node;
693
694 begin
695 pragma Assert (Node /= Empty_Node);
696 Zone := Project_Nodes.Table (Node).Comments;
697
698 if Zone = Empty_Node then
699 return Empty_Node;
700
701 else
702 return Project_Nodes.Table (Zone).Comments;
703 end if;
704 end First_Comment_After_End;
705
706 --------------------------
707 -- First_Comment_Before --
708 --------------------------
709
710 function First_Comment_Before
711 (Node : Project_Node_Id) return Project_Node_Id
712 is
713 Zone : Project_Node_Id := Empty_Node;
714
715 begin
716 pragma Assert (Node /= Empty_Node);
717 Zone := Project_Nodes.Table (Node).Comments;
718
719 if Zone = Empty_Node then
720 return Empty_Node;
721
722 else
723 return Project_Nodes.Table (Zone).Field1;
724 end if;
725 end First_Comment_Before;
726
727 ------------------------------
728 -- First_Comment_Before_End --
729 ------------------------------
730
731 function First_Comment_Before_End
732 (Node : Project_Node_Id) return Project_Node_Id
733 is
734 Zone : Project_Node_Id := Empty_Node;
735
736 begin
737 pragma Assert (Node /= Empty_Node);
738 Zone := Project_Nodes.Table (Node).Comments;
739
740 if Zone = Empty_Node then
741 return Empty_Node;
742
743 else
744 return Project_Nodes.Table (Zone).Field3;
745 end if;
746 end First_Comment_Before_End;
747
748 -------------------------------
749 -- First_Declarative_Item_Of --
750 -------------------------------
751
752 function First_Declarative_Item_Of
753 (Node : Project_Node_Id) return Project_Node_Id
754 is
755 begin
756 pragma Assert
757 (Node /= Empty_Node
758 and then
759 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
760 or else
761 Project_Nodes.Table (Node).Kind = N_Case_Item
762 or else
763 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
764
765 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
766 return Project_Nodes.Table (Node).Field1;
767 else
768 return Project_Nodes.Table (Node).Field2;
769 end if;
770 end First_Declarative_Item_Of;
771
772 ------------------------------
773 -- First_Expression_In_List --
774 ------------------------------
775
776 function First_Expression_In_List
777 (Node : Project_Node_Id) return Project_Node_Id
778 is
779 begin
780 pragma Assert
781 (Node /= Empty_Node
782 and then
783 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
784 return Project_Nodes.Table (Node).Field1;
785 end First_Expression_In_List;
786
787 --------------------------
788 -- First_Literal_String --
789 --------------------------
790
791 function First_Literal_String
792 (Node : Project_Node_Id) return Project_Node_Id
793 is
794 begin
795 pragma Assert
796 (Node /= Empty_Node
797 and then
798 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
799 return Project_Nodes.Table (Node).Field1;
800 end First_Literal_String;
801
802 ----------------------
803 -- First_Package_Of --
804 ----------------------
805
806 function First_Package_Of
807 (Node : Project_Node_Id) return Package_Declaration_Id
808 is
809 begin
810 pragma Assert
811 (Node /= Empty_Node
812 and then
813 Project_Nodes.Table (Node).Kind = N_Project);
814 return Project_Nodes.Table (Node).Packages;
815 end First_Package_Of;
816
817 --------------------------
818 -- First_String_Type_Of --
819 --------------------------
820
821 function First_String_Type_Of
822 (Node : Project_Node_Id) return Project_Node_Id
823 is
824 begin
825 pragma Assert
826 (Node /= Empty_Node
827 and then
828 Project_Nodes.Table (Node).Kind = N_Project);
829 return Project_Nodes.Table (Node).Field3;
830 end First_String_Type_Of;
831
832 ----------------
833 -- First_Term --
834 ----------------
835
836 function First_Term
837 (Node : Project_Node_Id) return Project_Node_Id
838 is
839 begin
840 pragma Assert
841 (Node /= Empty_Node
842 and then
843 Project_Nodes.Table (Node).Kind = N_Expression);
844 return Project_Nodes.Table (Node).Field1;
845 end First_Term;
846
847 -----------------------
848 -- First_Variable_Of --
849 -----------------------
850
851 function First_Variable_Of
852 (Node : Project_Node_Id) return Variable_Node_Id
853 is
854 begin
855 pragma Assert
856 (Node /= Empty_Node
857 and then
858 (Project_Nodes.Table (Node).Kind = N_Project
859 or else
860 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
861
862 return Project_Nodes.Table (Node).Variables;
863 end First_Variable_Of;
864
865 --------------------------
866 -- First_With_Clause_Of --
867 --------------------------
868
869 function First_With_Clause_Of
870 (Node : Project_Node_Id) return Project_Node_Id
871 is
872 begin
873 pragma Assert
874 (Node /= Empty_Node
875 and then
876 Project_Nodes.Table (Node).Kind = N_Project);
877 return Project_Nodes.Table (Node).Field1;
878 end First_With_Clause_Of;
879
880 ------------------------
881 -- Follows_Empty_Line --
882 ------------------------
883
884 function Follows_Empty_Line (Node : Project_Node_Id) return Boolean is
885 begin
886 pragma Assert
887 (Node /= Empty_Node
888 and then
889 Project_Nodes.Table (Node).Kind = N_Comment);
890 return Project_Nodes.Table (Node).Flag1;
891 end Follows_Empty_Line;
892
893 ----------
894 -- Hash --
895 ----------
896
897 function Hash (N : Project_Node_Id) return Header_Num is
898 begin
899 return Header_Num (N mod Project_Node_Id (Header_Num'Last));
900 end Hash;
901
902 ----------------
903 -- Initialize --
904 ----------------
905
906 procedure Initialize is
907 begin
908 Project_Nodes.Set_Last (Empty_Node);
909 Projects_Htable.Reset;
910 end Initialize;
911
912 -------------------------------
913 -- Is_Followed_By_Empty_Line --
914 -------------------------------
915
916 function Is_Followed_By_Empty_Line
917 (Node : Project_Node_Id) return Boolean
918 is
919 begin
920 pragma Assert
921 (Node /= Empty_Node
922 and then
923 Project_Nodes.Table (Node).Kind = N_Comment);
924 return Project_Nodes.Table (Node).Flag2;
925 end Is_Followed_By_Empty_Line;
926
927 ----------------------
928 -- Is_Extending_All --
929 ----------------------
930
931 function Is_Extending_All (Node : Project_Node_Id) return Boolean is
932 begin
933 pragma Assert
934 (Node /= Empty_Node
935 and then
936 (Project_Nodes.Table (Node).Kind = N_Project
937 or else
938 Project_Nodes.Table (Node).Kind = N_With_Clause));
939 return Project_Nodes.Table (Node).Flag2;
940 end Is_Extending_All;
941
942 -------------------------------------
943 -- Imported_Or_Extended_Project_Of --
944 -------------------------------------
945
946 function Imported_Or_Extended_Project_Of
947 (Project : Project_Node_Id;
948 With_Name : Name_Id) return Project_Node_Id
949 is
950 With_Clause : Project_Node_Id := First_With_Clause_Of (Project);
951 Result : Project_Node_Id := Empty_Node;
952
953 begin
954 -- First check all the imported projects
955
956 while With_Clause /= Empty_Node loop
957
958 -- Only non limited imported project may be used as prefix
959 -- of variable or attributes.
960
961 Result := Non_Limited_Project_Node_Of (With_Clause);
962 exit when Result /= Empty_Node and then Name_Of (Result) = With_Name;
963 With_Clause := Next_With_Clause_Of (With_Clause);
964 end loop;
965
966 -- If it is not an imported project, it might be the imported project
967
968 if With_Clause = Empty_Node then
969 Result := Extended_Project_Of (Project_Declaration_Of (Project));
970
971 if Result /= Empty_Node
972 and then Name_Of (Result) /= With_Name
973 then
974 Result := Empty_Node;
975 end if;
976 end if;
977
978 return Result;
979 end Imported_Or_Extended_Project_Of;
980
981 -------------
982 -- Kind_Of --
983 -------------
984
985 function Kind_Of (Node : Project_Node_Id) return Project_Node_Kind is
986 begin
987 pragma Assert (Node /= Empty_Node);
988 return Project_Nodes.Table (Node).Kind;
989 end Kind_Of;
990
991 -----------------
992 -- Location_Of --
993 -----------------
994
995 function Location_Of (Node : Project_Node_Id) return Source_Ptr is
996 begin
997 pragma Assert (Node /= Empty_Node);
998 return Project_Nodes.Table (Node).Location;
999 end Location_Of;
1000
1001 -------------
1002 -- Name_Of --
1003 -------------
1004
1005 function Name_Of (Node : Project_Node_Id) return Name_Id is
1006 begin
1007 pragma Assert (Node /= Empty_Node);
1008 return Project_Nodes.Table (Node).Name;
1009 end Name_Of;
1010
1011 --------------------
1012 -- Next_Case_Item --
1013 --------------------
1014
1015 function Next_Case_Item
1016 (Node : Project_Node_Id) return Project_Node_Id
1017 is
1018 begin
1019 pragma Assert
1020 (Node /= Empty_Node
1021 and then
1022 Project_Nodes.Table (Node).Kind = N_Case_Item);
1023 return Project_Nodes.Table (Node).Field3;
1024 end Next_Case_Item;
1025
1026 ------------------
1027 -- Next_Comment --
1028 ------------------
1029
1030 function Next_Comment (Node : Project_Node_Id) return Project_Node_Id is
1031 begin
1032 pragma Assert
1033 (Node /= Empty_Node
1034 and then
1035 Project_Nodes.Table (Node).Kind = N_Comment);
1036 return Project_Nodes.Table (Node).Comments;
1037 end Next_Comment;
1038
1039 ---------------------------
1040 -- Next_Declarative_Item --
1041 ---------------------------
1042
1043 function Next_Declarative_Item
1044 (Node : Project_Node_Id) return Project_Node_Id
1045 is
1046 begin
1047 pragma Assert
1048 (Node /= Empty_Node
1049 and then
1050 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
1051 return Project_Nodes.Table (Node).Field2;
1052 end Next_Declarative_Item;
1053
1054 -----------------------------
1055 -- Next_Expression_In_List --
1056 -----------------------------
1057
1058 function Next_Expression_In_List
1059 (Node : Project_Node_Id) return Project_Node_Id
1060 is
1061 begin
1062 pragma Assert
1063 (Node /= Empty_Node
1064 and then
1065 Project_Nodes.Table (Node).Kind = N_Expression);
1066 return Project_Nodes.Table (Node).Field2;
1067 end Next_Expression_In_List;
1068
1069 -------------------------
1070 -- Next_Literal_String --
1071 -------------------------
1072
1073 function Next_Literal_String
1074 (Node : Project_Node_Id)
1075 return Project_Node_Id
1076 is
1077 begin
1078 pragma Assert
1079 (Node /= Empty_Node
1080 and then
1081 Project_Nodes.Table (Node).Kind = N_Literal_String);
1082 return Project_Nodes.Table (Node).Field1;
1083 end Next_Literal_String;
1084
1085 -----------------------------
1086 -- Next_Package_In_Project --
1087 -----------------------------
1088
1089 function Next_Package_In_Project
1090 (Node : Project_Node_Id) return Project_Node_Id
1091 is
1092 begin
1093 pragma Assert
1094 (Node /= Empty_Node
1095 and then
1096 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1097 return Project_Nodes.Table (Node).Field3;
1098 end Next_Package_In_Project;
1099
1100 ----------------------
1101 -- Next_String_Type --
1102 ----------------------
1103
1104 function Next_String_Type
1105 (Node : Project_Node_Id)
1106 return Project_Node_Id
1107 is
1108 begin
1109 pragma Assert
1110 (Node /= Empty_Node
1111 and then
1112 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1113 return Project_Nodes.Table (Node).Field2;
1114 end Next_String_Type;
1115
1116 ---------------
1117 -- Next_Term --
1118 ---------------
1119
1120 function Next_Term
1121 (Node : Project_Node_Id) return Project_Node_Id
1122 is
1123 begin
1124 pragma Assert
1125 (Node /= Empty_Node
1126 and then
1127 Project_Nodes.Table (Node).Kind = N_Term);
1128 return Project_Nodes.Table (Node).Field2;
1129 end Next_Term;
1130
1131 -------------------
1132 -- Next_Variable --
1133 -------------------
1134
1135 function Next_Variable
1136 (Node : Project_Node_Id)
1137 return Project_Node_Id
1138 is
1139 begin
1140 pragma Assert
1141 (Node /= Empty_Node
1142 and then
1143 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1144 or else
1145 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1146
1147 return Project_Nodes.Table (Node).Field3;
1148 end Next_Variable;
1149
1150 -------------------------
1151 -- Next_With_Clause_Of --
1152 -------------------------
1153
1154 function Next_With_Clause_Of
1155 (Node : Project_Node_Id) return Project_Node_Id
1156 is
1157 begin
1158 pragma Assert
1159 (Node /= Empty_Node
1160 and then
1161 Project_Nodes.Table (Node).Kind = N_With_Clause);
1162 return Project_Nodes.Table (Node).Field2;
1163 end Next_With_Clause_Of;
1164
1165 ---------------------------------
1166 -- Non_Limited_Project_Node_Of --
1167 ---------------------------------
1168
1169 function Non_Limited_Project_Node_Of
1170 (Node : Project_Node_Id) return Project_Node_Id
1171 is
1172 begin
1173 pragma Assert
1174 (Node /= Empty_Node
1175 and then
1176 (Project_Nodes.Table (Node).Kind = N_With_Clause));
1177 return Project_Nodes.Table (Node).Field3;
1178 end Non_Limited_Project_Node_Of;
1179
1180 -------------------
1181 -- Package_Id_Of --
1182 -------------------
1183
1184 function Package_Id_Of (Node : Project_Node_Id) return Package_Node_Id is
1185 begin
1186 pragma Assert
1187 (Node /= Empty_Node
1188 and then
1189 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1190 return Project_Nodes.Table (Node).Pkg_Id;
1191 end Package_Id_Of;
1192
1193 ---------------------
1194 -- Package_Node_Of --
1195 ---------------------
1196
1197 function Package_Node_Of
1198 (Node : Project_Node_Id) return Project_Node_Id
1199 is
1200 begin
1201 pragma Assert
1202 (Node /= Empty_Node
1203 and then
1204 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1205 or else
1206 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1207 return Project_Nodes.Table (Node).Field2;
1208 end Package_Node_Of;
1209
1210 ------------------
1211 -- Path_Name_Of --
1212 ------------------
1213
1214 function Path_Name_Of (Node : Project_Node_Id) return Name_Id is
1215 begin
1216 pragma Assert
1217 (Node /= Empty_Node
1218 and then
1219 (Project_Nodes.Table (Node).Kind = N_Project
1220 or else
1221 Project_Nodes.Table (Node).Kind = N_With_Clause));
1222 return Project_Nodes.Table (Node).Path_Name;
1223 end Path_Name_Of;
1224
1225 ----------------------------
1226 -- Project_Declaration_Of --
1227 ----------------------------
1228
1229 function Project_Declaration_Of
1230 (Node : Project_Node_Id) return Project_Node_Id
1231 is
1232 begin
1233 pragma Assert
1234 (Node /= Empty_Node
1235 and then
1236 Project_Nodes.Table (Node).Kind = N_Project);
1237 return Project_Nodes.Table (Node).Field2;
1238 end Project_Declaration_Of;
1239
1240 -------------------------------------------
1241 -- Project_File_Includes_Unkept_Comments --
1242 -------------------------------------------
1243
1244 function Project_File_Includes_Unkept_Comments
1245 (Node : Project_Node_Id) return Boolean
1246 is
1247 Declaration : constant Project_Node_Id := Project_Declaration_Of (Node);
1248 begin
1249 return Project_Nodes.Table (Declaration).Flag1;
1250 end Project_File_Includes_Unkept_Comments;
1251
1252 ---------------------
1253 -- Project_Node_Of --
1254 ---------------------
1255
1256 function Project_Node_Of
1257 (Node : Project_Node_Id) return Project_Node_Id
1258 is
1259 begin
1260 pragma Assert
1261 (Node /= Empty_Node
1262 and then
1263 (Project_Nodes.Table (Node).Kind = N_With_Clause
1264 or else
1265 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1266 or else
1267 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1268 return Project_Nodes.Table (Node).Field1;
1269 end Project_Node_Of;
1270
1271 -----------------------------------
1272 -- Project_Of_Renamed_Package_Of --
1273 -----------------------------------
1274
1275 function Project_Of_Renamed_Package_Of
1276 (Node : Project_Node_Id) return Project_Node_Id
1277 is
1278 begin
1279 pragma Assert
1280 (Node /= Empty_Node
1281 and then
1282 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1283 return Project_Nodes.Table (Node).Field1;
1284 end Project_Of_Renamed_Package_Of;
1285
1286 --------------------------
1287 -- Remove_Next_End_Node --
1288 --------------------------
1289
1290 procedure Remove_Next_End_Node is
1291 begin
1292 Next_End_Nodes.Decrement_Last;
1293 end Remove_Next_End_Node;
1294
1295 -----------------
1296 -- Reset_State --
1297 -----------------
1298
1299 procedure Reset_State is
1300 begin
1301 End_Of_Line_Node := Empty_Node;
1302 Previous_Line_Node := Empty_Node;
1303 Previous_End_Node := Empty_Node;
1304 Unkept_Comments := False;
1305 Comments.Set_Last (0);
1306 end Reset_State;
1307
1308 -------------
1309 -- Restore --
1310 -------------
1311
1312 procedure Restore (S : in Comment_State) is
1313 begin
1314 End_Of_Line_Node := S.End_Of_Line_Node;
1315 Previous_Line_Node := S.Previous_Line_Node;
1316 Previous_End_Node := S.Previous_End_Node;
1317 Next_End_Nodes.Set_Last (0);
1318 Unkept_Comments := S.Unkept_Comments;
1319
1320 Comments.Set_Last (0);
1321
1322 for J in S.Comments'Range loop
1323 Comments.Increment_Last;
1324 Comments.Table (Comments.Last) := S.Comments (J);
1325 end loop;
1326 end Restore;
1327
1328 ----------
1329 -- Save --
1330 ----------
1331
1332 procedure Save (S : out Comment_State) is
1333 Cmts : constant Comments_Ptr := new Comment_Array (1 .. Comments.Last);
1334
1335 begin
1336 for J in 1 .. Comments.Last loop
1337 Cmts (J) := Comments.Table (J);
1338 end loop;
1339
1340 S :=
1341 (End_Of_Line_Node => End_Of_Line_Node,
1342 Previous_Line_Node => Previous_Line_Node,
1343 Previous_End_Node => Previous_End_Node,
1344 Unkept_Comments => Unkept_Comments,
1345 Comments => Cmts);
1346 end Save;
1347
1348 ----------
1349 -- Scan --
1350 ----------
1351
1352 procedure Scan is
1353 Empty_Line : Boolean := False;
1354 begin
1355 -- If there are comments, then they will not be kept. Set the flag and
1356 -- clear the comments.
1357
1358 if Comments.Last > 0 then
1359 Unkept_Comments := True;
1360 Comments.Set_Last (0);
1361 end if;
1362
1363 -- Loop until a token other that End_Of_Line or Comment is found
1364
1365 loop
1366 Prj.Err.Scanner.Scan;
1367
1368 case Token is
1369 when Tok_End_Of_Line =>
1370 if Prev_Token = Tok_End_Of_Line then
1371 Empty_Line := True;
1372
1373 if Comments.Last > 0 then
1374 Comments.Table (Comments.Last).Is_Followed_By_Empty_Line
1375 := True;
1376 end if;
1377 end if;
1378
1379 when Tok_Comment =>
1380 -- If this is a line comment, add it to the comment table
1381
1382 if Prev_Token = Tok_End_Of_Line
1383 or else Prev_Token = No_Token
1384 then
1385 Comments.Increment_Last;
1386 Comments.Table (Comments.Last) :=
1387 (Value => Comment_Id,
1388 Follows_Empty_Line => Empty_Line,
1389 Is_Followed_By_Empty_Line => False);
1390
1391 -- Otherwise, it is an end of line comment. If there is
1392 -- an end of line node specified, associate the comment with
1393 -- this node.
1394
1395 elsif End_Of_Line_Node /= Empty_Node then
1396 declare
1397 Zones : constant Project_Node_Id :=
1398 Comment_Zones_Of (End_Of_Line_Node);
1399 begin
1400 Project_Nodes.Table (Zones).Value := Comment_Id;
1401 end;
1402
1403 -- Otherwise, this end of line node cannot be kept
1404
1405 else
1406 Unkept_Comments := True;
1407 Comments.Set_Last (0);
1408 end if;
1409
1410 Empty_Line := False;
1411
1412 when others =>
1413 -- If there are comments, where the first comment is not
1414 -- following an empty line, put the initial uninterrupted
1415 -- comment zone with the node of the preceding line (either
1416 -- a Previous_Line or a Previous_End node), if any.
1417
1418 if Comments.Last > 0 and then
1419 not Comments.Table (1).Follows_Empty_Line then
1420 if Previous_Line_Node /= Empty_Node then
1421 Add_Comments
1422 (To => Previous_Line_Node, Where => After);
1423
1424 elsif Previous_End_Node /= Empty_Node then
1425 Add_Comments
1426 (To => Previous_End_Node, Where => After_End);
1427 end if;
1428 end if;
1429
1430 -- If there are still comments and the token is "end", then
1431 -- put these comments with the Next_End node, if any;
1432 -- otherwise, these comments cannot be kept. Always clear
1433 -- the comments.
1434
1435 if Comments.Last > 0 and then Token = Tok_End then
1436 if Next_End_Nodes.Last > 0 then
1437 Add_Comments
1438 (To => Next_End_Nodes.Table (Next_End_Nodes.Last),
1439 Where => Before_End);
1440
1441 else
1442 Unkept_Comments := True;
1443 end if;
1444
1445 Comments.Set_Last (0);
1446 end if;
1447
1448 -- Reset the End_Of_Line, Previous_Line and Previous_End nodes
1449 -- so that they are not used again.
1450
1451 End_Of_Line_Node := Empty_Node;
1452 Previous_Line_Node := Empty_Node;
1453 Previous_End_Node := Empty_Node;
1454
1455 -- And return
1456
1457 exit;
1458 end case;
1459 end loop;
1460 end Scan;
1461
1462 ------------------------------------
1463 -- Set_Associative_Array_Index_Of --
1464 ------------------------------------
1465
1466 procedure Set_Associative_Array_Index_Of
1467 (Node : Project_Node_Id;
1468 To : Name_Id)
1469 is
1470 begin
1471 pragma Assert
1472 (Node /= Empty_Node
1473 and then
1474 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1475 or else
1476 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1477 Project_Nodes.Table (Node).Value := To;
1478 end Set_Associative_Array_Index_Of;
1479
1480 --------------------------------
1481 -- Set_Associative_Package_Of --
1482 --------------------------------
1483
1484 procedure Set_Associative_Package_Of
1485 (Node : Project_Node_Id;
1486 To : Project_Node_Id)
1487 is
1488 begin
1489 pragma Assert
1490 (Node /= Empty_Node
1491 and then
1492 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration);
1493 Project_Nodes.Table (Node).Field3 := To;
1494 end Set_Associative_Package_Of;
1495
1496 --------------------------------
1497 -- Set_Associative_Project_Of --
1498 --------------------------------
1499
1500 procedure Set_Associative_Project_Of
1501 (Node : Project_Node_Id;
1502 To : Project_Node_Id)
1503 is
1504 begin
1505 pragma Assert
1506 (Node /= Empty_Node
1507 and then
1508 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
1509 Project_Nodes.Table (Node).Field2 := To;
1510 end Set_Associative_Project_Of;
1511
1512 --------------------------
1513 -- Set_Case_Insensitive --
1514 --------------------------
1515
1516 procedure Set_Case_Insensitive
1517 (Node : Project_Node_Id;
1518 To : Boolean)
1519 is
1520 begin
1521 pragma Assert
1522 (Node /= Empty_Node
1523 and then
1524 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1525 or else
1526 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1527 Project_Nodes.Table (Node).Flag1 := To;
1528 end Set_Case_Insensitive;
1529
1530 ------------------------------------
1531 -- Set_Case_Variable_Reference_Of --
1532 ------------------------------------
1533
1534 procedure Set_Case_Variable_Reference_Of
1535 (Node : Project_Node_Id;
1536 To : Project_Node_Id)
1537 is
1538 begin
1539 pragma Assert
1540 (Node /= Empty_Node
1541 and then
1542 Project_Nodes.Table (Node).Kind = N_Case_Construction);
1543 Project_Nodes.Table (Node).Field1 := To;
1544 end Set_Case_Variable_Reference_Of;
1545
1546 ---------------------------
1547 -- Set_Current_Item_Node --
1548 ---------------------------
1549
1550 procedure Set_Current_Item_Node
1551 (Node : Project_Node_Id;
1552 To : Project_Node_Id)
1553 is
1554 begin
1555 pragma Assert
1556 (Node /= Empty_Node
1557 and then
1558 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
1559 Project_Nodes.Table (Node).Field1 := To;
1560 end Set_Current_Item_Node;
1561
1562 ----------------------
1563 -- Set_Current_Term --
1564 ----------------------
1565
1566 procedure Set_Current_Term
1567 (Node : Project_Node_Id;
1568 To : Project_Node_Id)
1569 is
1570 begin
1571 pragma Assert
1572 (Node /= Empty_Node
1573 and then
1574 Project_Nodes.Table (Node).Kind = N_Term);
1575 Project_Nodes.Table (Node).Field1 := To;
1576 end Set_Current_Term;
1577
1578 ----------------------
1579 -- Set_Directory_Of --
1580 ----------------------
1581
1582 procedure Set_Directory_Of
1583 (Node : Project_Node_Id;
1584 To : Name_Id)
1585 is
1586 begin
1587 pragma Assert
1588 (Node /= Empty_Node
1589 and then
1590 Project_Nodes.Table (Node).Kind = N_Project);
1591 Project_Nodes.Table (Node).Directory := To;
1592 end Set_Directory_Of;
1593
1594 ---------------------
1595 -- Set_End_Of_Line --
1596 ---------------------
1597
1598 procedure Set_End_Of_Line (To : Project_Node_Id) is
1599 begin
1600 End_Of_Line_Node := To;
1601 end Set_End_Of_Line;
1602
1603 ----------------------------
1604 -- Set_Expression_Kind_Of --
1605 ----------------------------
1606
1607 procedure Set_Expression_Kind_Of
1608 (Node : Project_Node_Id;
1609 To : Variable_Kind)
1610 is
1611 begin
1612 pragma Assert
1613 (Node /= Empty_Node
1614 and then
1615 (Project_Nodes.Table (Node).Kind = N_Literal_String
1616 or else
1617 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1618 or else
1619 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
1620 or else
1621 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1622 or else
1623 Project_Nodes.Table (Node).Kind = N_Package_Declaration
1624 or else
1625 Project_Nodes.Table (Node).Kind = N_Expression
1626 or else
1627 Project_Nodes.Table (Node).Kind = N_Term
1628 or else
1629 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1630 or else
1631 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1632 Project_Nodes.Table (Node).Expr_Kind := To;
1633 end Set_Expression_Kind_Of;
1634
1635 -----------------------
1636 -- Set_Expression_Of --
1637 -----------------------
1638
1639 procedure Set_Expression_Of
1640 (Node : Project_Node_Id;
1641 To : Project_Node_Id)
1642 is
1643 begin
1644 pragma Assert
1645 (Node /= Empty_Node
1646 and then
1647 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1648 or else
1649 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1650 or else
1651 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1652 Project_Nodes.Table (Node).Field1 := To;
1653 end Set_Expression_Of;
1654
1655 -------------------------------
1656 -- Set_External_Reference_Of --
1657 -------------------------------
1658
1659 procedure Set_External_Reference_Of
1660 (Node : Project_Node_Id;
1661 To : Project_Node_Id)
1662 is
1663 begin
1664 pragma Assert
1665 (Node /= Empty_Node
1666 and then
1667 Project_Nodes.Table (Node).Kind = N_External_Value);
1668 Project_Nodes.Table (Node).Field1 := To;
1669 end Set_External_Reference_Of;
1670
1671 -----------------------------
1672 -- Set_External_Default_Of --
1673 -----------------------------
1674
1675 procedure Set_External_Default_Of
1676 (Node : Project_Node_Id;
1677 To : Project_Node_Id)
1678 is
1679 begin
1680 pragma Assert
1681 (Node /= Empty_Node
1682 and then
1683 Project_Nodes.Table (Node).Kind = N_External_Value);
1684 Project_Nodes.Table (Node).Field2 := To;
1685 end Set_External_Default_Of;
1686
1687 ----------------------------
1688 -- Set_First_Case_Item_Of --
1689 ----------------------------
1690
1691 procedure Set_First_Case_Item_Of
1692 (Node : Project_Node_Id;
1693 To : Project_Node_Id)
1694 is
1695 begin
1696 pragma Assert
1697 (Node /= Empty_Node
1698 and then
1699 Project_Nodes.Table (Node).Kind = N_Case_Construction);
1700 Project_Nodes.Table (Node).Field2 := To;
1701 end Set_First_Case_Item_Of;
1702
1703 -------------------------
1704 -- Set_First_Choice_Of --
1705 -------------------------
1706
1707 procedure Set_First_Choice_Of
1708 (Node : Project_Node_Id;
1709 To : Project_Node_Id)
1710 is
1711 begin
1712 pragma Assert
1713 (Node /= Empty_Node
1714 and then
1715 Project_Nodes.Table (Node).Kind = N_Case_Item);
1716 Project_Nodes.Table (Node).Field1 := To;
1717 end Set_First_Choice_Of;
1718
1719 -----------------------------
1720 -- Set_First_Comment_After --
1721 -----------------------------
1722
1723 procedure Set_First_Comment_After
1724 (Node : Project_Node_Id;
1725 To : Project_Node_Id)
1726 is
1727 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1728 begin
1729 Project_Nodes.Table (Zone).Field2 := To;
1730 end Set_First_Comment_After;
1731
1732 ---------------------------------
1733 -- Set_First_Comment_After_End --
1734 ---------------------------------
1735
1736 procedure Set_First_Comment_After_End
1737 (Node : Project_Node_Id;
1738 To : Project_Node_Id)
1739 is
1740 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1741 begin
1742 Project_Nodes.Table (Zone).Comments := To;
1743 end Set_First_Comment_After_End;
1744
1745 ------------------------------
1746 -- Set_First_Comment_Before --
1747 ------------------------------
1748
1749 procedure Set_First_Comment_Before
1750 (Node : Project_Node_Id;
1751 To : Project_Node_Id)
1752
1753 is
1754 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1755 begin
1756 Project_Nodes.Table (Zone).Field1 := To;
1757 end Set_First_Comment_Before;
1758
1759 ----------------------------------
1760 -- Set_First_Comment_Before_End --
1761 ----------------------------------
1762
1763 procedure Set_First_Comment_Before_End
1764 (Node : Project_Node_Id;
1765 To : Project_Node_Id)
1766 is
1767 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1768 begin
1769 Project_Nodes.Table (Zone).Field2 := To;
1770 end Set_First_Comment_Before_End;
1771
1772 ------------------------
1773 -- Set_Next_Case_Item --
1774 ------------------------
1775
1776 procedure Set_Next_Case_Item
1777 (Node : Project_Node_Id;
1778 To : Project_Node_Id)
1779 is
1780 begin
1781 pragma Assert
1782 (Node /= Empty_Node
1783 and then
1784 Project_Nodes.Table (Node).Kind = N_Case_Item);
1785 Project_Nodes.Table (Node).Field3 := To;
1786 end Set_Next_Case_Item;
1787
1788 ----------------------
1789 -- Set_Next_Comment --
1790 ----------------------
1791
1792 procedure Set_Next_Comment
1793 (Node : Project_Node_Id;
1794 To : Project_Node_Id)
1795 is
1796 begin
1797 pragma Assert
1798 (Node /= Empty_Node
1799 and then
1800 Project_Nodes.Table (Node).Kind = N_Comment);
1801 Project_Nodes.Table (Node).Comments := To;
1802 end Set_Next_Comment;
1803
1804 -----------------------------------
1805 -- Set_First_Declarative_Item_Of --
1806 -----------------------------------
1807
1808 procedure Set_First_Declarative_Item_Of
1809 (Node : Project_Node_Id;
1810 To : Project_Node_Id)
1811 is
1812 begin
1813 pragma Assert
1814 (Node /= Empty_Node
1815 and then
1816 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
1817 or else
1818 Project_Nodes.Table (Node).Kind = N_Case_Item
1819 or else
1820 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1821
1822 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
1823 Project_Nodes.Table (Node).Field1 := To;
1824 else
1825 Project_Nodes.Table (Node).Field2 := To;
1826 end if;
1827 end Set_First_Declarative_Item_Of;
1828
1829 ----------------------------------
1830 -- Set_First_Expression_In_List --
1831 ----------------------------------
1832
1833 procedure Set_First_Expression_In_List
1834 (Node : Project_Node_Id;
1835 To : Project_Node_Id)
1836 is
1837 begin
1838 pragma Assert
1839 (Node /= Empty_Node
1840 and then
1841 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
1842 Project_Nodes.Table (Node).Field1 := To;
1843 end Set_First_Expression_In_List;
1844
1845 ------------------------------
1846 -- Set_First_Literal_String --
1847 ------------------------------
1848
1849 procedure Set_First_Literal_String
1850 (Node : Project_Node_Id;
1851 To : Project_Node_Id)
1852 is
1853 begin
1854 pragma Assert
1855 (Node /= Empty_Node
1856 and then
1857 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1858 Project_Nodes.Table (Node).Field1 := To;
1859 end Set_First_Literal_String;
1860
1861 --------------------------
1862 -- Set_First_Package_Of --
1863 --------------------------
1864
1865 procedure Set_First_Package_Of
1866 (Node : Project_Node_Id;
1867 To : Package_Declaration_Id)
1868 is
1869 begin
1870 pragma Assert
1871 (Node /= Empty_Node
1872 and then
1873 Project_Nodes.Table (Node).Kind = N_Project);
1874 Project_Nodes.Table (Node).Packages := To;
1875 end Set_First_Package_Of;
1876
1877 ------------------------------
1878 -- Set_First_String_Type_Of --
1879 ------------------------------
1880
1881 procedure Set_First_String_Type_Of
1882 (Node : Project_Node_Id;
1883 To : Project_Node_Id)
1884 is
1885 begin
1886 pragma Assert
1887 (Node /= Empty_Node
1888 and then
1889 Project_Nodes.Table (Node).Kind = N_Project);
1890 Project_Nodes.Table (Node).Field3 := To;
1891 end Set_First_String_Type_Of;
1892
1893 --------------------
1894 -- Set_First_Term --
1895 --------------------
1896
1897 procedure Set_First_Term
1898 (Node : Project_Node_Id;
1899 To : Project_Node_Id)
1900 is
1901 begin
1902 pragma Assert
1903 (Node /= Empty_Node
1904 and then
1905 Project_Nodes.Table (Node).Kind = N_Expression);
1906 Project_Nodes.Table (Node).Field1 := To;
1907 end Set_First_Term;
1908
1909 ---------------------------
1910 -- Set_First_Variable_Of --
1911 ---------------------------
1912
1913 procedure Set_First_Variable_Of
1914 (Node : Project_Node_Id;
1915 To : Variable_Node_Id)
1916 is
1917 begin
1918 pragma Assert
1919 (Node /= Empty_Node
1920 and then
1921 (Project_Nodes.Table (Node).Kind = N_Project
1922 or else
1923 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1924 Project_Nodes.Table (Node).Variables := To;
1925 end Set_First_Variable_Of;
1926
1927 ------------------------------
1928 -- Set_First_With_Clause_Of --
1929 ------------------------------
1930
1931 procedure Set_First_With_Clause_Of
1932 (Node : Project_Node_Id;
1933 To : Project_Node_Id)
1934 is
1935 begin
1936 pragma Assert
1937 (Node /= Empty_Node
1938 and then
1939 Project_Nodes.Table (Node).Kind = N_Project);
1940 Project_Nodes.Table (Node).Field1 := To;
1941 end Set_First_With_Clause_Of;
1942
1943 --------------------------
1944 -- Set_Is_Extending_All --
1945 --------------------------
1946
1947 procedure Set_Is_Extending_All (Node : Project_Node_Id) is
1948 begin
1949 pragma Assert
1950 (Node /= Empty_Node
1951 and then
1952 (Project_Nodes.Table (Node).Kind = N_Project
1953 or else
1954 Project_Nodes.Table (Node).Kind = N_With_Clause));
1955 Project_Nodes.Table (Node).Flag2 := True;
1956 end Set_Is_Extending_All;
1957
1958 -----------------
1959 -- Set_Kind_Of --
1960 -----------------
1961
1962 procedure Set_Kind_Of
1963 (Node : Project_Node_Id;
1964 To : Project_Node_Kind)
1965 is
1966 begin
1967 pragma Assert (Node /= Empty_Node);
1968 Project_Nodes.Table (Node).Kind := To;
1969 end Set_Kind_Of;
1970
1971 ---------------------
1972 -- Set_Location_Of --
1973 ---------------------
1974
1975 procedure Set_Location_Of
1976 (Node : Project_Node_Id;
1977 To : Source_Ptr)
1978 is
1979 begin
1980 pragma Assert (Node /= Empty_Node);
1981 Project_Nodes.Table (Node).Location := To;
1982 end Set_Location_Of;
1983
1984 -----------------------------
1985 -- Set_Extended_Project_Of --
1986 -----------------------------
1987
1988 procedure Set_Extended_Project_Of
1989 (Node : Project_Node_Id;
1990 To : Project_Node_Id)
1991 is
1992 begin
1993 pragma Assert
1994 (Node /= Empty_Node
1995 and then
1996 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
1997 Project_Nodes.Table (Node).Field2 := To;
1998 end Set_Extended_Project_Of;
1999
2000 ----------------------------------
2001 -- Set_Extended_Project_Path_Of --
2002 ----------------------------------
2003
2004 procedure Set_Extended_Project_Path_Of
2005 (Node : Project_Node_Id;
2006 To : Name_Id)
2007 is
2008 begin
2009 pragma Assert
2010 (Node /= Empty_Node
2011 and then
2012 Project_Nodes.Table (Node).Kind = N_Project);
2013 Project_Nodes.Table (Node).Value := To;
2014 end Set_Extended_Project_Path_Of;
2015
2016 ------------------------------
2017 -- Set_Extending_Project_Of --
2018 ------------------------------
2019
2020 procedure Set_Extending_Project_Of
2021 (Node : Project_Node_Id;
2022 To : Project_Node_Id)
2023 is
2024 begin
2025 pragma Assert
2026 (Node /= Empty_Node
2027 and then
2028 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
2029 Project_Nodes.Table (Node).Field3 := To;
2030 end Set_Extending_Project_Of;
2031
2032 -----------------
2033 -- Set_Name_Of --
2034 -----------------
2035
2036 procedure Set_Name_Of
2037 (Node : Project_Node_Id;
2038 To : Name_Id)
2039 is
2040 begin
2041 pragma Assert (Node /= Empty_Node);
2042 Project_Nodes.Table (Node).Name := To;
2043 end Set_Name_Of;
2044
2045 -------------------------------
2046 -- Set_Next_Declarative_Item --
2047 -------------------------------
2048
2049 procedure Set_Next_Declarative_Item
2050 (Node : Project_Node_Id;
2051 To : Project_Node_Id)
2052 is
2053 begin
2054 pragma Assert
2055 (Node /= Empty_Node
2056 and then
2057 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
2058 Project_Nodes.Table (Node).Field2 := To;
2059 end Set_Next_Declarative_Item;
2060
2061 -----------------------
2062 -- Set_Next_End_Node --
2063 -----------------------
2064
2065 procedure Set_Next_End_Node (To : Project_Node_Id) is
2066 begin
2067 Next_End_Nodes.Increment_Last;
2068 Next_End_Nodes.Table (Next_End_Nodes.Last) := To;
2069 end Set_Next_End_Node;
2070
2071 ---------------------------------
2072 -- Set_Next_Expression_In_List --
2073 ---------------------------------
2074
2075 procedure Set_Next_Expression_In_List
2076 (Node : Project_Node_Id;
2077 To : Project_Node_Id)
2078 is
2079 begin
2080 pragma Assert
2081 (Node /= Empty_Node
2082 and then
2083 Project_Nodes.Table (Node).Kind = N_Expression);
2084 Project_Nodes.Table (Node).Field2 := To;
2085 end Set_Next_Expression_In_List;
2086
2087 -----------------------------
2088 -- Set_Next_Literal_String --
2089 -----------------------------
2090
2091 procedure Set_Next_Literal_String
2092 (Node : Project_Node_Id;
2093 To : Project_Node_Id)
2094 is
2095 begin
2096 pragma Assert
2097 (Node /= Empty_Node
2098 and then
2099 Project_Nodes.Table (Node).Kind = N_Literal_String);
2100 Project_Nodes.Table (Node).Field1 := To;
2101 end Set_Next_Literal_String;
2102
2103 ---------------------------------
2104 -- Set_Next_Package_In_Project --
2105 ---------------------------------
2106
2107 procedure Set_Next_Package_In_Project
2108 (Node : Project_Node_Id;
2109 To : Project_Node_Id)
2110 is
2111 begin
2112 pragma Assert
2113 (Node /= Empty_Node
2114 and then
2115 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
2116 Project_Nodes.Table (Node).Field3 := To;
2117 end Set_Next_Package_In_Project;
2118
2119 --------------------------
2120 -- Set_Next_String_Type --
2121 --------------------------
2122
2123 procedure Set_Next_String_Type
2124 (Node : Project_Node_Id;
2125 To : Project_Node_Id)
2126 is
2127 begin
2128 pragma Assert
2129 (Node /= Empty_Node
2130 and then
2131 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
2132 Project_Nodes.Table (Node).Field2 := To;
2133 end Set_Next_String_Type;
2134
2135 -------------------
2136 -- Set_Next_Term --
2137 -------------------
2138
2139 procedure Set_Next_Term
2140 (Node : Project_Node_Id;
2141 To : Project_Node_Id)
2142 is
2143 begin
2144 pragma Assert
2145 (Node /= Empty_Node
2146 and then
2147 Project_Nodes.Table (Node).Kind = N_Term);
2148 Project_Nodes.Table (Node).Field2 := To;
2149 end Set_Next_Term;
2150
2151 -----------------------
2152 -- Set_Next_Variable --
2153 -----------------------
2154
2155 procedure Set_Next_Variable
2156 (Node : Project_Node_Id;
2157 To : Project_Node_Id)
2158 is
2159 begin
2160 pragma Assert
2161 (Node /= Empty_Node
2162 and then
2163 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
2164 or else
2165 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
2166 Project_Nodes.Table (Node).Field3 := To;
2167 end Set_Next_Variable;
2168
2169 -----------------------------
2170 -- Set_Next_With_Clause_Of --
2171 -----------------------------
2172
2173 procedure Set_Next_With_Clause_Of
2174 (Node : Project_Node_Id;
2175 To : Project_Node_Id)
2176 is
2177 begin
2178 pragma Assert
2179 (Node /= Empty_Node
2180 and then
2181 Project_Nodes.Table (Node).Kind = N_With_Clause);
2182 Project_Nodes.Table (Node).Field2 := To;
2183 end Set_Next_With_Clause_Of;
2184
2185 -----------------------
2186 -- Set_Package_Id_Of --
2187 -----------------------
2188
2189 procedure Set_Package_Id_Of
2190 (Node : Project_Node_Id;
2191 To : Package_Node_Id)
2192 is
2193 begin
2194 pragma Assert
2195 (Node /= Empty_Node
2196 and then
2197 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
2198 Project_Nodes.Table (Node).Pkg_Id := To;
2199 end Set_Package_Id_Of;
2200
2201 -------------------------
2202 -- Set_Package_Node_Of --
2203 -------------------------
2204
2205 procedure Set_Package_Node_Of
2206 (Node : Project_Node_Id;
2207 To : Project_Node_Id)
2208 is
2209 begin
2210 pragma Assert
2211 (Node /= Empty_Node
2212 and then
2213 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
2214 or else
2215 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
2216 Project_Nodes.Table (Node).Field2 := To;
2217 end Set_Package_Node_Of;
2218
2219 ----------------------
2220 -- Set_Path_Name_Of --
2221 ----------------------
2222
2223 procedure Set_Path_Name_Of
2224 (Node : Project_Node_Id;
2225 To : Name_Id)
2226 is
2227 begin
2228 pragma Assert
2229 (Node /= Empty_Node
2230 and then
2231 (Project_Nodes.Table (Node).Kind = N_Project
2232 or else
2233 Project_Nodes.Table (Node).Kind = N_With_Clause));
2234 Project_Nodes.Table (Node).Path_Name := To;
2235 end Set_Path_Name_Of;
2236
2237 ---------------------------
2238 -- Set_Previous_End_Node --
2239 ---------------------------
2240 procedure Set_Previous_End_Node (To : Project_Node_Id) is
2241 begin
2242 Previous_End_Node := To;
2243 end Set_Previous_End_Node;
2244
2245 ----------------------------
2246 -- Set_Previous_Line_Node --
2247 ----------------------------
2248
2249 procedure Set_Previous_Line_Node (To : Project_Node_Id) is
2250 begin
2251 Previous_Line_Node := To;
2252 end Set_Previous_Line_Node;
2253
2254 --------------------------------
2255 -- Set_Project_Declaration_Of --
2256 --------------------------------
2257
2258 procedure Set_Project_Declaration_Of
2259 (Node : Project_Node_Id;
2260 To : Project_Node_Id)
2261 is
2262 begin
2263 pragma Assert
2264 (Node /= Empty_Node
2265 and then
2266 Project_Nodes.Table (Node).Kind = N_Project);
2267 Project_Nodes.Table (Node).Field2 := To;
2268 end Set_Project_Declaration_Of;
2269
2270 -----------------------------------------------
2271 -- Set_Project_File_Includes_Unkept_Comments --
2272 -----------------------------------------------
2273
2274 procedure Set_Project_File_Includes_Unkept_Comments
2275 (Node : Project_Node_Id;
2276 To : Boolean)
2277 is
2278 Declaration : constant Project_Node_Id := Project_Declaration_Of (Node);
2279 begin
2280 Project_Nodes.Table (Declaration).Flag1 := To;
2281 end Set_Project_File_Includes_Unkept_Comments;
2282
2283 -------------------------
2284 -- Set_Project_Node_Of --
2285 -------------------------
2286
2287 procedure Set_Project_Node_Of
2288 (Node : Project_Node_Id;
2289 To : Project_Node_Id;
2290 Limited_With : Boolean := False)
2291 is
2292 begin
2293 pragma Assert
2294 (Node /= Empty_Node
2295 and then
2296 (Project_Nodes.Table (Node).Kind = N_With_Clause
2297 or else
2298 Project_Nodes.Table (Node).Kind = N_Variable_Reference
2299 or else
2300 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
2301 Project_Nodes.Table (Node).Field1 := To;
2302
2303 if Project_Nodes.Table (Node).Kind = N_With_Clause
2304 and then not Limited_With
2305 then
2306 Project_Nodes.Table (Node).Field3 := To;
2307 end if;
2308 end Set_Project_Node_Of;
2309
2310 ---------------------------------------
2311 -- Set_Project_Of_Renamed_Package_Of --
2312 ---------------------------------------
2313
2314 procedure Set_Project_Of_Renamed_Package_Of
2315 (Node : Project_Node_Id;
2316 To : Project_Node_Id)
2317 is
2318 begin
2319 pragma Assert
2320 (Node /= Empty_Node
2321 and then
2322 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
2323 Project_Nodes.Table (Node).Field1 := To;
2324 end Set_Project_Of_Renamed_Package_Of;
2325
2326 ------------------------
2327 -- Set_String_Type_Of --
2328 ------------------------
2329
2330 procedure Set_String_Type_Of
2331 (Node : Project_Node_Id;
2332 To : Project_Node_Id)
2333 is
2334 begin
2335 pragma Assert
2336 (Node /= Empty_Node
2337 and then
2338 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
2339 or else
2340 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration)
2341 and then
2342 Project_Nodes.Table (To).Kind = N_String_Type_Declaration);
2343
2344 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
2345 Project_Nodes.Table (Node).Field3 := To;
2346 else
2347 Project_Nodes.Table (Node).Field2 := To;
2348 end if;
2349 end Set_String_Type_Of;
2350
2351 -------------------------
2352 -- Set_String_Value_Of --
2353 -------------------------
2354
2355 procedure Set_String_Value_Of
2356 (Node : Project_Node_Id;
2357 To : Name_Id)
2358 is
2359 begin
2360 pragma Assert
2361 (Node /= Empty_Node
2362 and then
2363 (Project_Nodes.Table (Node).Kind = N_With_Clause
2364 or else
2365 Project_Nodes.Table (Node).Kind = N_Comment
2366 or else
2367 Project_Nodes.Table (Node).Kind = N_Literal_String));
2368 Project_Nodes.Table (Node).Value := To;
2369 end Set_String_Value_Of;
2370
2371 --------------------
2372 -- String_Type_Of --
2373 --------------------
2374
2375 function String_Type_Of
2376 (Node : Project_Node_Id) return Project_Node_Id
2377 is
2378 begin
2379 pragma Assert
2380 (Node /= Empty_Node
2381 and then
2382 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
2383 or else
2384 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration));
2385
2386 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
2387 return Project_Nodes.Table (Node).Field3;
2388 else
2389 return Project_Nodes.Table (Node).Field2;
2390 end if;
2391 end String_Type_Of;
2392
2393 ---------------------
2394 -- String_Value_Of --
2395 ---------------------
2396
2397 function String_Value_Of (Node : Project_Node_Id) return Name_Id is
2398 begin
2399 pragma Assert
2400 (Node /= Empty_Node
2401 and then
2402 (Project_Nodes.Table (Node).Kind = N_With_Clause
2403 or else
2404 Project_Nodes.Table (Node).Kind = N_Comment
2405 or else
2406 Project_Nodes.Table (Node).Kind = N_Literal_String));
2407 return Project_Nodes.Table (Node).Value;
2408 end String_Value_Of;
2409
2410 --------------------
2411 -- Value_Is_Valid --
2412 --------------------
2413
2414 function Value_Is_Valid
2415 (For_Typed_Variable : Project_Node_Id;
2416 Value : Name_Id) return Boolean
2417 is
2418 begin
2419 pragma Assert
2420 (For_Typed_Variable /= Empty_Node
2421 and then
2422 (Project_Nodes.Table (For_Typed_Variable).Kind =
2423 N_Typed_Variable_Declaration));
2424
2425 declare
2426 Current_String : Project_Node_Id :=
2427 First_Literal_String
2428 (String_Type_Of (For_Typed_Variable));
2429
2430 begin
2431 while Current_String /= Empty_Node
2432 and then
2433 String_Value_Of (Current_String) /= Value
2434 loop
2435 Current_String :=
2436 Next_Literal_String (Current_String);
2437 end loop;
2438
2439 return Current_String /= Empty_Node;
2440 end;
2441
2442 end Value_Is_Valid;
2443
2444 -------------------------------
2445 -- There_Are_Unkept_Comments --
2446 -------------------------------
2447
2448 function There_Are_Unkept_Comments return Boolean is
2449 begin
2450 return Unkept_Comments;
2451 end There_Are_Unkept_Comments;
2452
2453
2454 end Prj.Tree;