Commit 1eb91182 authored by Bechir Zalila's avatar Bechir Zalila
Browse files

* Added support for parsing and analyzing the Error modeling

	annex EMV2.
	 (Work of End of Study internship, Fatma Kacem, ENIS, 2015)
parent f03b0eab
......@@ -57,6 +57,7 @@ TREE_PIDL_SPECS = src/core/tree/ocarina-me_aadl-aadl_tree-nodes.idl \
src/core/tree/ocarina-me_aadl-aadl_instances-nodes.idl \
src/core/tree/ocarina-me_aadl_ba-ba_tree-nodes.idl \
src/core/tree/ocarina-me_real-real_tree-nodes.idl \
src/core/tree/ocarina-me_aadl_ema-ema_tree-nodes.idl \
src/backends/ocarina-backends-ada_tree-nodes.idl \
src/backends/ocarina-backends-c_tree-nodes.idl \
src/backends/ocarina-backends-asn1_tree-nodes.idl \
......
......@@ -6,7 +6,7 @@
-- --
-- P r o j e c t --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -39,6 +39,7 @@ project Ocarina.Frontends is
for Source_Dirs use
(Src_Dir & "/aadl",
Src_Dir & "/aadl_ba",
Src_Dir & "/aadl_ema",
Src_Dir & "/real");
for Object_Dir use Build_Dir & "/objects";
for Library_Dir use Build_Dir & "/libs";
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2006-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -32,6 +32,7 @@
with Ocarina.Backends;
with Ocarina.BE_AADL;
with Ocarina.BE_AADL_BA;
with Ocarina.FE_AADL_EMA;
with Ocarina.BE_REAL;
with Ocarina.Transfo;
with Ocarina.Transfo.Fusions;
......@@ -200,6 +201,7 @@ package body Ocarina.Configuration is
Ocarina.Analyzer.Init_Analyzers;
Ocarina.FE_AADL.Init;
Ocarina.FE_AADL_BA.Init;
Ocarina.FE_AADL_EMA.Init;
Ocarina.FE_REAL.Init;
Ocarina.BE_AADL.Init;
Ocarina.BE_AADL_BA.Init;
......@@ -223,6 +225,7 @@ package body Ocarina.Configuration is
Installation_Directory := No_Name;
Ocarina.FE_AADL.Reset;
Ocarina.FE_AADL_BA.Reset;
Ocarina.FE_AADL_EMA.Reset;
Ocarina.FE_REAL.Reset;
Ocarina.Parser.Reset_Parsers;
Ocarina.Analyzer.Reset_Analyzers;
......
......@@ -6,28 +6,26 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010-2016 ESA & ISAE. --
-- --
-- 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. --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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. --
-- --
-- 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. --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- Ocarina is maintained by the Ocarina team --
-- (ocarina-users@listes.enst.fr) --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
......
......@@ -6,28 +6,26 @@
-- --
-- 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) --
-- Copyright (C) 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -154,6 +154,8 @@ package body Ocarina.Options is
Set_Annex_Action (Disable_REAL);
elsif Tmp_Name = Get_String_Name ("behavior_specification") then
Set_Annex_Action (Disable_BA);
elsif Tmp_Name = Get_String_Name ("emv2") then
Set_Annex_Action (Disable_EMA);
elsif Tmp_Name = Get_String_Name ("all") then
Set_Annex_Action (Disable_ALL);
exit;
......@@ -178,6 +180,8 @@ package body Ocarina.Options is
Get_String_Name ("behavior_specification");
Real_Language_Name : constant Name_Id :=
Get_String_Name ("real_specification");
Error_Language_Name : constant Name_Id :=
Get_String_Name ("emv2");
Perform : Boolean := True;
begin
if Current_Annex_Action (Disable_ALL) = 1 then
......@@ -192,6 +196,12 @@ package body Ocarina.Options is
and then Current_Annex_Action (Disable_REAL) = 1
then
Perform := False;
elsif Language = Error_Language_Name
and then Current_Annex_Action (Disable_EMA) = 1
then
Perform := False;
end if;
return Perform;
......
......@@ -82,7 +82,10 @@ package Ocarina.Options is
procedure Add_Library_Path (Path : String);
-- Add a library path in Library_Paths
type Annex_Action_Kind is (Disable_BA, Disable_REAL, Disable_ALL);
type Annex_Action_Kind is (Disable_BA,
Disable_REAL,
Disable_EMA,
Disable_ALL);
type Annex_Action is array (Annex_Action_Kind) of Byte;
......
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . A N A L Y Z E R . A A D L . A N N E X E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
with Ocarina.Analyzer;
with Ocarina.Analyzer.AADL.Finder;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_REAL.Tokens;
with Ocarina.ME_AADL_EMA.EMA_Tokens;
with Ocarina.ME_AADL_BA.Tokens;
with Ocarina.Instances;
with Ocarina.Namet;
with Errors;
with Charset;
with Utils;
package body Ocarina.Analyzer.AADL.Annexes is
use Ocarina.Analyzer;
use Ocarina.Analyzer.AADL.Finder;
use Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.Instances;
use Ocarina.Namet;
use Errors;
package RT renames Ocarina.ME_REAL.Tokens;
package EMAT renames Ocarina.ME_AADL_EMA.EMA_Tokens;
package BAT renames Ocarina.ME_AADL_BA.Tokens;
function Analyze (Language : Name_Id;
Language_Annex : String;
Root : Node_Id) return Boolean;
-- Allows to analyze all the annexes in the aadl model
procedure Execute_Analyze (Exist_Real : in out Boolean;
Exist_EMA : in out Boolean;
Exist_BA : in out Boolean;
Success : in out Boolean;
Root : Node_Id;
Ni : Node_Id);
-------------
-- Analyze --
-------------
function Analyze (Language : Name_Id;
Language_Annex : String;
Root : Node_Id) return Boolean
is
Success : Boolean := False;
Instance_Root : Node_Id;
begin
-- for real annex Analyze_Model takes the aadl root of
-- instance tree as parameter
if Language_Annex = RT.Language then
Instance_Root := Instantiate_Model (Root);
end if;
if Language_Annex = RT.Language then
Success := Analyze (Language, Instance_Root);
else
Success := Analyze (Language, Root);
end if;
Exit_On_Error (not Success, "Cannot analyze " &
Charset.To_Upper (Language_Annex) & " specifications");
return Success;
end Analyze;
--------------------------
-- Find_Analyze_Annexes --
--------------------------
-- if we find a type of the annexes : real or ema
-- then we call the function analyze once.
-- The function analyze model will do the search of the
-- rest of the annexes by her self
function Find_Analyze_Annexes (Root : Node_Id) return Boolean
is
L1 : Node_List;
L2 : Node_List;
N1 : Node_Id;
N2 : Node_Id;
Success : Boolean := True;
Is_Library : Boolean := False;
Exist_EMA : Boolean := False;
Exist_Real : Boolean := False;
Exist_BA : Boolean := False;
begin
L1 := Find_All_Declarations (Root,
(K_Component_Type,
K_Component_Implementation,
K_Feature_Group_Type,
K_Annex_Library));
N1 := L1.First;
while Present (N1) loop
if Kind (N1) = K_Feature_Group_Type then
L2 := Find_All_Subclauses
(N1, (1 => K_Annex_Subclause));
-- FIXME : subclause annexes in Feature_Group_Type
-- are not supported
elsif Kind (N1) = K_Annex_Library then
Is_Library := True;
else
L2 := Find_All_Subclauses (N1, (1 => K_Annex_Subclause));
end if;
if Is_Library then
Execute_Analyze (Exist_Real, Exist_EMA, Exist_BA,
Success, Root, N1);
-- FIXME : we can't have more than one annex library of the
-- same type
else
N2 := L2.First;
while Present (N2) loop
Execute_Analyze (Exist_Real, Exist_EMA, Exist_BA,
Success, Root, N2);
N2 := Next_Entity (N2);
end loop;
end if;
N1 := Next_Entity (N1);
end loop;
return Success;
end Find_Analyze_Annexes;
---------------------
-- Execute_Analyze --
---------------------
procedure Execute_Analyze (Exist_Real : in out Boolean;
Exist_EMA : in out Boolean;
Exist_BA : in out Boolean;
Success : in out Boolean;
Root : Node_Id;
Ni : Node_Id)
is
Language : Name_Id;
begin
Language := Utils.To_Lower
(Name (Identifier (Ni)));
if Get_Name_String (Language) = RT.Language
and then Present (Corresponding_Annex (Ni))
then
if not Exist_Real then
Success := Success and then Analyze
(Language, Get_Name_String (Language), Root);
end if;
Exist_Real := True;
elsif Get_Name_String (Language) = EMAT.Language
and then Present (Corresponding_Annex (Ni))
then
if not Exist_EMA then
Success := Success and then Analyze
(Language, Get_Name_String (Language), Root);
end if;
Exist_EMA := True;
elsif Get_Name_String (Language) = BAT.Language
and then Present (Corresponding_Annex (Ni))
then
if not Exist_BA then
Success := Success and then Analyze
(Language, Get_Name_String (Language), Root);
end if;
Exist_BA := True;
end if;
end Execute_Analyze;
end Ocarina.Analyzer.AADL.Annexes;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . A N A L Y Z E R . A A D L . A N N E X E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
package Ocarina.Analyzer.AADL.Annexes is
function Find_Analyze_Annexes (Root : Node_Id) return Boolean;
end Ocarina.Analyzer.AADL.Annexes;
......@@ -34,6 +34,7 @@ with Ocarina.Analyzer.AADL.Names;
with Ocarina.Analyzer.AADL.Links;
with Ocarina.Analyzer.AADL.Semantics;
with Ocarina.Analyzer.AADL.Naming_Rules;
with Ocarina.Analyzer.AADL.Annexes;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Tree.Nutils;
......@@ -50,6 +51,7 @@ package body Ocarina.Analyzer.AADL is
use Ocarina.Analyzer.AADL.Links;
use Ocarina.Analyzer.AADL.Semantics;
use Ocarina.Analyzer.AADL.Naming_Rules;
use Ocarina.Analyzer.AADL.Annexes;
use Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.ME_AADL.AADL_Tree.Nutils;
use Ocarina.ME_AADL.AADL_Tree.Entities;
......@@ -126,6 +128,9 @@ package body Ocarina.Analyzer.AADL is
and then Link_Properties_Of_AADL_Description (Root)
and then Check_Semantics_Of_Properties (Root);
Success := Success
and then Find_Analyze_Annexes (Root);
if Success
and then Get_Current_Action = Analyze_Model
and then Debug_Mode
......
This diff is collapsed.
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . A N A L Y Z E R . A A D L _ E M A . F I N D E R --
-- --
-- S p e c --
-- --
-- Copyright (C) 2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
with Ocarina.ME_AADL_EMA.EMA_Tree.Nodes;
package Ocarina.Analyzer.AADL_EMA.Finder is
type Node_Kind_Array is array (Positive range <>)
of Ocarina.ME_AADL_EMA.EMA_Tree.Nodes.Node_Kind;
type Int_Array is
array (Integer range <>) of Integer;
procedure Get_EMA_Annexes_List
(AADL_Root : Node_Id;
List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id;
Package_Spec_First : in out Node_Id;
Package_Spec_Last : in out Node_Id);
procedure Select_Nodes
(Parent_Node : List_Id;
Kinds : Node_Kind_Array;
List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id);
procedure Select_Nodes_Of_List_Identifiers
(Parent_Node : Node_Id;
Kinds : Node_Kind_Array;
List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id);
procedure Test_With_Package_Name_Alias
(AADL_Root : Node_Id;
Package_EMA : Node_Id;
Package_Spec : Node_Id;
Success : in out Boolean;
AADL_Package_Referenced : out Node_Id;
Identifier_Node : out Node_Id;
Pckg_Original_Name : out Node_Id;
Not_Allowed_Reference_Itself : out Boolean);
procedure Get_Error_Type_Reference_Of_Error_Type_Library
(EMA_Root : Node_Id;
List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id);
procedure Get_Error_Type_Set_Reference_Of_Error_Type_Library
(EMA_Root : Node_Id;
List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id);
function Search_Package_Annex_Root
(AADL_Root : Node_Id;
Package_Spec : Node_Id)
return Node_Id;
procedure Find_Error_Type_Library_Element
(Error_Type_Library_Node : Node_Id;
List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id;
Record_Identifier : Boolean := True);
procedure Put_In_A_List_Node (List_First_Node : in out Node_Id;
List_Last_Node : in out Node_Id;
Pckg_Name : Node_Id);
procedure Get_Error_Type_Id
(AADL_Root : Node_Id;
Pckg_Spec : Node_Id;
Identifiers_First : in out Node_Id;
Identifiers_Last : in out Node_Id;
Is_Set : Boolean);
function Find_Package_Annex_Library
(AADL_Root : Node_Id;
EMA_Root : Node_Id)
return Node_Id;
end Ocarina.Analyzer.AADL_EMA.Finder;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . A N A L Y Z E R . A A D L _ E M A . L I N K S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2016 ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --