Commit 6402696c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Improve code clarity

parent ddcfeb92
......@@ -96,49 +96,6 @@ procedure AADL_Parser is
-- Current_function is read from the list of system subcomponents
-------------------------------------
-- Load_Deployment_View_Properties --
-------------------------------------
procedure Load_Deployment_View_Properties (Root_Tree : in out Node_Id) is
Loc : Location;
F : Name_Id;
package Vectors is new Ada.Containers.Indefinite_Vectors (Natural,
String);
use Vectors;
AADL_Lib : Vectors.Vector;
begin
if Root_Tree = No_Node then
return;
end if;
AADL_Lib := AADL_Lib &
Ada.Command_Line.Argument (Interface_View) &
"aadl_project.aadl" &
"taste_properties.aadl" &
"Cheddar_Properties.aadl" &
"communication_properties.aadl" &
"deployment_properties.aadl" &
"thread_properties.aadl" &
"timing_properties.aadl" &
"programming_properties.aadl" &
"memory_properties.aadl" &
"modeling_properties.aadl" &
"arinc653.aadl" &
"base_types.aadl" &
"data_model.aadl" &
"deployment.aadl";
Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;
for each of AADL_Lib loop
Set_Str_To_Name_Buffer (each);
F := Ocarina.Files.Search_File (Name_Find);
Loc := Ocarina.Files.Load_File (F);
Root_Tree := Ocarina.Parser.Parse (AADL_Language, Root_Tree, Loc);
end loop;
end Load_Deployment_View_Properties;
-----------------------------------
-- Browse_Deployment_View_System --
-----------------------------------
......@@ -546,7 +503,7 @@ begin
Get_String_Name ("interfaceview.others");
IV_Root := Root_System (Instantiate_Model (Root => Interface_Root));
IV_AST := AADL_to_Ada_IV (IV_Root);
IV_AST := Parse_Interface_View (IV_Root);
Debug_Dump_IV (IV_AST);
......@@ -554,8 +511,8 @@ begin
-- deployment view.
if Depl_View_Pos > 0 then
Load_Deployment_View_Properties (Deployment_Root);
DV_AST := AADL_To_Ada_DV (Deployment_Root);
AADL_Lib.Append (Ada.Command_Line.Argument (Interface_View));
DV_AST := Parse_Deployment_View (Deployment_Root);
end if;
Ocarina.Configuration.Reset_Modules;
......
......@@ -6,12 +6,17 @@
with Ada.Text_IO,
Ada.Exceptions,
-- Ada.Command_Line,
Ocarina.Instances.Queries,
Ocarina.Backends.Properties,
Ocarina.Instances,
Ocarina.Files,
Ocarina.FE_AADL.Parser,
Ocarina.Parser,
Ocarina.Namet,
Ocarina.Analyzer,
Ocarina.Options,
Locations,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ocarina.ME_AADL.AADL_Instances.Entities;
......@@ -24,18 +29,40 @@ package body Deployment_View is
Ocarina.Instances.Queries,
Ocarina.Backends.Properties,
Ocarina.Namet,
Ocarina.Files,
Ocarina.FE_AADL.Parser,
Locations,
Ocarina.ME_AADL.AADL_Instances.Nodes,
Ocarina.ME_AADL.AADL_Instances.Nutils,
Ocarina.ME_AADL.AADL_Instances.Entities,
Ocarina.ME_AADL;
-- Ocarina.Backends.Utils;
----------------
-- Initialize --
----------------
function Initialize (Root : Node_Id) return Node_Id is
Root_Depl : Node_Id := Root;
Success : Boolean;
Root_Instance : Node_Id;
AADL_Language : constant Name_Id := Get_String_Name ("aadl");
Loc : Location;
F : Name_Id;
begin
Success := Ocarina.Analyzer.Analyze (AADL_Language, Root);
Ocarina.FE_AADL.Parser.Add_Pre_Prop_Sets := True;
-- Parse all AADL files possibly needed to instantiate the model
-- (Including the Interface View)
for each of AADL_Lib loop
Set_Str_To_Name_Buffer (each);
F := Ocarina.Files.Search_File (Name_Find);
Loc := Ocarina.Files.Load_File (F);
Root_Depl := Ocarina.Parser.Parse (Get_String_Name ("aadl"),
Root_Depl, Loc);
end loop;
Success := Ocarina.Analyzer.Analyze (AADL_Language, Root_Depl);
if not Success then
raise Deployment_View_Error with "Deployment view is incorrect";
......@@ -46,16 +73,15 @@ package body Deployment_View is
-- Instantiate AADL tree
Root_Instance := Ocarina.Instances.Instantiate_Model (Root => Root);
return Root_System (Root_Instance);
end Initialize;
---------------------------
-- AST Builder Functions --
---------------------------
function AADL_To_Ada_DV (System : Node_Id) return Complete_Deployment_View
function Parse_Deployment_View (System : Node_Id)
return Complete_Deployment_View
is
use type Node_Maps.Map;
use type Taste_Busses.Vector;
......@@ -165,14 +191,14 @@ package body Deployment_View is
F := First_Node (Features (Device));
while Present (F) loop
-- The sources of F
if not Is_Empty (Sources (F)) then
Src := First_Node (Sources (F));
if not Is_Empty (AIN.Sources (F)) then
Src := First_Node (AIN.Sources (F));
if Src /= No_Node then
if Item (Src) /= No_Node and then
not Is_Empty (Sources (Item (Src))) and then
First_Node (Sources (Item (Src))) /= No_Node
not Is_Empty (AIN.Sources (Item (Src))) and then
First_Node (AIN.Sources (Item (Src))) /= No_Node
then
Src := Item (First_Node (Sources (Item (Src))));
Src := Item (First_Node (AIN.Sources (Item (Src))));
Accessed_Bus := Src;
Accessed_Port := F;
end if;
......@@ -362,7 +388,7 @@ package body Deployment_View is
(Nodes => Nodes,
Connections => Conns,
Busses => Busses);
end AADL_To_Ada_DV;
end Parse_Deployment_View;
procedure Debug_Dump_DV (DV : Complete_Deployment_View) is null;
end Deployment_View;
......@@ -22,12 +22,30 @@ package Deployment_View is
use Option_UString;
use Option_ULL;
use String_Vectors;
-- Exceptions specific to the deployment view
Deployment_View_Error : exception;
Device_Driver_Error : exception;
Empty_Deployment_View_Error : exception;
-- List of Ocarina AADL models needed to parse the deployment view
AADL_Lib : String_Vectors.Vector := Empty_Vector &
"aadl_project.aadl" &
"taste_properties.aadl" &
"Cheddar_Properties.aadl" &
"communication_properties.aadl" &
"deployment_properties.aadl" &
"thread_properties.aadl" &
"timing_properties.aadl" &
"programming_properties.aadl" &
"memory_properties.aadl" &
"modeling_properties.aadl" &
"arinc653.aadl" &
"base_types.aadl" &
"data_model.aadl" &
"deployment.aadl";
-- Initialize Ocarina and instantiate the deployment view, return root.
function Initialize (Root : Node_Id) return Node_Id
with Pre => Root /= No_Node;
......@@ -86,7 +104,9 @@ package Deployment_View is
end record;
-- Function to build up the Ada AST by transforming the one from Ocarina
function AADL_To_Ada_DV (System : Node_Id) return Complete_Deployment_View;
function Parse_Deployment_View (System : Node_Id)
return Complete_Deployment_View
with Pre => System /= No_Node;
procedure Debug_Dump_DV (DV : Complete_Deployment_View);
......
......@@ -250,7 +250,9 @@ package body Interface_View is
-- AST Builder Functions --
---------------------------
function AADL_to_Ada_IV (System : Node_Id) return Complete_Interface_View is
function Parse_Interface_View (System : Node_Id)
return Complete_Interface_View
is
-- use type Functions.Vector;
use type Channels.Vector;
use type Ctxt_Params.Vector;
......@@ -652,7 +654,7 @@ package body Interface_View is
return IV_AST : constant Complete_Interface_View :=
(Flat_Functions => Functions);
end AADL_to_Ada_IV;
end Parse_Interface_View;
procedure Rename_Function (IV : in out Complete_Interface_View;
From, To : String)
......
......@@ -161,7 +161,9 @@ package Interface_View is
end record;
-- Function to build up the Ada AST by transforming the one from Ocarina
function AADL_to_Ada_IV (System : Node_Id) return Complete_Interface_View;
function Parse_Interface_View (System : Node_Id)
return Complete_Interface_View
with Pre => System /= No_Node;
-- Model transformation API: Rename a function
procedure Rename_Function (IV : in out Complete_Interface_View;
......
package Parser_Version is
Parser_Release : constant String :=
"d14e742 ; Commit Date: Mon Dec 4 20:18:01 2017 ";
"ddcfeb9 ; Commit Date: Mon Dec 4 21:20:27 2017 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from r0b92ed3)";
end Parser_Version;
\ No newline at end of file
Supports Markdown
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