Commit 01fb72cc authored by yoogx's avatar yoogx
Browse files

* Replace explicit visit of subcomponents with call to generic

          function

          For openaadl/ocarina#111
parent 1c195e70
......@@ -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- --
......@@ -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;
......@@ -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;
......@@ -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);
......@@ -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");
......@@ -468,7 +450,6 @@ 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
......@@ -476,16 +457,8 @@ package body Ocarina.Backends.Stats.Main is
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));
......@@ -497,7 +470,6 @@ 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
......@@ -505,16 +477,8 @@ package body Ocarina.Backends.Stats.Main is
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));
......@@ -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));
......
......@@ -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 --
......@@ -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;
......@@ -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;
-------------------------------
......@@ -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;
---------------------------
......
......@@ -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- --
......@@ -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;
......@@ -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 --
-----------
......@@ -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;
......@@ -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;
......
......@@ -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- --
......@@ -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;
......@@ -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;
......@@ -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;
---------------------------
......@@ -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;
......@@ -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
......
......@@ -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- --
......@@ -69,6 +69,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Naming is
procedure Visit_Process (E : Node_Id);
procedure Visit_Processor (E : Node_Id);
procedure Visit_Virtual_Processor (E : Node_Id);
procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);
procedure Add_Applications (AADL_Processor : Node_Id; XML_Node : Node_Id);
procedure Add_Shared_Data_Regions
......@@ -166,7 +167,6 @@ package body Ocarina.Backends.Vxworks653_Conf.Naming is
---------------------
procedure Visit_Processor (E : Node_Id) is
S : Node_Id;
P : Node_Id;
U : Node_Id;
N : Node_Id;
......@@ -178,16 +178,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Naming is
U := Map_HI_Unit (E);
Push_Entity (U);
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);
N := New_Node (XTN.K_HI_Tree_Bindings);
......@@ -232,8 +223,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Naming 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 process subcomponents
if AINU.Is_Process_Or_Device (Corresponding_Instance (S)) then
Visit_Process (Corresponding_Instance (S));
end if;
......@@ -406,8 +397,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Naming is
if not AINU.Is_Empty (Subcomponents (AADL_Processor)) then
S := First_Node (Subcomponents (AADL_Processor));
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
Add_Application (Corresponding_Instance (S), Applications_Node);
......
......@@ -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- --
......@@ -76,6 +76,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Partitions 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);
-----------
-- Visit --
......@@ -182,18 +183,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Partitions 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;
---------------------------
......@@ -206,8 +197,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Partitions 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;
......@@ -245,19 +236,15 @@ package body Ocarina.Backends.Vxworks653_Conf.Partitions is
Current_XML_Node := XTN.Root_Node (XTN.XML_File (U));
Partitions_Node := Make_XML_Node ("Partitions");
-- First, make the <Partition/> nodes
Partitions_Node := Make_XML_Node ("Partitions");
Append_Node_To_List (Partitions_Node, XTN.Subitems (Current_XML_Node));
--
-- First, make the <Partition/> nodes
--
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));
......
......@@ -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- --
......@@ -38,18 +38,18 @@ with Ocarina.ME_AADL.AADL_Instances.Entities;
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.Payloads 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;
......@@ -63,6 +63,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Payloads 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);
-----------
-- Visit --
-----------
......@@ -124,18 +126,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Payloads 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;
---------------------------
......@@ -148,8 +140,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Payloads 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;
......@@ -211,10 +203,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Payloads 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.
while Present (S) loop
if AINU.Is_Virtual_Processor (Corresponding_Instance (S)) then
Partition_Payload_Node := Make_XML_Node ("PartitionPayload");
Add_Attribute
......
......@@ -73,7 +73,10 @@ package body Ocarina.Backends.Vxworks653_Conf.Schedule 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 Fill_Scheduling_Slots (Processor : Node_Id);
-----------
-- Visit --
-----------
......@@ -135,18 +138,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Schedule 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;
---------------------------
......@@ -159,8 +152,8 @@ package body Ocarina.Backends.Vxworks653_Conf.Schedule 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;
......@@ -248,8 +241,7 @@ package body Ocarina.Backends.Vxworks653_Conf.Schedule 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));
...