----------------------------------------- --------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- OCARINA.EXPANDER.COMPONENTS.SUBCOMPONENTS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2005-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 Locations; with Ocarina.Nodes; with Ocarina.Nutils; with Ocarina.Entities; with Ocarina.Expander.Components; with Ocarina.Expander.Messages; with Ocarina.Expander.Namespaces; package body Ocarina.Expander.Components.Subcomponents is use Locations; use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.Entities; use Ocarina.Expander.Components; use Ocarina.Expander.Messages; use Ocarina.Expander.Namespaces; ------------------------- -- Expand_Subcomponent -- ------------------------- function Expand_Subcomponent (Instance_Root : Node_Id; Subcomponent : Node_Id) return Node_Id is pragma Assert (Kind (Instance_Root) = K_Architecture_Instance); pragma Assert (Kind (Subcomponent) = K_Subcomponent); New_Instance : constant Node_Id := New_Node (K_Subcomponent_Instance, Loc (Subcomponent)); New_Subinstance : Node_Id; Namespace_Instance : Node_Id; Subinstance_Homonym : Node_Id; begin Set_Identifier (New_Instance, Duplicate_Identifier (Identifier (Subcomponent))); Set_Corresponding_Declaration (New_Instance, Subcomponent); Set_Destinations (New_Instance, New_List (K_List_Id, No_Location)); if Present (Entity_Ref (Subcomponent)) and then Present (Get_Referenced_Entity (Entity_Ref (Subcomponent))) then -- Getting the component namespace Namespace_Instance := Expand_Namespace (Instance_Root, Namespace (Get_Referenced_Entity (Entity_Ref (Subcomponent)))); -- Verify whether the component has been expanded or not Subinstance_Homonym := Get_First_Contained_Homonym (Declarations (Namespace_Instance), Get_Referenced_Entity (Entity_Ref (Subcomponent))); New_Subinstance := Expand_Component (Instance_Root, Get_Referenced_Entity (Entity_Ref (Subcomponent))); if Present (New_Subinstance) then Set_Corresponding_Instance (New_Instance, New_Subinstance); Set_Parent_Subcomponent (New_Subinstance, New_Instance); Set_First_Homonym_In_Namespace (New_Subinstance, Subinstance_Homonym); end if; if Kind (Get_Referenced_Entity (Entity_Ref (Subcomponent))) = K_Component_Type then Display_Entity_Is_A_Component_Type (Subcomponent); end if; else Display_No_Entity_Ref (Subcomponent); New_Subinstance := No_Node; end if; return New_Instance; end Expand_Subcomponent; end Ocarina.Expander.Components.Subcomponents;