Commit c556cbce authored by yoogx's avatar yoogx

* Remove code duplication

        For openaadl/ocarina#111
parent ab0c47c6
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010-2015 ESA & ISAE. --
-- Copyright (C) 2010-2018 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- --
......@@ -40,6 +40,7 @@ with Ocarina.Backends.MAST_Tree.Nutils;
with Ocarina.Backends.MAST_Values;
with Ocarina.Backends.Properties;
with Ocarina.Backends.Utils;
with Ocarina.Backends.Helper;
package body Ocarina.Backends.MAST.Main is
......@@ -50,6 +51,7 @@ package body Ocarina.Backends.MAST.Main is
use Ocarina.Backends.Utils;
use Ocarina.Backends.Properties;
use Ocarina.Backends.MAST_Values;
use Ocarina.Backends.Helper;
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
......@@ -66,6 +68,7 @@ package body Ocarina.Backends.MAST.Main is
procedure Visit_Data (E : Node_Id);
procedure Visit_Device (E : Node_Id);
procedure Visit_Virtual_Processor (E : Node_Id);
procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);
function Map_Port_Operation_Name
(The_Thread : Node_Id;
......@@ -441,7 +444,6 @@ package body Ocarina.Backends.MAST.Main is
------------------
procedure Visit_Device (E : Node_Id) is
S : Node_Id;
N : Node_Id;
begin
N := Make_Driver_Wrapper (E);
......@@ -451,16 +453,7 @@ package body Ocarina.Backends.MAST.Main is
MTU.Append_Node_To_List (N, MTN.Declarations (MAST_File));
end if;
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
end Visit_Device;
---------------------
......@@ -468,7 +461,6 @@ package body Ocarina.Backends.MAST.Main is
---------------------
procedure Visit_Processor (E : Node_Id) is
S : Node_Id;
N : Node_Id;
begin
N :=
......@@ -489,16 +481,7 @@ package body Ocarina.Backends.MAST.Main is
MTU.Append_Node_To_List (N, MTN.Declarations (MAST_File));
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
end Visit_Processor;
-------------------
......@@ -506,18 +489,8 @@ package body Ocarina.Backends.MAST.Main is
-------------------
procedure Visit_Process (E : Node_Id) is
S : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
end Visit_Process;
----------------
......@@ -525,7 +498,6 @@ package body Ocarina.Backends.MAST.Main is
-------------------
procedure Visit_Data (E : Node_Id) is
S : Node_Id;
N : Node_Id;
CP : constant Supported_Concurrency_Control_Protocol :=
Get_Concurrency_Protocol (E);
......@@ -564,16 +536,7 @@ package body Ocarina.Backends.MAST.Main is
Append_Node_To_List (N, MTN.Declarations (MAST_File));
end if;
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
end Visit_Data;
------------------
......@@ -581,7 +544,6 @@ package body Ocarina.Backends.MAST.Main is
------------------
procedure Visit_Thread (E : Node_Id) is
S : Node_Id;
N : Node_Id;
Call : Node_Id;
Spg_Call : Node_Id;
......@@ -840,16 +802,7 @@ package body Ocarina.Backends.MAST.Main is
end loop;
end if;
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
if Has_Ports (E) then
The_Feature := First_Node (Features (E));
......@@ -900,21 +853,16 @@ package body Ocarina.Backends.MAST.Main is
------------------
procedure Visit_System (E : Node_Id) is
S : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if Get_Category_Of_Component (Corresponding_Instance (S)) /=
CC_Device
then
Visit (Corresponding_Instance (S));
end if;
for S of Subcomponents_Of (E) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if Get_Category_Of_Component (Corresponding_Instance (S)) /=
CC_Device
then
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
end loop;
end Visit_System;
end Ocarina.Backends.MAST.Main;
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