1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2009, 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 3, 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 COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Osint
; use Osint
;
29 with Ada
.Unchecked_Deallocation
;
31 package body Prj
.Tree
is
33 Node_With_Comments
: constant array (Project_Node_Kind
) of Boolean :=
35 N_With_Clause
=> True,
36 N_Project_Declaration
=> False,
37 N_Declarative_Item
=> False,
38 N_Package_Declaration
=> True,
39 N_String_Type_Declaration
=> True,
40 N_Literal_String
=> False,
41 N_Attribute_Declaration
=> True,
42 N_Typed_Variable_Declaration
=> True,
43 N_Variable_Declaration
=> True,
44 N_Expression
=> False,
46 N_Literal_String_List
=> False,
47 N_Variable_Reference
=> False,
48 N_External_Value
=> False,
49 N_Attribute_Reference
=> False,
50 N_Case_Construction
=> True,
52 N_Comment_Zones
=> True,
54 -- Indicates the kinds of node that may have associated comments
56 package Next_End_Nodes
is new Table
.Table
57 (Table_Component_Type
=> Project_Node_Id
,
58 Table_Index_Type
=> Natural,
61 Table_Increment
=> 100,
62 Table_Name
=> "Next_End_Nodes");
63 -- A stack of nodes to indicates to what node the next "end" is associated
65 use Tree_Private_Part
;
67 End_Of_Line_Node
: Project_Node_Id
:= Empty_Node
;
68 -- The node an end of line comment may be associated with
70 Previous_Line_Node
: Project_Node_Id
:= Empty_Node
;
71 -- The node an immediately following comment may be associated with
73 Previous_End_Node
: Project_Node_Id
:= Empty_Node
;
74 -- The node comments immediately following an "end" line may be
77 Unkept_Comments
: Boolean := False;
78 -- Set to True when some comments may not be associated with any node
80 function Comment_Zones_Of
81 (Node
: Project_Node_Id
;
82 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
83 -- Returns the ID of the N_Comment_Zones node associated with node Node.
84 -- If there is not already an N_Comment_Zones node, create one and
85 -- associate it with node Node.
91 procedure Add_Comments
92 (To
: Project_Node_Id
;
93 In_Tree
: Project_Node_Tree_Ref
;
94 Where
: Comment_Location
) is
95 Zone
: Project_Node_Id
:= Empty_Node
;
96 Previous
: Project_Node_Id
:= Empty_Node
;
101 and then In_Tree
.Project_Nodes
.Table
(To
).Kind
/= N_Comment
);
103 Zone
:= In_Tree
.Project_Nodes
.Table
(To
).Comments
;
107 -- Create new N_Comment_Zones node
109 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
110 In_Tree
.Project_Nodes
.Table
111 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
112 (Kind
=> N_Comment_Zones
,
113 Qualifier
=> Unspecified
,
114 Expr_Kind
=> Undefined
,
115 Location
=> No_Location
,
116 Directory
=> No_Path
,
117 Variables
=> Empty_Node
,
118 Packages
=> Empty_Node
,
119 Pkg_Id
=> Empty_Package
,
122 Path_Name
=> No_Path
,
124 Field1
=> Empty_Node
,
125 Field2
=> Empty_Node
,
126 Field3
=> Empty_Node
,
127 Field4
=> Empty_Node
,
130 Comments
=> Empty_Node
);
132 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
133 In_Tree
.Project_Nodes
.Table
(To
).Comments
:= Zone
;
136 if Where
= End_Of_Line
then
137 In_Tree
.Project_Nodes
.Table
(Zone
).Value
:= Comments
.Table
(1).Value
;
140 -- Get each comments in the Comments table and link them to node To
142 for J
in 1 .. Comments
.Last
loop
144 -- Create new N_Comment node
146 if (Where
= After
or else Where
= After_End
) and then
147 Token
/= Tok_EOF
and then
148 Comments
.Table
(J
).Follows_Empty_Line
150 Comments
.Table
(1 .. Comments
.Last
- J
+ 1) :=
151 Comments
.Table
(J
.. Comments
.Last
);
152 Comments
.Set_Last
(Comments
.Last
- J
+ 1);
156 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
157 In_Tree
.Project_Nodes
.Table
158 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
160 Qualifier
=> Unspecified
,
161 Expr_Kind
=> Undefined
,
162 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
164 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
165 Location
=> No_Location
,
166 Directory
=> No_Path
,
167 Variables
=> Empty_Node
,
168 Packages
=> Empty_Node
,
169 Pkg_Id
=> Empty_Package
,
172 Path_Name
=> No_Path
,
173 Value
=> Comments
.Table
(J
).Value
,
174 Field1
=> Empty_Node
,
175 Field2
=> Empty_Node
,
176 Field3
=> Empty_Node
,
177 Field4
=> Empty_Node
,
178 Comments
=> Empty_Node
);
180 -- If this is the first comment, put it in the right field of
183 if No
(Previous
) then
186 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
187 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
190 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:=
191 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
194 In_Tree
.Project_Nodes
.Table
(Zone
).Field3
:=
195 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
198 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:=
199 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
206 -- When it is not the first, link it to the previous one
208 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
209 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
212 -- This node becomes the previous one for the next comment, if
215 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
219 -- Empty the Comments table, so that there is no risk to link the same
220 -- comments to another node.
222 Comments
.Set_Last
(0);
225 --------------------------------
226 -- Associative_Array_Index_Of --
227 --------------------------------
229 function Associative_Array_Index_Of
230 (Node
: Project_Node_Id
;
231 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
237 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
239 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
240 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
241 end Associative_Array_Index_Of
;
243 ----------------------------
244 -- Associative_Package_Of --
245 ----------------------------
247 function Associative_Package_Of
248 (Node
: Project_Node_Id
;
249 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
255 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
));
256 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
257 end Associative_Package_Of
;
259 ----------------------------
260 -- Associative_Project_Of --
261 ----------------------------
263 function Associative_Project_Of
264 (Node
: Project_Node_Id
;
265 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
271 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
));
272 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
273 end Associative_Project_Of
;
275 ----------------------
276 -- Case_Insensitive --
277 ----------------------
279 function Case_Insensitive
280 (Node
: Project_Node_Id
;
281 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
286 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
288 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
289 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
290 end Case_Insensitive
;
292 --------------------------------
293 -- Case_Variable_Reference_Of --
294 --------------------------------
296 function Case_Variable_Reference_Of
297 (Node
: Project_Node_Id
;
298 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
304 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
305 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
306 end Case_Variable_Reference_Of
;
308 ----------------------
309 -- Comment_Zones_Of --
310 ----------------------
312 function Comment_Zones_Of
313 (Node
: Project_Node_Id
;
314 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
316 Zone
: Project_Node_Id
;
319 pragma Assert
(Present
(Node
));
320 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
322 -- If there is not already an N_Comment_Zones associated, create a new
323 -- one and associate it with node Node.
326 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
327 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
328 In_Tree
.Project_Nodes
.Table
(Zone
) :=
329 (Kind
=> N_Comment_Zones
,
330 Qualifier
=> Unspecified
,
331 Location
=> No_Location
,
332 Directory
=> No_Path
,
333 Expr_Kind
=> Undefined
,
334 Variables
=> Empty_Node
,
335 Packages
=> Empty_Node
,
336 Pkg_Id
=> Empty_Package
,
339 Path_Name
=> No_Path
,
341 Field1
=> Empty_Node
,
342 Field2
=> Empty_Node
,
343 Field3
=> Empty_Node
,
344 Field4
=> Empty_Node
,
347 Comments
=> Empty_Node
);
348 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= Zone
;
352 end Comment_Zones_Of
;
354 -----------------------
355 -- Current_Item_Node --
356 -----------------------
358 function Current_Item_Node
359 (Node
: Project_Node_Id
;
360 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
366 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
367 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
368 end Current_Item_Node
;
374 function Current_Term
375 (Node
: Project_Node_Id
;
376 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
382 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
383 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
386 --------------------------
387 -- Default_Project_Node --
388 --------------------------
390 function Default_Project_Node
391 (In_Tree
: Project_Node_Tree_Ref
;
392 Of_Kind
: Project_Node_Kind
;
393 And_Expr_Kind
: Variable_Kind
:= Undefined
) return Project_Node_Id
395 Result
: Project_Node_Id
;
396 Zone
: Project_Node_Id
;
397 Previous
: Project_Node_Id
;
400 -- Create new node with specified kind and expression kind
402 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
403 In_Tree
.Project_Nodes
.Table
404 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
406 Qualifier
=> Unspecified
,
407 Location
=> No_Location
,
408 Directory
=> No_Path
,
409 Expr_Kind
=> And_Expr_Kind
,
410 Variables
=> Empty_Node
,
411 Packages
=> Empty_Node
,
412 Pkg_Id
=> Empty_Package
,
415 Path_Name
=> No_Path
,
417 Field1
=> Empty_Node
,
418 Field2
=> Empty_Node
,
419 Field3
=> Empty_Node
,
420 Field4
=> Empty_Node
,
423 Comments
=> Empty_Node
);
425 -- Save the new node for the returned value
427 Result
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
429 if Comments
.Last
> 0 then
431 -- If this is not a node with comments, then set the flag
433 if not Node_With_Comments
(Of_Kind
) then
434 Unkept_Comments
:= True;
436 elsif Of_Kind
/= N_Comment
and then Of_Kind
/= N_Comment_Zones
then
438 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
439 In_Tree
.Project_Nodes
.Table
440 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
441 (Kind
=> N_Comment_Zones
,
442 Qualifier
=> Unspecified
,
443 Expr_Kind
=> Undefined
,
444 Location
=> No_Location
,
445 Directory
=> No_Path
,
446 Variables
=> Empty_Node
,
447 Packages
=> Empty_Node
,
448 Pkg_Id
=> Empty_Package
,
451 Path_Name
=> No_Path
,
453 Field1
=> Empty_Node
,
454 Field2
=> Empty_Node
,
455 Field3
=> Empty_Node
,
456 Field4
=> Empty_Node
,
459 Comments
=> Empty_Node
);
461 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
462 In_Tree
.Project_Nodes
.Table
(Result
).Comments
:= Zone
;
463 Previous
:= Empty_Node
;
465 for J
in 1 .. Comments
.Last
loop
467 -- Create a new N_Comment node
469 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
470 In_Tree
.Project_Nodes
.Table
471 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
473 Qualifier
=> Unspecified
,
474 Expr_Kind
=> Undefined
,
475 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
477 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
478 Location
=> No_Location
,
479 Directory
=> No_Path
,
480 Variables
=> Empty_Node
,
481 Packages
=> Empty_Node
,
482 Pkg_Id
=> Empty_Package
,
485 Path_Name
=> No_Path
,
486 Value
=> Comments
.Table
(J
).Value
,
487 Field1
=> Empty_Node
,
488 Field2
=> Empty_Node
,
489 Field3
=> Empty_Node
,
490 Field4
=> Empty_Node
,
491 Comments
=> Empty_Node
);
493 -- Link it to the N_Comment_Zones node, if it is the first,
494 -- otherwise to the previous one.
496 if No
(Previous
) then
497 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
498 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
501 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
502 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
505 -- This new node will be the previous one for the next
506 -- N_Comment node, if there is one.
508 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
511 -- Empty the Comments table after all comments have been processed
513 Comments
.Set_Last
(0);
518 end Default_Project_Node
;
524 function Directory_Of
525 (Node
: Project_Node_Id
;
526 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
is
531 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
532 return In_Tree
.Project_Nodes
.Table
(Node
).Directory
;
535 -------------------------
536 -- End_Of_Line_Comment --
537 -------------------------
539 function End_Of_Line_Comment
540 (Node
: Project_Node_Id
;
541 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
is
542 Zone
: Project_Node_Id
:= Empty_Node
;
545 pragma Assert
(Present
(Node
));
546 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
551 return In_Tree
.Project_Nodes
.Table
(Zone
).Value
;
553 end End_Of_Line_Comment
;
555 ------------------------
556 -- Expression_Kind_Of --
557 ------------------------
559 function Expression_Kind_Of
560 (Node
: Project_Node_Id
;
561 In_Tree
: Project_Node_Tree_Ref
) return Variable_Kind
is
566 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
568 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
570 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
572 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
573 N_Typed_Variable_Declaration
575 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
577 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
579 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
581 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
583 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
584 N_Attribute_Reference
));
586 return In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
;
587 end Expression_Kind_Of
;
593 function Expression_Of
594 (Node
: Project_Node_Id
;
595 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
601 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
602 N_Attribute_Declaration
604 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
605 N_Typed_Variable_Declaration
607 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
608 N_Variable_Declaration
));
610 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
613 -------------------------
614 -- Extended_Project_Of --
615 -------------------------
617 function Extended_Project_Of
618 (Node
: Project_Node_Id
;
619 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
625 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
626 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
627 end Extended_Project_Of
;
629 ------------------------------
630 -- Extended_Project_Path_Of --
631 ------------------------------
633 function Extended_Project_Path_Of
634 (Node
: Project_Node_Id
;
635 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
641 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
642 return Path_Name_Type
(In_Tree
.Project_Nodes
.Table
(Node
).Value
);
643 end Extended_Project_Path_Of
;
645 --------------------------
646 -- Extending_Project_Of --
647 --------------------------
648 function Extending_Project_Of
649 (Node
: Project_Node_Id
;
650 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
656 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
657 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
658 end Extending_Project_Of
;
660 ---------------------------
661 -- External_Reference_Of --
662 ---------------------------
664 function External_Reference_Of
665 (Node
: Project_Node_Id
;
666 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
672 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
673 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
674 end External_Reference_Of
;
676 -------------------------
677 -- External_Default_Of --
678 -------------------------
680 function External_Default_Of
681 (Node
: Project_Node_Id
;
682 In_Tree
: Project_Node_Tree_Ref
)
683 return Project_Node_Id
689 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
690 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
691 end External_Default_Of
;
693 ------------------------
694 -- First_Case_Item_Of --
695 ------------------------
697 function First_Case_Item_Of
698 (Node
: Project_Node_Id
;
699 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
705 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
706 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
707 end First_Case_Item_Of
;
709 ---------------------
710 -- First_Choice_Of --
711 ---------------------
713 function First_Choice_Of
714 (Node
: Project_Node_Id
;
715 In_Tree
: Project_Node_Tree_Ref
)
716 return Project_Node_Id
722 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
723 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
726 -------------------------
727 -- First_Comment_After --
728 -------------------------
730 function First_Comment_After
731 (Node
: Project_Node_Id
;
732 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
734 Zone
: Project_Node_Id
:= Empty_Node
;
736 pragma Assert
(Present
(Node
));
737 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
743 return In_Tree
.Project_Nodes
.Table
(Zone
).Field2
;
745 end First_Comment_After
;
747 -----------------------------
748 -- First_Comment_After_End --
749 -----------------------------
751 function First_Comment_After_End
752 (Node
: Project_Node_Id
;
753 In_Tree
: Project_Node_Tree_Ref
)
754 return Project_Node_Id
756 Zone
: Project_Node_Id
:= Empty_Node
;
759 pragma Assert
(Present
(Node
));
760 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
766 return In_Tree
.Project_Nodes
.Table
(Zone
).Comments
;
768 end First_Comment_After_End
;
770 --------------------------
771 -- First_Comment_Before --
772 --------------------------
774 function First_Comment_Before
775 (Node
: Project_Node_Id
;
776 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
778 Zone
: Project_Node_Id
:= Empty_Node
;
781 pragma Assert
(Present
(Node
));
782 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
788 return In_Tree
.Project_Nodes
.Table
(Zone
).Field1
;
790 end First_Comment_Before
;
792 ------------------------------
793 -- First_Comment_Before_End --
794 ------------------------------
796 function First_Comment_Before_End
797 (Node
: Project_Node_Id
;
798 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
800 Zone
: Project_Node_Id
:= Empty_Node
;
803 pragma Assert
(Present
(Node
));
804 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
810 return In_Tree
.Project_Nodes
.Table
(Zone
).Field3
;
812 end First_Comment_Before_End
;
814 -------------------------------
815 -- First_Declarative_Item_Of --
816 -------------------------------
818 function First_Declarative_Item_Of
819 (Node
: Project_Node_Id
;
820 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
826 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
828 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
830 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
832 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
833 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
835 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
837 end First_Declarative_Item_Of
;
839 ------------------------------
840 -- First_Expression_In_List --
841 ------------------------------
843 function First_Expression_In_List
844 (Node
: Project_Node_Id
;
845 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
851 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
852 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
853 end First_Expression_In_List
;
855 --------------------------
856 -- First_Literal_String --
857 --------------------------
859 function First_Literal_String
860 (Node
: Project_Node_Id
;
861 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
867 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
868 N_String_Type_Declaration
);
869 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
870 end First_Literal_String
;
872 ----------------------
873 -- First_Package_Of --
874 ----------------------
876 function First_Package_Of
877 (Node
: Project_Node_Id
;
878 In_Tree
: Project_Node_Tree_Ref
) return Package_Declaration_Id
884 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
885 return In_Tree
.Project_Nodes
.Table
(Node
).Packages
;
886 end First_Package_Of
;
888 --------------------------
889 -- First_String_Type_Of --
890 --------------------------
892 function First_String_Type_Of
893 (Node
: Project_Node_Id
;
894 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
900 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
901 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
902 end First_String_Type_Of
;
909 (Node
: Project_Node_Id
;
910 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
916 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
917 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
920 -----------------------
921 -- First_Variable_Of --
922 -----------------------
924 function First_Variable_Of
925 (Node
: Project_Node_Id
;
926 In_Tree
: Project_Node_Tree_Ref
) return Variable_Node_Id
932 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
934 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
936 return In_Tree
.Project_Nodes
.Table
(Node
).Variables
;
937 end First_Variable_Of
;
939 --------------------------
940 -- First_With_Clause_Of --
941 --------------------------
943 function First_With_Clause_Of
944 (Node
: Project_Node_Id
;
945 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
951 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
952 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
953 end First_With_Clause_Of
;
955 ------------------------
956 -- Follows_Empty_Line --
957 ------------------------
959 function Follows_Empty_Line
960 (Node
: Project_Node_Id
;
961 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
966 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
967 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
968 end Follows_Empty_Line
;
974 function Hash
(N
: Project_Node_Id
) return Header_Num
is
976 return Header_Num
(N
mod Project_Node_Id
(Header_Num
'Last));
983 procedure Initialize
(Tree
: Project_Node_Tree_Ref
) is
985 Project_Node_Table
.Init
(Tree
.Project_Nodes
);
986 Projects_Htable
.Reset
(Tree
.Projects_HT
);
988 -- Do not reset the external references, in case we are reloading a
989 -- project, since we want to preserve the current environment
990 -- Name_To_Name_HTable.Reset (Tree.External_References);
997 procedure Free
(Proj
: in out Project_Node_Tree_Ref
) is
998 procedure Unchecked_Free
is new Ada
.Unchecked_Deallocation
999 (Project_Node_Tree_Data
, Project_Node_Tree_Ref
);
1001 if Proj
/= null then
1002 Project_Node_Table
.Free
(Proj
.Project_Nodes
);
1003 Projects_Htable
.Reset
(Proj
.Projects_HT
);
1004 Name_To_Name_HTable
.Reset
(Proj
.External_References
);
1005 Free
(Proj
.Project_Path
);
1006 Unchecked_Free
(Proj
);
1010 -------------------------------
1011 -- Is_Followed_By_Empty_Line --
1012 -------------------------------
1014 function Is_Followed_By_Empty_Line
1015 (Node
: Project_Node_Id
;
1016 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1022 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1023 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1024 end Is_Followed_By_Empty_Line
;
1026 ----------------------
1027 -- Is_Extending_All --
1028 ----------------------
1030 function Is_Extending_All
1031 (Node
: Project_Node_Id
;
1032 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
1037 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1039 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1040 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1041 end Is_Extending_All
;
1043 -------------------------
1044 -- Is_Not_Last_In_List --
1045 -------------------------
1047 function Is_Not_Last_In_List
1048 (Node
: Project_Node_Id
;
1049 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
1054 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1055 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
1056 end Is_Not_Last_In_List
;
1058 -------------------------------------
1059 -- Imported_Or_Extended_Project_Of --
1060 -------------------------------------
1062 function Imported_Or_Extended_Project_Of
1063 (Project
: Project_Node_Id
;
1064 In_Tree
: Project_Node_Tree_Ref
;
1065 With_Name
: Name_Id
) return Project_Node_Id
1067 With_Clause
: Project_Node_Id
:=
1068 First_With_Clause_Of
(Project
, In_Tree
);
1069 Result
: Project_Node_Id
:= Empty_Node
;
1072 -- First check all the imported projects
1074 while Present
(With_Clause
) loop
1076 -- Only non limited imported project may be used as prefix
1077 -- of variable or attributes.
1079 Result
:= Non_Limited_Project_Node_Of
(With_Clause
, In_Tree
);
1080 exit when Present
(Result
)
1081 and then Name_Of
(Result
, In_Tree
) = With_Name
;
1082 With_Clause
:= Next_With_Clause_Of
(With_Clause
, In_Tree
);
1085 -- If it is not an imported project, it might be an extended project
1087 if No
(With_Clause
) then
1092 (Project_Declaration_Of
(Result
, In_Tree
), In_Tree
);
1094 exit when No
(Result
)
1095 or else Name_Of
(Result
, In_Tree
) = With_Name
;
1100 end Imported_Or_Extended_Project_Of
;
1107 (Node
: Project_Node_Id
;
1108 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Kind
is
1110 pragma Assert
(Present
(Node
));
1111 return In_Tree
.Project_Nodes
.Table
(Node
).Kind
;
1118 function Location_Of
1119 (Node
: Project_Node_Id
;
1120 In_Tree
: Project_Node_Tree_Ref
) return Source_Ptr
is
1122 pragma Assert
(Present
(Node
));
1123 return In_Tree
.Project_Nodes
.Table
(Node
).Location
;
1131 (Node
: Project_Node_Id
;
1132 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
is
1134 pragma Assert
(Present
(Node
));
1135 return In_Tree
.Project_Nodes
.Table
(Node
).Name
;
1138 --------------------
1139 -- Next_Case_Item --
1140 --------------------
1142 function Next_Case_Item
1143 (Node
: Project_Node_Id
;
1144 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1150 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
1151 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1158 function Next_Comment
1159 (Node
: Project_Node_Id
;
1160 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
is
1165 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1166 return In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
1169 ---------------------------
1170 -- Next_Declarative_Item --
1171 ---------------------------
1173 function Next_Declarative_Item
1174 (Node
: Project_Node_Id
;
1175 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1181 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1182 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1183 end Next_Declarative_Item
;
1185 -----------------------------
1186 -- Next_Expression_In_List --
1187 -----------------------------
1189 function Next_Expression_In_List
1190 (Node
: Project_Node_Id
;
1191 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1197 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
1198 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1199 end Next_Expression_In_List
;
1201 -------------------------
1202 -- Next_Literal_String --
1203 -------------------------
1205 function Next_Literal_String
1206 (Node
: Project_Node_Id
;
1207 In_Tree
: Project_Node_Tree_Ref
)
1208 return Project_Node_Id
1214 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
1215 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1216 end Next_Literal_String
;
1218 -----------------------------
1219 -- Next_Package_In_Project --
1220 -----------------------------
1222 function Next_Package_In_Project
1223 (Node
: Project_Node_Id
;
1224 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1230 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1231 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1232 end Next_Package_In_Project
;
1234 ----------------------
1235 -- Next_String_Type --
1236 ----------------------
1238 function Next_String_Type
1239 (Node
: Project_Node_Id
;
1240 In_Tree
: Project_Node_Tree_Ref
)
1241 return Project_Node_Id
1247 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1248 N_String_Type_Declaration
);
1249 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1250 end Next_String_Type
;
1257 (Node
: Project_Node_Id
;
1258 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1264 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1265 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1272 function Next_Variable
1273 (Node
: Project_Node_Id
;
1274 In_Tree
: Project_Node_Tree_Ref
)
1275 return Project_Node_Id
1281 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1282 N_Typed_Variable_Declaration
1284 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1285 N_Variable_Declaration
));
1287 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1290 -------------------------
1291 -- Next_With_Clause_Of --
1292 -------------------------
1294 function Next_With_Clause_Of
1295 (Node
: Project_Node_Id
;
1296 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1302 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1303 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1304 end Next_With_Clause_Of
;
1310 function No
(Node
: Project_Node_Id
) return Boolean is
1312 return Node
= Empty_Node
;
1315 ---------------------------------
1316 -- Non_Limited_Project_Node_Of --
1317 ---------------------------------
1319 function Non_Limited_Project_Node_Of
1320 (Node
: Project_Node_Id
;
1321 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1327 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1328 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1329 end Non_Limited_Project_Node_Of
;
1335 function Package_Id_Of
1336 (Node
: Project_Node_Id
;
1337 In_Tree
: Project_Node_Tree_Ref
) return Package_Node_Id
1343 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1344 return In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
;
1347 ---------------------
1348 -- Package_Node_Of --
1349 ---------------------
1351 function Package_Node_Of
1352 (Node
: Project_Node_Id
;
1353 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1359 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1361 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1362 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1363 end Package_Node_Of
;
1369 function Path_Name_Of
1370 (Node
: Project_Node_Id
;
1371 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
1377 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1379 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1380 return In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
;
1387 function Present
(Node
: Project_Node_Id
) return Boolean is
1389 return Node
/= Empty_Node
;
1392 ----------------------------
1393 -- Project_Declaration_Of --
1394 ----------------------------
1396 function Project_Declaration_Of
1397 (Node
: Project_Node_Id
;
1398 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1404 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1405 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1406 end Project_Declaration_Of
;
1408 --------------------------
1409 -- Project_Qualifier_Of --
1410 --------------------------
1412 function Project_Qualifier_Of
1413 (Node
: Project_Node_Id
;
1414 In_Tree
: Project_Node_Tree_Ref
) return Project_Qualifier
1420 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1421 return In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
;
1422 end Project_Qualifier_Of
;
1424 -----------------------
1425 -- Parent_Project_Of --
1426 -----------------------
1428 function Parent_Project_Of
1429 (Node
: Project_Node_Id
;
1430 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1436 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1437 return In_Tree
.Project_Nodes
.Table
(Node
).Field4
;
1438 end Parent_Project_Of
;
1440 -------------------------------------------
1441 -- Project_File_Includes_Unkept_Comments --
1442 -------------------------------------------
1444 function Project_File_Includes_Unkept_Comments
1445 (Node
: Project_Node_Id
;
1446 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1448 Declaration
: constant Project_Node_Id
:=
1449 Project_Declaration_Of
(Node
, In_Tree
);
1451 return In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
;
1452 end Project_File_Includes_Unkept_Comments
;
1454 ---------------------
1455 -- Project_Node_Of --
1456 ---------------------
1458 function Project_Node_Of
1459 (Node
: Project_Node_Id
;
1460 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1466 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
1468 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1470 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1471 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1472 end Project_Node_Of
;
1474 -----------------------------------
1475 -- Project_Of_Renamed_Package_Of --
1476 -----------------------------------
1478 function Project_Of_Renamed_Package_Of
1479 (Node
: Project_Node_Id
;
1480 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1486 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1487 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1488 end Project_Of_Renamed_Package_Of
;
1490 --------------------------
1491 -- Remove_Next_End_Node --
1492 --------------------------
1494 procedure Remove_Next_End_Node
is
1496 Next_End_Nodes
.Decrement_Last
;
1497 end Remove_Next_End_Node
;
1503 procedure Reset_State
is
1505 End_Of_Line_Node
:= Empty_Node
;
1506 Previous_Line_Node
:= Empty_Node
;
1507 Previous_End_Node
:= Empty_Node
;
1508 Unkept_Comments
:= False;
1509 Comments
.Set_Last
(0);
1512 ----------------------
1513 -- Restore_And_Free --
1514 ----------------------
1516 procedure Restore_And_Free
(S
: in out Comment_State
) is
1517 procedure Unchecked_Free
is new
1518 Ada
.Unchecked_Deallocation
(Comment_Array
, Comments_Ptr
);
1521 End_Of_Line_Node
:= S
.End_Of_Line_Node
;
1522 Previous_Line_Node
:= S
.Previous_Line_Node
;
1523 Previous_End_Node
:= S
.Previous_End_Node
;
1524 Next_End_Nodes
.Set_Last
(0);
1525 Unkept_Comments
:= S
.Unkept_Comments
;
1527 Comments
.Set_Last
(0);
1529 for J
in S
.Comments
'Range loop
1530 Comments
.Increment_Last
;
1531 Comments
.Table
(Comments
.Last
) := S
.Comments
(J
);
1534 Unchecked_Free
(S
.Comments
);
1535 end Restore_And_Free
;
1541 procedure Save
(S
: out Comment_State
) is
1542 Cmts
: constant Comments_Ptr
:= new Comment_Array
(1 .. Comments
.Last
);
1545 for J
in 1 .. Comments
.Last
loop
1546 Cmts
(J
) := Comments
.Table
(J
);
1550 (End_Of_Line_Node
=> End_Of_Line_Node
,
1551 Previous_Line_Node
=> Previous_Line_Node
,
1552 Previous_End_Node
=> Previous_End_Node
,
1553 Unkept_Comments
=> Unkept_Comments
,
1561 procedure Scan
(In_Tree
: Project_Node_Tree_Ref
) is
1562 Empty_Line
: Boolean := False;
1565 -- If there are comments, then they will not be kept. Set the flag and
1566 -- clear the comments.
1568 if Comments
.Last
> 0 then
1569 Unkept_Comments
:= True;
1570 Comments
.Set_Last
(0);
1573 -- Loop until a token other that End_Of_Line or Comment is found
1576 Prj
.Err
.Scanner
.Scan
;
1579 when Tok_End_Of_Line
=>
1580 if Prev_Token
= Tok_End_Of_Line
then
1583 if Comments
.Last
> 0 then
1584 Comments
.Table
(Comments
.Last
).Is_Followed_By_Empty_Line
1590 -- If this is a line comment, add it to the comment table
1592 if Prev_Token
= Tok_End_Of_Line
1593 or else Prev_Token
= No_Token
1595 Comments
.Increment_Last
;
1596 Comments
.Table
(Comments
.Last
) :=
1597 (Value
=> Comment_Id
,
1598 Follows_Empty_Line
=> Empty_Line
,
1599 Is_Followed_By_Empty_Line
=> False);
1601 -- Otherwise, it is an end of line comment. If there is
1602 -- an end of line node specified, associate the comment with
1605 elsif Present
(End_Of_Line_Node
) then
1607 Zones
: constant Project_Node_Id
:=
1608 Comment_Zones_Of
(End_Of_Line_Node
, In_Tree
);
1610 In_Tree
.Project_Nodes
.Table
(Zones
).Value
:= Comment_Id
;
1613 -- Otherwise, this end of line node cannot be kept
1616 Unkept_Comments
:= True;
1617 Comments
.Set_Last
(0);
1620 Empty_Line
:= False;
1623 -- If there are comments, where the first comment is not
1624 -- following an empty line, put the initial uninterrupted
1625 -- comment zone with the node of the preceding line (either
1626 -- a Previous_Line or a Previous_End node), if any.
1628 if Comments
.Last
> 0 and then
1629 not Comments
.Table
(1).Follows_Empty_Line
then
1630 if Present
(Previous_Line_Node
) then
1632 (To
=> Previous_Line_Node
,
1634 In_Tree
=> In_Tree
);
1636 elsif Present
(Previous_End_Node
) then
1638 (To
=> Previous_End_Node
,
1640 In_Tree
=> In_Tree
);
1644 -- If there are still comments and the token is "end", then
1645 -- put these comments with the Next_End node, if any;
1646 -- otherwise, these comments cannot be kept. Always clear
1649 if Comments
.Last
> 0 and then Token
= Tok_End
then
1650 if Next_End_Nodes
.Last
> 0 then
1652 (To
=> Next_End_Nodes
.Table
(Next_End_Nodes
.Last
),
1653 Where
=> Before_End
,
1654 In_Tree
=> In_Tree
);
1657 Unkept_Comments
:= True;
1660 Comments
.Set_Last
(0);
1663 -- Reset the End_Of_Line, Previous_Line and Previous_End nodes
1664 -- so that they are not used again.
1666 End_Of_Line_Node
:= Empty_Node
;
1667 Previous_Line_Node
:= Empty_Node
;
1668 Previous_End_Node
:= Empty_Node
;
1677 ------------------------------------
1678 -- Set_Associative_Array_Index_Of --
1679 ------------------------------------
1681 procedure Set_Associative_Array_Index_Of
1682 (Node
: Project_Node_Id
;
1683 In_Tree
: Project_Node_Tree_Ref
;
1690 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1692 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1693 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
1694 end Set_Associative_Array_Index_Of
;
1696 --------------------------------
1697 -- Set_Associative_Package_Of --
1698 --------------------------------
1700 procedure Set_Associative_Package_Of
1701 (Node
: Project_Node_Id
;
1702 In_Tree
: Project_Node_Tree_Ref
;
1703 To
: Project_Node_Id
)
1709 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
);
1710 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
1711 end Set_Associative_Package_Of
;
1713 --------------------------------
1714 -- Set_Associative_Project_Of --
1715 --------------------------------
1717 procedure Set_Associative_Project_Of
1718 (Node
: Project_Node_Id
;
1719 In_Tree
: Project_Node_Tree_Ref
;
1720 To
: Project_Node_Id
)
1726 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1727 N_Attribute_Declaration
));
1728 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1729 end Set_Associative_Project_Of
;
1731 --------------------------
1732 -- Set_Case_Insensitive --
1733 --------------------------
1735 procedure Set_Case_Insensitive
1736 (Node
: Project_Node_Id
;
1737 In_Tree
: Project_Node_Tree_Ref
;
1744 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1746 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1747 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= To
;
1748 end Set_Case_Insensitive
;
1750 ------------------------------------
1751 -- Set_Case_Variable_Reference_Of --
1752 ------------------------------------
1754 procedure Set_Case_Variable_Reference_Of
1755 (Node
: Project_Node_Id
;
1756 In_Tree
: Project_Node_Tree_Ref
;
1757 To
: Project_Node_Id
)
1763 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
1764 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1765 end Set_Case_Variable_Reference_Of
;
1767 ---------------------------
1768 -- Set_Current_Item_Node --
1769 ---------------------------
1771 procedure Set_Current_Item_Node
1772 (Node
: Project_Node_Id
;
1773 In_Tree
: Project_Node_Tree_Ref
;
1774 To
: Project_Node_Id
)
1780 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1781 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1782 end Set_Current_Item_Node
;
1784 ----------------------
1785 -- Set_Current_Term --
1786 ----------------------
1788 procedure Set_Current_Term
1789 (Node
: Project_Node_Id
;
1790 In_Tree
: Project_Node_Tree_Ref
;
1791 To
: Project_Node_Id
)
1797 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1798 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1799 end Set_Current_Term
;
1801 ----------------------
1802 -- Set_Directory_Of --
1803 ----------------------
1805 procedure Set_Directory_Of
1806 (Node
: Project_Node_Id
;
1807 In_Tree
: Project_Node_Tree_Ref
;
1808 To
: Path_Name_Type
)
1814 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1815 In_Tree
.Project_Nodes
.Table
(Node
).Directory
:= To
;
1816 end Set_Directory_Of
;
1818 ---------------------
1819 -- Set_End_Of_Line --
1820 ---------------------
1822 procedure Set_End_Of_Line
(To
: Project_Node_Id
) is
1824 End_Of_Line_Node
:= To
;
1825 end Set_End_Of_Line
;
1827 ----------------------------
1828 -- Set_Expression_Kind_Of --
1829 ----------------------------
1831 procedure Set_Expression_Kind_Of
1832 (Node
: Project_Node_Id
;
1833 In_Tree
: Project_Node_Tree_Ref
;
1840 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
1842 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1844 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
1846 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1847 N_Typed_Variable_Declaration
1849 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
1851 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
1853 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
1855 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1857 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1858 N_Attribute_Reference
));
1859 In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
:= To
;
1860 end Set_Expression_Kind_Of
;
1862 -----------------------
1863 -- Set_Expression_Of --
1864 -----------------------
1866 procedure Set_Expression_Of
1867 (Node
: Project_Node_Id
;
1868 In_Tree
: Project_Node_Tree_Ref
;
1869 To
: Project_Node_Id
)
1875 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1876 N_Attribute_Declaration
1878 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1879 N_Typed_Variable_Declaration
1881 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1882 N_Variable_Declaration
));
1883 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1884 end Set_Expression_Of
;
1886 -------------------------------
1887 -- Set_External_Reference_Of --
1888 -------------------------------
1890 procedure Set_External_Reference_Of
1891 (Node
: Project_Node_Id
;
1892 In_Tree
: Project_Node_Tree_Ref
;
1893 To
: Project_Node_Id
)
1899 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
1900 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1901 end Set_External_Reference_Of
;
1903 -----------------------------
1904 -- Set_External_Default_Of --
1905 -----------------------------
1907 procedure Set_External_Default_Of
1908 (Node
: Project_Node_Id
;
1909 In_Tree
: Project_Node_Tree_Ref
;
1910 To
: Project_Node_Id
)
1916 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
1917 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1918 end Set_External_Default_Of
;
1920 ----------------------------
1921 -- Set_First_Case_Item_Of --
1922 ----------------------------
1924 procedure Set_First_Case_Item_Of
1925 (Node
: Project_Node_Id
;
1926 In_Tree
: Project_Node_Tree_Ref
;
1927 To
: Project_Node_Id
)
1933 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
1934 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1935 end Set_First_Case_Item_Of
;
1937 -------------------------
1938 -- Set_First_Choice_Of --
1939 -------------------------
1941 procedure Set_First_Choice_Of
1942 (Node
: Project_Node_Id
;
1943 In_Tree
: Project_Node_Tree_Ref
;
1944 To
: Project_Node_Id
)
1950 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
1951 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1952 end Set_First_Choice_Of
;
1954 -----------------------------
1955 -- Set_First_Comment_After --
1956 -----------------------------
1958 procedure Set_First_Comment_After
1959 (Node
: Project_Node_Id
;
1960 In_Tree
: Project_Node_Tree_Ref
;
1961 To
: Project_Node_Id
)
1963 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
1965 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
1966 end Set_First_Comment_After
;
1968 ---------------------------------
1969 -- Set_First_Comment_After_End --
1970 ---------------------------------
1972 procedure Set_First_Comment_After_End
1973 (Node
: Project_Node_Id
;
1974 In_Tree
: Project_Node_Tree_Ref
;
1975 To
: Project_Node_Id
)
1977 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
1979 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:= To
;
1980 end Set_First_Comment_After_End
;
1982 ------------------------------
1983 -- Set_First_Comment_Before --
1984 ------------------------------
1986 procedure Set_First_Comment_Before
1987 (Node
: Project_Node_Id
;
1988 In_Tree
: Project_Node_Tree_Ref
;
1989 To
: Project_Node_Id
)
1992 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
1994 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:= To
;
1995 end Set_First_Comment_Before
;
1997 ----------------------------------
1998 -- Set_First_Comment_Before_End --
1999 ----------------------------------
2001 procedure Set_First_Comment_Before_End
2002 (Node
: Project_Node_Id
;
2003 In_Tree
: Project_Node_Tree_Ref
;
2004 To
: Project_Node_Id
)
2006 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2008 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2009 end Set_First_Comment_Before_End
;
2011 ------------------------
2012 -- Set_Next_Case_Item --
2013 ------------------------
2015 procedure Set_Next_Case_Item
2016 (Node
: Project_Node_Id
;
2017 In_Tree
: Project_Node_Tree_Ref
;
2018 To
: Project_Node_Id
)
2024 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2025 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2026 end Set_Next_Case_Item
;
2028 ----------------------
2029 -- Set_Next_Comment --
2030 ----------------------
2032 procedure Set_Next_Comment
2033 (Node
: Project_Node_Id
;
2034 In_Tree
: Project_Node_Tree_Ref
;
2035 To
: Project_Node_Id
)
2041 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
2042 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= To
;
2043 end Set_Next_Comment
;
2045 -----------------------------------
2046 -- Set_First_Declarative_Item_Of --
2047 -----------------------------------
2049 procedure Set_First_Declarative_Item_Of
2050 (Node
: Project_Node_Id
;
2051 In_Tree
: Project_Node_Tree_Ref
;
2052 To
: Project_Node_Id
)
2058 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
2060 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
2062 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2064 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
2065 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2067 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2069 end Set_First_Declarative_Item_Of
;
2071 ----------------------------------
2072 -- Set_First_Expression_In_List --
2073 ----------------------------------
2075 procedure Set_First_Expression_In_List
2076 (Node
: Project_Node_Id
;
2077 In_Tree
: Project_Node_Tree_Ref
;
2078 To
: Project_Node_Id
)
2084 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
2085 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2086 end Set_First_Expression_In_List
;
2088 ------------------------------
2089 -- Set_First_Literal_String --
2090 ------------------------------
2092 procedure Set_First_Literal_String
2093 (Node
: Project_Node_Id
;
2094 In_Tree
: Project_Node_Tree_Ref
;
2095 To
: Project_Node_Id
)
2101 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2102 N_String_Type_Declaration
);
2103 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2104 end Set_First_Literal_String
;
2106 --------------------------
2107 -- Set_First_Package_Of --
2108 --------------------------
2110 procedure Set_First_Package_Of
2111 (Node
: Project_Node_Id
;
2112 In_Tree
: Project_Node_Tree_Ref
;
2113 To
: Package_Declaration_Id
)
2119 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2120 In_Tree
.Project_Nodes
.Table
(Node
).Packages
:= To
;
2121 end Set_First_Package_Of
;
2123 ------------------------------
2124 -- Set_First_String_Type_Of --
2125 ------------------------------
2127 procedure Set_First_String_Type_Of
2128 (Node
: Project_Node_Id
;
2129 In_Tree
: Project_Node_Tree_Ref
;
2130 To
: Project_Node_Id
)
2136 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2137 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2138 end Set_First_String_Type_Of
;
2140 --------------------
2141 -- Set_First_Term --
2142 --------------------
2144 procedure Set_First_Term
2145 (Node
: Project_Node_Id
;
2146 In_Tree
: Project_Node_Tree_Ref
;
2147 To
: Project_Node_Id
)
2153 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2154 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2157 ---------------------------
2158 -- Set_First_Variable_Of --
2159 ---------------------------
2161 procedure Set_First_Variable_Of
2162 (Node
: Project_Node_Id
;
2163 In_Tree
: Project_Node_Tree_Ref
;
2164 To
: Variable_Node_Id
)
2170 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2172 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2173 In_Tree
.Project_Nodes
.Table
(Node
).Variables
:= To
;
2174 end Set_First_Variable_Of
;
2176 ------------------------------
2177 -- Set_First_With_Clause_Of --
2178 ------------------------------
2180 procedure Set_First_With_Clause_Of
2181 (Node
: Project_Node_Id
;
2182 In_Tree
: Project_Node_Tree_Ref
;
2183 To
: Project_Node_Id
)
2189 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2190 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2191 end Set_First_With_Clause_Of
;
2193 --------------------------
2194 -- Set_Is_Extending_All --
2195 --------------------------
2197 procedure Set_Is_Extending_All
2198 (Node
: Project_Node_Id
;
2199 In_Tree
: Project_Node_Tree_Ref
)
2205 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2207 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2208 In_Tree
.Project_Nodes
.Table
(Node
).Flag2
:= True;
2209 end Set_Is_Extending_All
;
2211 -----------------------------
2212 -- Set_Is_Not_Last_In_List --
2213 -----------------------------
2215 procedure Set_Is_Not_Last_In_List
2216 (Node
: Project_Node_Id
;
2217 In_Tree
: Project_Node_Tree_Ref
)
2223 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2224 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= True;
2225 end Set_Is_Not_Last_In_List
;
2231 procedure Set_Kind_Of
2232 (Node
: Project_Node_Id
;
2233 In_Tree
: Project_Node_Tree_Ref
;
2234 To
: Project_Node_Kind
)
2237 pragma Assert
(Present
(Node
));
2238 In_Tree
.Project_Nodes
.Table
(Node
).Kind
:= To
;
2241 ---------------------
2242 -- Set_Location_Of --
2243 ---------------------
2245 procedure Set_Location_Of
2246 (Node
: Project_Node_Id
;
2247 In_Tree
: Project_Node_Tree_Ref
;
2251 pragma Assert
(Present
(Node
));
2252 In_Tree
.Project_Nodes
.Table
(Node
).Location
:= To
;
2253 end Set_Location_Of
;
2255 -----------------------------
2256 -- Set_Extended_Project_Of --
2257 -----------------------------
2259 procedure Set_Extended_Project_Of
2260 (Node
: Project_Node_Id
;
2261 In_Tree
: Project_Node_Tree_Ref
;
2262 To
: Project_Node_Id
)
2268 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2269 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2270 end Set_Extended_Project_Of
;
2272 ----------------------------------
2273 -- Set_Extended_Project_Path_Of --
2274 ----------------------------------
2276 procedure Set_Extended_Project_Path_Of
2277 (Node
: Project_Node_Id
;
2278 In_Tree
: Project_Node_Tree_Ref
;
2279 To
: Path_Name_Type
)
2285 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2286 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= Name_Id
(To
);
2287 end Set_Extended_Project_Path_Of
;
2289 ------------------------------
2290 -- Set_Extending_Project_Of --
2291 ------------------------------
2293 procedure Set_Extending_Project_Of
2294 (Node
: Project_Node_Id
;
2295 In_Tree
: Project_Node_Tree_Ref
;
2296 To
: Project_Node_Id
)
2302 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2303 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2304 end Set_Extending_Project_Of
;
2310 procedure Set_Name_Of
2311 (Node
: Project_Node_Id
;
2312 In_Tree
: Project_Node_Tree_Ref
;
2316 pragma Assert
(Present
(Node
));
2317 In_Tree
.Project_Nodes
.Table
(Node
).Name
:= To
;
2320 -------------------------------
2321 -- Set_Next_Declarative_Item --
2322 -------------------------------
2324 procedure Set_Next_Declarative_Item
2325 (Node
: Project_Node_Id
;
2326 In_Tree
: Project_Node_Tree_Ref
;
2327 To
: Project_Node_Id
)
2333 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
2334 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2335 end Set_Next_Declarative_Item
;
2337 -----------------------
2338 -- Set_Next_End_Node --
2339 -----------------------
2341 procedure Set_Next_End_Node
(To
: Project_Node_Id
) is
2343 Next_End_Nodes
.Increment_Last
;
2344 Next_End_Nodes
.Table
(Next_End_Nodes
.Last
) := To
;
2345 end Set_Next_End_Node
;
2347 ---------------------------------
2348 -- Set_Next_Expression_In_List --
2349 ---------------------------------
2351 procedure Set_Next_Expression_In_List
2352 (Node
: Project_Node_Id
;
2353 In_Tree
: Project_Node_Tree_Ref
;
2354 To
: Project_Node_Id
)
2360 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2361 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2362 end Set_Next_Expression_In_List
;
2364 -----------------------------
2365 -- Set_Next_Literal_String --
2366 -----------------------------
2368 procedure Set_Next_Literal_String
2369 (Node
: Project_Node_Id
;
2370 In_Tree
: Project_Node_Tree_Ref
;
2371 To
: Project_Node_Id
)
2377 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
2378 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2379 end Set_Next_Literal_String
;
2381 ---------------------------------
2382 -- Set_Next_Package_In_Project --
2383 ---------------------------------
2385 procedure Set_Next_Package_In_Project
2386 (Node
: Project_Node_Id
;
2387 In_Tree
: Project_Node_Tree_Ref
;
2388 To
: Project_Node_Id
)
2394 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2395 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2396 end Set_Next_Package_In_Project
;
2398 --------------------------
2399 -- Set_Next_String_Type --
2400 --------------------------
2402 procedure Set_Next_String_Type
2403 (Node
: Project_Node_Id
;
2404 In_Tree
: Project_Node_Tree_Ref
;
2405 To
: Project_Node_Id
)
2411 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2412 N_String_Type_Declaration
);
2413 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2414 end Set_Next_String_Type
;
2420 procedure Set_Next_Term
2421 (Node
: Project_Node_Id
;
2422 In_Tree
: Project_Node_Tree_Ref
;
2423 To
: Project_Node_Id
)
2429 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
2430 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2433 -----------------------
2434 -- Set_Next_Variable --
2435 -----------------------
2437 procedure Set_Next_Variable
2438 (Node
: Project_Node_Id
;
2439 In_Tree
: Project_Node_Tree_Ref
;
2440 To
: Project_Node_Id
)
2446 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2447 N_Typed_Variable_Declaration
2449 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2450 N_Variable_Declaration
));
2451 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2452 end Set_Next_Variable
;
2454 -----------------------------
2455 -- Set_Next_With_Clause_Of --
2456 -----------------------------
2458 procedure Set_Next_With_Clause_Of
2459 (Node
: Project_Node_Id
;
2460 In_Tree
: Project_Node_Tree_Ref
;
2461 To
: Project_Node_Id
)
2467 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2468 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2469 end Set_Next_With_Clause_Of
;
2471 -----------------------
2472 -- Set_Package_Id_Of --
2473 -----------------------
2475 procedure Set_Package_Id_Of
2476 (Node
: Project_Node_Id
;
2477 In_Tree
: Project_Node_Tree_Ref
;
2478 To
: Package_Node_Id
)
2484 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2485 In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
:= To
;
2486 end Set_Package_Id_Of
;
2488 -------------------------
2489 -- Set_Package_Node_Of --
2490 -------------------------
2492 procedure Set_Package_Node_Of
2493 (Node
: Project_Node_Id
;
2494 In_Tree
: Project_Node_Tree_Ref
;
2495 To
: Project_Node_Id
)
2501 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2503 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2504 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2505 end Set_Package_Node_Of
;
2507 ----------------------
2508 -- Set_Path_Name_Of --
2509 ----------------------
2511 procedure Set_Path_Name_Of
2512 (Node
: Project_Node_Id
;
2513 In_Tree
: Project_Node_Tree_Ref
;
2514 To
: Path_Name_Type
)
2520 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2522 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2523 In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
:= To
;
2524 end Set_Path_Name_Of
;
2526 ---------------------------
2527 -- Set_Previous_End_Node --
2528 ---------------------------
2529 procedure Set_Previous_End_Node
(To
: Project_Node_Id
) is
2531 Previous_End_Node
:= To
;
2532 end Set_Previous_End_Node
;
2534 ----------------------------
2535 -- Set_Previous_Line_Node --
2536 ----------------------------
2538 procedure Set_Previous_Line_Node
(To
: Project_Node_Id
) is
2540 Previous_Line_Node
:= To
;
2541 end Set_Previous_Line_Node
;
2543 --------------------------------
2544 -- Set_Project_Declaration_Of --
2545 --------------------------------
2547 procedure Set_Project_Declaration_Of
2548 (Node
: Project_Node_Id
;
2549 In_Tree
: Project_Node_Tree_Ref
;
2550 To
: Project_Node_Id
)
2556 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2557 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2558 end Set_Project_Declaration_Of
;
2560 ------------------------------
2561 -- Set_Project_Qualifier_Of --
2562 ------------------------------
2564 procedure Set_Project_Qualifier_Of
2565 (Node
: Project_Node_Id
;
2566 In_Tree
: Project_Node_Tree_Ref
;
2567 To
: Project_Qualifier
)
2572 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2573 In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
:= To
;
2574 end Set_Project_Qualifier_Of
;
2576 ---------------------------
2577 -- Set_Parent_Project_Of --
2578 ---------------------------
2580 procedure Set_Parent_Project_Of
2581 (Node
: Project_Node_Id
;
2582 In_Tree
: Project_Node_Tree_Ref
;
2583 To
: Project_Node_Id
)
2588 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2589 In_Tree
.Project_Nodes
.Table
(Node
).Field4
:= To
;
2590 end Set_Parent_Project_Of
;
2592 -----------------------------------------------
2593 -- Set_Project_File_Includes_Unkept_Comments --
2594 -----------------------------------------------
2596 procedure Set_Project_File_Includes_Unkept_Comments
2597 (Node
: Project_Node_Id
;
2598 In_Tree
: Project_Node_Tree_Ref
;
2601 Declaration
: constant Project_Node_Id
:=
2602 Project_Declaration_Of
(Node
, In_Tree
);
2604 In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
:= To
;
2605 end Set_Project_File_Includes_Unkept_Comments
;
2607 -------------------------
2608 -- Set_Project_Node_Of --
2609 -------------------------
2611 procedure Set_Project_Node_Of
2612 (Node
: Project_Node_Id
;
2613 In_Tree
: Project_Node_Tree_Ref
;
2614 To
: Project_Node_Id
;
2615 Limited_With
: Boolean := False)
2621 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2623 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2625 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2626 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2628 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2629 and then not Limited_With
2631 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2633 end Set_Project_Node_Of
;
2635 ---------------------------------------
2636 -- Set_Project_Of_Renamed_Package_Of --
2637 ---------------------------------------
2639 procedure Set_Project_Of_Renamed_Package_Of
2640 (Node
: Project_Node_Id
;
2641 In_Tree
: Project_Node_Tree_Ref
;
2642 To
: Project_Node_Id
)
2648 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2649 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2650 end Set_Project_Of_Renamed_Package_Of
;
2652 -------------------------
2653 -- Set_Source_Index_Of --
2654 -------------------------
2656 procedure Set_Source_Index_Of
2657 (Node
: Project_Node_Id
;
2658 In_Tree
: Project_Node_Tree_Ref
;
2665 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2667 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2668 N_Attribute_Declaration
));
2669 In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
:= To
;
2670 end Set_Source_Index_Of
;
2672 ------------------------
2673 -- Set_String_Type_Of --
2674 ------------------------
2676 procedure Set_String_Type_Of
2677 (Node
: Project_Node_Id
;
2678 In_Tree
: Project_Node_Tree_Ref
;
2679 To
: Project_Node_Id
)
2685 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2686 N_Variable_Reference
2688 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2689 N_Typed_Variable_Declaration
)
2691 In_Tree
.Project_Nodes
.Table
(To
).Kind
= N_String_Type_Declaration
);
2693 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2694 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2696 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2698 end Set_String_Type_Of
;
2700 -------------------------
2701 -- Set_String_Value_Of --
2702 -------------------------
2704 procedure Set_String_Value_Of
2705 (Node
: Project_Node_Id
;
2706 In_Tree
: Project_Node_Tree_Ref
;
2713 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2715 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2717 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2718 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
2719 end Set_String_Value_Of
;
2721 ---------------------
2722 -- Source_Index_Of --
2723 ---------------------
2725 function Source_Index_Of
2726 (Node
: Project_Node_Id
;
2727 In_Tree
: Project_Node_Tree_Ref
) return Int
2733 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2735 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2736 N_Attribute_Declaration
));
2737 return In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
;
2738 end Source_Index_Of
;
2740 --------------------
2741 -- String_Type_Of --
2742 --------------------
2744 function String_Type_Of
2745 (Node
: Project_Node_Id
;
2746 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
2752 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2753 N_Variable_Reference
2755 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2756 N_Typed_Variable_Declaration
));
2758 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2759 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
2761 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
2765 ---------------------
2766 -- String_Value_Of --
2767 ---------------------
2769 function String_Value_Of
2770 (Node
: Project_Node_Id
;
2771 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
2777 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2779 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2781 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2782 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
2783 end String_Value_Of
;
2785 --------------------
2786 -- Value_Is_Valid --
2787 --------------------
2789 function Value_Is_Valid
2790 (For_Typed_Variable
: Project_Node_Id
;
2791 In_Tree
: Project_Node_Tree_Ref
;
2792 Value
: Name_Id
) return Boolean
2796 (Present
(For_Typed_Variable
)
2798 (In_Tree
.Project_Nodes
.Table
(For_Typed_Variable
).Kind
=
2799 N_Typed_Variable_Declaration
));
2802 Current_String
: Project_Node_Id
:=
2803 First_Literal_String
2804 (String_Type_Of
(For_Typed_Variable
, In_Tree
),
2808 while Present
(Current_String
)
2810 String_Value_Of
(Current_String
, In_Tree
) /= Value
2813 Next_Literal_String
(Current_String
, In_Tree
);
2816 return Present
(Current_String
);
2821 -------------------------------
2822 -- There_Are_Unkept_Comments --
2823 -------------------------------
2825 function There_Are_Unkept_Comments
return Boolean is
2827 return Unkept_Comments
;
2828 end There_Are_Unkept_Comments
;
2830 --------------------
2831 -- Create_Project --
2832 --------------------
2834 function Create_Project
2835 (In_Tree
: Project_Node_Tree_Ref
;
2837 Full_Path
: Path_Name_Type
;
2838 Is_Config_File
: Boolean := False) return Project_Node_Id
2840 Project
: Project_Node_Id
;
2841 Qualifier
: Project_Qualifier
:= Unspecified
;
2843 Project
:= Default_Project_Node
(In_Tree
, N_Project
);
2844 Set_Name_Of
(Project
, In_Tree
, Name
);
2847 Path_Name_Type
(Get_Directory
(File_Name_Type
(Full_Path
))));
2848 Set_Path_Name_Of
(Project
, In_Tree
, Full_Path
);
2850 Set_Project_Declaration_Of
2852 Default_Project_Node
(In_Tree
, N_Project_Declaration
));
2854 if Is_Config_File
then
2855 Qualifier
:= Configuration
;
2858 if not Is_Config_File
then
2859 Prj
.Tree
.Tree_Private_Part
.Projects_Htable
.Set
2860 (In_Tree
.Projects_HT
,
2862 Prj
.Tree
.Tree_Private_Part
.Project_Name_And_Node
'
2864 Display_Name => Name,
2865 Canonical_Path => No_Path,
2868 Proj_Qualifier => Qualifier));
2878 procedure Add_At_End
2879 (Tree : Project_Node_Tree_Ref;
2880 Parent : Project_Node_Id;
2881 Expr : Project_Node_Id;
2882 Add_Before_First_Pkg : Boolean := False;
2883 Add_Before_First_Case : Boolean := False)
2885 Real_Parent : Project_Node_Id;
2886 New_Decl, Decl, Next : Project_Node_Id;
2887 Last, L : Project_Node_Id;
2890 if Kind_Of (Expr, Tree) /= N_Declarative_Item then
2891 New_Decl := Default_Project_Node (Tree, N_Declarative_Item);
2892 Set_Current_Item_Node (New_Decl, Tree, Expr);
2897 if Kind_Of (Parent, Tree) = N_Project then
2898 Real_Parent := Project_Declaration_Of (Parent, Tree);
2900 Real_Parent := Parent;
2903 Decl := First_Declarative_Item_Of (Real_Parent, Tree);
2905 if Decl = Empty_Node then
2906 Set_First_Declarative_Item_Of (Real_Parent, Tree, New_Decl);
2909 Next := Next_Declarative_Item (Decl, Tree);
2910 exit when Next = Empty_Node
2912 (Add_Before_First_Pkg
2913 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
2914 N_Package_Declaration)
2916 (Add_Before_First_Case
2917 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
2918 N_Case_Construction);
2922 -- In case Expr is in fact a range of declarative items
2926 L := Next_Declarative_Item (Last, Tree);
2927 exit when L = Empty_Node;
2931 -- In case Expr is in fact a range of declarative items
2935 L := Next_Declarative_Item (Last, Tree);
2936 exit when L = Empty_Node;
2940 Set_Next_Declarative_Item (Last, Tree, Next);
2941 Set_Next_Declarative_Item (Decl, Tree, New_Decl);
2945 ---------------------------
2946 -- Create_Literal_String --
2947 ---------------------------
2949 function Create_Literal_String
2950 (Str : Namet.Name_Id;
2951 Tree : Project_Node_Tree_Ref) return Project_Node_Id
2953 Node : Project_Node_Id;
2955 Node := Default_Project_Node (Tree, N_Literal_String, Prj.Single);
2956 Set_Next_Literal_String (Node, Tree, Empty_Node);
2957 Set_String_Value_Of (Node, Tree, Str);
2959 end Create_Literal_String;
2961 ---------------------------
2962 -- Enclose_In_Expression --
2963 ---------------------------
2965 function Enclose_In_Expression
2966 (Node : Project_Node_Id;
2967 Tree : Project_Node_Tree_Ref) return Project_Node_Id
2969 Expr : Project_Node_Id;
2971 if Kind_Of (Node, Tree) /= N_Expression then
2972 Expr := Default_Project_Node (Tree, N_Expression, Single);
2974 (Expr, Tree, Default_Project_Node (Tree, N_Term, Single));
2975 Set_Current_Term (First_Term (Expr, Tree), Tree, Node);
2980 end Enclose_In_Expression;
2982 --------------------
2983 -- Create_Package --
2984 --------------------
2986 function Create_Package
2987 (Tree : Project_Node_Tree_Ref;
2988 Project : Project_Node_Id;
2989 Pkg : String) return Project_Node_Id
2991 Pack : Project_Node_Id;
2995 Name_Len := Pkg'Length;
2996 Name_Buffer (1 .. Name_Len) := Pkg;
2999 -- Check if the package already exists
3001 Pack := First_Package_Of (Project, Tree);
3002 while Pack /= Empty_Node loop
3003 if Prj.Tree.Name_Of (Pack, Tree) = N then
3007 Pack := Next_Package_In_Project (Pack, Tree);
3010 -- Create the package and add it to the declarative item
3012 Pack := Default_Project_Node (Tree, N_Package_Declaration);
3013 Set_Name_Of (Pack, Tree, N);
3015 -- Find the correct package id to use
3017 Set_Package_Id_Of (Pack, Tree, Package_Node_Id_Of (N));
3019 -- Add it to the list of packages
3021 Set_Next_Package_In_Project
3022 (Pack, Tree, First_Package_Of (Project, Tree));
3023 Set_First_Package_Of (Project, Tree, Pack);
3025 Add_At_End (Tree, Project_Declaration_Of (Project, Tree), Pack);
3030 ----------------------
3031 -- Create_Attribute --
3032 ----------------------
3034 function Create_Attribute
3035 (Tree : Project_Node_Tree_Ref;
3036 Prj_Or_Pkg : Project_Node_Id;
3038 Index_Name : Name_Id := No_Name;
3039 Kind : Variable_Kind := List;
3040 At_Index : Integer := 0;
3041 Value : Project_Node_Id := Empty_Node) return Project_Node_Id
3043 Node : constant Project_Node_Id :=
3044 Default_Project_Node (Tree, N_Attribute_Declaration, Kind);
3046 Case_Insensitive : Boolean;
3048 Pkg : Package_Node_Id;
3049 Start_At : Attribute_Node_Id;
3050 Expr : Project_Node_Id;
3053 Set_Name_Of (Node, Tree, Name);
3055 if Index_Name /= No_Name then
3056 Set_Associative_Array_Index_Of (Node, Tree, Index_Name);
3059 if Prj_Or_Pkg /= Empty_Node then
3060 Add_At_End (Tree, Prj_Or_Pkg, Node);
3063 -- Find out the case sensitivity of the attribute
3065 if Prj_Or_Pkg /= Empty_Node
3066 and then Kind_Of (Prj_Or_Pkg, Tree) = N_Package_Declaration
3068 Pkg := Prj.Attr.Package_Node_Id_Of (Name_Of (Prj_Or_Pkg, Tree));
3069 Start_At := First_Attribute_Of (Pkg);
3071 Start_At := Attribute_First;
3074 Start_At := Attribute_Node_Id_Of (Name, Start_At);
3076 Attribute_Kind_Of (Start_At) = Case_Insensitive_Associative_Array;
3077 Tree.Project_Nodes.Table (Node).Flag1 := Case_Insensitive;
3079 if At_Index /= 0 then
3080 if Attribute_Kind_Of (Start_At) =
3081 Optional_Index_Associative_Array
3082 or else Attribute_Kind_Of (Start_At) =
3083 Optional_Index_Case_Insensitive_Associative_Array
3085 -- Results in: for Name ("index" at index) use "value";
3086 -- This is currently only used for executables.
3088 Set_Source_Index_Of (Node, Tree, To => Int (At_Index));
3091 -- Results in: for Name ("index") use "value" at index;
3093 -- ??? This limitation makes no sense, we should be able to
3094 -- set the source index on an expression.
3096 pragma Assert (Kind_Of (Value, Tree) = N_Literal_String);
3097 Set_Source_Index_Of (Value, Tree, To => Int (At_Index));
3101 if Value /= Empty_Node then
3102 Expr := Enclose_In_Expression (Value, Tree);
3103 Set_Expression_Of (Node, Tree, Expr);
3107 end Create_Attribute;