-------------------------- ------------------------------------------------------ -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . A A D L . P R I N T E R . C O M P O N E N T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2007, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with Output; with Ocarina.Nodes; with Ocarina.Nutils; with Ocarina.AADL.Printer.Components.Features; with Ocarina.AADL.Printer.Components.Subcomponents; with Ocarina.AADL.Printer.Components.Connections; with Ocarina.AADL.Printer.Components.Flows; with Ocarina.AADL.Printer.Components.Subprogram_Calls; with Ocarina.AADL.Printer.Components.Modes; with Ocarina.AADL.Printer.Annexes; with Ocarina.AADL.Printer.Identifiers; with Ocarina.AADL.Printer.Properties; with Ocarina.Entities.Components; package body Ocarina.AADL.Printer.Components is use Output; use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.AADL.Printer.Components.Features; use Ocarina.AADL.Printer.Components.Subcomponents; use Ocarina.AADL.Printer.Components.Connections; use Ocarina.AADL.Printer.Components.Flows; use Ocarina.AADL.Printer.Components.Subprogram_Calls; use Ocarina.AADL.Printer.Components.Modes; use Ocarina.AADL.Printer.Annexes; use Ocarina.AADL.Printer.Identifiers; use Ocarina.AADL.Printer.Properties; use Ocarina.Entities.Components; Bug_Str : constant String := "[BUG is HERE]"; ------------------------------ -- Print_Component_Category -- ------------------------------ procedure Print_Component_Category (Category : Byte) is begin case Component_Category'Val (Category) is when CC_Data => Print_Token (T_Data); when CC_Subprogram => Print_Token (T_Subprogram); when CC_Thread => Print_Token (T_Thread); when CC_Threadgroup => Print_Tokens ((T_Thread, T_Group)); when CC_Process => Print_Token (T_Process); when CC_Memory => Print_Token (T_Memory); when CC_Processor => Print_Token (T_Processor); when CC_Bus => Print_Token (T_Bus); when CC_Device => Print_Token (T_Device); when CC_System => Print_Token (T_System); when others => Write_Line (Bug_Str); end case; end Print_Component_Category; -------------------------- -- Print_Component_Type -- -------------------------- procedure Print_Component_Type (Node : Node_Id; Options : Output_Options) is pragma Assert (Kind (Node) = K_Component_Type); Node_Parent : constant Node_Id := Parent (Node); Comp_Name : constant Node_Id := Identifier (Node); List_Node : Node_Id; begin Write_Indentation; Print_Component_Category (Category (Node)); Write_Space; Print_Identifier (Comp_Name); if Present (Node_Parent) then Write_Space; Print_Token (T_Extends); Write_Space; Print_Entity_Reference (Node_Parent); end if; Write_Eol; if not Is_Empty (Ocarina.Nodes.Features (Node)) then List_Node := First_Node (Ocarina.Nodes.Features (Node)); Write_Indentation; Print_Token (T_Features); Write_Eol; Increment_Indentation; while Present (List_Node) loop Print_Feature (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Flows (Node)) then List_Node := First_Node (Ocarina.Nodes.Flows (Node)); Write_Indentation; Print_Token (T_Flows); Write_Eol; Increment_Indentation; while Present (List_Node) loop Print_Flow_Spec (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Properties (Node)) then List_Node := First_Node (Ocarina.Nodes.Properties (Node)); Write_Indentation; Print_Token (T_Properties); Write_Eol; Increment_Indentation; while Present (List_Node) loop Print_Property_Association (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Annexes (Node)) then Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Annexes (Node)); while Present (List_Node) loop Print_Annex_Subclause (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; Write_Indentation; Print_Token (T_End); Write_Space; Print_Identifier (Comp_Name); Print_Token (T_Semicolon); Write_Eol; end Print_Component_Type; ------------------------------------ -- Print_Component_Implementation -- ------------------------------------ procedure Print_Component_Implementation (Node : Node_Id; Options : Output_Options) is Node_Parent : constant Node_Id := Parent (Node); Impl_Ident : constant Node_Id := Identifier (Node); List_Node : Node_Id; begin Write_Indentation; Print_Component_Category (Category (Node)); Write_Space; Print_Token (T_Implementation); Write_Space; Print_Identifier (Impl_Ident); if Present (Node_Parent) then Write_Space; Print_Token (T_Extends); Write_Space; Print_Entity_Reference (Node_Parent); end if; Write_Eol; if not Is_Empty (Ocarina.Nodes.Refines_Type (Node)) then Write_Indentation; Print_Tokens ((T_Refines, T_Type)); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Refines_Type (Node)); while Present (List_Node) loop Print_Feature (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Subcomponents (Node)) then Write_Indentation; Print_Token (T_Subcomponents); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Subcomponents (Node)); while Present (List_Node) loop Print_Subcomponent (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Calls (Node)) then Write_Indentation; Print_Token (T_Calls); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Calls (Node)); while Present (List_Node) loop Print_Subprogram_Call_Sequence (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Connections (Node)) then Write_Indentation; Print_Token (T_Connections); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Connections (Node)); while Present (List_Node) loop Print_Connection (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Flows (Node)) then Write_Indentation; Print_Token (T_Flows); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Flows (Node)); while Present (List_Node) loop Print_Flow_Implementation (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Modes (Node)) then Write_Indentation; Print_Token (T_Modes); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Modes (Node)); while Present (List_Node) loop case Kind (List_Node) is when K_Mode => Print_Mode (List_Node, Options); when K_Mode_Transition => Print_Mode_Transition (List_Node, Options); when others => raise Program_Error; end case; List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Properties (Node)) then Write_Indentation; Print_Token (T_Properties); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Properties (Node)); while Present (List_Node) loop Print_Property_Association (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Annexes (Node)) then Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Annexes (Node)); while Present (List_Node) loop Print_Annex_Subclause (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; Write_Indentation; Print_Token (T_End); Write_Space; Print_Identifier (Impl_Ident); Print_Token (T_Semicolon); Write_Eol; end Print_Component_Implementation; --------------------------- -- Print_Port_Group_Type -- --------------------------- procedure Print_Port_Group_Type (Node : Node_Id; Options : Output_Options) is Port_Ident : constant Node_Id := Identifier (Node); Node_Parent : constant Node_Id := Parent (Node); Inverse_Ref : constant Node_Id := Inverse_Of (Node); List_Node : Node_Id; begin Write_Indentation; Print_Tokens ((T_Port, T_Group)); Write_Space; Print_Identifier (Port_Ident); if Present (Node_Parent) then Write_Space; Print_Token (T_Extends); Write_Space; Print_Entity_Reference (Node_Parent); end if; Write_Eol; if Is_Empty (Ocarina.Nodes.Features (Node)) and then not Present (Inverse_Ref) then Write_Indentation; Print_Token (T_Features); Write_Eol; else if not Is_Empty (Ocarina.Nodes.Features (Node)) then Write_Indentation; Print_Token (T_Features); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Features (Node)); while Present (List_Node) loop if not Is_Implicit_Inverse (List_Node) then -- Implicit features come from 'inverse of' -- statements. Hence they should not be displayed. Print_Feature (List_Node, Options); end if; List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if Present (Inverse_Ref) then Write_Indentation; Print_Tokens ((T_Inverse, T_Of)); Write_Space; Print_Entity_Reference (Inverse_Ref); Write_Eol; end if; end if; if not Is_Empty (Ocarina.Nodes.Properties (Node)) then Write_Indentation; Print_Token (T_Properties); Write_Eol; Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Properties (Node)); while Present (List_Node) loop Print_Property_Association (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Decrement_Indentation; Write_Eol; end if; if not Is_Empty (Ocarina.Nodes.Annexes (Node)) then Increment_Indentation; List_Node := First_Node (Ocarina.Nodes.Annexes (Node)); while Present (List_Node) loop Print_Annex_Subclause (List_Node, Options); List_Node := Next_Node (List_Node); end loop; Write_Eol; end if; Write_Indentation; Print_Token (T_End); Write_Space; Print_Identifier (Port_Ident); Print_Token (T_Semicolon); Write_Eol; end Print_Port_Group_Type; end Ocarina.AADL.Printer.Components;