Commit 10f84b1e authored by Bechir Zalila's avatar Bechir Zalila

* (AO4AADL): New frontend for the generic annex language AA4AADL. More

	details on this language are on http://www.redcad.org/projects/AO4AADL/

	(By Sihem Loukil)
parent 2956fa8c
......@@ -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_ao4aadl-ao4aadl_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 \
......
......@@ -40,6 +40,7 @@ project Ocarina.Frontends is
(Src_Dir & "/aadl",
Src_Dir & "/aadl_ba",
Src_Dir & "/aadl_ema",
Src_Dir & "/ao4aadl",
Src_Dir & "/real");
for Object_Dir use Build_Dir & "/objects";
for Library_Dir use Build_Dir & "/libs";
......
......@@ -32,7 +32,6 @@
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;
......@@ -40,6 +39,8 @@ with Ocarina.Transfo.Fusions;
with Ocarina.FE_REAL;
with Ocarina.FE_AADL;
with Ocarina.FE_AADL_BA;
with Ocarina.FE_AADL_EMA;
with Ocarina.FE_AO4AADL;
with Ocarina.Analyzer;
......@@ -203,6 +204,7 @@ package body Ocarina.Configuration is
Ocarina.FE_AADL_BA.Init;
Ocarina.FE_AADL_EMA.Init;
Ocarina.FE_REAL.Init;
Ocarina.FE_AO4AADL.Init;
Ocarina.BE_AADL.Init;
Ocarina.BE_AADL_BA.Init;
Ocarina.BE_REAL.Init;
......@@ -227,6 +229,7 @@ package body Ocarina.Configuration is
Ocarina.FE_AADL_BA.Reset;
Ocarina.FE_AADL_EMA.Reset;
Ocarina.FE_REAL.Reset;
Ocarina.FE_AO4AADL.Reset;
Ocarina.Parser.Reset_Parsers;
Ocarina.Analyzer.Reset_Analyzers;
Ocarina.Backends.Reset;
......
This diff is collapsed.
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . A O 4 A A D L _ V A L U 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) --
-- --
------------------------------------------------------------------------------
-- This package contains the functions related to value management
-- inside the AO4AADL sub-tree.
with Ocarina.Types; use Ocarina.Types;
with Ocarina.Me_AO4AADL.AO4AADL_Tree.Nodes;
use Ocarina.Me_AO4AADL.AO4AADL_Tree.Nodes;
package Ocarina.AO4AADL_Values is
type Literal_Type is (LT_Integer, LT_Real, LT_String, LT_Boolean,
LT_Enumeration, LT_List, LT_Range, LT_Element);
type Value_Type (T : Literal_Type := LT_Integer) is record
case T is
when LT_Integer =>
IVal : Unsigned_Long_Long; -- Absolute value
ISign : Boolean; -- True => Negative
IBase : Unsigned_Short_Short; -- For printing purpose only
IExp : Integer; -- For printing purpose only
when LT_Real =>
RVal : Long_Long_Float; -- Absolute value
RSign : Boolean; -- True => Negative
RBase : Unsigned_Short_Short; -- For printing purpose only
RExp : Integer; -- For printing purpose only
when LT_String =>
SVal : Name_Id;
when LT_Boolean =>
BVal : Boolean;
when LT_Enumeration =>
EVal : Name_Id;
when LT_List =>
LVal : List_Id;
when LT_Element => -- Element of a set
ELVal : Node_Id;
when LT_Range =>
RVal_Left : Long_Long_Float; -- Absolute value
RSign_Left : Boolean; -- True => Negative
RVal_Right : Long_Long_Float; -- Absolute value
RSign_Right : Boolean; -- True => Negative
RVBase : Unsigned_Short_Short; -- For printing purpose only
RVExp : Integer; -- For printing purpose only
end case;
end record;
No_Value : constant Value_Id;
V_Zero : Value_Id;
V_One : Value_Id;
function Get_Value_Type (Value : Value_Id) return Value_Type;
function New_Boolean_Value (Value : Boolean) return Value_Id;
function New_Real_Value
(Value : Long_Long_Float;
Negative : Boolean := False;
Base : Unsigned_Short_Short := 10;
Exp : Integer := 0)
return Value_Id;
function New_Integer_Value
(Value : Unsigned_Long_Long;
Negative : Boolean := False;
Base : Unsigned_Short_Short := 10;
Exp : Integer := 0)
return Value_Id;
function New_String_Value (Value : Name_Id) return Value_Id;
function New_Enum_Value (Value : Name_Id) return Value_Id;
function New_Elem_Value (Value : Node_Id) return Value_Id;
function New_Range_Value
(LValue : Long_Long_Float;
RValue : Long_Long_Float;
LNegative : Boolean := False;
RNegative : Boolean := False;
Base : Unsigned_Short_Short := 10;
Exp : Integer := 0)
return Value_Id;
function New_List_Value (Value : List_Id) return Value_Id;
function New_Value (Value : Value_Type) return Value_Id;
function Value (V : Value_Id) return Value_Type;
procedure Set_Value (V : Value_Id; X : Value_Type);
function AADL_Value (V : Value_Id) return Value_Id;
function Power (Base : Integer; Exp : Integer) return Long_Long_Float;
-- Return (Base ** Exp)
function Image
(Value : Value_Type;
Quoted : Boolean := True)
return String;
function Image
(Value : Value_Id;
Quoted : Boolean := True)
return String;
-- Return the image of the given value. These routines edit the
-- name buffer.
function Image (V : Unsigned_Short_Short) return String;
pragma Inline (Image);
function Image (V : Integer) return String;
pragma Inline (Image);
function Image (V : Unsigned_Long_Long) return String;
pragma Inline (Image);
function Image (V : Long_Long_Float) return String;
pragma Inline (Image);
-- Call Remove_Leading_Spaces (XXXXXX'Image (V))
function Image
(V : Long_Long_Float;
Base : Unsigned_Short_Short;
Exp : Integer)
return String;
function Image
(V : Unsigned_Long_Long;
Base : Unsigned_Short_Short;
Exp : Integer)
return String;
function Image (Kind : Node_Kind) return String;
-- Return corresponding string of node kind
function "*" (L : Value_Type; R : Value_Type) return Value_Type;
-- Return L * R (accept Integer * Real)
function "/" (L : Value_Type; R : Value_Type) return Value_Type;
-- Return L / R (accept Integer * Real)
function "+" (L : Value_Type; R : Value_Type) return Value_Type;
-- Return L + R (accept Integer * Real)
function "-" (L : Value_Type; R : Value_Type) return Value_Type;
-- Return L - R (accept Integer * Real)
function "=" (L : Value_Type; R : Value_Type) return Boolean;
function "<" (L : Value_Type; R : Value_Type) return Boolean;
-- Accept comparison between integer and real
procedure Reset;
-- Reset the value table
private
No_Value : constant Value_Id := 0;
end Ocarina.AO4AADL_Values;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- OCARINA.ME_AO4AADL.AO4AADL_TREE.DEBUG --
-- --
-- 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) --
-- --
------------------------------------------------------------------------------
-- Debug function for REAL tree
with Locations; use Locations;
with Ocarina.Namet; use Ocarina.Namet;
with Utils; use Utils;
package body Ocarina.ME_AO4AADL.AO4AADL_Tree.Debug is
-----------
-- Image --
-----------
function Image (N : Node_Kind) return String is
I : constant String := Node_Kind'Image (N);
begin
return I (3 .. I'Last);
end Image;
function Image (N : Mode_Id) return String is
begin
case N is
when Mode_In =>
return Quoted ("in");
when Mode_Inout =>
return Quoted ("inout");
when Mode_Out =>
return Quoted ("out");
end case;
end Image;
procedure W_Indentation is
begin
for I in 1 .. N_Indents loop
Write_Str (" ");
end loop;
end W_Indentation;
procedure W_Boolean (N : Boolean) is
begin
Write_Str (N'Img);
end W_Boolean;
procedure W_Byte (N : Byte) is
begin
Write_Int (Int (N));
end W_Byte;
procedure W_List_Id (L : List_Id) is
E : Node_Id;
begin
if L = No_List then
return;
end if;
E := First_Node (L);
while E /= No_Node loop
W_Node_Id (E);
E := Next_Node (E);
end loop;
end W_List_Id;
procedure W_Node_Attribute
(A : String;
T : String;
V : String;
N : Int := 0)
is
C : Node_Id;
begin
if A = "Next_Node"
or else A = "Homonym"
or else A = "Name"
then
return;
end if;
N_Indents := N_Indents + 1;
W_Indentation;
Write_Str (A);
Write_Char (' ');
Write_Str (T);
Write_Char (' ');
C := Node_Id (N);
if T = "Name_Id" then
Write_Line (Quoted (V));
elsif T = "Node_Id"
and then Present (C)
then
case Kind (C) is
when others =>
Write_Line (V);
end case;
else
Write_Line (V);
end if;
if T = "Node_Id" then
W_Node_Id (Node_Id (N));
elsif T = "List_Id" then
W_List_Id (List_Id (N));
end if;
N_Indents := N_Indents - 1;
end W_Node_Attribute;
procedure W_Node_Id (N : Node_Id) is
begin
if N = No_Node then
return;
end if;
W_Node (N);
end W_Node_Id;
procedure W_Node_Header (N : Node_Id) is
begin
W_Indentation;
Write_Int (Int (N));
Write_Char (' ');
Write_Str (Image (Kind (N)));
Write_Char (' ');
Write_Line (Image (Loc (N)));
end W_Node_Header;
function Image (N : Name_Id) return String is
begin
if N = No_Name then
return No_Str;
else
return Get_Name_String (N);
end if;
end Image;
function Image (N : Node_Id) return String is
begin
return Image (Int (N));
end Image;
function Image (N : List_Id) return String is
begin
return Image (Int (N));
end Image;
function Image (N : Operator_Id) return String is
begin
return Image (Byte (N));
end Image;
function Image (N : Value_Id) return String is
begin
return Image (Int (N));
end Image;
function Image (N : Boolean) return String is
begin
return Boolean'Image (N);
end Image;
function Image (N : Byte) return String is
begin
return Image (Int (N));
end Image;
function Image (N : Int) return String is
S : constant String := Int'Image (N);
begin
return S (S'First + 1 .. S'Last);
end Image;
end Ocarina.ME_AO4AADL.AO4AADL_Tree.Debug;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- OCARINA.ME_AO4AADL.AO4AADL_TREE.DEBUG --
-- --
-- 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_AO4AADL.AO4AADL_Tree.Nodes;
with Ocarina.Output; use Ocarina.Output;
with Ocarina.Types;
package Ocarina.ME_AO4AADL.AO4AADL_Tree.Debug is
use Ocarina.ME_AO4AADL.AO4AADL_Tree.Nodes;
use Ocarina.Types;
N_Indents : Integer := -1;
procedure W_Eol (N : Natural := 1) renames Output.Write_Eol;
procedure W_Int (N : Int) renames Output.Write_Int;
procedure W_Indentation;
procedure W_Line (N : String) renames Output.Write_Line;
procedure W_Str (N : String) renames Output.Write_Str;
procedure W_Boolean (N : Boolean);
procedure W_Byte (N : Byte);
procedure W_List_Id (L : List_Id);
procedure W_Node_Id (N : Node_Id);
procedure W_Node_Header (N : Node_Id);
procedure W_Node_Attribute
(A : String;
T : String;
V : String;
N : Int := 0);
function Image (N : Node_Kind) return String;
function Image (N : Name_Id) return String;
function Image (N : Node_Id) return String;
function Image (N : List_Id) return String;
function Image (N : Operator_Id) return String;
function Image (N : Boolean) return String;
function Image (N : Byte) return String;
function Image (N : Int) return String;
function Image (N : Value_Id) return String;
function Image (N : Mode_Id) return String;
end Ocarina.ME_AO4AADL.AO4AADL_Tree.Debug;
// AO4AADL Tree
module Ocarina::ME_AO4AADL::AO4AADL_Tree::Nodes {
/******************/
/* Internal types */
/******************/
typedef octet Mode_Id;
typedef long Name_Id;
typedef long Value_Id;
/******************/
/* Internal nodes */
/******************/
interface Node_Id {
Node_Id Next_Node; // Link nodes together
};
interface Identifier : Node_Id {
Name_Id Name;
};
interface List_Id {
Node_Id First_Node;
Node_Id Last_Node;
};
interface Node_Container : Node_Id {
Node_Id Item;
};
interface Definition : Node_Id {
Node_Id Identifier;
};
interface Wildcard : Node_Id {
};
interface Star : Wildcard {
};
interface Interval : Wildcard {
};
interface Literal : Node_Id {
Value_Id Value;
};
/*
Aspect_Annex ::= { Aspect_Expression }+
*/
interface Aspect_Annex : Node_Id {
List_Id Aspect_Expressions;
// une annexe peut avoir 1 ou plusieurs "Aspect_Expression"
};
/*
Aspect_Expression ::= aspect Aspect_Identifier {
[ Aspect_Precedence; ]
[ Components_applied_to; ]
{ Pointcut_Specification; }+
{ Advice_Specification }+
}
*/
interface Aspect_Expression : Definition {
Node_Id Components_Applied_Tos;
// un aspect "Aspect_Expression" peut etre appliqué à plusieurs
// composants AADL
Node_Id Aspect_Precedence;
List_Id Pointcut_Specification;
// un aspect "Aspect_Expression" peut avoir plusieurs pointcuts
List_Id Advice_Specification;
// un aspect "Aspect_Expression" peut avoir plusieurs advices
};
/*
Components_applied_to ::= applied to ListComponents
ListComponents ::= Component { ,Component }*
*/
interface Components_Applied_To : Node_Id {
List_Id Components;
// un aspect "Aspect_Expression" peut etre appliqué à plusieurs
// composants AADL
};
/*
Component ::= Component_Category Component_Identifier
Component_Category ::= thread | process | subprogram
*/
interface Component : Definition {
octet Component_Category;
// pour spécifier les composants aux quels est appliqué un aspect,