--------------------------------------- ----------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . B U I L D E R . C O M P O N E N T S . F L O W S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2005-2006, 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 Ocarina.Nutils; with Ocarina.Nodes; package body Ocarina.Builder.Components.Flows is ------------------------------ -- Add_Property_Association -- ------------------------------ function Add_Property_Association (Flow : Node_Id; Property_Association : Node_Id) return Boolean is use Ocarina.Nodes; use Ocarina.Nutils; pragma Assert (Kind (Flow) = K_Flow_Spec or else Kind (Flow) = K_Flow_Implementation or else Kind (Flow) = K_End_To_End_Flow_Spec or else Kind (Flow) = K_Flow_Implementation_Refinement or else Kind (Flow) = K_End_To_End_Flow_Refinement); pragma Assert (Present (Property_Association)); begin if Is_Empty (Ocarina.Nodes.Properties (Flow)) then Set_Properties (Flow, New_List (K_List_Id, Loc (Property_Association))); end if; Append_Node_To_List (Property_Association, Ocarina.Nodes.Properties (Flow)); return True; end Add_Property_Association; ----------------------- -- Add_New_Flow_Spec -- ----------------------- function Add_New_Flow_Spec (Loc : Location; Name : Node_Id; Comp_Type : Node_Id; Category : Ocarina.Entities.Components.Flows.Flow_Category; Source_Flow : Node_Id; Sink_Flow : Node_Id; Is_Refinement : Boolean := False) return Node_Id is use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.Builder.Components; use Ocarina.Entities.Components.Flows; pragma Assert (Kind (Comp_Type) = K_Component_Type); Node : constant Node_Id := New_Node (K_Flow_Spec, Loc); Success : Boolean; begin Set_Identifier (Node, Name); Set_Corresponding_Entity (Name, Node); Set_Properties (Node, No_List); Set_Property_Scope (Node, New_Node (K_Scope_Definition, Loc)); Set_Corresponding_Entity (Property_Scope (Node), Node); Set_Is_Refinement (Node, Is_Refinement); Set_Category (Node, Flow_Category'Pos (Category)); Set_Source_Flow (Node, Source_Flow); Set_Sink_Flow (Node, Sink_Flow); Success := Add_Flow_Spec (Comp_Type, Node); if Success then return Node; else return No_Node; end if; end Add_New_Flow_Spec; --------------------------------- -- Add_New_Flow_Implementation -- --------------------------------- function Add_New_Flow_Implementation (Loc : Location; Container : Node_Id; Name : Node_Id; Category : Ocarina.Entities.Components.Flows.Flow_Category; In_Modes : Node_Id; Is_Refinement : Boolean) return Node_Id is use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.Builder.Components; use Ocarina.Entities.Components.Flows; pragma Assert (Present (Name)); pragma Assert (Kind (Container) = K_Component_Implementation); Node : Node_Id; begin if Is_Refinement then Node := New_Node (K_Flow_Implementation_Refinement, Loc); else Node := New_Node (K_Flow_Implementation, Loc); end if; Set_Identifier (Node, Name); Set_Corresponding_Entity (Name, Node); Set_Category (Node, Flow_Category'Pos (Category)); Set_Properties (Node, No_List); Set_Property_Scope (Node, New_Node (K_Scope_Definition, Loc)); Set_Corresponding_Entity (Property_Scope (Node), Node); Set_In_Modes (Node, In_Modes); if not Add_Flow_Implementation (Container, Node) then Node := No_Node; end if; return Node; end Add_New_Flow_Implementation; ---------------------------------- -- Add_New_End_To_End_Flow_Spec -- ---------------------------------- function Add_New_End_To_End_Flow_Spec (Loc : Location; Container : Node_Id; Name : Node_Id; In_Modes : Node_Id; Is_Refinement : Boolean) return Node_Id is use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.Builder.Components; pragma Assert (Present (Name)); pragma Assert (Kind (Container) = K_Component_Implementation); Node : Node_Id; begin if Is_Refinement then Node := New_Node (K_End_To_End_Flow_Refinement, Loc); else Node := New_Node (K_End_To_End_Flow_Spec, Loc); end if; Set_Identifier (Node, Name); Set_Corresponding_Entity (Name, Node); Set_Properties (Node, No_List); Set_Property_Scope (Node, New_Node (K_Scope_Definition, Loc)); Set_Corresponding_Entity (Property_Scope (Node), Node); Set_In_Modes (Node, In_Modes); if not Add_End_To_End_Flow_Spec (Container, Node) then Node := No_Node; end if; return Node; end Add_New_End_To_End_Flow_Spec; end Ocarina.Builder.Components.Flows;