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