1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2014, Free Software Foundation, Inc. --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Atree; use Atree;
27 with Err_Vars; use Err_Vars;
29 with Osint; use Osint;
30 with Output; use Output;
31 with Prj.Attr; use Prj.Attr;
33 with Prj.Err; use Prj.Err;
34 with Prj.Ext; use Prj.Ext;
35 with Prj.Nmsc; use Prj.Nmsc;
40 with Ada.Containers.Vectors;
41 with Ada.Strings.Fixed; use Ada.Strings.Fixed;
43 with GNAT.Case_Util; use GNAT.Case_Util;
46 package body Prj.Proc is
48 package Processed_Projects is new GNAT.HTable.Simple_HTable
49 (Header_Num => Header_Num,
50 Element => Project_Id,
51 No_Element => No_Project,
55 -- This hash table contains all processed projects
57 package Unit_Htable is new GNAT.HTable.Simple_HTable
58 (Header_Num => Header_Num,
60 No_Element => No_Source,
64 -- This hash table contains all processed projects
66 package Runtime_Defaults is new GNAT.HTable.Simple_HTable
67 (Header_Num => Prj.Header_Num,
69 No_Element => No_Name,
73 -- Stores the default values of 'Runtime names for the various languages
75 procedure Add (To_Exp : in out Name_Id; Str : Name_Id);
76 -- Concatenate two strings and returns another string if both
77 -- arguments are not null string.
79 -- In the following procedures, we are expected to guess the meaning of
80 -- the parameters from their names, this is never a good idea, comments
81 -- should be added precisely defining every formal ???
83 procedure Add_Attributes
84 (Project : Project_Id;
85 Project_Name : Name_Id;
86 Project_Dir : Name_Id;
87 Shared : Shared_Project_Tree_Data_Access;
88 Decl : in out Declarations;
89 First : Attribute_Node_Id;
90 Project_Level : Boolean);
91 -- Add all attributes, starting with First, with their default values to
92 -- the package or project with declarations Decl.
95 (In_Tree : Project_Tree_Ref;
97 Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
98 Flags : Processing_Flags);
99 -- Set all projects to not checked, then call Recursive_Check for the
100 -- main project Project. Project is set to No_Project if errors occurred.
101 -- Current_Dir is for optimization purposes, avoiding extra system calls.
102 -- If Allow_Duplicate_Basenames, then files with the same base names are
103 -- authorized within a project for source-based languages (never for unit
106 procedure Copy_Package_Declarations
107 (From : Declarations;
108 To : in out Declarations;
109 New_Loc : Source_Ptr;
110 Restricted : Boolean;
111 Shared : Shared_Project_Tree_Data_Access);
112 -- Copy a package declaration From to To for a renamed package. Change the
113 -- locations of all the attributes to New_Loc. When Restricted is
114 -- True, do not copy attributes Body, Spec, Implementation, Specification
115 -- and Linker_Options.
118 (Project : Project_Id;
119 Shared : Shared_Project_Tree_Data_Access;
120 From_Project_Node : Project_Node_Id;
121 From_Project_Node_Tree : Project_Node_Tree_Ref;
122 Env : Prj.Tree.Environment;
124 First_Term : Project_Node_Id;
125 Kind : Variable_Kind) return Variable_Value;
126 -- From N_Expression project node From_Project_Node, compute the value
127 -- of an expression and return it as a Variable_Value.
129 function Imported_Or_Extended_Project_From
130 (Project : Project_Id;
132 No_Extending : Boolean := False) return Project_Id;
133 -- Find an imported or extended project of Project whose name is With_Name.
134 -- When No_Extending is True, do not look for extending projects, returns
135 -- the exact project whose name is With_Name.
137 function Package_From
138 (Project : Project_Id;
139 Shared : Shared_Project_Tree_Data_Access;
140 With_Name : Name_Id) return Package_Id;
141 -- Find the package of Project whose name is With_Name
143 procedure Process_Declarative_Items
144 (Project : Project_Id;
145 In_Tree : Project_Tree_Ref;
146 From_Project_Node : Project_Node_Id;
147 Node_Tree : Project_Node_Tree_Ref;
148 Env : Prj.Tree.Environment;
150 Item : Project_Node_Id;
151 Child_Env : in out Prj.Tree.Environment);
152 -- Process declarative items starting with From_Project_Node, and put them
153 -- in declarations Decl. This is a recursive procedure; it calls itself for
154 -- a package declaration or a case construction.
156 -- Child_Env is the modified environment after seeing declarations like
157 -- "for External(...) use" or "for Project_Path use" in aggregate projects.
158 -- It should have been initialized first.
160 procedure Recursive_Process
161 (In_Tree : Project_Tree_Ref;
162 Project : out Project_Id;
163 Packages_To_Check : String_List_Access;
164 From_Project_Node : Project_Node_Id;
165 From_Project_Node_Tree : Project_Node_Tree_Ref;
166 Env : in out Prj.Tree.Environment;
167 Extended_By : Project_Id;
168 From_Encapsulated_Lib : Boolean;
169 On_New_Tree_Loaded : Tree_Loaded_Callback := null);
170 -- Process project with node From_Project_Node in the tree. Do nothing if
171 -- From_Project_Node is Empty_Node. If project has already been processed,
172 -- simply return its project id. Otherwise create a new project id, mark it
173 -- as processed, call itself recursively for all imported projects and a
174 -- extended project, if any. Then process the declarative items of the
177 -- Is_Root_Project should be true only for the project that the user
178 -- explicitly loaded. In the context of aggregate projects, only that
179 -- project is allowed to modify the environment that will be used to load
180 -- projects (Child_Env).
182 -- From_Encapsulated_Lib is true if we are parsing a project from
183 -- encapsulated library dependencies.
185 -- If specified, On_New_Tree_Loaded is called after each aggregated project
186 -- has been processed succesfully.
188 function Get_Attribute_Index
189 (Tree : Project_Node_Tree_Ref;
190 Attr : Project_Node_Id;
191 Index : Name_Id) return Name_Id;
192 -- Copy the index of the attribute into Name_Buffer, converting to lower
193 -- case if the attribute is case-insensitive.
199 procedure Add (To_Exp : in out Name_Id; Str : Name_Id) is
201 if To_Exp = No_Name or else To_Exp = Empty_String then
203 -- To_Exp is nil or empty. The result is Str
207 -- If Str is nil, then do not change To_Ext
209 elsif Str /= No_Name and then Str /= Empty_String then
211 S : constant String := Get_Name_String (Str);
213 Get_Name_String (To_Exp);
214 Add_Str_To_Name_Buffer (S);
224 procedure Add_Attributes
225 (Project : Project_Id;
226 Project_Name : Name_Id;
227 Project_Dir : Name_Id;
228 Shared : Shared_Project_Tree_Data_Access;
229 Decl : in out Declarations;
230 First : Attribute_Node_Id;
231 Project_Level : Boolean)
233 The_Attribute : Attribute_Node_Id := First;
236 while The_Attribute /= Empty_Attribute loop
237 if Attribute_Kind_Of (The_Attribute) = Single then
239 New_Attribute : Variable_Value;
242 case Variable_Kind_Of (The_Attribute) is
244 -- Undefined should not happen
248 (False, "attribute with an undefined kind");
251 -- Single attributes have a default value of empty string
257 Location => No_Location,
259 Value => Empty_String,
262 -- Special cases of <project>'Name and
263 -- <project>'Project_Dir.
265 if Project_Level then
266 if Attribute_Name_Of (The_Attribute) =
269 New_Attribute.Value := Project_Name;
271 elsif Attribute_Name_Of (The_Attribute) =
272 Snames.Name_Project_Dir
274 New_Attribute.Value := Project_Dir;
278 -- List attributes have a default value of nil list
284 Location => No_Location,
286 Values => Nil_String);
290 Variable_Element_Table.Increment_Last
291 (Shared.Variable_Elements);
292 Shared.Variable_Elements.Table
293 (Variable_Element_Table.Last (Shared.Variable_Elements)) :=
294 (Next => Decl.Attributes,
295 Name => Attribute_Name_Of (The_Attribute),
296 Value => New_Attribute);
298 Variable_Element_Table.Last
299 (Shared.Variable_Elements);
303 The_Attribute := Next_Attribute (After => The_Attribute);
312 (In_Tree : Project_Tree_Ref;
313 Project : Project_Id;
314 Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
315 Flags : Processing_Flags)
318 Process_Naming_Scheme (In_Tree, Project, Node_Tree, Flags);
320 -- Set the Other_Part field for the units
326 Iter : Source_Iterator;
331 Iter := For_Each_Source (In_Tree);
333 Source1 := Prj.Element (Iter);
334 exit when Source1 = No_Source;
336 if Source1.Unit /= No_Unit_Index then
337 Name := Source1.Unit.Name;
338 Source2 := Unit_Htable.Get (Name);
340 if Source2 = No_Source then
341 Unit_Htable.Set (K => Name, E => Source1);
343 Unit_Htable.Remove (Name);
352 -------------------------------
353 -- Copy_Package_Declarations --
354 -------------------------------
356 procedure Copy_Package_Declarations
357 (From : Declarations;
358 To : in out Declarations;
359 New_Loc : Source_Ptr;
360 Restricted : Boolean;
361 Shared : Shared_Project_Tree_Data_Access)
364 V2 : Variable_Id := No_Variable;
367 A2 : Array_Id := No_Array;
369 E1 : Array_Element_Id;
370 E2 : Array_Element_Id := No_Array_Element;
374 -- To avoid references in error messages to attribute declarations in
375 -- an original package that has been renamed, copy all the attribute
376 -- declarations of the package and change all locations to New_Loc,
377 -- the location of the renamed package.
379 -- First single attributes
381 V1 := From.Attributes;
382 while V1 /= No_Variable loop
384 -- Copy the attribute
386 Var := Shared.Variable_Elements.Table (V1);
389 -- Do not copy the value of attribute Linker_Options if Restricted
391 if Restricted and then Var.Name = Snames.Name_Linker_Options then
392 Var.Value.Values := Nil_String;
395 -- Remove the Next component
397 Var.Next := No_Variable;
399 -- Change the location to New_Loc
401 Var.Value.Location := New_Loc;
402 Variable_Element_Table.Increment_Last (Shared.Variable_Elements);
404 -- Put in new declaration
406 if To.Attributes = No_Variable then
408 Variable_Element_Table.Last (Shared.Variable_Elements);
410 Shared.Variable_Elements.Table (V2).Next :=
411 Variable_Element_Table.Last (Shared.Variable_Elements);
414 V2 := Variable_Element_Table.Last (Shared.Variable_Elements);
415 Shared.Variable_Elements.Table (V2) := Var;
418 -- Then the associated array attributes
421 while A1 /= No_Array loop
422 Arr := Shared.Arrays.Table (A1);
425 -- Remove the Next component
427 Arr.Next := No_Array;
428 Array_Table.Increment_Last (Shared.Arrays);
430 -- Create new Array declaration
432 if To.Arrays = No_Array then
433 To.Arrays := Array_Table.Last (Shared.Arrays);
435 Shared.Arrays.Table (A2).Next :=
436 Array_Table.Last (Shared.Arrays);
439 A2 := Array_Table.Last (Shared.Arrays);
441 -- Don't store the array as its first element has not been set yet
443 -- Copy the array elements of the array
446 Arr.Value := No_Array_Element;
447 while E1 /= No_Array_Element loop
449 -- Copy the array element
451 Elm := Shared.Array_Elements.Table (E1);
454 -- Remove the Next component
456 Elm.Next := No_Array_Element;
458 Elm.Restricted := Restricted;
460 -- Change the location
462 Elm.Value.Location := New_Loc;
463 Array_Element_Table.Increment_Last (Shared.Array_Elements);
465 -- Create new array element
467 if Arr.Value = No_Array_Element then
468 Arr.Value := Array_Element_Table.Last (Shared.Array_Elements);
470 Shared.Array_Elements.Table (E2).Next :=
471 Array_Element_Table.Last (Shared.Array_Elements);
474 E2 := Array_Element_Table.Last (Shared.Array_Elements);
475 Shared.Array_Elements.Table (E2) := Elm;
478 -- Finally, store the new array
480 Shared.Arrays.Table (A2) := Arr;
482 end Copy_Package_Declarations;
484 -------------------------
485 -- Get_Attribute_Index --
486 -------------------------
488 function Get_Attribute_Index
489 (Tree : Project_Node_Tree_Ref;
490 Attr : Project_Node_Id;
491 Index : Name_Id) return Name_Id
494 if Index = All_Other_Names
495 or else not Case_Insensitive (Attr, Tree)
500 Get_Name_String (Index);
501 To_Lower (Name_Buffer (1 .. Name_Len));
503 end Get_Attribute_Index;
510 (Project : Project_Id;
511 Shared : Shared_Project_Tree_Data_Access;
512 From_Project_Node : Project_Node_Id;
513 From_Project_Node_Tree : Project_Node_Tree_Ref;
514 Env : Prj.Tree.Environment;
516 First_Term : Project_Node_Id;
517 Kind : Variable_Kind) return Variable_Value
519 The_Term : Project_Node_Id;
520 -- The term in the expression list
522 The_Current_Term : Project_Node_Id := Empty_Node;
523 -- The current term node id
525 Result : Variable_Value (Kind => Kind);
526 -- The returned result
528 Last : String_List_Id := Nil_String;
529 -- Reference to the last string elements in Result, when Kind is List
531 Current_Term_Kind : Project_Node_Kind;
534 Result.Project := Project;
535 Result.Location := Location_Of (First_Term, From_Project_Node_Tree);
537 -- Process each term of the expression, starting with First_Term
539 The_Term := First_Term;
540 while Present (The_Term) loop
541 The_Current_Term := Current_Term (The_Term, From_Project_Node_Tree);
543 Kind_Of (The_Current_Term, From_Project_Node_Tree);
545 case Current_Term_Kind is
547 when N_Literal_String =>
553 -- Should never happen
555 pragma Assert (False, "Undefined expression kind");
561 (The_Current_Term, From_Project_Node_Tree));
564 (The_Current_Term, From_Project_Node_Tree);
568 String_Element_Table.Increment_Last
569 (Shared.String_Elements);
571 if Last = Nil_String then
573 -- This can happen in an expression like () & "toto"
575 Result.Values := String_Element_Table.Last
576 (Shared.String_Elements);
579 Shared.String_Elements.Table
580 (Last).Next := String_Element_Table.Last
581 (Shared.String_Elements);
584 Last := String_Element_Table.Last
585 (Shared.String_Elements);
587 Shared.String_Elements.Table (Last) :=
588 (Value => String_Value_Of
590 From_Project_Node_Tree),
591 Index => Source_Index_Of
593 From_Project_Node_Tree),
594 Display_Value => No_Name,
595 Location => Location_Of
597 From_Project_Node_Tree),
602 when N_Literal_String_List =>
605 String_Node : Project_Node_Id :=
606 First_Expression_In_List
608 From_Project_Node_Tree);
610 Value : Variable_Value;
613 if Present (String_Node) then
615 -- If String_Node is nil, it is an empty list, there is
621 From_Project_Node => From_Project_Node,
622 From_Project_Node_Tree => From_Project_Node_Tree,
627 (String_Node, From_Project_Node_Tree),
629 String_Element_Table.Increment_Last
630 (Shared.String_Elements);
632 if Result.Values = Nil_String then
634 -- This literal string list is the first term in a
635 -- string list expression
638 String_Element_Table.Last
639 (Shared.String_Elements);
642 Shared.String_Elements.Table (Last).Next :=
643 String_Element_Table.Last (Shared.String_Elements);
647 String_Element_Table.Last (Shared.String_Elements);
649 Shared.String_Elements.Table (Last) :=
650 (Value => Value.Value,
651 Display_Value => No_Name,
652 Location => Value.Location,
655 Index => Value.Index);
658 -- Add the other element of the literal string list
659 -- one after the other.
662 Next_Expression_In_List
663 (String_Node, From_Project_Node_Tree);
665 exit when No (String_Node);
671 From_Project_Node => From_Project_Node,
672 From_Project_Node_Tree => From_Project_Node_Tree,
677 (String_Node, From_Project_Node_Tree),
680 String_Element_Table.Increment_Last
681 (Shared.String_Elements);
682 Shared.String_Elements.Table (Last).Next :=
683 String_Element_Table.Last (Shared.String_Elements);
684 Last := String_Element_Table.Last
685 (Shared.String_Elements);
686 Shared.String_Elements.Table (Last) :=
687 (Value => Value.Value,
688 Display_Value => No_Name,
689 Location => Value.Location,
692 Index => Value.Index);
697 when N_Variable_Reference | N_Attribute_Reference =>
700 The_Project : Project_Id := Project;
701 The_Package : Package_Id := Pkg;
702 The_Name : Name_Id := No_Name;
703 The_Variable_Id : Variable_Id := No_Variable;
704 The_Variable : Variable_Value;
705 Term_Project : constant Project_Node_Id :=
708 From_Project_Node_Tree);
709 Term_Package : constant Project_Node_Id :=
712 From_Project_Node_Tree);
713 Index : Name_Id := No_Name;
716 <<Object_Dir_Restart>>
717 The_Project := Project;
720 The_Variable_Id := No_Variable;
723 if Present (Term_Project)
724 and then Term_Project /= From_Project_Node
726 -- This variable or attribute comes from another project
729 Name_Of (Term_Project, From_Project_Node_Tree);
730 The_Project := Imported_Or_Extended_Project_From
732 With_Name => The_Name,
733 No_Extending => True);
736 if Present (Term_Package) then
738 -- This is an attribute of a package
741 Name_Of (Term_Package, From_Project_Node_Tree);
743 The_Package := The_Project.Decl.Packages;
744 while The_Package /= No_Package
745 and then Shared.Packages.Table (The_Package).Name /=
749 Shared.Packages.Table (The_Package).Next;
753 (The_Package /= No_Package, "package not found.");
755 elsif Kind_Of (The_Current_Term, From_Project_Node_Tree) =
756 N_Attribute_Reference
758 The_Package := No_Package;
762 Name_Of (The_Current_Term, From_Project_Node_Tree);
764 if Current_Term_Kind = N_Attribute_Reference then
766 Associative_Array_Index_Of
767 (The_Current_Term, From_Project_Node_Tree);
770 -- If it is not an associative array attribute
772 if Index = No_Name then
774 -- It is not an associative array attribute
776 if The_Package /= No_Package then
778 -- First, if there is a package, look into the package
780 if Current_Term_Kind = N_Variable_Reference then
782 Shared.Packages.Table
783 (The_Package).Decl.Variables;
786 Shared.Packages.Table
787 (The_Package).Decl.Attributes;
790 while The_Variable_Id /= No_Variable
791 and then Shared.Variable_Elements.Table
792 (The_Variable_Id).Name /= The_Name
795 Shared.Variable_Elements.Table
796 (The_Variable_Id).Next;
801 if The_Variable_Id = No_Variable then
803 -- If we have not found it, look into the project
805 if Current_Term_Kind = N_Variable_Reference then
806 The_Variable_Id := The_Project.Decl.Variables;
808 The_Variable_Id := The_Project.Decl.Attributes;
811 while The_Variable_Id /= No_Variable
812 and then Shared.Variable_Elements.Table
813 (The_Variable_Id).Name /= The_Name
816 Shared.Variable_Elements.Table
817 (The_Variable_Id).Next;
822 if From_Project_Node_Tree.Incomplete_With then
823 if The_Variable_Id = No_Variable then
824 The_Variable := Nil_Variable_Value;
827 Shared.Variable_Elements.Table
828 (The_Variable_Id).Value;
832 pragma Assert (The_Variable_Id /= No_Variable,
833 "variable or attribute not found");
836 Shared.Variable_Elements.Table
837 (The_Variable_Id).Value;
842 -- It is an associative array attribute
845 The_Array : Array_Id := No_Array;
846 The_Element : Array_Element_Id := No_Array_Element;
847 Array_Index : Name_Id := No_Name;
850 if The_Package /= No_Package then
852 Shared.Packages.Table (The_Package).Decl.Arrays;
854 The_Array := The_Project.Decl.Arrays;
857 while The_Array /= No_Array
858 and then Shared.Arrays.Table (The_Array).Name /=
861 The_Array := Shared.Arrays.Table (The_Array).Next;
864 if The_Array /= No_Array then
866 Shared.Arrays.Table (The_Array).Value;
869 (From_Project_Node_Tree,
873 while The_Element /= No_Array_Element
874 and then Shared.Array_Elements.Table
875 (The_Element).Index /= Array_Index
878 Shared.Array_Elements.Table (The_Element).Next;
883 if The_Element /= No_Array_Element then
885 Shared.Array_Elements.Table (The_Element).Value;
888 if Expression_Kind_Of
889 (The_Current_Term, From_Project_Node_Tree) =
895 Location => No_Location,
897 Values => Nil_String);
902 Location => No_Location,
904 Value => Empty_String,
911 -- Check the defaults
913 if Current_Term_Kind = N_Attribute_Reference then
915 The_Default : constant Attribute_Default_Value :=
917 (The_Current_Term, From_Project_Node_Tree);
920 -- Check the special value for 'Target when specified
922 if The_Default = Target_Value
923 and then Opt.Target_Origin = Specified
926 Add_Str_To_Name_Buffer (Opt.Target_Value.all);
927 The_Variable.Value := Name_Find;
929 -- Check the defaults
931 elsif The_Variable.Default then
932 case The_Variable.Kind is
939 when Read_Only_Value =>
943 The_Variable.Value := Empty_String;
946 The_Variable.Value := Dot_String;
948 when Object_Dir_Value =>
949 From_Project_Node_Tree.Project_Nodes.Table
950 (The_Current_Term).Name :=
951 Snames.Name_Object_Dir;
952 From_Project_Node_Tree.Project_Nodes.Table
953 (The_Current_Term).Default :=
955 goto Object_Dir_Restart;
958 if Opt.Target_Value = null then
959 The_Variable.Value := Empty_String;
963 Add_Str_To_Name_Buffer
964 (Opt.Target_Value.all);
965 The_Variable.Value := Name_Find;
968 when Runtime_Value =>
969 Get_Name_String (Index);
970 To_Lower (Name_Buffer (1 .. Name_Len));
971 The_Variable.Value :=
972 Runtime_Defaults.Get (Name_Find);
973 if The_Variable.Value = No_Name then
974 The_Variable.Value := Empty_String;
981 when Read_Only_Value =>
985 The_Variable.Values := Nil_String;
988 The_Variable.Values :=
989 Shared.Dot_String_List;
991 when Object_Dir_Value |
1004 -- Should never happen
1006 pragma Assert (False, "undefined expression kind");
1010 case The_Variable.Kind is
1016 Add (Result.Value, The_Variable.Value);
1020 -- Should never happen
1024 "list cannot appear in single " &
1025 "string expression");
1030 case The_Variable.Kind is
1036 String_Element_Table.Increment_Last
1037 (Shared.String_Elements);
1039 if Last = Nil_String then
1041 -- This can happen in an expression such as
1045 String_Element_Table.Last
1046 (Shared.String_Elements);
1049 Shared.String_Elements.Table (Last).Next :=
1050 String_Element_Table.Last
1051 (Shared.String_Elements);
1055 String_Element_Table.Last
1056 (Shared.String_Elements);
1058 Shared.String_Elements.Table (Last) :=
1059 (Value => The_Variable.Value,
1060 Display_Value => No_Name,
1061 Location => Location_Of
1063 From_Project_Node_Tree),
1071 The_List : String_List_Id :=
1072 The_Variable.Values;
1075 while The_List /= Nil_String loop
1076 String_Element_Table.Increment_Last
1077 (Shared.String_Elements);
1079 if Last = Nil_String then
1081 String_Element_Table.Last
1082 (Shared.String_Elements);
1086 String_Elements.Table (Last).Next :=
1087 String_Element_Table.Last
1088 (Shared.String_Elements);
1093 String_Element_Table.Last
1094 (Shared.String_Elements);
1096 Shared.String_Elements.Table
1099 Shared.String_Elements.Table
1101 Display_Value => No_Name,
1105 From_Project_Node_Tree),
1110 The_List := Shared.String_Elements.Table
1118 when N_External_Value =>
1121 (External_Reference_Of
1122 (The_Current_Term, From_Project_Node_Tree),
1123 From_Project_Node_Tree));
1126 Name : constant Name_Id := Name_Find;
1127 Default : Name_Id := No_Name;
1128 Value : Name_Id := No_Name;
1129 Ext_List : Boolean := False;
1130 Str_List : String_List_Access := null;
1131 Def_Var : Variable_Value;
1133 Default_Node : constant Project_Node_Id :=
1136 From_Project_Node_Tree);
1139 -- If there is a default value for the external reference,
1142 if Present (Default_Node) then
1143 Def_Var := Expression
1144 (Project => Project,
1146 From_Project_Node => From_Project_Node,
1147 From_Project_Node_Tree => From_Project_Node_Tree,
1152 (Default_Node, From_Project_Node_Tree),
1155 if Def_Var /= Nil_Variable_Value then
1156 Default := Def_Var.Value;
1160 Ext_List := Expression_Kind_Of
1162 From_Project_Node_Tree) = List;
1165 Value := Prj.Ext.Value_Of (Env.External, Name, No_Name);
1167 if Value /= No_Name then
1169 Sep : constant String :=
1170 Get_Name_String (Default);
1171 First : Positive := 1;
1173 Done : Boolean := False;
1177 Get_Name_String (Value);
1180 or else Sep'Length = 0
1181 or else Name_Buffer (1 .. Name_Len) = Sep
1186 if not Done and then Name_Len < Sep'Length then
1190 (Name_Buffer (1 .. Name_Len)));
1195 if Name_Buffer (1 .. Sep'Length) = Sep then
1196 First := Sep'Length + 1;
1199 if Name_Len - First + 1 >= Sep'Length
1201 Name_Buffer (Name_Len - Sep'Length + 1 ..
1204 Name_Len := Name_Len - Sep'Length;
1207 if Name_Len = 0 then
1209 new String_List'(1 => new String'(""));
1216 -- Count the number of strings
1219 Saved : constant Positive := First;
1227 Name_Buffer (First .. Name_Len),
1231 First := Lst + Sep'Length;
1237 Str_List := new String_List (1 .. Nmb);
1239 -- Populate the string list
1246 Name_Buffer (First .. Name_Len),
1252 (Name_Buffer (First .. Name_Len));
1258 (Name_Buffer (First .. Lst - 1));
1260 First := Lst + Sep'Length;
1270 Value := Prj.Ext.Value_Of (Env.External, Name, Default);
1272 if Value = No_Name then
1273 if not Quiet_Output then
1275 (Env.Flags, "?undefined external reference",
1277 (The_Current_Term, From_Project_Node_Tree),
1281 Value := Empty_String;
1295 Add (Result.Value, Value);
1299 if not Ext_List or else Str_List /= null then
1300 String_Element_Table.Increment_Last
1301 (Shared.String_Elements);
1303 if Last = Nil_String then
1305 String_Element_Table.Last
1306 (Shared.String_Elements);
1309 Shared.String_Elements.Table (Last).Next
1310 := String_Element_Table.Last
1311 (Shared.String_Elements);
1314 Last := String_Element_Table.Last
1315 (Shared.String_Elements);
1318 for Ind in Str_List'Range loop
1320 Add_Str_To_Name_Buffer (Str_List (Ind).all);
1322 Shared.String_Elements.Table (Last) :=
1324 Display_Value => No_Name,
1328 From_Project_Node_Tree),
1333 if Ind /= Str_List'Last then
1334 String_Element_Table.Increment_Last
1335 (Shared.String_Elements);
1336 Shared.String_Elements.Table (Last).Next :=
1337 String_Element_Table.Last
1338 (Shared.String_Elements);
1339 Last := String_Element_Table.Last
1340 (Shared.String_Elements);
1345 Shared.String_Elements.Table (Last) :=
1347 Display_Value => No_Name,
1351 From_Project_Node_Tree),
1362 -- Should never happen
1366 "illegal node kind in an expression");
1367 raise Program_Error;
1371 The_Term := Next_Term (The_Term, From_Project_Node_Tree);
1377 ---------------------------------------
1378 -- Imported_Or_Extended_Project_From --
1379 ---------------------------------------
1381 function Imported_Or_Extended_Project_From
1382 (Project : Project_Id;
1383 With_Name : Name_Id;
1384 No_Extending : Boolean := False) return Project_Id
1386 List : Project_List;
1387 Result : Project_Id;
1388 Temp_Result : Project_Id;
1391 -- First check if it is the name of an extended project
1393 Result := Project.Extends;
1394 while Result /= No_Project loop
1395 if Result.Name = With_Name then
1398 Result := Result.Extends;
1402 -- Then check the name of each imported project
1404 Temp_Result := No_Project;
1405 List := Project.Imported_Projects;
1406 while List /= null loop
1407 Result := List.Project;
1409 -- If the project is directly imported, then returns its ID
1411 if Result.Name = With_Name then
1415 -- If a project extending the project is imported, then keep this
1416 -- extending project as a possibility. It will be the returned ID
1417 -- if the project is not imported directly.
1423 Proj := Result.Extends;
1424 while Proj /= No_Project loop
1425 if Proj.Name = With_Name then
1426 if No_Extending then
1427 Temp_Result := Proj;
1429 Temp_Result := Result;
1435 Proj := Proj.Extends;
1442 pragma Assert (Temp_Result /= No_Project, "project not found");
1444 end Imported_Or_Extended_Project_From;
1450 function Package_From
1451 (Project : Project_Id;
1452 Shared : Shared_Project_Tree_Data_Access;
1453 With_Name : Name_Id) return Package_Id
1455 Result : Package_Id := Project.Decl.Packages;
1458 -- Check the name of each existing package of Project
1460 while Result /= No_Package
1461 and then Shared.Packages.Table (Result).Name /= With_Name
1463 Result := Shared.Packages.Table (Result).Next;
1466 if Result = No_Package then
1468 -- Should never happen
1471 ("package """ & Get_Name_String (With_Name) & """ not found");
1472 raise Program_Error;
1484 (In_Tree : Project_Tree_Ref;
1485 Project : out Project_Id;
1486 Packages_To_Check : String_List_Access;
1487 Success : out Boolean;
1488 From_Project_Node : Project_Node_Id;
1489 From_Project_Node_Tree : Project_Node_Tree_Ref;
1490 Env : in out Prj.Tree.Environment;
1491 Reset_Tree : Boolean := True;
1492 On_New_Tree_Loaded : Tree_Loaded_Callback := null)
1495 Process_Project_Tree_Phase_1
1496 (In_Tree => In_Tree,
1499 From_Project_Node => From_Project_Node,
1500 From_Project_Node_Tree => From_Project_Node_Tree,
1502 Packages_To_Check => Packages_To_Check,
1503 Reset_Tree => Reset_Tree,
1504 On_New_Tree_Loaded => On_New_Tree_Loaded);
1506 if Project_Qualifier_Of
1507 (From_Project_Node, From_Project_Node_Tree) /= Configuration
1509 Process_Project_Tree_Phase_2
1510 (In_Tree => In_Tree,
1513 From_Project_Node => From_Project_Node,
1514 From_Project_Node_Tree => From_Project_Node_Tree,
1519 -------------------------------
1520 -- Process_Declarative_Items --
1521 -------------------------------
1523 procedure Process_Declarative_Items
1524 (Project : Project_Id;
1525 In_Tree : Project_Tree_Ref;
1526 From_Project_Node : Project_Node_Id;
1527 Node_Tree : Project_Node_Tree_Ref;
1528 Env : Prj.Tree.Environment;
1530 Item : Project_Node_Id;
1531 Child_Env : in out Prj.Tree.Environment)
1533 Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared;
1535 procedure Check_Or_Set_Typed_Variable
1536 (Value : in out Variable_Value;
1537 Declaration : Project_Node_Id);
1538 -- Check whether Value is valid for this typed variable declaration. If
1539 -- it is an error, the behavior depends on the flags: either an error is
1540 -- reported, or a warning, or nothing. In the last two cases, the value
1541 -- of the variable is set to a valid value, replacing Value.
1543 procedure Process_Package_Declaration
1544 (Current_Item : Project_Node_Id);
1545 procedure Process_Attribute_Declaration
1546 (Current : Project_Node_Id);
1547 procedure Process_Case_Construction
1548 (Current_Item : Project_Node_Id);
1549 procedure Process_Associative_Array
1550 (Current_Item : Project_Node_Id);
1551 procedure Process_Expression
1552 (Current : Project_Node_Id);
1553 procedure Process_Expression_For_Associative_Array
1554 (Current : Project_Node_Id;
1555 New_Value : Variable_Value);
1556 procedure Process_Expression_Variable_Decl
1557 (Current_Item : Project_Node_Id;
1558 New_Value : Variable_Value);
1559 -- Process the various declarative items
1561 ---------------------------------
1562 -- Check_Or_Set_Typed_Variable --
1563 ---------------------------------
1565 procedure Check_Or_Set_Typed_Variable
1566 (Value : in out Variable_Value;
1567 Declaration : Project_Node_Id)
1569 Loc : constant Source_Ptr := Location_Of (Declaration, Node_Tree);
1571 Reset_Value : Boolean := False;
1572 Current_String : Project_Node_Id;
1575 -- Report an error for an empty string
1577 if Value.Value = Empty_String then
1578 Error_Msg_Name_1 := Name_Of (Declaration, Node_Tree);
1580 case Env.Flags.Allow_Invalid_External is
1583 (Env.Flags, "no value defined for %%", Loc, Project);
1585 Reset_Value := True;
1587 (Env.Flags, "?no value defined for %%", Loc, Project);
1589 Reset_Value := True;
1593 -- Loop through all the valid strings for the
1594 -- string type and compare to the string value.
1597 First_Literal_String
1598 (String_Type_Of (Declaration, Node_Tree), Node_Tree);
1600 while Present (Current_String)
1602 String_Value_Of (Current_String, Node_Tree) /= Value.Value
1605 Next_Literal_String (Current_String, Node_Tree);
1608 -- Report error if string value is not one for the string type
1610 if No (Current_String) then
1611 Error_Msg_Name_1 := Value.Value;
1612 Error_Msg_Name_2 := Name_Of (Declaration, Node_Tree);
1614 case Env.Flags.Allow_Invalid_External is
1617 (Env.Flags, "value %% is illegal for typed string %%",
1622 (Env.Flags, "?value %% is illegal for typed string %%",
1624 Reset_Value := True;
1627 Reset_Value := True;
1634 First_Literal_String
1635 (String_Type_Of (Declaration, Node_Tree), Node_Tree);
1636 Value.Value := String_Value_Of (Current_String, Node_Tree);
1638 end Check_Or_Set_Typed_Variable;
1640 ---------------------------------
1641 -- Process_Package_Declaration --
1642 ---------------------------------
1644 procedure Process_Package_Declaration
1645 (Current_Item : Project_Node_Id)
1648 -- Do not process a package declaration that should be ignored
1650 if Expression_Kind_Of (Current_Item, Node_Tree) /= Ignored then
1652 -- Create the new package
1654 Package_Table.Increment_Last (Shared.Packages);
1657 New_Pkg : constant Package_Id :=
1658 Package_Table.Last (Shared.Packages);
1659 The_New_Package : Package_Element;
1661 Project_Of_Renamed_Package : constant Project_Node_Id :=
1662 Project_Of_Renamed_Package_Of
1663 (Current_Item, Node_Tree);
1666 -- Set the name of the new package
1668 The_New_Package.Name := Name_Of (Current_Item, Node_Tree);
1670 -- Insert the new package in the appropriate list
1672 if Pkg /= No_Package then
1673 The_New_Package.Next :=
1674 Shared.Packages.Table (Pkg).Decl.Packages;
1675 Shared.Packages.Table (Pkg).Decl.Packages := New_Pkg;
1678 The_New_Package.Next := Project.Decl.Packages;
1679 Project.Decl.Packages := New_Pkg;
1682 Shared.Packages.Table (New_Pkg) := The_New_Package;
1684 if Present (Project_Of_Renamed_Package) then
1686 -- Renamed or extending package
1689 Project_Name : constant Name_Id :=
1690 Name_Of (Project_Of_Renamed_Package,
1693 Renamed_Project : constant Project_Id :=
1694 Imported_Or_Extended_Project_From
1695 (Project, Project_Name);
1697 Renamed_Package : constant Package_Id :=
1699 (Renamed_Project, Shared,
1700 Name_Of (Current_Item, Node_Tree));
1703 -- For a renamed package, copy the declarations of the
1704 -- renamed package, but set all the locations to the
1705 -- location of the package name in the renaming
1708 Copy_Package_Declarations
1709 (From => Shared.Packages.Table
1710 (Renamed_Package).Decl,
1711 To => Shared.Packages.Table (New_Pkg).Decl,
1712 New_Loc => Location_Of (Current_Item, Node_Tree),
1713 Restricted => False,
1718 -- Set the default values of the attributes
1723 Name_Id (Project.Directory.Display_Name),
1725 Shared.Packages.Table (New_Pkg).Decl,
1727 (Package_Id_Of (Current_Item, Node_Tree)),
1728 Project_Level => False);
1731 -- Process declarative items (nothing to do when the package is
1732 -- renaming, as the first declarative item is null).
1734 Process_Declarative_Items
1735 (Project => Project,
1737 From_Project_Node => From_Project_Node,
1738 Node_Tree => Node_Tree,
1742 First_Declarative_Item_Of (Current_Item, Node_Tree),
1743 Child_Env => Child_Env);
1746 end Process_Package_Declaration;
1748 -------------------------------
1749 -- Process_Associative_Array --
1750 -------------------------------
1752 procedure Process_Associative_Array
1753 (Current_Item : Project_Node_Id)
1755 Current_Item_Name : constant Name_Id :=
1756 Name_Of (Current_Item, Node_Tree);
1757 -- The name of the attribute
1759 Current_Location : constant Source_Ptr :=
1760 Location_Of (Current_Item, Node_Tree);
1762 New_Array : Array_Id;
1763 -- The new associative array created
1765 Orig_Array : Array_Id;
1766 -- The associative array value
1768 Orig_Project_Name : Name_Id := No_Name;
1769 -- The name of the project where the associative array
1772 Orig_Project : Project_Id := No_Project;
1773 -- The id of the project where the associative array
1776 Orig_Package_Name : Name_Id := No_Name;
1777 -- The name of the package, if any, where the associative array value
1780 Orig_Package : Package_Id := No_Package;
1781 -- The id of the package, if any, where the associative array value
1784 New_Element : Array_Element_Id := No_Array_Element;
1785 -- Id of a new array element created
1787 Prev_Element : Array_Element_Id := No_Array_Element;
1788 -- Last new element id created
1790 Orig_Element : Array_Element_Id := No_Array_Element;
1791 -- Current array element in original associative array
1793 Next_Element : Array_Element_Id := No_Array_Element;
1794 -- Id of the array element that follows the new element. This is not
1795 -- always nil, because values for the associative array attribute may
1796 -- already have been declared, and the array elements declared are
1802 -- First find if the associative array attribute already has elements
1805 if Pkg /= No_Package then
1806 New_Array := Shared.Packages.Table (Pkg).Decl.Arrays;
1808 New_Array := Project.Decl.Arrays;
1811 while New_Array /= No_Array
1812 and then Shared.Arrays.Table (New_Array).Name /= Current_Item_Name
1814 New_Array := Shared.Arrays.Table (New_Array).Next;
1817 -- If the attribute has never been declared add new entry in the
1818 -- arrays of the project/package and link it.
1820 if New_Array = No_Array then
1821 Array_Table.Increment_Last (Shared.Arrays);
1822 New_Array := Array_Table.Last (Shared.Arrays);
1824 if Pkg /= No_Package then
1825 Shared.Arrays.Table (New_Array) :=
1826 (Name => Current_Item_Name,
1827 Location => Current_Location,
1828 Value => No_Array_Element,
1829 Next => Shared.Packages.Table (Pkg).Decl.Arrays);
1831 Shared.Packages.Table (Pkg).Decl.Arrays := New_Array;
1834 Shared.Arrays.Table (New_Array) :=
1835 (Name => Current_Item_Name,
1836 Location => Current_Location,
1837 Value => No_Array_Element,
1838 Next => Project.Decl.Arrays);
1840 Project.Decl.Arrays := New_Array;
1844 -- Find the project where the value is declared
1846 Orig_Project_Name :=
1848 (Associative_Project_Of (Current_Item, Node_Tree), Node_Tree);
1850 Prj := In_Tree.Projects;
1851 while Prj /= null loop
1852 if Prj.Project.Name = Orig_Project_Name then
1853 Orig_Project := Prj.Project;
1859 pragma Assert (Orig_Project /= No_Project,
1860 "original project not found");
1862 if No (Associative_Package_Of (Current_Item, Node_Tree)) then
1863 Orig_Array := Orig_Project.Decl.Arrays;
1866 -- If in a package, find the package where the value is declared
1868 Orig_Package_Name :=
1870 (Associative_Package_Of (Current_Item, Node_Tree), Node_Tree);
1872 Orig_Package := Orig_Project.Decl.Packages;
1873 pragma Assert (Orig_Package /= No_Package,
1874 "original package not found");
1876 while Shared.Packages.Table
1877 (Orig_Package).Name /= Orig_Package_Name
1879 Orig_Package := Shared.Packages.Table (Orig_Package).Next;
1880 pragma Assert (Orig_Package /= No_Package,
1881 "original package not found");
1884 Orig_Array := Shared.Packages.Table (Orig_Package).Decl.Arrays;
1887 -- Now look for the array
1889 while Orig_Array /= No_Array
1890 and then Shared.Arrays.Table (Orig_Array).Name /= Current_Item_Name
1892 Orig_Array := Shared.Arrays.Table (Orig_Array).Next;
1895 if Orig_Array = No_Array then
1898 "associative array value not found",
1899 Location_Of (Current_Item, Node_Tree),
1903 Orig_Element := Shared.Arrays.Table (Orig_Array).Value;
1905 -- Copy each array element
1907 while Orig_Element /= No_Array_Element loop
1909 -- Case of first element
1911 if Prev_Element = No_Array_Element then
1913 -- And there is no array element declared yet, create a new
1914 -- first array element.
1916 if Shared.Arrays.Table (New_Array).Value =
1919 Array_Element_Table.Increment_Last
1920 (Shared.Array_Elements);
1921 New_Element := Array_Element_Table.Last
1922 (Shared.Array_Elements);
1923 Shared.Arrays.Table (New_Array).Value := New_Element;
1924 Next_Element := No_Array_Element;
1926 -- Otherwise, the new element is the first
1929 New_Element := Shared.Arrays.Table (New_Array).Value;
1931 Shared.Array_Elements.Table (New_Element).Next;
1934 -- Otherwise, reuse an existing element, or create
1935 -- one if necessary.
1939 Shared.Array_Elements.Table (Prev_Element).Next;
1941 if Next_Element = No_Array_Element then
1942 Array_Element_Table.Increment_Last
1943 (Shared.Array_Elements);
1944 New_Element := Array_Element_Table.Last
1945 (Shared.Array_Elements);
1946 Shared.Array_Elements.Table (Prev_Element).Next :=
1950 New_Element := Next_Element;
1952 Shared.Array_Elements.Table (New_Element).Next;
1956 -- Copy the value of the element
1958 Shared.Array_Elements.Table (New_Element) :=
1959 Shared.Array_Elements.Table (Orig_Element);
1960 Shared.Array_Elements.Table (New_Element).Value.Project
1963 -- Adjust the Next link
1965 Shared.Array_Elements.Table (New_Element).Next := Next_Element;
1967 -- Adjust the previous id for the next element
1969 Prev_Element := New_Element;
1971 -- Go to the next element in the original array
1973 Orig_Element := Shared.Array_Elements.Table (Orig_Element).Next;
1976 -- Make sure that the array ends here, in case there previously a
1977 -- greater number of elements.
1979 Shared.Array_Elements.Table (New_Element).Next := No_Array_Element;
1981 end Process_Associative_Array;
1983 ----------------------------------------------
1984 -- Process_Expression_For_Associative_Array --
1985 ----------------------------------------------
1987 procedure Process_Expression_For_Associative_Array
1988 (Current : Project_Node_Id;
1989 New_Value : Variable_Value)
1991 Name : constant Name_Id := Name_Of (Current, Node_Tree);
1992 Current_Location : constant Source_Ptr :=
1993 Location_Of (Current, Node_Tree);
1995 Index_Name : Name_Id :=
1996 Associative_Array_Index_Of (Current, Node_Tree);
1998 Source_Index : constant Int :=
1999 Source_Index_Of (Current, Node_Tree);
2001 The_Array : Array_Id;
2002 Elem : Array_Element_Id := No_Array_Element;
2005 if Index_Name /= All_Other_Names then
2006 Index_Name := Get_Attribute_Index (Node_Tree, Current, Index_Name);
2009 -- Look for the array in the appropriate list
2011 if Pkg /= No_Package then
2012 The_Array := Shared.Packages.Table (Pkg).Decl.Arrays;
2014 The_Array := Project.Decl.Arrays;
2017 while The_Array /= No_Array
2018 and then Shared.Arrays.Table (The_Array).Name /= Name
2020 The_Array := Shared.Arrays.Table (The_Array).Next;
2023 -- If the array cannot be found, create a new entry in the list.
2024 -- As The_Array_Element is initialized to No_Array_Element, a new
2025 -- element will be created automatically later
2027 if The_Array = No_Array then
2028 Array_Table.Increment_Last (Shared.Arrays);
2029 The_Array := Array_Table.Last (Shared.Arrays);
2031 if Pkg /= No_Package then
2032 Shared.Arrays.Table (The_Array) :=
2034 Location => Current_Location,
2035 Value => No_Array_Element,
2036 Next => Shared.Packages.Table (Pkg).Decl.Arrays);
2038 Shared.Packages.Table (Pkg).Decl.Arrays := The_Array;
2041 Shared.Arrays.Table (The_Array) :=
2043 Location => Current_Location,
2044 Value => No_Array_Element,
2045 Next => Project.Decl.Arrays);
2047 Project.Decl.Arrays := The_Array;
2051 Elem := Shared.Arrays.Table (The_Array).Value;
2054 -- Look in the list, if any, to find an element with the same index
2055 -- and same source index.
2057 while Elem /= No_Array_Element
2059 (Shared.Array_Elements.Table (Elem).Index /= Index_Name
2061 Shared.Array_Elements.Table (Elem).Src_Index /= Source_Index)
2063 Elem := Shared.Array_Elements.Table (Elem).Next;
2066 -- If no such element were found, create a new one
2067 -- and insert it in the element list, with the
2070 if Elem = No_Array_Element then
2071 Array_Element_Table.Increment_Last (Shared.Array_Elements);
2072 Elem := Array_Element_Table.Last (Shared.Array_Elements);
2074 Shared.Array_Elements.Table
2076 (Index => Index_Name,
2077 Restricted => False,
2078 Src_Index => Source_Index,
2079 Index_Case_Sensitive =>
2080 not Case_Insensitive (Current, Node_Tree),
2082 Next => Shared.Arrays.Table (The_Array).Value);
2084 Shared.Arrays.Table (The_Array).Value := Elem;
2087 -- An element with the same index already exists, just replace its
2088 -- value with the new one.
2090 Shared.Array_Elements.Table (Elem).Value := New_Value;
2093 if Name = Snames.Name_External then
2094 if In_Tree.Is_Root_Tree then
2095 Add (Child_Env.External,
2096 External_Name => Get_Name_String (Index_Name),
2097 Value => Get_Name_String (New_Value.Value),
2098 Source => From_External_Attribute);
2100 External_Name => Get_Name_String (Index_Name),
2101 Value => Get_Name_String (New_Value.Value),
2102 Source => From_External_Attribute,
2105 if Current_Verbosity = High then
2107 ("'for External' has no effect except in root aggregate ("
2108 & Get_Name_String (Index_Name) & ")", New_Value.Value);
2112 end Process_Expression_For_Associative_Array;
2114 --------------------------------------
2115 -- Process_Expression_Variable_Decl --
2116 --------------------------------------
2118 procedure Process_Expression_Variable_Decl
2119 (Current_Item : Project_Node_Id;
2120 New_Value : Variable_Value)
2122 Name : constant Name_Id := Name_Of (Current_Item, Node_Tree);
2124 Is_Attribute : constant Boolean :=
2125 Kind_Of (Current_Item, Node_Tree) =
2126 N_Attribute_Declaration;
2128 Var : Variable_Id := No_Variable;
2131 -- First, find the list where to find the variable or attribute
2133 if Is_Attribute then
2134 if Pkg /= No_Package then
2135 Var := Shared.Packages.Table (Pkg).Decl.Attributes;
2137 Var := Project.Decl.Attributes;
2141 if Pkg /= No_Package then
2142 Var := Shared.Packages.Table (Pkg).Decl.Variables;
2144 Var := Project.Decl.Variables;
2148 -- Loop through the list, to find if it has already been declared
2150 while Var /= No_Variable
2151 and then Shared.Variable_Elements.Table (Var).Name /= Name
2153 Var := Shared.Variable_Elements.Table (Var).Next;
2156 -- If it has not been declared, create a new entry in the list
2158 if Var = No_Variable then
2160 -- All single string attribute should already have been declared
2161 -- with a default empty string value.
2165 "illegal attribute declaration for " & Get_Name_String (Name));
2167 Variable_Element_Table.Increment_Last (Shared.Variable_Elements);
2168 Var := Variable_Element_Table.Last (Shared.Variable_Elements);
2170 -- Put the new variable in the appropriate list
2172 if Pkg /= No_Package then
2173 Shared.Variable_Elements.Table (Var) :=
2174 (Next => Shared.Packages.Table (Pkg).Decl.Variables,
2176 Value => New_Value);
2177 Shared.Packages.Table (Pkg).Decl.Variables := Var;
2180 Shared.Variable_Elements.Table (Var) :=
2181 (Next => Project.Decl.Variables,
2183 Value => New_Value);
2184 Project.Decl.Variables := Var;
2187 -- If the variable/attribute has already been declared, just
2188 -- change the value.
2191 Shared.Variable_Elements.Table (Var).Value := New_Value;
2194 if Is_Attribute and then Name = Snames.Name_Project_Path then
2195 if In_Tree.Is_Root_Tree then
2198 new Ada.Containers.Vectors (Positive, Name_Id);
2199 Val : String_List_Id := New_Value.Values;
2200 List : Name_Ids.Vector;
2204 while Val /= Nil_String loop
2206 (Shared.String_Elements.Table (Val).Value);
2207 Val := Shared.String_Elements.Table (Val).Next;
2210 -- Prepend them in the order found in the attribute
2212 for K in Positive range 1 .. Positive (List.Length) loop
2213 Prj.Env.Add_Directories
2214 (Child_Env.Project_Path,
2216 (Name => Get_Name_String
2218 Directory => Get_Name_String
2219 (Project.Directory.Display_Name)),
2225 if Current_Verbosity = High then
2227 ("'for Project_Path' has no effect except in"
2228 & " root aggregate");
2232 end Process_Expression_Variable_Decl;
2234 ------------------------
2235 -- Process_Expression --
2236 ------------------------
2238 procedure Process_Expression (Current : Project_Node_Id) is
2239 New_Value : Variable_Value :=
2241 (Project => Project,
2243 From_Project_Node => From_Project_Node,
2244 From_Project_Node_Tree => Node_Tree,
2249 (Expression_Of (Current, Node_Tree), Node_Tree),
2251 Expression_Kind_Of (Current, Node_Tree));
2254 -- Process a typed variable declaration
2256 if Kind_Of (Current, Node_Tree) = N_Typed_Variable_Declaration then
2257 Check_Or_Set_Typed_Variable (New_Value, Current);
2260 if Kind_Of (Current, Node_Tree) /= N_Attribute_Declaration
2261 or else Associative_Array_Index_Of (Current, Node_Tree) = No_Name
2263 Process_Expression_Variable_Decl (Current, New_Value);
2265 Process_Expression_For_Associative_Array (Current, New_Value);
2267 end Process_Expression;
2269 -----------------------------------
2270 -- Process_Attribute_Declaration --
2271 -----------------------------------
2273 procedure Process_Attribute_Declaration (Current : Project_Node_Id) is
2275 if Expression_Of (Current, Node_Tree) = Empty_Node then
2276 Process_Associative_Array (Current);
2278 Process_Expression (Current);
2280 end Process_Attribute_Declaration;
2282 -------------------------------
2283 -- Process_Case_Construction --
2284 -------------------------------
2286 procedure Process_Case_Construction
2287 (Current_Item : Project_Node_Id)
2289 The_Project : Project_Id := Project;
2290 -- The id of the project of the case variable
2292 The_Package : Package_Id := Pkg;
2293 -- The id of the package, if any, of the case variable
2295 The_Variable : Variable_Value := Nil_Variable_Value;
2296 -- The case variable
2298 Case_Value : Name_Id := No_Name;
2299 -- The case variable value
2301 Case_Item : Project_Node_Id := Empty_Node;
2302 Choice_String : Project_Node_Id := Empty_Node;
2303 Decl_Item : Project_Node_Id := Empty_Node;
2307 Variable_Node : constant Project_Node_Id :=
2308 Case_Variable_Reference_Of
2312 Var_Id : Variable_Id := No_Variable;
2313 Name : Name_Id := No_Name;
2316 -- If a project was specified for the case variable, get its id
2318 if Present (Project_Node_Of (Variable_Node, Node_Tree)) then
2321 (Project_Node_Of (Variable_Node, Node_Tree), Node_Tree);
2323 Imported_Or_Extended_Project_From
2324 (Project, Name, No_Extending => True);
2325 The_Package := No_Package;
2328 -- If a package was specified for the case variable, get its id
2330 if Present (Package_Node_Of (Variable_Node, Node_Tree)) then
2333 (Package_Node_Of (Variable_Node, Node_Tree), Node_Tree);
2334 The_Package := Package_From (The_Project, Shared, Name);
2337 Name := Name_Of (Variable_Node, Node_Tree);
2339 -- First, look for the case variable into the package, if any
2341 if The_Package /= No_Package then
2342 Name := Name_Of (Variable_Node, Node_Tree);
2344 Var_Id := Shared.Packages.Table (The_Package).Decl.Variables;
2345 while Var_Id /= No_Variable
2346 and then Shared.Variable_Elements.Table (Var_Id).Name /= Name
2348 Var_Id := Shared.Variable_Elements.Table (Var_Id).Next;
2352 -- If not found in the package, or if there is no package, look at
2353 -- the project level.
2355 if Var_Id = No_Variable
2356 and then No (Package_Node_Of (Variable_Node, Node_Tree))
2358 Var_Id := The_Project.Decl.Variables;
2359 while Var_Id /= No_Variable
2360 and then Shared.Variable_Elements.Table (Var_Id).Name /= Name
2362 Var_Id := Shared.Variable_Elements.Table (Var_Id).Next;
2366 if Var_Id = No_Variable then
2368 -- Should never happen, because this has already been checked
2372 ("variable """ & Get_Name_String (Name) & """ not found");
2373 raise Program_Error;
2376 -- Get the case variable
2378 The_Variable := Shared.Variable_Elements. Table (Var_Id).Value;
2380 if The_Variable.Kind /= Single then
2382 -- Should never happen, because this has already been checked
2385 Write_Line ("variable""" & Get_Name_String (Name) &
2386 """ is not a single string variable");
2387 raise Program_Error;
2390 -- Get the case variable value
2392 Case_Value := The_Variable.Value;
2395 -- Now look into all the case items of the case construction
2397 Case_Item := First_Case_Item_Of (Current_Item, Node_Tree);
2400 while Present (Case_Item) loop
2401 Choice_String := First_Choice_Of (Case_Item, Node_Tree);
2403 -- When Choice_String is nil, it means that it is the
2404 -- "when others =>" alternative.
2406 if No (Choice_String) then
2407 Decl_Item := First_Declarative_Item_Of (Case_Item, Node_Tree);
2408 exit Case_Item_Loop;
2411 -- Look into all the alternative of this case item
2414 while Present (Choice_String) loop
2415 if Case_Value = String_Value_Of (Choice_String, Node_Tree) then
2417 First_Declarative_Item_Of (Case_Item, Node_Tree);
2418 exit Case_Item_Loop;
2421 Choice_String := Next_Literal_String (Choice_String, Node_Tree);
2422 end loop Choice_Loop;
2424 Case_Item := Next_Case_Item (Case_Item, Node_Tree);
2425 end loop Case_Item_Loop;
2427 -- If there is an alternative, then we process it
2429 if Present (Decl_Item) then
2430 Process_Declarative_Items
2431 (Project => Project,
2433 From_Project_Node => From_Project_Node,
2434 Node_Tree => Node_Tree,
2438 Child_Env => Child_Env);
2440 end Process_Case_Construction;
2444 Current, Decl : Project_Node_Id;
2445 Kind : Project_Node_Kind;
2447 -- Start of processing for Process_Declarative_Items
2451 while Present (Decl) loop
2452 Current := Current_Item_Node (Decl, Node_Tree);
2453 Decl := Next_Declarative_Item (Decl, Node_Tree);
2454 Kind := Kind_Of (Current, Node_Tree);
2457 when N_Package_Declaration =>
2458 Process_Package_Declaration (Current);
2460 -- Nothing to process for string type declaration
2462 when N_String_Type_Declaration =>
2465 when N_Attribute_Declaration |
2466 N_Typed_Variable_Declaration |
2467 N_Variable_Declaration =>
2468 Process_Attribute_Declaration (Current);
2470 when N_Case_Construction =>
2471 Process_Case_Construction (Current);
2474 Write_Line ("Illegal declarative item: " & Kind'Img);
2475 raise Program_Error;
2478 end Process_Declarative_Items;
2480 ----------------------------------
2481 -- Process_Project_Tree_Phase_1 --
2482 ----------------------------------
2484 procedure Process_Project_Tree_Phase_1
2485 (In_Tree : Project_Tree_Ref;
2486 Project : out Project_Id;
2487 Packages_To_Check : String_List_Access;
2488 Success : out Boolean;
2489 From_Project_Node : Project_Node_Id;
2490 From_Project_Node_Tree : Project_Node_Tree_Ref;
2491 Env : in out Prj.Tree.Environment;
2492 Reset_Tree : Boolean := True;
2493 On_New_Tree_Loaded : Tree_Loaded_Callback := null)
2498 -- Make sure there are no projects in the data structure
2500 Free_List (In_Tree.Projects, Free_Project => True);
2503 Processed_Projects.Reset;
2505 -- And process the main project and all of the projects it depends on,
2508 Debug_Increase_Indent ("Process tree, phase 1");
2511 (Project => Project,
2513 Packages_To_Check => Packages_To_Check,
2514 From_Project_Node => From_Project_Node,
2515 From_Project_Node_Tree => From_Project_Node_Tree,
2517 Extended_By => No_Project,
2518 From_Encapsulated_Lib => False,
2519 On_New_Tree_Loaded => On_New_Tree_Loaded);
2522 Total_Errors_Detected = 0
2524 (Warning_Mode /= Treat_As_Error or else Warnings_Detected = 0);
2526 if Current_Verbosity = High then
2527 Debug_Decrease_Indent
2528 ("Done Process tree, phase 1, Success=" & Success'Img);
2530 end Process_Project_Tree_Phase_1;
2532 ----------------------------------
2533 -- Process_Project_Tree_Phase_2 --
2534 ----------------------------------
2536 procedure Process_Project_Tree_Phase_2
2537 (In_Tree : Project_Tree_Ref;
2538 Project : Project_Id;
2539 Success : out Boolean;
2540 From_Project_Node : Project_Node_Id;
2541 From_Project_Node_Tree : Project_Node_Tree_Ref;
2544 Obj_Dir : Path_Name_Type;
2545 Extending : Project_Id;
2546 Extending2 : Project_Id;
2549 -- Start of processing for Process_Project_Tree_Phase_2
2554 Debug_Increase_Indent ("Process tree, phase 2", Project.Name);
2556 if Project /= No_Project then
2557 Check (In_Tree, Project, From_Project_Node_Tree, Env.Flags);
2560 -- If main project is an extending all project, set object directory of
2561 -- all virtual extending projects to object directory of main project.
2563 if Project /= No_Project
2564 and then Is_Extending_All (From_Project_Node, From_Project_Node_Tree)
2567 Object_Dir : constant Path_Information := Project.Object_Directory;
2570 Prj := In_Tree.Projects;
2571 while Prj /= null loop
2572 if Prj.Project.Virtual then
2573 Prj.Project.Object_Directory := Object_Dir;
2581 -- Check that no extending project shares its object directory with
2582 -- the project(s) it extends.
2584 if Project /= No_Project then
2585 Prj := In_Tree.Projects;
2586 while Prj /= null loop
2587 Extending := Prj.Project.Extended_By;
2589 if Extending /= No_Project then
2590 Obj_Dir := Prj.Project.Object_Directory.Name;
2592 -- Check that a project being extended does not share its
2593 -- object directory with any project that extends it, directly
2594 -- or indirectly, including a virtual extending project.
2596 -- Start with the project directly extending it
2598 Extending2 := Extending;
2599 while Extending2 /= No_Project loop
2600 if Has_Ada_Sources (Extending2)
2601 and then Extending2.Object_Directory.Name = Obj_Dir
2603 if Extending2.Virtual then
2604 Error_Msg_Name_1 := Prj.Project.Display_Name;
2607 "project %% cannot be extended by a virtual" &
2608 " project with the same object directory",
2609 Prj.Project.Location, Project);
2612 Error_Msg_Name_1 := Extending2.Display_Name;
2613 Error_Msg_Name_2 := Prj.Project.Display_Name;
2616 "project %% cannot extend project %%",
2617 Extending2.Location, Project);
2620 "\they share the same object directory",
2621 Extending2.Location, Project);
2625 -- Continue with the next extending project, if any
2627 Extending2 := Extending2.Extended_By;
2635 Debug_Decrease_Indent ("Done Process tree, phase 2");
2637 Success := Total_Errors_Detected = 0
2639 (Warning_Mode /= Treat_As_Error or else Warnings_Detected = 0);
2640 end Process_Project_Tree_Phase_2;
2642 -----------------------
2643 -- Recursive_Process --
2644 -----------------------
2646 procedure Recursive_Process
2647 (In_Tree : Project_Tree_Ref;
2648 Project : out Project_Id;
2649 Packages_To_Check : String_List_Access;
2650 From_Project_Node : Project_Node_Id;
2651 From_Project_Node_Tree : Project_Node_Tree_Ref;
2652 Env : in out Prj.Tree.Environment;
2653 Extended_By : Project_Id;
2654 From_Encapsulated_Lib : Boolean;
2655 On_New_Tree_Loaded : Tree_Loaded_Callback := null)
2657 Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared;
2659 Child_Env : Prj.Tree.Environment;
2660 -- Only used for the root aggregate project (if any). This is left
2661 -- uninitialized otherwise.
2663 procedure Process_Imported_Projects
2664 (Imported : in out Project_List;
2665 Limited_With : Boolean);
2666 -- Process imported projects. If Limited_With is True, then only
2667 -- projects processed through a "limited with" are processed, otherwise
2668 -- only projects imported through a standard "with" are processed.
2669 -- Imported is the id of the last imported project.
2671 procedure Process_Aggregated_Projects;
2672 -- Process all the projects aggregated in List. This does nothing if the
2673 -- project is not an aggregate project.
2675 procedure Process_Extended_Project;
2676 -- Process the extended project: inherit all packages from the extended
2677 -- project that are not explicitly defined or renamed. Also inherit the
2678 -- languages, if attribute Languages is not explicitly defined.
2680 -------------------------------
2681 -- Process_Imported_Projects --
2682 -------------------------------
2684 procedure Process_Imported_Projects
2685 (Imported : in out Project_List;
2686 Limited_With : Boolean)
2688 With_Clause : Project_Node_Id;
2689 New_Project : Project_Id;
2690 Proj_Node : Project_Node_Id;
2694 First_With_Clause_Of
2695 (From_Project_Node, From_Project_Node_Tree);
2697 while Present (With_Clause) loop
2699 Non_Limited_Project_Node_Of
2700 (With_Clause, From_Project_Node_Tree);
2701 New_Project := No_Project;
2703 if (Limited_With and then No (Proj_Node))
2704 or else (not Limited_With and then Present (Proj_Node))
2707 (In_Tree => In_Tree,
2708 Project => New_Project,
2709 Packages_To_Check => Packages_To_Check,
2710 From_Project_Node =>
2711 Project_Node_Of (With_Clause, From_Project_Node_Tree),
2712 From_Project_Node_Tree => From_Project_Node_Tree,
2714 Extended_By => No_Project,
2715 From_Encapsulated_Lib => From_Encapsulated_Lib,
2716 On_New_Tree_Loaded => On_New_Tree_Loaded);
2718 if Imported = null then
2719 Project.Imported_Projects := new Project_List_Element'
2720 (Project => New_Project,
2721 From_Encapsulated_Lib => False,
2723 Imported := Project.Imported_Projects;
2725 Imported.Next := new Project_List_Element'
2726 (Project => New_Project,
2727 From_Encapsulated_Lib => False,
2729 Imported := Imported.Next;
2734 Next_With_Clause_Of (With_Clause, From_Project_Node_Tree);
2736 end Process_Imported_Projects;
2738 ---------------------------------
2739 -- Process_Aggregated_Projects --
2740 ---------------------------------
2742 procedure Process_Aggregated_Projects is
2743 List : Aggregated_Project_List;
2744 Loaded_Project : Prj.Tree.Project_Node_Id;
2745 Success : Boolean := True;
2746 Tree : Project_Tree_Ref;
2747 Node_Tree : Project_Node_Tree_Ref;
2750 if Project.Qualifier not in Aggregate_Project then
2754 Debug_Increase_Indent ("Process_Aggregated_Projects", Project.Name);
2756 Prj.Nmsc.Process_Aggregated_Projects
2759 Node_Tree => From_Project_Node_Tree,
2760 Flags => Env.Flags);
2762 List := Project.Aggregated_Projects;
2763 while Success and then List /= null loop
2764 Node_Tree := new Project_Node_Tree_Data;
2765 Initialize (Node_Tree);
2768 (In_Tree => Node_Tree,
2769 Project => Loaded_Project,
2770 Packages_To_Check => Packages_To_Check,
2771 Project_File_Name => Get_Name_String (List.Path),
2772 Errout_Handling => Prj.Part.Never_Finalize,
2773 Current_Directory => Get_Name_String (Project.Directory.Name),
2774 Is_Config_File => False,
2777 Success := not Prj.Tree.No (Loaded_Project);
2780 if Node_Tree.Incomplete_With then
2781 From_Project_Node_Tree.Incomplete_With := True;
2784 List.Tree := new Project_Tree_Data (Is_Root_Tree => False);
2785 Prj.Initialize (List.Tree);
2786 List.Tree.Shared := In_Tree.Shared;
2788 -- In aggregate library, aggregated projects are parsed using
2789 -- the aggregate library tree.
2791 if Project.Qualifier = Aggregate_Library then
2797 -- We can only do the phase 1 of the processing, since we do
2798 -- not have access to the configuration file yet (this is
2799 -- called when doing phase 1 of the processing for the root
2800 -- aggregate project).
2802 if In_Tree.Is_Root_Tree then
2803 Process_Project_Tree_Phase_1
2805 Project => List.Project,
2806 Packages_To_Check => Packages_To_Check,
2808 From_Project_Node => Loaded_Project,
2809 From_Project_Node_Tree => Node_Tree,
2811 Reset_Tree => False,
2812 On_New_Tree_Loaded => On_New_Tree_Loaded);
2814 -- use the same environment as the rest of the aggregated
2815 -- projects, ie the one that was setup by the root aggregate
2816 Process_Project_Tree_Phase_1
2818 Project => List.Project,
2819 Packages_To_Check => Packages_To_Check,
2821 From_Project_Node => Loaded_Project,
2822 From_Project_Node_Tree => Node_Tree,
2824 Reset_Tree => False,
2825 On_New_Tree_Loaded => On_New_Tree_Loaded);
2828 if On_New_Tree_Loaded /= null then
2830 (Node_Tree, Tree, Loaded_Project, List.Project);
2834 Debug_Output ("Failed to parse", Name_Id (List.Path));
2840 Debug_Decrease_Indent ("Done Process_Aggregated_Projects");
2841 end Process_Aggregated_Projects;
2843 ------------------------------
2844 -- Process_Extended_Project --
2845 ------------------------------
2847 procedure Process_Extended_Project is
2848 Extended_Pkg : Package_Id;
2849 Current_Pkg : Package_Id;
2850 Element : Package_Element;
2851 First : constant Package_Id := Project.Decl.Packages;
2852 Attribute1 : Variable_Id;
2853 Attribute2 : Variable_Id;
2854 Attr_Value1 : Variable;
2855 Attr_Value2 : Variable;
2858 Extended_Pkg := Project.Extends.Decl.Packages;
2859 while Extended_Pkg /= No_Package loop
2860 Element := Shared.Packages.Table (Extended_Pkg);
2862 Current_Pkg := First;
2863 while Current_Pkg /= No_Package
2865 Shared.Packages.Table (Current_Pkg).Name /= Element.Name
2867 Current_Pkg := Shared.Packages.Table (Current_Pkg).Next;
2870 if Current_Pkg = No_Package then
2871 Package_Table.Increment_Last (Shared.Packages);
2872 Current_Pkg := Package_Table.Last (Shared.Packages);
2873 Shared.Packages.Table (Current_Pkg) :=
2874 (Name => Element.Name,
2875 Decl => No_Declarations,
2876 Parent => No_Package,
2877 Next => Project.Decl.Packages);
2878 Project.Decl.Packages := Current_Pkg;
2879 Copy_Package_Declarations
2880 (From => Element.Decl,
2881 To => Shared.Packages.Table (Current_Pkg).Decl,
2882 New_Loc => No_Location,
2887 Extended_Pkg := Element.Next;
2890 -- Check if attribute Languages is declared in the extending project
2892 Attribute1 := Project.Decl.Attributes;
2893 while Attribute1 /= No_Variable loop
2894 Attr_Value1 := Shared.Variable_Elements. Table (Attribute1);
2895 exit when Attr_Value1.Name = Snames.Name_Languages;
2896 Attribute1 := Attr_Value1.Next;
2899 if Attribute1 = No_Variable or else Attr_Value1.Value.Default then
2901 -- Attribute Languages is not declared in the extending project.
2902 -- Check if it is declared in the project being extended.
2904 Attribute2 := Project.Extends.Decl.Attributes;
2905 while Attribute2 /= No_Variable loop
2906 Attr_Value2 := Shared.Variable_Elements.Table (Attribute2);
2907 exit when Attr_Value2.Name = Snames.Name_Languages;
2908 Attribute2 := Attr_Value2.Next;
2911 if Attribute2 /= No_Variable
2912 and then not Attr_Value2.Value.Default
2914 -- As attribute Languages is declared in the project being
2915 -- extended, copy its value for the extending project.
2917 if Attribute1 = No_Variable then
2918 Variable_Element_Table.Increment_Last
2919 (Shared.Variable_Elements);
2920 Attribute1 := Variable_Element_Table.Last
2921 (Shared.Variable_Elements);
2922 Attr_Value1.Next := Project.Decl.Attributes;
2923 Project.Decl.Attributes := Attribute1;
2926 Attr_Value1.Name := Snames.Name_Languages;
2927 Attr_Value1.Value := Attr_Value2.Value;
2928 Shared.Variable_Elements.Table (Attribute1) := Attr_Value1;
2931 end Process_Extended_Project;
2933 -- Start of processing for Recursive_Process
2936 if No (From_Project_Node) then
2937 Project := No_Project;
2941 Imported, Mark : Project_List;
2942 Declaration_Node : Project_Node_Id := Empty_Node;
2944 Name : constant Name_Id :=
2945 Name_Of (From_Project_Node, From_Project_Node_Tree);
2947 Display_Name : constant Name_Id :=
2949 (From_Project_Node, From_Project_Node_Tree);
2952 Project := Processed_Projects.Get (Name);
2954 if Project /= No_Project then
2956 -- Make sure that, when a project is extended, the project id
2957 -- of the project extending it is recorded in its data, even
2958 -- when it has already been processed as an imported project.
2959 -- This is for virtually extended projects.
2961 if Extended_By /= No_Project then
2962 Project.Extended_By := Extended_By;
2968 -- Check if the project is already in the tree
2970 Project := No_Project;
2973 List : Project_List := In_Tree.Projects;
2974 Path : constant Path_Name_Type :=
2975 Path_Name_Of (From_Project_Node,
2976 From_Project_Node_Tree);
2979 while List /= null loop
2980 if List.Project.Path.Display_Name = Path then
2981 Project := List.Project;
2989 if Project = No_Project then
2993 (Project_Qualifier_Of
2994 (From_Project_Node, From_Project_Node_Tree)));
2996 -- Note that at this point we do not know yet if the project
2997 -- has been withed from an encapsulated library or not.
3000 new Project_List_Element'
3001 (Project => Project,
3002 From_Encapsulated_Lib => False,
3003 Next => In_Tree.Projects);
3006 -- Keep track of this point
3008 Mark := In_Tree.Projects;
3010 Processed_Projects.Set (Name, Project);
3012 Project.Name := Name;
3013 Project.Display_Name := Display_Name;
3015 Get_Name_String (Name);
3017 -- If name starts with the virtual prefix, flag the project as
3018 -- being a virtual extending project.
3020 if Name_Len > Virtual_Prefix'Length
3022 Name_Buffer (1 .. Virtual_Prefix'Length) = Virtual_Prefix
3024 Project.Virtual := True;
3027 Project.Path.Display_Name :=
3028 Path_Name_Of (From_Project_Node, From_Project_Node_Tree);
3029 Get_Name_String (Project.Path.Display_Name);
3030 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3031 Project.Path.Name := Name_Find;
3034 Location_Of (From_Project_Node, From_Project_Node_Tree);
3036 Project.Directory.Display_Name :=
3037 Directory_Of (From_Project_Node, From_Project_Node_Tree);
3038 Get_Name_String (Project.Directory.Display_Name);
3039 Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
3040 Project.Directory.Name := Name_Find;
3042 Project.Extended_By := Extended_By;
3047 Name_Id (Project.Directory.Display_Name),
3050 Prj.Attr.Attribute_First,
3051 Project_Level => True);
3053 Process_Imported_Projects (Imported, Limited_With => False);
3055 if Project.Qualifier = Aggregate then
3056 Initialize_And_Copy (Child_Env, Copy_From => Env);
3058 elsif Project.Qualifier = Aggregate_Library then
3060 -- The child environment is the same as the current one
3065 -- No need to initialize Child_Env, since it will not be
3066 -- used anyway by Process_Declarative_Items (only the root
3067 -- aggregate can modify it, and it is never read anyway).
3073 Project_Declaration_Of
3074 (From_Project_Node, From_Project_Node_Tree);
3077 (In_Tree => In_Tree,
3078 Project => Project.Extends,
3079 Packages_To_Check => Packages_To_Check,
3080 From_Project_Node =>
3082 (Declaration_Node, From_Project_Node_Tree),
3083 From_Project_Node_Tree => From_Project_Node_Tree,
3085 Extended_By => Project,
3086 From_Encapsulated_Lib => From_Encapsulated_Lib,
3087 On_New_Tree_Loaded => On_New_Tree_Loaded);
3089 Process_Declarative_Items
3090 (Project => Project,
3092 From_Project_Node => From_Project_Node,
3093 Node_Tree => From_Project_Node_Tree,
3096 Item => First_Declarative_Item_Of
3097 (Declaration_Node, From_Project_Node_Tree),
3098 Child_Env => Child_Env);
3100 if Project.Extends /= No_Project then
3101 Process_Extended_Project;
3104 Process_Imported_Projects (Imported, Limited_With => True);
3106 if Total_Errors_Detected = 0 then
3107 Process_Aggregated_Projects;
3110 -- At this point (after Process_Declarative_Items) we have the
3111 -- attribute values set, we can backtrace In_Tree.Project and
3112 -- set the From_Encapsulated_Library status.
3115 Lib_Standalone : constant Prj.Variable_Value :=
3117 (Snames.Name_Library_Standalone,
3118 Project.Decl.Attributes,
3120 List : Project_List := In_Tree.Projects;
3121 Is_Encapsulated : Boolean;
3124 Get_Name_String (Lib_Standalone.Value);
3125 To_Lower (Name_Buffer (1 .. Name_Len));
3127 Is_Encapsulated := Name_Buffer (1 .. Name_Len) = "encapsulated";
3129 if Is_Encapsulated then
3130 while List /= null and then List /= Mark loop
3131 List.From_Encapsulated_Lib := Is_Encapsulated;
3136 if Total_Errors_Detected = 0 then
3138 -- For an aggregate library we add the aggregated projects
3139 -- as imported ones. This is necessary to give visibility
3140 -- to all sources from the aggregates from the aggregated
3141 -- library projects.
3143 if Project.Qualifier = Aggregate_Library then
3145 L : Aggregated_Project_List;
3147 L := Project.Aggregated_Projects;
3148 while L /= null loop
3149 Project.Imported_Projects :=
3150 new Project_List_Element'
3151 (Project => L.Project,
3152 From_Encapsulated_Lib => Is_Encapsulated,
3154 Project.Imported_Projects);
3162 if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
3167 end Recursive_Process;
3169 -----------------------------
3170 -- Set_Default_Runtime_For --
3171 -----------------------------
3173 procedure Set_Default_Runtime_For (Language : Name_Id; Value : String) is
3175 Name_Len := Value'Length;
3176 Name_Buffer (1 .. Name_Len) := Value;
3177 Runtime_Defaults.Set (Language, Name_Find);
3178 end Set_Default_Runtime_For;