------------------------------------------------- ------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . E X P A N D E R . N A M E S P A C E S -- -- -- -- 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.Nutils; with Ocarina.Nodes; with Ocarina.Entities; package body Ocarina.Expander.Namespaces is use Locations; use Ocarina.Nutils; use Ocarina.Nodes; use Ocarina.Entities; ---------------------- -- Expand_Namespace -- ---------------------- function Expand_Namespace (Instance_Root : node_id; Namespace : node_id) return node_id is pragma assert (Kind (Instance_Root) = k_architecture_instance); pragma assert (Kind (Namespace) = k_package_specification or else Kind (Namespace) = k_aadl_specification); Namespace_Instance : node_id := No_Node; begin -- If the namespace has already been expanded, do not re-expand -- it and return the previously expanded value. if Kind (Namespace) = k_package_specification then Namespace_Instance := Get_First_Homonym (Ocarina.Nodes.Namespaces (Instance_Root), Namespace); if No (Namespace_Instance) then Namespace_Instance := New_Node (k_namespace_instance, No_Location); Set_Declarations (Namespace_Instance, New_List (k_list_id, No_Location)); Set_Identifier (Namespace_Instance, Duplicate_Identifier (Identifier (Namespace))); Set_Corresponding_Declaration (Namespace_Instance, Namespace); Append_Node_To_List (Namespace_Instance, Ocarina.Nodes.Namespaces (Instance_Root)); end if; else Namespace_Instance := Unnamed_Namespace (Instance_Root); if No (Namespace_Instance) then Namespace_Instance := New_Node (k_namespace_instance, No_Location); Set_Unnamed_Namespace (Instance_Root, Namespace_Instance); Set_Declarations (Namespace_Instance, New_List (k_list_id, No_Location)); Set_Identifier (Namespace_Instance, Make_Identifier (Loc (Namespace), No_Name, No_Name, Namespace)); Set_Corresponding_Declaration (Namespace_Instance, Namespace); end if; end if; return Namespace_Instance; end Expand_Namespace; end Ocarina.Expander.Namespaces;