1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2011, 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 Field1
=> Empty_Node
,
126 Field2
=> Empty_Node
,
127 Field3
=> Empty_Node
,
128 Field4
=> Empty_Node
,
131 Comments
=> Empty_Node
);
133 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
134 In_Tree
.Project_Nodes
.Table
(To
).Comments
:= Zone
;
137 if Where
= End_Of_Line
then
138 In_Tree
.Project_Nodes
.Table
(Zone
).Value
:= Comments
.Table
(1).Value
;
141 -- Get each comments in the Comments table and link them to node To
143 for J
in 1 .. Comments
.Last
loop
145 -- Create new N_Comment node
147 if (Where
= After
or else Where
= After_End
)
148 and then Token
/= Tok_EOF
149 and then Comments
.Table
(J
).Follows_Empty_Line
151 Comments
.Table
(1 .. Comments
.Last
- J
+ 1) :=
152 Comments
.Table
(J
.. Comments
.Last
);
153 Comments
.Set_Last
(Comments
.Last
- J
+ 1);
157 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
158 In_Tree
.Project_Nodes
.Table
159 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
161 Qualifier
=> Unspecified
,
162 Expr_Kind
=> Undefined
,
163 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
165 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
166 Location
=> No_Location
,
167 Directory
=> No_Path
,
168 Variables
=> Empty_Node
,
169 Packages
=> Empty_Node
,
170 Pkg_Id
=> Empty_Package
,
173 Path_Name
=> No_Path
,
174 Value
=> Comments
.Table
(J
).Value
,
175 Field1
=> Empty_Node
,
176 Field2
=> Empty_Node
,
177 Field3
=> Empty_Node
,
178 Field4
=> Empty_Node
,
179 Comments
=> Empty_Node
);
181 -- If this is the first comment, put it in the right field of
184 if No
(Previous
) then
187 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
188 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
191 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:=
192 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
195 In_Tree
.Project_Nodes
.Table
(Zone
).Field3
:=
196 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
199 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:=
200 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
207 -- When it is not the first, link it to the previous one
209 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
210 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
213 -- This node becomes the previous one for the next comment, if
216 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
220 -- Empty the Comments table, so that there is no risk to link the same
221 -- comments to another node.
223 Comments
.Set_Last
(0);
226 --------------------------------
227 -- Associative_Array_Index_Of --
228 --------------------------------
230 function Associative_Array_Index_Of
231 (Node
: Project_Node_Id
;
232 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
238 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
240 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
241 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
242 end Associative_Array_Index_Of
;
244 ----------------------------
245 -- Associative_Package_Of --
246 ----------------------------
248 function Associative_Package_Of
249 (Node
: Project_Node_Id
;
250 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
256 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
));
257 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
258 end Associative_Package_Of
;
260 ----------------------------
261 -- Associative_Project_Of --
262 ----------------------------
264 function Associative_Project_Of
265 (Node
: Project_Node_Id
;
266 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
272 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
));
273 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
274 end Associative_Project_Of
;
276 ----------------------
277 -- Case_Insensitive --
278 ----------------------
280 function Case_Insensitive
281 (Node
: Project_Node_Id
;
282 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
287 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
289 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
290 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
291 end Case_Insensitive
;
293 --------------------------------
294 -- Case_Variable_Reference_Of --
295 --------------------------------
297 function Case_Variable_Reference_Of
298 (Node
: Project_Node_Id
;
299 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
305 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
306 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
307 end Case_Variable_Reference_Of
;
309 ----------------------
310 -- Comment_Zones_Of --
311 ----------------------
313 function Comment_Zones_Of
314 (Node
: Project_Node_Id
;
315 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
317 Zone
: Project_Node_Id
;
320 pragma Assert
(Present
(Node
));
321 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
323 -- If there is not already an N_Comment_Zones associated, create a new
324 -- one and associate it with node Node.
327 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
328 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
329 In_Tree
.Project_Nodes
.Table
(Zone
) :=
330 (Kind
=> N_Comment_Zones
,
331 Qualifier
=> Unspecified
,
332 Location
=> No_Location
,
333 Directory
=> No_Path
,
334 Expr_Kind
=> Undefined
,
335 Variables
=> Empty_Node
,
336 Packages
=> Empty_Node
,
337 Pkg_Id
=> Empty_Package
,
340 Path_Name
=> No_Path
,
342 Field1
=> Empty_Node
,
343 Field2
=> Empty_Node
,
344 Field3
=> Empty_Node
,
345 Field4
=> Empty_Node
,
348 Comments
=> Empty_Node
);
349 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= Zone
;
353 end Comment_Zones_Of
;
355 -----------------------
356 -- Current_Item_Node --
357 -----------------------
359 function Current_Item_Node
360 (Node
: Project_Node_Id
;
361 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
367 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
368 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
369 end Current_Item_Node
;
375 function Current_Term
376 (Node
: Project_Node_Id
;
377 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
383 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
384 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
387 --------------------------
388 -- Default_Project_Node --
389 --------------------------
391 function Default_Project_Node
392 (In_Tree
: Project_Node_Tree_Ref
;
393 Of_Kind
: Project_Node_Kind
;
394 And_Expr_Kind
: Variable_Kind
:= Undefined
) return Project_Node_Id
396 Result
: Project_Node_Id
;
397 Zone
: Project_Node_Id
;
398 Previous
: Project_Node_Id
;
401 -- Create new node with specified kind and expression kind
403 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
404 In_Tree
.Project_Nodes
.Table
405 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
407 Qualifier
=> Unspecified
,
408 Location
=> No_Location
,
409 Directory
=> No_Path
,
410 Expr_Kind
=> And_Expr_Kind
,
411 Variables
=> Empty_Node
,
412 Packages
=> Empty_Node
,
413 Pkg_Id
=> Empty_Package
,
416 Path_Name
=> No_Path
,
418 Field1
=> Empty_Node
,
419 Field2
=> Empty_Node
,
420 Field3
=> Empty_Node
,
421 Field4
=> Empty_Node
,
424 Comments
=> Empty_Node
);
426 -- Save the new node for the returned value
428 Result
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
430 if Comments
.Last
> 0 then
432 -- If this is not a node with comments, then set the flag
434 if not Node_With_Comments
(Of_Kind
) then
435 Unkept_Comments
:= True;
437 elsif Of_Kind
/= N_Comment
and then Of_Kind
/= N_Comment_Zones
then
439 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
440 In_Tree
.Project_Nodes
.Table
441 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
442 (Kind
=> N_Comment_Zones
,
443 Qualifier
=> Unspecified
,
444 Expr_Kind
=> Undefined
,
445 Location
=> No_Location
,
446 Directory
=> No_Path
,
447 Variables
=> Empty_Node
,
448 Packages
=> Empty_Node
,
449 Pkg_Id
=> Empty_Package
,
452 Path_Name
=> No_Path
,
454 Field1
=> Empty_Node
,
455 Field2
=> Empty_Node
,
456 Field3
=> Empty_Node
,
457 Field4
=> Empty_Node
,
460 Comments
=> Empty_Node
);
462 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
463 In_Tree
.Project_Nodes
.Table
(Result
).Comments
:= Zone
;
464 Previous
:= Empty_Node
;
466 for J
in 1 .. Comments
.Last
loop
468 -- Create a new N_Comment node
470 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
471 In_Tree
.Project_Nodes
.Table
472 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
474 Qualifier
=> Unspecified
,
475 Expr_Kind
=> Undefined
,
476 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
478 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
479 Location
=> No_Location
,
480 Directory
=> No_Path
,
481 Variables
=> Empty_Node
,
482 Packages
=> Empty_Node
,
483 Pkg_Id
=> Empty_Package
,
486 Path_Name
=> No_Path
,
487 Value
=> Comments
.Table
(J
).Value
,
488 Field1
=> Empty_Node
,
489 Field2
=> Empty_Node
,
490 Field3
=> Empty_Node
,
491 Field4
=> Empty_Node
,
492 Comments
=> Empty_Node
);
494 -- Link it to the N_Comment_Zones node, if it is the first,
495 -- otherwise to the previous one.
497 if No
(Previous
) then
498 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
499 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
502 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
503 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
506 -- This new node will be the previous one for the next
507 -- N_Comment node, if there is one.
509 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
512 -- Empty the Comments table after all comments have been processed
514 Comments
.Set_Last
(0);
519 end Default_Project_Node
;
525 function Directory_Of
526 (Node
: Project_Node_Id
;
527 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
is
532 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
533 return In_Tree
.Project_Nodes
.Table
(Node
).Directory
;
536 -------------------------
537 -- End_Of_Line_Comment --
538 -------------------------
540 function End_Of_Line_Comment
541 (Node
: Project_Node_Id
;
542 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
is
543 Zone
: Project_Node_Id
:= Empty_Node
;
546 pragma Assert
(Present
(Node
));
547 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
552 return In_Tree
.Project_Nodes
.Table
(Zone
).Value
;
554 end End_Of_Line_Comment
;
556 ------------------------
557 -- Expression_Kind_Of --
558 ------------------------
560 function Expression_Kind_Of
561 (Node
: Project_Node_Id
;
562 In_Tree
: Project_Node_Tree_Ref
) return Variable_Kind
567 and then -- should use Nkind_In here ??? why not???
568 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
570 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
572 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
574 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
575 N_Typed_Variable_Declaration
577 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
579 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
581 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
583 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
585 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
587 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
));
588 return In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
;
589 end Expression_Kind_Of
;
595 function Expression_Of
596 (Node
: Project_Node_Id
;
597 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
603 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
604 N_Attribute_Declaration
606 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
607 N_Typed_Variable_Declaration
609 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
610 N_Variable_Declaration
));
612 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
615 -------------------------
616 -- Extended_Project_Of --
617 -------------------------
619 function Extended_Project_Of
620 (Node
: Project_Node_Id
;
621 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
627 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
628 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
629 end Extended_Project_Of
;
631 ------------------------------
632 -- Extended_Project_Path_Of --
633 ------------------------------
635 function Extended_Project_Path_Of
636 (Node
: Project_Node_Id
;
637 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
643 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
644 return Path_Name_Type
(In_Tree
.Project_Nodes
.Table
(Node
).Value
);
645 end Extended_Project_Path_Of
;
647 --------------------------
648 -- Extending_Project_Of --
649 --------------------------
650 function Extending_Project_Of
651 (Node
: Project_Node_Id
;
652 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
658 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
659 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
660 end Extending_Project_Of
;
662 ---------------------------
663 -- External_Reference_Of --
664 ---------------------------
666 function External_Reference_Of
667 (Node
: Project_Node_Id
;
668 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
674 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
675 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
676 end External_Reference_Of
;
678 -------------------------
679 -- External_Default_Of --
680 -------------------------
682 function External_Default_Of
683 (Node
: Project_Node_Id
;
684 In_Tree
: Project_Node_Tree_Ref
)
685 return Project_Node_Id
691 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
692 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
693 end External_Default_Of
;
695 ------------------------
696 -- First_Case_Item_Of --
697 ------------------------
699 function First_Case_Item_Of
700 (Node
: Project_Node_Id
;
701 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
707 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
708 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
709 end First_Case_Item_Of
;
711 ---------------------
712 -- First_Choice_Of --
713 ---------------------
715 function First_Choice_Of
716 (Node
: Project_Node_Id
;
717 In_Tree
: Project_Node_Tree_Ref
)
718 return Project_Node_Id
724 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
725 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
728 -------------------------
729 -- First_Comment_After --
730 -------------------------
732 function First_Comment_After
733 (Node
: Project_Node_Id
;
734 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
736 Zone
: Project_Node_Id
:= Empty_Node
;
738 pragma Assert
(Present
(Node
));
739 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
745 return In_Tree
.Project_Nodes
.Table
(Zone
).Field2
;
747 end First_Comment_After
;
749 -----------------------------
750 -- First_Comment_After_End --
751 -----------------------------
753 function First_Comment_After_End
754 (Node
: Project_Node_Id
;
755 In_Tree
: Project_Node_Tree_Ref
)
756 return Project_Node_Id
758 Zone
: Project_Node_Id
:= Empty_Node
;
761 pragma Assert
(Present
(Node
));
762 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
768 return In_Tree
.Project_Nodes
.Table
(Zone
).Comments
;
770 end First_Comment_After_End
;
772 --------------------------
773 -- First_Comment_Before --
774 --------------------------
776 function First_Comment_Before
777 (Node
: Project_Node_Id
;
778 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
780 Zone
: Project_Node_Id
:= Empty_Node
;
783 pragma Assert
(Present
(Node
));
784 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
790 return In_Tree
.Project_Nodes
.Table
(Zone
).Field1
;
792 end First_Comment_Before
;
794 ------------------------------
795 -- First_Comment_Before_End --
796 ------------------------------
798 function First_Comment_Before_End
799 (Node
: Project_Node_Id
;
800 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
802 Zone
: Project_Node_Id
:= Empty_Node
;
805 pragma Assert
(Present
(Node
));
806 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
812 return In_Tree
.Project_Nodes
.Table
(Zone
).Field3
;
814 end First_Comment_Before_End
;
816 -------------------------------
817 -- First_Declarative_Item_Of --
818 -------------------------------
820 function First_Declarative_Item_Of
821 (Node
: Project_Node_Id
;
822 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
828 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
830 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
832 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
834 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
835 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
837 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
839 end First_Declarative_Item_Of
;
841 ------------------------------
842 -- First_Expression_In_List --
843 ------------------------------
845 function First_Expression_In_List
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_Literal_String_List
);
854 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
855 end First_Expression_In_List
;
857 --------------------------
858 -- First_Literal_String --
859 --------------------------
861 function First_Literal_String
862 (Node
: Project_Node_Id
;
863 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
869 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
870 N_String_Type_Declaration
);
871 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
872 end First_Literal_String
;
874 ----------------------
875 -- First_Package_Of --
876 ----------------------
878 function First_Package_Of
879 (Node
: Project_Node_Id
;
880 In_Tree
: Project_Node_Tree_Ref
) return Package_Declaration_Id
886 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
887 return In_Tree
.Project_Nodes
.Table
(Node
).Packages
;
888 end First_Package_Of
;
890 --------------------------
891 -- First_String_Type_Of --
892 --------------------------
894 function First_String_Type_Of
895 (Node
: Project_Node_Id
;
896 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
902 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
903 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
904 end First_String_Type_Of
;
911 (Node
: Project_Node_Id
;
912 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
918 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
919 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
922 -----------------------
923 -- First_Variable_Of --
924 -----------------------
926 function First_Variable_Of
927 (Node
: Project_Node_Id
;
928 In_Tree
: Project_Node_Tree_Ref
) return Variable_Node_Id
934 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
936 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
938 return In_Tree
.Project_Nodes
.Table
(Node
).Variables
;
939 end First_Variable_Of
;
941 --------------------------
942 -- First_With_Clause_Of --
943 --------------------------
945 function First_With_Clause_Of
946 (Node
: Project_Node_Id
;
947 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
953 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
954 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
955 end First_With_Clause_Of
;
957 ------------------------
958 -- Follows_Empty_Line --
959 ------------------------
961 function Follows_Empty_Line
962 (Node
: Project_Node_Id
;
963 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
968 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
969 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
970 end Follows_Empty_Line
;
976 function Hash
(N
: Project_Node_Id
) return Header_Num
is
978 return Header_Num
(N
mod Project_Node_Id
(Header_Num
'Last));
985 procedure Initialize
(Tree
: Project_Node_Tree_Ref
) is
987 Project_Node_Table
.Init
(Tree
.Project_Nodes
);
988 Projects_Htable
.Reset
(Tree
.Projects_HT
);
995 procedure Override_Flags
996 (Self
: in out Environment
;
997 Flags
: Prj
.Processing_Flags
)
1000 Self
.Flags
:= Flags
;
1007 procedure Initialize
1008 (Self
: out Environment
;
1009 Flags
: Processing_Flags
) is
1011 -- Do not reset the external references, in case we are reloading a
1012 -- project, since we want to preserve the current environment. But we
1013 -- still need to ensure that the external references are properly
1015 -- Prj.Ext.Reset (Tree.External);
1017 Prj
.Ext
.Initialize
(Self
.External
);
1019 Self
.Flags
:= Flags
;
1022 -------------------------
1023 -- Initialize_And_Copy --
1024 -------------------------
1026 procedure Initialize_And_Copy
1027 (Self
: out Environment
;
1028 Copy_From
: Environment
) is
1030 Self
.Flags
:= Copy_From
.Flags
;
1031 Prj
.Ext
.Initialize
(Self
.External
, Copy_From
=> Copy_From
.External
);
1032 Prj
.Env
.Copy
(From
=> Copy_From
.Project_Path
, To
=> Self
.Project_Path
);
1033 end Initialize_And_Copy
;
1039 procedure Free
(Self
: in out Environment
) is
1041 Prj
.Ext
.Free
(Self
.External
);
1042 Free
(Self
.Project_Path
);
1049 procedure Free
(Proj
: in out Project_Node_Tree_Ref
) is
1050 procedure Unchecked_Free
is new Ada
.Unchecked_Deallocation
1051 (Project_Node_Tree_Data
, Project_Node_Tree_Ref
);
1053 if Proj
/= null then
1054 Project_Node_Table
.Free
(Proj
.Project_Nodes
);
1055 Projects_Htable
.Reset
(Proj
.Projects_HT
);
1056 Unchecked_Free
(Proj
);
1060 -------------------------------
1061 -- Is_Followed_By_Empty_Line --
1062 -------------------------------
1064 function Is_Followed_By_Empty_Line
1065 (Node
: Project_Node_Id
;
1066 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1072 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1073 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1074 end Is_Followed_By_Empty_Line
;
1076 ----------------------
1077 -- Is_Extending_All --
1078 ----------------------
1080 function Is_Extending_All
1081 (Node
: Project_Node_Id
;
1082 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
1087 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1089 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1090 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1091 end Is_Extending_All
;
1093 -------------------------
1094 -- Is_Not_Last_In_List --
1095 -------------------------
1097 function Is_Not_Last_In_List
1098 (Node
: Project_Node_Id
;
1099 In_Tree
: Project_Node_Tree_Ref
) return Boolean is
1104 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1105 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
1106 end Is_Not_Last_In_List
;
1108 -------------------------------------
1109 -- Imported_Or_Extended_Project_Of --
1110 -------------------------------------
1112 function Imported_Or_Extended_Project_Of
1113 (Project
: Project_Node_Id
;
1114 In_Tree
: Project_Node_Tree_Ref
;
1115 With_Name
: Name_Id
) return Project_Node_Id
1117 With_Clause
: Project_Node_Id
:=
1118 First_With_Clause_Of
(Project
, In_Tree
);
1119 Result
: Project_Node_Id
:= Empty_Node
;
1122 -- First check all the imported projects
1124 while Present
(With_Clause
) loop
1126 -- Only non limited imported project may be used as prefix
1127 -- of variable or attributes.
1129 Result
:= Non_Limited_Project_Node_Of
(With_Clause
, In_Tree
);
1130 exit when Present
(Result
)
1131 and then Name_Of
(Result
, In_Tree
) = With_Name
;
1132 With_Clause
:= Next_With_Clause_Of
(With_Clause
, In_Tree
);
1135 -- If it is not an imported project, it might be an extended project
1137 if No
(With_Clause
) then
1142 (Project_Declaration_Of
(Result
, In_Tree
), In_Tree
);
1144 exit when No
(Result
)
1145 or else Name_Of
(Result
, In_Tree
) = With_Name
;
1150 end Imported_Or_Extended_Project_Of
;
1157 (Node
: Project_Node_Id
;
1158 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Kind
is
1160 pragma Assert
(Present
(Node
));
1161 return In_Tree
.Project_Nodes
.Table
(Node
).Kind
;
1168 function Location_Of
1169 (Node
: Project_Node_Id
;
1170 In_Tree
: Project_Node_Tree_Ref
) return Source_Ptr
is
1172 pragma Assert
(Present
(Node
));
1173 return In_Tree
.Project_Nodes
.Table
(Node
).Location
;
1181 (Node
: Project_Node_Id
;
1182 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
is
1184 pragma Assert
(Present
(Node
));
1185 return In_Tree
.Project_Nodes
.Table
(Node
).Name
;
1188 --------------------
1189 -- Next_Case_Item --
1190 --------------------
1192 function Next_Case_Item
1193 (Node
: Project_Node_Id
;
1194 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1200 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
1201 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1208 function Next_Comment
1209 (Node
: Project_Node_Id
;
1210 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
is
1215 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1216 return In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
1219 ---------------------------
1220 -- Next_Declarative_Item --
1221 ---------------------------
1223 function Next_Declarative_Item
1224 (Node
: Project_Node_Id
;
1225 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1231 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1232 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1233 end Next_Declarative_Item
;
1235 -----------------------------
1236 -- Next_Expression_In_List --
1237 -----------------------------
1239 function Next_Expression_In_List
1240 (Node
: Project_Node_Id
;
1241 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1247 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
1248 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1249 end Next_Expression_In_List
;
1251 -------------------------
1252 -- Next_Literal_String --
1253 -------------------------
1255 function Next_Literal_String
1256 (Node
: Project_Node_Id
;
1257 In_Tree
: Project_Node_Tree_Ref
)
1258 return Project_Node_Id
1264 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
1265 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1266 end Next_Literal_String
;
1268 -----------------------------
1269 -- Next_Package_In_Project --
1270 -----------------------------
1272 function Next_Package_In_Project
1273 (Node
: Project_Node_Id
;
1274 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1280 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1281 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1282 end Next_Package_In_Project
;
1284 ----------------------
1285 -- Next_String_Type --
1286 ----------------------
1288 function Next_String_Type
1289 (Node
: Project_Node_Id
;
1290 In_Tree
: Project_Node_Tree_Ref
)
1291 return Project_Node_Id
1297 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1298 N_String_Type_Declaration
);
1299 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1300 end Next_String_Type
;
1307 (Node
: Project_Node_Id
;
1308 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1314 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1315 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1322 function Next_Variable
1323 (Node
: Project_Node_Id
;
1324 In_Tree
: Project_Node_Tree_Ref
)
1325 return Project_Node_Id
1331 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1332 N_Typed_Variable_Declaration
1334 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1335 N_Variable_Declaration
));
1337 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1340 -------------------------
1341 -- Next_With_Clause_Of --
1342 -------------------------
1344 function Next_With_Clause_Of
1345 (Node
: Project_Node_Id
;
1346 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1352 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1353 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1354 end Next_With_Clause_Of
;
1360 function No
(Node
: Project_Node_Id
) return Boolean is
1362 return Node
= Empty_Node
;
1365 ---------------------------------
1366 -- Non_Limited_Project_Node_Of --
1367 ---------------------------------
1369 function Non_Limited_Project_Node_Of
1370 (Node
: Project_Node_Id
;
1371 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1377 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1378 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1379 end Non_Limited_Project_Node_Of
;
1385 function Package_Id_Of
1386 (Node
: Project_Node_Id
;
1387 In_Tree
: Project_Node_Tree_Ref
) return Package_Node_Id
1393 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1394 return In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
;
1397 ---------------------
1398 -- Package_Node_Of --
1399 ---------------------
1401 function Package_Node_Of
1402 (Node
: Project_Node_Id
;
1403 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1409 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1411 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1412 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1413 end Package_Node_Of
;
1419 function Path_Name_Of
1420 (Node
: Project_Node_Id
;
1421 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
1427 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1429 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1430 return In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
;
1437 function Present
(Node
: Project_Node_Id
) return Boolean is
1439 return Node
/= Empty_Node
;
1442 ----------------------------
1443 -- Project_Declaration_Of --
1444 ----------------------------
1446 function Project_Declaration_Of
1447 (Node
: Project_Node_Id
;
1448 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1454 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1455 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1456 end Project_Declaration_Of
;
1458 --------------------------
1459 -- Project_Qualifier_Of --
1460 --------------------------
1462 function Project_Qualifier_Of
1463 (Node
: Project_Node_Id
;
1464 In_Tree
: Project_Node_Tree_Ref
) return Project_Qualifier
1470 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1471 return In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
;
1472 end Project_Qualifier_Of
;
1474 -----------------------
1475 -- Parent_Project_Of --
1476 -----------------------
1478 function Parent_Project_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_Project
);
1487 return In_Tree
.Project_Nodes
.Table
(Node
).Field4
;
1488 end Parent_Project_Of
;
1490 -------------------------------------------
1491 -- Project_File_Includes_Unkept_Comments --
1492 -------------------------------------------
1494 function Project_File_Includes_Unkept_Comments
1495 (Node
: Project_Node_Id
;
1496 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1498 Declaration
: constant Project_Node_Id
:=
1499 Project_Declaration_Of
(Node
, In_Tree
);
1501 return In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
;
1502 end Project_File_Includes_Unkept_Comments
;
1504 ---------------------
1505 -- Project_Node_Of --
1506 ---------------------
1508 function Project_Node_Of
1509 (Node
: Project_Node_Id
;
1510 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1516 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
1518 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1520 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1521 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1522 end Project_Node_Of
;
1524 -----------------------------------
1525 -- Project_Of_Renamed_Package_Of --
1526 -----------------------------------
1528 function Project_Of_Renamed_Package_Of
1529 (Node
: Project_Node_Id
;
1530 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1536 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1537 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1538 end Project_Of_Renamed_Package_Of
;
1540 --------------------------
1541 -- Remove_Next_End_Node --
1542 --------------------------
1544 procedure Remove_Next_End_Node
is
1546 Next_End_Nodes
.Decrement_Last
;
1547 end Remove_Next_End_Node
;
1553 procedure Reset_State
is
1555 End_Of_Line_Node
:= Empty_Node
;
1556 Previous_Line_Node
:= Empty_Node
;
1557 Previous_End_Node
:= Empty_Node
;
1558 Unkept_Comments
:= False;
1559 Comments
.Set_Last
(0);
1562 ----------------------
1563 -- Restore_And_Free --
1564 ----------------------
1566 procedure Restore_And_Free
(S
: in out Comment_State
) is
1567 procedure Unchecked_Free
is new
1568 Ada
.Unchecked_Deallocation
(Comment_Array
, Comments_Ptr
);
1571 End_Of_Line_Node
:= S
.End_Of_Line_Node
;
1572 Previous_Line_Node
:= S
.Previous_Line_Node
;
1573 Previous_End_Node
:= S
.Previous_End_Node
;
1574 Next_End_Nodes
.Set_Last
(0);
1575 Unkept_Comments
:= S
.Unkept_Comments
;
1577 Comments
.Set_Last
(0);
1579 for J
in S
.Comments
'Range loop
1580 Comments
.Increment_Last
;
1581 Comments
.Table
(Comments
.Last
) := S
.Comments
(J
);
1584 Unchecked_Free
(S
.Comments
);
1585 end Restore_And_Free
;
1591 procedure Save
(S
: out Comment_State
) is
1592 Cmts
: constant Comments_Ptr
:= new Comment_Array
(1 .. Comments
.Last
);
1595 for J
in 1 .. Comments
.Last
loop
1596 Cmts
(J
) := Comments
.Table
(J
);
1600 (End_Of_Line_Node
=> End_Of_Line_Node
,
1601 Previous_Line_Node
=> Previous_Line_Node
,
1602 Previous_End_Node
=> Previous_End_Node
,
1603 Unkept_Comments
=> Unkept_Comments
,
1611 procedure Scan
(In_Tree
: Project_Node_Tree_Ref
) is
1612 Empty_Line
: Boolean := False;
1615 -- If there are comments, then they will not be kept. Set the flag and
1616 -- clear the comments.
1618 if Comments
.Last
> 0 then
1619 Unkept_Comments
:= True;
1620 Comments
.Set_Last
(0);
1623 -- Loop until a token other that End_Of_Line or Comment is found
1626 Prj
.Err
.Scanner
.Scan
;
1629 when Tok_End_Of_Line
=>
1630 if Prev_Token
= Tok_End_Of_Line
then
1633 if Comments
.Last
> 0 then
1634 Comments
.Table
(Comments
.Last
).Is_Followed_By_Empty_Line
1640 -- If this is a line comment, add it to the comment table
1642 if Prev_Token
= Tok_End_Of_Line
1643 or else Prev_Token
= No_Token
1645 Comments
.Increment_Last
;
1646 Comments
.Table
(Comments
.Last
) :=
1647 (Value
=> Comment_Id
,
1648 Follows_Empty_Line
=> Empty_Line
,
1649 Is_Followed_By_Empty_Line
=> False);
1651 -- Otherwise, it is an end of line comment. If there is
1652 -- an end of line node specified, associate the comment with
1655 elsif Present
(End_Of_Line_Node
) then
1657 Zones
: constant Project_Node_Id
:=
1658 Comment_Zones_Of
(End_Of_Line_Node
, In_Tree
);
1660 In_Tree
.Project_Nodes
.Table
(Zones
).Value
:= Comment_Id
;
1663 -- Otherwise, this end of line node cannot be kept
1666 Unkept_Comments
:= True;
1667 Comments
.Set_Last
(0);
1670 Empty_Line
:= False;
1673 -- If there are comments, where the first comment is not
1674 -- following an empty line, put the initial uninterrupted
1675 -- comment zone with the node of the preceding line (either
1676 -- a Previous_Line or a Previous_End node), if any.
1678 if Comments
.Last
> 0 and then
1679 not Comments
.Table
(1).Follows_Empty_Line
then
1680 if Present
(Previous_Line_Node
) then
1682 (To
=> Previous_Line_Node
,
1684 In_Tree
=> In_Tree
);
1686 elsif Present
(Previous_End_Node
) then
1688 (To
=> Previous_End_Node
,
1690 In_Tree
=> In_Tree
);
1694 -- If there are still comments and the token is "end", then
1695 -- put these comments with the Next_End node, if any;
1696 -- otherwise, these comments cannot be kept. Always clear
1699 if Comments
.Last
> 0 and then Token
= Tok_End
then
1700 if Next_End_Nodes
.Last
> 0 then
1702 (To
=> Next_End_Nodes
.Table
(Next_End_Nodes
.Last
),
1703 Where
=> Before_End
,
1704 In_Tree
=> In_Tree
);
1707 Unkept_Comments
:= True;
1710 Comments
.Set_Last
(0);
1713 -- Reset the End_Of_Line, Previous_Line and Previous_End nodes
1714 -- so that they are not used again.
1716 End_Of_Line_Node
:= Empty_Node
;
1717 Previous_Line_Node
:= Empty_Node
;
1718 Previous_End_Node
:= Empty_Node
;
1727 ------------------------------------
1728 -- Set_Associative_Array_Index_Of --
1729 ------------------------------------
1731 procedure Set_Associative_Array_Index_Of
1732 (Node
: Project_Node_Id
;
1733 In_Tree
: Project_Node_Tree_Ref
;
1740 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1742 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1743 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
1744 end Set_Associative_Array_Index_Of
;
1746 --------------------------------
1747 -- Set_Associative_Package_Of --
1748 --------------------------------
1750 procedure Set_Associative_Package_Of
1751 (Node
: Project_Node_Id
;
1752 In_Tree
: Project_Node_Tree_Ref
;
1753 To
: Project_Node_Id
)
1759 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
);
1760 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
1761 end Set_Associative_Package_Of
;
1763 --------------------------------
1764 -- Set_Associative_Project_Of --
1765 --------------------------------
1767 procedure Set_Associative_Project_Of
1768 (Node
: Project_Node_Id
;
1769 In_Tree
: Project_Node_Tree_Ref
;
1770 To
: Project_Node_Id
)
1776 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1777 N_Attribute_Declaration
));
1778 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1779 end Set_Associative_Project_Of
;
1781 --------------------------
1782 -- Set_Case_Insensitive --
1783 --------------------------
1785 procedure Set_Case_Insensitive
1786 (Node
: Project_Node_Id
;
1787 In_Tree
: Project_Node_Tree_Ref
;
1794 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1796 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1797 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= To
;
1798 end Set_Case_Insensitive
;
1800 ------------------------------------
1801 -- Set_Case_Variable_Reference_Of --
1802 ------------------------------------
1804 procedure Set_Case_Variable_Reference_Of
1805 (Node
: Project_Node_Id
;
1806 In_Tree
: Project_Node_Tree_Ref
;
1807 To
: Project_Node_Id
)
1813 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
1814 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1815 end Set_Case_Variable_Reference_Of
;
1817 ---------------------------
1818 -- Set_Current_Item_Node --
1819 ---------------------------
1821 procedure Set_Current_Item_Node
1822 (Node
: Project_Node_Id
;
1823 In_Tree
: Project_Node_Tree_Ref
;
1824 To
: Project_Node_Id
)
1830 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1831 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1832 end Set_Current_Item_Node
;
1834 ----------------------
1835 -- Set_Current_Term --
1836 ----------------------
1838 procedure Set_Current_Term
1839 (Node
: Project_Node_Id
;
1840 In_Tree
: Project_Node_Tree_Ref
;
1841 To
: Project_Node_Id
)
1847 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1848 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1849 end Set_Current_Term
;
1851 ----------------------
1852 -- Set_Directory_Of --
1853 ----------------------
1855 procedure Set_Directory_Of
1856 (Node
: Project_Node_Id
;
1857 In_Tree
: Project_Node_Tree_Ref
;
1858 To
: Path_Name_Type
)
1864 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1865 In_Tree
.Project_Nodes
.Table
(Node
).Directory
:= To
;
1866 end Set_Directory_Of
;
1868 ---------------------
1869 -- Set_End_Of_Line --
1870 ---------------------
1872 procedure Set_End_Of_Line
(To
: Project_Node_Id
) is
1874 End_Of_Line_Node
:= To
;
1875 end Set_End_Of_Line
;
1877 ----------------------------
1878 -- Set_Expression_Kind_Of --
1879 ----------------------------
1881 procedure Set_Expression_Kind_Of
1882 (Node
: Project_Node_Id
;
1883 In_Tree
: Project_Node_Tree_Ref
;
1889 and then -- should use Nkind_In here ??? why not???
1890 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
1892 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1894 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
1896 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1897 N_Typed_Variable_Declaration
1899 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
1901 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
1903 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
1905 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1907 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
1909 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
));
1910 In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
:= To
;
1911 end Set_Expression_Kind_Of
;
1913 -----------------------
1914 -- Set_Expression_Of --
1915 -----------------------
1917 procedure Set_Expression_Of
1918 (Node
: Project_Node_Id
;
1919 In_Tree
: Project_Node_Tree_Ref
;
1920 To
: Project_Node_Id
)
1926 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1927 N_Attribute_Declaration
1929 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1930 N_Typed_Variable_Declaration
1932 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1933 N_Variable_Declaration
));
1934 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1935 end Set_Expression_Of
;
1937 -------------------------------
1938 -- Set_External_Reference_Of --
1939 -------------------------------
1941 procedure Set_External_Reference_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_External_Value
);
1951 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1952 end Set_External_Reference_Of
;
1954 -----------------------------
1955 -- Set_External_Default_Of --
1956 -----------------------------
1958 procedure Set_External_Default_Of
1959 (Node
: Project_Node_Id
;
1960 In_Tree
: Project_Node_Tree_Ref
;
1961 To
: Project_Node_Id
)
1967 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
1968 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1969 end Set_External_Default_Of
;
1971 ----------------------------
1972 -- Set_First_Case_Item_Of --
1973 ----------------------------
1975 procedure Set_First_Case_Item_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
= N_Case_Construction
);
1985 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1986 end Set_First_Case_Item_Of
;
1988 -------------------------
1989 -- Set_First_Choice_Of --
1990 -------------------------
1992 procedure Set_First_Choice_Of
1993 (Node
: Project_Node_Id
;
1994 In_Tree
: Project_Node_Tree_Ref
;
1995 To
: Project_Node_Id
)
2001 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2002 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2003 end Set_First_Choice_Of
;
2005 -----------------------------
2006 -- Set_First_Comment_After --
2007 -----------------------------
2009 procedure Set_First_Comment_After
2010 (Node
: Project_Node_Id
;
2011 In_Tree
: Project_Node_Tree_Ref
;
2012 To
: Project_Node_Id
)
2014 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2016 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2017 end Set_First_Comment_After
;
2019 ---------------------------------
2020 -- Set_First_Comment_After_End --
2021 ---------------------------------
2023 procedure Set_First_Comment_After_End
2024 (Node
: Project_Node_Id
;
2025 In_Tree
: Project_Node_Tree_Ref
;
2026 To
: Project_Node_Id
)
2028 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2030 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:= To
;
2031 end Set_First_Comment_After_End
;
2033 ------------------------------
2034 -- Set_First_Comment_Before --
2035 ------------------------------
2037 procedure Set_First_Comment_Before
2038 (Node
: Project_Node_Id
;
2039 In_Tree
: Project_Node_Tree_Ref
;
2040 To
: Project_Node_Id
)
2043 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2045 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:= To
;
2046 end Set_First_Comment_Before
;
2048 ----------------------------------
2049 -- Set_First_Comment_Before_End --
2050 ----------------------------------
2052 procedure Set_First_Comment_Before_End
2053 (Node
: Project_Node_Id
;
2054 In_Tree
: Project_Node_Tree_Ref
;
2055 To
: Project_Node_Id
)
2057 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2059 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2060 end Set_First_Comment_Before_End
;
2062 ------------------------
2063 -- Set_Next_Case_Item --
2064 ------------------------
2066 procedure Set_Next_Case_Item
2067 (Node
: Project_Node_Id
;
2068 In_Tree
: Project_Node_Tree_Ref
;
2069 To
: Project_Node_Id
)
2075 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2076 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2077 end Set_Next_Case_Item
;
2079 ----------------------
2080 -- Set_Next_Comment --
2081 ----------------------
2083 procedure Set_Next_Comment
2084 (Node
: Project_Node_Id
;
2085 In_Tree
: Project_Node_Tree_Ref
;
2086 To
: Project_Node_Id
)
2092 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
2093 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= To
;
2094 end Set_Next_Comment
;
2096 -----------------------------------
2097 -- Set_First_Declarative_Item_Of --
2098 -----------------------------------
2100 procedure Set_First_Declarative_Item_Of
2101 (Node
: Project_Node_Id
;
2102 In_Tree
: Project_Node_Tree_Ref
;
2103 To
: Project_Node_Id
)
2109 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
2111 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
2113 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2115 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
2116 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2118 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2120 end Set_First_Declarative_Item_Of
;
2122 ----------------------------------
2123 -- Set_First_Expression_In_List --
2124 ----------------------------------
2126 procedure Set_First_Expression_In_List
2127 (Node
: Project_Node_Id
;
2128 In_Tree
: Project_Node_Tree_Ref
;
2129 To
: Project_Node_Id
)
2135 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
2136 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2137 end Set_First_Expression_In_List
;
2139 ------------------------------
2140 -- Set_First_Literal_String --
2141 ------------------------------
2143 procedure Set_First_Literal_String
2144 (Node
: Project_Node_Id
;
2145 In_Tree
: Project_Node_Tree_Ref
;
2146 To
: Project_Node_Id
)
2152 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2153 N_String_Type_Declaration
);
2154 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2155 end Set_First_Literal_String
;
2157 --------------------------
2158 -- Set_First_Package_Of --
2159 --------------------------
2161 procedure Set_First_Package_Of
2162 (Node
: Project_Node_Id
;
2163 In_Tree
: Project_Node_Tree_Ref
;
2164 To
: Package_Declaration_Id
)
2170 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2171 In_Tree
.Project_Nodes
.Table
(Node
).Packages
:= To
;
2172 end Set_First_Package_Of
;
2174 ------------------------------
2175 -- Set_First_String_Type_Of --
2176 ------------------------------
2178 procedure Set_First_String_Type_Of
2179 (Node
: Project_Node_Id
;
2180 In_Tree
: Project_Node_Tree_Ref
;
2181 To
: Project_Node_Id
)
2187 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2188 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2189 end Set_First_String_Type_Of
;
2191 --------------------
2192 -- Set_First_Term --
2193 --------------------
2195 procedure Set_First_Term
2196 (Node
: Project_Node_Id
;
2197 In_Tree
: Project_Node_Tree_Ref
;
2198 To
: Project_Node_Id
)
2204 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2205 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2208 ---------------------------
2209 -- Set_First_Variable_Of --
2210 ---------------------------
2212 procedure Set_First_Variable_Of
2213 (Node
: Project_Node_Id
;
2214 In_Tree
: Project_Node_Tree_Ref
;
2215 To
: Variable_Node_Id
)
2221 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2223 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2224 In_Tree
.Project_Nodes
.Table
(Node
).Variables
:= To
;
2225 end Set_First_Variable_Of
;
2227 ------------------------------
2228 -- Set_First_With_Clause_Of --
2229 ------------------------------
2231 procedure Set_First_With_Clause_Of
2232 (Node
: Project_Node_Id
;
2233 In_Tree
: Project_Node_Tree_Ref
;
2234 To
: Project_Node_Id
)
2240 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2241 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2242 end Set_First_With_Clause_Of
;
2244 --------------------------
2245 -- Set_Is_Extending_All --
2246 --------------------------
2248 procedure Set_Is_Extending_All
2249 (Node
: Project_Node_Id
;
2250 In_Tree
: Project_Node_Tree_Ref
)
2256 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2258 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2259 In_Tree
.Project_Nodes
.Table
(Node
).Flag2
:= True;
2260 end Set_Is_Extending_All
;
2262 -----------------------------
2263 -- Set_Is_Not_Last_In_List --
2264 -----------------------------
2266 procedure Set_Is_Not_Last_In_List
2267 (Node
: Project_Node_Id
;
2268 In_Tree
: Project_Node_Tree_Ref
)
2273 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2274 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= True;
2275 end Set_Is_Not_Last_In_List
;
2281 procedure Set_Kind_Of
2282 (Node
: Project_Node_Id
;
2283 In_Tree
: Project_Node_Tree_Ref
;
2284 To
: Project_Node_Kind
)
2287 pragma Assert
(Present
(Node
));
2288 In_Tree
.Project_Nodes
.Table
(Node
).Kind
:= To
;
2291 ---------------------
2292 -- Set_Location_Of --
2293 ---------------------
2295 procedure Set_Location_Of
2296 (Node
: Project_Node_Id
;
2297 In_Tree
: Project_Node_Tree_Ref
;
2301 pragma Assert
(Present
(Node
));
2302 In_Tree
.Project_Nodes
.Table
(Node
).Location
:= To
;
2303 end Set_Location_Of
;
2305 -----------------------------
2306 -- Set_Extended_Project_Of --
2307 -----------------------------
2309 procedure Set_Extended_Project_Of
2310 (Node
: Project_Node_Id
;
2311 In_Tree
: Project_Node_Tree_Ref
;
2312 To
: Project_Node_Id
)
2318 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2319 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2320 end Set_Extended_Project_Of
;
2322 ----------------------------------
2323 -- Set_Extended_Project_Path_Of --
2324 ----------------------------------
2326 procedure Set_Extended_Project_Path_Of
2327 (Node
: Project_Node_Id
;
2328 In_Tree
: Project_Node_Tree_Ref
;
2329 To
: Path_Name_Type
)
2335 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2336 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= Name_Id
(To
);
2337 end Set_Extended_Project_Path_Of
;
2339 ------------------------------
2340 -- Set_Extending_Project_Of --
2341 ------------------------------
2343 procedure Set_Extending_Project_Of
2344 (Node
: Project_Node_Id
;
2345 In_Tree
: Project_Node_Tree_Ref
;
2346 To
: Project_Node_Id
)
2352 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2353 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2354 end Set_Extending_Project_Of
;
2360 procedure Set_Name_Of
2361 (Node
: Project_Node_Id
;
2362 In_Tree
: Project_Node_Tree_Ref
;
2366 pragma Assert
(Present
(Node
));
2367 In_Tree
.Project_Nodes
.Table
(Node
).Name
:= To
;
2370 -------------------------------
2371 -- Set_Next_Declarative_Item --
2372 -------------------------------
2374 procedure Set_Next_Declarative_Item
2375 (Node
: Project_Node_Id
;
2376 In_Tree
: Project_Node_Tree_Ref
;
2377 To
: Project_Node_Id
)
2383 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
2384 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2385 end Set_Next_Declarative_Item
;
2387 -----------------------
2388 -- Set_Next_End_Node --
2389 -----------------------
2391 procedure Set_Next_End_Node
(To
: Project_Node_Id
) is
2393 Next_End_Nodes
.Increment_Last
;
2394 Next_End_Nodes
.Table
(Next_End_Nodes
.Last
) := To
;
2395 end Set_Next_End_Node
;
2397 ---------------------------------
2398 -- Set_Next_Expression_In_List --
2399 ---------------------------------
2401 procedure Set_Next_Expression_In_List
2402 (Node
: Project_Node_Id
;
2403 In_Tree
: Project_Node_Tree_Ref
;
2404 To
: Project_Node_Id
)
2410 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2411 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2412 end Set_Next_Expression_In_List
;
2414 -----------------------------
2415 -- Set_Next_Literal_String --
2416 -----------------------------
2418 procedure Set_Next_Literal_String
2419 (Node
: Project_Node_Id
;
2420 In_Tree
: Project_Node_Tree_Ref
;
2421 To
: Project_Node_Id
)
2427 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
2428 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2429 end Set_Next_Literal_String
;
2431 ---------------------------------
2432 -- Set_Next_Package_In_Project --
2433 ---------------------------------
2435 procedure Set_Next_Package_In_Project
2436 (Node
: Project_Node_Id
;
2437 In_Tree
: Project_Node_Tree_Ref
;
2438 To
: Project_Node_Id
)
2444 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2445 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2446 end Set_Next_Package_In_Project
;
2448 --------------------------
2449 -- Set_Next_String_Type --
2450 --------------------------
2452 procedure Set_Next_String_Type
2453 (Node
: Project_Node_Id
;
2454 In_Tree
: Project_Node_Tree_Ref
;
2455 To
: Project_Node_Id
)
2461 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2462 N_String_Type_Declaration
);
2463 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2464 end Set_Next_String_Type
;
2470 procedure Set_Next_Term
2471 (Node
: Project_Node_Id
;
2472 In_Tree
: Project_Node_Tree_Ref
;
2473 To
: Project_Node_Id
)
2479 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
2480 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2483 -----------------------
2484 -- Set_Next_Variable --
2485 -----------------------
2487 procedure Set_Next_Variable
2488 (Node
: Project_Node_Id
;
2489 In_Tree
: Project_Node_Tree_Ref
;
2490 To
: Project_Node_Id
)
2496 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2497 N_Typed_Variable_Declaration
2499 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2500 N_Variable_Declaration
));
2501 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2502 end Set_Next_Variable
;
2504 -----------------------------
2505 -- Set_Next_With_Clause_Of --
2506 -----------------------------
2508 procedure Set_Next_With_Clause_Of
2509 (Node
: Project_Node_Id
;
2510 In_Tree
: Project_Node_Tree_Ref
;
2511 To
: Project_Node_Id
)
2517 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2518 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2519 end Set_Next_With_Clause_Of
;
2521 -----------------------
2522 -- Set_Package_Id_Of --
2523 -----------------------
2525 procedure Set_Package_Id_Of
2526 (Node
: Project_Node_Id
;
2527 In_Tree
: Project_Node_Tree_Ref
;
2528 To
: Package_Node_Id
)
2534 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2535 In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
:= To
;
2536 end Set_Package_Id_Of
;
2538 -------------------------
2539 -- Set_Package_Node_Of --
2540 -------------------------
2542 procedure Set_Package_Node_Of
2543 (Node
: Project_Node_Id
;
2544 In_Tree
: Project_Node_Tree_Ref
;
2545 To
: Project_Node_Id
)
2551 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2553 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2554 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2555 end Set_Package_Node_Of
;
2557 ----------------------
2558 -- Set_Path_Name_Of --
2559 ----------------------
2561 procedure Set_Path_Name_Of
2562 (Node
: Project_Node_Id
;
2563 In_Tree
: Project_Node_Tree_Ref
;
2564 To
: Path_Name_Type
)
2570 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2572 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2573 In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
:= To
;
2574 end Set_Path_Name_Of
;
2576 ---------------------------
2577 -- Set_Previous_End_Node --
2578 ---------------------------
2579 procedure Set_Previous_End_Node
(To
: Project_Node_Id
) is
2581 Previous_End_Node
:= To
;
2582 end Set_Previous_End_Node
;
2584 ----------------------------
2585 -- Set_Previous_Line_Node --
2586 ----------------------------
2588 procedure Set_Previous_Line_Node
(To
: Project_Node_Id
) is
2590 Previous_Line_Node
:= To
;
2591 end Set_Previous_Line_Node
;
2593 --------------------------------
2594 -- Set_Project_Declaration_Of --
2595 --------------------------------
2597 procedure Set_Project_Declaration_Of
2598 (Node
: Project_Node_Id
;
2599 In_Tree
: Project_Node_Tree_Ref
;
2600 To
: Project_Node_Id
)
2606 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2607 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2608 end Set_Project_Declaration_Of
;
2610 ------------------------------
2611 -- Set_Project_Qualifier_Of --
2612 ------------------------------
2614 procedure Set_Project_Qualifier_Of
2615 (Node
: Project_Node_Id
;
2616 In_Tree
: Project_Node_Tree_Ref
;
2617 To
: Project_Qualifier
)
2622 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2623 In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
:= To
;
2624 end Set_Project_Qualifier_Of
;
2626 ---------------------------
2627 -- Set_Parent_Project_Of --
2628 ---------------------------
2630 procedure Set_Parent_Project_Of
2631 (Node
: Project_Node_Id
;
2632 In_Tree
: Project_Node_Tree_Ref
;
2633 To
: Project_Node_Id
)
2638 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2639 In_Tree
.Project_Nodes
.Table
(Node
).Field4
:= To
;
2640 end Set_Parent_Project_Of
;
2642 -----------------------------------------------
2643 -- Set_Project_File_Includes_Unkept_Comments --
2644 -----------------------------------------------
2646 procedure Set_Project_File_Includes_Unkept_Comments
2647 (Node
: Project_Node_Id
;
2648 In_Tree
: Project_Node_Tree_Ref
;
2651 Declaration
: constant Project_Node_Id
:=
2652 Project_Declaration_Of
(Node
, In_Tree
);
2654 In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
:= To
;
2655 end Set_Project_File_Includes_Unkept_Comments
;
2657 -------------------------
2658 -- Set_Project_Node_Of --
2659 -------------------------
2661 procedure Set_Project_Node_Of
2662 (Node
: Project_Node_Id
;
2663 In_Tree
: Project_Node_Tree_Ref
;
2664 To
: Project_Node_Id
;
2665 Limited_With
: Boolean := False)
2671 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2673 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2675 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2676 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2678 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2679 and then not Limited_With
2681 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2683 end Set_Project_Node_Of
;
2685 ---------------------------------------
2686 -- Set_Project_Of_Renamed_Package_Of --
2687 ---------------------------------------
2689 procedure Set_Project_Of_Renamed_Package_Of
2690 (Node
: Project_Node_Id
;
2691 In_Tree
: Project_Node_Tree_Ref
;
2692 To
: Project_Node_Id
)
2698 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2699 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2700 end Set_Project_Of_Renamed_Package_Of
;
2702 -------------------------
2703 -- Set_Source_Index_Of --
2704 -------------------------
2706 procedure Set_Source_Index_Of
2707 (Node
: Project_Node_Id
;
2708 In_Tree
: Project_Node_Tree_Ref
;
2715 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2717 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2718 N_Attribute_Declaration
));
2719 In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
:= To
;
2720 end Set_Source_Index_Of
;
2722 ------------------------
2723 -- Set_String_Type_Of --
2724 ------------------------
2726 procedure Set_String_Type_Of
2727 (Node
: Project_Node_Id
;
2728 In_Tree
: Project_Node_Tree_Ref
;
2729 To
: Project_Node_Id
)
2735 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2736 N_Variable_Reference
2738 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2739 N_Typed_Variable_Declaration
)
2741 In_Tree
.Project_Nodes
.Table
(To
).Kind
= N_String_Type_Declaration
);
2743 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2744 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2746 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2748 end Set_String_Type_Of
;
2750 -------------------------
2751 -- Set_String_Value_Of --
2752 -------------------------
2754 procedure Set_String_Value_Of
2755 (Node
: Project_Node_Id
;
2756 In_Tree
: Project_Node_Tree_Ref
;
2763 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2765 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2767 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2768 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
2769 end Set_String_Value_Of
;
2771 ---------------------
2772 -- Source_Index_Of --
2773 ---------------------
2775 function Source_Index_Of
2776 (Node
: Project_Node_Id
;
2777 In_Tree
: Project_Node_Tree_Ref
) return Int
2783 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2785 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2786 N_Attribute_Declaration
));
2787 return In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
;
2788 end Source_Index_Of
;
2790 --------------------
2791 -- String_Type_Of --
2792 --------------------
2794 function String_Type_Of
2795 (Node
: Project_Node_Id
;
2796 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
2802 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2803 N_Variable_Reference
2805 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2806 N_Typed_Variable_Declaration
));
2808 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2809 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
2811 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
2815 ---------------------
2816 -- String_Value_Of --
2817 ---------------------
2819 function String_Value_Of
2820 (Node
: Project_Node_Id
;
2821 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
2827 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2829 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2831 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2832 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
2833 end String_Value_Of
;
2835 --------------------
2836 -- Value_Is_Valid --
2837 --------------------
2839 function Value_Is_Valid
2840 (For_Typed_Variable
: Project_Node_Id
;
2841 In_Tree
: Project_Node_Tree_Ref
;
2842 Value
: Name_Id
) return Boolean
2846 (Present
(For_Typed_Variable
)
2848 (In_Tree
.Project_Nodes
.Table
(For_Typed_Variable
).Kind
=
2849 N_Typed_Variable_Declaration
));
2852 Current_String
: Project_Node_Id
:=
2853 First_Literal_String
2854 (String_Type_Of
(For_Typed_Variable
, In_Tree
),
2858 while Present
(Current_String
)
2860 String_Value_Of
(Current_String
, In_Tree
) /= Value
2863 Next_Literal_String
(Current_String
, In_Tree
);
2866 return Present
(Current_String
);
2871 -------------------------------
2872 -- There_Are_Unkept_Comments --
2873 -------------------------------
2875 function There_Are_Unkept_Comments
return Boolean is
2877 return Unkept_Comments
;
2878 end There_Are_Unkept_Comments
;
2880 --------------------
2881 -- Create_Project --
2882 --------------------
2884 function Create_Project
2885 (In_Tree
: Project_Node_Tree_Ref
;
2887 Full_Path
: Path_Name_Type
;
2888 Is_Config_File
: Boolean := False) return Project_Node_Id
2890 Project
: Project_Node_Id
;
2891 Qualifier
: Project_Qualifier
:= Unspecified
;
2893 Project
:= Default_Project_Node
(In_Tree
, N_Project
);
2894 Set_Name_Of
(Project
, In_Tree
, Name
);
2897 Path_Name_Type
(Get_Directory
(File_Name_Type
(Full_Path
))));
2898 Set_Path_Name_Of
(Project
, In_Tree
, Full_Path
);
2900 Set_Project_Declaration_Of
2902 Default_Project_Node
(In_Tree
, N_Project_Declaration
));
2904 if Is_Config_File
then
2905 Qualifier
:= Configuration
;
2908 if not Is_Config_File
then
2909 Prj
.Tree
.Tree_Private_Part
.Projects_Htable
.Set
2910 (In_Tree
.Projects_HT
,
2912 Prj
.Tree
.Tree_Private_Part
.Project_Name_And_Node
'
2914 Display_Name => Name,
2915 Canonical_Path => No_Path,
2918 Proj_Qualifier => Qualifier));
2928 procedure Add_At_End
2929 (Tree : Project_Node_Tree_Ref;
2930 Parent : Project_Node_Id;
2931 Expr : Project_Node_Id;
2932 Add_Before_First_Pkg : Boolean := False;
2933 Add_Before_First_Case : Boolean := False)
2935 Real_Parent : Project_Node_Id;
2936 New_Decl, Decl, Next : Project_Node_Id;
2937 Last, L : Project_Node_Id;
2940 if Kind_Of (Expr, Tree) /= N_Declarative_Item then
2941 New_Decl := Default_Project_Node (Tree, N_Declarative_Item);
2942 Set_Current_Item_Node (New_Decl, Tree, Expr);
2947 if Kind_Of (Parent, Tree) = N_Project then
2948 Real_Parent := Project_Declaration_Of (Parent, Tree);
2950 Real_Parent := Parent;
2953 Decl := First_Declarative_Item_Of (Real_Parent, Tree);
2955 if Decl = Empty_Node then
2956 Set_First_Declarative_Item_Of (Real_Parent, Tree, New_Decl);
2959 Next := Next_Declarative_Item (Decl, Tree);
2960 exit when Next = Empty_Node
2962 (Add_Before_First_Pkg
2963 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
2964 N_Package_Declaration)
2966 (Add_Before_First_Case
2967 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
2968 N_Case_Construction);
2972 -- In case Expr is in fact a range of declarative items
2976 L := Next_Declarative_Item (Last, Tree);
2977 exit when L = Empty_Node;
2981 -- In case Expr is in fact a range of declarative items
2985 L := Next_Declarative_Item (Last, Tree);
2986 exit when L = Empty_Node;
2990 Set_Next_Declarative_Item (Last, Tree, Next);
2991 Set_Next_Declarative_Item (Decl, Tree, New_Decl);
2995 ---------------------------
2996 -- Create_Literal_String --
2997 ---------------------------
2999 function Create_Literal_String
3000 (Str : Namet.Name_Id;
3001 Tree : Project_Node_Tree_Ref) return Project_Node_Id
3003 Node : Project_Node_Id;
3005 Node := Default_Project_Node (Tree, N_Literal_String, Prj.Single);
3006 Set_Next_Literal_String (Node, Tree, Empty_Node);
3007 Set_String_Value_Of (Node, Tree, Str);
3009 end Create_Literal_String;
3011 ---------------------------
3012 -- Enclose_In_Expression --
3013 ---------------------------
3015 function Enclose_In_Expression
3016 (Node : Project_Node_Id;
3017 Tree : Project_Node_Tree_Ref) return Project_Node_Id
3019 Expr : Project_Node_Id;
3021 if Kind_Of (Node, Tree) /= N_Expression then
3022 Expr := Default_Project_Node (Tree, N_Expression, Single);
3024 (Expr, Tree, Default_Project_Node (Tree, N_Term, Single));
3025 Set_Current_Term (First_Term (Expr, Tree), Tree, Node);
3030 end Enclose_In_Expression;
3032 --------------------
3033 -- Create_Package --
3034 --------------------
3036 function Create_Package
3037 (Tree : Project_Node_Tree_Ref;
3038 Project : Project_Node_Id;
3039 Pkg : String) return Project_Node_Id
3041 Pack : Project_Node_Id;
3045 Name_Len := Pkg'Length;
3046 Name_Buffer (1 .. Name_Len) := Pkg;
3049 -- Check if the package already exists
3051 Pack := First_Package_Of (Project, Tree);
3052 while Pack /= Empty_Node loop
3053 if Prj.Tree.Name_Of (Pack, Tree) = N then
3057 Pack := Next_Package_In_Project (Pack, Tree);
3060 -- Create the package and add it to the declarative item
3062 Pack := Default_Project_Node (Tree, N_Package_Declaration);
3063 Set_Name_Of (Pack, Tree, N);
3065 -- Find the correct package id to use
3067 Set_Package_Id_Of (Pack, Tree, Package_Node_Id_Of (N));
3069 -- Add it to the list of packages
3071 Set_Next_Package_In_Project
3072 (Pack, Tree, First_Package_Of (Project, Tree));
3073 Set_First_Package_Of (Project, Tree, Pack);
3075 Add_At_End (Tree, Project_Declaration_Of (Project, Tree), Pack);
3080 ----------------------
3081 -- Create_Attribute --
3082 ----------------------
3084 function Create_Attribute
3085 (Tree : Project_Node_Tree_Ref;
3086 Prj_Or_Pkg : Project_Node_Id;
3088 Index_Name : Name_Id := No_Name;
3089 Kind : Variable_Kind := List;
3090 At_Index : Integer := 0;
3091 Value : Project_Node_Id := Empty_Node) return Project_Node_Id
3093 Node : constant Project_Node_Id :=
3094 Default_Project_Node (Tree, N_Attribute_Declaration, Kind);
3096 Case_Insensitive : Boolean;
3098 Pkg : Package_Node_Id;
3099 Start_At : Attribute_Node_Id;
3100 Expr : Project_Node_Id;
3103 Set_Name_Of (Node, Tree, Name);
3105 if Index_Name /= No_Name then
3106 Set_Associative_Array_Index_Of (Node, Tree, Index_Name);
3109 if Prj_Or_Pkg /= Empty_Node then
3110 Add_At_End (Tree, Prj_Or_Pkg, Node);
3113 -- Find out the case sensitivity of the attribute
3115 if Prj_Or_Pkg /= Empty_Node
3116 and then Kind_Of (Prj_Or_Pkg, Tree) = N_Package_Declaration
3118 Pkg := Prj.Attr.Package_Node_Id_Of (Name_Of (Prj_Or_Pkg, Tree));
3119 Start_At := First_Attribute_Of (Pkg);
3121 Start_At := Attribute_First;
3124 Start_At := Attribute_Node_Id_Of (Name, Start_At);
3126 Attribute_Kind_Of (Start_At) = Case_Insensitive_Associative_Array;
3127 Tree.Project_Nodes.Table (Node).Flag1 := Case_Insensitive;
3129 if At_Index /= 0 then
3130 if Attribute_Kind_Of (Start_At) =
3131 Optional_Index_Associative_Array
3132 or else Attribute_Kind_Of (Start_At) =
3133 Optional_Index_Case_Insensitive_Associative_Array
3135 -- Results in: for Name ("index" at index) use "value";
3136 -- This is currently only used for executables.
3138 Set_Source_Index_Of (Node, Tree, To => Int (At_Index));
3141 -- Results in: for Name ("index") use "value" at index;
3143 -- ??? This limitation makes no sense, we should be able to
3144 -- set the source index on an expression.
3146 pragma Assert (Kind_Of (Value, Tree) = N_Literal_String);
3147 Set_Source_Index_Of (Value, Tree, To => Int (At_Index));
3151 if Value /= Empty_Node then
3152 Expr := Enclose_In_Expression (Value, Tree);
3153 Set_Expression_Of (Node, Tree, Expr);
3157 end Create_Attribute;