buildsupport_utils.ads 7.09 KB
Newer Older
Maxime Perrotin's avatar
Maxime Perrotin committed
1
--  *************************** buildsupport ****************************  --
Maxime Perrotin's avatar
Maxime Perrotin committed
2
--  (c) 2017 European Space Agency - maxime.perrotin@esa.int
Maxime Perrotin's avatar
Maxime Perrotin committed
3
4
5
--  LGPL license, see LICENSE file

--  Set of helper functions for buildsupport
Maxime Perrotin's avatar
Maxime Perrotin committed
6
with Ocarina,
7
     --  Ocarina.Types,
Maxime Perrotin's avatar
Maxime Perrotin committed
8
9
     Ocarina.Types,
     Ocarina.Namet,
10
     Ocarina.Backends.Properties,
11
     Ada.Containers.Indefinite_Ordered_Maps,
12
     Ada.Containers.Indefinite_Vectors,
Maxime Perrotin's avatar
Maxime Perrotin committed
13
14
     Ocarina.ME_AADL.AADL_Tree.Nodes,
     Ocarina.ME_AADL.AADL_Instances.Nodes,
Maxime Perrotin's avatar
Maxime Perrotin committed
15
16
     Ada.Strings.Unbounded,
     Option_Type;
Maxime Perrotin's avatar
Maxime Perrotin committed
17

Maxime Perrotin's avatar
Maxime Perrotin committed
18
use Ocarina,
Maxime Perrotin's avatar
Maxime Perrotin committed
19
20
    Ocarina.Types,
    Ocarina.Namet,
21
    Ocarina.Backends.Properties,
Maxime Perrotin's avatar
Maxime Perrotin committed
22
23
    Ocarina.ME_AADL.AADL_Tree.Nodes,
    Ocarina.ME_AADL.AADL_Instances.Nodes,
24
25
    Ada.Containers,
    Ada.Strings.Unbounded;
Maxime Perrotin's avatar
Maxime Perrotin committed
26
27
28

package Buildsupport_Utils is

Maxime Perrotin's avatar
Maxime Perrotin committed
29
30
   package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
Maxime Perrotin's avatar
Maxime Perrotin committed
31
   function US (Source : String) return Unbounded_String renames
Maxime Perrotin's avatar
Maxime Perrotin committed
32
       To_Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
33
34
35
36
37
38
39
40
41
42
43
44

   procedure Banner;

   procedure Usage;

   procedure Exit_On_Error (Error : Boolean; Reason : String);

   type Synchronism is (Sync, Async);

   type Supported_RCM_Operation_Kind is (Unprotected_Operation,
                                         Protected_Operation,
                                         Cyclic_Operation,
45
46
                                         Sporadic_Operation,
                                         Any_Operation);
Maxime Perrotin's avatar
Maxime Perrotin committed
47

48
   function Get_RCM_Operation_Kind (E : Node_Id)
Maxime Perrotin's avatar
Maxime Perrotin committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
     return Supported_RCM_Operation_Kind;

   function Get_RCM_Operation (E : Node_Id) return Node_Id;

   function Get_RCM_Period (D : Node_Id) return Unsigned_Long_Long;

   function Get_APLC_Binding (E : Node_Id) return List_Id;

   type Supported_ASN1_Encoding is (Default, Native, UPER, ACN);

   function Get_ASN1_Encoding (E : Node_Id) return Supported_ASN1_Encoding;

   type Supported_ASN1_Basic_Type is (ASN1_Sequence,
                                      ASN1_SequenceOf,
                                      ASN1_Enumerated,
                                      ASN1_Set,
                                      ASN1_SetOf,
                                      ASN1_Integer,
                                      ASN1_Boolean,
                                      ASN1_Real,
                                      ASN1_OctetString,
                                      ASN1_Choice,
                                      ASN1_String,
                                      ASN1_Unknown);

74
   package Property_Maps is new Indefinite_Ordered_Maps (String, String);
75
76
   use Property_Maps;
   package String_Vectors is new Indefinite_Vectors (Natural, String);
77

Maxime Perrotin's avatar
Maxime Perrotin committed
78
79
80
81
82
83
84
85
   function Get_ASN1_Basic_Type (E : Node_Id) return Supported_ASN1_Basic_Type;

   function Get_Ada_Package_Name (D : Node_Id) return Name_Id;

   function Get_Ellidiss_Tool_Version (D : Node_Id) return Name_Id;

   function Get_Interface_Name (D : Node_Id) return Name_Id;

86
   function Get_Env_Vars     (D : Node_Id) return Name_Id;
87

Maxime Perrotin's avatar
Maxime Perrotin committed
88
89
   function Get_ASN1_Module_Name (D : Node_Id) return String;

Maxime Perrotin's avatar
Maxime Perrotin committed
90
91
   function Get_Properties_Map (D : Node_Id) return Property_Maps.Map;

Maxime Perrotin's avatar
Maxime Perrotin committed
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
   --  Shortcut to read an identifier from the parser, in lowercase
   function ATN_Lower (N : Node_Id) return String is
       (Get_Name_String (ATN.Name (ATN.Identifier (N))));

   --  Shortcut to read an identifier from the parser, with original case
   function ATN_Case (N : Node_Id) return String is
       (Get_Name_String (ATN.Display_Name (ATN.Identifier (N))));

   --  Shortcut to read an identifier from the parser, in lowercase
   function AIN_Lower (N : Node_Id) return String is
       (Get_Name_String (AIN.Name (AIN.Identifier (N))));

   --  Shortcut to read an identifier from the parser, with original case
   function AIN_Case (N : Node_Id) return String is
       (Get_Name_String (AIN.Display_Name (AIN.Identifier (N))));

108
109
110
   --  Types needed to build the AST of the TASTE Interface View in Ada
   type Parameter_Direction is (param_in, param_out);

111
112
   package Option_UString is new Option_Type (Unbounded_String);
   use Option_UString;
Maxime Perrotin's avatar
Maxime Perrotin committed
113
   subtype Optional_Unbounded_String is Option_UString.Option;
Maxime Perrotin's avatar
Maxime Perrotin committed
114
115
116
   package Option_ULL is new Option_Type (Unsigned_Long_Long);
   use Option_ULL;
   subtype Optional_Long_Long is Option_ULL.Option;
117

118
   type ASN1_Parameter is
119
       record
120
121
122
123
124
125
126
           Name            : Unbounded_String;
           Sort            : Unbounded_String;
           ASN1_Module     : Unbounded_String;
           ASN1_Basic_Type : Supported_ASN1_Basic_Type;
           ASN1_File_Name  : Unbounded_String;
           Encoding        : Supported_ASN1_Encoding;
           Direction       : Parameter_Direction;
127
128
       end record;

129
   package Parameters is new Indefinite_Vectors (Natural, ASN1_Parameter);
130

131
132
   type Taste_Interface is
       record
Maxime Perrotin's avatar
Maxime Perrotin committed
133
           Name            : Unbounded_String;
134
           Params          : Parameters.Vector;
Maxime Perrotin's avatar
Maxime Perrotin committed
135
           RCM             : Supported_RCM_Operation_Kind;
136
           Period_Or_MIAT  : Unsigned_Long_Long;
Maxime Perrotin's avatar
Maxime Perrotin committed
137
138
           WCET_ms         : Optional_Long_Long := Nothing;
           Queue_Size      : Optional_Long_Long := Nothing;
Maxime Perrotin's avatar
Maxime Perrotin committed
139
           User_Properties : Property_Maps.Map;
140
141
142
       end record;

   package Interfaces is new Indefinite_Vectors (Natural, Taste_Interface);
143

Maxime Perrotin's avatar
Maxime Perrotin committed
144
   type Context_Parameter is
145
       record
146
           Name           : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
147
148
149
           Sort           : Unbounded_String;
           Default_Value  : Unbounded_String;
           ASN1_Module    : Unbounded_String;
Maxime Perrotin's avatar
Maxime Perrotin committed
150
           ASN1_File_Name : Optional_Unbounded_String := Nothing;
Maxime Perrotin's avatar
Maxime Perrotin committed
151
152
153
154
155
156
157
       end record;

   package Ctxt_Params is new Indefinite_Vectors (Natural, Context_Parameter);

   type Taste_Terminal_Function is
       record
           Name            : Unbounded_String;
158
           Prefix          : Optional_Unbounded_String := Nothing;
Maxime Perrotin's avatar
Maxime Perrotin committed
159
           Language        : Supported_Source_Language;
Maxime Perrotin's avatar
Maxime Perrotin committed
160
           Zip_File        : Optional_Unbounded_String := Nothing;
Maxime Perrotin's avatar
Maxime Perrotin committed
161
162
163
164
165
           Context_Params  : Ctxt_Params.Vector;
           User_Properties : Property_Maps.Map;
           Timers          : String_Vectors.Vector;
           Provided        : Interfaces.Vector;
           Required        : Interfaces.Vector;
166
167
       end record;

168
169
170
171
172
   package Functions is new Indefinite_Vectors (Natural,
                                                Taste_Terminal_Function);

   type Connection is
       record
173
174
175
176
           Caller  : Unbounded_String;
           Callee  : Unbounded_String;
           RI_Name : Unbounded_String;
           PI_Name : Unbounded_String;
177
178
179
       end record;

   package Channels is new Indefinite_Vectors (Natural, Connection);
Maxime Perrotin's avatar
Maxime Perrotin committed
180
181
182
   package Connection_Maps is new Indefinite_Ordered_Maps (String,
                                                           Channels.Vector,
                                                          "=" => Channels."=");
183

184
   type Complete_Interface_View is
185
       record
Maxime Perrotin's avatar
Maxime Perrotin committed
186
187
188
           Flat_Functions  : Functions.Vector;
           End_To_End_Conn : Channels.Vector;
           Nested_Conn     : Connection_Maps.Map;
189
190
       end record;

Maxime Perrotin's avatar
Maxime Perrotin committed
191
192
193
   --  Function to build up the Ada AST by transforming the one from Ocarina
   function AADL_to_Ada_IV (System : Node_Id) return Complete_Interface_View;

Maxime Perrotin's avatar
Maxime Perrotin committed
194
end Buildsupport_Utils;