diff options
Diffstat (limited to 'gcc/ada/prj-pp.adb')
-rw-r--r-- | gcc/ada/prj-pp.adb | 254 |
1 files changed, 144 insertions, 110 deletions
diff --git a/gcc/ada/prj-pp.adb b/gcc/ada/prj-pp.adb index f9cceb5..b1ef31e 100644 --- a/gcc/ada/prj-pp.adb +++ b/gcc/ada/prj-pp.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2004 Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2005 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- -- @@ -63,6 +63,7 @@ package body Prj.PP is procedure Pretty_Print (Project : Prj.Tree.Project_Node_Id; + In_Tree : Prj.Tree.Project_Node_Tree_Ref; Increment : Positive := 3; Eliminate_Empty_Case_Constructions : Boolean := False; Minimize_Empty_Lines : Boolean := False; @@ -254,7 +255,7 @@ package body Prj.PP is ------------------------------- procedure Write_End_Of_Line_Comment (Node : Project_Node_Id) is - Value : constant Name_Id := End_Of_Line_Comment (Node); + Value : constant Name_Id := End_Of_Line_Comment (Node, In_Tree); begin if Value /= No_Name then @@ -309,136 +310,152 @@ package body Prj.PP is begin if Node /= Empty_Node then - case Kind_Of (Node) is + case Kind_Of (Node, In_Tree) is when N_Project => pragma Debug (Indicate_Tested (N_Project)); - if First_With_Clause_Of (Node) /= Empty_Node then + if First_With_Clause_Of (Node, In_Tree) /= Empty_Node then -- with clause(s) - Print (First_With_Clause_Of (Node), Indent); + Print (First_With_Clause_Of (Node, In_Tree), Indent); Write_Empty_Line (Always => True); end if; - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); Write_String ("project "); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); -- Check if this project extends another project - if Extended_Project_Path_Of (Node) /= No_Name then + if Extended_Project_Path_Of (Node, In_Tree) /= No_Name then Write_String (" extends "); - Output_String (Extended_Project_Path_Of (Node)); + Output_String (Extended_Project_Path_Of (Node, In_Tree)); end if; Write_String (" is"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent + Increment); + Print + (First_Comment_After (Node, In_Tree), Indent + Increment); Write_Empty_Line (Always => True); -- Output all of the declarations in the project - Print (Project_Declaration_Of (Node), Indent); - Print (First_Comment_Before_End (Node), Indent + Increment); + Print (Project_Declaration_Of (Node, In_Tree), Indent); + Print + (First_Comment_Before_End (Node, In_Tree), + Indent + Increment); Start_Line (Indent); Write_String ("end "); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); Write_Line (";"); - Print (First_Comment_After_End (Node), Indent); + Print (First_Comment_After_End (Node, In_Tree), Indent); when N_With_Clause => pragma Debug (Indicate_Tested (N_With_Clause)); - if Name_Of (Node) /= No_Name then - Print (First_Comment_Before (Node), Indent); + if Name_Of (Node, In_Tree) /= No_Name then + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); - if Non_Limited_Project_Node_Of (Node) = Empty_Node then + if Non_Limited_Project_Node_Of (Node, In_Tree) = + Empty_Node + then Write_String ("limited "); end if; Write_String ("with "); - Output_String (String_Value_Of (Node)); + Output_String (String_Value_Of (Node, In_Tree)); Write_String (";"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent); + Print (First_Comment_After (Node, In_Tree), Indent); end if; - Print (Next_With_Clause_Of (Node), Indent); + Print (Next_With_Clause_Of (Node, In_Tree), Indent); when N_Project_Declaration => pragma Debug (Indicate_Tested (N_Project_Declaration)); - if First_Declarative_Item_Of (Node) /= Empty_Node then + if + First_Declarative_Item_Of (Node, In_Tree) /= Empty_Node + then Print - (First_Declarative_Item_Of (Node), Indent + Increment); + (First_Declarative_Item_Of (Node, In_Tree), + Indent + Increment); Write_Empty_Line (Always => True); end if; when N_Declarative_Item => pragma Debug (Indicate_Tested (N_Declarative_Item)); - Print (Current_Item_Node (Node), Indent); - Print (Next_Declarative_Item (Node), Indent); + Print (Current_Item_Node (Node, In_Tree), Indent); + Print (Next_Declarative_Item (Node, In_Tree), Indent); when N_Package_Declaration => pragma Debug (Indicate_Tested (N_Package_Declaration)); Write_Empty_Line (Always => True); - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); Write_String ("package "); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); - if Project_Of_Renamed_Package_Of (Node) /= Empty_Node then + if Project_Of_Renamed_Package_Of (Node, In_Tree) /= + Empty_Node + then Write_String (" renames "); Output_Name - (Name_Of (Project_Of_Renamed_Package_Of (Node))); + (Name_Of + (Project_Of_Renamed_Package_Of (Node, In_Tree), + In_Tree)); Write_String ("."); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); Write_String (";"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After_End (Node), Indent); + Print (First_Comment_After_End (Node, In_Tree), Indent); else Write_String (" is"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent + Increment); + Print (First_Comment_After (Node, In_Tree), + Indent + Increment); - if First_Declarative_Item_Of (Node) /= Empty_Node then + if First_Declarative_Item_Of (Node, In_Tree) /= + Empty_Node + then Print - (First_Declarative_Item_Of (Node), + (First_Declarative_Item_Of (Node, In_Tree), Indent + Increment); end if; - Print (First_Comment_Before_End (Node), + Print (First_Comment_Before_End (Node, In_Tree), Indent + Increment); Start_Line (Indent); Write_String ("end "); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); Write_Line (";"); - Print (First_Comment_After_End (Node), Indent); + Print (First_Comment_After_End (Node, In_Tree), Indent); Write_Empty_Line; end if; when N_String_Type_Declaration => pragma Debug (Indicate_Tested (N_String_Type_Declaration)); - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); Write_String ("type "); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); Write_Line (" is"); Start_Line (Indent + Increment); Write_String ("("); declare String_Node : Project_Node_Id := - First_Literal_String (Node); + First_Literal_String (Node, In_Tree); begin while String_Node /= Empty_Node loop - Output_String (String_Value_Of (String_Node)); - String_Node := Next_Literal_String (String_Node); + Output_String (String_Value_Of (String_Node, In_Tree)); + String_Node := + Next_Literal_String (String_Node, In_Tree); if String_Node /= Empty_Node then Write_String (", "); @@ -448,76 +465,78 @@ package body Prj.PP is Write_String (");"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent); + Print (First_Comment_After (Node, In_Tree), Indent); when N_Literal_String => pragma Debug (Indicate_Tested (N_Literal_String)); - Output_String (String_Value_Of (Node)); + Output_String (String_Value_Of (Node, In_Tree)); - if Source_Index_Of (Node) /= 0 then + if Source_Index_Of (Node, In_Tree) /= 0 then Write_String (" at "); - Write_String (Source_Index_Of (Node)'Img); + Write_String (Source_Index_Of (Node, In_Tree)'Img); end if; when N_Attribute_Declaration => pragma Debug (Indicate_Tested (N_Attribute_Declaration)); - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); Write_String ("for "); - Output_Attribute_Name (Name_Of (Node)); + Output_Attribute_Name (Name_Of (Node, In_Tree)); - if Associative_Array_Index_Of (Node) /= No_Name then + if Associative_Array_Index_Of (Node, In_Tree) /= No_Name then Write_String (" ("); - Output_String (Associative_Array_Index_Of (Node)); + Output_String + (Associative_Array_Index_Of (Node, In_Tree)); - if Source_Index_Of (Node) /= 0 then + if Source_Index_Of (Node, In_Tree) /= 0 then Write_String (" at "); - Write_String (Source_Index_Of (Node)'Img); + Write_String (Source_Index_Of (Node, In_Tree)'Img); end if; Write_String (")"); end if; Write_String (" use "); - Print (Expression_Of (Node), Indent); + Print (Expression_Of (Node, In_Tree), Indent); Write_String (";"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent); + Print (First_Comment_After (Node, In_Tree), Indent); when N_Typed_Variable_Declaration => pragma Debug (Indicate_Tested (N_Typed_Variable_Declaration)); - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); Write_String (" : "); - Output_Name (Name_Of (String_Type_Of (Node))); + Output_Name + (Name_Of (String_Type_Of (Node, In_Tree), In_Tree)); Write_String (" := "); - Print (Expression_Of (Node), Indent); + Print (Expression_Of (Node, In_Tree), Indent); Write_String (";"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent); + Print (First_Comment_After (Node, In_Tree), Indent); when N_Variable_Declaration => pragma Debug (Indicate_Tested (N_Variable_Declaration)); - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); Write_String (" := "); - Print (Expression_Of (Node), Indent); + Print (Expression_Of (Node, In_Tree), Indent); Write_String (";"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent); + Print (First_Comment_After (Node, In_Tree), Indent); when N_Expression => pragma Debug (Indicate_Tested (N_Expression)); declare - Term : Project_Node_Id := First_Term (Node); + Term : Project_Node_Id := First_Term (Node, In_Tree); begin while Term /= Empty_Node loop Print (Term, Indent); - Term := Next_Term (Term); + Term := Next_Term (Term, In_Tree); if Term /= Empty_Node then Write_String (" & "); @@ -527,7 +546,7 @@ package body Prj.PP is when N_Term => pragma Debug (Indicate_Tested (N_Term)); - Print (Current_Term (Node), Indent); + Print (Current_Term (Node, In_Tree), Indent); when N_Literal_String_List => pragma Debug (Indicate_Tested (N_Literal_String_List)); @@ -535,12 +554,13 @@ package body Prj.PP is declare Expression : Project_Node_Id := - First_Expression_In_List (Node); + First_Expression_In_List (Node, In_Tree); begin while Expression /= Empty_Node loop Print (Expression, Indent); - Expression := Next_Expression_In_List (Expression); + Expression := + Next_Expression_In_List (Expression, In_Tree); if Expression /= Empty_Node then Write_String (", "); @@ -552,26 +572,28 @@ package body Prj.PP is when N_Variable_Reference => pragma Debug (Indicate_Tested (N_Variable_Reference)); - if Project_Node_Of (Node) /= Empty_Node then - Output_Name (Name_Of (Project_Node_Of (Node))); + if Project_Node_Of (Node, In_Tree) /= Empty_Node then + Output_Name + (Name_Of (Project_Node_Of (Node, In_Tree), In_Tree)); Write_String ("."); end if; - if Package_Node_Of (Node) /= Empty_Node then - Output_Name (Name_Of (Package_Node_Of (Node))); + if Package_Node_Of (Node, In_Tree) /= Empty_Node then + Output_Name + (Name_Of (Package_Node_Of (Node, In_Tree), In_Tree)); Write_String ("."); end if; - Output_Name (Name_Of (Node)); + Output_Name (Name_Of (Node, In_Tree)); when N_External_Value => pragma Debug (Indicate_Tested (N_External_Value)); Write_String ("external ("); - Print (External_Reference_Of (Node), Indent); + Print (External_Reference_Of (Node, In_Tree), Indent); - if External_Default_Of (Node) /= Empty_Node then + if External_Default_Of (Node, In_Tree) /= Empty_Node then Write_String (", "); - Print (External_Default_Of (Node), Indent); + Print (External_Default_Of (Node, In_Tree), Indent); end if; Write_String (")"); @@ -579,29 +601,32 @@ package body Prj.PP is when N_Attribute_Reference => pragma Debug (Indicate_Tested (N_Attribute_Reference)); - if Project_Node_Of (Node) /= Empty_Node - and then Project_Node_Of (Node) /= Project + if Project_Node_Of (Node, In_Tree) /= Empty_Node + and then Project_Node_Of (Node, In_Tree) /= Project then - Output_Name (Name_Of (Project_Node_Of (Node))); + Output_Name + (Name_Of (Project_Node_Of (Node, In_Tree), In_Tree)); - if Package_Node_Of (Node) /= Empty_Node then + if Package_Node_Of (Node, In_Tree) /= Empty_Node then Write_String ("."); - Output_Name (Name_Of (Package_Node_Of (Node))); + Output_Name + (Name_Of (Package_Node_Of (Node, In_Tree), In_Tree)); end if; - elsif Package_Node_Of (Node) /= Empty_Node then - Output_Name (Name_Of (Package_Node_Of (Node))); + elsif Package_Node_Of (Node, In_Tree) /= Empty_Node then + Output_Name + (Name_Of (Package_Node_Of (Node, In_Tree), In_Tree)); else Write_String ("project"); end if; Write_String ("'"); - Output_Attribute_Name (Name_Of (Node)); + Output_Attribute_Name (Name_Of (Node, In_Tree)); declare Index : constant Name_Id := - Associative_Array_Index_Of (Node); + Associative_Array_Index_Of (Node, In_Tree); begin if Index /= No_Name then @@ -615,72 +640,81 @@ package body Prj.PP is pragma Debug (Indicate_Tested (N_Case_Construction)); declare - Case_Item : Project_Node_Id := First_Case_Item_Of (Node); + Case_Item : Project_Node_Id; Is_Non_Empty : Boolean := False; + begin + Case_Item := First_Case_Item_Of (Node, In_Tree); while Case_Item /= Empty_Node loop - if First_Declarative_Item_Of (Case_Item) /= Empty_Node + if First_Declarative_Item_Of (Case_Item, In_Tree) /= + Empty_Node or else not Eliminate_Empty_Case_Constructions then Is_Non_Empty := True; exit; end if; - Case_Item := Next_Case_Item (Case_Item); + + Case_Item := Next_Case_Item (Case_Item, In_Tree); end loop; if Is_Non_Empty then Write_Empty_Line; - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); Write_String ("case "); - Print (Case_Variable_Reference_Of (Node), Indent); + Print + (Case_Variable_Reference_Of (Node, In_Tree), + Indent); Write_String (" is"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent + Increment); + Print + (First_Comment_After (Node, In_Tree), + Indent + Increment); declare Case_Item : Project_Node_Id := - First_Case_Item_Of (Node); - + First_Case_Item_Of (Node, In_Tree); begin while Case_Item /= Empty_Node loop pragma Assert - (Kind_Of (Case_Item) = N_Case_Item); + (Kind_Of (Case_Item, In_Tree) = N_Case_Item); Print (Case_Item, Indent + Increment); - Case_Item := Next_Case_Item (Case_Item); + Case_Item := + Next_Case_Item (Case_Item, In_Tree); end loop; end; - Print (First_Comment_Before_End (Node), + Print (First_Comment_Before_End (Node, In_Tree), Indent + Increment); Start_Line (Indent); Write_Line ("end case;"); - Print (First_Comment_After_End (Node), Indent); + Print + (First_Comment_After_End (Node, In_Tree), Indent); end if; end; when N_Case_Item => pragma Debug (Indicate_Tested (N_Case_Item)); - if First_Declarative_Item_Of (Node) /= Empty_Node + if First_Declarative_Item_Of (Node, In_Tree) /= Empty_Node or else not Eliminate_Empty_Case_Constructions then Write_Empty_Line; - Print (First_Comment_Before (Node), Indent); + Print (First_Comment_Before (Node, In_Tree), Indent); Start_Line (Indent); Write_String ("when "); - if First_Choice_Of (Node) = Empty_Node then + if First_Choice_Of (Node, In_Tree) = Empty_Node then Write_String ("others"); else declare - Label : Project_Node_Id := First_Choice_Of (Node); - + Label : Project_Node_Id := + First_Choice_Of (Node, In_Tree); begin while Label /= Empty_Node loop Print (Label, Indent); - Label := Next_Literal_String (Label); + Label := Next_Literal_String (Label, In_Tree); if Label /= Empty_Node then Write_String (" | "); @@ -691,16 +725,16 @@ package body Prj.PP is Write_String (" =>"); Write_End_Of_Line_Comment (Node); - Print (First_Comment_After (Node), Indent + Increment); + Print + (First_Comment_After (Node, In_Tree), + Indent + Increment); declare First : constant Project_Node_Id := - First_Declarative_Item_Of (Node); - + First_Declarative_Item_Of (Node, In_Tree); begin if First = Empty_Node then Write_Empty_Line; - else Print (First, Indent + Increment); end if; @@ -716,22 +750,22 @@ package body Prj.PP is when N_Comment => pragma Debug (Indicate_Tested (N_Comment)); - if Follows_Empty_Line (Node) then + if Follows_Empty_Line (Node, In_Tree) then Write_Empty_Line; end if; Start_Line (Indent); Write_String ("--"); Write_String - (Get_Name_String (String_Value_Of (Node)), + (Get_Name_String (String_Value_Of (Node, In_Tree)), Truncated => True); Write_Line (""); - if Is_Followed_By_Empty_Line (Node) then + if Is_Followed_By_Empty_Line (Node, In_Tree) then Write_Empty_Line; end if; - Print (Next_Comment (Node), Indent); + Print (Next_Comment (Node, In_Tree), Indent); end case; end if; end Print; |