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

33
with Ocarina.Builder.AADL.Namespaces;
34
with Ocarina.Builder.AADL.Components;
35

36
with Ocarina.ME_AADL.AADL_Tree.Nodes;
37
with Ocarina.ME_AADL.AADL_Tree.Nutils;
38

39
package body Ocarina.Builder.AADL.Annexes is
40

41
   function Add_New_Annex
42
     (Loc        : Locations.Location;
43
      Annex_Name : Ocarina.Types.Node_Id;
44
      Namespace  : Ocarina.Types.Node_Id;
45
      Annex_Kind : Ocarina.ME_AADL.AADL_Tree.Nodes.Node_Kind;
46
      In_Modes   : Ocarina.Types.Node_Id := Ocarina.Types.No_Node)
47
     return Ocarina.Types.Node_Id;
48

49
   -------------------
50
   -- Add_New_Annex --
51
   -------------------
52

53 1
   function Add_New_Annex
54
     (Loc        : Locations.Location;
55
      Annex_Name : Ocarina.Types.Node_Id;
56
      Namespace  : Ocarina.Types.Node_Id;
57
      Annex_Kind : Ocarina.ME_AADL.AADL_Tree.Nodes.Node_Kind;
58
      In_Modes   : Ocarina.Types.Node_Id := Ocarina.Types.No_Node)
59
     return Ocarina.Types.Node_Id
60
   is
61
      use Ocarina.Types;
62
      use Ocarina.Builder.AADL.Components;
63
      use Ocarina.Builder.AADL.Namespaces;
64
      use Ocarina.ME_AADL.AADL_Tree.Nodes;
65
      use Ocarina.ME_AADL.AADL_Tree.Nutils;
66

67
      pragma Assert
68
        (Annex_Name /= No_Node and then Kind (Annex_Name) = K_Identifier);
69
      pragma Assert (Namespace /= No_Node);
70
      pragma Assert
71
        ((Annex_Kind = K_Annex_Subclause
72
          and then
73 1
          (Kind (Namespace) = K_Component_Implementation
74 1
           or else Kind (Namespace) = K_Package_Specification
75 1
           or else Kind (Namespace) = K_Component_Type
76 0
           or else Kind (Namespace) = K_Feature_Group_Type))
77
         or else
78 0
         (Annex_Kind = K_Annex_Library
79
          and then
80 0
          (Kind (Namespace) = K_Package_Specification
81 0
           or else Kind (Namespace) = K_AADL_Specification)));
82

83 1
      Node    : constant Node_Id := New_Node (Annex_Kind, Loc);
84 1
      Success : Boolean          := True;
85
   begin
86 1
      Set_Identifier (Node, Annex_Name);
87 1
      Set_Corresponding_Entity (Annex_Name, Node);
88 1
      Set_Annex_Content (Node, No_Node);
89

90 1
      if Kind (Namespace) = K_AADL_Specification then
91 0
         Set_Container_Package (Node, Namespace);
92 0
         Success := Add_Declaration (Namespace, Node);
93

94 1
      elsif Kind (Namespace) = K_Component_Type
95 1
        or else Kind (Namespace) = K_Package_Specification
96 1
        or else Kind (Namespace) = K_Component_Implementation
97 0
        or else Kind (Namespace) = K_Feature_Group_Type
98
      then
99 1
         Set_In_Modes (Node, In_Modes);
100 1
         Set_Container_Component (Node, Namespace);
101 1
         Success := Add_Annex (Namespace, Node);
102
      end if;
103

104 1
      if Success then
105 1
         return Node;
106
      else
107 0
         return No_Node;
108
      end if;
109
   end Add_New_Annex;
110

111
   -----------------------
112
   -- Set_Annex_Content --
113
   -----------------------
114

115 1
   procedure Set_Annex_Content
116
     (Annex : Ocarina.Types.Node_Id;
117
      Text  : Ocarina.Types.Name_Id)
118
   is
119
      use Ocarina.Types;
120
      use Ocarina.ME_AADL.AADL_Tree.Nodes;
121
      use Ocarina.ME_AADL.AADL_Tree.Nutils;
122

123
      pragma Assert
124
        (Annex /= No_Node
125
         and then
126 1
         (Kind (Annex) = K_Annex_Subclause
127 0
          or else Kind (Annex) = K_Annex_Library));
128

129 1
      Content : constant Node_Id := New_Node (K_Annex_Content, Loc (Annex));
130
   begin
131 1
      Set_Raw_Text (Content, Text);
132 1
      Set_Annex_Content (Annex, Content);
133 1
   end Set_Annex_Content;
134

135
   -----------------------------
136
   -- Add_New_Annex_Subclause --
137
   -----------------------------
138

139 1
   function Add_New_Annex_Subclause
140
     (Loc        : Locations.Location;
141
      Annex_Name : Ocarina.Types.Node_Id;
142
      Namespace  : Ocarina.Types.Node_Id;
143
      In_Modes   : Ocarina.Types.Node_Id) return Ocarina.Types.Node_Id
144
   is
145
      use Ocarina.ME_AADL.AADL_Tree.Nodes;
146

147
   begin
148 1
      return Add_New_Annex
149
          (Loc,
150
           Annex_Name,
151
           Namespace,
152
           K_Annex_Subclause,
153
           In_Modes);
154
   end Add_New_Annex_Subclause;
155

156
   ---------------------------
157
   -- Add_New_Annex_Library --
158
   ---------------------------
159

160 0
   function Add_New_Annex_Library
161
     (Loc        : Locations.Location;
162
      Annex_Name : Ocarina.Types.Node_Id;
163
      Namespace  : Ocarina.Types.Node_Id;
164
      Is_Private : Boolean := False) return Ocarina.Types.Node_Id
165
   is
166
      use Ocarina.Types;
167
      use Ocarina.ME_AADL.AADL_Tree.Nodes;
168

169
      Node : constant Node_Id :=
170 0
        Add_New_Annex (Loc, Annex_Name, Namespace, K_Annex_Library);
171
   begin
172 0
      Set_Is_Private (Node, Is_Private);
173 0
      return Node;
174
   end Add_New_Annex_Library;
175

176
   ------------------------
177
   -- Add_New_Annex_Path --
178
   ------------------------
179

180 0
   function Add_New_Annex_Path
181
     (Loc              : Locations.Location;
182
      Container        : Ocarina.Types.Node_Id;
183
      Annex_Identifier : Ocarina.Types.Node_Id;
184
      List_Identifiers : Ocarina.Types.List_Id) return Ocarina.Types.Node_Id
185
   is
186
      use Ocarina.Types;
187
      use Ocarina.ME_AADL.AADL_Tree.Nodes;
188
      use Ocarina.ME_AADL.AADL_Tree.Nutils;
189

190 0
      pragma Assert (Container /= No_Node);
191 0
      pragma Assert (not Is_Empty (List_Identifiers));
192

193 0
      Node : constant Node_Id := New_Node (K_Annex_Path, Loc);
194

195
   begin
196

197 0
      Set_Container_Component (Node, Container);
198 0
      Set_Identifier (Node, Annex_Identifier);
199 0
      Set_Identifiers (Node, List_Identifiers);
200

201 0
      return Node;
202
   end Add_New_Annex_Path;
203

204
end Ocarina.Builder.AADL.Annexes;

Read our documentation on viewing source code .

Loading