---------------------------------------- ---------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- GAIA.PROCESSOR.ENTITIES.SUBPROGRAM_CALLS -- -- -- -- 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; with Ocarina.Nutils; with Ocarina.Entities; with Gaia.Processor.Nodes; with Gaia.Processor.Nodes.Utils; package body Gaia.Processor.Entities.Subprogram_Calls is package ON renames Ocarina.Nodes; package ONU renames Ocarina.Nutils; package GN renames Gaia.Processor.Nodes; package GNU renames Gaia.Processor.Nodes.Utils; function Duplicate_Parameter (Parameter_Instance : Node_Id; Subprogram_Call_Node : Node_Id) return Boolean; --------------------------- -- Process_Call_Sequence -- --------------------------- function Process_Call_Sequence (Sequence, Sp : Node_Id) return Boolean is use Ocarina.Entities; use ON; use GN; use GNU; pragma Assert (ON.Kind (Sequence) = ON.K_Call_Sequence_Instance); pragma Assert (GN.Kind (Sp) = GN.K_Call_Sequence or else GN.Kind (Sp) = GN.K_Thread); List_Node : Node_Id; Sublist_Node : Node_Id; Call_Node : Node_Id; Success : Boolean := True; Identifier : Node_Id; begin if not ONU.Is_Empty (ON.Subprogram_Calls (Sequence)) then List_Node := ON.First_Node (ON.Subprogram_Calls (Sequence)); while Present (List_Node) loop Call_Node := GNU.New_Node (GN.K_Subprogram_Call); Identifier := GNU.Make_Identifier (Normalize_Name (Get_Name_Of_Entity (ON.Corresponding_Instance (List_Node)))); Bind_Identifier_To_Entity (Identifier, Call_Node); GN.Set_Scoped_Name (Call_Node, GNU.Map_Scoped_Name (Call_Node, List_Node)); Try_Perform_Link (GN.Set_Corresponding_Subprogram'Access, Call_Node, Corresponding_Instance (List_Node), False); GN.Set_Parameters (Call_Node, GNU.New_List (GN.K_List_Id)); GN.Set_Call_Name (Call_Node, Normalize_Name (Get_Name_Of_Entity (List_Node))); -- We set the annotation so that we can find the gaia -- call node when dealing with Ocarina call node. Used -- in Process_Connection. ON.Set_Annotation (List_Node, Call_Node); -- Set a specific instance of parameters for the -- subprogram call, by duplicating the parameters of the -- subprogram definition. if not ONU.Is_Empty (ON.Features (ON.Corresponding_Instance (List_Node))) then Sublist_Node := ON.First_Node (ON.Features (ON.Corresponding_Instance (List_Node))); while Present (Sublist_Node) loop if ON.Kind (Sublist_Node) = ON.K_Parameter_Instance then Success := Duplicate_Parameter (Sublist_Node, Call_Node) and then Success; end if; Sublist_Node := ON.Next_Node (Sublist_Node); end loop; end if; GNU.Append_Node_To_List (Call_Node, GN.Statements (Sp)); List_Node := ON.Next_Node (List_Node); end loop; end if; return Success; end Process_Call_Sequence; ------------------------- -- Duplicate_Parameter -- ------------------------- function Duplicate_Parameter (Parameter_Instance : Node_Id; Subprogram_Call_Node : Node_Id) return Boolean is use Ocarina.Entities; use ON; use GN; use GNU; pragma Assert (Parameter_Instance /= No_Node and then (ON.Kind (Parameter_Instance) = ON.K_Parameter_Instance)); pragma Assert (Subprogram_Call_Node /= No_Node); Success : constant Boolean := True; Parameter : Node_Id; Identifier : Node_Id; begin Parameter := New_Node (GN.K_Parameter); Identifier := Make_Identifier (Normalize_Name (Get_Name_Of_Entity (Parameter_Instance))); Bind_Identifier_To_Entity (Identifier, Parameter); GN.Set_Scoped_Name (Parameter, Append_Scoped_Name (Scoped_Name (Subprogram_Call_Node), Parameter, GN.Name (GN.Identifier (Parameter)))); GN.Set_Is_In (Parameter, ON.Is_In (Parameter_Instance)); GN.Set_Is_Out (Parameter, ON.Is_Out (Parameter_Instance)); Try_Perform_Link (GN.Set_Type_Spec'Access, Parameter, Corresponding_Instance (Parameter_Instance), True); -- We set the annotation so that we can find the gaia parameter -- node when dealing with Ocarina parameter node. Used in -- Process_Connection. ON.Set_Annotation (Parameter_Instance, Parameter); Append_Node_To_List (Parameter, Parameters (Subprogram_Call_Node)); return Success; end Duplicate_Parameter; end Gaia.Processor.Entities.Subprogram_Calls;