1
1
with Ada.Characters.Handling ; use Ada.Characters.Handling;
2
2
with Namet ; use Namet;
3
- with Stringt ; use Stringt;
4
3
with Nlists ; use Nlists;
5
4
with Einfo ; use Einfo;
6
5
with Aspects ; use Aspects;
6
+ with Sem_Util ; use Sem_Util;
7
7
with Ireps ; use Ireps;
8
8
with Follow ; use Follow;
9
9
with Range_Check ; use Range_Check;
@@ -42,128 +42,14 @@ package body ASVAT.Modelling is
42
42
return Result;
43
43
end Find_Model ;
44
44
45
- -- -----------------------
46
- -- Get_Annotation_Name --
47
- -- -----------------------
48
-
49
- function Get_Annotation_Name (N : Node_Id) return String is
50
- (Get_Name_String
51
- (Chars (Expression
52
- (First (Pragma_Argument_Associations (N))))));
53
-
54
- -- -------------------------
55
- -- Get_Import_Convention --
56
- -- -------------------------
57
-
58
- function Get_Import_Convention (N : Node_Id) return String is
59
- -- The gnat front end insists thet the parameters for
60
- -- pragma Import are given in the specified order even
61
- -- if named association is used:
62
- -- 1. Convention,
63
- -- 2. Enity,
64
- -- 3. Optional External_Name,
65
- -- 4. Optional Link_Name.
66
- -- The first 2 parameters are mandatory and
67
- -- for ASVAT models the External_Name is required.
68
- --
69
- -- The Convention parameter will always be present as
70
- -- the first parameter.
71
- Conv_Assoc : constant Node_Id :=
72
- First (Pragma_Argument_Associations (N));
73
- Conv_Name : constant Name_Id := Chars (Conv_Assoc);
74
- Convention : constant String := Get_Name_String
75
- (Chars (Expression (Conv_Assoc)));
76
- begin
77
- -- Double check the named parameter if named association is used.
78
- pragma Assert (Conv_Name = No_Name or else
79
- Get_Name_String (Conv_Name) = " convention" );
80
- return Convention;
81
- end Get_Import_Convention ;
82
-
83
- -- ----------------------------
84
- -- Get_Import_External_Name --
85
- -- ----------------------------
86
-
87
- function Get_Import_External_Name (N : Node_Id) return String is
88
- -- The gnat front end insists thet the parameters for
89
- -- pragma Import are given in the specified order even
90
- -- if named association is used:
91
- -- 1. Convention,
92
- -- 2. Enity,
93
- -- 3. Optional External_Name,
94
- -- 4. Optional Link_Name.
95
- -- The first 2 parameters are mandatory and
96
- -- for ASVAT models the External_Name is required.
97
- --
98
- -- The External_Name parameter, if present, will be
99
- -- the third parameter.
100
- External_Assoc : constant Node_Id := Next
101
- (Next
102
- (First (Pragma_Argument_Associations (N))));
103
- begin
104
- if Present (External_Assoc) then
105
- declare
106
- External_Name : constant Name_Id := Chars (External_Assoc);
107
- External_Name_Id : constant String_Id :=
108
- Strval (Expression (External_Assoc));
109
- External_Name_Id_Length : constant Natural :=
110
- Natural (String_Length (External_Name_Id));
111
- begin
112
- -- Double check the named parameter if named association is used.
113
- pragma Assert (External_Name = No_Name or else
114
- Get_Name_String
115
- (External_Name) = " external_name" );
116
- String_To_Name_Buffer (External_Name_Id);
117
- return To_Lower (Name_Buffer (1 .. External_Name_Id_Length));
118
- end ;
119
- else
120
- return " " ;
121
- end if ;
122
- end Get_Import_External_Name ;
123
-
124
- -- ------------------------
125
- -- Get_Import_Link_Name --
126
- -- ------------------------
127
-
128
- function Get_Import_Link_Name (N : Node_Id) return String is
129
- -- The gnat front end insists thet the parameters for
130
- -- pragma Import are given in the specified order even
131
- -- if named association is used:
132
- -- 1. Convention,
133
- -- 2. Enity,
134
- -- 3. Optional External_Name,
135
- -- 4. Optional Link_Name.
136
- -- The first 2 parameters are mandatory and
137
- -- for ASVAT models the External_Name is required
138
- -- and for imported non-visible objects, Link_Name is required.
139
- -- The Link_Name parameter, if present, will be
140
- -- the Fourth parameter.
141
- External_Assoc : constant Node_Id := Next
142
- (Next
143
- (First (Pragma_Argument_Associations (N))));
144
- Link_Assoc : constant Node_Id :=
145
- (if Present (External_Assoc) then Next (External_Assoc)
146
- else External_Assoc);
147
- begin
148
- if Present (Link_Assoc) then
149
- declare
150
- Link_Name : constant Name_Id := Chars (Link_Assoc);
151
- Link_Name_Id : constant String_Id :=
152
- Strval (Expression (Link_Assoc));
153
- Link_Name_Id_Length : constant Natural :=
154
- Natural (String_Length (Link_Name_Id));
155
- begin
156
- -- Double check the named parameter if named association is used.
157
- pragma Assert (Link_Name = No_Name or else
158
- Get_Name_String
159
- (Link_Name) = " link_name" );
160
- String_To_Name_Buffer (Link_Name_Id);
161
- return To_Lower (Name_Buffer (1 .. Link_Name_Id_Length));
162
- end ;
163
- else
164
- return " " ;
165
- end if ;
166
- end Get_Import_Link_Name ;
45
+ -- -------------------------
46
+ -- -- Get_Annotation_Name --
47
+ -- -------------------------
48
+ --
49
+ -- function Get_Annotation_Name (N : Node_Id) return String is
50
+ -- (Get_Name_String
51
+ -- (Chars (Expression
52
+ -- (First (Pragma_Argument_Associations (N))))));
167
53
168
54
-- -----------------------
169
55
-- Get_Model_From_Anno --
@@ -224,51 +110,11 @@ package body ASVAT.Modelling is
224
110
end if ;
225
111
end Get_Model_From_Anno ;
226
112
227
- -- -------------------------
228
- -- Get_Model_From_Import --
229
- -- -------------------------
230
-
231
- function Get_Model_From_Import (N : Node_Id) return Model_Sorts is
232
- Convention : constant String :=
233
- Get_Import_Convention (N);
234
-
235
- Is_Ada : constant Boolean := Convention = " ada" ;
236
-
237
- Model_String : constant String :=
238
- (if Is_Ada then
239
- Get_Import_External_Name (N)
240
- else
241
- " " );
242
- Model : constant Model_Sorts := Find_Model (Model_String);
243
- begin
244
- if Is_Ada then
245
- if Model_String = " " then
246
- Report_Unhandled_Node_Empty
247
- (N, " Get_Model_From_Import" ,
248
- " Import convention Ada must have a model sort" );
249
- elsif Model = Not_A_Model then
250
- Report_Unhandled_Node_Empty
251
- (N, " Get_Model_From_Import" ,
252
- " Import convention Ada but '" &
253
- Model_String &
254
- " ' is not an ASVAT model sort" );
255
- end if ;
256
- end if ;
257
- return Model;
258
- end Get_Model_From_Import ;
259
-
260
113
-- ------------------
261
114
-- Get_Model_Sort --
262
115
-- ------------------
263
116
264
117
function Get_Model_Sort (E : Entity_Id) return Model_Sorts is
265
- Obj_Import : constant Node_Id := Get_Pragma (E, Pragma_Import);
266
- Subprog_Import : constant Node_Id :=
267
- (if Ekind (E) in E_Procedure | E_Function then
268
- Import_Pragma (E)
269
- else
270
- Obj_Import);
271
-
272
118
Anno : constant Node_Id := Find_Aspect (E, Aspect_Annotate);
273
119
274
120
Anno_Model : constant Model_Sorts :=
@@ -277,27 +123,8 @@ package body ASVAT.Modelling is
277
123
else
278
124
Not_A_Model);
279
125
280
- -- The ASVAT anotation is used even if there is a pragma Import
281
- -- specifying a, possibly different, model.
282
- Import_Model : constant Model_Sorts :=
283
- (if Present (Obj_Import) then
284
- (if Anno_Model = Not_A_Model then
285
- Get_Model_From_Import (Obj_Import)
286
- else
287
- Anno_Model)
288
- elsif Present (Subprog_Import) then
289
- (if Anno_Model = Not_A_Model then
290
- Get_Model_From_Import (Subprog_Import)
291
- else
292
- Anno_Model)
293
- else
294
- Not_A_Model);
295
-
296
126
begin
297
- return (if Anno_Model /= Not_A_Model then
298
- Anno_Model
299
- else
300
- Import_Model);
127
+ return Anno_Model;
301
128
end Get_Model_Sort ;
302
129
303
130
-- ------------------------
0 commit comments