Commit 2b46fc52 authored by yoogx's avatar yoogx
Browse files

Merge branch 'master' into spark2014

parents 57f765df 1c7c282a
......@@ -20,3 +20,4 @@ tools/compare.py
log.*
support/headers_ocarina*
auto.cgpr
SUBDIRS = support tools projects src resources projects-distrib examples @DOC_DIR@
SUBDIRS = support tools projects src resources projects-distrib examples doc
AUTOMAKE_OPTIONS = no-dependencies
ACLOCAL_AMFLAGS = -I support
......
......@@ -195,7 +195,7 @@ AC_SUBST(EXE_SUFFIX)
root="`dirname $0`"
AC_MSG_CHECKING([default services])
AC_MSG_CHECKING([AADL runtime to build])
AC_ARG_WITH(ocarina-runtimes,
AS_HELP_STRING([--with-ocarina-runtimes=x], [enumerate runtimes]),
[
......@@ -203,7 +203,6 @@ AS_HELP_STRING([--with-ocarina-runtimes=x], [enumerate runtimes]),
AM_CONDITIONAL(PO_HI_ADA, false)
AM_CONDITIONAL(PO_HI_C, false)
AM_CONDITIONAL(PO_HI_JAVA, false)
AM_CONDITIONAL(PO_QOS_ADA, false)
AM_CONDITIONAL(POK, false)
newwithval=`echo ${withval} | tr "[A-Z]" "[a-z]"`
......@@ -211,7 +210,7 @@ AS_HELP_STRING([--with-ocarina-runtimes=x], [enumerate runtimes]),
do
case ${R} in
all )
for P in polyorb-hi-ada polyorb-hi-c polyorb-qos-ada polyorb-hi-java
for P in polyorb-hi-ada polyorb-hi-c polyorb-hi-java
do
if test -d ${root}/resources/runtime/${P}
then
......@@ -224,13 +223,11 @@ AS_HELP_STRING([--with-ocarina-runtimes=x], [enumerate runtimes]),
AM_CONDITIONAL(PO_HI_ADA, true)
AM_CONDITIONAL(PO_HI_C, true)
AM_CONDITIONAL(PO_HI_JAVA, true)
AM_CONDITIONAL(PO_QOS_ADA, true)
;;
none )
AM_CONDITIONAL(PO_HI_ADA, false)
AM_CONDITIONAL(PO_HI_C, false)
AM_CONDITIONAL(PO_QOS_ADA, false)
;;
pok )
......@@ -273,16 +270,6 @@ AS_HELP_STRING([--with-ocarina-runtimes=x], [enumerate runtimes]),
AM_CONDITIONAL(PO_HI_JAVA, true)
;;
polyorb-qos-ada )
if test -d ${root}/resources/runtime/${R}
then
RUNTIME_LIST="${RUNTIME_LIST}${R} "
else
AC_MSG_ERROR([runtime ${R} not found])
fi
AM_CONDITIONAL(PO_QOS_ADA, true)
;;
* )
AC_MSG_ERROR([unknown runtime ${R}])
;;
......@@ -292,11 +279,18 @@ AS_HELP_STRING([--with-ocarina-runtimes=x], [enumerate runtimes]),
],
[
RUNTIME_LIST=""
for P in polyorb-hi-ada polyorb-hi-c polyorb-hi-java
do
if test -d ${root}/resources/runtime/${P}
then
RUNTIME_LIST="${RUNTIME_LIST}${P} "
fi
done
AM_CONDITIONAL(POK, test -d "${root}/resources/runtime/pok")
AM_CONDITIONAL(PO_HI_ADA, test -d "${root}/resources/runtime/polyorb-hi-ada")
AM_CONDITIONAL(PO_HI_C, test -d "${root}/resources/runtime/polyorb-hi-c")
AM_CONDITIONAL(PO_HI_JAVA, test -d "${root}/resources/runtime/polyorb-hi-java")
AM_CONDITIONAL(PO_QOS_ADA, test -d "${root}/resources/runtime/polyorb-qos-ada")
])
AC_MSG_RESULT(${RUNTIME_LIST})
AC_SUBST(RUNTIME_LIST)
......@@ -379,18 +373,18 @@ AC_SUBST(CYGPATH_U)
AC_CHECK_PROGS(TEXI2HTML, texi2html)
DOC_DIR=
DOC_TARGETS=
DOC_FLAG=
AC_ARG_ENABLE(doc,
[ --enable-doc Build documentation [default=no]],
[if [[ "$enableval" = "yes" ]]; then
DOC_DIR=doc
DOC_TARGETS=docs
DOC_FLAG=--enable-doc
fi],
[])
AC_SUBST(DOC_DIR)
AC_SUBST(DOC_TARGETS)
AC_SUBST(DOC_FLAG)
##########################################
......
SUBDIRS=real
GUIDE=ocarina
man_MANS = ocarina-config.1 ocarina.1
......@@ -7,12 +9,13 @@ GUIDE_RSTFILES = $(srcdir)/about.rst $(srcdir)/gfdl.rst \
$(srcdir)/python.rst $(srcdir)/editors.rst \
$(srcdir)/installation.rst $(srcdir)/usage.rst
EXTRA_DIST= $(srcdir)/CODING_GUIDELINES $(srcdir)/CONTRIBUTING \
$(srcdir)/PROBLEM-REPORT-FORM $(GUIDE_TEXIFILES) $(ALL_IMAGES) \
$(man_MANS) $(srcdir)/ocarina-config.html \
$(srcdir)/ocarina_man.html
EXTRA_DIST= $(srcdir)/PROBLEM-REPORT-FORM $(GUIDE_TEXIFILES) \
$(ALL_IMAGES) $(man_MANS) $(srcdir)/ocarina-config.html \
$(srcdir)/ocarina_man.html $(srcdir)/ocarina.css
docs: $(GUIDE).html $(GUIDE).pdf
all-local: $(GUIDE).html $(GUIDE).pdf
all-local: @DOC_TARGETS@
$(GUIDE).html: $(GUIDE_RSTFILES)
make html
......@@ -37,7 +40,8 @@ dist-hook: all
if [ -r $(GUIDE).pdf ]; then \
cp -p -r $(GUIDE).html $(GUIDE).pdf $(distdir); \
cp -p $(SED_FILES) $(distdir); \
else \
fi
if [ -r $(srcdir)/$(GUIDE).pdf ]; then \
cp -r $(srcdir)/$(GUIDE).html $(srcdir)/$(GUIDE).pdf $(distdir); \
cp -p ${addprefix $(srcdir)/, $(SED_FILES)} $(distdir); \
fi
......
......@@ -13,7 +13,9 @@ export TEXINPUTS:=$(texinputs)
bibinputs:=$(srcdir):$(BIBINPUTS)
export BIBINPUTS:=$(bibinputs)
all-local: $(LATEX_FILE).tex biblio.bib $(REAL_CODE)
all-local:
build: $(LATEX_FILE).tex biblio.bib $(REAL_CODE)
latex $(srcdir)/$(LATEX_FILE).tex ;
bibtex $(LATEX_FILE) ;
latex $(srcdir)/$(LATEX_FILE).tex ;
......@@ -34,7 +36,7 @@ distclean-local: clean
install-data-local: all
$(INSTALL) -d $(DESTDIR)$(datadir)/doc/ocarina
$(INSTALL_DATA) $(LATEX_FILE).pdf $(DESTDIR)$(datadir)/doc/ocarina
-$(INSTALL_DATA) $(LATEX_FILE).pdf $(DESTDIR)$(datadir)/doc/ocarina
EXTRA_DIST= $(srcdir)/sources2/range_set.real \
$(srcdir)/sources2/evaluation.real $(srcdir)/sources2/data.aadl \
......
......@@ -4,7 +4,7 @@ include $(top_srcdir)/Makefile.common
BUILD_PROJECTS= ocarina-core.gpr ocarina-frontends.gpr \
ocarina-backends.gpr ocarina-config.gpr ocarina-transfo.gpr \
ocarina-main.gpr
ocarina-main.gpr $(PYTHON_PRJ)
# All project files have to be packaged with "make dist"
......@@ -26,7 +26,8 @@ OBJECT_DIRS = $(top_builddir)/src/core/objects \
$(top_builddir)/src/frontends/objects \
$(top_builddir)/src/backends/objects \
$(top_builddir)/src/transfo/objects \
$(top_builddir)/src/main/objects
$(top_builddir)/src/main/objects \
$(top_builddir)/src/python/objects
# Library directories (*.ali, *.a)
......@@ -34,7 +35,8 @@ LIB_DIRS = $(top_builddir)/src/core/libs \
$(top_builddir)/src/frontends/libs \
$(top_builddir)/src/backends/libs \
$(top_builddir)/src/transfo/libs \
$(top_builddir)/src/config/libs $(top_builddir)/src/main/libs
$(top_builddir)/src/config/libs $(top_builddir)/src/main/libs \
$(top_builddir)/src/python/libs
# All directories used for the build process. If the configure is
# performed from a directory different from the top source directory,
......
......@@ -59,7 +59,7 @@ project Ocarina is
"-gnatoa",
"-fstack-check",
"-gnaty",
"-gnatwl",
"-gnatwL", -- elaboration warnings disabled
"-gnatyu", -- not in -gnaty: check multiple blank lines
"-gnatys", -- not in -gnatx: check useless parentheses
@GCOV@"-fprofile-arcs",
......
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . A L L O Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 2014 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. --
-- --
-- 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 TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
with Charset; use Charset;
with Ocarina.Namet;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.Instances; use Ocarina.Instances;
with Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.ME_AADL.AADL_Instances.Entities;
with GNAT.Command_Line;
with Ocarina.Backends.Utils;
with Ada.Text_IO;
package body Ocarina.Backends.Alloy is
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.Namet;
use Ada.Text_IO;
use Ocarina.ME_AADL;
use Ocarina.Backends.Utils;
use AIN;
procedure Visit (E : Node_Id);
procedure Visit_Architecture_Instance (E : Node_Id);
procedure Visit_Component_Instance (E : Node_Id);
FD : File_Type;
Root_System_Name : Name_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_Name_String : constant array
(Component_Category'Range) of Name_Id :=
(CC_Abstract => Get_String_Name ("abstract"),
CC_Bus => Get_String_Name ("bus"),
CC_Data => Get_String_Name ("data"),
CC_Device => Get_String_Name ("device"),
CC_Memory => Get_String_Name ("memory"),
CC_Process => Get_String_Name ("process"),
CC_Processor => Get_String_Name ("processor"),
CC_Subprogram => Get_String_Name ("subprogram"),
CC_Subprogram_Group => Get_String_Name ("subprogram group"),
CC_System => Get_String_Name ("system"),
CC_Thread => Get_String_Name ("thread"),
CC_Thread_Group => Get_String_Name ("thread group"),
CC_Unknown => No_Name,
CC_Virtual_Bus => Get_String_Name ("virtual_bus"),
CC_Virtual_Processor => Get_String_Name ("virtual_processor"));
Category : constant Component_Category := Get_Category_Of_Component (E);
T : Node_Id;
begin
-- Create Alloy component
-- Rule #1: the name of this component is deduced from the name
-- of the corresponding instance name
if Present (Parent_Subcomponent (E)) then
Put_Line (FD, "one sig " &
To_Lower
(Get_Name_String
(Normalize_Name
(Fully_Qualified_Instance_Name (E))))
& " extends Component{}{");
else
Put_Line (Kind (E)'Img);
Root_System_Name := Normalize_Name
(Display_Name (Identifier (E)));
Put_Line (FD, "one sig " &
To_Lower (Get_Name_String (Root_System_Name))
& " extends Component{}{");
end if;
Put_Line (FD, ASCII.HT & "type="
& Get_Name_String (Category_Name_String (Category)));
-- Rule #2: list subcomponents
Put (FD, ASCII.HT & "subcomponents=");
if Present (Subcomponents (E)) then
T := First_Node (Subcomponents (E));
while Present (T) loop
declare
Subcomponent_Name : constant String :=
To_Lower
(Get_Name_String
(Normalize_Name
(Fully_Qualified_Instance_Name
(Corresponding_Instance (T)))));
begin
Put (FD, Subcomponent_Name);
T := Next_Node (T);
if Present (T) then
Put (FD, "+");
end if;
end;
end loop;
New_Line (FD);
else
Put_Line (FD, "none");
end if;
-- Rule#3: list properties
Put (FD, ASCII.HT & "properties=");
if Present (AIN.Properties (E)) then
T := First_Node (AIN.Properties (E));
while Present (T) loop
Put (FD,
To_Lower
(Get_Name_String
(Normalize_Name
(Display_Name
(Identifier (T))))));
T := Next_Node (T);
if Present (T) then
Put (FD, "+");
end if;
end loop;
New_Line (Fd);
else
Put_Line (FD, "none");
end if;
-- Close create of component
Put_Line (FD, "}");
New_Line (FD);
-- Iterate over subcomponents
if Present (Subcomponents (E)) then
T := First_Node (Subcomponents (E));
while Present (T) loop
Visit (Corresponding_Instance (T));
T := Next_Node (T);
end loop;
end if;
end Visit_Component_Instance;
----------
-- Init --
----------
procedure Init is
begin
-- Registration of the generator
Register_Backend ("alloy", Generate'Access, Alloy_Backend);
end Init;
--------------
-- Generate --
--------------
procedure Generate (AADL_Root : Node_Id) is
use GNAT.Command_Line;
Instance_Root : Node_Id;
begin
-- Instantiate the AADL tree
Instance_Root := Instantiate_Model (AADL_Root);
if No (Instance_Root) then
raise Program_Error;
end if;
Initialize_Option_Scan;
loop
case Getopt ("* ") is
when ASCII.NUL =>
exit;
when others =>
null;
end case;
end loop;
-- Open a new .als file
Create (File => FD, Name => "con_model.als");
Put_Line (FD, "// This file has been generated by Ocarina");
Put_Line (FD, "// DO NOT EDIT IT");
New_Line (FD);
Put_Line (FD, "module con_model");
Put_Line (FD, "open alloy/common/lib_sig");
New_Line (FD);
-- Visit instance model
New_Line (FD);
Put_Line (FD, "// Mapping of the AADL instance tree");
New_Line (FD);
Visit_Architecture_Instance (Instance_Root);
-- Add global contract
New_Line (FD);
Put_Line (FD, "// Declaration of the contract(s) "
& "representing the model(s)");
New_Line (FD);
Put_Line (FD, "one sig aadl_model extends Contract{}{");
Put_Line (FD, ASCII.HT & "assumption=none");
Put_Line (FD, ASCII.HT & "input=none");
Put_Line (FD, ASCII.HT & "guarantee=none");
-- Generate output
declare
Print_Subcomponents : Boolean := True;
E : constant Node_Id := Root_System (Instance_Root);
T : Node_Id;
begin
-- We consider two patterns
-- a) system with subcomponents as system/bus/device only
-- b) general case
if Present (Subcomponents (E)) then
T := First_Node (Subcomponents (E));
while Present (T) loop
Print_Subcomponents := Print_Subcomponents
and then (Get_Category_Of_Component (T) = CC_System
or else Get_Category_Of_Component (T) = CC_Device
or else Get_Category_Of_Component (T) = CC_Bus);
T := Next_Node (T);
end loop;
end if;
-- We are in case a), generate all subcomponents of root system
if Print_Subcomponents then
Put (Fd, ASCII.HT & "output=");
if Present (Subcomponents (E)) then
T := First_Node (Subcomponents (E));
while Present (T) loop
declare
Subcomponent_Name : constant String :=
To_Lower
(Get_Name_String
(Normalize_Name
(Fully_Qualified_Instance_Name
(Corresponding_Instance (T)))));
begin
Put (FD, Subcomponent_Name);
T := Next_Node (T);
if Present (T) then
Put (FD, "+");
end if;
end;
end loop;
New_Line (FD);
else
Put_Line (FD, "none");
end if;
else
-- We are in case b), generate only root system
Put_Line (FD, ASCII.HT & "output="
& To_Lower (Get_Name_String (Root_System_Name)));
end if;
end;
Put_Line (FD, "}");
-- Close file descriptor
Close (FD);
end Generate;
-----------
-- Reset --
-----------
procedure Reset is
begin
null;
end Reset;
end Ocarina.Backends.Alloy;
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . B A C K E N D S . A L L O Y --
-- --
-- S p e c --
-- --
-- Copyright (C) 2014 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. --
-- --
-- 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 TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
package Ocarina.Backends.Alloy is
procedure Init;
-- Initialize Ocarina.
-- To be called before any action.
procedure Generate (AADL_Root : Node_Id);
-- Generate TPO file for Bound-T
procedure Reset;
-- Reset the internal data
end Ocarina.Backends.Alloy;
......@@ -124,9 +124,9 @@ package body Ocarina.Backends.BoundT is
(AIN.Name (AIN.Identifier (AIN.Parent_Subcomponent (E)))) =
Boundt_Process
then
Visit_Process_Instance (E);
end if;
when CC_Thread =>
Visit_Thread_Instance (E);
......
......@@ -333,6 +333,12 @@ package body Ocarina.Backends.Utils is
if Ada_Style then
Add_Char_To_Name_Buffer ('_');
end if;
elsif Initial_Name (Index) = ':' then
Add_Char_To_Name_Buffer ('_');
if Ada_Style then
Add_Char_To_Name_Buffer ('_');
end if;
else
Add_Char_To_Name_Buffer (Initial_Name (Index));