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