------------------------------------------ -------------------------------------- -- -- -- 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 . M O D E 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.Nodes; with Ocarina.Nutils; package body Ocarina.Builder.Components.Modes is ------------------------------ -- Add_Property_Association -- ------------------------------ function Add_Property_Association (Mode : Types.node_id; Property_Association : Types.node_id) return Boolean is use Ocarina.Nodes; use Ocarina.Nutils; pragma assert (Mode /= No_Node and then Kind (Mode) = k_mode); pragma assert (Property_Association /= No_Node); begin if Is_Empty (Ocarina.Nodes.Properties (Mode)) then Set_Properties (Mode, New_List (k_list_id, Loc (Property_Association))); end if; Append_Node_To_List (Property_Association, Ocarina.Nodes.Properties (Mode)); return True; end Add_Property_Association; ------------------ -- Add_New_Mode -- ------------------ function Add_New_Mode (Loc : Locations.location; Identifier : Types.node_id; Component : Types.node_id) return Types.node_id is use Ocarina.Nodes; use Ocarina.Nutils; pragma assert (Identifier /= No_Node and then Kind (Identifier) = k_identifier); pragma assert (Component /= No_Node and then Kind (Component) = k_component_implementation); Node : node_id; Success : Boolean := True; Property_Scop : constant node_id := New_Node (k_scope_definition, Loc); begin Node := New_Node (k_mode, Loc); Set_Identifier (Node, Identifier); Set_Corresponding_Entity (Identifier, Node); Set_Property_Scope (Node, Property_Scop); Set_Corresponding_Entity (Property_Scope (Node), Node); Set_Scoped_Identifiers (Property_Scop, No_Node); Success := Add_Mode (Component, Node); if Success then return Node; else return No_Node; end if; end Add_New_Mode; ----------------------------- -- Add_New_Mode_Transition -- ----------------------------- function Add_New_Mode_Transition (Loc : Locations.location; Component : Types.node_id) return Types.node_id is use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.Builder.Components; pragma assert (Component /= No_Node and then Kind (Component) = k_component_implementation); Node : constant node_id := New_Node (k_mode_transition, Loc); Success : Boolean := True; begin Success := Add_Mode (Component => Component, Mode => Node); if Success then return Node; else return No_Node; end if; end Add_New_Mode_Transition; end Ocarina.Builder.Components.Modes;