Commit c08f8865 authored by yoogx's avatar yoogx

* Adjust mapping rules

parent 80decb60
......@@ -30,14 +30,14 @@
-- (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;
with GNAT.Command_Line;
with Ocarina.Backends.Utils;
with Ada.Text_IO;
package body Ocarina.Backends.Alloy is
......@@ -47,6 +47,7 @@ package body Ocarina.Backends.Alloy is
use Ocarina.Namet;
use Ada.Text_IO;
use Ocarina.ME_AADL;
use Ocarina.Backends.Utils;
use AIN;
procedure Visit (E : Node_Id);
......@@ -56,6 +57,7 @@ package body Ocarina.Backends.Alloy is
procedure Visit_Component_Instance (E : Node_Id);
FD : File_Type;
Root_System_Name : Name_Id;
-----------
-- Visit --
......@@ -106,8 +108,8 @@ package body Ocarina.Backends.Alloy is
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"));
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);
......@@ -120,13 +122,19 @@ package body Ocarina.Backends.Alloy is
if Present (Parent_Subcomponent (E)) then
Put_Line (FD, "one sig " &
Get_Name_String
(Display_Name (Identifier (Parent_Subcomponent (E))))
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 " &
Get_Name_String (Display_Name (Identifier (E)))
& " extends Component{}{");
To_Lower (Get_Name_String (Root_System_Name))
& " extends Component{}{");
end if;
......@@ -141,9 +149,11 @@ package body Ocarina.Backends.Alloy is
while Present (T) loop
declare
Subcomponent_Name : constant String :=
String'(Get_Name_String
(Display_Name
(Identifier (T))));
To_Lower
(Get_Name_String
(Normalize_Name
(Fully_Qualified_Instance_Name
(Corresponding_Instance (T)))));
begin
Put (FD, Subcomponent_Name);
......@@ -165,7 +175,12 @@ package body Ocarina.Backends.Alloy is
if Present (AIN.Properties (E)) then
T := First_Node (AIN.Properties (E));
while Present (T) loop
Put (FD, Get_Name_String (Display_Name (Identifier (T))));
Put (FD,
To_Lower
(Get_Name_String
(Normalize_Name
(Display_Name
(Identifier (T))))));
T := Next_Node (T);
if Present (T) then
Put (FD, "+");
......@@ -180,6 +195,7 @@ package body Ocarina.Backends.Alloy is
-- Close create of component
Put_Line (FD, "}");
New_Line (FD);
-- Iterate over subcomponents
......@@ -236,14 +252,36 @@ package body Ocarina.Backends.Alloy is
Create (File => FD, Name => "tran_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 tran_model");
Put_Line (FD, "open 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);
-- Close file descriptors
-- 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, "}");
Put_Line (FD, ASCII.HT & "assumption=none");
Put_Line (FD, ASCII.HT & "input=none");
Put_Line (FD, ASCII.HT & "guarantee=none");
Put_Line (FD, ASCII.HT & "output="
& To_Lower (Get_Name_String (Root_System_Name)));
Put_Line (FD, "}");
-- Close file descriptor
Close (FD);
end Generate;
......
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