------------------------------------------------ -------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- OCARINA.VISITOR.INSTANCES.PROPERTIES -- -- -- -- 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; package body Ocarina.Visitor.Instances.Properties is use Ocarina.Nodes; function Visit_Property_Associations (Properties : list_id; Root : node_id; Container : node_id; Callback : property_instance_callback) return Boolean; function Visit_Properties_Of_Component_Instance (Root : node_id; Component : node_id; Callback : property_instance_callback) return Boolean; function Visit_Properties_Of_Namespace_Instance (Root : node_id; The_Namespace : node_id; Callback : property_instance_callback) return Boolean; --------------------------------- -- Visit_Property_Associations -- --------------------------------- function Visit_Property_Associations (Properties : list_id; Root : node_id; Container : node_id; Callback : property_instance_callback) return Boolean is pragma assert (Present (Container)); Success : Boolean := True; List_Node : node_id; begin if Properties /= No_List then List_Node := First_Node (Properties); while Present (List_Node) loop pragma assert (Kind (List_Node) = k_property_association); Success := Callback (Root => Root, Container => Container, Property => List_Node) and then Success; List_Node := Next_Node (List_Node); end loop; end if; return Success; end Visit_Property_Associations; -------------------------------------------- -- Visit_Properties_Of_Component_Instance -- -------------------------------------------- function Visit_Properties_Of_Component_Instance (Root : node_id; Component : node_id; Callback : property_instance_callback) return Boolean is pragma assert (Kind (Component) = k_component_instance); Success : Boolean := True; List_Node : node_id; Call_List_Node : node_id; begin -- Features if Features (Component) /= No_List then List_Node := First_Node (Features (Component)); while Present (List_Node) loop Success := Visit_Property_Associations (Root => Root, Properties => Ocarina.Nodes.Properties (List_Node), Container => List_Node, Callback => Callback) and then Success; List_Node := Next_Node (List_Node); end loop; end if; -- Subcomponents if Subcomponents (Component) /= No_List then List_Node := First_Node (Subcomponents (Component)); while Present (List_Node) loop Success := Visit_Properties_Of_Component_Instance (Root => Root, Component => Corresponding_Instance (List_Node), Callback => Callback) and then Success; List_Node := Next_Node (List_Node); end loop; end if; -- Call sequences -- Some call sequences are anonymous if Calls (Component) /= No_List then List_Node := First_Node (Calls (Component)); while Present (List_Node) loop if Subprogram_Calls (List_Node) /= No_List then Call_List_Node := First_Node (Subprogram_Calls (List_Node)); while Present (Call_List_Node) loop Success := Visit_Properties_Of_Component_Instance (Root => Root, Component => Corresponding_Instance (Call_List_Node), Callback => Callback) and then Success; Call_List_Node := Next_Node (Call_List_Node); end loop; end if; List_Node := Next_Node (List_Node); end loop; end if; -- Connections -- Some connections are anonymous if Connections (Component) /= No_List then List_Node := First_Node (Connections (Component)); while Present (List_Node) loop Success := Visit_Property_Associations (Root => Root, Properties => Ocarina.Nodes.Properties (List_Node), Container => List_Node, Callback => Callback) and then Success; List_Node := Next_Node (List_Node); end loop; end if; -- Flows if Flows (Component) /= No_List then List_Node := First_Node (Flows (Component)); while Present (List_Node) loop Success := Visit_Property_Associations (Root => Root, Properties => Ocarina.Nodes.Properties (List_Node), Container => List_Node, Callback => Callback) and then Success; List_Node := Next_Node (List_Node); end loop; end if; -- Modes if Modes (Component) /= No_List then List_Node := First_Node (Modes (Component)); while Present (List_Node) loop if Kind (List_Node) = k_mode then Success := Visit_Property_Associations (Root => Root, Properties => Ocarina.Nodes.Properties (List_Node), Container => List_Node, Callback => Callback) and then Success; end if; List_Node := Next_Node (List_Node); end loop; end if; -- Properties Success := Visit_Property_Associations (Root => Root, Properties => Ocarina.Nodes.Properties (Component), Container => Component, Callback => Callback) and then Success; return Success; end Visit_Properties_Of_Component_Instance; -------------------------------------------- -- Visit_Properties_Of_Namespace_Instance -- -------------------------------------------- function Visit_Properties_Of_Namespace_Instance (Root : node_id; The_Namespace : node_id; Callback : property_instance_callback) return Boolean is pragma assert (Kind (The_Namespace) = k_namespace_instance); Success : Boolean := True; List_Node : node_id; The_Component : node_id; begin -- Declarations if Declarations (The_Namespace) /= No_List then List_Node := First_Node (Declarations (The_Namespace)); while Present (List_Node) loop The_Component := Item (List_Node); pragma assert (Kind (The_Component) = k_component_instance); Success := Visit_Properties_Of_Component_Instance (Root => Root, Component => The_Component, Callback => Callback) and then Success; List_Node := Next_Node (List_Node); end loop; end if; return Success; end Visit_Properties_Of_Namespace_Instance; ---------------------------------- -- Visit_All_Property_Instances -- ---------------------------------- function Visit_All_Property_Instances (Root : node_id; Callback : property_instance_callback) return Boolean is pragma assert (Kind (Root) = k_architecture_instance); Success : Boolean := True; List_Node : node_id; begin Success := Visit_Properties_Of_Component_Instance (Root => Root, Component => Root_System (Root), Callback => Callback); if Namespaces (Root) /= No_List then List_Node := First_Node (Namespaces (Root)); while Present (List_Node) loop Success := Visit_Properties_Of_Namespace_Instance (Root => Root, The_Namespace => List_Node, Callback => Callback) and then Success; List_Node := Next_Node (List_Node); end loop; end if; return Success; end Visit_All_Property_Instances; end Ocarina.Visitor.Instances.Properties;