1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2014, 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
;
27 with Prj
.Env
; use Prj
.Env
;
30 with Ada
.Unchecked_Deallocation
;
32 package body Prj
.Tree
is
34 Node_With_Comments
: constant array (Project_Node_Kind
) of Boolean :=
36 N_With_Clause
=> True,
37 N_Project_Declaration
=> False,
38 N_Declarative_Item
=> False,
39 N_Package_Declaration
=> True,
40 N_String_Type_Declaration
=> True,
41 N_Literal_String
=> False,
42 N_Attribute_Declaration
=> True,
43 N_Typed_Variable_Declaration
=> True,
44 N_Variable_Declaration
=> True,
45 N_Expression
=> False,
47 N_Literal_String_List
=> False,
48 N_Variable_Reference
=> False,
49 N_External_Value
=> False,
50 N_Attribute_Reference
=> False,
51 N_Case_Construction
=> True,
53 N_Comment_Zones
=> True,
55 -- Indicates the kinds of node that may have associated comments
57 package Next_End_Nodes
is new Table
.Table
58 (Table_Component_Type
=> Project_Node_Id
,
59 Table_Index_Type
=> Natural,
62 Table_Increment
=> 100,
63 Table_Name
=> "Next_End_Nodes");
64 -- A stack of nodes to indicates to what node the next "end" is associated
66 use Tree_Private_Part
;
68 End_Of_Line_Node
: Project_Node_Id
:= Empty_Node
;
69 -- The node an end of line comment may be associated with
71 Previous_Line_Node
: Project_Node_Id
:= Empty_Node
;
72 -- The node an immediately following comment may be associated with
74 Previous_End_Node
: Project_Node_Id
:= Empty_Node
;
75 -- The node comments immediately following an "end" line may be
78 Unkept_Comments
: Boolean := False;
79 -- Set to True when some comments may not be associated with any node
81 function Comment_Zones_Of
82 (Node
: Project_Node_Id
;
83 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
;
84 -- Returns the ID of the N_Comment_Zones node associated with node Node.
85 -- If there is not already an N_Comment_Zones node, create one and
86 -- associate it with node Node.
92 procedure Add_Comments
93 (To
: Project_Node_Id
;
94 In_Tree
: Project_Node_Tree_Ref
;
95 Where
: Comment_Location
) is
96 Zone
: Project_Node_Id
:= Empty_Node
;
97 Previous
: Project_Node_Id
:= Empty_Node
;
102 and then In_Tree
.Project_Nodes
.Table
(To
).Kind
/= N_Comment
);
104 Zone
:= In_Tree
.Project_Nodes
.Table
(To
).Comments
;
108 -- Create new N_Comment_Zones node
110 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
111 In_Tree
.Project_Nodes
.Table
112 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
113 (Kind
=> N_Comment_Zones
,
114 Qualifier
=> Unspecified
,
115 Expr_Kind
=> Undefined
,
116 Location
=> No_Location
,
117 Directory
=> No_Path
,
118 Variables
=> Empty_Node
,
119 Packages
=> Empty_Node
,
120 Pkg_Id
=> Empty_Package
,
123 Path_Name
=> No_Path
,
125 Default
=> Empty_Value
,
126 Field1
=> Empty_Node
,
127 Field2
=> Empty_Node
,
128 Field3
=> Empty_Node
,
129 Field4
=> Empty_Node
,
132 Comments
=> Empty_Node
);
134 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
135 In_Tree
.Project_Nodes
.Table
(To
).Comments
:= Zone
;
138 if Where
= End_Of_Line
then
139 In_Tree
.Project_Nodes
.Table
(Zone
).Value
:= Comments
.Table
(1).Value
;
142 -- Get each comments in the Comments table and link them to node To
144 for J
in 1 .. Comments
.Last
loop
146 -- Create new N_Comment node
148 if (Where
= After
or else Where
= After_End
)
149 and then Token
/= Tok_EOF
150 and then Comments
.Table
(J
).Follows_Empty_Line
152 Comments
.Table
(1 .. Comments
.Last
- J
+ 1) :=
153 Comments
.Table
(J
.. Comments
.Last
);
154 Comments
.Set_Last
(Comments
.Last
- J
+ 1);
158 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
159 In_Tree
.Project_Nodes
.Table
160 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
162 Qualifier
=> Unspecified
,
163 Expr_Kind
=> Undefined
,
164 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
166 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
167 Location
=> No_Location
,
168 Directory
=> No_Path
,
169 Variables
=> Empty_Node
,
170 Packages
=> Empty_Node
,
171 Pkg_Id
=> Empty_Package
,
174 Path_Name
=> No_Path
,
175 Value
=> Comments
.Table
(J
).Value
,
176 Default
=> Empty_Value
,
177 Field1
=> Empty_Node
,
178 Field2
=> Empty_Node
,
179 Field3
=> Empty_Node
,
180 Field4
=> Empty_Node
,
181 Comments
=> Empty_Node
);
183 -- If this is the first comment, put it in the right field of
186 if No
(Previous
) then
189 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
190 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
193 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:=
194 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
197 In_Tree
.Project_Nodes
.Table
(Zone
).Field3
:=
198 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
201 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:=
202 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
209 -- When it is not the first, link it to the previous one
211 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
212 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
215 -- This node becomes the previous one for the next comment, if
218 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
222 -- Empty the Comments table, so that there is no risk to link the same
223 -- comments to another node.
225 Comments
.Set_Last
(0);
228 --------------------------------
229 -- Associative_Array_Index_Of --
230 --------------------------------
232 function Associative_Array_Index_Of
233 (Node
: Project_Node_Id
;
234 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
240 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
242 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
243 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
244 end Associative_Array_Index_Of
;
246 ----------------------------
247 -- Associative_Package_Of --
248 ----------------------------
250 function Associative_Package_Of
251 (Node
: Project_Node_Id
;
252 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
258 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
));
259 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
260 end Associative_Package_Of
;
262 ----------------------------
263 -- Associative_Project_Of --
264 ----------------------------
266 function Associative_Project_Of
267 (Node
: Project_Node_Id
;
268 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
274 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
));
275 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
276 end Associative_Project_Of
;
278 ----------------------
279 -- Case_Insensitive --
280 ----------------------
282 function Case_Insensitive
283 (Node
: Project_Node_Id
;
284 In_Tree
: Project_Node_Tree_Ref
) return Boolean
290 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
292 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
293 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
294 end Case_Insensitive
;
296 --------------------------------
297 -- Case_Variable_Reference_Of --
298 --------------------------------
300 function Case_Variable_Reference_Of
301 (Node
: Project_Node_Id
;
302 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
308 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
309 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
310 end Case_Variable_Reference_Of
;
312 ----------------------
313 -- Comment_Zones_Of --
314 ----------------------
316 function Comment_Zones_Of
317 (Node
: Project_Node_Id
;
318 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
320 Zone
: Project_Node_Id
;
323 pragma Assert
(Present
(Node
));
324 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
326 -- If there is not already an N_Comment_Zones associated, create a new
327 -- one and associate it with node Node.
330 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
331 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
332 In_Tree
.Project_Nodes
.Table
(Zone
) :=
333 (Kind
=> N_Comment_Zones
,
334 Qualifier
=> Unspecified
,
335 Location
=> No_Location
,
336 Directory
=> No_Path
,
337 Expr_Kind
=> Undefined
,
338 Variables
=> Empty_Node
,
339 Packages
=> Empty_Node
,
340 Pkg_Id
=> Empty_Package
,
343 Path_Name
=> No_Path
,
345 Default
=> Empty_Value
,
346 Field1
=> Empty_Node
,
347 Field2
=> Empty_Node
,
348 Field3
=> Empty_Node
,
349 Field4
=> Empty_Node
,
352 Comments
=> Empty_Node
);
353 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= Zone
;
357 end Comment_Zones_Of
;
359 -----------------------
360 -- Current_Item_Node --
361 -----------------------
363 function Current_Item_Node
364 (Node
: Project_Node_Id
;
365 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
371 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
372 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
373 end Current_Item_Node
;
379 function Current_Term
380 (Node
: Project_Node_Id
;
381 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
387 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
388 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
396 (Node
: Project_Node_Id
;
397 In_Tree
: Project_Node_Tree_Ref
) return Attribute_Default_Value
403 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
);
404 return In_Tree
.Project_Nodes
.Table
(Node
).Default
;
407 --------------------------
408 -- Default_Project_Node --
409 --------------------------
411 function Default_Project_Node
412 (In_Tree
: Project_Node_Tree_Ref
;
413 Of_Kind
: Project_Node_Kind
;
414 And_Expr_Kind
: Variable_Kind
:= Undefined
) return Project_Node_Id
416 Result
: Project_Node_Id
;
417 Zone
: Project_Node_Id
;
418 Previous
: Project_Node_Id
;
421 -- Create new node with specified kind and expression kind
423 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
424 In_Tree
.Project_Nodes
.Table
425 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
427 Qualifier
=> Unspecified
,
428 Location
=> No_Location
,
429 Directory
=> No_Path
,
430 Expr_Kind
=> And_Expr_Kind
,
431 Variables
=> Empty_Node
,
432 Packages
=> Empty_Node
,
433 Pkg_Id
=> Empty_Package
,
436 Path_Name
=> No_Path
,
438 Default
=> Empty_Value
,
439 Field1
=> Empty_Node
,
440 Field2
=> Empty_Node
,
441 Field3
=> Empty_Node
,
442 Field4
=> Empty_Node
,
445 Comments
=> Empty_Node
);
447 -- Save the new node for the returned value
449 Result
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
451 if Comments
.Last
> 0 then
453 -- If this is not a node with comments, then set the flag
455 if not Node_With_Comments
(Of_Kind
) then
456 Unkept_Comments
:= True;
458 elsif Of_Kind
/= N_Comment
and then Of_Kind
/= N_Comment_Zones
then
460 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
461 In_Tree
.Project_Nodes
.Table
462 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
463 (Kind
=> N_Comment_Zones
,
464 Qualifier
=> Unspecified
,
465 Expr_Kind
=> Undefined
,
466 Location
=> No_Location
,
467 Directory
=> No_Path
,
468 Variables
=> Empty_Node
,
469 Packages
=> Empty_Node
,
470 Pkg_Id
=> Empty_Package
,
473 Path_Name
=> No_Path
,
475 Default
=> Empty_Value
,
476 Field1
=> Empty_Node
,
477 Field2
=> Empty_Node
,
478 Field3
=> Empty_Node
,
479 Field4
=> Empty_Node
,
482 Comments
=> Empty_Node
);
484 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
485 In_Tree
.Project_Nodes
.Table
(Result
).Comments
:= Zone
;
486 Previous
:= Empty_Node
;
488 for J
in 1 .. Comments
.Last
loop
490 -- Create a new N_Comment node
492 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
493 In_Tree
.Project_Nodes
.Table
494 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
496 Qualifier
=> Unspecified
,
497 Expr_Kind
=> Undefined
,
498 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
500 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
501 Location
=> No_Location
,
502 Directory
=> No_Path
,
503 Variables
=> Empty_Node
,
504 Packages
=> Empty_Node
,
505 Pkg_Id
=> Empty_Package
,
508 Path_Name
=> No_Path
,
509 Value
=> Comments
.Table
(J
).Value
,
510 Default
=> Empty_Value
,
511 Field1
=> Empty_Node
,
512 Field2
=> Empty_Node
,
513 Field3
=> Empty_Node
,
514 Field4
=> Empty_Node
,
515 Comments
=> Empty_Node
);
517 -- Link it to the N_Comment_Zones node, if it is the first,
518 -- otherwise to the previous one.
520 if No
(Previous
) then
521 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
522 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
525 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
526 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
529 -- This new node will be the previous one for the next
530 -- N_Comment node, if there is one.
532 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
535 -- Empty the Comments table after all comments have been processed
537 Comments
.Set_Last
(0);
542 end Default_Project_Node
;
548 function Directory_Of
549 (Node
: Project_Node_Id
;
550 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
556 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
557 return In_Tree
.Project_Nodes
.Table
(Node
).Directory
;
560 -------------------------
561 -- End_Of_Line_Comment --
562 -------------------------
564 function End_Of_Line_Comment
565 (Node
: Project_Node_Id
;
566 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
568 Zone
: Project_Node_Id
:= Empty_Node
;
571 pragma Assert
(Present
(Node
));
572 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
577 return In_Tree
.Project_Nodes
.Table
(Zone
).Value
;
579 end End_Of_Line_Comment
;
581 ------------------------
582 -- Expression_Kind_Of --
583 ------------------------
585 function Expression_Kind_Of
586 (Node
: Project_Node_Id
;
587 In_Tree
: Project_Node_Tree_Ref
) return Variable_Kind
592 and then -- should use Nkind_In here ??? why not???
593 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
595 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
597 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
599 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
600 N_Typed_Variable_Declaration
602 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
604 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
606 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
608 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
610 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
612 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
));
613 return In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
;
614 end Expression_Kind_Of
;
620 function Expression_Of
621 (Node
: Project_Node_Id
;
622 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
628 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
629 N_Attribute_Declaration
631 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
632 N_Typed_Variable_Declaration
634 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
635 N_Variable_Declaration
));
637 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
640 -------------------------
641 -- Extended_Project_Of --
642 -------------------------
644 function Extended_Project_Of
645 (Node
: Project_Node_Id
;
646 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
652 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
653 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
654 end Extended_Project_Of
;
656 ------------------------------
657 -- Extended_Project_Path_Of --
658 ------------------------------
660 function Extended_Project_Path_Of
661 (Node
: Project_Node_Id
;
662 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
668 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
669 return Path_Name_Type
(In_Tree
.Project_Nodes
.Table
(Node
).Value
);
670 end Extended_Project_Path_Of
;
672 --------------------------
673 -- Extending_Project_Of --
674 --------------------------
675 function Extending_Project_Of
676 (Node
: Project_Node_Id
;
677 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
683 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
684 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
685 end Extending_Project_Of
;
687 ---------------------------
688 -- External_Reference_Of --
689 ---------------------------
691 function External_Reference_Of
692 (Node
: Project_Node_Id
;
693 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
699 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
700 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
701 end External_Reference_Of
;
703 -------------------------
704 -- External_Default_Of --
705 -------------------------
707 function External_Default_Of
708 (Node
: Project_Node_Id
;
709 In_Tree
: Project_Node_Tree_Ref
)
710 return Project_Node_Id
716 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
717 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
718 end External_Default_Of
;
720 ------------------------
721 -- First_Case_Item_Of --
722 ------------------------
724 function First_Case_Item_Of
725 (Node
: Project_Node_Id
;
726 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
732 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
733 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
734 end First_Case_Item_Of
;
736 ---------------------
737 -- First_Choice_Of --
738 ---------------------
740 function First_Choice_Of
741 (Node
: Project_Node_Id
;
742 In_Tree
: Project_Node_Tree_Ref
)
743 return Project_Node_Id
749 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
750 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
753 -------------------------
754 -- First_Comment_After --
755 -------------------------
757 function First_Comment_After
758 (Node
: Project_Node_Id
;
759 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
761 Zone
: Project_Node_Id
:= Empty_Node
;
763 pragma Assert
(Present
(Node
));
764 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
770 return In_Tree
.Project_Nodes
.Table
(Zone
).Field2
;
772 end First_Comment_After
;
774 -----------------------------
775 -- First_Comment_After_End --
776 -----------------------------
778 function First_Comment_After_End
779 (Node
: Project_Node_Id
;
780 In_Tree
: Project_Node_Tree_Ref
)
781 return Project_Node_Id
783 Zone
: Project_Node_Id
:= Empty_Node
;
786 pragma Assert
(Present
(Node
));
787 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
793 return In_Tree
.Project_Nodes
.Table
(Zone
).Comments
;
795 end First_Comment_After_End
;
797 --------------------------
798 -- First_Comment_Before --
799 --------------------------
801 function First_Comment_Before
802 (Node
: Project_Node_Id
;
803 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
805 Zone
: Project_Node_Id
:= Empty_Node
;
808 pragma Assert
(Present
(Node
));
809 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
815 return In_Tree
.Project_Nodes
.Table
(Zone
).Field1
;
817 end First_Comment_Before
;
819 ------------------------------
820 -- First_Comment_Before_End --
821 ------------------------------
823 function First_Comment_Before_End
824 (Node
: Project_Node_Id
;
825 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
827 Zone
: Project_Node_Id
:= Empty_Node
;
830 pragma Assert
(Present
(Node
));
831 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
837 return In_Tree
.Project_Nodes
.Table
(Zone
).Field3
;
839 end First_Comment_Before_End
;
841 -------------------------------
842 -- First_Declarative_Item_Of --
843 -------------------------------
845 function First_Declarative_Item_Of
846 (Node
: Project_Node_Id
;
847 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
853 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
855 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
857 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
859 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
860 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
862 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
864 end First_Declarative_Item_Of
;
866 ------------------------------
867 -- First_Expression_In_List --
868 ------------------------------
870 function First_Expression_In_List
871 (Node
: Project_Node_Id
;
872 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
878 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
879 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
880 end First_Expression_In_List
;
882 --------------------------
883 -- First_Literal_String --
884 --------------------------
886 function First_Literal_String
887 (Node
: Project_Node_Id
;
888 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
894 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
895 N_String_Type_Declaration
);
896 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
897 end First_Literal_String
;
899 ----------------------
900 -- First_Package_Of --
901 ----------------------
903 function First_Package_Of
904 (Node
: Project_Node_Id
;
905 In_Tree
: Project_Node_Tree_Ref
) return Package_Declaration_Id
911 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
912 return In_Tree
.Project_Nodes
.Table
(Node
).Packages
;
913 end First_Package_Of
;
915 --------------------------
916 -- First_String_Type_Of --
917 --------------------------
919 function First_String_Type_Of
920 (Node
: Project_Node_Id
;
921 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
927 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
928 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
929 end First_String_Type_Of
;
936 (Node
: Project_Node_Id
;
937 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
943 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
944 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
947 -----------------------
948 -- First_Variable_Of --
949 -----------------------
951 function First_Variable_Of
952 (Node
: Project_Node_Id
;
953 In_Tree
: Project_Node_Tree_Ref
) return Variable_Node_Id
959 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
961 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
963 return In_Tree
.Project_Nodes
.Table
(Node
).Variables
;
964 end First_Variable_Of
;
966 --------------------------
967 -- First_With_Clause_Of --
968 --------------------------
970 function First_With_Clause_Of
971 (Node
: Project_Node_Id
;
972 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
978 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
979 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
980 end First_With_Clause_Of
;
982 ------------------------
983 -- Follows_Empty_Line --
984 ------------------------
986 function Follows_Empty_Line
987 (Node
: Project_Node_Id
;
988 In_Tree
: Project_Node_Tree_Ref
) return Boolean
994 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
995 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
996 end Follows_Empty_Line
;
1002 function Hash
(N
: Project_Node_Id
) return Header_Num
is
1004 return Header_Num
(N
mod Project_Node_Id
(Header_Num
'Last));
1011 procedure Initialize
(Tree
: Project_Node_Tree_Ref
) is
1013 Project_Node_Table
.Init
(Tree
.Project_Nodes
);
1014 Projects_Htable
.Reset
(Tree
.Projects_HT
);
1017 --------------------
1018 -- Override_Flags --
1019 --------------------
1021 procedure Override_Flags
1022 (Self
: in out Environment
;
1023 Flags
: Prj
.Processing_Flags
)
1026 Self
.Flags
:= Flags
;
1033 procedure Initialize
1034 (Self
: out Environment
;
1035 Flags
: Processing_Flags
)
1038 -- Do not reset the external references, in case we are reloading a
1039 -- project, since we want to preserve the current environment. But we
1040 -- still need to ensure that the external references are properly
1043 Prj
.Ext
.Initialize
(Self
.External
);
1045 Self
.Flags
:= Flags
;
1048 -------------------------
1049 -- Initialize_And_Copy --
1050 -------------------------
1052 procedure Initialize_And_Copy
1053 (Self
: out Environment
;
1054 Copy_From
: Environment
)
1057 Self
.Flags
:= Copy_From
.Flags
;
1058 Prj
.Ext
.Initialize
(Self
.External
, Copy_From
=> Copy_From
.External
);
1059 Prj
.Env
.Copy
(From
=> Copy_From
.Project_Path
, To
=> Self
.Project_Path
);
1060 end Initialize_And_Copy
;
1066 procedure Free
(Self
: in out Environment
) is
1068 Prj
.Ext
.Free
(Self
.External
);
1069 Free
(Self
.Project_Path
);
1076 procedure Free
(Proj
: in out Project_Node_Tree_Ref
) is
1077 procedure Unchecked_Free
is new Ada
.Unchecked_Deallocation
1078 (Project_Node_Tree_Data
, Project_Node_Tree_Ref
);
1080 if Proj
/= null then
1081 Project_Node_Table
.Free
(Proj
.Project_Nodes
);
1082 Projects_Htable
.Reset
(Proj
.Projects_HT
);
1083 Unchecked_Free
(Proj
);
1087 -------------------------------
1088 -- Is_Followed_By_Empty_Line --
1089 -------------------------------
1091 function Is_Followed_By_Empty_Line
1092 (Node
: Project_Node_Id
;
1093 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1099 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1100 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1101 end Is_Followed_By_Empty_Line
;
1103 ----------------------
1104 -- Is_Extending_All --
1105 ----------------------
1107 function Is_Extending_All
1108 (Node
: Project_Node_Id
;
1109 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1115 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1117 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1118 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1119 end Is_Extending_All
;
1121 -------------------------
1122 -- Is_Not_Last_In_List --
1123 -------------------------
1125 function Is_Not_Last_In_List
1126 (Node
: Project_Node_Id
;
1127 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1133 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1134 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
1135 end Is_Not_Last_In_List
;
1137 -------------------------------------
1138 -- Imported_Or_Extended_Project_Of --
1139 -------------------------------------
1141 function Imported_Or_Extended_Project_Of
1142 (Project
: Project_Node_Id
;
1143 In_Tree
: Project_Node_Tree_Ref
;
1144 With_Name
: Name_Id
) return Project_Node_Id
1146 With_Clause
: Project_Node_Id
;
1147 Result
: Project_Node_Id
:= Empty_Node
;
1150 -- First check all the imported projects
1152 With_Clause
:= First_With_Clause_Of
(Project
, In_Tree
);
1153 while Present
(With_Clause
) loop
1155 -- Only non limited imported project may be used as prefix of
1156 -- variables or attributes.
1158 Result
:= Non_Limited_Project_Node_Of
(With_Clause
, In_Tree
);
1159 while Present
(Result
) loop
1160 if Name_Of
(Result
, In_Tree
) = With_Name
then
1166 (Project_Declaration_Of
(Result
, In_Tree
), In_Tree
);
1169 With_Clause
:= Next_With_Clause_Of
(With_Clause
, In_Tree
);
1172 -- If it is not an imported project, it might be an extended project
1174 if No
(With_Clause
) then
1179 (Project_Declaration_Of
(Result
, In_Tree
), In_Tree
);
1181 exit when No
(Result
)
1182 or else Name_Of
(Result
, In_Tree
) = With_Name
;
1187 end Imported_Or_Extended_Project_Of
;
1194 (Node
: Project_Node_Id
;
1195 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Kind
1198 pragma Assert
(Present
(Node
));
1199 return In_Tree
.Project_Nodes
.Table
(Node
).Kind
;
1206 function Location_Of
1207 (Node
: Project_Node_Id
;
1208 In_Tree
: Project_Node_Tree_Ref
) return Source_Ptr
1211 pragma Assert
(Present
(Node
));
1212 return In_Tree
.Project_Nodes
.Table
(Node
).Location
;
1220 (Node
: Project_Node_Id
;
1221 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
1224 pragma Assert
(Present
(Node
));
1225 return In_Tree
.Project_Nodes
.Table
(Node
).Name
;
1228 --------------------
1229 -- Next_Case_Item --
1230 --------------------
1232 function Next_Case_Item
1233 (Node
: Project_Node_Id
;
1234 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1240 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
1241 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1248 function Next_Comment
1249 (Node
: Project_Node_Id
;
1250 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1256 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1257 return In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
1260 ---------------------------
1261 -- Next_Declarative_Item --
1262 ---------------------------
1264 function Next_Declarative_Item
1265 (Node
: Project_Node_Id
;
1266 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1272 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1273 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1274 end Next_Declarative_Item
;
1276 -----------------------------
1277 -- Next_Expression_In_List --
1278 -----------------------------
1280 function Next_Expression_In_List
1281 (Node
: Project_Node_Id
;
1282 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1288 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
1289 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1290 end Next_Expression_In_List
;
1292 -------------------------
1293 -- Next_Literal_String --
1294 -------------------------
1296 function Next_Literal_String
1297 (Node
: Project_Node_Id
;
1298 In_Tree
: Project_Node_Tree_Ref
)
1299 return Project_Node_Id
1305 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
1306 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1307 end Next_Literal_String
;
1309 -----------------------------
1310 -- Next_Package_In_Project --
1311 -----------------------------
1313 function Next_Package_In_Project
1314 (Node
: Project_Node_Id
;
1315 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1321 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1322 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1323 end Next_Package_In_Project
;
1325 ----------------------
1326 -- Next_String_Type --
1327 ----------------------
1329 function Next_String_Type
1330 (Node
: Project_Node_Id
;
1331 In_Tree
: Project_Node_Tree_Ref
)
1332 return Project_Node_Id
1338 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1339 N_String_Type_Declaration
);
1340 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1341 end Next_String_Type
;
1348 (Node
: Project_Node_Id
;
1349 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1354 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1355 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1362 function Next_Variable
1363 (Node
: Project_Node_Id
;
1364 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1370 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1371 N_Typed_Variable_Declaration
1373 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1374 N_Variable_Declaration
));
1376 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1379 -------------------------
1380 -- Next_With_Clause_Of --
1381 -------------------------
1383 function Next_With_Clause_Of
1384 (Node
: Project_Node_Id
;
1385 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1391 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1392 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1393 end Next_With_Clause_Of
;
1399 function No
(Node
: Project_Node_Id
) return Boolean is
1401 return Node
= Empty_Node
;
1404 ---------------------------------
1405 -- Non_Limited_Project_Node_Of --
1406 ---------------------------------
1408 function Non_Limited_Project_Node_Of
1409 (Node
: Project_Node_Id
;
1410 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1416 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1417 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1418 end Non_Limited_Project_Node_Of
;
1424 function Package_Id_Of
1425 (Node
: Project_Node_Id
;
1426 In_Tree
: Project_Node_Tree_Ref
) return Package_Node_Id
1432 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1433 return In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
;
1436 ---------------------
1437 -- Package_Node_Of --
1438 ---------------------
1440 function Package_Node_Of
1441 (Node
: Project_Node_Id
;
1442 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1448 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1450 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1451 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1452 end Package_Node_Of
;
1458 function Path_Name_Of
1459 (Node
: Project_Node_Id
;
1460 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
1466 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1468 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1469 return In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
;
1476 function Present
(Node
: Project_Node_Id
) return Boolean is
1478 return Node
/= Empty_Node
;
1481 ----------------------------
1482 -- Project_Declaration_Of --
1483 ----------------------------
1485 function Project_Declaration_Of
1486 (Node
: Project_Node_Id
;
1487 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1493 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1494 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1495 end Project_Declaration_Of
;
1497 --------------------------
1498 -- Project_Qualifier_Of --
1499 --------------------------
1501 function Project_Qualifier_Of
1502 (Node
: Project_Node_Id
;
1503 In_Tree
: Project_Node_Tree_Ref
) return Project_Qualifier
1509 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1510 return In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
;
1511 end Project_Qualifier_Of
;
1513 -----------------------
1514 -- Parent_Project_Of --
1515 -----------------------
1517 function Parent_Project_Of
1518 (Node
: Project_Node_Id
;
1519 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1525 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1526 return In_Tree
.Project_Nodes
.Table
(Node
).Field4
;
1527 end Parent_Project_Of
;
1529 -------------------------------------------
1530 -- Project_File_Includes_Unkept_Comments --
1531 -------------------------------------------
1533 function Project_File_Includes_Unkept_Comments
1534 (Node
: Project_Node_Id
;
1535 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1537 Declaration
: constant Project_Node_Id
:=
1538 Project_Declaration_Of
(Node
, In_Tree
);
1540 return In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
;
1541 end Project_File_Includes_Unkept_Comments
;
1543 ---------------------
1544 -- Project_Node_Of --
1545 ---------------------
1547 function Project_Node_Of
1548 (Node
: Project_Node_Id
;
1549 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1555 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
1557 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1559 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1560 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1561 end Project_Node_Of
;
1563 -----------------------------------
1564 -- Project_Of_Renamed_Package_Of --
1565 -----------------------------------
1567 function Project_Of_Renamed_Package_Of
1568 (Node
: Project_Node_Id
;
1569 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1575 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1576 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1577 end Project_Of_Renamed_Package_Of
;
1579 --------------------------
1580 -- Remove_Next_End_Node --
1581 --------------------------
1583 procedure Remove_Next_End_Node
is
1585 Next_End_Nodes
.Decrement_Last
;
1586 end Remove_Next_End_Node
;
1592 procedure Reset_State
is
1594 End_Of_Line_Node
:= Empty_Node
;
1595 Previous_Line_Node
:= Empty_Node
;
1596 Previous_End_Node
:= Empty_Node
;
1597 Unkept_Comments
:= False;
1598 Comments
.Set_Last
(0);
1601 ----------------------
1602 -- Restore_And_Free --
1603 ----------------------
1605 procedure Restore_And_Free
(S
: in out Comment_State
) is
1606 procedure Unchecked_Free
is new
1607 Ada
.Unchecked_Deallocation
(Comment_Array
, Comments_Ptr
);
1610 End_Of_Line_Node
:= S
.End_Of_Line_Node
;
1611 Previous_Line_Node
:= S
.Previous_Line_Node
;
1612 Previous_End_Node
:= S
.Previous_End_Node
;
1613 Next_End_Nodes
.Set_Last
(0);
1614 Unkept_Comments
:= S
.Unkept_Comments
;
1616 Comments
.Set_Last
(0);
1618 for J
in S
.Comments
'Range loop
1619 Comments
.Increment_Last
;
1620 Comments
.Table
(Comments
.Last
) := S
.Comments
(J
);
1623 Unchecked_Free
(S
.Comments
);
1624 end Restore_And_Free
;
1630 procedure Save
(S
: out Comment_State
) is
1631 Cmts
: constant Comments_Ptr
:= new Comment_Array
(1 .. Comments
.Last
);
1634 for J
in 1 .. Comments
.Last
loop
1635 Cmts
(J
) := Comments
.Table
(J
);
1639 (End_Of_Line_Node
=> End_Of_Line_Node
,
1640 Previous_Line_Node
=> Previous_Line_Node
,
1641 Previous_End_Node
=> Previous_End_Node
,
1642 Unkept_Comments
=> Unkept_Comments
,
1650 procedure Scan
(In_Tree
: Project_Node_Tree_Ref
) is
1651 Empty_Line
: Boolean := False;
1654 -- If there are comments, then they will not be kept. Set the flag and
1655 -- clear the comments.
1657 if Comments
.Last
> 0 then
1658 Unkept_Comments
:= True;
1659 Comments
.Set_Last
(0);
1662 -- Loop until a token other that End_Of_Line or Comment is found
1665 Prj
.Err
.Scanner
.Scan
;
1668 when Tok_End_Of_Line
=>
1669 if Prev_Token
= Tok_End_Of_Line
then
1672 if Comments
.Last
> 0 then
1673 Comments
.Table
(Comments
.Last
).Is_Followed_By_Empty_Line
1679 -- If this is a line comment, add it to the comment table
1681 if Prev_Token
= Tok_End_Of_Line
1682 or else Prev_Token
= No_Token
1684 Comments
.Increment_Last
;
1685 Comments
.Table
(Comments
.Last
) :=
1686 (Value
=> Comment_Id
,
1687 Follows_Empty_Line
=> Empty_Line
,
1688 Is_Followed_By_Empty_Line
=> False);
1690 -- Otherwise, it is an end of line comment. If there is an
1691 -- end of line node specified, associate the comment with
1694 elsif Present
(End_Of_Line_Node
) then
1696 Zones
: constant Project_Node_Id
:=
1697 Comment_Zones_Of
(End_Of_Line_Node
, In_Tree
);
1699 In_Tree
.Project_Nodes
.Table
(Zones
).Value
:= Comment_Id
;
1702 -- Otherwise, this end of line node cannot be kept
1705 Unkept_Comments
:= True;
1706 Comments
.Set_Last
(0);
1709 Empty_Line
:= False;
1713 -- If there are comments, where the first comment is not
1714 -- following an empty line, put the initial uninterrupted
1715 -- comment zone with the node of the preceding line (either
1716 -- a Previous_Line or a Previous_End node), if any.
1718 if Comments
.Last
> 0 and then
1719 not Comments
.Table
(1).Follows_Empty_Line
1721 if Present
(Previous_Line_Node
) then
1723 (To
=> Previous_Line_Node
,
1725 In_Tree
=> In_Tree
);
1727 elsif Present
(Previous_End_Node
) then
1729 (To
=> Previous_End_Node
,
1731 In_Tree
=> In_Tree
);
1735 -- If there are still comments and the token is "end", then
1736 -- put these comments with the Next_End node, if any;
1737 -- otherwise, these comments cannot be kept. Always clear
1740 if Comments
.Last
> 0 and then Token
= Tok_End
then
1741 if Next_End_Nodes
.Last
> 0 then
1743 (To
=> Next_End_Nodes
.Table
(Next_End_Nodes
.Last
),
1744 Where
=> Before_End
,
1745 In_Tree
=> In_Tree
);
1748 Unkept_Comments
:= True;
1751 Comments
.Set_Last
(0);
1754 -- Reset the End_Of_Line, Previous_Line and Previous_End nodes
1755 -- so that they are not used again.
1757 End_Of_Line_Node
:= Empty_Node
;
1758 Previous_Line_Node
:= Empty_Node
;
1759 Previous_End_Node
:= Empty_Node
;
1768 ------------------------------------
1769 -- Set_Associative_Array_Index_Of --
1770 ------------------------------------
1772 procedure Set_Associative_Array_Index_Of
1773 (Node
: Project_Node_Id
;
1774 In_Tree
: Project_Node_Tree_Ref
;
1781 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1783 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1784 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
1785 end Set_Associative_Array_Index_Of
;
1787 --------------------------------
1788 -- Set_Associative_Package_Of --
1789 --------------------------------
1791 procedure Set_Associative_Package_Of
1792 (Node
: Project_Node_Id
;
1793 In_Tree
: Project_Node_Tree_Ref
;
1794 To
: Project_Node_Id
)
1800 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
);
1801 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
1802 end Set_Associative_Package_Of
;
1804 --------------------------------
1805 -- Set_Associative_Project_Of --
1806 --------------------------------
1808 procedure Set_Associative_Project_Of
1809 (Node
: Project_Node_Id
;
1810 In_Tree
: Project_Node_Tree_Ref
;
1811 To
: Project_Node_Id
)
1817 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1818 N_Attribute_Declaration
));
1819 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1820 end Set_Associative_Project_Of
;
1822 --------------------------
1823 -- Set_Case_Insensitive --
1824 --------------------------
1826 procedure Set_Case_Insensitive
1827 (Node
: Project_Node_Id
;
1828 In_Tree
: Project_Node_Tree_Ref
;
1835 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1837 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1838 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= To
;
1839 end Set_Case_Insensitive
;
1841 ------------------------------------
1842 -- Set_Case_Variable_Reference_Of --
1843 ------------------------------------
1845 procedure Set_Case_Variable_Reference_Of
1846 (Node
: Project_Node_Id
;
1847 In_Tree
: Project_Node_Tree_Ref
;
1848 To
: Project_Node_Id
)
1854 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
1855 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1856 end Set_Case_Variable_Reference_Of
;
1858 ---------------------------
1859 -- Set_Current_Item_Node --
1860 ---------------------------
1862 procedure Set_Current_Item_Node
1863 (Node
: Project_Node_Id
;
1864 In_Tree
: Project_Node_Tree_Ref
;
1865 To
: Project_Node_Id
)
1871 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1872 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1873 end Set_Current_Item_Node
;
1875 ----------------------
1876 -- Set_Current_Term --
1877 ----------------------
1879 procedure Set_Current_Term
1880 (Node
: Project_Node_Id
;
1881 In_Tree
: Project_Node_Tree_Ref
;
1882 To
: Project_Node_Id
)
1888 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1889 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1890 end Set_Current_Term
;
1892 --------------------
1893 -- Set_Default_Of --
1894 --------------------
1896 procedure Set_Default_Of
1897 (Node
: Project_Node_Id
;
1898 In_Tree
: Project_Node_Tree_Ref
;
1899 To
: Attribute_Default_Value
)
1905 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
);
1906 In_Tree
.Project_Nodes
.Table
(Node
).Default
:= To
;
1909 ----------------------
1910 -- Set_Directory_Of --
1911 ----------------------
1913 procedure Set_Directory_Of
1914 (Node
: Project_Node_Id
;
1915 In_Tree
: Project_Node_Tree_Ref
;
1916 To
: Path_Name_Type
)
1922 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1923 In_Tree
.Project_Nodes
.Table
(Node
).Directory
:= To
;
1924 end Set_Directory_Of
;
1926 ---------------------
1927 -- Set_End_Of_Line --
1928 ---------------------
1930 procedure Set_End_Of_Line
(To
: Project_Node_Id
) is
1932 End_Of_Line_Node
:= To
;
1933 end Set_End_Of_Line
;
1935 ----------------------------
1936 -- Set_Expression_Kind_Of --
1937 ----------------------------
1939 procedure Set_Expression_Kind_Of
1940 (Node
: Project_Node_Id
;
1941 In_Tree
: Project_Node_Tree_Ref
;
1947 and then -- should use Nkind_In here ??? why not???
1948 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
1950 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1952 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
1954 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1955 N_Typed_Variable_Declaration
1957 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
1959 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
1961 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
1963 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1965 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
1967 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
));
1968 In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
:= To
;
1969 end Set_Expression_Kind_Of
;
1971 -----------------------
1972 -- Set_Expression_Of --
1973 -----------------------
1975 procedure Set_Expression_Of
1976 (Node
: Project_Node_Id
;
1977 In_Tree
: Project_Node_Tree_Ref
;
1978 To
: Project_Node_Id
)
1984 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1985 N_Attribute_Declaration
1987 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1988 N_Typed_Variable_Declaration
1990 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1991 N_Variable_Declaration
));
1992 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1993 end Set_Expression_Of
;
1995 -------------------------------
1996 -- Set_External_Reference_Of --
1997 -------------------------------
1999 procedure Set_External_Reference_Of
2000 (Node
: Project_Node_Id
;
2001 In_Tree
: Project_Node_Tree_Ref
;
2002 To
: Project_Node_Id
)
2008 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
2009 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2010 end Set_External_Reference_Of
;
2012 -----------------------------
2013 -- Set_External_Default_Of --
2014 -----------------------------
2016 procedure Set_External_Default_Of
2017 (Node
: Project_Node_Id
;
2018 In_Tree
: Project_Node_Tree_Ref
;
2019 To
: Project_Node_Id
)
2025 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
2026 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2027 end Set_External_Default_Of
;
2029 ----------------------------
2030 -- Set_First_Case_Item_Of --
2031 ----------------------------
2033 procedure Set_First_Case_Item_Of
2034 (Node
: Project_Node_Id
;
2035 In_Tree
: Project_Node_Tree_Ref
;
2036 To
: Project_Node_Id
)
2042 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
2043 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2044 end Set_First_Case_Item_Of
;
2046 -------------------------
2047 -- Set_First_Choice_Of --
2048 -------------------------
2050 procedure Set_First_Choice_Of
2051 (Node
: Project_Node_Id
;
2052 In_Tree
: Project_Node_Tree_Ref
;
2053 To
: Project_Node_Id
)
2059 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2060 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2061 end Set_First_Choice_Of
;
2063 -----------------------------
2064 -- Set_First_Comment_After --
2065 -----------------------------
2067 procedure Set_First_Comment_After
2068 (Node
: Project_Node_Id
;
2069 In_Tree
: Project_Node_Tree_Ref
;
2070 To
: Project_Node_Id
)
2072 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2074 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2075 end Set_First_Comment_After
;
2077 ---------------------------------
2078 -- Set_First_Comment_After_End --
2079 ---------------------------------
2081 procedure Set_First_Comment_After_End
2082 (Node
: Project_Node_Id
;
2083 In_Tree
: Project_Node_Tree_Ref
;
2084 To
: Project_Node_Id
)
2086 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2088 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:= To
;
2089 end Set_First_Comment_After_End
;
2091 ------------------------------
2092 -- Set_First_Comment_Before --
2093 ------------------------------
2095 procedure Set_First_Comment_Before
2096 (Node
: Project_Node_Id
;
2097 In_Tree
: Project_Node_Tree_Ref
;
2098 To
: Project_Node_Id
)
2100 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2102 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:= To
;
2103 end Set_First_Comment_Before
;
2105 ----------------------------------
2106 -- Set_First_Comment_Before_End --
2107 ----------------------------------
2109 procedure Set_First_Comment_Before_End
2110 (Node
: Project_Node_Id
;
2111 In_Tree
: Project_Node_Tree_Ref
;
2112 To
: Project_Node_Id
)
2114 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2116 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2117 end Set_First_Comment_Before_End
;
2119 ------------------------
2120 -- Set_Next_Case_Item --
2121 ------------------------
2123 procedure Set_Next_Case_Item
2124 (Node
: Project_Node_Id
;
2125 In_Tree
: Project_Node_Tree_Ref
;
2126 To
: Project_Node_Id
)
2132 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2133 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2134 end Set_Next_Case_Item
;
2136 ----------------------
2137 -- Set_Next_Comment --
2138 ----------------------
2140 procedure Set_Next_Comment
2141 (Node
: Project_Node_Id
;
2142 In_Tree
: Project_Node_Tree_Ref
;
2143 To
: Project_Node_Id
)
2149 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
2150 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= To
;
2151 end Set_Next_Comment
;
2153 -----------------------------------
2154 -- Set_First_Declarative_Item_Of --
2155 -----------------------------------
2157 procedure Set_First_Declarative_Item_Of
2158 (Node
: Project_Node_Id
;
2159 In_Tree
: Project_Node_Tree_Ref
;
2160 To
: Project_Node_Id
)
2166 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
2168 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
2170 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2172 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
2173 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2175 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2177 end Set_First_Declarative_Item_Of
;
2179 ----------------------------------
2180 -- Set_First_Expression_In_List --
2181 ----------------------------------
2183 procedure Set_First_Expression_In_List
2184 (Node
: Project_Node_Id
;
2185 In_Tree
: Project_Node_Tree_Ref
;
2186 To
: Project_Node_Id
)
2192 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
2193 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2194 end Set_First_Expression_In_List
;
2196 ------------------------------
2197 -- Set_First_Literal_String --
2198 ------------------------------
2200 procedure Set_First_Literal_String
2201 (Node
: Project_Node_Id
;
2202 In_Tree
: Project_Node_Tree_Ref
;
2203 To
: Project_Node_Id
)
2209 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2210 N_String_Type_Declaration
);
2211 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2212 end Set_First_Literal_String
;
2214 --------------------------
2215 -- Set_First_Package_Of --
2216 --------------------------
2218 procedure Set_First_Package_Of
2219 (Node
: Project_Node_Id
;
2220 In_Tree
: Project_Node_Tree_Ref
;
2221 To
: Package_Declaration_Id
)
2227 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2228 In_Tree
.Project_Nodes
.Table
(Node
).Packages
:= To
;
2229 end Set_First_Package_Of
;
2231 ------------------------------
2232 -- Set_First_String_Type_Of --
2233 ------------------------------
2235 procedure Set_First_String_Type_Of
2236 (Node
: Project_Node_Id
;
2237 In_Tree
: Project_Node_Tree_Ref
;
2238 To
: Project_Node_Id
)
2244 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2245 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2246 end Set_First_String_Type_Of
;
2248 --------------------
2249 -- Set_First_Term --
2250 --------------------
2252 procedure Set_First_Term
2253 (Node
: Project_Node_Id
;
2254 In_Tree
: Project_Node_Tree_Ref
;
2255 To
: Project_Node_Id
)
2261 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2262 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2265 ---------------------------
2266 -- Set_First_Variable_Of --
2267 ---------------------------
2269 procedure Set_First_Variable_Of
2270 (Node
: Project_Node_Id
;
2271 In_Tree
: Project_Node_Tree_Ref
;
2272 To
: Variable_Node_Id
)
2278 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2280 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2281 In_Tree
.Project_Nodes
.Table
(Node
).Variables
:= To
;
2282 end Set_First_Variable_Of
;
2284 ------------------------------
2285 -- Set_First_With_Clause_Of --
2286 ------------------------------
2288 procedure Set_First_With_Clause_Of
2289 (Node
: Project_Node_Id
;
2290 In_Tree
: Project_Node_Tree_Ref
;
2291 To
: Project_Node_Id
)
2297 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2298 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2299 end Set_First_With_Clause_Of
;
2301 --------------------------
2302 -- Set_Is_Extending_All --
2303 --------------------------
2305 procedure Set_Is_Extending_All
2306 (Node
: Project_Node_Id
;
2307 In_Tree
: Project_Node_Tree_Ref
)
2313 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2315 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2316 In_Tree
.Project_Nodes
.Table
(Node
).Flag2
:= True;
2317 end Set_Is_Extending_All
;
2319 -----------------------------
2320 -- Set_Is_Not_Last_In_List --
2321 -----------------------------
2323 procedure Set_Is_Not_Last_In_List
2324 (Node
: Project_Node_Id
;
2325 In_Tree
: Project_Node_Tree_Ref
)
2330 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2331 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= True;
2332 end Set_Is_Not_Last_In_List
;
2338 procedure Set_Kind_Of
2339 (Node
: Project_Node_Id
;
2340 In_Tree
: Project_Node_Tree_Ref
;
2341 To
: Project_Node_Kind
)
2344 pragma Assert
(Present
(Node
));
2345 In_Tree
.Project_Nodes
.Table
(Node
).Kind
:= To
;
2348 ---------------------
2349 -- Set_Location_Of --
2350 ---------------------
2352 procedure Set_Location_Of
2353 (Node
: Project_Node_Id
;
2354 In_Tree
: Project_Node_Tree_Ref
;
2358 pragma Assert
(Present
(Node
));
2359 In_Tree
.Project_Nodes
.Table
(Node
).Location
:= To
;
2360 end Set_Location_Of
;
2362 -----------------------------
2363 -- Set_Extended_Project_Of --
2364 -----------------------------
2366 procedure Set_Extended_Project_Of
2367 (Node
: Project_Node_Id
;
2368 In_Tree
: Project_Node_Tree_Ref
;
2369 To
: Project_Node_Id
)
2375 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2376 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2377 end Set_Extended_Project_Of
;
2379 ----------------------------------
2380 -- Set_Extended_Project_Path_Of --
2381 ----------------------------------
2383 procedure Set_Extended_Project_Path_Of
2384 (Node
: Project_Node_Id
;
2385 In_Tree
: Project_Node_Tree_Ref
;
2386 To
: Path_Name_Type
)
2392 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2393 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= Name_Id
(To
);
2394 end Set_Extended_Project_Path_Of
;
2396 ------------------------------
2397 -- Set_Extending_Project_Of --
2398 ------------------------------
2400 procedure Set_Extending_Project_Of
2401 (Node
: Project_Node_Id
;
2402 In_Tree
: Project_Node_Tree_Ref
;
2403 To
: Project_Node_Id
)
2409 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2410 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2411 end Set_Extending_Project_Of
;
2417 procedure Set_Name_Of
2418 (Node
: Project_Node_Id
;
2419 In_Tree
: Project_Node_Tree_Ref
;
2423 pragma Assert
(Present
(Node
));
2424 In_Tree
.Project_Nodes
.Table
(Node
).Name
:= To
;
2427 -------------------------------
2428 -- Set_Next_Declarative_Item --
2429 -------------------------------
2431 procedure Set_Next_Declarative_Item
2432 (Node
: Project_Node_Id
;
2433 In_Tree
: Project_Node_Tree_Ref
;
2434 To
: Project_Node_Id
)
2440 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
2441 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2442 end Set_Next_Declarative_Item
;
2444 -----------------------
2445 -- Set_Next_End_Node --
2446 -----------------------
2448 procedure Set_Next_End_Node
(To
: Project_Node_Id
) is
2450 Next_End_Nodes
.Increment_Last
;
2451 Next_End_Nodes
.Table
(Next_End_Nodes
.Last
) := To
;
2452 end Set_Next_End_Node
;
2454 ---------------------------------
2455 -- Set_Next_Expression_In_List --
2456 ---------------------------------
2458 procedure Set_Next_Expression_In_List
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_Expression
);
2468 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2469 end Set_Next_Expression_In_List
;
2471 -----------------------------
2472 -- Set_Next_Literal_String --
2473 -----------------------------
2475 procedure Set_Next_Literal_String
2476 (Node
: Project_Node_Id
;
2477 In_Tree
: Project_Node_Tree_Ref
;
2478 To
: Project_Node_Id
)
2484 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
2485 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2486 end Set_Next_Literal_String
;
2488 ---------------------------------
2489 -- Set_Next_Package_In_Project --
2490 ---------------------------------
2492 procedure Set_Next_Package_In_Project
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_Package_Declaration
);
2502 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2503 end Set_Next_Package_In_Project
;
2505 --------------------------
2506 -- Set_Next_String_Type --
2507 --------------------------
2509 procedure Set_Next_String_Type
2510 (Node
: Project_Node_Id
;
2511 In_Tree
: Project_Node_Tree_Ref
;
2512 To
: Project_Node_Id
)
2518 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2519 N_String_Type_Declaration
);
2520 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2521 end Set_Next_String_Type
;
2527 procedure Set_Next_Term
2528 (Node
: Project_Node_Id
;
2529 In_Tree
: Project_Node_Tree_Ref
;
2530 To
: Project_Node_Id
)
2536 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
2537 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2540 -----------------------
2541 -- Set_Next_Variable --
2542 -----------------------
2544 procedure Set_Next_Variable
2545 (Node
: Project_Node_Id
;
2546 In_Tree
: Project_Node_Tree_Ref
;
2547 To
: Project_Node_Id
)
2553 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2554 N_Typed_Variable_Declaration
2556 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2557 N_Variable_Declaration
));
2558 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2559 end Set_Next_Variable
;
2561 -----------------------------
2562 -- Set_Next_With_Clause_Of --
2563 -----------------------------
2565 procedure Set_Next_With_Clause_Of
2566 (Node
: Project_Node_Id
;
2567 In_Tree
: Project_Node_Tree_Ref
;
2568 To
: Project_Node_Id
)
2574 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2575 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2576 end Set_Next_With_Clause_Of
;
2578 -----------------------
2579 -- Set_Package_Id_Of --
2580 -----------------------
2582 procedure Set_Package_Id_Of
2583 (Node
: Project_Node_Id
;
2584 In_Tree
: Project_Node_Tree_Ref
;
2585 To
: Package_Node_Id
)
2591 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2592 In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
:= To
;
2593 end Set_Package_Id_Of
;
2595 -------------------------
2596 -- Set_Package_Node_Of --
2597 -------------------------
2599 procedure Set_Package_Node_Of
2600 (Node
: Project_Node_Id
;
2601 In_Tree
: Project_Node_Tree_Ref
;
2602 To
: Project_Node_Id
)
2608 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2610 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2611 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2612 end Set_Package_Node_Of
;
2614 ----------------------
2615 -- Set_Path_Name_Of --
2616 ----------------------
2618 procedure Set_Path_Name_Of
2619 (Node
: Project_Node_Id
;
2620 In_Tree
: Project_Node_Tree_Ref
;
2621 To
: Path_Name_Type
)
2627 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2629 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2630 In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
:= To
;
2631 end Set_Path_Name_Of
;
2633 ---------------------------
2634 -- Set_Previous_End_Node --
2635 ---------------------------
2636 procedure Set_Previous_End_Node
(To
: Project_Node_Id
) is
2638 Previous_End_Node
:= To
;
2639 end Set_Previous_End_Node
;
2641 ----------------------------
2642 -- Set_Previous_Line_Node --
2643 ----------------------------
2645 procedure Set_Previous_Line_Node
(To
: Project_Node_Id
) is
2647 Previous_Line_Node
:= To
;
2648 end Set_Previous_Line_Node
;
2650 --------------------------------
2651 -- Set_Project_Declaration_Of --
2652 --------------------------------
2654 procedure Set_Project_Declaration_Of
2655 (Node
: Project_Node_Id
;
2656 In_Tree
: Project_Node_Tree_Ref
;
2657 To
: Project_Node_Id
)
2663 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2664 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2665 end Set_Project_Declaration_Of
;
2667 ------------------------------
2668 -- Set_Project_Qualifier_Of --
2669 ------------------------------
2671 procedure Set_Project_Qualifier_Of
2672 (Node
: Project_Node_Id
;
2673 In_Tree
: Project_Node_Tree_Ref
;
2674 To
: Project_Qualifier
)
2679 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2680 In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
:= To
;
2681 end Set_Project_Qualifier_Of
;
2683 ---------------------------
2684 -- Set_Parent_Project_Of --
2685 ---------------------------
2687 procedure Set_Parent_Project_Of
2688 (Node
: Project_Node_Id
;
2689 In_Tree
: Project_Node_Tree_Ref
;
2690 To
: Project_Node_Id
)
2695 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2696 In_Tree
.Project_Nodes
.Table
(Node
).Field4
:= To
;
2697 end Set_Parent_Project_Of
;
2699 -----------------------------------------------
2700 -- Set_Project_File_Includes_Unkept_Comments --
2701 -----------------------------------------------
2703 procedure Set_Project_File_Includes_Unkept_Comments
2704 (Node
: Project_Node_Id
;
2705 In_Tree
: Project_Node_Tree_Ref
;
2708 Declaration
: constant Project_Node_Id
:=
2709 Project_Declaration_Of
(Node
, In_Tree
);
2711 In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
:= To
;
2712 end Set_Project_File_Includes_Unkept_Comments
;
2714 -------------------------
2715 -- Set_Project_Node_Of --
2716 -------------------------
2718 procedure Set_Project_Node_Of
2719 (Node
: Project_Node_Id
;
2720 In_Tree
: Project_Node_Tree_Ref
;
2721 To
: Project_Node_Id
;
2722 Limited_With
: Boolean := False)
2728 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2730 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2732 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2733 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2735 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2736 and then not Limited_With
2738 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2740 end Set_Project_Node_Of
;
2742 ---------------------------------------
2743 -- Set_Project_Of_Renamed_Package_Of --
2744 ---------------------------------------
2746 procedure Set_Project_Of_Renamed_Package_Of
2747 (Node
: Project_Node_Id
;
2748 In_Tree
: Project_Node_Tree_Ref
;
2749 To
: Project_Node_Id
)
2755 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2756 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2757 end Set_Project_Of_Renamed_Package_Of
;
2759 -------------------------
2760 -- Set_Source_Index_Of --
2761 -------------------------
2763 procedure Set_Source_Index_Of
2764 (Node
: Project_Node_Id
;
2765 In_Tree
: Project_Node_Tree_Ref
;
2772 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2774 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2775 N_Attribute_Declaration
));
2776 In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
:= To
;
2777 end Set_Source_Index_Of
;
2779 ------------------------
2780 -- Set_String_Type_Of --
2781 ------------------------
2783 procedure Set_String_Type_Of
2784 (Node
: Project_Node_Id
;
2785 In_Tree
: Project_Node_Tree_Ref
;
2786 To
: Project_Node_Id
)
2792 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2793 N_Variable_Reference
2795 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2796 N_Typed_Variable_Declaration
)
2798 In_Tree
.Project_Nodes
.Table
(To
).Kind
= N_String_Type_Declaration
);
2800 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2801 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2803 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2805 end Set_String_Type_Of
;
2807 -------------------------
2808 -- Set_String_Value_Of --
2809 -------------------------
2811 procedure Set_String_Value_Of
2812 (Node
: Project_Node_Id
;
2813 In_Tree
: Project_Node_Tree_Ref
;
2820 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2822 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2824 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2825 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
2826 end Set_String_Value_Of
;
2828 ---------------------
2829 -- Source_Index_Of --
2830 ---------------------
2832 function Source_Index_Of
2833 (Node
: Project_Node_Id
;
2834 In_Tree
: Project_Node_Tree_Ref
) return Int
2840 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2842 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2843 N_Attribute_Declaration
));
2844 return In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
;
2845 end Source_Index_Of
;
2847 --------------------
2848 -- String_Type_Of --
2849 --------------------
2851 function String_Type_Of
2852 (Node
: Project_Node_Id
;
2853 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
2859 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2860 N_Variable_Reference
2862 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2863 N_Typed_Variable_Declaration
));
2865 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2866 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
2868 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
2872 ---------------------
2873 -- String_Value_Of --
2874 ---------------------
2876 function String_Value_Of
2877 (Node
: Project_Node_Id
;
2878 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
2884 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2886 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2888 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2889 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
2890 end String_Value_Of
;
2892 --------------------
2893 -- Value_Is_Valid --
2894 --------------------
2896 function Value_Is_Valid
2897 (For_Typed_Variable
: Project_Node_Id
;
2898 In_Tree
: Project_Node_Tree_Ref
;
2899 Value
: Name_Id
) return Boolean
2903 (Present
(For_Typed_Variable
)
2905 (In_Tree
.Project_Nodes
.Table
(For_Typed_Variable
).Kind
=
2906 N_Typed_Variable_Declaration
));
2909 Current_String
: Project_Node_Id
:=
2910 First_Literal_String
2911 (String_Type_Of
(For_Typed_Variable
, In_Tree
),
2915 while Present
(Current_String
)
2917 String_Value_Of
(Current_String
, In_Tree
) /= Value
2920 Next_Literal_String
(Current_String
, In_Tree
);
2923 return Present
(Current_String
);
2928 -------------------------------
2929 -- There_Are_Unkept_Comments --
2930 -------------------------------
2932 function There_Are_Unkept_Comments
return Boolean is
2934 return Unkept_Comments
;
2935 end There_Are_Unkept_Comments
;
2937 --------------------
2938 -- Create_Project --
2939 --------------------
2941 function Create_Project
2942 (In_Tree
: Project_Node_Tree_Ref
;
2944 Full_Path
: Path_Name_Type
;
2945 Is_Config_File
: Boolean := False) return Project_Node_Id
2947 Project
: Project_Node_Id
;
2948 Qualifier
: Project_Qualifier
:= Unspecified
;
2950 Project
:= Default_Project_Node
(In_Tree
, N_Project
);
2951 Set_Name_Of
(Project
, In_Tree
, Name
);
2954 Path_Name_Type
(Get_Directory
(File_Name_Type
(Full_Path
))));
2955 Set_Path_Name_Of
(Project
, In_Tree
, Full_Path
);
2957 Set_Project_Declaration_Of
2959 Default_Project_Node
(In_Tree
, N_Project_Declaration
));
2961 if Is_Config_File
then
2962 Qualifier
:= Configuration
;
2965 if not Is_Config_File
then
2966 Prj
.Tree
.Tree_Private_Part
.Projects_Htable
.Set
2967 (In_Tree
.Projects_HT
,
2969 Prj
.Tree
.Tree_Private_Part
.Project_Name_And_Node
'
2971 Display_Name => Name,
2972 Resolved_Path => No_Path,
2975 From_Extended => False,
2976 Proj_Qualifier => Qualifier));
2986 procedure Add_At_End
2987 (Tree : Project_Node_Tree_Ref;
2988 Parent : Project_Node_Id;
2989 Expr : Project_Node_Id;
2990 Add_Before_First_Pkg : Boolean := False;
2991 Add_Before_First_Case : Boolean := False)
2993 Real_Parent : Project_Node_Id;
2994 New_Decl, Decl, Next : Project_Node_Id;
2995 Last, L : Project_Node_Id;
2998 if Kind_Of (Expr, Tree) /= N_Declarative_Item then
2999 New_Decl := Default_Project_Node (Tree, N_Declarative_Item);
3000 Set_Current_Item_Node (New_Decl, Tree, Expr);
3005 if Kind_Of (Parent, Tree) = N_Project then
3006 Real_Parent := Project_Declaration_Of (Parent, Tree);
3008 Real_Parent := Parent;
3011 Decl := First_Declarative_Item_Of (Real_Parent, Tree);
3013 if Decl = Empty_Node then
3014 Set_First_Declarative_Item_Of (Real_Parent, Tree, New_Decl);
3017 Next := Next_Declarative_Item (Decl, Tree);
3018 exit when Next = Empty_Node
3020 (Add_Before_First_Pkg
3021 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
3022 N_Package_Declaration)
3024 (Add_Before_First_Case
3025 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
3026 N_Case_Construction);
3030 -- In case Expr is in fact a range of declarative items
3034 L := Next_Declarative_Item (Last, Tree);
3035 exit when L = Empty_Node;
3039 -- In case Expr is in fact a range of declarative items
3043 L := Next_Declarative_Item (Last, Tree);
3044 exit when L = Empty_Node;
3048 Set_Next_Declarative_Item (Last, Tree, Next);
3049 Set_Next_Declarative_Item (Decl, Tree, New_Decl);
3053 ---------------------------
3054 -- Create_Literal_String --
3055 ---------------------------
3057 function Create_Literal_String
3058 (Str : Namet.Name_Id;
3059 Tree : Project_Node_Tree_Ref) return Project_Node_Id
3061 Node : Project_Node_Id;
3063 Node := Default_Project_Node (Tree, N_Literal_String, Prj.Single);
3064 Set_Next_Literal_String (Node, Tree, Empty_Node);
3065 Set_String_Value_Of (Node, Tree, Str);
3067 end Create_Literal_String;
3069 ---------------------------
3070 -- Enclose_In_Expression --
3071 ---------------------------
3073 function Enclose_In_Expression
3074 (Node : Project_Node_Id;
3075 Tree : Project_Node_Tree_Ref) return Project_Node_Id
3077 Expr : Project_Node_Id;
3079 if Kind_Of (Node, Tree) /= N_Expression then
3080 Expr := Default_Project_Node (Tree, N_Expression, Single);
3082 (Expr, Tree, Default_Project_Node (Tree, N_Term, Single));
3083 Set_Current_Term (First_Term (Expr, Tree), Tree, Node);
3088 end Enclose_In_Expression;
3090 --------------------
3091 -- Create_Package --
3092 --------------------
3094 function Create_Package
3095 (Tree : Project_Node_Tree_Ref;
3096 Project : Project_Node_Id;
3097 Pkg : String) return Project_Node_Id
3099 Pack : Project_Node_Id;
3103 Name_Len := Pkg'Length;
3104 Name_Buffer (1 .. Name_Len) := Pkg;
3107 -- Check if the package already exists
3109 Pack := First_Package_Of (Project, Tree);
3110 while Pack /= Empty_Node loop
3111 if Prj.Tree.Name_Of (Pack, Tree) = N then
3115 Pack := Next_Package_In_Project (Pack, Tree);
3118 -- Create the package and add it to the declarative item
3120 Pack := Default_Project_Node (Tree, N_Package_Declaration);
3121 Set_Name_Of (Pack, Tree, N);
3123 -- Find the correct package id to use
3125 Set_Package_Id_Of (Pack, Tree, Package_Node_Id_Of (N));
3127 -- Add it to the list of packages
3129 Set_Next_Package_In_Project
3130 (Pack, Tree, First_Package_Of (Project, Tree));
3131 Set_First_Package_Of (Project, Tree, Pack);
3133 Add_At_End (Tree, Project_Declaration_Of (Project, Tree), Pack);
3138 ----------------------
3139 -- Create_Attribute --
3140 ----------------------
3142 function Create_Attribute
3143 (Tree : Project_Node_Tree_Ref;
3144 Prj_Or_Pkg : Project_Node_Id;
3146 Index_Name : Name_Id := No_Name;
3147 Kind : Variable_Kind := List;
3148 At_Index : Integer := 0;
3149 Value : Project_Node_Id := Empty_Node) return Project_Node_Id
3151 Node : constant Project_Node_Id :=
3152 Default_Project_Node (Tree, N_Attribute_Declaration, Kind);
3154 Case_Insensitive : Boolean;
3156 Pkg : Package_Node_Id;
3157 Start_At : Attribute_Node_Id;
3158 Expr : Project_Node_Id;
3161 Set_Name_Of (Node, Tree, Name);
3163 if Index_Name /= No_Name then
3164 Set_Associative_Array_Index_Of (Node, Tree, Index_Name);
3167 if Prj_Or_Pkg /= Empty_Node then
3168 Add_At_End (Tree, Prj_Or_Pkg, Node);
3171 -- Find out the case sensitivity of the attribute
3173 if Prj_Or_Pkg /= Empty_Node
3174 and then Kind_Of (Prj_Or_Pkg, Tree) = N_Package_Declaration
3176 Pkg := Prj.Attr.Package_Node_Id_Of (Name_Of (Prj_Or_Pkg, Tree));
3177 Start_At := First_Attribute_Of (Pkg);
3179 Start_At := Attribute_First;
3182 Start_At := Attribute_Node_Id_Of (Name, Start_At);
3184 Attribute_Kind_Of (Start_At) = Case_Insensitive_Associative_Array;
3185 Tree.Project_Nodes.Table (Node).Flag1 := Case_Insensitive;
3187 if At_Index /= 0 then
3188 if Attribute_Kind_Of (Start_At) =
3189 Optional_Index_Associative_Array
3190 or else Attribute_Kind_Of (Start_At) =
3191 Optional_Index_Case_Insensitive_Associative_Array
3193 -- Results in: for Name ("index" at index) use "value";
3194 -- This is currently only used for executables.
3196 Set_Source_Index_Of (Node, Tree, To => Int (At_Index));
3199 -- Results in: for Name ("index") use "value" at index;
3201 -- ??? This limitation makes no sense, we should be able to
3202 -- set the source index on an expression.
3204 pragma Assert (Kind_Of (Value, Tree) = N_Literal_String);
3205 Set_Source_Index_Of (Value, Tree, To => Int (At_Index));
3209 if Value /= Empty_Node then
3210 Expr := Enclose_In_Expression (Value, Tree);
3211 Set_Expression_Of (Node, Tree, Expr);
3215 end Create_Attribute;