1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2001-2004 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Err_Vars
; use Err_Vars
;
28 with Namet
; use Namet
;
30 with Osint
; use Osint
;
31 with Output
; use Output
;
32 with Prj
.Attr
; use Prj
.Attr
;
33 with Prj
.Com
; use Prj
.Com
;
34 with Prj
.Err
; use Prj
.Err
;
35 with Prj
.Ext
; use Prj
.Ext
;
36 with Prj
.Nmsc
; use Prj
.Nmsc
;
39 with GNAT
.Case_Util
; use GNAT
.Case_Util
;
42 package body Prj
.Proc
is
44 Error_Report
: Put_Line_Access
:= null;
46 package Processed_Projects
is new GNAT
.HTable
.Simple_HTable
47 (Header_Num
=> Header_Num
,
48 Element
=> Project_Id
,
49 No_Element
=> No_Project
,
53 -- This hash table contains all processed projects
55 procedure Add
(To_Exp
: in out Name_Id
; Str
: Name_Id
);
56 -- Concatenate two strings and returns another string if both
57 -- arguments are not null string.
59 procedure Add_Attributes
60 (Project
: Project_Id
;
61 Decl
: in out Declarations
;
62 First
: Attribute_Node_Id
);
63 -- Add all attributes, starting with First, with their default
64 -- values to the package or project with declarations Decl.
67 (Project
: Project_Id
;
68 From_Project_Node
: Project_Node_Id
;
70 First_Term
: Project_Node_Id
;
71 Kind
: Variable_Kind
) return Variable_Value
;
72 -- From N_Expression project node From_Project_Node, compute the value
73 -- of an expression and return it as a Variable_Value.
75 function Imported_Or_Extended_Project_From
76 (Project
: Project_Id
;
77 With_Name
: Name_Id
) return Project_Id
;
78 -- Find an imported or extended project of Project whose name is With_Name
81 (Project
: Project_Id
;
82 With_Name
: Name_Id
) return Package_Id
;
83 -- Find the package of Project whose name is With_Name
85 procedure Process_Declarative_Items
86 (Project
: Project_Id
;
87 From_Project_Node
: Project_Node_Id
;
89 Item
: Project_Node_Id
);
90 -- Process declarative items starting with From_Project_Node, and put them
91 -- in declarations Decl. This is a recursive procedure; it calls itself for
92 -- a package declaration or a case construction.
94 procedure Recursive_Process
95 (Project
: out Project_Id
;
96 From_Project_Node
: Project_Node_Id
;
97 Extended_By
: Project_Id
);
98 -- Process project with node From_Project_Node in the tree.
99 -- Do nothing if From_Project_Node is Empty_Node.
100 -- If project has already been processed, simply return its project id.
101 -- Otherwise create a new project id, mark it as processed, call itself
102 -- recursively for all imported projects and a extended project, if any.
103 -- Then process the declarative items of the project.
106 (Project
: in out Project_Id
;
107 Process_Languages
: Languages_Processed
;
108 Follow_Links
: Boolean);
109 -- Set all projects to not checked, then call Recursive_Check for the
110 -- main project Project. Project is set to No_Project if errors occurred.
111 -- See Prj.Nmsc.Ada_Check for information on Follow_Links.
113 procedure Recursive_Check
114 (Project
: Project_Id
;
115 Process_Languages
: Languages_Processed
;
116 Follow_Links
: Boolean);
117 -- If Project is not marked as checked, mark it as checked, call
118 -- Check_Naming_Scheme for the project, then call itself for a
119 -- possible extended project and all the imported projects of Project.
120 -- See Prj.Nmsc.Ada_Check for information on Follow_Links
126 procedure Add
(To_Exp
: in out Name_Id
; Str
: Name_Id
) is
128 if To_Exp
= Types
.No_Name
or else To_Exp
= Empty_String
then
130 -- To_Exp is nil or empty. The result is Str.
134 -- If Str is nil, then do not change To_Ext
136 elsif Str
/= No_Name
and then Str
/= Empty_String
then
138 S
: constant String := Get_Name_String
(Str
);
141 Get_Name_String
(To_Exp
);
142 Add_Str_To_Name_Buffer
(S
);
152 procedure Add_Attributes
153 (Project
: Project_Id
;
154 Decl
: in out Declarations
;
155 First
: Attribute_Node_Id
)
157 The_Attribute
: Attribute_Node_Id
:= First
;
158 Attribute_Data
: Attribute_Record
;
161 while The_Attribute
/= Empty_Attribute
loop
162 Attribute_Data
:= Attributes
.Table
(The_Attribute
);
164 if Attribute_Data
.Kind_2
= Single
then
166 New_Attribute
: Variable_Value
;
169 case Attribute_Data
.Kind_1
is
171 -- Undefined should not happen
175 (False, "attribute with an undefined kind");
178 -- Single attributes have a default value of empty string
184 Location
=> No_Location
,
186 Value
=> Empty_String
,
189 -- List attributes have a default value of nil list
195 Location
=> No_Location
,
197 Values
=> Nil_String
);
201 Variable_Elements
.Increment_Last
;
202 Variable_Elements
.Table
(Variable_Elements
.Last
) :=
203 (Next
=> Decl
.Attributes
,
204 Name
=> Attribute_Data
.Name
,
205 Value
=> New_Attribute
);
206 Decl
.Attributes
:= Variable_Elements
.Last
;
210 The_Attribute
:= Attributes
.Table
(The_Attribute
).Next
;
219 (Project
: in out Project_Id
;
220 Process_Languages
: Languages_Processed
;
221 Follow_Links
: Boolean) is
223 -- Make sure that all projects are marked as not checked
225 for Index
in 1 .. Projects
.Last
loop
226 Projects
.Table
(Index
).Checked
:= False;
229 Recursive_Check
(Project
, Process_Languages
, Follow_Links
);
238 (Project
: Project_Id
;
239 From_Project_Node
: Project_Node_Id
;
241 First_Term
: Project_Node_Id
;
242 Kind
: Variable_Kind
) return Variable_Value
244 The_Term
: Project_Node_Id
:= First_Term
;
245 -- The term in the expression list
247 The_Current_Term
: Project_Node_Id
:= Empty_Node
;
248 -- The current term node id
250 Result
: Variable_Value
(Kind
=> Kind
);
251 -- The returned result
253 Last
: String_List_Id
:= Nil_String
;
254 -- Reference to the last string elements in Result, when Kind is List.
257 Result
.Project
:= Project
;
258 Result
.Location
:= Location_Of
(First_Term
);
260 -- Process each term of the expression, starting with First_Term
262 while The_Term
/= Empty_Node
loop
263 The_Current_Term
:= Current_Term
(The_Term
);
265 case Kind_Of
(The_Current_Term
) is
267 when N_Literal_String
=>
273 -- Should never happen
275 pragma Assert
(False, "Undefined expression kind");
279 Add
(Result
.Value
, String_Value_Of
(The_Current_Term
));
280 Result
.Index
:= Source_Index_Of
(The_Current_Term
);
284 String_Elements
.Increment_Last
;
286 if Last
= Nil_String
then
288 -- This can happen in an expression such as
291 Result
.Values
:= String_Elements
.Last
;
294 String_Elements
.Table
(Last
).Next
:=
295 String_Elements
.Last
;
298 Last
:= String_Elements
.Last
;
299 String_Elements
.Table
(Last
) :=
300 (Value
=> String_Value_Of
(The_Current_Term
),
301 Index
=> Source_Index_Of
(The_Current_Term
),
302 Display_Value
=> No_Name
,
303 Location
=> Location_Of
(The_Current_Term
),
309 when N_Literal_String_List
=>
312 String_Node
: Project_Node_Id
:=
313 First_Expression_In_List
(The_Current_Term
);
315 Value
: Variable_Value
;
318 if String_Node
/= Empty_Node
then
320 -- If String_Node is nil, it is an empty list,
321 -- there is nothing to do
325 From_Project_Node
=> From_Project_Node
,
327 First_Term
=> Tree
.First_Term
(String_Node
),
329 String_Elements
.Increment_Last
;
331 if Result
.Values
= Nil_String
then
333 -- This literal string list is the first term
334 -- in a string list expression
336 Result
.Values
:= String_Elements
.Last
;
339 String_Elements
.Table
(Last
).Next
:=
340 String_Elements
.Last
;
343 Last
:= String_Elements
.Last
;
344 String_Elements
.Table
(Last
) :=
345 (Value
=> Value
.Value
,
346 Display_Value
=> No_Name
,
347 Location
=> Value
.Location
,
350 Index
=> Value
.Index
);
353 -- Add the other element of the literal string list
354 -- one after the other
357 Next_Expression_In_List
(String_Node
);
359 exit when String_Node
= Empty_Node
;
364 From_Project_Node
=> From_Project_Node
,
366 First_Term
=> Tree
.First_Term
(String_Node
),
369 String_Elements
.Increment_Last
;
370 String_Elements
.Table
(Last
).Next
:=
371 String_Elements
.Last
;
372 Last
:= String_Elements
.Last
;
373 String_Elements
.Table
(Last
) :=
374 (Value
=> Value
.Value
,
375 Display_Value
=> No_Name
,
376 Location
=> Value
.Location
,
379 Index
=> Value
.Index
);
386 when N_Variable_Reference | N_Attribute_Reference
=>
389 The_Project
: Project_Id
:= Project
;
390 The_Package
: Package_Id
:= Pkg
;
391 The_Name
: Name_Id
:= No_Name
;
392 The_Variable_Id
: Variable_Id
:= No_Variable
;
393 The_Variable
: Variable_Value
;
394 Term_Project
: constant Project_Node_Id
:=
395 Project_Node_Of
(The_Current_Term
);
396 Term_Package
: constant Project_Node_Id
:=
397 Package_Node_Of
(The_Current_Term
);
398 Index
: Name_Id
:= No_Name
;
401 if Term_Project
/= Empty_Node
and then
402 Term_Project
/= From_Project_Node
404 -- This variable or attribute comes from another project
406 The_Name
:= Name_Of
(Term_Project
);
407 The_Project
:= Imported_Or_Extended_Project_From
409 With_Name
=> The_Name
);
412 if Term_Package
/= Empty_Node
then
414 -- This is an attribute of a package
416 The_Name
:= Name_Of
(Term_Package
);
417 The_Package
:= Projects
.Table
(The_Project
).Decl
.Packages
;
419 while The_Package
/= No_Package
420 and then Packages
.Table
(The_Package
).Name
/= The_Name
422 The_Package
:= Packages
.Table
(The_Package
).Next
;
426 (The_Package
/= No_Package
,
427 "package not found.");
429 elsif Kind_Of
(The_Current_Term
) = N_Attribute_Reference
then
430 The_Package
:= No_Package
;
433 The_Name
:= Name_Of
(The_Current_Term
);
435 if Kind_Of
(The_Current_Term
) = N_Attribute_Reference
then
436 Index
:= Associative_Array_Index_Of
(The_Current_Term
);
439 -- If it is not an associative array attribute
441 if Index
= No_Name
then
443 -- It is not an associative array attribute
445 if The_Package
/= No_Package
then
447 -- First, if there is a package, look into the package
450 Kind_Of
(The_Current_Term
) = N_Variable_Reference
453 Packages
.Table
(The_Package
).Decl
.Variables
;
457 Packages
.Table
(The_Package
).Decl
.Attributes
;
460 while The_Variable_Id
/= No_Variable
462 Variable_Elements
.Table
(The_Variable_Id
).Name
/=
466 Variable_Elements
.Table
(The_Variable_Id
).Next
;
471 if The_Variable_Id
= No_Variable
then
473 -- If we have not found it, look into the project
476 Kind_Of
(The_Current_Term
) = N_Variable_Reference
479 Projects
.Table
(The_Project
).Decl
.Variables
;
483 Projects
.Table
(The_Project
).Decl
.Attributes
;
486 while The_Variable_Id
/= No_Variable
488 Variable_Elements
.Table
(The_Variable_Id
).Name
/=
492 Variable_Elements
.Table
(The_Variable_Id
).Next
;
497 pragma Assert
(The_Variable_Id
/= No_Variable
,
498 "variable or attribute not found");
500 The_Variable
:= Variable_Elements
.Table
501 (The_Variable_Id
).Value
;
505 -- It is an associative array attribute
508 The_Array
: Array_Id
:= No_Array
;
509 The_Element
: Array_Element_Id
:= No_Array_Element
;
510 Array_Index
: Name_Id
:= No_Name
;
512 if The_Package
/= No_Package
then
514 Packages
.Table
(The_Package
).Decl
.Arrays
;
518 Projects
.Table
(The_Project
).Decl
.Arrays
;
521 while The_Array
/= No_Array
522 and then Arrays
.Table
(The_Array
).Name
/= The_Name
524 The_Array
:= Arrays
.Table
(The_Array
).Next
;
527 if The_Array
/= No_Array
then
528 The_Element
:= Arrays
.Table
(The_Array
).Value
;
530 Get_Name_String
(Index
);
532 if Case_Insensitive
(The_Current_Term
) then
533 To_Lower
(Name_Buffer
(1 .. Name_Len
));
536 Array_Index
:= Name_Find
;
538 while The_Element
/= No_Array_Element
539 and then Array_Elements
.Table
(The_Element
).Index
543 Array_Elements
.Table
(The_Element
).Next
;
548 if The_Element
/= No_Array_Element
then
550 Array_Elements
.Table
(The_Element
).Value
;
554 Expression_Kind_Of
(The_Current_Term
) = List
559 Location
=> No_Location
,
561 Values
=> Nil_String
);
567 Location
=> No_Location
,
569 Value
=> Empty_String
,
580 -- Should never happen
582 pragma Assert
(False, "undefined expression kind");
587 case The_Variable
.Kind
is
593 Add
(Result
.Value
, The_Variable
.Value
);
597 -- Should never happen
601 "list cannot appear in single " &
602 "string expression");
607 case The_Variable
.Kind
is
613 String_Elements
.Increment_Last
;
615 if Last
= Nil_String
then
617 -- This can happen in an expression such as
620 Result
.Values
:= String_Elements
.Last
;
623 String_Elements
.Table
(Last
).Next
:=
624 String_Elements
.Last
;
627 Last
:= String_Elements
.Last
;
628 String_Elements
.Table
(Last
) :=
629 (Value
=> The_Variable
.Value
,
630 Display_Value
=> No_Name
,
631 Location
=> Location_Of
(The_Current_Term
),
639 The_List
: String_List_Id
:=
643 while The_List
/= Nil_String
loop
644 String_Elements
.Increment_Last
;
646 if Last
= Nil_String
then
647 Result
.Values
:= String_Elements
.Last
;
650 String_Elements
.Table
(Last
).Next
:=
651 String_Elements
.Last
;
655 Last
:= String_Elements
.Last
;
656 String_Elements
.Table
(Last
) :=
658 String_Elements
.Table
660 Display_Value
=> No_Name
,
661 Location
=> Location_Of
667 String_Elements
.Table
(The_List
).Next
;
674 when N_External_Value
=>
676 (String_Value_Of
(External_Reference_Of
(The_Current_Term
)));
679 Name
: constant Name_Id
:= Name_Find
;
680 Default
: Name_Id
:= No_Name
;
681 Value
: Name_Id
:= No_Name
;
683 Default_Node
: constant Project_Node_Id
:=
684 External_Default_Of
(The_Current_Term
);
687 if Default_Node
/= Empty_Node
then
688 Default
:= String_Value_Of
(Default_Node
);
691 Value
:= Prj
.Ext
.Value_Of
(Name
, Default
);
693 if Value
= No_Name
then
694 if not Opt
.Quiet_Output
then
695 if Error_Report
= null then
697 ("?undefined external reference",
698 Location_Of
(The_Current_Term
));
702 ("warning: """ & Get_Name_String
(Name
) &
703 """ is an undefined external reference",
708 Value
:= Empty_String
;
718 Add
(Result
.Value
, Value
);
721 String_Elements
.Increment_Last
;
723 if Last
= Nil_String
then
724 Result
.Values
:= String_Elements
.Last
;
727 String_Elements
.Table
(Last
).Next
:=
728 String_Elements
.Last
;
731 Last
:= String_Elements
.Last
;
732 String_Elements
.Table
(Last
) :=
734 Display_Value
=> No_Name
,
735 Location
=> Location_Of
(The_Current_Term
),
745 -- Should never happen
749 "illegal node kind in an expression");
754 The_Term
:= Next_Term
(The_Term
);
760 ---------------------------------------
761 -- Imported_Or_Extended_Project_From --
762 ---------------------------------------
764 function Imported_Or_Extended_Project_From
765 (Project
: Project_Id
;
766 With_Name
: Name_Id
) return Project_Id
768 Data
: constant Project_Data
:= Projects
.Table
(Project
);
769 List
: Project_List
:= Data
.Imported_Projects
;
772 -- First check if it is the name of a extended project
774 if Data
.Extends
/= No_Project
775 and then Projects
.Table
(Data
.Extends
).Name
= With_Name
780 -- Then check the name of each imported project
782 while List
/= Empty_Project_List
785 (Project_Lists
.Table
(List
).Project
).Name
/= With_Name
788 List
:= Project_Lists
.Table
(List
).Next
;
792 (List
/= Empty_Project_List
,
793 "project not found");
795 return Project_Lists
.Table
(List
).Project
;
797 end Imported_Or_Extended_Project_From
;
803 function Package_From
804 (Project
: Project_Id
;
805 With_Name
: Name_Id
) return Package_Id
807 Data
: constant Project_Data
:= Projects
.Table
(Project
);
808 Result
: Package_Id
:= Data
.Decl
.Packages
;
811 -- Check the name of each existing package of Project
813 while Result
/= No_Package
815 Packages
.Table
(Result
).Name
/= With_Name
817 Result
:= Packages
.Table
(Result
).Next
;
820 if Result
= No_Package
then
821 -- Should never happen
822 Write_Line
("package """ & Get_Name_String
(With_Name
) &
836 (Project
: out Project_Id
;
837 Success
: out Boolean;
838 From_Project_Node
: Project_Node_Id
;
839 Report_Error
: Put_Line_Access
;
840 Process_Languages
: Languages_Processed
:= Ada_Language
;
841 Follow_Links
: Boolean := True)
844 Extending
: Project_Id
;
845 Extending2
: Project_Id
;
848 Error_Report
:= Report_Error
;
851 -- Make sure there is no projects in the data structure
853 Projects
.Set_Last
(No_Project
);
854 Processed_Projects
.Reset
;
856 -- And process the main project and all of the projects it depends on,
861 From_Project_Node
=> From_Project_Node
,
862 Extended_By
=> No_Project
);
864 if Project
/= No_Project
then
865 Check
(Project
, Process_Languages
, Follow_Links
);
868 -- If main project is an extending all project, set the object
869 -- directory of all virtual extending projects to the object directory
870 -- of the main project.
872 if Project
/= No_Project
873 and then Is_Extending_All
(From_Project_Node
)
876 Object_Dir
: constant Name_Id
:=
877 Projects
.Table
(Project
).Object_Directory
;
879 for Index
in Projects
.First
.. Projects
.Last
loop
880 if Projects
.Table
(Index
).Virtual
then
881 Projects
.Table
(Index
).Object_Directory
:= Object_Dir
;
887 -- Check that no extending project shares its object directory with
888 -- the project(s) it extends.
890 if Project
/= No_Project
then
891 for Proj
in 1 .. Projects
.Last
loop
892 Extending
:= Projects
.Table
(Proj
).Extended_By
;
894 if Extending
/= No_Project
then
895 Obj_Dir
:= Projects
.Table
(Proj
).Object_Directory
;
897 -- Check that a project being extended does not share its
898 -- object directory with any project that extends it, directly
899 -- or indirectly, including a virtual extending project.
901 -- Start with the project directly extending it
903 Extending2
:= Extending
;
905 while Extending2
/= No_Project
loop
906 if Projects
.Table
(Extending2
).Sources_Present
908 Projects
.Table
(Extending2
).Object_Directory
= Obj_Dir
910 if Projects
.Table
(Extending2
).Virtual
then
911 Error_Msg_Name_1
:= Projects
.Table
(Proj
).Name
;
913 if Error_Report
= null then
915 ("project % cannot be extended by a virtual " &
916 "project with the same object directory",
917 Projects
.Table
(Proj
).Location
);
922 Get_Name_String
(Error_Msg_Name_1
) &
923 """ cannot be extended by a virtual " &
924 "project with the same object directory",
930 Projects
.Table
(Extending2
).Name
;
931 Error_Msg_Name_2
:= Projects
.Table
(Proj
).Name
;
933 if Error_Report
= null then
935 ("project % cannot extend project %",
936 Projects
.Table
(Extending2
).Location
);
938 ("\they share the same object directory",
939 Projects
.Table
(Extending2
).Location
);
944 Get_Name_String
(Error_Msg_Name_1
) &
945 """ cannot extend project """ &
946 Get_Name_String
(Error_Msg_Name_2
) & """",
949 ("they share the same object directory",
955 -- Continue with the next extending project, if any
957 Extending2
:= Projects
.Table
(Extending2
).Extended_By
;
963 Success
:= Total_Errors_Detected
<= 0;
966 -------------------------------
967 -- Process_Declarative_Items --
968 -------------------------------
970 procedure Process_Declarative_Items
971 (Project
: Project_Id
;
972 From_Project_Node
: Project_Node_Id
;
974 Item
: Project_Node_Id
)
976 Current_Declarative_Item
: Project_Node_Id
:= Item
;
977 Current_Item
: Project_Node_Id
:= Empty_Node
;
980 -- For each declarative item
982 while Current_Declarative_Item
/= Empty_Node
loop
986 Current_Item
:= Current_Item_Node
(Current_Declarative_Item
);
988 -- And set Current_Declarative_Item to the next declarative item
989 -- ready for the next iteration.
991 Current_Declarative_Item
:= Next_Declarative_Item
992 (Current_Declarative_Item
);
994 case Kind_Of
(Current_Item
) is
996 when N_Package_Declaration
=>
997 -- Do not process a package declaration that should be ignored
999 if Expression_Kind_Of
(Current_Item
) /= Ignored
then
1000 -- Create the new package
1002 Packages
.Increment_Last
;
1005 New_Pkg
: constant Package_Id
:= Packages
.Last
;
1006 The_New_Package
: Package_Element
;
1008 Project_Of_Renamed_Package
: constant Project_Node_Id
:=
1009 Project_Of_Renamed_Package_Of
1013 -- Set the name of the new package
1015 The_New_Package
.Name
:= Name_Of
(Current_Item
);
1017 -- Insert the new package in the appropriate list
1019 if Pkg
/= No_Package
then
1020 The_New_Package
.Next
:=
1021 Packages
.Table
(Pkg
).Decl
.Packages
;
1022 Packages
.Table
(Pkg
).Decl
.Packages
:= New_Pkg
;
1024 The_New_Package
.Next
:=
1025 Projects
.Table
(Project
).Decl
.Packages
;
1026 Projects
.Table
(Project
).Decl
.Packages
:= New_Pkg
;
1029 Packages
.Table
(New_Pkg
) := The_New_Package
;
1031 if Project_Of_Renamed_Package
/= Empty_Node
then
1036 Project_Name
: constant Name_Id
:=
1038 (Project_Of_Renamed_Package
);
1040 Renamed_Project
: constant Project_Id
:=
1041 Imported_Or_Extended_Project_From
1042 (Project
, Project_Name
);
1044 Renamed_Package
: constant Package_Id
:=
1047 Name_Of
(Current_Item
));
1050 -- For a renamed package, set declarations to
1051 -- the declarations of the renamed package.
1053 Packages
.Table
(New_Pkg
).Decl
:=
1054 Packages
.Table
(Renamed_Package
).Decl
;
1057 -- Standard package declaration, not renaming
1060 -- Set the default values of the attributes
1064 Packages
.Table
(New_Pkg
).Decl
,
1065 Package_Attributes
.Table
1066 (Package_Id_Of
(Current_Item
)).First_Attribute
);
1068 -- And process declarative items of the new package
1070 Process_Declarative_Items
1071 (Project
=> Project
,
1072 From_Project_Node
=> From_Project_Node
,
1074 Item
=> First_Declarative_Item_Of
1080 when N_String_Type_Declaration
=>
1082 -- There is nothing to process
1086 when N_Attribute_Declaration |
1087 N_Typed_Variable_Declaration |
1088 N_Variable_Declaration
=>
1090 if Expression_Of
(Current_Item
) = Empty_Node
then
1092 -- It must be a full associative array attribute declaration
1095 Current_Item_Name
: constant Name_Id
:=
1096 Name_Of
(Current_Item
);
1097 -- The name of the attribute
1099 New_Array
: Array_Id
;
1100 -- The new associative array created
1102 Orig_Array
: Array_Id
;
1103 -- The associative array value
1105 Orig_Project_Name
: Name_Id
:= No_Name
;
1106 -- The name of the project where the associative array
1109 Orig_Project
: Project_Id
:= No_Project
;
1110 -- The id of the project where the associative array
1113 Orig_Package_Name
: Name_Id
:= No_Name
;
1114 -- The name of the package, if any, where the associative
1117 Orig_Package
: Package_Id
:= No_Package
;
1118 -- The id of the package, if any, where the associative
1121 New_Element
: Array_Element_Id
:= No_Array_Element
;
1122 -- Id of a new array element created
1124 Prev_Element
: Array_Element_Id
:= No_Array_Element
;
1125 -- Last new element id created
1127 Orig_Element
: Array_Element_Id
:= No_Array_Element
;
1128 -- Current array element in the original associative
1131 Next_Element
: Array_Element_Id
:= No_Array_Element
;
1132 -- Id of the array element that follows the new element.
1133 -- This is not always nil, because values for the
1134 -- associative array attribute may already have been
1135 -- declared, and the array elements declared are reused.
1138 -- First, find if the associative array attribute already
1139 -- has elements declared.
1141 if Pkg
/= No_Package
then
1142 New_Array
:= Packages
.Table
(Pkg
).Decl
.Arrays
;
1145 New_Array
:= Projects
.Table
(Project
).Decl
.Arrays
;
1148 while New_Array
/= No_Array
and then
1149 Arrays
.Table
(New_Array
).Name
/= Current_Item_Name
1151 New_Array
:= Arrays
.Table
(New_Array
).Next
;
1154 -- If the attribute has never been declared add new entry
1155 -- in the arrays of the project/package and link it.
1157 if New_Array
= No_Array
then
1158 Arrays
.Increment_Last
;
1159 New_Array
:= Arrays
.Last
;
1161 if Pkg
/= No_Package
then
1162 Arrays
.Table
(New_Array
) :=
1163 (Name
=> Current_Item_Name
,
1164 Value
=> No_Array_Element
,
1165 Next
=> Packages
.Table
(Pkg
).Decl
.Arrays
);
1166 Packages
.Table
(Pkg
).Decl
.Arrays
:= New_Array
;
1169 Arrays
.Table
(New_Array
) :=
1170 (Name
=> Current_Item_Name
,
1171 Value
=> No_Array_Element
,
1172 Next
=> Projects
.Table
(Project
).Decl
.Arrays
);
1173 Projects
.Table
(Project
).Decl
.Arrays
:= New_Array
;
1177 -- Find the project where the value is declared
1179 Orig_Project_Name
:=
1180 Name_Of
(Associative_Project_Of
(Current_Item
));
1182 for Index
in Projects
.First
.. Projects
.Last
loop
1183 if Projects
.Table
(Index
).Name
= Orig_Project_Name
then
1184 Orig_Project
:= Index
;
1189 pragma Assert
(Orig_Project
/= No_Project
,
1190 "original project not found");
1192 if Associative_Package_Of
(Current_Item
) = Empty_Node
then
1194 Projects
.Table
(Orig_Project
).Decl
.Arrays
;
1197 -- If in a package, find the package where the
1198 -- value is declared.
1200 Orig_Package_Name
:=
1201 Name_Of
(Associative_Package_Of
(Current_Item
));
1203 Projects
.Table
(Orig_Project
).Decl
.Packages
;
1204 pragma Assert
(Orig_Package
/= No_Package
,
1205 "original package not found");
1207 while Packages
.Table
(Orig_Package
).Name
/=
1210 Orig_Package
:= Packages
.Table
(Orig_Package
).Next
;
1211 pragma Assert
(Orig_Package
/= No_Package
,
1212 "original package not found");
1216 Packages
.Table
(Orig_Package
).Decl
.Arrays
;
1219 -- Now look for the array
1221 while Orig_Array
/= No_Array
and then
1222 Arrays
.Table
(Orig_Array
).Name
/= Current_Item_Name
1224 Orig_Array
:= Arrays
.Table
(Orig_Array
).Next
;
1227 if Orig_Array
= No_Array
then
1228 if Error_Report
= null then
1230 ("associative array value cannot be found",
1231 Location_Of
(Current_Item
));
1235 ("associative array value cannot be found",
1240 Orig_Element
:= Arrays
.Table
(Orig_Array
).Value
;
1242 -- Copy each array element
1244 while Orig_Element
/= No_Array_Element
loop
1245 -- If it is the first element ...
1247 if Prev_Element
= No_Array_Element
then
1248 -- And there is no array element declared yet,
1249 -- create a new first array element.
1251 if Arrays
.Table
(New_Array
).Value
=
1254 Array_Elements
.Increment_Last
;
1255 New_Element
:= Array_Elements
.Last
;
1256 Arrays
.Table
(New_Array
).Value
:= New_Element
;
1257 Next_Element
:= No_Array_Element
;
1259 -- Otherwise, the new element is the first
1262 New_Element
:= Arrays
.Table
(New_Array
).Value
;
1264 Array_Elements
.Table
(New_Element
).Next
;
1267 -- Otherwise, reuse an existing element, or create
1268 -- one if necessary.
1272 Array_Elements
.Table
(Prev_Element
).Next
;
1274 if Next_Element
= No_Array_Element
then
1275 Array_Elements
.Increment_Last
;
1276 New_Element
:= Array_Elements
.Last
;
1279 New_Element
:= Next_Element
;
1281 Array_Elements
.Table
(New_Element
).Next
;
1285 -- Copy the value of the element
1287 Array_Elements
.Table
(New_Element
) :=
1288 Array_Elements
.Table
(Orig_Element
);
1289 Array_Elements
.Table
(New_Element
).Value
.Project
:=
1292 -- Adjust the Next link
1294 Array_Elements
.Table
(New_Element
).Next
:=
1297 -- Adjust the previous id for the next element
1299 Prev_Element
:= New_Element
;
1301 -- Go to the next element in the original array
1303 Array_Elements
.Table
(Orig_Element
).Next
;
1306 -- Make sure that the array ends here, in case there
1307 -- previously a greater number of elements.
1309 Array_Elements
.Table
(New_Element
).Next
:=
1314 -- Declarations other that full associative arrays
1318 New_Value
: constant Variable_Value
:=
1320 (Project
=> Project
,
1321 From_Project_Node
=> From_Project_Node
,
1324 Tree
.First_Term
(Expression_Of
1327 Expression_Kind_Of
(Current_Item
));
1328 -- The expression value
1330 The_Variable
: Variable_Id
:= No_Variable
;
1332 Current_Item_Name
: constant Name_Id
:=
1333 Name_Of
(Current_Item
);
1336 -- Process a typed variable declaration
1339 Kind_Of
(Current_Item
) = N_Typed_Variable_Declaration
1341 -- Report an error for an empty string
1343 if New_Value
.Value
= Empty_String
then
1344 Error_Msg_Name_1
:= Name_Of
(Current_Item
);
1346 if Error_Report
= null then
1348 ("no value defined for %",
1349 Location_Of
(Current_Item
));
1353 ("no value defined for " &
1354 Get_Name_String
(Error_Msg_Name_1
),
1360 Current_String
: Project_Node_Id
:=
1361 First_Literal_String
1366 -- Loop through all the valid strings for
1367 -- the string type and compare to the string
1370 while Current_String
/= Empty_Node
1371 and then String_Value_Of
(Current_String
) /=
1375 Next_Literal_String
(Current_String
);
1378 -- Report an error if the string value is not
1379 -- one for the string type.
1381 if Current_String
= Empty_Node
then
1382 Error_Msg_Name_1
:= New_Value
.Value
;
1383 Error_Msg_Name_2
:= Name_Of
(Current_Item
);
1385 if Error_Report
= null then
1387 ("value { is illegal for typed string %",
1388 Location_Of
(Current_Item
));
1393 Get_Name_String
(Error_Msg_Name_1
) &
1394 """ is illegal for typed string """ &
1395 Get_Name_String
(Error_Msg_Name_2
) &
1404 if Kind_Of
(Current_Item
) /= N_Attribute_Declaration
1406 Associative_Array_Index_Of
(Current_Item
) = No_Name
1408 -- Case of a variable declaration or of a not
1409 -- associative array attribute.
1411 -- First, find the list where to find the variable
1415 Kind_Of
(Current_Item
) = N_Attribute_Declaration
1417 if Pkg
/= No_Package
then
1419 Packages
.Table
(Pkg
).Decl
.Attributes
;
1423 Projects
.Table
(Project
).Decl
.Attributes
;
1427 if Pkg
/= No_Package
then
1429 Packages
.Table
(Pkg
).Decl
.Variables
;
1433 Projects
.Table
(Project
).Decl
.Variables
;
1438 -- Loop through the list, to find if it has already
1442 The_Variable
/= No_Variable
1444 Variable_Elements
.Table
(The_Variable
).Name
/=
1448 Variable_Elements
.Table
(The_Variable
).Next
;
1451 -- If it has not been declared, create a new entry
1454 if The_Variable
= No_Variable
then
1455 -- All single string attribute should already have
1456 -- been declared with a default empty string value.
1459 (Kind_Of
(Current_Item
) /=
1460 N_Attribute_Declaration
,
1461 "illegal attribute declaration");
1463 Variable_Elements
.Increment_Last
;
1464 The_Variable
:= Variable_Elements
.Last
;
1466 -- Put the new variable in the appropriate list
1468 if Pkg
/= No_Package
then
1469 Variable_Elements
.Table
(The_Variable
) :=
1471 Packages
.Table
(Pkg
).Decl
.Variables
,
1472 Name
=> Current_Item_Name
,
1473 Value
=> New_Value
);
1474 Packages
.Table
(Pkg
).Decl
.Variables
:=
1478 Variable_Elements
.Table
(The_Variable
) :=
1480 Projects
.Table
(Project
).Decl
.Variables
,
1481 Name
=> Current_Item_Name
,
1482 Value
=> New_Value
);
1483 Projects
.Table
(Project
).Decl
.Variables
:=
1487 -- If the variable/attribute has already been
1488 -- declared, just change the value.
1491 Variable_Elements
.Table
(The_Variable
).Value
:=
1497 -- Associative array attribute
1499 -- Get the string index
1502 (Associative_Array_Index_Of
(Current_Item
));
1504 -- Put in lower case, if necessary
1506 if Case_Insensitive
(Current_Item
) then
1507 GNAT
.Case_Util
.To_Lower
1508 (Name_Buffer
(1 .. Name_Len
));
1512 The_Array
: Array_Id
;
1514 The_Array_Element
: Array_Element_Id
:=
1517 Index_Name
: constant Name_Id
:= Name_Find
;
1518 -- The name id of the index
1521 -- Look for the array in the appropriate list
1523 if Pkg
/= No_Package
then
1524 The_Array
:= Packages
.Table
(Pkg
).Decl
.Arrays
;
1527 The_Array
:= Projects
.Table
1528 (Project
).Decl
.Arrays
;
1532 The_Array
/= No_Array
1533 and then Arrays
.Table
(The_Array
).Name
/=
1536 The_Array
:= Arrays
.Table
(The_Array
).Next
;
1539 -- If the array cannot be found, create a new
1540 -- entry in the list. As The_Array_Element is
1541 -- initialized to No_Array_Element, a new element
1542 -- will be created automatically later.
1544 if The_Array
= No_Array
then
1545 Arrays
.Increment_Last
;
1546 The_Array
:= Arrays
.Last
;
1548 if Pkg
/= No_Package
then
1549 Arrays
.Table
(The_Array
) :=
1550 (Name
=> Current_Item_Name
,
1551 Value
=> No_Array_Element
,
1552 Next
=> Packages
.Table
(Pkg
).Decl
.Arrays
);
1553 Packages
.Table
(Pkg
).Decl
.Arrays
:= The_Array
;
1556 Arrays
.Table
(The_Array
) :=
1557 (Name
=> Current_Item_Name
,
1558 Value
=> No_Array_Element
,
1560 Projects
.Table
(Project
).Decl
.Arrays
);
1561 Projects
.Table
(Project
).Decl
.Arrays
:=
1565 -- Otherwise, initialize The_Array_Element as the
1566 -- head of the element list.
1569 The_Array_Element
:=
1570 Arrays
.Table
(The_Array
).Value
;
1573 -- Look in the list, if any, to find an element
1574 -- with the same index.
1576 while The_Array_Element
/= No_Array_Element
1578 Array_Elements
.Table
(The_Array_Element
).Index
/=
1581 The_Array_Element
:=
1582 Array_Elements
.Table
(The_Array_Element
).Next
;
1585 -- If no such element were found, create a new
1586 -- one and insert it in the element list, with
1587 -- the propoer value.
1589 if The_Array_Element
= No_Array_Element
then
1590 Array_Elements
.Increment_Last
;
1591 The_Array_Element
:= Array_Elements
.Last
;
1593 Array_Elements
.Table
(The_Array_Element
) :=
1594 (Index
=> Index_Name
,
1595 Src_Index
=> Source_Index_Of
(Current_Item
),
1596 Index_Case_Sensitive
=>
1597 not Case_Insensitive
(Current_Item
),
1599 Next
=> Arrays
.Table
(The_Array
).Value
);
1600 Arrays
.Table
(The_Array
).Value
:=
1603 -- An element with the same index already exists,
1604 -- just replace its value with the new one.
1607 Array_Elements
.Table
(The_Array_Element
).Value
:=
1615 when N_Case_Construction
=>
1617 The_Project
: Project_Id
:= Project
;
1618 -- The id of the project of the case variable
1620 The_Package
: Package_Id
:= Pkg
;
1621 -- The id of the package, if any, of the case variable
1623 The_Variable
: Variable_Value
:= Nil_Variable_Value
;
1624 -- The case variable
1626 Case_Value
: Name_Id
:= No_Name
;
1627 -- The case variable value
1629 Case_Item
: Project_Node_Id
:= Empty_Node
;
1630 Choice_String
: Project_Node_Id
:= Empty_Node
;
1631 Decl_Item
: Project_Node_Id
:= Empty_Node
;
1635 Variable_Node
: constant Project_Node_Id
:=
1636 Case_Variable_Reference_Of
1639 Var_Id
: Variable_Id
:= No_Variable
;
1640 Name
: Name_Id
:= No_Name
;
1643 -- If a project were specified for the case variable,
1646 if Project_Node_Of
(Variable_Node
) /= Empty_Node
then
1647 Name
:= Name_Of
(Project_Node_Of
(Variable_Node
));
1649 Imported_Or_Extended_Project_From
(Project
, Name
);
1652 -- If a package were specified for the case variable,
1655 if Package_Node_Of
(Variable_Node
) /= Empty_Node
then
1656 Name
:= Name_Of
(Package_Node_Of
(Variable_Node
));
1657 The_Package
:= Package_From
(The_Project
, Name
);
1660 Name
:= Name_Of
(Variable_Node
);
1662 -- First, look for the case variable into the package,
1665 if The_Package
/= No_Package
then
1666 Var_Id
:= Packages
.Table
(The_Package
).Decl
.Variables
;
1667 Name
:= Name_Of
(Variable_Node
);
1668 while Var_Id
/= No_Variable
1670 Variable_Elements
.Table
(Var_Id
).Name
/= Name
1672 Var_Id
:= Variable_Elements
.Table
(Var_Id
).Next
;
1676 -- If not found in the package, or if there is no
1677 -- package, look at the project level.
1679 if Var_Id
= No_Variable
1680 and then Package_Node_Of
(Variable_Node
) = Empty_Node
1682 Var_Id
:= Projects
.Table
(The_Project
).Decl
.Variables
;
1683 while Var_Id
/= No_Variable
1685 Variable_Elements
.Table
(Var_Id
).Name
/= Name
1687 Var_Id
:= Variable_Elements
.Table
(Var_Id
).Next
;
1691 if Var_Id
= No_Variable
then
1693 -- Should never happen, because this has already been
1694 -- checked during parsing.
1696 Write_Line
("variable """ &
1697 Get_Name_String
(Name
) &
1699 raise Program_Error
;
1702 -- Get the case variable
1704 The_Variable
:= Variable_Elements
.Table
(Var_Id
).Value
;
1706 if The_Variable
.Kind
/= Single
then
1708 -- Should never happen, because this has already been
1709 -- checked during parsing.
1711 Write_Line
("variable""" &
1712 Get_Name_String
(Name
) &
1713 """ is not a single string variable");
1714 raise Program_Error
;
1717 -- Get the case variable value
1718 Case_Value
:= The_Variable
.Value
;
1721 -- Now look into all the case items of the case construction
1723 Case_Item
:= First_Case_Item_Of
(Current_Item
);
1725 while Case_Item
/= Empty_Node
loop
1726 Choice_String
:= First_Choice_Of
(Case_Item
);
1728 -- When Choice_String is nil, it means that it is
1729 -- the "when others =>" alternative.
1731 if Choice_String
= Empty_Node
then
1732 Decl_Item
:= First_Declarative_Item_Of
(Case_Item
);
1733 exit Case_Item_Loop
;
1736 -- Look into all the alternative of this case item
1739 while Choice_String
/= Empty_Node
loop
1741 Case_Value
= String_Value_Of
(Choice_String
)
1744 First_Declarative_Item_Of
(Case_Item
);
1745 exit Case_Item_Loop
;
1749 Next_Literal_String
(Choice_String
);
1750 end loop Choice_Loop
;
1751 Case_Item
:= Next_Case_Item
(Case_Item
);
1752 end loop Case_Item_Loop
;
1754 -- If there is an alternative, then we process it
1756 if Decl_Item
/= Empty_Node
then
1757 Process_Declarative_Items
1758 (Project
=> Project
,
1759 From_Project_Node
=> From_Project_Node
,
1767 -- Should never happen
1769 Write_Line
("Illegal declarative item: " &
1770 Project_Node_Kind
'Image (Kind_Of
(Current_Item
)));
1771 raise Program_Error
;
1774 end Process_Declarative_Items
;
1776 ---------------------
1777 -- Recursive_Check --
1778 ---------------------
1780 procedure Recursive_Check
1781 (Project
: Project_Id
;
1782 Process_Languages
: Languages_Processed
;
1783 Follow_Links
: Boolean)
1785 Data
: Project_Data
;
1786 Imported_Project_List
: Project_List
:= Empty_Project_List
;
1789 -- Do nothing if Project is No_Project, or Project has already
1790 -- been marked as checked.
1792 if Project
/= No_Project
1793 and then not Projects
.Table
(Project
).Checked
1795 -- Mark project as checked, to avoid infinite recursion in
1796 -- ill-formed trees, where a project imports itself.
1798 Projects
.Table
(Project
).Checked
:= True;
1800 Data
:= Projects
.Table
(Project
);
1802 -- Call itself for a possible extended project.
1803 -- (if there is no extended project, then nothing happens).
1805 Recursive_Check
(Data
.Extends
, Process_Languages
, Follow_Links
);
1807 -- Call itself for all imported projects
1809 Imported_Project_List
:= Data
.Imported_Projects
;
1810 while Imported_Project_List
/= Empty_Project_List
loop
1812 (Project_Lists
.Table
(Imported_Project_List
).Project
,
1813 Process_Languages
, Follow_Links
);
1814 Imported_Project_List
:=
1815 Project_Lists
.Table
(Imported_Project_List
).Next
;
1818 if Opt
.Verbose_Mode
then
1819 Write_Str
("Checking project file """);
1820 Write_Str
(Get_Name_String
(Data
.Name
));
1824 case Process_Languages
is
1825 when Ada_Language
=>
1826 Prj
.Nmsc
.Ada_Check
(Project
, Error_Report
, Follow_Links
);
1828 when Other_Languages
=>
1829 Prj
.Nmsc
.Other_Languages_Check
(Project
, Error_Report
);
1832 end Recursive_Check
;
1834 -----------------------
1835 -- Recursive_Process --
1836 -----------------------
1838 procedure Recursive_Process
1839 (Project
: out Project_Id
;
1840 From_Project_Node
: Project_Node_Id
;
1841 Extended_By
: Project_Id
)
1843 With_Clause
: Project_Node_Id
;
1846 if From_Project_Node
= Empty_Node
then
1847 Project
:= No_Project
;
1851 Processed_Data
: Project_Data
:= Empty_Project
;
1852 Imported
: Project_List
:= Empty_Project_List
;
1853 Declaration_Node
: Project_Node_Id
:= Empty_Node
;
1854 Name
: constant Name_Id
:= Name_Of
(From_Project_Node
);
1857 Project
:= Processed_Projects
.Get
(Name
);
1859 if Project
/= No_Project
then
1863 Projects
.Increment_Last
;
1864 Project
:= Projects
.Last
;
1865 Processed_Projects
.Set
(Name
, Project
);
1867 Processed_Data
.Name
:= Name
;
1869 Get_Name_String
(Name
);
1871 -- If name starts with the virtual prefix, flag the project as
1872 -- being a virtual extending project.
1874 if Name_Len
> Virtual_Prefix
'Length
1875 and then Name_Buffer
(1 .. Virtual_Prefix
'Length) =
1878 Processed_Data
.Virtual
:= True;
1881 Processed_Data
.Display_Path_Name
:=
1882 Path_Name_Of
(From_Project_Node
);
1883 Get_Name_String
(Processed_Data
.Display_Path_Name
);
1884 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1885 Processed_Data
.Path_Name
:= Name_Find
;
1887 Processed_Data
.Location
:= Location_Of
(From_Project_Node
);
1889 Processed_Data
.Display_Directory
:=
1890 Directory_Of
(From_Project_Node
);
1891 Get_Name_String
(Processed_Data
.Display_Directory
);
1892 Canonical_Case_File_Name
(Name_Buffer
(1 .. Name_Len
));
1893 Processed_Data
.Directory
:= Name_Find
;
1895 Processed_Data
.Extended_By
:= Extended_By
;
1896 Processed_Data
.Naming
:= Standard_Naming_Data
;
1898 Add_Attributes
(Project
, Processed_Data
.Decl
, Attribute_First
);
1899 With_Clause
:= First_With_Clause_Of
(From_Project_Node
);
1901 while With_Clause
/= Empty_Node
loop
1903 New_Project
: Project_Id
;
1904 New_Data
: Project_Data
;
1908 (Project
=> New_Project
,
1909 From_Project_Node
=> Project_Node_Of
(With_Clause
),
1910 Extended_By
=> No_Project
);
1911 New_Data
:= Projects
.Table
(New_Project
);
1913 -- If we were the first project to import it,
1914 -- set First_Referred_By to us.
1916 if New_Data
.First_Referred_By
= No_Project
then
1917 New_Data
.First_Referred_By
:= Project
;
1918 Projects
.Table
(New_Project
) := New_Data
;
1921 -- Add this project to our list of imported projects
1923 Project_Lists
.Increment_Last
;
1924 Project_Lists
.Table
(Project_Lists
.Last
) :=
1925 (Project
=> New_Project
, Next
=> Empty_Project_List
);
1927 -- Imported is the id of the last imported project.
1928 -- If it is nil, then this imported project is our first.
1930 if Imported
= Empty_Project_List
then
1931 Processed_Data
.Imported_Projects
:= Project_Lists
.Last
;
1934 Project_Lists
.Table
(Imported
).Next
:= Project_Lists
.Last
;
1937 Imported
:= Project_Lists
.Last
;
1939 With_Clause
:= Next_With_Clause_Of
(With_Clause
);
1943 Declaration_Node
:= Project_Declaration_Of
(From_Project_Node
);
1946 (Project
=> Processed_Data
.Extends
,
1947 From_Project_Node
=> Extended_Project_Of
(Declaration_Node
),
1948 Extended_By
=> Project
);
1950 Projects
.Table
(Project
) := Processed_Data
;
1952 Process_Declarative_Items
1953 (Project
=> Project
,
1954 From_Project_Node
=> From_Project_Node
,
1956 Item
=> First_Declarative_Item_Of
1957 (Declaration_Node
));
1959 -- If it is an extending project, inherit all packages
1960 -- from the extended project that are not explicitely defined
1961 -- or renamed. Also inherit the languages, if attribute Languages
1962 -- is not explicitely defined.
1964 if Processed_Data
.Extends
/= No_Project
then
1965 Processed_Data
:= Projects
.Table
(Project
);
1968 Extended_Pkg
: Package_Id
:=
1970 (Processed_Data
.Extends
).Decl
.Packages
;
1971 Current_Pkg
: Package_Id
;
1972 Element
: Package_Element
;
1973 First
: constant Package_Id
:=
1974 Processed_Data
.Decl
.Packages
;
1975 Attribute1
: Variable_Id
;
1976 Attribute2
: Variable_Id
;
1977 Attr_Value1
: Variable
;
1978 Attr_Value2
: Variable
;
1981 while Extended_Pkg
/= No_Package
loop
1982 Element
:= Packages
.Table
(Extended_Pkg
);
1984 Current_Pkg
:= First
;
1987 exit when Current_Pkg
= No_Package
1988 or else Packages
.Table
(Current_Pkg
).Name
1990 Current_Pkg
:= Packages
.Table
(Current_Pkg
).Next
;
1993 if Current_Pkg
= No_Package
then
1994 Packages
.Increment_Last
;
1995 Current_Pkg
:= Packages
.Last
;
1996 Packages
.Table
(Current_Pkg
) :=
1997 (Name
=> Element
.Name
,
1998 Decl
=> Element
.Decl
,
1999 Parent
=> No_Package
,
2000 Next
=> Processed_Data
.Decl
.Packages
);
2001 Processed_Data
.Decl
.Packages
:= Current_Pkg
;
2004 Extended_Pkg
:= Element
.Next
;
2007 -- Check if attribute Languages is declared in the
2008 -- extending project.
2010 Attribute1
:= Processed_Data
.Decl
.Attributes
;
2011 while Attribute1
/= No_Variable
loop
2012 Attr_Value1
:= Variable_Elements
.Table
(Attribute1
);
2013 exit when Attr_Value1
.Name
= Snames
.Name_Languages
;
2014 Attribute1
:= Attr_Value1
.Next
;
2017 if Attribute1
= No_Variable
or else
2018 Attr_Value1
.Value
.Default
2020 -- Attribute Languages is not declared in the extending
2021 -- project. Check if it is declared in the project being
2025 Projects
.Table
(Processed_Data
.Extends
).Decl
.Attributes
;
2027 while Attribute2
/= No_Variable
loop
2028 Attr_Value2
:= Variable_Elements
.Table
(Attribute2
);
2029 exit when Attr_Value2
.Name
= Snames
.Name_Languages
;
2030 Attribute2
:= Attr_Value2
.Next
;
2033 if Attribute2
/= No_Variable
and then
2034 not Attr_Value2
.Value
.Default
2036 -- As attribute Languages is declared in the project
2037 -- being extended, copy its value for the extending
2040 if Attribute1
= No_Variable
then
2041 Variable_Elements
.Increment_Last
;
2042 Attribute1
:= Variable_Elements
.Last
;
2043 Attr_Value1
.Next
:= Processed_Data
.Decl
.Attributes
;
2044 Processed_Data
.Decl
.Attributes
:= Attribute1
;
2047 Attr_Value1
.Name
:= Snames
.Name_Languages
;
2048 Attr_Value1
.Value
:= Attr_Value2
.Value
;
2049 Variable_Elements
.Table
(Attribute1
) := Attr_Value1
;
2054 Projects
.Table
(Project
) := Processed_Data
;
2058 end Recursive_Process
;