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

add model browser to generate MAST entities

begin to handle processor components



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@1345 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent e2f5ee5b
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . M A S T . M A I N --
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, European Space Agency (ESA). --
-- --
-- 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 Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.MAST_Tree.Nodes;
with Ocarina.Backends.MAST_Tree.Nutils;
-- with Ocarina.Backends.Properties;
package body Ocarina.Backends.MAST.Main is
use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.MAST_Tree.Nutils;
-- use Ocarina.Backends.Properties;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package MTN renames Ocarina.Backends.MAST_Tree.Nodes;
package MTU renames Ocarina.Backends.MAST_Tree.Nutils;
procedure Visit_Component (E : Node_Id);
procedure Visit_System (E : Node_Id);
procedure Visit_Processor (E : Node_Id);
procedure Visit_Bus (E : Node_Id);
procedure Visit_Virtual_Processor (E : Node_Id);
Root_System_Node : Node_Id := No_Node;
-----------
-- Visit --
-----------
procedure Visit (E : Node_Id) is
begin
case Kind (E) is
when K_Architecture_Instance =>
Root_System_Node := Root_System (E);
Visit (Root_System_Node);
when K_Component_Instance =>
Visit_Component (E);
when others =>
null;
end case;
end Visit;
---------------------
-- Visit_Component --
---------------------
procedure Visit_Component (E : Node_Id) is
Category : constant Component_Category
:= Get_Category_Of_Component (E);
begin
case Category is
when CC_System =>
Visit_System (E);
when CC_Processor =>
Visit_Processor (E);
when CC_Bus =>
Visit_Bus (E);
when CC_Virtual_Processor =>
Visit_Virtual_Processor (E);
when others =>
null;
end case;
end Visit_Component;
---------------
-- Visit_Bus --
---------------
procedure Visit_Bus (E : Node_Id) is
pragma Unreferenced (E);
begin
null;
end Visit_Bus;
--------------------------------------
-- Visit_Virtual_Processor_Instance --
--------------------------------------
procedure Visit_Virtual_Processor (E : Node_Id) is
pragma Unreferenced (E);
begin
null;
end Visit_Virtual_Processor;
---------------------
-- Visit_Processor --
---------------------
procedure Visit_Processor (E : Node_Id) is
S : Node_Id;
N : Node_Id;
begin
N := MTU.Make_Processing_Resource
(Get_String_Name ("test"), Get_String_Name ("test"));
MTU.Append_Node_To_List (N, MTN.Declarations (MAST_File));
if not AINU.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_Processor;
------------------
-- Visit_System --
------------------
procedure Visit_System (E : Node_Id) is
S : Node_Id;
begin
if not AINU.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;
end Ocarina.Backends.MAST.Main;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . M A S T . M A I N --
-- --
-- S p e c --
-- --
-- Copyright (C) 2010, European Space Agency (ESA). --
-- --
-- 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.MAST.Main is
procedure Visit (E : Node_Id);
end Ocarina.Backends.MAST.Main;
......@@ -37,6 +37,7 @@ with Ocarina.Backends.Messages;
with Ocarina.Backends.Utils;
-- with Ocarina.Backends.MAST_Tree.Nodes;
with Ocarina.Backends.MAST_Tree.Nutils;
with Ocarina.Backends.MAST.Main;
with Ocarina.Backends.MAST_Tree.Generator;
with GNAT.Command_Line; use GNAT.Command_Line;
......@@ -137,11 +138,11 @@ package body Ocarina.Backends.MAST is
---------------------------------
procedure Visit_Architecture_Instance (E : Node_Id) is
pragma Unreferenced (E);
begin
MAST_File := MTU.Make_MAST_File
(MTU.Make_Defining_Identifier
(Get_String_Name ("mast-model")));
MAST.Main.Visit (E);
end Visit_Architecture_Instance;
-------------------
......
......@@ -54,6 +54,7 @@ package body Ocarina.Backends.MAST_Tree.Generator is
procedure Generate_Defining_Identifier (N : Node_Id);
procedure Generate_Literal (N : Node_Id);
procedure Generate_MAST_File (N : Node_Id);
procedure Generate_Processing_Resource (N : Node_Id);
procedure Write (T : Token_Type);
procedure Write_Line (T : Token_Type);
......@@ -152,6 +153,9 @@ package body Ocarina.Backends.MAST_Tree.Generator is
when K_Literal =>
Generate_Literal (N);
when K_Processing_Resource =>
Generate_Processing_Resource (N);
when others =>
Display_Error ("other element in generator", Fatal => False);
null;
......@@ -219,4 +223,27 @@ package body Ocarina.Backends.MAST_Tree.Generator is
Release_Output (Fd);
end Generate_MAST_File;
----------------------------------
-- Generate_Processing_Resource --
----------------------------------
procedure Generate_Processing_Resource (N : Node_Id) is
begin
Write_Line ("Processing_Resource (");
Increment_Indentation;
Write_Indentation (-1);
Write_Str ("Type =>");
Write_Name (Node_Type (N));
Write_Line (",");
Write_Indentation (-1);
Write_Str ("Name =>");
Write_Name (Node_Name (N));
Decrement_Indentation;
Write_Indentation (-1);
Write_Line (");");
end Generate_Processing_Resource;
end Ocarina.Backends.MAST_Tree.Generator;
......@@ -491,6 +491,7 @@ package body Ocarina.Backends.MAST_Tree.Nutils is
File : Node_Id;
begin
File := New_Node (K_MAST_File);
MTN.Set_Declarations (File, New_List (MTN.K_List_Id));
Set_Defining_Identifier (File, Identifier);
Set_Corresponding_Node (Identifier, File);
......@@ -521,4 +522,18 @@ package body Ocarina.Backends.MAST_Tree.Nutils is
return N;
end Make_Container;
------------------------------
-- Make_Processing_Resource --
------------------------------
function Make_Processing_Resource (PR_Name : Name_Id; PR_Type : Name_Id)
return Node_Id is
N : Node_Id;
begin
N := New_Node (MTN.K_Processing_Resource);
MTN.Set_Node_Name (N, PR_Name);
MTN.Set_Node_Type (N, PR_Type);
return N;
end Make_Processing_Resource;
end Ocarina.Backends.MAST_Tree.Nutils;
......@@ -167,7 +167,7 @@ package Ocarina.Backends.MAST_Tree.Nutils is
function Make_Container (Content : Node_Id) return Node_Id;
-- function Make_Processing_Resource
-- (Resource_Name : Name_Id; Resource_Type : Name_Id) return Node_Id;
function Make_Processing_Resource (PR_Name : Name_Id; PR_Type : Name_Id)
return Node_Id;
end Ocarina.Backends.MAST_Tree.Nutils;
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