Skip to content

Commit

Permalink
* Replace explicit visit of subcomponents with call to generic
Browse files Browse the repository at this point in the history
          function

          For #111
  • Loading branch information
yoogx committed Jul 16, 2018
1 parent 1c195e7 commit 01fb72c
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 218 deletions.
60 changes: 7 additions & 53 deletions src/backends/stats/ocarina-backends-stats-main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2008-2009 Telecom ParisTech, 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- --
Expand Down Expand Up @@ -74,6 +74,7 @@ package body Ocarina.Backends.Stats.Main is
procedure Visit_Subprogram_Instance (E : Node_Id);
procedure Look_For_Ports (AADL_Node : Node_Id; XML_Node : Node_Id);
procedure Look_For_Connections (E : Node_Id; N : Node_Id);
procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);

System_Nb_Processes : Unsigned_Long_Long := 0;
System_Nb_Threads : Unsigned_Long_Long := 0;
Expand Down Expand Up @@ -256,7 +257,6 @@ package body Ocarina.Backends.Stats.Main is
----------------------------

procedure Visit_Process_Instance (E : Node_Id) is
S : Node_Id;
P : Node_Id;
Q : Node_Id;
N : Node_Id;
Expand Down Expand Up @@ -289,16 +289,7 @@ package body Ocarina.Backends.Stats.Main is
Old_Current_Parent := Current_Parent_Node;
Current_Parent_Node := Process_Node;

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);

Look_For_Connections (E, Process_Node);

Expand Down Expand Up @@ -393,16 +384,7 @@ package body Ocarina.Backends.Stats.Main is
-- node.
N := Map_Thread (E);

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 not AINU.Is_Empty (Calls (E)) then
R := Make_XML_Node ("calls");
Expand Down Expand Up @@ -468,24 +450,15 @@ package body Ocarina.Backends.Stats.Main is
------------------------

procedure Visit_Bus_Instance (E : Node_Id) is
S : Node_Id;
N : Node_Id;
O : Node_Id;
begin
-- Create the main node and set its name as an item
N := Map_Bus (E);
O := Current_Parent_Node;
Current_Parent_Node := N;
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_Subcomponents_Of (E);

Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
Current_Parent_Node := O;

Append_Node_To_List (N, XTN.Subitems (Current_Parent_Node));
Expand All @@ -497,24 +470,15 @@ package body Ocarina.Backends.Stats.Main is
------------------------------

procedure Visit_Processor_Instance (E : Node_Id) is
S : Node_Id;
N : Node_Id;
O : Node_Id;
begin
-- Create the main node and set its name as an item
N := Map_Processor (E);
O := Current_Parent_Node;
Current_Parent_Node := N;
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);
Current_Parent_Node := O;

Append_Node_To_List (N, XTN.Subitems (Current_Parent_Node));
Expand All @@ -526,22 +490,12 @@ package body Ocarina.Backends.Stats.Main is
--------------------------------------

procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
S : Node_Id;
N : Node_Id;
begin
-- Create the main node and set its name as an item
N := Map_Virtual_Processor (E);

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);

Append_Node_To_List (N, XTN.Subitems (Current_Parent_Node));

Expand Down
38 changes: 4 additions & 34 deletions src/backends/subprograms/ocarina-backends-subprograms.adb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ package body Ocarina.Backends.Subprograms is
procedure Visit_Thread_Instance (E : Node_Id);
procedure Visit_Subprogram_Instance (E : Node_Id);
procedure Visit_Device_Instance (E : Node_Id);
procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);

-------------------------
-- Map_Subprogram_Spec --
Expand Down Expand Up @@ -338,20 +339,11 @@ package body Ocarina.Backends.Subprograms is

procedure Visit_Device_Instance (E : Node_Id) is
Implementation : Node_Id;
S : Node_Id;
begin
Implementation := Get_Classifier_Property (E, "implemented_as");

if Implementation /= No_Node then
if not AINU.Is_Empty (AIN.Subcomponents (Implementation)) then
S := AAN.First_Node (Subcomponents (Implementation));
while Present (S) loop
Visit (Corresponding_Instance (S));

S := AIN.Next_Node (S);
end loop;
end if;

Visit_Subcomponents_Of (Implementation);
end if;
end Visit_Device_Instance;

Expand All @@ -360,21 +352,8 @@ package body Ocarina.Backends.Subprograms is
----------------------------

procedure Visit_Process_Instance (E : Node_Id) is
S : Node_Id;
begin
-- Visit all the subcomponents of the process

if not AINU.Is_Empty (Subcomponents (E)) then
S := AIN.First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.

Visit (Corresponding_Instance (S));

S := AIN.Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
end Visit_Process_Instance;

-------------------------------
Expand Down Expand Up @@ -426,17 +405,8 @@ package body Ocarina.Backends.Subprograms is
---------------------------

procedure Visit_System_Instance (E : Node_Id) is
S : Node_Id;
begin
-- Visit all the subcomponents of the system

if not AINU.Is_Empty (Subcomponents (E)) then
S := AIN.First_Node (Subcomponents (E));
while Present (S) loop
Visit (Corresponding_Instance (S));
S := AIN.Next_Node (S);
end loop;
end if;
Visit_Subcomponents_Of (E);
end Visit_System_Instance;

---------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2015 ESA & ISAE. --
-- Copyright (C) 2015-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- --
Expand Down Expand Up @@ -46,7 +46,6 @@ with Ocarina.Backends.Vxworks653_Conf.Mapping;

package body Ocarina.Backends.Vxworks653_Conf.Connections is

-- use Locations;
use Ocarina.ME_AADL;
use Ocarina.Backends.Utils;

Expand All @@ -69,6 +68,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Connections is
procedure Visit_Processor_Instance (E : Node_Id);
procedure Visit_Bus_Instance (E : Node_Id);
procedure Visit_Virtual_Processor_Instance (E : Node_Id);

-----------
-- Visit --
-----------
Expand Down Expand Up @@ -132,8 +132,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Connections is
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 processor subcomponents

if AINU.Is_Processor (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
Expand Down Expand Up @@ -176,8 +176,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Connections is
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 virtual processor subcomponents

if AINU.Is_Virtual_Processor (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2015 ESA & ISAE. --
-- Copyright (C) 2015-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- --
Expand All @@ -31,27 +31,24 @@

with Ocarina.Namet; use Ocarina.Namet;

-- with Locations;

with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;

-- with Ocarina.Backends.Properties;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.Vxworks653_Conf.Mapping;
with Ocarina.Backends.Utils;

package body Ocarina.Backends.Vxworks653_Conf.Hm is

-- use Locations;
use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.XML_Tree.Nutils;
-- use Ocarina.Backends.Properties;
use Ocarina.Backends.Vxworks653_Conf.Mapping;
use Ocarina.Backends.Utils;

package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
Expand All @@ -67,6 +64,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Hm is
procedure Visit_Processor_Instance (E : Node_Id);
procedure Visit_Bus_Instance (E : Node_Id);
procedure Visit_Virtual_Processor_Instance (E : Node_Id);
procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);

procedure Add_System_Error
(XML_Node : Node_Id;
Expand Down Expand Up @@ -144,18 +142,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Hm is
----------------------------

procedure Visit_Process_Instance (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_Instance;

---------------------------
Expand All @@ -168,8 +156,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Hm is
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 processor subcomponents

if AINU.Is_Processor (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
Expand Down Expand Up @@ -377,8 +365,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Hm is
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 virtual processor subcomponents

if AINU.Is_Virtual_Processor (Corresponding_Instance (S)) then
Append_Node_To_List
Expand Down

0 comments on commit 01fb72c

Please sign in to comment.