-- --
-- B o d y --
-- --
--- Copyright (C) 2001-2007, Free Software Foundation, Inc. --
+-- Copyright (C) 2001-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
W_Char : Write_Char_Ap := null;
W_Eol : Write_Eol_Ap := null;
W_Str : Write_Str_Ap := null;
- Backward_Compatibility : Boolean)
+ Backward_Compatibility : Boolean;
+ Id : Prj.Project_Id := Prj.No_Project)
is
procedure Print (Node : Project_Node_Id; Indent : Natural);
-- A recursive procedure that traverses a project file tree and outputs
procedure Print (Node : Project_Node_Id; Indent : Natural) is
begin
- if Node /= Empty_Node then
+ if Present (Node) then
case Kind_Of (Node, In_Tree) is
when N_Project =>
pragma Debug (Indicate_Tested (N_Project));
- if First_With_Clause_Of (Node, In_Tree) /= Empty_Node then
+ if Present (First_With_Clause_Of (Node, In_Tree)) then
-- with clause(s)
Print (First_Comment_Before (Node, In_Tree), Indent);
Start_Line (Indent);
Write_String ("project ");
- Output_Name (Name_Of (Node, In_Tree));
+
+ if Id /= Prj.No_Project then
+ Output_Name (Id.Display_Name);
+ else
+ Output_Name (Name_Of (Node, In_Tree));
+ end if;
-- Check if this project extends another project
Indent + Increment);
Start_Line (Indent);
Write_String ("end ");
- Output_Name (Name_Of (Node, In_Tree));
+
+ if Id /= Prj.No_Project then
+ Output_Name (Id.Display_Name);
+ else
+ Output_Name (Name_Of (Node, In_Tree));
+ end if;
+
Write_Line (";");
Print (First_Comment_After_End (Node, In_Tree), Indent);
pragma Debug (Indicate_Tested (N_Project_Declaration));
if
- First_Declarative_Item_Of (Node, In_Tree) /= Empty_Node
+ Present (First_Declarative_Item_Of (Node, In_Tree))
then
Print
(First_Declarative_Item_Of (Node, In_Tree),
First_Literal_String (Node, In_Tree);
begin
- while String_Node /= Empty_Node loop
+ while Present (String_Node) loop
Output_String (String_Value_Of (String_Node, In_Tree));
String_Node :=
Next_Literal_String (String_Node, In_Tree);
- if String_Node /= Empty_Node then
+ if Present (String_Node) then
Write_String (", ");
end if;
end loop;
Output_String (String_Value_Of (Node, In_Tree));
if Source_Index_Of (Node, In_Tree) /= 0 then
- Write_String (" at ");
+ Write_String (" at");
Write_String (Source_Index_Of (Node, In_Tree)'Img);
end if;
Write_String (" (");
Output_String
(Associative_Array_Index_Of (Node, In_Tree));
+ Write_String (")");
+ end if;
+
+ Write_String (" use ");
+
+ if Present (Expression_Of (Node, In_Tree)) then
+ Print (Expression_Of (Node, In_Tree), Indent);
+
+ else
+ -- Full associative array declaration
- if Source_Index_Of (Node, In_Tree) /= 0 then
- Write_String (" at ");
- Write_String (Source_Index_Of (Node, In_Tree)'Img);
+ if
+ Present (Associative_Project_Of (Node, In_Tree))
+ then
+ Output_Name
+ (Name_Of
+ (Associative_Project_Of (Node, In_Tree),
+ In_Tree));
+
+ if
+ Present (Associative_Package_Of (Node, In_Tree))
+ then
+ Write_String (".");
+ Output_Name
+ (Name_Of
+ (Associative_Package_Of (Node, In_Tree),
+ In_Tree));
+ end if;
+
+ elsif
+ Present (Associative_Package_Of (Node, In_Tree))
+ then
+ Output_Name
+ (Name_Of
+ (Associative_Package_Of (Node, In_Tree),
+ In_Tree));
end if;
- Write_String (")");
+ Write_String ("'");
+ Output_Attribute_Name (Name_Of (Node, In_Tree));
+ end if;
+
+ if Source_Index_Of (Node, In_Tree) /= 0 then
+ Write_String (" at");
+ Write_String (Source_Index_Of (Node, In_Tree)'Img);
end if;
- Write_String (" use ");
- Print (Expression_Of (Node, In_Tree), Indent);
Write_String (";");
Write_End_Of_Line_Comment (Node);
Print (First_Comment_After (Node, In_Tree), Indent);
Term : Project_Node_Id := First_Term (Node, In_Tree);
begin
- while Term /= Empty_Node loop
+ while Present (Term) loop
Print (Term, Indent);
Term := Next_Term (Term, In_Tree);
- if Term /= Empty_Node then
+ if Present (Term) then
Write_String (" & ");
end if;
end loop;
First_Expression_In_List (Node, In_Tree);
begin
- while Expression /= Empty_Node loop
+ while Present (Expression) loop
Print (Expression, Indent);
Expression :=
Next_Expression_In_List (Expression, In_Tree);
- if Expression /= Empty_Node then
+ if Present (Expression) then
Write_String (", ");
end if;
end loop;
when N_Variable_Reference =>
pragma Debug (Indicate_Tested (N_Variable_Reference));
- if Project_Node_Of (Node, In_Tree) /= Empty_Node then
+ if Present (Project_Node_Of (Node, In_Tree)) then
Output_Name
(Name_Of (Project_Node_Of (Node, In_Tree), In_Tree));
Write_String (".");
end if;
- if Package_Node_Of (Node, In_Tree) /= Empty_Node then
+ if Present (Package_Node_Of (Node, In_Tree)) then
Output_Name
(Name_Of (Package_Node_Of (Node, In_Tree), In_Tree));
Write_String (".");
Write_String ("external (");
Print (External_Reference_Of (Node, In_Tree), Indent);
- if External_Default_Of (Node, In_Tree) /= Empty_Node then
+ if Present (External_Default_Of (Node, In_Tree)) then
Write_String (", ");
Print (External_Default_Of (Node, In_Tree), Indent);
end if;
when N_Attribute_Reference =>
pragma Debug (Indicate_Tested (N_Attribute_Reference));
- if Project_Node_Of (Node, In_Tree) /= Empty_Node
+ if Present (Project_Node_Of (Node, In_Tree))
and then Project_Node_Of (Node, In_Tree) /= Project
then
Output_Name
(Name_Of (Project_Node_Of (Node, In_Tree), In_Tree));
- if Package_Node_Of (Node, In_Tree) /= Empty_Node then
+ if Present (Package_Node_Of (Node, In_Tree)) then
Write_String (".");
Output_Name
(Name_Of (Package_Node_Of (Node, In_Tree), In_Tree));
end if;
- elsif Package_Node_Of (Node, In_Tree) /= Empty_Node then
+ elsif Present (Package_Node_Of (Node, In_Tree)) then
Output_Name
(Name_Of (Package_Node_Of (Node, In_Tree), In_Tree));
begin
Case_Item := First_Case_Item_Of (Node, In_Tree);
- while Case_Item /= Empty_Node loop
- if First_Declarative_Item_Of (Case_Item, In_Tree) /=
- Empty_Node
- or else not Eliminate_Empty_Case_Constructions
+ while Present (Case_Item) loop
+ if Present
+ (First_Declarative_Item_Of (Case_Item, In_Tree))
+ or else not Eliminate_Empty_Case_Constructions
then
Is_Non_Empty := True;
exit;
Case_Item : Project_Node_Id :=
First_Case_Item_Of (Node, In_Tree);
begin
- while Case_Item /= Empty_Node loop
+ while Present (Case_Item) loop
pragma Assert
(Kind_Of (Case_Item, In_Tree) = N_Case_Item);
Print (Case_Item, Indent + Increment);
when N_Case_Item =>
pragma Debug (Indicate_Tested (N_Case_Item));
- if First_Declarative_Item_Of (Node, In_Tree) /= Empty_Node
+ if Present (First_Declarative_Item_Of (Node, In_Tree))
or else not Eliminate_Empty_Case_Constructions
then
Write_Empty_Line;
Start_Line (Indent);
Write_String ("when ");
- if First_Choice_Of (Node, In_Tree) = Empty_Node then
+ if No (First_Choice_Of (Node, In_Tree)) then
Write_String ("others");
else
Label : Project_Node_Id :=
First_Choice_Of (Node, In_Tree);
begin
- while Label /= Empty_Node loop
+ while Present (Label) loop
Print (Label, Indent);
Label := Next_Literal_String (Label, In_Tree);
- if Label /= Empty_Node then
+ if Present (Label) then
Write_String (" | ");
end if;
end loop;
First : constant Project_Node_Id :=
First_Declarative_Item_Of (Node, In_Tree);
begin
- if First = Empty_Node then
+ if No (First) then
Write_Empty_Line;
else
Print (First, Indent + Increment);