1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--    O C A R I N A . B A C K E N D S . D E O S _ C O N F . N A M I N G     --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2015-2019 ESA & ISAE, 2019-2020 OpenAADL           --
10
--                                                                          --
11
-- Ocarina  is free software; you can redistribute it and/or modify under   --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
15
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
16
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
--                    Ocarina is maintained by OpenAADL team                --
28
--                              (info@openaadl.org)                         --
29
--                                                                          --
30
------------------------------------------------------------------------------
31

32
with Locations;
33
with Ocarina.ME_AADL;
34
with Ocarina.ME_AADL.AADL_Instances.Nodes;
35
with Ocarina.ME_AADL.AADL_Instances.Nutils;
36
with Ocarina.ME_AADL.AADL_Instances.Entities;
37

38
with Ocarina.Backends.Properties;
39
with Ocarina.Backends.XML_Tree.Nodes;
40
with Ocarina.Backends.XML_Tree.Nutils;
41
with Ocarina.Backends.Deos_Conf.Mapping;
42

43
package body Ocarina.Backends.Deos_Conf.Naming is
44

45
   use Locations;
46
   use Ocarina.ME_AADL;
47
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
48
   use Ocarina.ME_AADL.AADL_Instances.Entities;
49
   use Ocarina.Backends.XML_Tree.Nutils;
50
   use Ocarina.Backends.Properties;
51
   use Ocarina.Backends.Deos_Conf.Mapping;
52

53
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
54
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
55
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
56
   package XTU renames Ocarina.Backends.XML_Tree.Nutils;
57

58
   procedure Visit_Component (E : Node_Id);
59
   procedure Visit_System (E : Node_Id);
60
   procedure Visit_Process (E : Node_Id);
61
   procedure Visit_Processor (E : Node_Id);
62
   procedure Visit_Virtual_Processor (E : Node_Id);
63

64
   -----------
65
   -- Visit --
66
   -----------
67

68 1
   procedure Visit (E : Node_Id) is
69
   begin
70
      case Kind (E) is
71 1
         when K_Architecture_Instance =>
72 1
            Visit (Root_System (E));
73

74 1
         when K_Component_Instance =>
75 1
            Visit_Component (E);
76

77 0
         when others =>
78 0
            null;
79
      end case;
80 1
   end Visit;
81

82
   ---------------------
83
   -- Visit_Component --
84
   ---------------------
85

86 1
   procedure Visit_Component (E : Node_Id) is
87 1
      Category : constant Component_Category := Get_Category_Of_Component (E);
88
   begin
89
      case Category is
90 1
         when CC_System =>
91 1
            Visit_System (E);
92

93 0
         when CC_Process =>
94 0
            Visit_Process (E);
95

96 0
         when CC_Device =>
97 0
            Visit_Process (E);
98

99 0
         when CC_Processor =>
100 0
            Visit_Processor (E);
101

102 1
         when CC_Virtual_Processor =>
103 1
            Visit_Virtual_Processor (E);
104

105 0
         when others =>
106 0
            null;
107
      end case;
108 1
   end Visit_Component;
109

110
   -------------------
111
   -- Visit_Process --
112
   -------------------
113

114 1
   procedure Visit_Process (E : Node_Id) is
115 1
      N              : Node_Id;
116 1
      Processes_List : List_Id;
117
   begin
118
      Processes_List :=
119 1
        XTN.Processes (Backend_Node (Identifier (Get_Bound_Processor (E))));
120

121 1
      N := XTU.Make_Container (E);
122

123 1
      XTU.Append_Node_To_List (N, Processes_List);
124 1
   end Visit_Process;
125

126
   --------------------------------------
127
   -- Visit_Virtual_Processor_Instance --
128
   --------------------------------------
129

130 1
   procedure Visit_Virtual_Processor (E : Node_Id) is
131 1
      Processes : List_Id;
132 1
      N         : Node_Id;
133
   begin
134 1
      N := New_Node (XTN.K_HI_Tree_Bindings);
135

136 1
      AIN.Set_Backend_Node (Identifier (E), N);
137

138 1
      Processes := XTU.New_List (XTN.K_List_Id);
139

140 1
      XTN.Set_Processes (N, Processes);
141

142 1
   end Visit_Virtual_Processor;
143

144
   ---------------------
145
   -- Visit_Processor --
146
   ---------------------
147

148 1
   procedure Visit_Processor (E : Node_Id) is
149 1
      S         : Node_Id;
150 1
      P         : Node_Id;
151 1
      U         : Node_Id;
152 1
      N         : Node_Id;
153 1
      Processes : List_Id;
154
   begin
155 1
      P := Map_HI_Node (E);
156 1
      Push_Entity (P);
157

158 1
      U := Map_HI_Unit (E);
159 1
      Push_Entity (U);
160

161 1
      if not AINU.Is_Empty (Subcomponents (E)) then
162 1
         S := First_Node (Subcomponents (E));
163 1
         while Present (S) loop
164
            --  Visit the component instance corresponding to the
165
            --  subcomponent S.
166

167 1
            Visit (Corresponding_Instance (S));
168 1
            S := Next_Node (S);
169 1
         end loop;
170
      end if;
171

172 1
      N := New_Node (XTN.K_HI_Tree_Bindings);
173

174 1
      Processes := AINU.New_List (K_Node_Id, No_Location);
175

176 1
      XTN.Set_Processes (N, Processes);
177

178 1
      XTN.Set_Unit (N, U);
179 1
      XTN.Set_Node (N, P);
180

181 1
      AIN.Set_Backend_Node (Identifier (E), N);
182

183 1
      Pop_Entity;
184 1
      Pop_Entity;
185 1
   end Visit_Processor;
186

187
   ------------------
188
   -- Visit_System --
189
   ------------------
190

191 1
   procedure Visit_System (E : Node_Id) is
192 1
      S                  : Node_Id;
193 1
      Component_Instance : Node_Id;
194
   begin
195 1
      if not AINU.Is_Empty (Subcomponents (E)) then
196 1
         S := First_Node (Subcomponents (E));
197 1
         while Present (S) loop
198 1
            Component_Instance := Corresponding_Instance (S);
199 1
            if Get_Category_Of_Component (Component_Instance) =
200
              CC_Processor
201
            then
202 1
               Visit_Processor (Component_Instance);
203
            end if;
204 1
            S := Next_Node (S);
205 1
         end loop;
206
      end if;
207

208 1
      if not AINU.Is_Empty (Subcomponents (E)) then
209 1
         S := First_Node (Subcomponents (E));
210 1
         while Present (S) loop
211
            --  Visit the component instance corresponding to the
212
            --  subcomponent S.
213 1
            if AINU.Is_Process_Or_Device (Corresponding_Instance (S)) then
214 1
               Visit_Process (Corresponding_Instance (S));
215
            end if;
216 1
            S := Next_Node (S);
217 1
         end loop;
218
      end if;
219

220 1
   end Visit_System;
221

222
end Ocarina.Backends.Deos_Conf.Naming;

Read our documentation on viewing source code .

Loading