1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2013, 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
288 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
290 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
291 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
292 end Case_Insensitive
;
294 --------------------------------
295 -- Case_Variable_Reference_Of --
296 --------------------------------
298 function Case_Variable_Reference_Of
299 (Node
: Project_Node_Id
;
300 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
306 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
307 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
308 end Case_Variable_Reference_Of
;
310 ----------------------
311 -- Comment_Zones_Of --
312 ----------------------
314 function Comment_Zones_Of
315 (Node
: Project_Node_Id
;
316 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
318 Zone
: Project_Node_Id
;
321 pragma Assert
(Present
(Node
));
322 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
324 -- If there is not already an N_Comment_Zones associated, create a new
325 -- one and associate it with node Node.
328 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
329 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
330 In_Tree
.Project_Nodes
.Table
(Zone
) :=
331 (Kind
=> N_Comment_Zones
,
332 Qualifier
=> Unspecified
,
333 Location
=> No_Location
,
334 Directory
=> No_Path
,
335 Expr_Kind
=> Undefined
,
336 Variables
=> Empty_Node
,
337 Packages
=> Empty_Node
,
338 Pkg_Id
=> Empty_Package
,
341 Path_Name
=> No_Path
,
343 Field1
=> Empty_Node
,
344 Field2
=> Empty_Node
,
345 Field3
=> Empty_Node
,
346 Field4
=> Empty_Node
,
349 Comments
=> Empty_Node
);
350 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= Zone
;
354 end Comment_Zones_Of
;
356 -----------------------
357 -- Current_Item_Node --
358 -----------------------
360 function Current_Item_Node
361 (Node
: Project_Node_Id
;
362 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
368 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
369 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
370 end Current_Item_Node
;
376 function Current_Term
377 (Node
: Project_Node_Id
;
378 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
384 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
385 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
388 --------------------------
389 -- Default_Project_Node --
390 --------------------------
392 function Default_Project_Node
393 (In_Tree
: Project_Node_Tree_Ref
;
394 Of_Kind
: Project_Node_Kind
;
395 And_Expr_Kind
: Variable_Kind
:= Undefined
) return Project_Node_Id
397 Result
: Project_Node_Id
;
398 Zone
: Project_Node_Id
;
399 Previous
: Project_Node_Id
;
402 -- Create new node with specified kind and expression kind
404 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
405 In_Tree
.Project_Nodes
.Table
406 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
408 Qualifier
=> Unspecified
,
409 Location
=> No_Location
,
410 Directory
=> No_Path
,
411 Expr_Kind
=> And_Expr_Kind
,
412 Variables
=> Empty_Node
,
413 Packages
=> Empty_Node
,
414 Pkg_Id
=> Empty_Package
,
417 Path_Name
=> No_Path
,
419 Field1
=> Empty_Node
,
420 Field2
=> Empty_Node
,
421 Field3
=> Empty_Node
,
422 Field4
=> Empty_Node
,
425 Comments
=> Empty_Node
);
427 -- Save the new node for the returned value
429 Result
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
431 if Comments
.Last
> 0 then
433 -- If this is not a node with comments, then set the flag
435 if not Node_With_Comments
(Of_Kind
) then
436 Unkept_Comments
:= True;
438 elsif Of_Kind
/= N_Comment
and then Of_Kind
/= N_Comment_Zones
then
440 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
441 In_Tree
.Project_Nodes
.Table
442 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
443 (Kind
=> N_Comment_Zones
,
444 Qualifier
=> Unspecified
,
445 Expr_Kind
=> Undefined
,
446 Location
=> No_Location
,
447 Directory
=> No_Path
,
448 Variables
=> Empty_Node
,
449 Packages
=> Empty_Node
,
450 Pkg_Id
=> Empty_Package
,
453 Path_Name
=> No_Path
,
455 Field1
=> Empty_Node
,
456 Field2
=> Empty_Node
,
457 Field3
=> Empty_Node
,
458 Field4
=> Empty_Node
,
461 Comments
=> Empty_Node
);
463 Zone
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
464 In_Tree
.Project_Nodes
.Table
(Result
).Comments
:= Zone
;
465 Previous
:= Empty_Node
;
467 for J
in 1 .. Comments
.Last
loop
469 -- Create a new N_Comment node
471 Project_Node_Table
.Increment_Last
(In_Tree
.Project_Nodes
);
472 In_Tree
.Project_Nodes
.Table
473 (Project_Node_Table
.Last
(In_Tree
.Project_Nodes
)) :=
475 Qualifier
=> Unspecified
,
476 Expr_Kind
=> Undefined
,
477 Flag1
=> Comments
.Table
(J
).Follows_Empty_Line
,
479 Comments
.Table
(J
).Is_Followed_By_Empty_Line
,
480 Location
=> No_Location
,
481 Directory
=> No_Path
,
482 Variables
=> Empty_Node
,
483 Packages
=> Empty_Node
,
484 Pkg_Id
=> Empty_Package
,
487 Path_Name
=> No_Path
,
488 Value
=> Comments
.Table
(J
).Value
,
489 Field1
=> Empty_Node
,
490 Field2
=> Empty_Node
,
491 Field3
=> Empty_Node
,
492 Field4
=> Empty_Node
,
493 Comments
=> Empty_Node
);
495 -- Link it to the N_Comment_Zones node, if it is the first,
496 -- otherwise to the previous one.
498 if No
(Previous
) then
499 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:=
500 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
503 In_Tree
.Project_Nodes
.Table
(Previous
).Comments
:=
504 Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
507 -- This new node will be the previous one for the next
508 -- N_Comment node, if there is one.
510 Previous
:= Project_Node_Table
.Last
(In_Tree
.Project_Nodes
);
513 -- Empty the Comments table after all comments have been processed
515 Comments
.Set_Last
(0);
520 end Default_Project_Node
;
526 function Directory_Of
527 (Node
: Project_Node_Id
;
528 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
534 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
535 return In_Tree
.Project_Nodes
.Table
(Node
).Directory
;
538 -------------------------
539 -- End_Of_Line_Comment --
540 -------------------------
542 function End_Of_Line_Comment
543 (Node
: Project_Node_Id
;
544 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
546 Zone
: Project_Node_Id
:= Empty_Node
;
549 pragma Assert
(Present
(Node
));
550 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
555 return In_Tree
.Project_Nodes
.Table
(Zone
).Value
;
557 end End_Of_Line_Comment
;
559 ------------------------
560 -- Expression_Kind_Of --
561 ------------------------
563 function Expression_Kind_Of
564 (Node
: Project_Node_Id
;
565 In_Tree
: Project_Node_Tree_Ref
) return Variable_Kind
570 and then -- should use Nkind_In here ??? why not???
571 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
573 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
575 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
577 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
578 N_Typed_Variable_Declaration
580 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
582 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
584 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
586 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
588 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
590 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
));
591 return In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
;
592 end Expression_Kind_Of
;
598 function Expression_Of
599 (Node
: Project_Node_Id
;
600 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
606 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
607 N_Attribute_Declaration
609 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
610 N_Typed_Variable_Declaration
612 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
613 N_Variable_Declaration
));
615 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
618 -------------------------
619 -- Extended_Project_Of --
620 -------------------------
622 function Extended_Project_Of
623 (Node
: Project_Node_Id
;
624 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
630 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
631 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
632 end Extended_Project_Of
;
634 ------------------------------
635 -- Extended_Project_Path_Of --
636 ------------------------------
638 function Extended_Project_Path_Of
639 (Node
: Project_Node_Id
;
640 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
646 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
647 return Path_Name_Type
(In_Tree
.Project_Nodes
.Table
(Node
).Value
);
648 end Extended_Project_Path_Of
;
650 --------------------------
651 -- Extending_Project_Of --
652 --------------------------
653 function Extending_Project_Of
654 (Node
: Project_Node_Id
;
655 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
661 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
662 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
663 end Extending_Project_Of
;
665 ---------------------------
666 -- External_Reference_Of --
667 ---------------------------
669 function External_Reference_Of
670 (Node
: Project_Node_Id
;
671 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
677 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
678 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
679 end External_Reference_Of
;
681 -------------------------
682 -- External_Default_Of --
683 -------------------------
685 function External_Default_Of
686 (Node
: Project_Node_Id
;
687 In_Tree
: Project_Node_Tree_Ref
)
688 return Project_Node_Id
694 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
695 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
696 end External_Default_Of
;
698 ------------------------
699 -- First_Case_Item_Of --
700 ------------------------
702 function First_Case_Item_Of
703 (Node
: Project_Node_Id
;
704 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
710 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
711 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
712 end First_Case_Item_Of
;
714 ---------------------
715 -- First_Choice_Of --
716 ---------------------
718 function First_Choice_Of
719 (Node
: Project_Node_Id
;
720 In_Tree
: Project_Node_Tree_Ref
)
721 return Project_Node_Id
727 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
728 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
731 -------------------------
732 -- First_Comment_After --
733 -------------------------
735 function First_Comment_After
736 (Node
: Project_Node_Id
;
737 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
739 Zone
: Project_Node_Id
:= Empty_Node
;
741 pragma Assert
(Present
(Node
));
742 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
748 return In_Tree
.Project_Nodes
.Table
(Zone
).Field2
;
750 end First_Comment_After
;
752 -----------------------------
753 -- First_Comment_After_End --
754 -----------------------------
756 function First_Comment_After_End
757 (Node
: Project_Node_Id
;
758 In_Tree
: Project_Node_Tree_Ref
)
759 return Project_Node_Id
761 Zone
: Project_Node_Id
:= Empty_Node
;
764 pragma Assert
(Present
(Node
));
765 Zone
:= In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
771 return In_Tree
.Project_Nodes
.Table
(Zone
).Comments
;
773 end First_Comment_After_End
;
775 --------------------------
776 -- First_Comment_Before --
777 --------------------------
779 function First_Comment_Before
780 (Node
: Project_Node_Id
;
781 In_Tree
: Project_Node_Tree_Ref
) 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
).Field1
;
795 end First_Comment_Before
;
797 ------------------------------
798 -- First_Comment_Before_End --
799 ------------------------------
801 function First_Comment_Before_End
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
).Field3
;
817 end First_Comment_Before_End
;
819 -------------------------------
820 -- First_Declarative_Item_Of --
821 -------------------------------
823 function First_Declarative_Item_Of
824 (Node
: Project_Node_Id
;
825 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
831 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
833 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
835 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
837 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
838 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
840 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
842 end First_Declarative_Item_Of
;
844 ------------------------------
845 -- First_Expression_In_List --
846 ------------------------------
848 function First_Expression_In_List
849 (Node
: Project_Node_Id
;
850 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
856 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
857 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
858 end First_Expression_In_List
;
860 --------------------------
861 -- First_Literal_String --
862 --------------------------
864 function First_Literal_String
865 (Node
: Project_Node_Id
;
866 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
872 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
873 N_String_Type_Declaration
);
874 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
875 end First_Literal_String
;
877 ----------------------
878 -- First_Package_Of --
879 ----------------------
881 function First_Package_Of
882 (Node
: Project_Node_Id
;
883 In_Tree
: Project_Node_Tree_Ref
) return Package_Declaration_Id
889 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
890 return In_Tree
.Project_Nodes
.Table
(Node
).Packages
;
891 end First_Package_Of
;
893 --------------------------
894 -- First_String_Type_Of --
895 --------------------------
897 function First_String_Type_Of
898 (Node
: Project_Node_Id
;
899 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
905 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
906 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
907 end First_String_Type_Of
;
914 (Node
: Project_Node_Id
;
915 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
921 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
922 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
925 -----------------------
926 -- First_Variable_Of --
927 -----------------------
929 function First_Variable_Of
930 (Node
: Project_Node_Id
;
931 In_Tree
: Project_Node_Tree_Ref
) return Variable_Node_Id
937 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
939 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
941 return In_Tree
.Project_Nodes
.Table
(Node
).Variables
;
942 end First_Variable_Of
;
944 --------------------------
945 -- First_With_Clause_Of --
946 --------------------------
948 function First_With_Clause_Of
949 (Node
: Project_Node_Id
;
950 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
956 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
957 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
958 end First_With_Clause_Of
;
960 ------------------------
961 -- Follows_Empty_Line --
962 ------------------------
964 function Follows_Empty_Line
965 (Node
: Project_Node_Id
;
966 In_Tree
: Project_Node_Tree_Ref
) return Boolean
972 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
973 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
974 end Follows_Empty_Line
;
980 function Hash
(N
: Project_Node_Id
) return Header_Num
is
982 return Header_Num
(N
mod Project_Node_Id
(Header_Num
'Last));
989 procedure Initialize
(Tree
: Project_Node_Tree_Ref
) is
991 Project_Node_Table
.Init
(Tree
.Project_Nodes
);
992 Projects_Htable
.Reset
(Tree
.Projects_HT
);
999 procedure Override_Flags
1000 (Self
: in out Environment
;
1001 Flags
: Prj
.Processing_Flags
)
1004 Self
.Flags
:= Flags
;
1011 procedure Initialize
1012 (Self
: out Environment
;
1013 Flags
: Processing_Flags
)
1016 -- Do not reset the external references, in case we are reloading a
1017 -- project, since we want to preserve the current environment. But we
1018 -- still need to ensure that the external references are properly
1021 Prj
.Ext
.Initialize
(Self
.External
);
1023 Self
.Flags
:= Flags
;
1026 -------------------------
1027 -- Initialize_And_Copy --
1028 -------------------------
1030 procedure Initialize_And_Copy
1031 (Self
: out Environment
;
1032 Copy_From
: Environment
)
1035 Self
.Flags
:= Copy_From
.Flags
;
1036 Prj
.Ext
.Initialize
(Self
.External
, Copy_From
=> Copy_From
.External
);
1037 Prj
.Env
.Copy
(From
=> Copy_From
.Project_Path
, To
=> Self
.Project_Path
);
1038 end Initialize_And_Copy
;
1044 procedure Free
(Self
: in out Environment
) is
1046 Prj
.Ext
.Free
(Self
.External
);
1047 Free
(Self
.Project_Path
);
1054 procedure Free
(Proj
: in out Project_Node_Tree_Ref
) is
1055 procedure Unchecked_Free
is new Ada
.Unchecked_Deallocation
1056 (Project_Node_Tree_Data
, Project_Node_Tree_Ref
);
1058 if Proj
/= null then
1059 Project_Node_Table
.Free
(Proj
.Project_Nodes
);
1060 Projects_Htable
.Reset
(Proj
.Projects_HT
);
1061 Unchecked_Free
(Proj
);
1065 -------------------------------
1066 -- Is_Followed_By_Empty_Line --
1067 -------------------------------
1069 function Is_Followed_By_Empty_Line
1070 (Node
: Project_Node_Id
;
1071 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1077 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1078 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1079 end Is_Followed_By_Empty_Line
;
1081 ----------------------
1082 -- Is_Extending_All --
1083 ----------------------
1085 function Is_Extending_All
1086 (Node
: Project_Node_Id
;
1087 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1093 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1095 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1096 return In_Tree
.Project_Nodes
.Table
(Node
).Flag2
;
1097 end Is_Extending_All
;
1099 -------------------------
1100 -- Is_Not_Last_In_List --
1101 -------------------------
1103 function Is_Not_Last_In_List
1104 (Node
: Project_Node_Id
;
1105 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1111 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1112 return In_Tree
.Project_Nodes
.Table
(Node
).Flag1
;
1113 end Is_Not_Last_In_List
;
1115 -------------------------------------
1116 -- Imported_Or_Extended_Project_Of --
1117 -------------------------------------
1119 function Imported_Or_Extended_Project_Of
1120 (Project
: Project_Node_Id
;
1121 In_Tree
: Project_Node_Tree_Ref
;
1122 With_Name
: Name_Id
) return Project_Node_Id
1124 With_Clause
: Project_Node_Id
:=
1125 First_With_Clause_Of
(Project
, In_Tree
);
1126 Result
: Project_Node_Id
:= Empty_Node
;
1129 -- First check all the imported projects
1131 while Present
(With_Clause
) loop
1133 -- Only non limited imported project may be used as prefix
1134 -- of variable or attributes.
1136 Result
:= Non_Limited_Project_Node_Of
(With_Clause
, In_Tree
);
1137 exit when Present
(Result
)
1138 and then Name_Of
(Result
, In_Tree
) = With_Name
;
1139 With_Clause
:= Next_With_Clause_Of
(With_Clause
, In_Tree
);
1142 -- If it is not an imported project, it might be an extended project
1144 if No
(With_Clause
) then
1149 (Project_Declaration_Of
(Result
, In_Tree
), In_Tree
);
1151 exit when No
(Result
)
1152 or else Name_Of
(Result
, In_Tree
) = With_Name
;
1157 end Imported_Or_Extended_Project_Of
;
1164 (Node
: Project_Node_Id
;
1165 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Kind
1168 pragma Assert
(Present
(Node
));
1169 return In_Tree
.Project_Nodes
.Table
(Node
).Kind
;
1176 function Location_Of
1177 (Node
: Project_Node_Id
;
1178 In_Tree
: Project_Node_Tree_Ref
) return Source_Ptr
1181 pragma Assert
(Present
(Node
));
1182 return In_Tree
.Project_Nodes
.Table
(Node
).Location
;
1190 (Node
: Project_Node_Id
;
1191 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
1194 pragma Assert
(Present
(Node
));
1195 return In_Tree
.Project_Nodes
.Table
(Node
).Name
;
1198 --------------------
1199 -- Next_Case_Item --
1200 --------------------
1202 function Next_Case_Item
1203 (Node
: Project_Node_Id
;
1204 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1210 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
1211 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1218 function Next_Comment
1219 (Node
: Project_Node_Id
;
1220 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1226 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
1227 return In_Tree
.Project_Nodes
.Table
(Node
).Comments
;
1230 ---------------------------
1231 -- Next_Declarative_Item --
1232 ---------------------------
1234 function Next_Declarative_Item
1235 (Node
: Project_Node_Id
;
1236 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1242 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1243 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1244 end Next_Declarative_Item
;
1246 -----------------------------
1247 -- Next_Expression_In_List --
1248 -----------------------------
1250 function Next_Expression_In_List
1251 (Node
: Project_Node_Id
;
1252 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1258 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
1259 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1260 end Next_Expression_In_List
;
1262 -------------------------
1263 -- Next_Literal_String --
1264 -------------------------
1266 function Next_Literal_String
1267 (Node
: Project_Node_Id
;
1268 In_Tree
: Project_Node_Tree_Ref
)
1269 return Project_Node_Id
1275 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
1276 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1277 end Next_Literal_String
;
1279 -----------------------------
1280 -- Next_Package_In_Project --
1281 -----------------------------
1283 function Next_Package_In_Project
1284 (Node
: Project_Node_Id
;
1285 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1291 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1292 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1293 end Next_Package_In_Project
;
1295 ----------------------
1296 -- Next_String_Type --
1297 ----------------------
1299 function Next_String_Type
1300 (Node
: Project_Node_Id
;
1301 In_Tree
: Project_Node_Tree_Ref
)
1302 return Project_Node_Id
1308 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1309 N_String_Type_Declaration
);
1310 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1311 end Next_String_Type
;
1318 (Node
: Project_Node_Id
;
1319 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1325 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1326 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1333 function Next_Variable
1334 (Node
: Project_Node_Id
;
1335 In_Tree
: Project_Node_Tree_Ref
)
1336 return Project_Node_Id
1342 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1343 N_Typed_Variable_Declaration
1345 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1346 N_Variable_Declaration
));
1348 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1351 -------------------------
1352 -- Next_With_Clause_Of --
1353 -------------------------
1355 function Next_With_Clause_Of
1356 (Node
: Project_Node_Id
;
1357 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1363 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
1364 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1365 end Next_With_Clause_Of
;
1371 function No
(Node
: Project_Node_Id
) return Boolean is
1373 return Node
= Empty_Node
;
1376 ---------------------------------
1377 -- Non_Limited_Project_Node_Of --
1378 ---------------------------------
1380 function Non_Limited_Project_Node_Of
1381 (Node
: Project_Node_Id
;
1382 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1388 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1389 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
1390 end Non_Limited_Project_Node_Of
;
1396 function Package_Id_Of
1397 (Node
: Project_Node_Id
;
1398 In_Tree
: Project_Node_Tree_Ref
) return Package_Node_Id
1404 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1405 return In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
;
1408 ---------------------
1409 -- Package_Node_Of --
1410 ---------------------
1412 function Package_Node_Of
1413 (Node
: Project_Node_Id
;
1414 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1420 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1422 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1423 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1424 end Package_Node_Of
;
1430 function Path_Name_Of
1431 (Node
: Project_Node_Id
;
1432 In_Tree
: Project_Node_Tree_Ref
) return Path_Name_Type
1438 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
1440 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
1441 return In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
;
1448 function Present
(Node
: Project_Node_Id
) return Boolean is
1450 return Node
/= Empty_Node
;
1453 ----------------------------
1454 -- Project_Declaration_Of --
1455 ----------------------------
1457 function Project_Declaration_Of
1458 (Node
: Project_Node_Id
;
1459 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1465 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1466 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
1467 end Project_Declaration_Of
;
1469 --------------------------
1470 -- Project_Qualifier_Of --
1471 --------------------------
1473 function Project_Qualifier_Of
1474 (Node
: Project_Node_Id
;
1475 In_Tree
: Project_Node_Tree_Ref
) return Project_Qualifier
1481 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1482 return In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
;
1483 end Project_Qualifier_Of
;
1485 -----------------------
1486 -- Parent_Project_Of --
1487 -----------------------
1489 function Parent_Project_Of
1490 (Node
: Project_Node_Id
;
1491 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1497 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1498 return In_Tree
.Project_Nodes
.Table
(Node
).Field4
;
1499 end Parent_Project_Of
;
1501 -------------------------------------------
1502 -- Project_File_Includes_Unkept_Comments --
1503 -------------------------------------------
1505 function Project_File_Includes_Unkept_Comments
1506 (Node
: Project_Node_Id
;
1507 In_Tree
: Project_Node_Tree_Ref
) return Boolean
1509 Declaration
: constant Project_Node_Id
:=
1510 Project_Declaration_Of
(Node
, In_Tree
);
1512 return In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
;
1513 end Project_File_Includes_Unkept_Comments
;
1515 ---------------------
1516 -- Project_Node_Of --
1517 ---------------------
1519 function Project_Node_Of
1520 (Node
: Project_Node_Id
;
1521 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1527 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
1529 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1531 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1532 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1533 end Project_Node_Of
;
1535 -----------------------------------
1536 -- Project_Of_Renamed_Package_Of --
1537 -----------------------------------
1539 function Project_Of_Renamed_Package_Of
1540 (Node
: Project_Node_Id
;
1541 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
1547 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
1548 return In_Tree
.Project_Nodes
.Table
(Node
).Field1
;
1549 end Project_Of_Renamed_Package_Of
;
1551 --------------------------
1552 -- Remove_Next_End_Node --
1553 --------------------------
1555 procedure Remove_Next_End_Node
is
1557 Next_End_Nodes
.Decrement_Last
;
1558 end Remove_Next_End_Node
;
1564 procedure Reset_State
is
1566 End_Of_Line_Node
:= Empty_Node
;
1567 Previous_Line_Node
:= Empty_Node
;
1568 Previous_End_Node
:= Empty_Node
;
1569 Unkept_Comments
:= False;
1570 Comments
.Set_Last
(0);
1573 ----------------------
1574 -- Restore_And_Free --
1575 ----------------------
1577 procedure Restore_And_Free
(S
: in out Comment_State
) is
1578 procedure Unchecked_Free
is new
1579 Ada
.Unchecked_Deallocation
(Comment_Array
, Comments_Ptr
);
1582 End_Of_Line_Node
:= S
.End_Of_Line_Node
;
1583 Previous_Line_Node
:= S
.Previous_Line_Node
;
1584 Previous_End_Node
:= S
.Previous_End_Node
;
1585 Next_End_Nodes
.Set_Last
(0);
1586 Unkept_Comments
:= S
.Unkept_Comments
;
1588 Comments
.Set_Last
(0);
1590 for J
in S
.Comments
'Range loop
1591 Comments
.Increment_Last
;
1592 Comments
.Table
(Comments
.Last
) := S
.Comments
(J
);
1595 Unchecked_Free
(S
.Comments
);
1596 end Restore_And_Free
;
1602 procedure Save
(S
: out Comment_State
) is
1603 Cmts
: constant Comments_Ptr
:= new Comment_Array
(1 .. Comments
.Last
);
1606 for J
in 1 .. Comments
.Last
loop
1607 Cmts
(J
) := Comments
.Table
(J
);
1611 (End_Of_Line_Node
=> End_Of_Line_Node
,
1612 Previous_Line_Node
=> Previous_Line_Node
,
1613 Previous_End_Node
=> Previous_End_Node
,
1614 Unkept_Comments
=> Unkept_Comments
,
1622 procedure Scan
(In_Tree
: Project_Node_Tree_Ref
) is
1623 Empty_Line
: Boolean := False;
1626 -- If there are comments, then they will not be kept. Set the flag and
1627 -- clear the comments.
1629 if Comments
.Last
> 0 then
1630 Unkept_Comments
:= True;
1631 Comments
.Set_Last
(0);
1634 -- Loop until a token other that End_Of_Line or Comment is found
1637 Prj
.Err
.Scanner
.Scan
;
1640 when Tok_End_Of_Line
=>
1641 if Prev_Token
= Tok_End_Of_Line
then
1644 if Comments
.Last
> 0 then
1645 Comments
.Table
(Comments
.Last
).Is_Followed_By_Empty_Line
1651 -- If this is a line comment, add it to the comment table
1653 if Prev_Token
= Tok_End_Of_Line
1654 or else Prev_Token
= No_Token
1656 Comments
.Increment_Last
;
1657 Comments
.Table
(Comments
.Last
) :=
1658 (Value
=> Comment_Id
,
1659 Follows_Empty_Line
=> Empty_Line
,
1660 Is_Followed_By_Empty_Line
=> False);
1662 -- Otherwise, it is an end of line comment. If there is an
1663 -- end of line node specified, associate the comment with
1666 elsif Present
(End_Of_Line_Node
) then
1668 Zones
: constant Project_Node_Id
:=
1669 Comment_Zones_Of
(End_Of_Line_Node
, In_Tree
);
1671 In_Tree
.Project_Nodes
.Table
(Zones
).Value
:= Comment_Id
;
1674 -- Otherwise, this end of line node cannot be kept
1677 Unkept_Comments
:= True;
1678 Comments
.Set_Last
(0);
1681 Empty_Line
:= False;
1684 -- If there are comments, where the first comment is not
1685 -- following an empty line, put the initial uninterrupted
1686 -- comment zone with the node of the preceding line (either
1687 -- a Previous_Line or a Previous_End node), if any.
1689 if Comments
.Last
> 0 and then
1690 not Comments
.Table
(1).Follows_Empty_Line
then
1691 if Present
(Previous_Line_Node
) then
1693 (To
=> Previous_Line_Node
,
1695 In_Tree
=> In_Tree
);
1697 elsif Present
(Previous_End_Node
) then
1699 (To
=> Previous_End_Node
,
1701 In_Tree
=> In_Tree
);
1705 -- If there are still comments and the token is "end", then
1706 -- put these comments with the Next_End node, if any;
1707 -- otherwise, these comments cannot be kept. Always clear
1710 if Comments
.Last
> 0 and then Token
= Tok_End
then
1711 if Next_End_Nodes
.Last
> 0 then
1713 (To
=> Next_End_Nodes
.Table
(Next_End_Nodes
.Last
),
1714 Where
=> Before_End
,
1715 In_Tree
=> In_Tree
);
1718 Unkept_Comments
:= True;
1721 Comments
.Set_Last
(0);
1724 -- Reset the End_Of_Line, Previous_Line and Previous_End nodes
1725 -- so that they are not used again.
1727 End_Of_Line_Node
:= Empty_Node
;
1728 Previous_Line_Node
:= Empty_Node
;
1729 Previous_End_Node
:= Empty_Node
;
1738 ------------------------------------
1739 -- Set_Associative_Array_Index_Of --
1740 ------------------------------------
1742 procedure Set_Associative_Array_Index_Of
1743 (Node
: Project_Node_Id
;
1744 In_Tree
: Project_Node_Tree_Ref
;
1751 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1753 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1754 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
1755 end Set_Associative_Array_Index_Of
;
1757 --------------------------------
1758 -- Set_Associative_Package_Of --
1759 --------------------------------
1761 procedure Set_Associative_Package_Of
1762 (Node
: Project_Node_Id
;
1763 In_Tree
: Project_Node_Tree_Ref
;
1764 To
: Project_Node_Id
)
1770 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
);
1771 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
1772 end Set_Associative_Package_Of
;
1774 --------------------------------
1775 -- Set_Associative_Project_Of --
1776 --------------------------------
1778 procedure Set_Associative_Project_Of
1779 (Node
: Project_Node_Id
;
1780 In_Tree
: Project_Node_Tree_Ref
;
1781 To
: Project_Node_Id
)
1787 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1788 N_Attribute_Declaration
));
1789 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1790 end Set_Associative_Project_Of
;
1792 --------------------------
1793 -- Set_Case_Insensitive --
1794 --------------------------
1796 procedure Set_Case_Insensitive
1797 (Node
: Project_Node_Id
;
1798 In_Tree
: Project_Node_Tree_Ref
;
1805 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1807 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
1808 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= To
;
1809 end Set_Case_Insensitive
;
1811 ------------------------------------
1812 -- Set_Case_Variable_Reference_Of --
1813 ------------------------------------
1815 procedure Set_Case_Variable_Reference_Of
1816 (Node
: Project_Node_Id
;
1817 In_Tree
: Project_Node_Tree_Ref
;
1818 To
: Project_Node_Id
)
1824 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
1825 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1826 end Set_Case_Variable_Reference_Of
;
1828 ---------------------------
1829 -- Set_Current_Item_Node --
1830 ---------------------------
1832 procedure Set_Current_Item_Node
1833 (Node
: Project_Node_Id
;
1834 In_Tree
: Project_Node_Tree_Ref
;
1835 To
: Project_Node_Id
)
1841 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
1842 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1843 end Set_Current_Item_Node
;
1845 ----------------------
1846 -- Set_Current_Term --
1847 ----------------------
1849 procedure Set_Current_Term
1850 (Node
: Project_Node_Id
;
1851 In_Tree
: Project_Node_Tree_Ref
;
1852 To
: Project_Node_Id
)
1858 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
1859 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1860 end Set_Current_Term
;
1862 ----------------------
1863 -- Set_Directory_Of --
1864 ----------------------
1866 procedure Set_Directory_Of
1867 (Node
: Project_Node_Id
;
1868 In_Tree
: Project_Node_Tree_Ref
;
1869 To
: Path_Name_Type
)
1875 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
1876 In_Tree
.Project_Nodes
.Table
(Node
).Directory
:= To
;
1877 end Set_Directory_Of
;
1879 ---------------------
1880 -- Set_End_Of_Line --
1881 ---------------------
1883 procedure Set_End_Of_Line
(To
: Project_Node_Id
) is
1885 End_Of_Line_Node
:= To
;
1886 end Set_End_Of_Line
;
1888 ----------------------------
1889 -- Set_Expression_Kind_Of --
1890 ----------------------------
1892 procedure Set_Expression_Kind_Of
1893 (Node
: Project_Node_Id
;
1894 In_Tree
: Project_Node_Tree_Ref
;
1900 and then -- should use Nkind_In here ??? why not???
1901 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
1903 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Declaration
1905 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Declaration
1907 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1908 N_Typed_Variable_Declaration
1910 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
1912 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
1914 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
1916 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
1918 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
1920 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
));
1921 In_Tree
.Project_Nodes
.Table
(Node
).Expr_Kind
:= To
;
1922 end Set_Expression_Kind_Of
;
1924 -----------------------
1925 -- Set_Expression_Of --
1926 -----------------------
1928 procedure Set_Expression_Of
1929 (Node
: Project_Node_Id
;
1930 In_Tree
: Project_Node_Tree_Ref
;
1931 To
: Project_Node_Id
)
1937 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1938 N_Attribute_Declaration
1940 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1941 N_Typed_Variable_Declaration
1943 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
1944 N_Variable_Declaration
));
1945 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1946 end Set_Expression_Of
;
1948 -------------------------------
1949 -- Set_External_Reference_Of --
1950 -------------------------------
1952 procedure Set_External_Reference_Of
1953 (Node
: Project_Node_Id
;
1954 In_Tree
: Project_Node_Tree_Ref
;
1955 To
: Project_Node_Id
)
1961 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
1962 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
1963 end Set_External_Reference_Of
;
1965 -----------------------------
1966 -- Set_External_Default_Of --
1967 -----------------------------
1969 procedure Set_External_Default_Of
1970 (Node
: Project_Node_Id
;
1971 In_Tree
: Project_Node_Tree_Ref
;
1972 To
: Project_Node_Id
)
1978 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_External_Value
);
1979 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1980 end Set_External_Default_Of
;
1982 ----------------------------
1983 -- Set_First_Case_Item_Of --
1984 ----------------------------
1986 procedure Set_First_Case_Item_Of
1987 (Node
: Project_Node_Id
;
1988 In_Tree
: Project_Node_Tree_Ref
;
1989 To
: Project_Node_Id
)
1995 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Construction
);
1996 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
1997 end Set_First_Case_Item_Of
;
1999 -------------------------
2000 -- Set_First_Choice_Of --
2001 -------------------------
2003 procedure Set_First_Choice_Of
2004 (Node
: Project_Node_Id
;
2005 In_Tree
: Project_Node_Tree_Ref
;
2006 To
: Project_Node_Id
)
2012 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2013 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2014 end Set_First_Choice_Of
;
2016 -----------------------------
2017 -- Set_First_Comment_After --
2018 -----------------------------
2020 procedure Set_First_Comment_After
2021 (Node
: Project_Node_Id
;
2022 In_Tree
: Project_Node_Tree_Ref
;
2023 To
: Project_Node_Id
)
2025 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2027 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2028 end Set_First_Comment_After
;
2030 ---------------------------------
2031 -- Set_First_Comment_After_End --
2032 ---------------------------------
2034 procedure Set_First_Comment_After_End
2035 (Node
: Project_Node_Id
;
2036 In_Tree
: Project_Node_Tree_Ref
;
2037 To
: Project_Node_Id
)
2039 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2041 In_Tree
.Project_Nodes
.Table
(Zone
).Comments
:= To
;
2042 end Set_First_Comment_After_End
;
2044 ------------------------------
2045 -- Set_First_Comment_Before --
2046 ------------------------------
2048 procedure Set_First_Comment_Before
2049 (Node
: Project_Node_Id
;
2050 In_Tree
: Project_Node_Tree_Ref
;
2051 To
: Project_Node_Id
)
2053 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2055 In_Tree
.Project_Nodes
.Table
(Zone
).Field1
:= To
;
2056 end Set_First_Comment_Before
;
2058 ----------------------------------
2059 -- Set_First_Comment_Before_End --
2060 ----------------------------------
2062 procedure Set_First_Comment_Before_End
2063 (Node
: Project_Node_Id
;
2064 In_Tree
: Project_Node_Tree_Ref
;
2065 To
: Project_Node_Id
)
2067 Zone
: constant Project_Node_Id
:= Comment_Zones_Of
(Node
, In_Tree
);
2069 In_Tree
.Project_Nodes
.Table
(Zone
).Field2
:= To
;
2070 end Set_First_Comment_Before_End
;
2072 ------------------------
2073 -- Set_Next_Case_Item --
2074 ------------------------
2076 procedure Set_Next_Case_Item
2077 (Node
: Project_Node_Id
;
2078 In_Tree
: Project_Node_Tree_Ref
;
2079 To
: Project_Node_Id
)
2085 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
);
2086 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2087 end Set_Next_Case_Item
;
2089 ----------------------
2090 -- Set_Next_Comment --
2091 ----------------------
2093 procedure Set_Next_Comment
2094 (Node
: Project_Node_Id
;
2095 In_Tree
: Project_Node_Tree_Ref
;
2096 To
: Project_Node_Id
)
2102 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
);
2103 In_Tree
.Project_Nodes
.Table
(Node
).Comments
:= To
;
2104 end Set_Next_Comment
;
2106 -----------------------------------
2107 -- Set_First_Declarative_Item_Of --
2108 -----------------------------------
2110 procedure Set_First_Declarative_Item_Of
2111 (Node
: Project_Node_Id
;
2112 In_Tree
: Project_Node_Tree_Ref
;
2113 To
: Project_Node_Id
)
2119 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
2121 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Case_Item
2123 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2125 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
then
2126 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2128 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2130 end Set_First_Declarative_Item_Of
;
2132 ----------------------------------
2133 -- Set_First_Expression_In_List --
2134 ----------------------------------
2136 procedure Set_First_Expression_In_List
2137 (Node
: Project_Node_Id
;
2138 In_Tree
: Project_Node_Tree_Ref
;
2139 To
: Project_Node_Id
)
2145 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String_List
);
2146 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2147 end Set_First_Expression_In_List
;
2149 ------------------------------
2150 -- Set_First_Literal_String --
2151 ------------------------------
2153 procedure Set_First_Literal_String
2154 (Node
: Project_Node_Id
;
2155 In_Tree
: Project_Node_Tree_Ref
;
2156 To
: Project_Node_Id
)
2162 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2163 N_String_Type_Declaration
);
2164 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2165 end Set_First_Literal_String
;
2167 --------------------------
2168 -- Set_First_Package_Of --
2169 --------------------------
2171 procedure Set_First_Package_Of
2172 (Node
: Project_Node_Id
;
2173 In_Tree
: Project_Node_Tree_Ref
;
2174 To
: Package_Declaration_Id
)
2180 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2181 In_Tree
.Project_Nodes
.Table
(Node
).Packages
:= To
;
2182 end Set_First_Package_Of
;
2184 ------------------------------
2185 -- Set_First_String_Type_Of --
2186 ------------------------------
2188 procedure Set_First_String_Type_Of
2189 (Node
: Project_Node_Id
;
2190 In_Tree
: Project_Node_Tree_Ref
;
2191 To
: Project_Node_Id
)
2197 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2198 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2199 end Set_First_String_Type_Of
;
2201 --------------------
2202 -- Set_First_Term --
2203 --------------------
2205 procedure Set_First_Term
2206 (Node
: Project_Node_Id
;
2207 In_Tree
: Project_Node_Tree_Ref
;
2208 To
: Project_Node_Id
)
2214 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2215 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2218 ---------------------------
2219 -- Set_First_Variable_Of --
2220 ---------------------------
2222 procedure Set_First_Variable_Of
2223 (Node
: Project_Node_Id
;
2224 In_Tree
: Project_Node_Tree_Ref
;
2225 To
: Variable_Node_Id
)
2231 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2233 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
));
2234 In_Tree
.Project_Nodes
.Table
(Node
).Variables
:= To
;
2235 end Set_First_Variable_Of
;
2237 ------------------------------
2238 -- Set_First_With_Clause_Of --
2239 ------------------------------
2241 procedure Set_First_With_Clause_Of
2242 (Node
: Project_Node_Id
;
2243 In_Tree
: Project_Node_Tree_Ref
;
2244 To
: Project_Node_Id
)
2250 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2251 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2252 end Set_First_With_Clause_Of
;
2254 --------------------------
2255 -- Set_Is_Extending_All --
2256 --------------------------
2258 procedure Set_Is_Extending_All
2259 (Node
: Project_Node_Id
;
2260 In_Tree
: Project_Node_Tree_Ref
)
2266 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2268 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2269 In_Tree
.Project_Nodes
.Table
(Node
).Flag2
:= True;
2270 end Set_Is_Extending_All
;
2272 -----------------------------
2273 -- Set_Is_Not_Last_In_List --
2274 -----------------------------
2276 procedure Set_Is_Not_Last_In_List
2277 (Node
: Project_Node_Id
;
2278 In_Tree
: Project_Node_Tree_Ref
)
2283 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2284 In_Tree
.Project_Nodes
.Table
(Node
).Flag1
:= True;
2285 end Set_Is_Not_Last_In_List
;
2291 procedure Set_Kind_Of
2292 (Node
: Project_Node_Id
;
2293 In_Tree
: Project_Node_Tree_Ref
;
2294 To
: Project_Node_Kind
)
2297 pragma Assert
(Present
(Node
));
2298 In_Tree
.Project_Nodes
.Table
(Node
).Kind
:= To
;
2301 ---------------------
2302 -- Set_Location_Of --
2303 ---------------------
2305 procedure Set_Location_Of
2306 (Node
: Project_Node_Id
;
2307 In_Tree
: Project_Node_Tree_Ref
;
2311 pragma Assert
(Present
(Node
));
2312 In_Tree
.Project_Nodes
.Table
(Node
).Location
:= To
;
2313 end Set_Location_Of
;
2315 -----------------------------
2316 -- Set_Extended_Project_Of --
2317 -----------------------------
2319 procedure Set_Extended_Project_Of
2320 (Node
: Project_Node_Id
;
2321 In_Tree
: Project_Node_Tree_Ref
;
2322 To
: Project_Node_Id
)
2328 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2329 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2330 end Set_Extended_Project_Of
;
2332 ----------------------------------
2333 -- Set_Extended_Project_Path_Of --
2334 ----------------------------------
2336 procedure Set_Extended_Project_Path_Of
2337 (Node
: Project_Node_Id
;
2338 In_Tree
: Project_Node_Tree_Ref
;
2339 To
: Path_Name_Type
)
2345 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2346 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= Name_Id
(To
);
2347 end Set_Extended_Project_Path_Of
;
2349 ------------------------------
2350 -- Set_Extending_Project_Of --
2351 ------------------------------
2353 procedure Set_Extending_Project_Of
2354 (Node
: Project_Node_Id
;
2355 In_Tree
: Project_Node_Tree_Ref
;
2356 To
: Project_Node_Id
)
2362 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project_Declaration
);
2363 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2364 end Set_Extending_Project_Of
;
2370 procedure Set_Name_Of
2371 (Node
: Project_Node_Id
;
2372 In_Tree
: Project_Node_Tree_Ref
;
2376 pragma Assert
(Present
(Node
));
2377 In_Tree
.Project_Nodes
.Table
(Node
).Name
:= To
;
2380 -------------------------------
2381 -- Set_Next_Declarative_Item --
2382 -------------------------------
2384 procedure Set_Next_Declarative_Item
2385 (Node
: Project_Node_Id
;
2386 In_Tree
: Project_Node_Tree_Ref
;
2387 To
: Project_Node_Id
)
2393 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Declarative_Item
);
2394 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2395 end Set_Next_Declarative_Item
;
2397 -----------------------
2398 -- Set_Next_End_Node --
2399 -----------------------
2401 procedure Set_Next_End_Node
(To
: Project_Node_Id
) is
2403 Next_End_Nodes
.Increment_Last
;
2404 Next_End_Nodes
.Table
(Next_End_Nodes
.Last
) := To
;
2405 end Set_Next_End_Node
;
2407 ---------------------------------
2408 -- Set_Next_Expression_In_List --
2409 ---------------------------------
2411 procedure Set_Next_Expression_In_List
2412 (Node
: Project_Node_Id
;
2413 In_Tree
: Project_Node_Tree_Ref
;
2414 To
: Project_Node_Id
)
2420 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Expression
);
2421 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2422 end Set_Next_Expression_In_List
;
2424 -----------------------------
2425 -- Set_Next_Literal_String --
2426 -----------------------------
2428 procedure Set_Next_Literal_String
2429 (Node
: Project_Node_Id
;
2430 In_Tree
: Project_Node_Tree_Ref
;
2431 To
: Project_Node_Id
)
2437 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
);
2438 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2439 end Set_Next_Literal_String
;
2441 ---------------------------------
2442 -- Set_Next_Package_In_Project --
2443 ---------------------------------
2445 procedure Set_Next_Package_In_Project
2446 (Node
: Project_Node_Id
;
2447 In_Tree
: Project_Node_Tree_Ref
;
2448 To
: Project_Node_Id
)
2454 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2455 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2456 end Set_Next_Package_In_Project
;
2458 --------------------------
2459 -- Set_Next_String_Type --
2460 --------------------------
2462 procedure Set_Next_String_Type
2463 (Node
: Project_Node_Id
;
2464 In_Tree
: Project_Node_Tree_Ref
;
2465 To
: Project_Node_Id
)
2471 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2472 N_String_Type_Declaration
);
2473 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2474 end Set_Next_String_Type
;
2480 procedure Set_Next_Term
2481 (Node
: Project_Node_Id
;
2482 In_Tree
: Project_Node_Tree_Ref
;
2483 To
: Project_Node_Id
)
2489 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Term
);
2490 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2493 -----------------------
2494 -- Set_Next_Variable --
2495 -----------------------
2497 procedure Set_Next_Variable
2498 (Node
: Project_Node_Id
;
2499 In_Tree
: Project_Node_Tree_Ref
;
2500 To
: Project_Node_Id
)
2506 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2507 N_Typed_Variable_Declaration
2509 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2510 N_Variable_Declaration
));
2511 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2512 end Set_Next_Variable
;
2514 -----------------------------
2515 -- Set_Next_With_Clause_Of --
2516 -----------------------------
2518 procedure Set_Next_With_Clause_Of
2519 (Node
: Project_Node_Id
;
2520 In_Tree
: Project_Node_Tree_Ref
;
2521 To
: Project_Node_Id
)
2527 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
);
2528 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2529 end Set_Next_With_Clause_Of
;
2531 -----------------------
2532 -- Set_Package_Id_Of --
2533 -----------------------
2535 procedure Set_Package_Id_Of
2536 (Node
: Project_Node_Id
;
2537 In_Tree
: Project_Node_Tree_Ref
;
2538 To
: Package_Node_Id
)
2544 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2545 In_Tree
.Project_Nodes
.Table
(Node
).Pkg_Id
:= To
;
2546 end Set_Package_Id_Of
;
2548 -------------------------
2549 -- Set_Package_Node_Of --
2550 -------------------------
2552 procedure Set_Package_Node_Of
2553 (Node
: Project_Node_Id
;
2554 In_Tree
: Project_Node_Tree_Ref
;
2555 To
: Project_Node_Id
)
2561 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2563 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2564 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2565 end Set_Package_Node_Of
;
2567 ----------------------
2568 -- Set_Path_Name_Of --
2569 ----------------------
2571 procedure Set_Path_Name_Of
2572 (Node
: Project_Node_Id
;
2573 In_Tree
: Project_Node_Tree_Ref
;
2574 To
: Path_Name_Type
)
2580 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
2582 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
));
2583 In_Tree
.Project_Nodes
.Table
(Node
).Path_Name
:= To
;
2584 end Set_Path_Name_Of
;
2586 ---------------------------
2587 -- Set_Previous_End_Node --
2588 ---------------------------
2589 procedure Set_Previous_End_Node
(To
: Project_Node_Id
) is
2591 Previous_End_Node
:= To
;
2592 end Set_Previous_End_Node
;
2594 ----------------------------
2595 -- Set_Previous_Line_Node --
2596 ----------------------------
2598 procedure Set_Previous_Line_Node
(To
: Project_Node_Id
) is
2600 Previous_Line_Node
:= To
;
2601 end Set_Previous_Line_Node
;
2603 --------------------------------
2604 -- Set_Project_Declaration_Of --
2605 --------------------------------
2607 procedure Set_Project_Declaration_Of
2608 (Node
: Project_Node_Id
;
2609 In_Tree
: Project_Node_Tree_Ref
;
2610 To
: Project_Node_Id
)
2616 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2617 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2618 end Set_Project_Declaration_Of
;
2620 ------------------------------
2621 -- Set_Project_Qualifier_Of --
2622 ------------------------------
2624 procedure Set_Project_Qualifier_Of
2625 (Node
: Project_Node_Id
;
2626 In_Tree
: Project_Node_Tree_Ref
;
2627 To
: Project_Qualifier
)
2632 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2633 In_Tree
.Project_Nodes
.Table
(Node
).Qualifier
:= To
;
2634 end Set_Project_Qualifier_Of
;
2636 ---------------------------
2637 -- Set_Parent_Project_Of --
2638 ---------------------------
2640 procedure Set_Parent_Project_Of
2641 (Node
: Project_Node_Id
;
2642 In_Tree
: Project_Node_Tree_Ref
;
2643 To
: Project_Node_Id
)
2648 and then In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Project
);
2649 In_Tree
.Project_Nodes
.Table
(Node
).Field4
:= To
;
2650 end Set_Parent_Project_Of
;
2652 -----------------------------------------------
2653 -- Set_Project_File_Includes_Unkept_Comments --
2654 -----------------------------------------------
2656 procedure Set_Project_File_Includes_Unkept_Comments
2657 (Node
: Project_Node_Id
;
2658 In_Tree
: Project_Node_Tree_Ref
;
2661 Declaration
: constant Project_Node_Id
:=
2662 Project_Declaration_Of
(Node
, In_Tree
);
2664 In_Tree
.Project_Nodes
.Table
(Declaration
).Flag1
:= To
;
2665 end Set_Project_File_Includes_Unkept_Comments
;
2667 -------------------------
2668 -- Set_Project_Node_Of --
2669 -------------------------
2671 procedure Set_Project_Node_Of
2672 (Node
: Project_Node_Id
;
2673 In_Tree
: Project_Node_Tree_Ref
;
2674 To
: Project_Node_Id
;
2675 Limited_With
: Boolean := False)
2681 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2683 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
2685 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Attribute_Reference
));
2686 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2688 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2689 and then not Limited_With
2691 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2693 end Set_Project_Node_Of
;
2695 ---------------------------------------
2696 -- Set_Project_Of_Renamed_Package_Of --
2697 ---------------------------------------
2699 procedure Set_Project_Of_Renamed_Package_Of
2700 (Node
: Project_Node_Id
;
2701 In_Tree
: Project_Node_Tree_Ref
;
2702 To
: Project_Node_Id
)
2708 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Package_Declaration
);
2709 In_Tree
.Project_Nodes
.Table
(Node
).Field1
:= To
;
2710 end Set_Project_Of_Renamed_Package_Of
;
2712 -------------------------
2713 -- Set_Source_Index_Of --
2714 -------------------------
2716 procedure Set_Source_Index_Of
2717 (Node
: Project_Node_Id
;
2718 In_Tree
: Project_Node_Tree_Ref
;
2725 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2727 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2728 N_Attribute_Declaration
));
2729 In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
:= To
;
2730 end Set_Source_Index_Of
;
2732 ------------------------
2733 -- Set_String_Type_Of --
2734 ------------------------
2736 procedure Set_String_Type_Of
2737 (Node
: Project_Node_Id
;
2738 In_Tree
: Project_Node_Tree_Ref
;
2739 To
: Project_Node_Id
)
2745 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2746 N_Variable_Reference
2748 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2749 N_Typed_Variable_Declaration
)
2751 In_Tree
.Project_Nodes
.Table
(To
).Kind
= N_String_Type_Declaration
);
2753 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2754 In_Tree
.Project_Nodes
.Table
(Node
).Field3
:= To
;
2756 In_Tree
.Project_Nodes
.Table
(Node
).Field2
:= To
;
2758 end Set_String_Type_Of
;
2760 -------------------------
2761 -- Set_String_Value_Of --
2762 -------------------------
2764 procedure Set_String_Value_Of
2765 (Node
: Project_Node_Id
;
2766 In_Tree
: Project_Node_Tree_Ref
;
2773 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2775 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2777 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2778 In_Tree
.Project_Nodes
.Table
(Node
).Value
:= To
;
2779 end Set_String_Value_Of
;
2781 ---------------------
2782 -- Source_Index_Of --
2783 ---------------------
2785 function Source_Index_Of
2786 (Node
: Project_Node_Id
;
2787 In_Tree
: Project_Node_Tree_Ref
) return Int
2793 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
2795 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2796 N_Attribute_Declaration
));
2797 return In_Tree
.Project_Nodes
.Table
(Node
).Src_Index
;
2798 end Source_Index_Of
;
2800 --------------------
2801 -- String_Type_Of --
2802 --------------------
2804 function String_Type_Of
2805 (Node
: Project_Node_Id
;
2806 In_Tree
: Project_Node_Tree_Ref
) return Project_Node_Id
2812 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2813 N_Variable_Reference
2815 In_Tree
.Project_Nodes
.Table
(Node
).Kind
=
2816 N_Typed_Variable_Declaration
));
2818 if In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Variable_Reference
then
2819 return In_Tree
.Project_Nodes
.Table
(Node
).Field3
;
2821 return In_Tree
.Project_Nodes
.Table
(Node
).Field2
;
2825 ---------------------
2826 -- String_Value_Of --
2827 ---------------------
2829 function String_Value_Of
2830 (Node
: Project_Node_Id
;
2831 In_Tree
: Project_Node_Tree_Ref
) return Name_Id
2837 (In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_With_Clause
2839 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Comment
2841 In_Tree
.Project_Nodes
.Table
(Node
).Kind
= N_Literal_String
));
2842 return In_Tree
.Project_Nodes
.Table
(Node
).Value
;
2843 end String_Value_Of
;
2845 --------------------
2846 -- Value_Is_Valid --
2847 --------------------
2849 function Value_Is_Valid
2850 (For_Typed_Variable
: Project_Node_Id
;
2851 In_Tree
: Project_Node_Tree_Ref
;
2852 Value
: Name_Id
) return Boolean
2856 (Present
(For_Typed_Variable
)
2858 (In_Tree
.Project_Nodes
.Table
(For_Typed_Variable
).Kind
=
2859 N_Typed_Variable_Declaration
));
2862 Current_String
: Project_Node_Id
:=
2863 First_Literal_String
2864 (String_Type_Of
(For_Typed_Variable
, In_Tree
),
2868 while Present
(Current_String
)
2870 String_Value_Of
(Current_String
, In_Tree
) /= Value
2873 Next_Literal_String
(Current_String
, In_Tree
);
2876 return Present
(Current_String
);
2881 -------------------------------
2882 -- There_Are_Unkept_Comments --
2883 -------------------------------
2885 function There_Are_Unkept_Comments
return Boolean is
2887 return Unkept_Comments
;
2888 end There_Are_Unkept_Comments
;
2890 --------------------
2891 -- Create_Project --
2892 --------------------
2894 function Create_Project
2895 (In_Tree
: Project_Node_Tree_Ref
;
2897 Full_Path
: Path_Name_Type
;
2898 Is_Config_File
: Boolean := False) return Project_Node_Id
2900 Project
: Project_Node_Id
;
2901 Qualifier
: Project_Qualifier
:= Unspecified
;
2903 Project
:= Default_Project_Node
(In_Tree
, N_Project
);
2904 Set_Name_Of
(Project
, In_Tree
, Name
);
2907 Path_Name_Type
(Get_Directory
(File_Name_Type
(Full_Path
))));
2908 Set_Path_Name_Of
(Project
, In_Tree
, Full_Path
);
2910 Set_Project_Declaration_Of
2912 Default_Project_Node
(In_Tree
, N_Project_Declaration
));
2914 if Is_Config_File
then
2915 Qualifier
:= Configuration
;
2918 if not Is_Config_File
then
2919 Prj
.Tree
.Tree_Private_Part
.Projects_Htable
.Set
2920 (In_Tree
.Projects_HT
,
2922 Prj
.Tree
.Tree_Private_Part
.Project_Name_And_Node
'
2924 Display_Name => Name,
2925 Canonical_Path => No_Path,
2928 Proj_Qualifier => Qualifier));
2938 procedure Add_At_End
2939 (Tree : Project_Node_Tree_Ref;
2940 Parent : Project_Node_Id;
2941 Expr : Project_Node_Id;
2942 Add_Before_First_Pkg : Boolean := False;
2943 Add_Before_First_Case : Boolean := False)
2945 Real_Parent : Project_Node_Id;
2946 New_Decl, Decl, Next : Project_Node_Id;
2947 Last, L : Project_Node_Id;
2950 if Kind_Of (Expr, Tree) /= N_Declarative_Item then
2951 New_Decl := Default_Project_Node (Tree, N_Declarative_Item);
2952 Set_Current_Item_Node (New_Decl, Tree, Expr);
2957 if Kind_Of (Parent, Tree) = N_Project then
2958 Real_Parent := Project_Declaration_Of (Parent, Tree);
2960 Real_Parent := Parent;
2963 Decl := First_Declarative_Item_Of (Real_Parent, Tree);
2965 if Decl = Empty_Node then
2966 Set_First_Declarative_Item_Of (Real_Parent, Tree, New_Decl);
2969 Next := Next_Declarative_Item (Decl, Tree);
2970 exit when Next = Empty_Node
2972 (Add_Before_First_Pkg
2973 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
2974 N_Package_Declaration)
2976 (Add_Before_First_Case
2977 and then Kind_Of (Current_Item_Node (Next, Tree), Tree) =
2978 N_Case_Construction);
2982 -- In case Expr is in fact a range of declarative items
2986 L := Next_Declarative_Item (Last, Tree);
2987 exit when L = Empty_Node;
2991 -- In case Expr is in fact a range of declarative items
2995 L := Next_Declarative_Item (Last, Tree);
2996 exit when L = Empty_Node;
3000 Set_Next_Declarative_Item (Last, Tree, Next);
3001 Set_Next_Declarative_Item (Decl, Tree, New_Decl);
3005 ---------------------------
3006 -- Create_Literal_String --
3007 ---------------------------
3009 function Create_Literal_String
3010 (Str : Namet.Name_Id;
3011 Tree : Project_Node_Tree_Ref) return Project_Node_Id
3013 Node : Project_Node_Id;
3015 Node := Default_Project_Node (Tree, N_Literal_String, Prj.Single);
3016 Set_Next_Literal_String (Node, Tree, Empty_Node);
3017 Set_String_Value_Of (Node, Tree, Str);
3019 end Create_Literal_String;
3021 ---------------------------
3022 -- Enclose_In_Expression --
3023 ---------------------------
3025 function Enclose_In_Expression
3026 (Node : Project_Node_Id;
3027 Tree : Project_Node_Tree_Ref) return Project_Node_Id
3029 Expr : Project_Node_Id;
3031 if Kind_Of (Node, Tree) /= N_Expression then
3032 Expr := Default_Project_Node (Tree, N_Expression, Single);
3034 (Expr, Tree, Default_Project_Node (Tree, N_Term, Single));
3035 Set_Current_Term (First_Term (Expr, Tree), Tree, Node);
3040 end Enclose_In_Expression;
3042 --------------------
3043 -- Create_Package --
3044 --------------------
3046 function Create_Package
3047 (Tree : Project_Node_Tree_Ref;
3048 Project : Project_Node_Id;
3049 Pkg : String) return Project_Node_Id
3051 Pack : Project_Node_Id;
3055 Name_Len := Pkg'Length;
3056 Name_Buffer (1 .. Name_Len) := Pkg;
3059 -- Check if the package already exists
3061 Pack := First_Package_Of (Project, Tree);
3062 while Pack /= Empty_Node loop
3063 if Prj.Tree.Name_Of (Pack, Tree) = N then
3067 Pack := Next_Package_In_Project (Pack, Tree);
3070 -- Create the package and add it to the declarative item
3072 Pack := Default_Project_Node (Tree, N_Package_Declaration);
3073 Set_Name_Of (Pack, Tree, N);
3075 -- Find the correct package id to use
3077 Set_Package_Id_Of (Pack, Tree, Package_Node_Id_Of (N));
3079 -- Add it to the list of packages
3081 Set_Next_Package_In_Project
3082 (Pack, Tree, First_Package_Of (Project, Tree));
3083 Set_First_Package_Of (Project, Tree, Pack);
3085 Add_At_End (Tree, Project_Declaration_Of (Project, Tree), Pack);
3090 ----------------------
3091 -- Create_Attribute --
3092 ----------------------
3094 function Create_Attribute
3095 (Tree : Project_Node_Tree_Ref;
3096 Prj_Or_Pkg : Project_Node_Id;
3098 Index_Name : Name_Id := No_Name;
3099 Kind : Variable_Kind := List;
3100 At_Index : Integer := 0;
3101 Value : Project_Node_Id := Empty_Node) return Project_Node_Id
3103 Node : constant Project_Node_Id :=
3104 Default_Project_Node (Tree, N_Attribute_Declaration, Kind);
3106 Case_Insensitive : Boolean;
3108 Pkg : Package_Node_Id;
3109 Start_At : Attribute_Node_Id;
3110 Expr : Project_Node_Id;
3113 Set_Name_Of (Node, Tree, Name);
3115 if Index_Name /= No_Name then
3116 Set_Associative_Array_Index_Of (Node, Tree, Index_Name);
3119 if Prj_Or_Pkg /= Empty_Node then
3120 Add_At_End (Tree, Prj_Or_Pkg, Node);
3123 -- Find out the case sensitivity of the attribute
3125 if Prj_Or_Pkg /= Empty_Node
3126 and then Kind_Of (Prj_Or_Pkg, Tree) = N_Package_Declaration
3128 Pkg := Prj.Attr.Package_Node_Id_Of (Name_Of (Prj_Or_Pkg, Tree));
3129 Start_At := First_Attribute_Of (Pkg);
3131 Start_At := Attribute_First;
3134 Start_At := Attribute_Node_Id_Of (Name, Start_At);
3136 Attribute_Kind_Of (Start_At) = Case_Insensitive_Associative_Array;
3137 Tree.Project_Nodes.Table (Node).Flag1 := Case_Insensitive;
3139 if At_Index /= 0 then
3140 if Attribute_Kind_Of (Start_At) =
3141 Optional_Index_Associative_Array
3142 or else Attribute_Kind_Of (Start_At) =
3143 Optional_Index_Case_Insensitive_Associative_Array
3145 -- Results in: for Name ("index" at index) use "value";
3146 -- This is currently only used for executables.
3148 Set_Source_Index_Of (Node, Tree, To => Int (At_Index));
3151 -- Results in: for Name ("index") use "value" at index;
3153 -- ??? This limitation makes no sense, we should be able to
3154 -- set the source index on an expression.
3156 pragma Assert (Kind_Of (Value, Tree) = N_Literal_String);
3157 Set_Source_Index_Of (Value, Tree, To => Int (At_Index));
3161 if Value /= Empty_Node then
3162 Expr := Enclose_In_Expression (Value, Tree);
3163 Set_Expression_Of (Node, Tree, Expr);
3167 end Create_Attribute;