-------------------------- ------------------------------------------------------ -- -- -- 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;