Debian Codegraph @

gcc/ada/gen_il-types.ads

raw
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- G E N _ I L . T Y P E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2020-2025, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it 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. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
25
26 package Gen_IL.Types is
27
28 -- Enumeration of all the types that are "of interest". We have an
29 -- enumeration literal here for every node kind, every entity kind,
30 -- and every type that can be the type of a field.
31
32 -- The following is "optional type enumeration" -- i.e. it is Type_Enum
33 -- (declared below) plus the special null value No_Type. See the spec of
34 -- Gen_IL.Gen for how to modify this. (Of course, in Ada we have to define
35 -- this backwards from the above conceptual description.)
36
37 -- Note that there are various subranges of this type declared below,
38 -- which might need to be kept in sync when modifying this.
39
40 -- The "Between_..." literals below are simply for making the subranges.
41 -- When adding literals to this enumeration type, be sure to put them in
42 -- the right place so they end up in the appropriate subranges
43 -- (Abstract_Node, Abstract_Entity, Concrete_Node, Concrete_Entity).
44
45 type Opt_Type_Enum is
46 (No_Type,
47
48 Flag,
49 -- We use Flag for Boolean, so we don't conflict with
50 -- Standard.Boolean.
51
52 Node_Id,
53 List_Id,
54 Elist_Id,
55 Name_Id,
56 String_Id,
57 Uint,
58 Valid_Uint,
59 Unat,
60 Upos,
61 Nonzero_Uint,
62 Ureal,
63 Source_File_Index,
64
65 Node_Kind_Type, -- Type of result of Nkind function, i.e. Node_Kind
66 Entity_Kind_Type, -- Type of result of Ekind function, i.e. Entity_Kind
67 Source_Ptr,
68 Small_Paren_Count_Type,
69 Union_Id,
70 Convention_Id,
71
72 Component_Alignment_Kind,
73 Mechanism_Type,
74
75 Between_Special_And_Abstract_Node_Types,
76
77 -- Abstract node types:
78
79 Node_Kind, -- root of node type hierarchy
80 N_Access_To_Subprogram_Definition,
81 N_Alternative,
82 N_Array_Type_Definition,
83 N_Binary_Op,
84 N_Body_Stub,
85 N_Declaration,
86 N_Delay_Statement,
87 N_Direct_Name,
88 N_Entity,
89 N_Entity_Name,
90 N_Formal_Subprogram_Declaration,
91 N_Generic_Declaration,
92 N_Generic_Instantiation,
93 N_Generic_Renaming_Declaration,
94 N_Has_Bounds,
95 N_Has_Chars,
96 N_Has_Condition,
97 N_Has_Entity,
98 N_Has_Etype,
99 N_Is_Case_Choice,
100 N_Is_Decl,
101 N_Is_Exception_Choice,
102 N_Is_Index,
103 N_Is_Range,
104 N_Multiplying_Operator,
105 N_Later_Decl_Item,
106 N_Membership_Test,
107 N_Numeric_Or_String_Literal,
108 N_Op,
109 N_Op_Boolean,
110 N_Op_Compare,
111 N_Op_Shift,
112 N_Proper_Body,
113 N_Push_xxx_Label,
114 N_Pop_xxx_Label,
115 N_Push_Pop_xxx_Label,
116 N_Raise_xxx_Error,
117 N_Renaming_Declaration,
118 N_Representation_Clause,
119 N_Short_Circuit,
120 N_SCIL_Node,
121 N_Statement_Other_Than_Procedure_Call,
122 N_Subprogram_Call,
123 N_Subprogram_Instantiation,
124 N_Subexpr,
125 N_Subprogram_Specification,
126 N_Unary_Op,
127 N_Lib_Unit_Declaration,
128 N_Lib_Unit_Renaming_Declaration,
129 N_Lib_Unit_Body,
130
131 -- End of abstract node types.
132
133 Between_Abstract_Node_And_Abstract_Entity_Types,
134
135 -- Abstract entity types:
136
137 Entity_Kind, -- root of entity type hierarchy
138 Access_Kind,
139 Access_Subprogram_Kind,
140 Access_Protected_Kind,
141 Aggregate_Kind,
142 Allocatable_Kind,
143 Anonymous_Access_Kind,
144 Array_Kind,
145 Assignable_Kind,
146 Class_Wide_Kind,
147 Composite_Kind,
148 Concurrent_Kind,
149 Concurrent_Body_Kind,
150 Constant_Or_Variable_Kind,
151 Decimal_Fixed_Point_Kind,
152 Digits_Kind,
153 Discrete_Kind,
154 Discrete_Or_Fixed_Point_Kind,
155 Elementary_Kind,
156 Enumeration_Kind,
157 Entry_Kind,
158 Evaluable_Kind,
159 Exception_Or_Object_Kind,
160 Fixed_Point_Kind,
161 Float_Kind,
162 Formal_Kind,
163 Formal_Object_Kind,
164 Generic_Subprogram_Kind,
165 Generic_Unit_Kind,
166 Global_Name_Kind,
167 Incomplete_Kind,
168 Incomplete_Or_Private_Kind,
169 Integer_Kind,
170 Modular_Integer_Kind,
171 Named_Access_Kind,
172 Named_Kind,
173 Numeric_Kind,
174 Object_Kind,
175 Ordinary_Fixed_Point_Kind,
176 Overloadable_Kind,
177 Private_Kind,
178 Protected_Kind,
179 Real_Kind,
180 Record_Kind,
181 Record_Field_Kind,
182 Scalar_Kind,
183 Scope_Kind,
184 Signed_Integer_Kind,
185 Subprogram_Type_Or_Kind,
186 Subprogram_Kind,
187 Task_Kind,
188 Type_Kind,
189 Void_Or_Type_Kind,
190
191 -- End of abstract entity types.
192
193 Between_Abstract_Entity_And_Concrete_Node_Types,
194
195 -- Concrete node types:
196
197 N_Unused_At_Start,
198 N_At_Clause,
199 N_Component_Clause,
200 N_Enumeration_Representation_Clause,
201 N_Mod_Clause,
202 N_Record_Representation_Clause,
203 N_Attribute_Definition_Clause,
204 N_Empty,
205 N_Pragma_Argument_Association,
206 N_Error,
207 N_Defining_Character_Literal,
208 N_Defining_Identifier,
209 N_Defining_Operator_Symbol,
210 N_Expanded_Name,
211 N_Identifier,
212 N_Operator_Symbol,
213 N_Character_Literal,
214 N_Op_Add,
215 N_Op_Concat,
216 N_Op_Expon,
217 N_Op_Subtract,
218 N_Op_Divide,
219 N_Op_Mod,
220 N_Op_Multiply,
221 N_Op_Rem,
222 N_Op_And,
223 N_Op_Eq,
224 N_Op_Ge,
225 N_Op_Gt,
226 N_Op_Le,
227 N_Op_Lt,
228 N_Op_Ne,
229 N_Op_Or,
230 N_Op_Xor,
231 N_Op_Rotate_Left,
232 N_Op_Rotate_Right,
233 N_Op_Shift_Left,
234 N_Op_Shift_Right,
235 N_Op_Shift_Right_Arithmetic,
236 N_Op_Abs,
237 N_Op_Minus,
238 N_Op_Not,
239 N_Op_Plus,
240 N_Attribute_Reference,
241 N_In,
242 N_Not_In,
243 N_And_Then,
244 N_Or_Else,
245 N_Function_Call,
246 N_Procedure_Call_Statement,
247 N_Raise_Constraint_Error,
248 N_Raise_Program_Error,
249 N_Raise_Storage_Error,
250 N_Integer_Literal,
251 N_Real_Literal,
252 N_String_Literal,
253 N_Explicit_Dereference,
254 N_Expression_With_Actions,
255 N_External_Initializer,
256 N_If_Expression,
257 N_Indexed_Component,
258 N_Interpolated_String_Literal,
259 N_Null,
260 N_Qualified_Expression,
261 N_Quantified_Expression,
262 N_Aggregate,
263 N_Allocator,
264 N_Case_Expression,
265 N_Delta_Aggregate,
266 N_Extension_Aggregate,
267 N_Raise_Expression,
268 N_Range,
269 N_Reference,
270 N_Selected_Component,
271 N_Slice,
272 N_Target_Name,
273 N_Type_Conversion,
274 N_Unchecked_Type_Conversion,
275 N_Subtype_Indication,
276 N_Component_Declaration,
277 N_Entry_Declaration,
278 N_Expression_Function,
279 N_Formal_Object_Declaration,
280 N_Formal_Type_Declaration,
281 N_Full_Type_Declaration,
282 N_Incomplete_Type_Declaration,
283 N_Iterator_Specification,
284 N_Loop_Parameter_Specification,
285 N_Object_Declaration,
286 N_Protected_Type_Declaration,
287 N_Private_Extension_Declaration,
288 N_Private_Type_Declaration,
289 N_Subtype_Declaration,
290 N_Function_Specification,
291 N_Procedure_Specification,
292 N_Access_Function_Definition,
293 N_Access_Procedure_Definition,
294 N_Task_Type_Declaration,
295 N_Package_Body_Stub,
296 N_Protected_Body_Stub,
297 N_Subprogram_Body_Stub,
298 N_Task_Body_Stub,
299 N_Function_Instantiation,
300 N_Procedure_Instantiation,
301 N_Package_Instantiation,
302 N_Package_Body,
303 N_Subprogram_Body,
304 N_Protected_Body,
305 N_Task_Body,
306 N_Implicit_Label_Declaration,
307 N_Package_Declaration,
308 N_Single_Task_Declaration,
309 N_Subprogram_Declaration,
310 N_Use_Package_Clause,
311 N_Generic_Package_Declaration,
312 N_Generic_Subprogram_Declaration,
313 N_Constrained_Array_Definition,
314 N_Unconstrained_Array_Definition,
315 N_Exception_Renaming_Declaration,
316 N_Object_Renaming_Declaration,
317 N_Package_Renaming_Declaration,
318 N_Subprogram_Renaming_Declaration,
319 N_Generic_Function_Renaming_Declaration,
320 N_Generic_Package_Renaming_Declaration,
321 N_Generic_Procedure_Renaming_Declaration,
322 N_Abort_Statement,
323 N_Accept_Statement,
324 N_Assignment_Statement,
325 N_Asynchronous_Select,
326 N_Block_Statement,
327 N_Case_Statement,
328 N_Code_Statement,
329 N_Compound_Statement,
330 N_Conditional_Entry_Call,
331 N_Delay_Relative_Statement,
332 N_Delay_Until_Statement,
333 N_Entry_Call_Statement,
334 N_Free_Statement,
335 N_Goto_Statement,
336 N_Goto_When_Statement,
337 N_Loop_Statement,
338 N_Null_Statement,
339 N_Raise_Statement,
340 N_Raise_When_Statement,
341 N_Requeue_Statement,
342 N_Simple_Return_Statement,
343 N_Extended_Return_Statement,
344 N_Return_When_Statement,
345 N_Selective_Accept,
346 N_Timed_Entry_Call,
347 N_Exit_Statement,
348 N_If_Statement,
349 N_Accept_Alternative,
350 N_Delay_Alternative,
351 N_Elsif_Part,
352 N_Entry_Body_Formal_Part,
353 N_Iteration_Scheme,
354 N_Terminate_Alternative,
355 N_Formal_Abstract_Subprogram_Declaration,
356 N_Formal_Concrete_Subprogram_Declaration,
357 N_Push_Constraint_Error_Label,
358 N_Push_Program_Error_Label,
359 N_Push_Storage_Error_Label,
360 N_Pop_Constraint_Error_Label,
361 N_Pop_Program_Error_Label,
362 N_Pop_Storage_Error_Label,
363 N_SCIL_Dispatch_Table_Tag_Init,
364 N_SCIL_Dispatching_Call,
365 N_SCIL_Membership_Test,
366 N_Abortable_Part,
367 N_Abstract_Subprogram_Declaration,
368 N_Access_Definition,
369 N_Access_To_Object_Definition,
370 N_Aspect_Specification,
371 N_Call_Marker,
372 N_Case_Expression_Alternative,
373 N_Case_Statement_Alternative,
374 N_Compilation_Unit,
375 N_Compilation_Unit_Aux,
376 N_Component_Association,
377 N_Component_Definition,
378 N_Component_List,
379 N_Contract,
380 N_Derived_Type_Definition,
381 N_Decimal_Fixed_Point_Definition,
382 N_Defining_Program_Unit_Name,
383 N_Delta_Constraint,
384 N_Designator,
385 N_Digits_Constraint,
386 N_Discriminant_Association,
387 N_Discriminant_Specification,
388 N_Enumeration_Type_Definition,
389 N_Entry_Body,
390 N_Entry_Call_Alternative,
391 N_Entry_Index_Specification,
392 N_Exception_Declaration,
393 N_Exception_Handler,
394 N_Floating_Point_Definition,
395 N_Formal_Decimal_Fixed_Point_Definition,
396 N_Formal_Derived_Type_Definition,
397 N_Formal_Discrete_Type_Definition,
398 N_Formal_Floating_Point_Definition,
399 N_Formal_Modular_Type_Definition,
400 N_Formal_Ordinary_Fixed_Point_Definition,
401 N_Formal_Package_Declaration,
402 N_Formal_Private_Type_Definition,
403 N_Formal_Incomplete_Type_Definition,
404 N_Formal_Signed_Integer_Type_Definition,
405 N_Freeze_Entity,
406 N_Freeze_Generic_Entity,
407 N_Generic_Association,
408 N_Handled_Sequence_Of_Statements,
409 N_Index_Or_Discriminant_Constraint,
410 N_Iterated_Component_Association,
411 N_Iterated_Element_Association,
412 N_Itype_Reference,
413 N_Label,
414 N_Modular_Type_Definition,
415 N_Number_Declaration,
416 N_Ordinary_Fixed_Point_Definition,
417 N_Others_Choice,
418 N_Package_Specification,
419 N_Parameter_Association,
420 N_Parameter_Specification,
421 N_Pragma,
422 N_Protected_Definition,
423 N_Range_Constraint,
424 N_Real_Range_Specification,
425 N_Record_Definition,
426 N_Signed_Integer_Type_Definition,
427 N_Single_Protected_Declaration,
428 N_Subunit,
429 N_Task_Definition,
430 N_Triggering_Alternative,
431 N_Use_Type_Clause,
432 N_Validate_Unchecked_Conversion,
433 N_Variable_Reference_Marker,
434 N_Variant,
435 N_Variant_Part,
436 N_With_Clause,
437 N_Unused_At_End,
438
439 -- End of concrete node types.
440
441 Between_Concrete_Node_And_Concrete_Entity_Types,
442
443 -- Concrete entity types:
444
445 E_Void,
446 E_Component,
447 E_Constant,
448 E_Discriminant,
449 E_Loop_Parameter,
450 E_Variable,
451 E_Out_Parameter,
452 E_In_Out_Parameter,
453 E_In_Parameter,
454 E_Generic_In_Out_Parameter,
455 E_Generic_In_Parameter,
456 E_Named_Integer,
457 E_Named_Real,
458 E_Enumeration_Type,
459 E_Enumeration_Subtype,
460 E_Signed_Integer_Type,
461 E_Signed_Integer_Subtype,
462 E_Modular_Integer_Type,
463 E_Modular_Integer_Subtype,
464 E_Ordinary_Fixed_Point_Type,
465 E_Ordinary_Fixed_Point_Subtype,
466 E_Decimal_Fixed_Point_Type,
467 E_Decimal_Fixed_Point_Subtype,
468 E_Floating_Point_Type,
469 E_Floating_Point_Subtype,
470 E_Access_Type,
471 E_Access_Subtype,
472 E_Access_Attribute_Type,
473 E_Allocator_Type,
474 E_General_Access_Type,
475 E_Access_Subprogram_Type,
476 E_Access_Protected_Subprogram_Type,
477 E_Anonymous_Access_Protected_Subprogram_Type,
478 E_Anonymous_Access_Subprogram_Type,
479 E_Anonymous_Access_Type,
480 E_Array_Type,
481 E_Array_Subtype,
482 E_String_Literal_Subtype,
483 E_Class_Wide_Type,
484 E_Class_Wide_Subtype,
485 E_Record_Type,
486 E_Record_Subtype,
487 E_Record_Type_With_Private,
488 E_Record_Subtype_With_Private,
489 E_Private_Type,
490 E_Private_Subtype,
491 E_Limited_Private_Type,
492 E_Limited_Private_Subtype,
493 E_Incomplete_Type,
494 E_Incomplete_Subtype,
495 E_Task_Type,
496 E_Task_Subtype,
497 E_Protected_Type,
498 E_Protected_Subtype,
499 E_Exception_Type,
500 E_Subprogram_Type,
501 E_Enumeration_Literal,
502 E_Function,
503 E_Operator,
504 E_Procedure,
505 E_Abstract_State,
506 E_Entry,
507 E_Entry_Family,
508 E_Block,
509 E_Entry_Index_Parameter,
510 E_Exception,
511 E_Generic_Function,
512 E_Generic_Procedure,
513 E_Generic_Package,
514 E_Label,
515 E_Loop,
516 E_Return_Statement,
517 E_Package,
518 E_Package_Body,
519 E_Protected_Body,
520 E_Task_Body,
521 E_Subprogram_Body
522
523 -- End of concrete entity types.
524
525 ); -- Type_Enum
526
527 subtype Type_Enum is Opt_Type_Enum
528 range Opt_Type_Enum'Succ (No_Type) .. Opt_Type_Enum'Last;
529 -- Enumeration of types -- Opt_Type_Enum without the special null value
530 -- No_Type.
531
532 subtype Node_Or_Entity_Type is
533 Type_Enum range
534 Type_Enum'Succ (Between_Special_And_Abstract_Node_Types) ..
535 Type_Enum'Last;
536
537 subtype Abstract_Type is
538 Type_Enum range
539 Type_Enum'Succ (Between_Special_And_Abstract_Node_Types) ..
540 Type_Enum'Pred (Between_Abstract_Entity_And_Concrete_Node_Types);
541 subtype Abstract_Node is
542 Abstract_Type range
543 Type_Enum'Succ (Between_Special_And_Abstract_Node_Types) ..
544 Type_Enum'Pred (Between_Abstract_Node_And_Abstract_Entity_Types);
545 subtype Abstract_Entity is
546 Abstract_Type range
547 Type_Enum'Succ (Between_Abstract_Node_And_Abstract_Entity_Types) ..
548 Type_Enum'Pred (Between_Abstract_Entity_And_Concrete_Node_Types);
549
550 subtype Concrete_Type is
551 Type_Enum range
552 Type_Enum'Succ (Between_Abstract_Entity_And_Concrete_Node_Types) ..
553 Type_Enum'Last;
554 subtype Concrete_Node is
555 Concrete_Type range
556 Type_Enum'Succ (Between_Abstract_Entity_And_Concrete_Node_Types) ..
557 Type_Enum'Pred (Between_Concrete_Node_And_Concrete_Entity_Types);
558 subtype Concrete_Entity is
559 Concrete_Type range
560 Type_Enum'Succ (Between_Concrete_Node_And_Concrete_Entity_Types) ..
561 Type_Enum'Last;
562
563 subtype Root_Type is Abstract_Type with
564 Predicate => Root_Type in Node_Kind | Entity_Kind;
565
566 subtype Node_Type is Node_Or_Entity_Type with
567 Predicate => Node_Type in Abstract_Node | Concrete_Node;
568 subtype Entity_Type is Node_Or_Entity_Type with
569 Predicate => Entity_Type in Abstract_Entity | Concrete_Entity;
570
571 subtype Special_Type is Type_Enum range
572 Flag .. Type_Enum'Pred (Between_Special_And_Abstract_Node_Types);
573
574 subtype Traversed_Field_Type is Type_Enum with Predicate =>
575 Traversed_Field_Type in Node_Id | List_Id | Node_Type;
576 -- These are the types of fields traversed by Traverse_Func
577
578 subtype Entity_Node is Node_Type with
579 Predicate => Entity_Node in
580 N_Defining_Character_Literal
581 | N_Defining_Identifier
582 | N_Defining_Operator_Symbol;
583
584 subtype Opt_Abstract_Type is Opt_Type_Enum with
585 Predicate => Opt_Abstract_Type in No_Type | Abstract_Type;
586
587 subtype Type_Boundaries is Type_Enum with
588 Predicate => Type_Boundaries in
589 Between_Abstract_Node_And_Abstract_Entity_Types |
590 Between_Abstract_Entity_And_Concrete_Node_Types |
591 Between_Concrete_Node_And_Concrete_Entity_Types;
592 -- These are not used, other than to separate the various subranges.
593
594 subtype Uint_Subtype is Type_Enum with
595 Predicate => Uint_Subtype in Valid_Uint | Unat | Upos | Nonzero_Uint;
596 -- These are the subtypes of Uint that have predicates restricting their
597 -- values.
598
599 end Gen_IL.Types;