OpenAADL / ocarina
1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--     O C A R I N A . B A C K E N D S . A I R _ C O N F . M O D U L E      --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2018-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.Utils;
39
with Ocarina.Backends.XML_Tree.Nodes;
40
with Ocarina.Backends.XML_Tree.Nutils;
41
with Ocarina.Backends.AIR_Conf.Mapping;
42

43
package body Ocarina.Backends.AIR_Conf.Module 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.Utils;
50
   use Ocarina.Backends.XML_Tree.Nutils;
51
   use Ocarina.Backends.AIR_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

57
   procedure Visit_Architecture_Instance (E : Node_Id);
58
   procedure Visit_Component_Instance (E : Node_Id);
59
   procedure Visit_System_Instance (E : Node_Id);
60
   procedure Visit_Process_Instance (E : Node_Id);
61
   procedure Visit_Processor_Instance (E : Node_Id);
62
   procedure Visit_Virtual_Processor_Instance (E : Node_Id);
63
   procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);
64

65
   -----------
66
   -- Visit --
67
   -----------
68

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

75 1
         when K_Component_Instance =>
76 1
            Visit_Component_Instance (E);
77

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

83
   ---------------------------------
84
   -- Visit_Architecture_Instance --
85
   ---------------------------------
86

87 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
88
   begin
89 1
      Visit (Root_System (E));
90 1
   end Visit_Architecture_Instance;
91

92
   ------------------------------
93
   -- Visit_Component_Instance --
94
   ------------------------------
95

96 1
   procedure Visit_Component_Instance (E : Node_Id) is
97 1
      Category : constant Component_Category := Get_Category_Of_Component (E);
98
   begin
99 1
      case Category is
100 1
         when CC_System =>
101 1
            Visit_System_Instance (E);
102

103 0
         when CC_Process =>
104 0
            Visit_Process_Instance (E);
105

106 1
         when CC_Processor =>
107 1
            Visit_Processor_Instance (E);
108

109 1
         when CC_Virtual_Processor =>
110 1
            Visit_Virtual_Processor_Instance (E);
111

112 0
         when others =>
113 0
            null;
114 1
      end case;
115 1
   end Visit_Component_Instance;
116

117
   ----------------------------
118
   -- Visit_Process_Instance --
119
   ----------------------------
120

121 0
   procedure Visit_Process_Instance (E : Node_Id) is
122
   begin
123 0
      Visit_Subcomponents_Of (E);
124 0
   end Visit_Process_Instance;
125

126
   ---------------------------
127
   -- Visit_System_Instance --
128
   ---------------------------
129

130 1
   procedure Visit_System_Instance (E : Node_Id) is
131 1
      S         : Node_Id;
132 1
      P         : Node_Id;
133 1
      U         : Node_Id;
134 1
      N         : Node_Id;
135 1
      Processes : List_Id;
136
   begin
137 1
      P := Map_HI_Node (E);
138 1
      Push_Entity (P);
139

140 1
      U := Map_HI_Unit (E);
141 1
      Push_Entity (U);
142

143 1
      if not AINU.Is_Empty (Subcomponents (E)) then
144 1
         S := First_Node (Subcomponents (E));
145 1
         while Present (S) loop
146
            --  Visit processor subcomponents
147

148 1
            if AINU.Is_Processor (Corresponding_Instance (S)) then
149 1
               Visit (Corresponding_Instance (S));
150
            end if;
151 1
            S := Next_Node (S);
152 1
         end loop;
153
      end if;
154 1
      N := New_Node (XTN.K_HI_Tree_Bindings);
155

156 1
      Processes := AINU.New_List (K_Node_Id, No_Location);
157

158 1
      XTN.Set_Processes (N, Processes);
159

160 1
      XTN.Set_Unit (N, U);
161 1
      XTN.Set_Node (N, P);
162

163 1
      AIN.Set_Backend_Node (Identifier (E), N);
164

165 1
      Pop_Entity;
166 1
      Pop_Entity;
167 1
   end Visit_System_Instance;
168

169
   ------------------------------
170
   -- Visit_Processor_Instance --
171
   ------------------------------
172

173 1
   procedure Visit_Processor_Instance (E : Node_Id) is
174 1
      N         : Node_Id;
175 1
      Processes : List_Id;
176
   begin
177 1
      Visit_Subcomponents_Of (E);
178

179 1
      N := New_Node (XTN.K_HI_Tree_Bindings);
180

181 1
      Processes := AINU.New_List (K_Node_Id, No_Location);
182

183 1
      XTN.Set_Processes (N, Processes);
184

185 1
      AIN.Set_Backend_Node (Identifier (E), N);
186 1
   end Visit_Processor_Instance;
187

188
   --------------------------------------
189
   -- Visit_Virtual_Processor_Instance --
190
   --------------------------------------
191

192 1
   procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
193
   begin
194 1
      Visit_Subcomponents_Of (E);
195 1
   end Visit_Virtual_Processor_Instance;
196

197
end Ocarina.Backends.AIR_Conf.Module;

Read our documentation on viewing source code .

Loading