Commit d1bb5901 authored by julien.delange's avatar julien.delange

setup the environment to generate ASN1 deployment

informations



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@666 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 8925c270
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . A S N 1 . D E P L O Y M E N T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, 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.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
package body Ocarina.Backends.ASN1.Deployment is
use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
procedure Visit_Architecture_Instance (E : Node_Id);
procedure Visit_Component_Instance (E : Node_Id);
procedure Visit_System_Instance (E : Node_Id);
procedure Visit_Process_Instance (E : Node_Id);
procedure Visit_Device_Instance (E : Node_Id);
procedure Visit_Thread_Instance (E : Node_Id);
procedure Visit_Subprogram_Instance (E : Node_Id);
-----------
-- Visit --
-----------
procedure Visit (E : Node_Id) is
begin
case Kind (E) is
when K_Architecture_Instance =>
Visit_Architecture_Instance (E);
when K_Component_Instance =>
Visit_Component_Instance (E);
when others =>
null;
end case;
end Visit;
---------------------------------
-- Visit_Architecture_Instance --
---------------------------------
procedure Visit_Architecture_Instance (E : Node_Id) is
begin
Visit (Root_System (E));
end Visit_Architecture_Instance;
------------------------------
-- Visit_Component_Instance --
------------------------------
procedure Visit_Component_Instance (E : Node_Id) is
Category : constant Component_Category
:= Get_Category_Of_Component (E);
begin
case Category is
when CC_System =>
Visit_System_Instance (E);
when CC_Process =>
Visit_Process_Instance (E);
when CC_Thread =>
Visit_Thread_Instance (E);
when CC_Device =>
Visit_Device_Instance (E);
when CC_Subprogram =>
Visit_Subprogram_Instance (E);
when others =>
null;
end case;
end Visit_Component_Instance;
----------------------------
-- Visit_Process_Instance --
----------------------------
procedure Visit_Process_Instance (E : Node_Id) is
S : Node_Id;
begin
if not AAU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
end Visit_Process_Instance;
---------------------------
-- Visit_System_Instance --
---------------------------
procedure Visit_System_Instance (E : Node_Id) is
S : Node_Id;
begin
-- Visit all the subcomponents of the system
if not AAU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
end Visit_System_Instance;
---------------------------
-- Visit_Thread_Instance --
---------------------------
procedure Visit_Thread_Instance (E : Node_Id) is
S : Node_Id;
Call_Seq : Node_Id;
Spg_Call : Node_Id;
begin
if not AAU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
if not AAU.Is_Empty (Calls (E)) then
Call_Seq := First_Node (Calls (E));
while Present (Call_Seq) loop
-- For each call sequence visit all the called
-- subprograms.
if not AAU.Is_Empty (Subprogram_Calls (Call_Seq)) then
Spg_Call := First_Node (Subprogram_Calls (Call_Seq));
while Present (Spg_Call) loop
Visit (Corresponding_Instance (Spg_Call));
Spg_Call := Next_Node (Spg_Call);
end loop;
end if;
Call_Seq := Next_Node (Call_Seq);
end loop;
end if;
end Visit_Thread_Instance;
-------------------------------
-- Visit_Subprogram_Instance --
-------------------------------
procedure Visit_Subprogram_Instance (E : Node_Id) is
pragma Unreferenced (E);
begin
null;
end Visit_Subprogram_Instance;
---------------------------
-- Visit_Device_Instance --
---------------------------
procedure Visit_Device_Instance (E : Node_Id) is
pragma Unreferenced (E);
begin
null;
end Visit_Device_Instance;
end Ocarina.Backends.ASN1.Deployment;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . A S N 1 . D E P L O Y M E N T --
-- --
-- S p e c --
-- --
-- Copyright (C) 2010, 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) --
-- --
------------------------------------------------------------------------------
package Ocarina.Backends.ASN1.Deployment is
procedure Visit (E : Node_Id);
end Ocarina.Backends.ASN1.Deployment;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . A S N 1 --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, 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.Instances;
with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages;
with Ocarina.Backends.ASN1_Tree.Generator;
with Ocarina.Backends.ASN1.Deployment;
with Ocarina.Backends.Utils;
with Ocarina.Backends.Build_Utils;
with GNAT.Command_Line;
with Namet;
package body Ocarina.Backends.ASN1 is
use GNAT.Command_Line;
use Namet;
use Ocarina.Backends.Messages;
use Ocarina.Backends.ASN1_Tree.Generator;
use Ocarina.Backends.Utils;
use Ocarina.Backends.Expander;
use Ocarina.Instances;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
procedure Visit_Architecture_Instance (E : Node_Id);
-- Most top level visitor routine. E is the root of the AADL
-- instance tree. The procedure does a traversal for each
-- compilation unit to be generated.
--------------
-- Generate --
--------------
procedure Generate (AADL_Root : Node_Id) is
Instance_Root : Node_Id;
begin
-- Instantiate the AADL tree
Instance_Root := Instantiate_Model (AADL_Root);
-- Expand the AADL instance
Expand (Instance_Root);
Visit_Architecture_Instance (Instance_Root);
-- Abort if the construction of the C tree failed
if No (ASN1_Root) then
Display_Error ("Code generation failed", Fatal => True);
end if;
-- Enter the output directory
Enter_Directory (Generated_Sources_Directory);
if Remove_Generated_Sources then
Build_Utils.Makefiles.Clean (Instance_Root);
else
-- Create the source files
ASN1_Tree.Generator.Generate (ASN1_Root);
end if;
-- Leave the output directory
Leave_Directory;
end Generate;
----------
-- Init --
----------
procedure Init is
begin
Generated_Sources_Directory := Get_String_Name (".");
Initialize_Option_Scan;
loop
case Getopt ("* b z ec er o: perf") is
when ASCII.NUL =>
exit;
when 'z' =>
Remove_Generated_Sources := True;
when 'o' =>
declare
D : constant String := Parameter;
begin
if D'Length /= 0 then
Generated_Sources_Directory := Get_String_Name (D);
end if;
end;
when others =>
null;
end case;
end loop;
Register_Backend ("asn1_deployment", Generate'Access, ASN1_Deployment);
end Init;
-----------
-- Reset --
-----------
procedure Reset is
begin
null;
end Reset;
---------------------------------
-- Visit_Architecture_Instance --
---------------------------------
procedure Visit_Architecture_Instance (E : Node_Id) is
begin
Deployment.Visit (E);
end Visit_Architecture_Instance;
end Ocarina.Backends.ASN1;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . A S N 1 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2010, 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) --
-- --
------------------------------------------------------------------------------
package Ocarina.Backends.ASN1 is
procedure Generate (AADL_Root : Node_Id);
procedure Init;
procedure Reset;
private
ASN1_Root : Node_Id;
end Ocarina.Backends.ASN1;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- OCARINA.BACKENDS.ASN1_TREE.GENERATOR --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, 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 Namet; use Namet;
with Output; use Output;
with Ocarina.Backends.ASN1_Tree.Nodes;
with Ocarina.Backends.ASN1_Tree.Nutils;
with Ocarina.Backends.Messages;
package body Ocarina.Backends.ASN1_Tree.Generator is
use Ocarina.Backends.ASN1_Tree.Nodes;
use Ocarina.Backends.ASN1_Tree.Nutils;
use Ocarina.Backends.Messages;
procedure Write (T : Token_Type);
procedure Write_Line (T : Token_Type);
pragma Unreferenced (Write_Line);
-----------
-- Write --
-----------
procedure Write (T : Token_Type) is
begin
Write_Name (Token_Image (T));
end Write;
----------------
-- Write_Line --
----------------
procedure Write_Line (T : Token_Type) is
begin
Write (T);
Write_Eol;
end Write_Line;
--------------
-- Generate --
--------------
procedure Generate (N : Node_Id) is
begin
case Kind (N) is
when others =>
Display_Error ("other element in generator", Fatal => False);
null;
end case;
end Generate;
end Ocarina.Backends.ASN1_Tree.Generator;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- OCARINA.BACKENDS.ASN1_TREE.GENERATOR --
-- --
-- S p e c --
-- --
-- Copyright (C) 2010, 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) --
-- --
------------------------------------------------------------------------------
package Ocarina.Backends.ASN1_Tree.Generator is
Var_Name_Len : Natural := 0;
procedure Generate (N : Node_Id);
-- All code generation is performed in the current directory. It
-- is up to the caller to change the working directory before
-- calling Generate.
end Ocarina.Backends.ASN1_Tree.Generator;
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009, GET-Telecom Paris. --
-- Copyright (C) 2008-2010, 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 --
......@@ -43,6 +43,7 @@ with Ocarina.Backends.Build_Utils;
with Ocarina.Backends.Messages;
with Ocarina.Backends.PN;
with Ocarina.Backends.PO_HI_Ada;
with Ocarina.Backends.ASN1;
with Ocarina.Backends.PO_HI_C;
with Ocarina.Backends.PO_HI_RTSJ;
with Ocarina.Backends.Stats;
......@@ -174,6 +175,7 @@ package body Ocarina.Backends is
Subprograms.Init;
REAL.Init;
Carts.Init;
ASN1.Init;
end Init;
----------------------
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2008-2009, GET-Telecom Paris. --
-- Copyright (C) 2008-2010, 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 --
......@@ -52,6 +52,7 @@ package Ocarina.Backends is
AADL,
AADL_Min,
AADL_Annex,
ASN1_Deployment,
Bound_T,
Petri_Nets,
PolyORB_QoS_Ada,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment