1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2004 Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
29 package body Prj.Tree is
31 Node_With_Comments : constant array (Project_Node_Kind) of Boolean :=
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,
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,
50 N_Comment_Zones => True,
52 -- Indicates the kinds of node that may have associated comments
54 package Next_End_Nodes is new Table.Table
55 (Table_Component_Type => Project_Node_Id,
56 Table_Index_Type => Natural,
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
63 use Tree_Private_Part;
65 End_Of_Line_Node : Project_Node_Id := Empty_Node;
66 -- The node an end of line comment may be associated with
68 Previous_Line_Node : Project_Node_Id := Empty_Node;
69 -- The node an immediately following comment may be associated with
71 Previous_End_Node : Project_Node_Id := Empty_Node;
72 -- The node comments immediately following an "end" line may be
75 Unkept_Comments : Boolean := False;
76 -- Set to True when some comments may not be associated with any node
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.
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;
96 Project_Nodes.Table (To).Kind /= N_Comment);
98 Zone := Project_Nodes.Table (To).Comments;
100 if Zone = Empty_Node then
102 -- Create new N_Comment_Zones node
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,
114 Path_Name => No_Name,
116 Field1 => Empty_Node,
117 Field2 => Empty_Node,
118 Field3 => Empty_Node,
121 Comments => Empty_Node);
123 Zone := Project_Nodes.Last;
124 Project_Nodes.Table (To).Comments := Zone;
127 if Where = End_Of_Line then
128 Project_Nodes.Table (Zone).Value := Comments.Table (1).Value;
131 -- Get each comments in the Comments table and link them to node To
133 for J in 1 .. Comments.Last loop
135 -- Create new N_Comment node
137 if (Where = After or else Where = After_End) and then
138 Token /= Tok_EOF and then
139 Comments.Table (J).Follows_Empty_Line
141 Comments.Table (1 .. Comments.Last - J + 1) :=
142 Comments.Table (J .. Comments.Last);
143 Comments.Set_Last (Comments.Last - J + 1);
147 Project_Nodes.Increment_Last;
148 Project_Nodes.Table (Project_Nodes.Last) :=
150 Expr_Kind => Undefined,
151 Flag1 => Comments.Table (J).Follows_Empty_Line,
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,
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);
167 -- If this is the first comment, put it in the right field of
170 if Previous = Empty_Node then
173 Project_Nodes.Table (Zone).Field1 := Project_Nodes.Last;
176 Project_Nodes.Table (Zone).Field2 := Project_Nodes.Last;
179 Project_Nodes.Table (Zone).Field3 := Project_Nodes.Last;
182 Project_Nodes.Table (Zone).Comments := Project_Nodes.Last;
189 -- When it is not the first, link it to the previous one
191 Project_Nodes.Table (Previous).Comments := Project_Nodes.Last;
194 -- This node becomes the previous one for the next comment, if
197 Previous := Project_Nodes.Last;
201 -- Empty the Comments table, so that there is no risk to link the same
202 -- comments to another node.
204 Comments.Set_Last (0);
208 --------------------------------
209 -- Associative_Array_Index_Of --
210 --------------------------------
212 function Associative_Array_Index_Of
213 (Node : Project_Node_Id) return Name_Id
219 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
221 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
222 return Project_Nodes.Table (Node).Value;
223 end Associative_Array_Index_Of;
225 ----------------------------
226 -- Associative_Package_Of --
227 ----------------------------
229 function Associative_Package_Of
230 (Node : Project_Node_Id) return Project_Node_Id
236 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
237 return Project_Nodes.Table (Node).Field3;
238 end Associative_Package_Of;
240 ----------------------------
241 -- Associative_Project_Of --
242 ----------------------------
244 function Associative_Project_Of
245 (Node : Project_Node_Id) return Project_Node_Id
251 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
252 return Project_Nodes.Table (Node).Field2;
253 end Associative_Project_Of;
255 ----------------------
256 -- Case_Insensitive --
257 ----------------------
259 function Case_Insensitive (Node : Project_Node_Id) return Boolean is
264 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
266 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
267 return Project_Nodes.Table (Node).Flag1;
268 end Case_Insensitive;
270 --------------------------------
271 -- Case_Variable_Reference_Of --
272 --------------------------------
274 function Case_Variable_Reference_Of
275 (Node : Project_Node_Id) return Project_Node_Id
281 Project_Nodes.Table (Node).Kind = N_Case_Construction);
282 return Project_Nodes.Table (Node).Field1;
283 end Case_Variable_Reference_Of;
285 ----------------------
286 -- Comment_Zones_Of --
287 ----------------------
289 function Comment_Zones_Of
290 (Node : Project_Node_Id) return Project_Node_Id
292 Zone : Project_Node_Id;
295 pragma Assert (Node /= Empty_Node);
296 Zone := Project_Nodes.Table (Node).Comments;
298 -- If there is not already an N_Comment_Zones associated, create a new
299 -- one and associate it with node Node.
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,
313 Path_Name => No_Name,
315 Field1 => Empty_Node,
316 Field2 => Empty_Node,
317 Field3 => Empty_Node,
320 Comments => Empty_Node);
321 Project_Nodes.Table (Node).Comments := Zone;
325 end Comment_Zones_Of;
327 -----------------------
328 -- Current_Item_Node --
329 -----------------------
331 function Current_Item_Node
332 (Node : Project_Node_Id) return Project_Node_Id
338 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
339 return Project_Nodes.Table (Node).Field1;
340 end Current_Item_Node;
346 function Current_Term
347 (Node : Project_Node_Id) return Project_Node_Id
353 Project_Nodes.Table (Node).Kind = N_Term);
354 return Project_Nodes.Table (Node).Field1;
357 --------------------------
358 -- Default_Project_Node --
359 --------------------------
361 function Default_Project_Node
362 (Of_Kind : Project_Node_Kind;
363 And_Expr_Kind : Variable_Kind := Undefined) return Project_Node_Id
365 Result : Project_Node_Id;
366 Zone : Project_Node_Id;
367 Previous : Project_Node_Id;
370 -- Create new node with specified kind and expression kind
372 Project_Nodes.Increment_Last;
373 Project_Nodes.Table (Project_Nodes.Last) :=
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,
382 Path_Name => No_Name,
384 Field1 => Empty_Node,
385 Field2 => Empty_Node,
386 Field3 => Empty_Node,
389 Comments => Empty_Node);
391 -- Save the new node for the returned value
393 Result := Project_Nodes.Last;
395 if Comments.Last > 0 then
397 -- If this is not a node with comments, then set the flag
399 if not Node_With_Comments (Of_Kind) then
400 Unkept_Comments := True;
402 elsif Of_Kind /= N_Comment and then Of_Kind /= N_Comment_Zones then
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,
414 Path_Name => No_Name,
416 Field1 => Empty_Node,
417 Field2 => Empty_Node,
418 Field3 => Empty_Node,
421 Comments => Empty_Node);
423 Zone := Project_Nodes.Last;
424 Project_Nodes.Table (Result).Comments := Zone;
425 Previous := Empty_Node;
427 for J in 1 .. Comments.Last loop
429 -- Create a new N_Comment node
431 Project_Nodes.Increment_Last;
432 Project_Nodes.Table (Project_Nodes.Last) :=
434 Expr_Kind => Undefined,
435 Flag1 => Comments.Table (J).Follows_Empty_Line,
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,
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);
451 -- Link it to the N_Comment_Zones node, if it is the first,
452 -- otherwise to the previous one.
454 if Previous = Empty_Node then
455 Project_Nodes.Table (Zone).Field1 := Project_Nodes.Last;
458 Project_Nodes.Table (Previous).Comments :=
462 -- This new node will be the previous one for the next
463 -- N_Comment node, if there is one.
465 Previous := Project_Nodes.Last;
468 -- Empty the Comments table after all comments have been processed
470 Comments.Set_Last (0);
475 end Default_Project_Node;
481 function Directory_Of (Node : Project_Node_Id) return Name_Id is
486 Project_Nodes.Table (Node).Kind = N_Project);
487 return Project_Nodes.Table (Node).Directory;
490 -------------------------
491 -- End_Of_Line_Comment --
492 -------------------------
494 function End_Of_Line_Comment (Node : Project_Node_Id) return Name_Id is
495 Zone : Project_Node_Id := Empty_Node;
498 pragma Assert (Node /= Empty_Node);
499 Zone := Project_Nodes.Table (Node).Comments;
501 if Zone = Empty_Node then
504 return Project_Nodes.Table (Zone).Value;
506 end End_Of_Line_Comment;
508 ------------------------
509 -- Expression_Kind_Of --
510 ------------------------
512 function Expression_Kind_Of (Node : Project_Node_Id) return Variable_Kind is
517 (Project_Nodes.Table (Node).Kind = N_Literal_String
519 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
521 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
523 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
525 Project_Nodes.Table (Node).Kind = N_Package_Declaration
527 Project_Nodes.Table (Node).Kind = N_Expression
529 Project_Nodes.Table (Node).Kind = N_Term
531 Project_Nodes.Table (Node).Kind = N_Variable_Reference
533 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
535 return Project_Nodes.Table (Node).Expr_Kind;
536 end Expression_Kind_Of;
542 function Expression_Of
543 (Node : Project_Node_Id) return Project_Node_Id
549 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
551 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
553 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
555 return Project_Nodes.Table (Node).Field1;
558 -------------------------
559 -- Extended_Project_Of --
560 -------------------------
562 function Extended_Project_Of
563 (Node : Project_Node_Id) return Project_Node_Id
569 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
570 return Project_Nodes.Table (Node).Field2;
571 end Extended_Project_Of;
573 ------------------------------
574 -- Extended_Project_Path_Of --
575 ------------------------------
577 function Extended_Project_Path_Of
578 (Node : Project_Node_Id) return Name_Id
584 Project_Nodes.Table (Node).Kind = N_Project);
585 return Project_Nodes.Table (Node).Value;
586 end Extended_Project_Path_Of;
588 --------------------------
589 -- Extending_Project_Of --
590 --------------------------
591 function Extending_Project_Of
592 (Node : Project_Node_Id) return Project_Node_Id
598 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
599 return Project_Nodes.Table (Node).Field3;
600 end Extending_Project_Of;
602 ---------------------------
603 -- External_Reference_Of --
604 ---------------------------
606 function External_Reference_Of
607 (Node : Project_Node_Id) return Project_Node_Id
613 Project_Nodes.Table (Node).Kind = N_External_Value);
614 return Project_Nodes.Table (Node).Field1;
615 end External_Reference_Of;
617 -------------------------
618 -- External_Default_Of --
619 -------------------------
621 function External_Default_Of
622 (Node : Project_Node_Id)
623 return Project_Node_Id
629 Project_Nodes.Table (Node).Kind = N_External_Value);
630 return Project_Nodes.Table (Node).Field2;
631 end External_Default_Of;
633 ------------------------
634 -- First_Case_Item_Of --
635 ------------------------
637 function First_Case_Item_Of
638 (Node : Project_Node_Id) return Project_Node_Id
644 Project_Nodes.Table (Node).Kind = N_Case_Construction);
645 return Project_Nodes.Table (Node).Field2;
646 end First_Case_Item_Of;
648 ---------------------
649 -- First_Choice_Of --
650 ---------------------
652 function First_Choice_Of
653 (Node : Project_Node_Id)
654 return Project_Node_Id
660 Project_Nodes.Table (Node).Kind = N_Case_Item);
661 return Project_Nodes.Table (Node).Field1;
664 -------------------------
665 -- First_Comment_After --
666 -------------------------
668 function First_Comment_After
669 (Node : Project_Node_Id) return Project_Node_Id
671 Zone : Project_Node_Id := Empty_Node;
673 pragma Assert (Node /= Empty_Node);
674 Zone := Project_Nodes.Table (Node).Comments;
676 if Zone = Empty_Node then
680 return Project_Nodes.Table (Zone).Field2;
682 end First_Comment_After;
684 -----------------------------
685 -- First_Comment_After_End --
686 -----------------------------
688 function First_Comment_After_End
689 (Node : Project_Node_Id)
690 return Project_Node_Id
692 Zone : Project_Node_Id := Empty_Node;
695 pragma Assert (Node /= Empty_Node);
696 Zone := Project_Nodes.Table (Node).Comments;
698 if Zone = Empty_Node then
702 return Project_Nodes.Table (Zone).Comments;
704 end First_Comment_After_End;
706 --------------------------
707 -- First_Comment_Before --
708 --------------------------
710 function First_Comment_Before
711 (Node : Project_Node_Id) return Project_Node_Id
713 Zone : Project_Node_Id := Empty_Node;
716 pragma Assert (Node /= Empty_Node);
717 Zone := Project_Nodes.Table (Node).Comments;
719 if Zone = Empty_Node then
723 return Project_Nodes.Table (Zone).Field1;
725 end First_Comment_Before;
727 ------------------------------
728 -- First_Comment_Before_End --
729 ------------------------------
731 function First_Comment_Before_End
732 (Node : Project_Node_Id) return Project_Node_Id
734 Zone : Project_Node_Id := Empty_Node;
737 pragma Assert (Node /= Empty_Node);
738 Zone := Project_Nodes.Table (Node).Comments;
740 if Zone = Empty_Node then
744 return Project_Nodes.Table (Zone).Field3;
746 end First_Comment_Before_End;
748 -------------------------------
749 -- First_Declarative_Item_Of --
750 -------------------------------
752 function First_Declarative_Item_Of
753 (Node : Project_Node_Id) return Project_Node_Id
759 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
761 Project_Nodes.Table (Node).Kind = N_Case_Item
763 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
765 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
766 return Project_Nodes.Table (Node).Field1;
768 return Project_Nodes.Table (Node).Field2;
770 end First_Declarative_Item_Of;
772 ------------------------------
773 -- First_Expression_In_List --
774 ------------------------------
776 function First_Expression_In_List
777 (Node : Project_Node_Id) return Project_Node_Id
783 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
784 return Project_Nodes.Table (Node).Field1;
785 end First_Expression_In_List;
787 --------------------------
788 -- First_Literal_String --
789 --------------------------
791 function First_Literal_String
792 (Node : Project_Node_Id) return Project_Node_Id
798 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
799 return Project_Nodes.Table (Node).Field1;
800 end First_Literal_String;
802 ----------------------
803 -- First_Package_Of --
804 ----------------------
806 function First_Package_Of
807 (Node : Project_Node_Id) return Package_Declaration_Id
813 Project_Nodes.Table (Node).Kind = N_Project);
814 return Project_Nodes.Table (Node).Packages;
815 end First_Package_Of;
817 --------------------------
818 -- First_String_Type_Of --
819 --------------------------
821 function First_String_Type_Of
822 (Node : Project_Node_Id) return Project_Node_Id
828 Project_Nodes.Table (Node).Kind = N_Project);
829 return Project_Nodes.Table (Node).Field3;
830 end First_String_Type_Of;
837 (Node : Project_Node_Id) return Project_Node_Id
843 Project_Nodes.Table (Node).Kind = N_Expression);
844 return Project_Nodes.Table (Node).Field1;
847 -----------------------
848 -- First_Variable_Of --
849 -----------------------
851 function First_Variable_Of
852 (Node : Project_Node_Id) return Variable_Node_Id
858 (Project_Nodes.Table (Node).Kind = N_Project
860 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
862 return Project_Nodes.Table (Node).Variables;
863 end First_Variable_Of;
865 --------------------------
866 -- First_With_Clause_Of --
867 --------------------------
869 function First_With_Clause_Of
870 (Node : Project_Node_Id) return Project_Node_Id
876 Project_Nodes.Table (Node).Kind = N_Project);
877 return Project_Nodes.Table (Node).Field1;
878 end First_With_Clause_Of;
880 ------------------------
881 -- Follows_Empty_Line --
882 ------------------------
884 function Follows_Empty_Line (Node : Project_Node_Id) return Boolean is
889 Project_Nodes.Table (Node).Kind = N_Comment);
890 return Project_Nodes.Table (Node).Flag1;
891 end Follows_Empty_Line;
897 function Hash (N : Project_Node_Id) return Header_Num is
899 return Header_Num (N mod Project_Node_Id (Header_Num'Last));
906 procedure Initialize is
908 Project_Nodes.Set_Last (Empty_Node);
909 Projects_Htable.Reset;
912 -------------------------------
913 -- Is_Followed_By_Empty_Line --
914 -------------------------------
916 function Is_Followed_By_Empty_Line
917 (Node : Project_Node_Id) return Boolean
923 Project_Nodes.Table (Node).Kind = N_Comment);
924 return Project_Nodes.Table (Node).Flag2;
925 end Is_Followed_By_Empty_Line;
927 ----------------------
928 -- Is_Extending_All --
929 ----------------------
931 function Is_Extending_All (Node : Project_Node_Id) return Boolean is
936 (Project_Nodes.Table (Node).Kind = N_Project
938 Project_Nodes.Table (Node).Kind = N_With_Clause));
939 return Project_Nodes.Table (Node).Flag2;
940 end Is_Extending_All;
942 -------------------------------------
943 -- Imported_Or_Extended_Project_Of --
944 -------------------------------------
946 function Imported_Or_Extended_Project_Of
947 (Project : Project_Node_Id;
948 With_Name : Name_Id) return Project_Node_Id
950 With_Clause : Project_Node_Id := First_With_Clause_Of (Project);
951 Result : Project_Node_Id := Empty_Node;
954 -- First check all the imported projects
956 while With_Clause /= Empty_Node loop
958 -- Only non limited imported project may be used as prefix
959 -- of variable or attributes.
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);
966 -- If it is not an imported project, it might be the imported project
968 if With_Clause = Empty_Node then
969 Result := Extended_Project_Of (Project_Declaration_Of (Project));
971 if Result /= Empty_Node
972 and then Name_Of (Result) /= With_Name
974 Result := Empty_Node;
979 end Imported_Or_Extended_Project_Of;
985 function Kind_Of (Node : Project_Node_Id) return Project_Node_Kind is
987 pragma Assert (Node /= Empty_Node);
988 return Project_Nodes.Table (Node).Kind;
995 function Location_Of (Node : Project_Node_Id) return Source_Ptr is
997 pragma Assert (Node /= Empty_Node);
998 return Project_Nodes.Table (Node).Location;
1005 function Name_Of (Node : Project_Node_Id) return Name_Id is
1007 pragma Assert (Node /= Empty_Node);
1008 return Project_Nodes.Table (Node).Name;
1011 --------------------
1012 -- Next_Case_Item --
1013 --------------------
1015 function Next_Case_Item
1016 (Node : Project_Node_Id) return Project_Node_Id
1022 Project_Nodes.Table (Node).Kind = N_Case_Item);
1023 return Project_Nodes.Table (Node).Field3;
1030 function Next_Comment (Node : Project_Node_Id) return Project_Node_Id is
1035 Project_Nodes.Table (Node).Kind = N_Comment);
1036 return Project_Nodes.Table (Node).Comments;
1039 ---------------------------
1040 -- Next_Declarative_Item --
1041 ---------------------------
1043 function Next_Declarative_Item
1044 (Node : Project_Node_Id) return Project_Node_Id
1050 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
1051 return Project_Nodes.Table (Node).Field2;
1052 end Next_Declarative_Item;
1054 -----------------------------
1055 -- Next_Expression_In_List --
1056 -----------------------------
1058 function Next_Expression_In_List
1059 (Node : Project_Node_Id) return Project_Node_Id
1065 Project_Nodes.Table (Node).Kind = N_Expression);
1066 return Project_Nodes.Table (Node).Field2;
1067 end Next_Expression_In_List;
1069 -------------------------
1070 -- Next_Literal_String --
1071 -------------------------
1073 function Next_Literal_String
1074 (Node : Project_Node_Id)
1075 return Project_Node_Id
1081 Project_Nodes.Table (Node).Kind = N_Literal_String);
1082 return Project_Nodes.Table (Node).Field1;
1083 end Next_Literal_String;
1085 -----------------------------
1086 -- Next_Package_In_Project --
1087 -----------------------------
1089 function Next_Package_In_Project
1090 (Node : Project_Node_Id) return Project_Node_Id
1096 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1097 return Project_Nodes.Table (Node).Field3;
1098 end Next_Package_In_Project;
1100 ----------------------
1101 -- Next_String_Type --
1102 ----------------------
1104 function Next_String_Type
1105 (Node : Project_Node_Id)
1106 return Project_Node_Id
1112 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1113 return Project_Nodes.Table (Node).Field2;
1114 end Next_String_Type;
1121 (Node : Project_Node_Id) return Project_Node_Id
1127 Project_Nodes.Table (Node).Kind = N_Term);
1128 return Project_Nodes.Table (Node).Field2;
1135 function Next_Variable
1136 (Node : Project_Node_Id)
1137 return Project_Node_Id
1143 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1145 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1147 return Project_Nodes.Table (Node).Field3;
1150 -------------------------
1151 -- Next_With_Clause_Of --
1152 -------------------------
1154 function Next_With_Clause_Of
1155 (Node : Project_Node_Id) return Project_Node_Id
1161 Project_Nodes.Table (Node).Kind = N_With_Clause);
1162 return Project_Nodes.Table (Node).Field2;
1163 end Next_With_Clause_Of;
1165 ---------------------------------
1166 -- Non_Limited_Project_Node_Of --
1167 ---------------------------------
1169 function Non_Limited_Project_Node_Of
1170 (Node : Project_Node_Id) return Project_Node_Id
1176 (Project_Nodes.Table (Node).Kind = N_With_Clause));
1177 return Project_Nodes.Table (Node).Field3;
1178 end Non_Limited_Project_Node_Of;
1184 function Package_Id_Of (Node : Project_Node_Id) return Package_Node_Id is
1189 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1190 return Project_Nodes.Table (Node).Pkg_Id;
1193 ---------------------
1194 -- Package_Node_Of --
1195 ---------------------
1197 function Package_Node_Of
1198 (Node : Project_Node_Id) return Project_Node_Id
1204 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
1206 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1207 return Project_Nodes.Table (Node).Field2;
1208 end Package_Node_Of;
1214 function Path_Name_Of (Node : Project_Node_Id) return Name_Id is
1219 (Project_Nodes.Table (Node).Kind = N_Project
1221 Project_Nodes.Table (Node).Kind = N_With_Clause));
1222 return Project_Nodes.Table (Node).Path_Name;
1225 ----------------------------
1226 -- Project_Declaration_Of --
1227 ----------------------------
1229 function Project_Declaration_Of
1230 (Node : Project_Node_Id) return Project_Node_Id
1236 Project_Nodes.Table (Node).Kind = N_Project);
1237 return Project_Nodes.Table (Node).Field2;
1238 end Project_Declaration_Of;
1240 -------------------------------------------
1241 -- Project_File_Includes_Unkept_Comments --
1242 -------------------------------------------
1244 function Project_File_Includes_Unkept_Comments
1245 (Node : Project_Node_Id) return Boolean
1247 Declaration : constant Project_Node_Id := Project_Declaration_Of (Node);
1249 return Project_Nodes.Table (Declaration).Flag1;
1250 end Project_File_Includes_Unkept_Comments;
1252 ---------------------
1253 -- Project_Node_Of --
1254 ---------------------
1256 function Project_Node_Of
1257 (Node : Project_Node_Id) return Project_Node_Id
1263 (Project_Nodes.Table (Node).Kind = N_With_Clause
1265 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1267 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1268 return Project_Nodes.Table (Node).Field1;
1269 end Project_Node_Of;
1271 -----------------------------------
1272 -- Project_Of_Renamed_Package_Of --
1273 -----------------------------------
1275 function Project_Of_Renamed_Package_Of
1276 (Node : Project_Node_Id) return Project_Node_Id
1282 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
1283 return Project_Nodes.Table (Node).Field1;
1284 end Project_Of_Renamed_Package_Of;
1286 --------------------------
1287 -- Remove_Next_End_Node --
1288 --------------------------
1290 procedure Remove_Next_End_Node is
1292 Next_End_Nodes.Decrement_Last;
1293 end Remove_Next_End_Node;
1299 procedure Reset_State is
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);
1312 procedure Restore (S : in Comment_State) is
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;
1320 Comments.Set_Last (0);
1322 for J in S.Comments'Range loop
1323 Comments.Increment_Last;
1324 Comments.Table (Comments.Last) := S.Comments (J);
1332 procedure Save (S : out Comment_State) is
1333 Cmts : constant Comments_Ptr := new Comment_Array (1 .. Comments.Last);
1336 for J in 1 .. Comments.Last loop
1337 Cmts (J) := Comments.Table (J);
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,
1353 Empty_Line : Boolean := False;
1355 -- If there are comments, then they will not be kept. Set the flag and
1356 -- clear the comments.
1358 if Comments.Last > 0 then
1359 Unkept_Comments := True;
1360 Comments.Set_Last (0);
1363 -- Loop until a token other that End_Of_Line or Comment is found
1366 Prj.Err.Scanner.Scan;
1369 when Tok_End_Of_Line =>
1370 if Prev_Token = Tok_End_Of_Line then
1373 if Comments.Last > 0 then
1374 Comments.Table (Comments.Last).Is_Followed_By_Empty_Line
1380 -- If this is a line comment, add it to the comment table
1382 if Prev_Token = Tok_End_Of_Line
1383 or else Prev_Token = No_Token
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);
1391 -- Otherwise, it is an end of line comment. If there is
1392 -- an end of line node specified, associate the comment with
1395 elsif End_Of_Line_Node /= Empty_Node then
1397 Zones : constant Project_Node_Id :=
1398 Comment_Zones_Of (End_Of_Line_Node);
1400 Project_Nodes.Table (Zones).Value := Comment_Id;
1403 -- Otherwise, this end of line node cannot be kept
1406 Unkept_Comments := True;
1407 Comments.Set_Last (0);
1410 Empty_Line := False;
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.
1418 if Comments.Last > 0 and then
1419 not Comments.Table (1).Follows_Empty_Line then
1420 if Previous_Line_Node /= Empty_Node then
1422 (To => Previous_Line_Node, Where => After);
1424 elsif Previous_End_Node /= Empty_Node then
1426 (To => Previous_End_Node, Where => After_End);
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
1435 if Comments.Last > 0 and then Token = Tok_End then
1436 if Next_End_Nodes.Last > 0 then
1438 (To => Next_End_Nodes.Table (Next_End_Nodes.Last),
1439 Where => Before_End);
1442 Unkept_Comments := True;
1445 Comments.Set_Last (0);
1448 -- Reset the End_Of_Line, Previous_Line and Previous_End nodes
1449 -- so that they are not used again.
1451 End_Of_Line_Node := Empty_Node;
1452 Previous_Line_Node := Empty_Node;
1453 Previous_End_Node := Empty_Node;
1462 ------------------------------------
1463 -- Set_Associative_Array_Index_Of --
1464 ------------------------------------
1466 procedure Set_Associative_Array_Index_Of
1467 (Node : Project_Node_Id;
1474 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1476 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1477 Project_Nodes.Table (Node).Value := To;
1478 end Set_Associative_Array_Index_Of;
1480 --------------------------------
1481 -- Set_Associative_Package_Of --
1482 --------------------------------
1484 procedure Set_Associative_Package_Of
1485 (Node : Project_Node_Id;
1486 To : Project_Node_Id)
1492 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration);
1493 Project_Nodes.Table (Node).Field3 := To;
1494 end Set_Associative_Package_Of;
1496 --------------------------------
1497 -- Set_Associative_Project_Of --
1498 --------------------------------
1500 procedure Set_Associative_Project_Of
1501 (Node : Project_Node_Id;
1502 To : Project_Node_Id)
1508 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration));
1509 Project_Nodes.Table (Node).Field2 := To;
1510 end Set_Associative_Project_Of;
1512 --------------------------
1513 -- Set_Case_Insensitive --
1514 --------------------------
1516 procedure Set_Case_Insensitive
1517 (Node : Project_Node_Id;
1524 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1526 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1527 Project_Nodes.Table (Node).Flag1 := To;
1528 end Set_Case_Insensitive;
1530 ------------------------------------
1531 -- Set_Case_Variable_Reference_Of --
1532 ------------------------------------
1534 procedure Set_Case_Variable_Reference_Of
1535 (Node : Project_Node_Id;
1536 To : Project_Node_Id)
1542 Project_Nodes.Table (Node).Kind = N_Case_Construction);
1543 Project_Nodes.Table (Node).Field1 := To;
1544 end Set_Case_Variable_Reference_Of;
1546 ---------------------------
1547 -- Set_Current_Item_Node --
1548 ---------------------------
1550 procedure Set_Current_Item_Node
1551 (Node : Project_Node_Id;
1552 To : Project_Node_Id)
1558 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
1559 Project_Nodes.Table (Node).Field1 := To;
1560 end Set_Current_Item_Node;
1562 ----------------------
1563 -- Set_Current_Term --
1564 ----------------------
1566 procedure Set_Current_Term
1567 (Node : Project_Node_Id;
1568 To : Project_Node_Id)
1574 Project_Nodes.Table (Node).Kind = N_Term);
1575 Project_Nodes.Table (Node).Field1 := To;
1576 end Set_Current_Term;
1578 ----------------------
1579 -- Set_Directory_Of --
1580 ----------------------
1582 procedure Set_Directory_Of
1583 (Node : Project_Node_Id;
1590 Project_Nodes.Table (Node).Kind = N_Project);
1591 Project_Nodes.Table (Node).Directory := To;
1592 end Set_Directory_Of;
1594 ---------------------
1595 -- Set_End_Of_Line --
1596 ---------------------
1598 procedure Set_End_Of_Line (To : Project_Node_Id) is
1600 End_Of_Line_Node := To;
1601 end Set_End_Of_Line;
1603 ----------------------------
1604 -- Set_Expression_Kind_Of --
1605 ----------------------------
1607 procedure Set_Expression_Kind_Of
1608 (Node : Project_Node_Id;
1615 (Project_Nodes.Table (Node).Kind = N_Literal_String
1617 Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1619 Project_Nodes.Table (Node).Kind = N_Variable_Declaration
1621 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1623 Project_Nodes.Table (Node).Kind = N_Package_Declaration
1625 Project_Nodes.Table (Node).Kind = N_Expression
1627 Project_Nodes.Table (Node).Kind = N_Term
1629 Project_Nodes.Table (Node).Kind = N_Variable_Reference
1631 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
1632 Project_Nodes.Table (Node).Expr_Kind := To;
1633 end Set_Expression_Kind_Of;
1635 -----------------------
1636 -- Set_Expression_Of --
1637 -----------------------
1639 procedure Set_Expression_Of
1640 (Node : Project_Node_Id;
1641 To : Project_Node_Id)
1647 (Project_Nodes.Table (Node).Kind = N_Attribute_Declaration
1649 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
1651 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
1652 Project_Nodes.Table (Node).Field1 := To;
1653 end Set_Expression_Of;
1655 -------------------------------
1656 -- Set_External_Reference_Of --
1657 -------------------------------
1659 procedure Set_External_Reference_Of
1660 (Node : Project_Node_Id;
1661 To : Project_Node_Id)
1667 Project_Nodes.Table (Node).Kind = N_External_Value);
1668 Project_Nodes.Table (Node).Field1 := To;
1669 end Set_External_Reference_Of;
1671 -----------------------------
1672 -- Set_External_Default_Of --
1673 -----------------------------
1675 procedure Set_External_Default_Of
1676 (Node : Project_Node_Id;
1677 To : Project_Node_Id)
1683 Project_Nodes.Table (Node).Kind = N_External_Value);
1684 Project_Nodes.Table (Node).Field2 := To;
1685 end Set_External_Default_Of;
1687 ----------------------------
1688 -- Set_First_Case_Item_Of --
1689 ----------------------------
1691 procedure Set_First_Case_Item_Of
1692 (Node : Project_Node_Id;
1693 To : Project_Node_Id)
1699 Project_Nodes.Table (Node).Kind = N_Case_Construction);
1700 Project_Nodes.Table (Node).Field2 := To;
1701 end Set_First_Case_Item_Of;
1703 -------------------------
1704 -- Set_First_Choice_Of --
1705 -------------------------
1707 procedure Set_First_Choice_Of
1708 (Node : Project_Node_Id;
1709 To : Project_Node_Id)
1715 Project_Nodes.Table (Node).Kind = N_Case_Item);
1716 Project_Nodes.Table (Node).Field1 := To;
1717 end Set_First_Choice_Of;
1719 -----------------------------
1720 -- Set_First_Comment_After --
1721 -----------------------------
1723 procedure Set_First_Comment_After
1724 (Node : Project_Node_Id;
1725 To : Project_Node_Id)
1727 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1729 Project_Nodes.Table (Zone).Field2 := To;
1730 end Set_First_Comment_After;
1732 ---------------------------------
1733 -- Set_First_Comment_After_End --
1734 ---------------------------------
1736 procedure Set_First_Comment_After_End
1737 (Node : Project_Node_Id;
1738 To : Project_Node_Id)
1740 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1742 Project_Nodes.Table (Zone).Comments := To;
1743 end Set_First_Comment_After_End;
1745 ------------------------------
1746 -- Set_First_Comment_Before --
1747 ------------------------------
1749 procedure Set_First_Comment_Before
1750 (Node : Project_Node_Id;
1751 To : Project_Node_Id)
1754 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1756 Project_Nodes.Table (Zone).Field1 := To;
1757 end Set_First_Comment_Before;
1759 ----------------------------------
1760 -- Set_First_Comment_Before_End --
1761 ----------------------------------
1763 procedure Set_First_Comment_Before_End
1764 (Node : Project_Node_Id;
1765 To : Project_Node_Id)
1767 Zone : constant Project_Node_Id := Comment_Zones_Of (Node);
1769 Project_Nodes.Table (Zone).Field2 := To;
1770 end Set_First_Comment_Before_End;
1772 ------------------------
1773 -- Set_Next_Case_Item --
1774 ------------------------
1776 procedure Set_Next_Case_Item
1777 (Node : Project_Node_Id;
1778 To : Project_Node_Id)
1784 Project_Nodes.Table (Node).Kind = N_Case_Item);
1785 Project_Nodes.Table (Node).Field3 := To;
1786 end Set_Next_Case_Item;
1788 ----------------------
1789 -- Set_Next_Comment --
1790 ----------------------
1792 procedure Set_Next_Comment
1793 (Node : Project_Node_Id;
1794 To : Project_Node_Id)
1800 Project_Nodes.Table (Node).Kind = N_Comment);
1801 Project_Nodes.Table (Node).Comments := To;
1802 end Set_Next_Comment;
1804 -----------------------------------
1805 -- Set_First_Declarative_Item_Of --
1806 -----------------------------------
1808 procedure Set_First_Declarative_Item_Of
1809 (Node : Project_Node_Id;
1810 To : Project_Node_Id)
1816 (Project_Nodes.Table (Node).Kind = N_Project_Declaration
1818 Project_Nodes.Table (Node).Kind = N_Case_Item
1820 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1822 if Project_Nodes.Table (Node).Kind = N_Project_Declaration then
1823 Project_Nodes.Table (Node).Field1 := To;
1825 Project_Nodes.Table (Node).Field2 := To;
1827 end Set_First_Declarative_Item_Of;
1829 ----------------------------------
1830 -- Set_First_Expression_In_List --
1831 ----------------------------------
1833 procedure Set_First_Expression_In_List
1834 (Node : Project_Node_Id;
1835 To : Project_Node_Id)
1841 Project_Nodes.Table (Node).Kind = N_Literal_String_List);
1842 Project_Nodes.Table (Node).Field1 := To;
1843 end Set_First_Expression_In_List;
1845 ------------------------------
1846 -- Set_First_Literal_String --
1847 ------------------------------
1849 procedure Set_First_Literal_String
1850 (Node : Project_Node_Id;
1851 To : Project_Node_Id)
1857 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
1858 Project_Nodes.Table (Node).Field1 := To;
1859 end Set_First_Literal_String;
1861 --------------------------
1862 -- Set_First_Package_Of --
1863 --------------------------
1865 procedure Set_First_Package_Of
1866 (Node : Project_Node_Id;
1867 To : Package_Declaration_Id)
1873 Project_Nodes.Table (Node).Kind = N_Project);
1874 Project_Nodes.Table (Node).Packages := To;
1875 end Set_First_Package_Of;
1877 ------------------------------
1878 -- Set_First_String_Type_Of --
1879 ------------------------------
1881 procedure Set_First_String_Type_Of
1882 (Node : Project_Node_Id;
1883 To : Project_Node_Id)
1889 Project_Nodes.Table (Node).Kind = N_Project);
1890 Project_Nodes.Table (Node).Field3 := To;
1891 end Set_First_String_Type_Of;
1893 --------------------
1894 -- Set_First_Term --
1895 --------------------
1897 procedure Set_First_Term
1898 (Node : Project_Node_Id;
1899 To : Project_Node_Id)
1905 Project_Nodes.Table (Node).Kind = N_Expression);
1906 Project_Nodes.Table (Node).Field1 := To;
1909 ---------------------------
1910 -- Set_First_Variable_Of --
1911 ---------------------------
1913 procedure Set_First_Variable_Of
1914 (Node : Project_Node_Id;
1915 To : Variable_Node_Id)
1921 (Project_Nodes.Table (Node).Kind = N_Project
1923 Project_Nodes.Table (Node).Kind = N_Package_Declaration));
1924 Project_Nodes.Table (Node).Variables := To;
1925 end Set_First_Variable_Of;
1927 ------------------------------
1928 -- Set_First_With_Clause_Of --
1929 ------------------------------
1931 procedure Set_First_With_Clause_Of
1932 (Node : Project_Node_Id;
1933 To : Project_Node_Id)
1939 Project_Nodes.Table (Node).Kind = N_Project);
1940 Project_Nodes.Table (Node).Field1 := To;
1941 end Set_First_With_Clause_Of;
1943 --------------------------
1944 -- Set_Is_Extending_All --
1945 --------------------------
1947 procedure Set_Is_Extending_All (Node : Project_Node_Id) is
1952 (Project_Nodes.Table (Node).Kind = N_Project
1954 Project_Nodes.Table (Node).Kind = N_With_Clause));
1955 Project_Nodes.Table (Node).Flag2 := True;
1956 end Set_Is_Extending_All;
1962 procedure Set_Kind_Of
1963 (Node : Project_Node_Id;
1964 To : Project_Node_Kind)
1967 pragma Assert (Node /= Empty_Node);
1968 Project_Nodes.Table (Node).Kind := To;
1971 ---------------------
1972 -- Set_Location_Of --
1973 ---------------------
1975 procedure Set_Location_Of
1976 (Node : Project_Node_Id;
1980 pragma Assert (Node /= Empty_Node);
1981 Project_Nodes.Table (Node).Location := To;
1982 end Set_Location_Of;
1984 -----------------------------
1985 -- Set_Extended_Project_Of --
1986 -----------------------------
1988 procedure Set_Extended_Project_Of
1989 (Node : Project_Node_Id;
1990 To : Project_Node_Id)
1996 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
1997 Project_Nodes.Table (Node).Field2 := To;
1998 end Set_Extended_Project_Of;
2000 ----------------------------------
2001 -- Set_Extended_Project_Path_Of --
2002 ----------------------------------
2004 procedure Set_Extended_Project_Path_Of
2005 (Node : Project_Node_Id;
2012 Project_Nodes.Table (Node).Kind = N_Project);
2013 Project_Nodes.Table (Node).Value := To;
2014 end Set_Extended_Project_Path_Of;
2016 ------------------------------
2017 -- Set_Extending_Project_Of --
2018 ------------------------------
2020 procedure Set_Extending_Project_Of
2021 (Node : Project_Node_Id;
2022 To : Project_Node_Id)
2028 Project_Nodes.Table (Node).Kind = N_Project_Declaration);
2029 Project_Nodes.Table (Node).Field3 := To;
2030 end Set_Extending_Project_Of;
2036 procedure Set_Name_Of
2037 (Node : Project_Node_Id;
2041 pragma Assert (Node /= Empty_Node);
2042 Project_Nodes.Table (Node).Name := To;
2045 -------------------------------
2046 -- Set_Next_Declarative_Item --
2047 -------------------------------
2049 procedure Set_Next_Declarative_Item
2050 (Node : Project_Node_Id;
2051 To : Project_Node_Id)
2057 Project_Nodes.Table (Node).Kind = N_Declarative_Item);
2058 Project_Nodes.Table (Node).Field2 := To;
2059 end Set_Next_Declarative_Item;
2061 -----------------------
2062 -- Set_Next_End_Node --
2063 -----------------------
2065 procedure Set_Next_End_Node (To : Project_Node_Id) is
2067 Next_End_Nodes.Increment_Last;
2068 Next_End_Nodes.Table (Next_End_Nodes.Last) := To;
2069 end Set_Next_End_Node;
2071 ---------------------------------
2072 -- Set_Next_Expression_In_List --
2073 ---------------------------------
2075 procedure Set_Next_Expression_In_List
2076 (Node : Project_Node_Id;
2077 To : Project_Node_Id)
2083 Project_Nodes.Table (Node).Kind = N_Expression);
2084 Project_Nodes.Table (Node).Field2 := To;
2085 end Set_Next_Expression_In_List;
2087 -----------------------------
2088 -- Set_Next_Literal_String --
2089 -----------------------------
2091 procedure Set_Next_Literal_String
2092 (Node : Project_Node_Id;
2093 To : Project_Node_Id)
2099 Project_Nodes.Table (Node).Kind = N_Literal_String);
2100 Project_Nodes.Table (Node).Field1 := To;
2101 end Set_Next_Literal_String;
2103 ---------------------------------
2104 -- Set_Next_Package_In_Project --
2105 ---------------------------------
2107 procedure Set_Next_Package_In_Project
2108 (Node : Project_Node_Id;
2109 To : Project_Node_Id)
2115 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
2116 Project_Nodes.Table (Node).Field3 := To;
2117 end Set_Next_Package_In_Project;
2119 --------------------------
2120 -- Set_Next_String_Type --
2121 --------------------------
2123 procedure Set_Next_String_Type
2124 (Node : Project_Node_Id;
2125 To : Project_Node_Id)
2131 Project_Nodes.Table (Node).Kind = N_String_Type_Declaration);
2132 Project_Nodes.Table (Node).Field2 := To;
2133 end Set_Next_String_Type;
2139 procedure Set_Next_Term
2140 (Node : Project_Node_Id;
2141 To : Project_Node_Id)
2147 Project_Nodes.Table (Node).Kind = N_Term);
2148 Project_Nodes.Table (Node).Field2 := To;
2151 -----------------------
2152 -- Set_Next_Variable --
2153 -----------------------
2155 procedure Set_Next_Variable
2156 (Node : Project_Node_Id;
2157 To : Project_Node_Id)
2163 (Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration
2165 Project_Nodes.Table (Node).Kind = N_Variable_Declaration));
2166 Project_Nodes.Table (Node).Field3 := To;
2167 end Set_Next_Variable;
2169 -----------------------------
2170 -- Set_Next_With_Clause_Of --
2171 -----------------------------
2173 procedure Set_Next_With_Clause_Of
2174 (Node : Project_Node_Id;
2175 To : Project_Node_Id)
2181 Project_Nodes.Table (Node).Kind = N_With_Clause);
2182 Project_Nodes.Table (Node).Field2 := To;
2183 end Set_Next_With_Clause_Of;
2185 -----------------------
2186 -- Set_Package_Id_Of --
2187 -----------------------
2189 procedure Set_Package_Id_Of
2190 (Node : Project_Node_Id;
2191 To : Package_Node_Id)
2197 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
2198 Project_Nodes.Table (Node).Pkg_Id := To;
2199 end Set_Package_Id_Of;
2201 -------------------------
2202 -- Set_Package_Node_Of --
2203 -------------------------
2205 procedure Set_Package_Node_Of
2206 (Node : Project_Node_Id;
2207 To : Project_Node_Id)
2213 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
2215 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
2216 Project_Nodes.Table (Node).Field2 := To;
2217 end Set_Package_Node_Of;
2219 ----------------------
2220 -- Set_Path_Name_Of --
2221 ----------------------
2223 procedure Set_Path_Name_Of
2224 (Node : Project_Node_Id;
2231 (Project_Nodes.Table (Node).Kind = N_Project
2233 Project_Nodes.Table (Node).Kind = N_With_Clause));
2234 Project_Nodes.Table (Node).Path_Name := To;
2235 end Set_Path_Name_Of;
2237 ---------------------------
2238 -- Set_Previous_End_Node --
2239 ---------------------------
2240 procedure Set_Previous_End_Node (To : Project_Node_Id) is
2242 Previous_End_Node := To;
2243 end Set_Previous_End_Node;
2245 ----------------------------
2246 -- Set_Previous_Line_Node --
2247 ----------------------------
2249 procedure Set_Previous_Line_Node (To : Project_Node_Id) is
2251 Previous_Line_Node := To;
2252 end Set_Previous_Line_Node;
2254 --------------------------------
2255 -- Set_Project_Declaration_Of --
2256 --------------------------------
2258 procedure Set_Project_Declaration_Of
2259 (Node : Project_Node_Id;
2260 To : Project_Node_Id)
2266 Project_Nodes.Table (Node).Kind = N_Project);
2267 Project_Nodes.Table (Node).Field2 := To;
2268 end Set_Project_Declaration_Of;
2270 -----------------------------------------------
2271 -- Set_Project_File_Includes_Unkept_Comments --
2272 -----------------------------------------------
2274 procedure Set_Project_File_Includes_Unkept_Comments
2275 (Node : Project_Node_Id;
2278 Declaration : constant Project_Node_Id := Project_Declaration_Of (Node);
2280 Project_Nodes.Table (Declaration).Flag1 := To;
2281 end Set_Project_File_Includes_Unkept_Comments;
2283 -------------------------
2284 -- Set_Project_Node_Of --
2285 -------------------------
2287 procedure Set_Project_Node_Of
2288 (Node : Project_Node_Id;
2289 To : Project_Node_Id;
2290 Limited_With : Boolean := False)
2296 (Project_Nodes.Table (Node).Kind = N_With_Clause
2298 Project_Nodes.Table (Node).Kind = N_Variable_Reference
2300 Project_Nodes.Table (Node).Kind = N_Attribute_Reference));
2301 Project_Nodes.Table (Node).Field1 := To;
2303 if Project_Nodes.Table (Node).Kind = N_With_Clause
2304 and then not Limited_With
2306 Project_Nodes.Table (Node).Field3 := To;
2308 end Set_Project_Node_Of;
2310 ---------------------------------------
2311 -- Set_Project_Of_Renamed_Package_Of --
2312 ---------------------------------------
2314 procedure Set_Project_Of_Renamed_Package_Of
2315 (Node : Project_Node_Id;
2316 To : Project_Node_Id)
2322 Project_Nodes.Table (Node).Kind = N_Package_Declaration);
2323 Project_Nodes.Table (Node).Field1 := To;
2324 end Set_Project_Of_Renamed_Package_Of;
2326 ------------------------
2327 -- Set_String_Type_Of --
2328 ------------------------
2330 procedure Set_String_Type_Of
2331 (Node : Project_Node_Id;
2332 To : Project_Node_Id)
2338 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
2340 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration)
2342 Project_Nodes.Table (To).Kind = N_String_Type_Declaration);
2344 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
2345 Project_Nodes.Table (Node).Field3 := To;
2347 Project_Nodes.Table (Node).Field2 := To;
2349 end Set_String_Type_Of;
2351 -------------------------
2352 -- Set_String_Value_Of --
2353 -------------------------
2355 procedure Set_String_Value_Of
2356 (Node : Project_Node_Id;
2363 (Project_Nodes.Table (Node).Kind = N_With_Clause
2365 Project_Nodes.Table (Node).Kind = N_Comment
2367 Project_Nodes.Table (Node).Kind = N_Literal_String));
2368 Project_Nodes.Table (Node).Value := To;
2369 end Set_String_Value_Of;
2371 --------------------
2372 -- String_Type_Of --
2373 --------------------
2375 function String_Type_Of
2376 (Node : Project_Node_Id) return Project_Node_Id
2382 (Project_Nodes.Table (Node).Kind = N_Variable_Reference
2384 Project_Nodes.Table (Node).Kind = N_Typed_Variable_Declaration));
2386 if Project_Nodes.Table (Node).Kind = N_Variable_Reference then
2387 return Project_Nodes.Table (Node).Field3;
2389 return Project_Nodes.Table (Node).Field2;
2393 ---------------------
2394 -- String_Value_Of --
2395 ---------------------
2397 function String_Value_Of (Node : Project_Node_Id) return Name_Id is
2402 (Project_Nodes.Table (Node).Kind = N_With_Clause
2404 Project_Nodes.Table (Node).Kind = N_Comment
2406 Project_Nodes.Table (Node).Kind = N_Literal_String));
2407 return Project_Nodes.Table (Node).Value;
2408 end String_Value_Of;
2410 --------------------
2411 -- Value_Is_Valid --
2412 --------------------
2414 function Value_Is_Valid
2415 (For_Typed_Variable : Project_Node_Id;
2416 Value : Name_Id) return Boolean
2420 (For_Typed_Variable /= Empty_Node
2422 (Project_Nodes.Table (For_Typed_Variable).Kind =
2423 N_Typed_Variable_Declaration));
2426 Current_String : Project_Node_Id :=
2427 First_Literal_String
2428 (String_Type_Of (For_Typed_Variable));
2431 while Current_String /= Empty_Node
2433 String_Value_Of (Current_String) /= Value
2436 Next_Literal_String (Current_String);
2439 return Current_String /= Empty_Node;
2444 -------------------------------
2445 -- There_Are_Unkept_Comments --
2446 -------------------------------
2448 function There_Are_Unkept_Comments return Boolean is
2450 return Unkept_Comments;
2451 end There_Are_Unkept_Comments;