@@ -6,6 +6,7 @@ with GOTO_Utils; use GOTO_Utils;
6
6
with Range_Check ; use Range_Check;
7
7
with Symbol_Table_Info ; use Symbol_Table_Info;
8
8
with Tree_Walk ; use Tree_Walk;
9
+ with Follow ; use Follow;
9
10
10
11
package body Gnat2goto_Itypes is
11
12
@@ -89,7 +90,8 @@ package body Gnat2goto_Itypes is
89
90
when E_Signed_Integer_Type => Do_Itype_Integer_Type (N),
90
91
when E_Floating_Point_Type => Create_Dummy_Irep,
91
92
when E_Anonymous_Access_Type => Make_Pointer_Type
92
- (Base => Do_Type_Reference (Designated_Type (Etype (N)))),
93
+ (Base => Do_Type_Reference (Designated_Type (Etype (N)))),
94
+ when E_Modular_Integer_Subtype => Do_Modular_Integer_Subtype (N),
93
95
when others => Report_Unhandled_Node_Irep (N, " Do_Itype_Definition" ,
94
96
" Unknown Ekind" ));
95
97
end Do_Itype_Definition ;
@@ -171,4 +173,58 @@ package body Gnat2goto_Itypes is
171
173
return Do_Type_Reference (Etype (N));
172
174
end Do_Itype_Record_Subtype ;
173
175
176
+ function Do_Modular_Integer_Subtype (N : Entity_Id) return Irep is
177
+ Modular_Type : constant Irep := Do_Type_Reference (Etype (N));
178
+ Followed_Mod_Type : constant Irep :=
179
+ Follow_Symbol_Type (Modular_Type, Global_Symbol_Table);
180
+
181
+ S_Range : constant Node_Id := Scalar_Range (N);
182
+ Lower_Bound : constant Node_Id := Low_Bound (S_Range);
183
+ Upper_Bound : constant Node_Id := High_Bound (S_Range);
184
+
185
+ Lower_Bound_Value : Integer;
186
+ Upper_Bound_Value : Integer;
187
+ begin
188
+ pragma Assert (Kind (Followed_Mod_Type) in I_Unsignedbv_Type
189
+ | I_Ada_Mod_Type);
190
+
191
+ case Nkind (Lower_Bound) is
192
+ when N_Integer_Literal => Lower_Bound_Value :=
193
+ Store_Nat_Bound (Bound_Type_Nat (Intval (Lower_Bound)));
194
+ when N_Identifier => Lower_Bound_Value :=
195
+ Store_Symbol_Bound (Bound_Type_Symbol (Lower_Bound));
196
+ when others =>
197
+ Report_Unhandled_Node_Empty (Lower_Bound,
198
+ " Do_Base_Range_Constraint" ,
199
+ " unsupported lower range kind" );
200
+ end case ;
201
+
202
+ case Nkind (Upper_Bound) is
203
+ when N_Integer_Literal => Upper_Bound_Value :=
204
+ Store_Nat_Bound (Bound_Type_Nat (Intval (Upper_Bound)));
205
+ when N_Identifier => Upper_Bound_Value :=
206
+ Store_Symbol_Bound (Bound_Type_Symbol (Upper_Bound));
207
+ when others =>
208
+ Report_Unhandled_Node_Empty (Upper_Bound,
209
+ " Do_Base_Range_Constraint" ,
210
+ " unsupported upper range kind" );
211
+ end case ;
212
+
213
+ if Kind (Followed_Mod_Type) = I_Ada_Mod_Type then
214
+ return Make_Bounded_Mod_Type (I_Subtype => Make_Nil_Type,
215
+ Width =>
216
+ Get_Width (Followed_Mod_Type),
217
+ Lower_Bound => Lower_Bound_Value,
218
+ Ada_Mod_Max =>
219
+ Get_Ada_Mod_Max (Followed_Mod_Type),
220
+ Upper_Bound => Upper_Bound_Value);
221
+ else
222
+ return Make_Bounded_Unsignedbv_Type (I_Subtype => Make_Nil_Type,
223
+ Width =>
224
+ Get_Width (Followed_Mod_Type),
225
+ Lower_Bound => Lower_Bound_Value,
226
+ Upper_Bound => Upper_Bound_Value);
227
+ end if ;
228
+ end Do_Modular_Integer_Subtype ;
229
+
174
230
end Gnat2goto_Itypes ;
0 commit comments