------------------------------------------------------- ------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . B U I L D E R . A N N E X 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 Ocarina.Nodes; with Ocarina.Nutils; with Ocarina.Builder.Namespaces; with Ocarina.Builder.Components; package body Ocarina.Builder.Annexes is function Add_New_Annex (Loc : Locations.location; Annex_Name : Types.node_id; Namespace : Types.node_id; Annex_Kind : Ocarina.Nodes.node_kind) return Types.node_id; ------------------- -- Add_New_Annex -- ------------------- function Add_New_Annex (Loc : Locations.location; Annex_Name : Types.node_id; Namespace : Types.node_id; Annex_Kind : Ocarina.Nodes.node_kind) return Types.node_id is use Ocarina.Nodes; use Ocarina.Nutils; use Ocarina.Builder.Components; use Ocarina.Builder.Namespaces; use Types; pragma assert (Annex_Name /= No_Node and then Kind (Annex_Name) = k_identifier); pragma assert (Namespace /= No_Node); pragma assert ((Annex_Kind = k_annex_subclause and then (Kind (Namespace) = k_component_implementation or else Kind (Namespace) = k_component_type or else Kind (Namespace) = k_port_group_type)) or else (Annex_Kind = k_annex_library and then (Kind (Namespace) = k_package_specification or else Kind (Namespace) = k_aadl_specification))); Node : constant node_id := New_Node (Annex_Kind, Loc); Success : Boolean := True; begin Set_Identifier (Node, Annex_Name); Set_Corresponding_Entity (Annex_Name, Node); Set_Annex_Content (Node, No_Node); if Kind (Namespace) = k_aadl_specification or else Kind (Namespace) = k_package_specification then Set_Container_Package (Node, Namespace); Success := Add_Declaration (Namespace, Node); elsif Kind (Namespace) = k_component_type or else Kind (Namespace) = k_component_implementation or else Kind (Namespace) = k_port_group_type then Set_Container_Component (Node, Namespace); Success := Add_Annex (Namespace, Node); end if; if Success then return Node; else return No_Node; end if; end Add_New_Annex; ----------------------- -- Set_Annex_Content -- ----------------------- function Set_Annex_Content (Annex : Types.node_id; Text : Types.name_id) return Boolean is use Types; use Ocarina.Nodes; use Ocarina.Nutils; pragma assert (Annex /= No_Node and then (Kind (Annex) = k_annex_subclause or else Kind (Annex) = k_annex_library)); Content : constant node_id := New_Node (k_annex_content, Loc (Annex)); begin Set_Raw_Text (Content, Text); Set_Annex_Content (Annex, Content); return True; end Set_Annex_Content; ----------------------------- -- Add_New_Annex_Subclause -- ----------------------------- function Add_New_Annex_Subclause (Loc : Locations.location; Annex_Name : Types.node_id; Namespace : Types.node_id) return Types.node_id is use Types; use Ocarina.Nodes; begin return Add_New_Annex (Loc, Annex_Name, Namespace, k_annex_subclause); end Add_New_Annex_Subclause; --------------------------- -- Add_New_Annex_Library -- --------------------------- function Add_New_Annex_Library (Loc : Locations.location; Annex_Name : Types.node_id; Namespace : Types.node_id; Is_Private : Boolean := False) return Types.node_id is use Types; use Ocarina.Nodes; Node : constant node_id := Add_New_Annex (Loc, Annex_Name, Namespace, k_annex_library); begin Set_Is_Private (Node, Is_Private); return Node; end Add_New_Annex_Library; end Ocarina.Builder.Annexes;