1------------------------------------------------------------------------------ 2-- -- 3-- GNAT COMPILER COMPONENTS -- 4-- -- 5-- C S T A N D -- 6-- -- 7-- B o d y -- 8-- -- 9-- Copyright (C) 1992-2004 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 2, 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 COPYING. If not, write -- 19-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- 20-- MA 02111-1307, USA. -- 21-- -- 22-- GNAT was originally developed by the GNAT team at New York University. -- 23-- Extensive contributions were provided by Ada Core Technologies Inc. -- 24-- -- 25------------------------------------------------------------------------------ 26 27with Atree; use Atree; 28with Csets; use Csets; 29with Debug; use Debug; 30with Einfo; use Einfo; 31with Layout; use Layout; 32with Namet; use Namet; 33with Nlists; use Nlists; 34with Nmake; use Nmake; 35with Opt; use Opt; 36with Output; use Output; 37with Targparm; use Targparm; 38with Tbuild; use Tbuild; 39with Ttypes; use Ttypes; 40with Ttypef; use Ttypef; 41with Scn; 42with Sem_Mech; use Sem_Mech; 43with Sem_Util; use Sem_Util; 44with Sinfo; use Sinfo; 45with Snames; use Snames; 46with Stand; use Stand; 47with Uintp; use Uintp; 48with Urealp; use Urealp; 49 50package body CStand is 51 52 Stloc : constant Source_Ptr := Standard_Location; 53 Staloc : constant Source_Ptr := Standard_ASCII_Location; 54 -- Standard abbreviations used throughout this package 55 56 ----------------------- 57 -- Local Subprograms -- 58 ----------------------- 59 60 procedure Build_Float_Type (E : Entity_Id; Siz : Int; Digs : Int); 61 -- Procedure to build standard predefined float base type. The first 62 -- parameter is the entity for the type, and the second parameter 63 -- is the size in bits. The third parameter is the digits value. 64 65 procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Int); 66 -- Procedure to build standard predefined signed integer subtype. The 67 -- first parameter is the entity for the subtype. The second parameter 68 -- is the size in bits. The corresponding base type is not built by 69 -- this routine but instead must be built by the caller where needed. 70 71 procedure Create_Operators; 72 -- Make entries for each of the predefined operators in Standard 73 74 procedure Create_Unconstrained_Base_Type 75 (E : Entity_Id; 76 K : Entity_Kind); 77 -- The predefined signed integer types are constrained subtypes which 78 -- must have a corresponding unconstrained base type. This type is almost 79 -- useless. The only place it has semantics is Subtypes_Statically_Match. 80 -- Consequently, we arrange for it to be identical apart from the setting 81 -- of the constrained bit. This routine takes an entity E for the Type, 82 -- copies it to estabish the base type, then resets the Ekind of the 83 -- original entity to K (the Ekind for the subtype). The Etype field of 84 -- E is set by the call (to point to the created base type entity), and 85 -- also the Is_Constrained flag of E is set. 86 -- 87 -- To understand the exact requirement for this, see RM 3.5.4(11) which 88 -- makes it clear that Integer, for example, is constrained, with the 89 -- constraint bounds matching the bounds of the (unconstrained) base 90 -- type. The point is that Integer and Integer'Base have identical 91 -- bounds, but do not statically match, since a subtype with constraints 92 -- never matches a subtype with no constraints. 93 94 function Identifier_For (S : Standard_Entity_Type) return Node_Id; 95 -- Returns an identifier node with the same name as the defining 96 -- identifier corresponding to the given Standard_Entity_Type value 97 98 procedure Make_Component 99 (Rec : Entity_Id; 100 Typ : Entity_Id; 101 Nam : String); 102 -- Build a record component with the given type and name, and append to 103 -- the list of components of Rec. 104 105 function Make_Formal 106 (Typ : Entity_Id; 107 Formal_Name : String) return Entity_Id; 108 -- Construct entity for subprogram formal with given name and type 109 110 function Make_Integer (V : Uint) return Node_Id; 111 -- Builds integer literal with given value 112 113 procedure Make_Name (Id : Entity_Id; Nam : String); 114 -- Make an entry in the names table for Nam, and set as Chars field of Id 115 116 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id; 117 -- Build entity for standard operator with given name and type. 118 119 function New_Standard_Entity 120 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id; 121 -- Builds a new entity for Standard 122 123 procedure Print_Standard; 124 -- Print representation of package Standard if switch set 125 126 procedure Set_Integer_Bounds 127 (Id : Entity_Id; 128 Typ : Entity_Id; 129 Lb : Uint; 130 Hb : Uint); 131 -- Procedure to set bounds for integer type or subtype. Id is the entity 132 -- whose bounds and type are to be set. The Typ parameter is the Etype 133 -- value for the entity (which will be the same as Id for all predefined 134 -- integer base types. The third and fourth parameters are the bounds. 135 136 ---------------------- 137 -- Build_Float_Type -- 138 ---------------------- 139 140 procedure Build_Float_Type (E : Entity_Id; Siz : Int; Digs : Int) is 141 begin 142 Set_Type_Definition (Parent (E), 143 Make_Floating_Point_Definition (Stloc, 144 Digits_Expression => Make_Integer (UI_From_Int (Digs)))); 145 Set_Ekind (E, E_Floating_Point_Type); 146 Set_Etype (E, E); 147 Init_Size (E, Siz); 148 Set_Prim_Alignment (E); 149 Init_Digits_Value (E, Digs); 150 Set_Float_Bounds (E); 151 Set_Is_Frozen (E); 152 Set_Is_Public (E); 153 Set_Size_Known_At_Compile_Time (E); 154 end Build_Float_Type; 155 156 ------------------------------- 157 -- Build_Signed_Integer_Type -- 158 ------------------------------- 159 160 procedure Build_Signed_Integer_Type (E : Entity_Id; Siz : Int) is 161 U2Siz1 : constant Uint := 2 ** (Siz - 1); 162 Lbound : constant Uint := -U2Siz1; 163 Ubound : constant Uint := U2Siz1 - 1; 164 165 begin 166 Set_Type_Definition (Parent (E), 167 Make_Signed_Integer_Type_Definition (Stloc, 168 Low_Bound => Make_Integer (Lbound), 169 High_Bound => Make_Integer (Ubound))); 170 171 Set_Ekind (E, E_Signed_Integer_Type); 172 Set_Etype (E, E); 173 Init_Size (E, Siz); 174 Set_Prim_Alignment (E); 175 Set_Integer_Bounds (E, E, Lbound, Ubound); 176 Set_Is_Frozen (E); 177 Set_Is_Public (E); 178 Set_Is_Known_Valid (E); 179 Set_Size_Known_At_Compile_Time (E); 180 end Build_Signed_Integer_Type; 181 182 ---------------------- 183 -- Create_Operators -- 184 ---------------------- 185 186 -- Each operator has an abbreviated signature. The formals have the names 187 -- LEFT and RIGHT. Their types are not actually used for resolution. 188 189 procedure Create_Operators is 190 Op_Node : Entity_Id; 191 192 -- Following list has two entries for concatenation, to include 193 -- explicitly the operation on wide strings. 194 195 Binary_Ops : constant array (S_Binary_Ops) of Name_Id := 196 (Name_Op_Add, Name_Op_And, Name_Op_Concat, Name_Op_Concat, 197 Name_Op_Divide, Name_Op_Eq, Name_Op_Expon, Name_Op_Ge, 198 Name_Op_Gt, Name_Op_Le, Name_Op_Lt, Name_Op_Mod, 199 Name_Op_Multiply, Name_Op_Ne, Name_Op_Or, Name_Op_Rem, 200 Name_Op_Subtract, Name_Op_Xor); 201 202 Bin_Op_Types : constant array (S_Binary_Ops) of Entity_Id := 203 (Universal_Integer, Standard_Boolean, 204 Standard_String, Standard_Wide_String, 205 Universal_Integer, Standard_Boolean, 206 Universal_Integer, Standard_Boolean, 207 Standard_Boolean, Standard_Boolean, 208 Standard_Boolean, Universal_Integer, 209 Universal_Integer, Standard_Boolean, 210 Standard_Boolean, Universal_Integer, 211 Universal_Integer, Standard_Boolean); 212 213 Unary_Ops : constant array (S_Unary_Ops) of Name_Id := 214 (Name_Op_Abs, Name_Op_Subtract, Name_Op_Not, Name_Op_Add); 215 216 Unary_Op_Types : constant array (S_Unary_Ops) of Entity_Id := 217 (Universal_Integer, Universal_Integer, 218 Standard_Boolean, Universal_Integer); 219 220 -- Corresponding to Abs, Minus, Not, and Plus. 221 222 begin 223 for J in S_Binary_Ops loop 224 Op_Node := New_Operator (Binary_Ops (J), Bin_Op_Types (J)); 225 SE (J) := Op_Node; 226 Append_Entity (Make_Formal (Any_Type, "LEFT"), Op_Node); 227 Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node); 228 end loop; 229 230 for J in S_Unary_Ops loop 231 Op_Node := New_Operator (Unary_Ops (J), Unary_Op_Types (J)); 232 SE (J) := Op_Node; 233 Append_Entity (Make_Formal (Any_Type, "RIGHT"), Op_Node); 234 end loop; 235 236 -- For concatenation, we create a separate operator for each 237 -- array type. This simplifies the resolution of the component- 238 -- component concatenation operation. In Standard, we set the types 239 -- of the formals for string and wide string concatenation. 240 241 Set_Etype (First_Entity (Standard_Op_Concat), Standard_String); 242 Set_Etype (Last_Entity (Standard_Op_Concat), Standard_String); 243 244 Set_Etype (First_Entity (Standard_Op_Concatw), Standard_Wide_String); 245 Set_Etype (Last_Entity (Standard_Op_Concatw), Standard_Wide_String); 246 247 end Create_Operators; 248 249 --------------------- 250 -- Create_Standard -- 251 --------------------- 252 253 -- The tree for the package Standard is prefixed to all compilations. 254 -- Several entities required by semantic analysis are denoted by global 255 -- variables that are initialized to point to the corresponding 256 -- occurrences in STANDARD. The visible entities of STANDARD are 257 -- created here. The private entities defined in STANDARD are created 258 -- by Initialize_Standard in the semantics module. 259 260 procedure Create_Standard is 261 Decl_S : constant List_Id := New_List; 262 -- List of declarations in Standard 263 264 Decl_A : constant List_Id := New_List; 265 -- List of declarations in ASCII 266 267 Decl : Node_Id; 268 Pspec : Node_Id; 269 Tdef_Node : Node_Id; 270 Ident_Node : Node_Id; 271 Ccode : Char_Code; 272 E_Id : Entity_Id; 273 R_Node : Node_Id; 274 B_Node : Node_Id; 275 276 procedure Build_Exception (S : Standard_Entity_Type); 277 -- Procedure to declare given entity as an exception 278 279 --------------------- 280 -- Build_Exception -- 281 --------------------- 282 283 procedure Build_Exception (S : Standard_Entity_Type) is 284 begin 285 Set_Ekind (Standard_Entity (S), E_Exception); 286 Set_Etype (Standard_Entity (S), Standard_Exception_Type); 287 Set_Exception_Code (Standard_Entity (S), Uint_0); 288 Set_Is_Public (Standard_Entity (S), True); 289 290 Decl := 291 Make_Exception_Declaration (Stloc, 292 Defining_Identifier => Standard_Entity (S)); 293 Append (Decl, Decl_S); 294 end Build_Exception; 295 296 -- Start of processing for Create_Standard 297 298 begin 299 -- Initialize scanner for internal scans of literals 300 301 Scn.Initialize_Scanner (No_Unit, Internal_Source_File); 302 303 -- First step is to create defining identifiers for each entity 304 305 for S in Standard_Entity_Type loop 306 declare 307 S_Name : constant String := Standard_Entity_Type'Image (S); 308 -- Name of entity (note we skip S_ at the start) 309 310 Ident_Node : Node_Id; 311 -- Defining identifier node 312 313 begin 314 Ident_Node := New_Standard_Entity; 315 Make_Name (Ident_Node, S_Name (3 .. S_Name'Length)); 316 Standard_Entity (S) := Ident_Node; 317 end; 318 end loop; 319 320 -- Create package declaration node for package Standard 321 322 Standard_Package_Node := New_Node (N_Package_Declaration, Stloc); 323 324 Pspec := New_Node (N_Package_Specification, Stloc); 325 Set_Specification (Standard_Package_Node, Pspec); 326 327 Set_Defining_Unit_Name (Pspec, Standard_Standard); 328 Set_Visible_Declarations (Pspec, Decl_S); 329 330 Set_Ekind (Standard_Standard, E_Package); 331 Set_Is_Pure (Standard_Standard); 332 Set_Is_Compilation_Unit (Standard_Standard); 333 334 -- Create type declaration nodes for standard types 335 336 for S in S_Types loop 337 Decl := New_Node (N_Full_Type_Declaration, Stloc); 338 Set_Defining_Identifier (Decl, Standard_Entity (S)); 339 Set_Is_Frozen (Standard_Entity (S)); 340 Set_Is_Public (Standard_Entity (S)); 341 Append (Decl, Decl_S); 342 end loop; 343 344 -- Create type definition node for type Boolean. The Size is set to 345 -- 1 as required by Ada 95 and current ARG interpretations for Ada/83. 346 347 -- Note: Object_Size of Boolean is 8. This means that we do NOT in 348 -- general know that Boolean variables have valid values, so we do 349 -- not set the Is_Known_Valid flag. 350 351 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); 352 Set_Literals (Tdef_Node, New_List); 353 Append (Standard_False, Literals (Tdef_Node)); 354 Append (Standard_True, Literals (Tdef_Node)); 355 Set_Type_Definition (Parent (Standard_Boolean), Tdef_Node); 356 357 Set_Ekind (Standard_Boolean, E_Enumeration_Type); 358 Set_First_Literal (Standard_Boolean, Standard_False); 359 Set_Etype (Standard_Boolean, Standard_Boolean); 360 Init_Esize (Standard_Boolean, Standard_Character_Size); 361 Init_RM_Size (Standard_Boolean, 1); 362 Set_Prim_Alignment (Standard_Boolean); 363 364 Set_Is_Unsigned_Type (Standard_Boolean); 365 Set_Size_Known_At_Compile_Time (Standard_Boolean); 366 367 Set_Ekind (Standard_True, E_Enumeration_Literal); 368 Set_Etype (Standard_True, Standard_Boolean); 369 Set_Enumeration_Pos (Standard_True, Uint_1); 370 Set_Enumeration_Rep (Standard_True, Uint_1); 371 Set_Is_Known_Valid (Standard_True, True); 372 373 Set_Ekind (Standard_False, E_Enumeration_Literal); 374 Set_Etype (Standard_False, Standard_Boolean); 375 Set_Enumeration_Pos (Standard_False, Uint_0); 376 Set_Enumeration_Rep (Standard_False, Uint_0); 377 Set_Is_Known_Valid (Standard_False, True); 378 379 -- For the bounds of Boolean, we create a range node corresponding to 380 381 -- range False .. True 382 383 -- where the occurrences of the literals must point to the 384 -- corresponding definition. 385 386 R_Node := New_Node (N_Range, Stloc); 387 B_Node := New_Node (N_Identifier, Stloc); 388 Set_Chars (B_Node, Chars (Standard_False)); 389 Set_Entity (B_Node, Standard_False); 390 Set_Etype (B_Node, Standard_Boolean); 391 Set_Is_Static_Expression (B_Node); 392 Set_Low_Bound (R_Node, B_Node); 393 394 B_Node := New_Node (N_Identifier, Stloc); 395 Set_Chars (B_Node, Chars (Standard_True)); 396 Set_Entity (B_Node, Standard_True); 397 Set_Etype (B_Node, Standard_Boolean); 398 Set_Is_Static_Expression (B_Node); 399 Set_High_Bound (R_Node, B_Node); 400 401 Set_Scalar_Range (Standard_Boolean, R_Node); 402 Set_Etype (R_Node, Standard_Boolean); 403 Set_Parent (R_Node, Standard_Boolean); 404 405 -- Create type definition nodes for predefined integer types 406 407 Build_Signed_Integer_Type 408 (Standard_Short_Short_Integer, Standard_Short_Short_Integer_Size); 409 410 Build_Signed_Integer_Type 411 (Standard_Short_Integer, Standard_Short_Integer_Size); 412 413 Build_Signed_Integer_Type 414 (Standard_Integer, Standard_Integer_Size); 415 416 declare 417 LIS : Nat; 418 begin 419 if Debug_Flag_M then 420 LIS := 64; 421 else 422 LIS := Standard_Long_Integer_Size; 423 end if; 424 425 Build_Signed_Integer_Type (Standard_Long_Integer, LIS); 426 end; 427 428 Build_Signed_Integer_Type 429 (Standard_Long_Long_Integer, Standard_Long_Long_Integer_Size); 430 431 Create_Unconstrained_Base_Type 432 (Standard_Short_Short_Integer, E_Signed_Integer_Subtype); 433 434 Create_Unconstrained_Base_Type 435 (Standard_Short_Integer, E_Signed_Integer_Subtype); 436 437 Create_Unconstrained_Base_Type 438 (Standard_Integer, E_Signed_Integer_Subtype); 439 440 Create_Unconstrained_Base_Type 441 (Standard_Long_Integer, E_Signed_Integer_Subtype); 442 443 Create_Unconstrained_Base_Type 444 (Standard_Long_Long_Integer, E_Signed_Integer_Subtype); 445 446 -- Create type definition nodes for predefined float types 447 448 Build_Float_Type 449 (Standard_Short_Float, 450 Standard_Short_Float_Size, 451 Standard_Short_Float_Digits); 452 453 Build_Float_Type 454 (Standard_Float, 455 Standard_Float_Size, 456 Standard_Float_Digits); 457 458 Build_Float_Type 459 (Standard_Long_Float, 460 Standard_Long_Float_Size, 461 Standard_Long_Float_Digits); 462 463 Build_Float_Type 464 (Standard_Long_Long_Float, 465 Standard_Long_Long_Float_Size, 466 Standard_Long_Long_Float_Digits); 467 468 -- Create type definition node for type Character. Note that we do not 469 -- set the Literals field, since type Character is handled with special 470 -- routine that do not need a literal list. 471 472 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); 473 Set_Type_Definition (Parent (Standard_Character), Tdef_Node); 474 475 Set_Ekind (Standard_Character, E_Enumeration_Type); 476 Set_Etype (Standard_Character, Standard_Character); 477 Init_Esize (Standard_Character, Standard_Character_Size); 478 Init_RM_Size (Standard_Character, 8); 479 Set_Prim_Alignment (Standard_Character); 480 481 Set_Is_Unsigned_Type (Standard_Character); 482 Set_Is_Character_Type (Standard_Character); 483 Set_Is_Known_Valid (Standard_Character); 484 Set_Size_Known_At_Compile_Time (Standard_Character); 485 486 -- Create the bounds for type Character. 487 488 R_Node := New_Node (N_Range, Stloc); 489 490 -- Low bound for type Character (Standard.Nul) 491 492 B_Node := New_Node (N_Character_Literal, Stloc); 493 Set_Is_Static_Expression (B_Node); 494 Set_Chars (B_Node, No_Name); 495 Set_Char_Literal_Value (B_Node, 16#00#); 496 Set_Entity (B_Node, Empty); 497 Set_Etype (B_Node, Standard_Character); 498 Set_Low_Bound (R_Node, B_Node); 499 500 -- High bound for type Character 501 502 B_Node := New_Node (N_Character_Literal, Stloc); 503 Set_Is_Static_Expression (B_Node); 504 Set_Chars (B_Node, No_Name); 505 Set_Char_Literal_Value (B_Node, 16#FF#); 506 Set_Entity (B_Node, Empty); 507 Set_Etype (B_Node, Standard_Character); 508 Set_High_Bound (R_Node, B_Node); 509 510 Set_Scalar_Range (Standard_Character, R_Node); 511 Set_Etype (R_Node, Standard_Character); 512 Set_Parent (R_Node, Standard_Character); 513 514 -- Create type definition for type Wide_Character. Note that we do not 515 -- set the Literals field, since type Wide_Character is handled with 516 -- special routines that do not need a literal list. 517 518 Tdef_Node := New_Node (N_Enumeration_Type_Definition, Stloc); 519 Set_Type_Definition (Parent (Standard_Wide_Character), Tdef_Node); 520 521 Set_Ekind (Standard_Wide_Character, E_Enumeration_Type); 522 Set_Etype (Standard_Wide_Character, Standard_Wide_Character); 523 Init_Size (Standard_Wide_Character, Standard_Wide_Character_Size); 524 525 Set_Prim_Alignment (Standard_Wide_Character); 526 Set_Is_Unsigned_Type (Standard_Wide_Character); 527 Set_Is_Character_Type (Standard_Wide_Character); 528 Set_Is_Known_Valid (Standard_Wide_Character); 529 Set_Size_Known_At_Compile_Time (Standard_Wide_Character); 530 531 -- Create the bounds for type Wide_Character. 532 533 R_Node := New_Node (N_Range, Stloc); 534 535 -- Low bound for type Wide_Character 536 537 B_Node := New_Node (N_Character_Literal, Stloc); 538 Set_Is_Static_Expression (B_Node); 539 Set_Chars (B_Node, No_Name); -- ??? 540 Set_Char_Literal_Value (B_Node, 16#0000#); 541 Set_Entity (B_Node, Empty); 542 Set_Etype (B_Node, Standard_Wide_Character); 543 Set_Low_Bound (R_Node, B_Node); 544 545 -- High bound for type Wide_Character 546 547 B_Node := New_Node (N_Character_Literal, Stloc); 548 Set_Is_Static_Expression (B_Node); 549 Set_Chars (B_Node, No_Name); -- ??? 550 Set_Char_Literal_Value (B_Node, 16#FFFF#); 551 Set_Entity (B_Node, Empty); 552 Set_Etype (B_Node, Standard_Wide_Character); 553 Set_High_Bound (R_Node, B_Node); 554 555 Set_Scalar_Range (Standard_Wide_Character, R_Node); 556 Set_Etype (R_Node, Standard_Wide_Character); 557 Set_Parent (R_Node, Standard_Wide_Character); 558 559 -- Create type definition node for type String 560 561 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); 562 563 declare 564 CompDef_Node : Node_Id; 565 begin 566 CompDef_Node := New_Node (N_Component_Definition, Stloc); 567 Set_Aliased_Present (CompDef_Node, False); 568 Set_Subtype_Indication (CompDef_Node, Identifier_For (S_Character)); 569 Set_Component_Definition (Tdef_Node, CompDef_Node); 570 end; 571 572 Set_Subtype_Marks (Tdef_Node, New_List); 573 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); 574 Set_Type_Definition (Parent (Standard_String), Tdef_Node); 575 576 Set_Ekind (Standard_String, E_String_Type); 577 Set_Etype (Standard_String, Standard_String); 578 Set_Component_Type (Standard_String, Standard_Character); 579 Set_Component_Size (Standard_String, Uint_8); 580 Init_Size_Align (Standard_String); 581 582 -- Set index type of String 583 584 E_Id := First 585 (Subtype_Marks (Type_Definition (Parent (Standard_String)))); 586 Set_First_Index (Standard_String, E_Id); 587 Set_Entity (E_Id, Standard_Positive); 588 Set_Etype (E_Id, Standard_Positive); 589 590 -- Create type definition node for type Wide_String 591 592 Tdef_Node := New_Node (N_Unconstrained_Array_Definition, Stloc); 593 declare 594 CompDef_Node : Node_Id; 595 begin 596 CompDef_Node := New_Node (N_Component_Definition, Stloc); 597 Set_Aliased_Present (CompDef_Node, False); 598 Set_Subtype_Indication (CompDef_Node, 599 Identifier_For (S_Wide_Character)); 600 Set_Component_Definition (Tdef_Node, CompDef_Node); 601 end; 602 Set_Subtype_Marks (Tdef_Node, New_List); 603 Append (Identifier_For (S_Positive), Subtype_Marks (Tdef_Node)); 604 Set_Type_Definition (Parent (Standard_Wide_String), Tdef_Node); 605 606 Set_Ekind (Standard_Wide_String, E_String_Type); 607 Set_Etype (Standard_Wide_String, Standard_Wide_String); 608 Set_Component_Type (Standard_Wide_String, Standard_Wide_Character); 609 Set_Component_Size (Standard_Wide_String, Uint_16); 610 Init_Size_Align (Standard_Wide_String); 611 612 -- Set index type of Wide_String 613 614 E_Id := First 615 (Subtype_Marks (Type_Definition (Parent (Standard_Wide_String)))); 616 Set_First_Index (Standard_Wide_String, E_Id); 617 Set_Entity (E_Id, Standard_Positive); 618 Set_Etype (E_Id, Standard_Positive); 619 620 -- Create subtype declaration for Natural 621 622 Decl := New_Node (N_Subtype_Declaration, Stloc); 623 Set_Defining_Identifier (Decl, Standard_Natural); 624 Set_Subtype_Indication (Decl, 625 New_Occurrence_Of (Standard_Integer, Stloc)); 626 Append (Decl, Decl_S); 627 628 Set_Ekind (Standard_Natural, E_Signed_Integer_Subtype); 629 Set_Etype (Standard_Natural, Base_Type (Standard_Integer)); 630 Init_Esize (Standard_Natural, Standard_Integer_Size); 631 Init_RM_Size (Standard_Natural, Standard_Integer_Size - 1); 632 Set_Prim_Alignment (Standard_Natural); 633 Set_Size_Known_At_Compile_Time 634 (Standard_Natural); 635 Set_Integer_Bounds (Standard_Natural, 636 Typ => Base_Type (Standard_Integer), 637 Lb => Uint_0, 638 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); 639 Set_Is_Constrained (Standard_Natural); 640 Set_Is_Frozen (Standard_Natural); 641 Set_Is_Public (Standard_Natural); 642 643 -- Create subtype declaration for Positive 644 645 Decl := New_Node (N_Subtype_Declaration, Stloc); 646 Set_Defining_Identifier (Decl, Standard_Positive); 647 Set_Subtype_Indication (Decl, 648 New_Occurrence_Of (Standard_Integer, Stloc)); 649 Append (Decl, Decl_S); 650 651 Set_Ekind (Standard_Positive, E_Signed_Integer_Subtype); 652 Set_Etype (Standard_Positive, Base_Type (Standard_Integer)); 653 Init_Esize (Standard_Positive, Standard_Integer_Size); 654 Init_RM_Size (Standard_Positive, Standard_Integer_Size - 1); 655 Set_Prim_Alignment (Standard_Positive); 656 657 Set_Size_Known_At_Compile_Time (Standard_Positive); 658 659 Set_Integer_Bounds (Standard_Positive, 660 Typ => Base_Type (Standard_Integer), 661 Lb => Uint_1, 662 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); 663 Set_Is_Constrained (Standard_Positive); 664 Set_Is_Frozen (Standard_Positive); 665 Set_Is_Public (Standard_Positive); 666 667 -- Create declaration for package ASCII 668 669 Decl := New_Node (N_Package_Declaration, Stloc); 670 Append (Decl, Decl_S); 671 672 Pspec := New_Node (N_Package_Specification, Stloc); 673 Set_Specification (Decl, Pspec); 674 675 Set_Defining_Unit_Name (Pspec, Standard_Entity (S_ASCII)); 676 Set_Ekind (Standard_Entity (S_ASCII), E_Package); 677 Set_Visible_Declarations (Pspec, Decl_A); 678 679 -- Create control character definitions in package ASCII. Note that 680 -- the character literal entries created here correspond to literal 681 -- values that are impossible in the source, but can be represented 682 -- internally with no difficulties. 683 684 Ccode := 16#00#; 685 686 for S in S_ASCII_Names loop 687 Decl := New_Node (N_Object_Declaration, Staloc); 688 Set_Constant_Present (Decl, True); 689 690 declare 691 A_Char : constant Entity_Id := Standard_Entity (S); 692 Expr_Decl : Node_Id; 693 694 begin 695 Set_Sloc (A_Char, Staloc); 696 Set_Ekind (A_Char, E_Constant); 697 Set_Never_Set_In_Source (A_Char, True); 698 Set_Is_True_Constant (A_Char, True); 699 Set_Etype (A_Char, Standard_Character); 700 Set_Scope (A_Char, Standard_Entity (S_ASCII)); 701 Set_Is_Immediately_Visible (A_Char, False); 702 Set_Is_Public (A_Char, True); 703 Set_Is_Known_Valid (A_Char, True); 704 705 Append_Entity (A_Char, Standard_Entity (S_ASCII)); 706 Set_Defining_Identifier (Decl, A_Char); 707 708 Set_Object_Definition (Decl, Identifier_For (S_Character)); 709 Expr_Decl := New_Node (N_Character_Literal, Staloc); 710 Set_Expression (Decl, Expr_Decl); 711 712 Set_Is_Static_Expression (Expr_Decl); 713 Set_Chars (Expr_Decl, No_Name); 714 Set_Etype (Expr_Decl, Standard_Character); 715 Set_Char_Literal_Value (Expr_Decl, Ccode); 716 end; 717 718 Append (Decl, Decl_A); 719 720 -- Increment character code, dealing with non-contiguities 721 722 Ccode := Ccode + 1; 723 724 if Ccode = 16#20# then 725 Ccode := 16#21#; 726 elsif Ccode = 16#27# then 727 Ccode := 16#3A#; 728 elsif Ccode = 16#3C# then 729 Ccode := 16#3F#; 730 elsif Ccode = 16#41# then 731 Ccode := 16#5B#; 732 end if; 733 end loop; 734 735 -- Create semantic phase entities 736 737 Standard_Void_Type := New_Standard_Entity; 738 Set_Ekind (Standard_Void_Type, E_Void); 739 Set_Etype (Standard_Void_Type, Standard_Void_Type); 740 Set_Scope (Standard_Void_Type, Standard_Standard); 741 Make_Name (Standard_Void_Type, "_void_type"); 742 743 -- The type field of packages is set to void 744 745 Set_Etype (Standard_Standard, Standard_Void_Type); 746 Set_Etype (Standard_ASCII, Standard_Void_Type); 747 748 -- Standard_A_String is actually used in generated code, so it has a 749 -- type name that is reasonable, but does not overlap any Ada name. 750 751 Standard_A_String := New_Standard_Entity; 752 Set_Ekind (Standard_A_String, E_Access_Type); 753 Set_Scope (Standard_A_String, Standard_Standard); 754 Set_Etype (Standard_A_String, Standard_A_String); 755 756 if Debug_Flag_6 then 757 Init_Size (Standard_A_String, System_Address_Size); 758 else 759 Init_Size (Standard_A_String, System_Address_Size * 2); 760 end if; 761 762 Init_Alignment (Standard_A_String); 763 764 Set_Directly_Designated_Type 765 (Standard_A_String, Standard_String); 766 Make_Name (Standard_A_String, "access_string"); 767 768 Standard_A_Char := New_Standard_Entity; 769 Set_Ekind (Standard_A_Char, E_Access_Type); 770 Set_Scope (Standard_A_Char, Standard_Standard); 771 Set_Etype (Standard_A_Char, Standard_A_String); 772 Init_Size (Standard_A_Char, System_Address_Size); 773 Set_Prim_Alignment (Standard_A_Char); 774 775 Set_Directly_Designated_Type (Standard_A_Char, Standard_Character); 776 Make_Name (Standard_A_Char, "access_character"); 777 778 -- Note on type names. The type names for the following special types 779 -- are constructed so that they will look reasonable should they ever 780 -- appear in error messages etc, although in practice the use of the 781 -- special insertion character } for types results in special handling 782 -- of these type names in any case. The blanks in these names would 783 -- trouble in Gigi, but that's OK here, since none of these types 784 -- should ever get through to Gigi! Attributes of these types are 785 -- filled out to minimize problems with cascaded errors (for example, 786 -- Any_Integer is given reasonable and consistent type and size values) 787 788 Any_Type := New_Standard_Entity; 789 Decl := New_Node (N_Full_Type_Declaration, Stloc); 790 Set_Defining_Identifier (Decl, Any_Type); 791 Set_Scope (Any_Type, Standard_Standard); 792 Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size); 793 Make_Name (Any_Type, "any type"); 794 795 Any_Id := New_Standard_Entity; 796 Set_Ekind (Any_Id, E_Variable); 797 Set_Scope (Any_Id, Standard_Standard); 798 Set_Etype (Any_Id, Any_Type); 799 Init_Size_Align (Any_Id); 800 Make_Name (Any_Id, "any id"); 801 802 Any_Access := New_Standard_Entity; 803 Set_Ekind (Any_Access, E_Access_Type); 804 Set_Scope (Any_Access, Standard_Standard); 805 Set_Etype (Any_Access, Any_Access); 806 Init_Size (Any_Access, System_Address_Size); 807 Set_Prim_Alignment (Any_Access); 808 Make_Name (Any_Access, "an access type"); 809 810 Any_Character := New_Standard_Entity; 811 Set_Ekind (Any_Character, E_Enumeration_Type); 812 Set_Scope (Any_Character, Standard_Standard); 813 Set_Etype (Any_Character, Any_Character); 814 Set_Is_Unsigned_Type (Any_Character); 815 Set_Is_Character_Type (Any_Character); 816 Init_Esize (Any_Character, Standard_Character_Size); 817 Init_RM_Size (Any_Character, 8); 818 Set_Prim_Alignment (Any_Character); 819 Set_Scalar_Range (Any_Character, Scalar_Range (Standard_Character)); 820 Make_Name (Any_Character, "a character type"); 821 822 Any_Array := New_Standard_Entity; 823 Set_Ekind (Any_Array, E_String_Type); 824 Set_Scope (Any_Array, Standard_Standard); 825 Set_Etype (Any_Array, Any_Array); 826 Set_Component_Type (Any_Array, Any_Character); 827 Init_Size_Align (Any_Array); 828 Make_Name (Any_Array, "an array type"); 829 830 Any_Boolean := New_Standard_Entity; 831 Set_Ekind (Any_Boolean, E_Enumeration_Type); 832 Set_Scope (Any_Boolean, Standard_Standard); 833 Set_Etype (Any_Boolean, Standard_Boolean); 834 Init_Esize (Any_Boolean, Standard_Character_Size); 835 Init_RM_Size (Any_Boolean, 1); 836 Set_Prim_Alignment (Any_Boolean); 837 Set_Is_Unsigned_Type (Any_Boolean); 838 Set_Scalar_Range (Any_Boolean, Scalar_Range (Standard_Boolean)); 839 Make_Name (Any_Boolean, "a boolean type"); 840 841 Any_Composite := New_Standard_Entity; 842 Set_Ekind (Any_Composite, E_Array_Type); 843 Set_Scope (Any_Composite, Standard_Standard); 844 Set_Etype (Any_Composite, Any_Composite); 845 Set_Component_Size (Any_Composite, Uint_0); 846 Set_Component_Type (Any_Composite, Standard_Integer); 847 Init_Size_Align (Any_Composite); 848 Make_Name (Any_Composite, "a composite type"); 849 850 Any_Discrete := New_Standard_Entity; 851 Set_Ekind (Any_Discrete, E_Signed_Integer_Type); 852 Set_Scope (Any_Discrete, Standard_Standard); 853 Set_Etype (Any_Discrete, Any_Discrete); 854 Init_Size (Any_Discrete, Standard_Integer_Size); 855 Set_Prim_Alignment (Any_Discrete); 856 Make_Name (Any_Discrete, "a discrete type"); 857 858 Any_Fixed := New_Standard_Entity; 859 Set_Ekind (Any_Fixed, E_Ordinary_Fixed_Point_Type); 860 Set_Scope (Any_Fixed, Standard_Standard); 861 Set_Etype (Any_Fixed, Any_Fixed); 862 Init_Size (Any_Fixed, Standard_Integer_Size); 863 Set_Prim_Alignment (Any_Fixed); 864 Make_Name (Any_Fixed, "a fixed-point type"); 865 866 Any_Integer := New_Standard_Entity; 867 Set_Ekind (Any_Integer, E_Signed_Integer_Type); 868 Set_Scope (Any_Integer, Standard_Standard); 869 Set_Etype (Any_Integer, Standard_Long_Long_Integer); 870 Init_Size (Any_Integer, Standard_Long_Long_Integer_Size); 871 Set_Prim_Alignment (Any_Integer); 872 873 Set_Integer_Bounds 874 (Any_Integer, 875 Typ => Base_Type (Standard_Integer), 876 Lb => Uint_0, 877 Hb => Intval (High_Bound (Scalar_Range (Standard_Integer)))); 878 Make_Name (Any_Integer, "an integer type"); 879 880 Any_Modular := New_Standard_Entity; 881 Set_Ekind (Any_Modular, E_Modular_Integer_Type); 882 Set_Scope (Any_Modular, Standard_Standard); 883 Set_Etype (Any_Modular, Standard_Long_Long_Integer); 884 Init_Size (Any_Modular, Standard_Long_Long_Integer_Size); 885 Set_Prim_Alignment (Any_Modular); 886 Set_Is_Unsigned_Type (Any_Modular); 887 Make_Name (Any_Modular, "a modular type"); 888 889 Any_Numeric := New_Standard_Entity; 890 Set_Ekind (Any_Numeric, E_Signed_Integer_Type); 891 Set_Scope (Any_Numeric, Standard_Standard); 892 Set_Etype (Any_Numeric, Standard_Long_Long_Integer); 893 Init_Size (Any_Numeric, Standard_Long_Long_Integer_Size); 894 Set_Prim_Alignment (Any_Numeric); 895 Make_Name (Any_Numeric, "a numeric type"); 896 897 Any_Real := New_Standard_Entity; 898 Set_Ekind (Any_Real, E_Floating_Point_Type); 899 Set_Scope (Any_Real, Standard_Standard); 900 Set_Etype (Any_Real, Standard_Long_Long_Float); 901 Init_Size (Any_Real, Standard_Long_Long_Float_Size); 902 Set_Prim_Alignment (Any_Real); 903 Make_Name (Any_Real, "a real type"); 904 905 Any_Scalar := New_Standard_Entity; 906 Set_Ekind (Any_Scalar, E_Signed_Integer_Type); 907 Set_Scope (Any_Scalar, Standard_Standard); 908 Set_Etype (Any_Scalar, Any_Scalar); 909 Init_Size (Any_Scalar, Standard_Integer_Size); 910 Set_Prim_Alignment (Any_Scalar); 911 Make_Name (Any_Scalar, "a scalar type"); 912 913 Any_String := New_Standard_Entity; 914 Set_Ekind (Any_String, E_String_Type); 915 Set_Scope (Any_String, Standard_Standard); 916 Set_Etype (Any_String, Any_String); 917 Set_Component_Type (Any_String, Any_Character); 918 Init_Size_Align (Any_String); 919 Make_Name (Any_String, "a string type"); 920 921 declare 922 Index : Node_Id; 923 924 begin 925 Index := 926 Make_Range (Stloc, 927 Low_Bound => Make_Integer (Uint_0), 928 High_Bound => Make_Integer (Uint_2 ** Standard_Integer_Size)); 929 Set_Etype (Index, Standard_Integer); 930 Set_First_Index (Any_String, Index); 931 end; 932 933 Standard_Integer_8 := New_Standard_Entity; 934 Decl := New_Node (N_Full_Type_Declaration, Stloc); 935 Set_Defining_Identifier (Decl, Standard_Integer_8); 936 Make_Name (Standard_Integer_8, "integer_8"); 937 Set_Scope (Standard_Integer_8, Standard_Standard); 938 Build_Signed_Integer_Type (Standard_Integer_8, 8); 939 940 Standard_Integer_16 := New_Standard_Entity; 941 Decl := New_Node (N_Full_Type_Declaration, Stloc); 942 Set_Defining_Identifier (Decl, Standard_Integer_16); 943 Make_Name (Standard_Integer_16, "integer_16"); 944 Set_Scope (Standard_Integer_16, Standard_Standard); 945 Build_Signed_Integer_Type (Standard_Integer_16, 16); 946 947 Standard_Integer_32 := New_Standard_Entity; 948 Decl := New_Node (N_Full_Type_Declaration, Stloc); 949 Set_Defining_Identifier (Decl, Standard_Integer_32); 950 Make_Name (Standard_Integer_32, "integer_32"); 951 Set_Scope (Standard_Integer_32, Standard_Standard); 952 Build_Signed_Integer_Type (Standard_Integer_32, 32); 953 954 Standard_Integer_64 := New_Standard_Entity; 955 Decl := New_Node (N_Full_Type_Declaration, Stloc); 956 Set_Defining_Identifier (Decl, Standard_Integer_64); 957 Make_Name (Standard_Integer_64, "integer_64"); 958 Set_Scope (Standard_Integer_64, Standard_Standard); 959 Build_Signed_Integer_Type (Standard_Integer_64, 64); 960 961 Standard_Unsigned := New_Standard_Entity; 962 Decl := New_Node (N_Full_Type_Declaration, Stloc); 963 Set_Defining_Identifier (Decl, Standard_Unsigned); 964 Make_Name (Standard_Unsigned, "unsigned"); 965 966 Set_Ekind (Standard_Unsigned, E_Modular_Integer_Type); 967 Set_Scope (Standard_Unsigned, Standard_Standard); 968 Set_Etype (Standard_Unsigned, Standard_Unsigned); 969 Init_Size (Standard_Unsigned, Standard_Integer_Size); 970 Set_Prim_Alignment (Standard_Unsigned); 971 Set_Modulus (Standard_Unsigned, 972 Uint_2 ** Standard_Integer_Size); 973 Set_Is_Unsigned_Type (Standard_Unsigned); 974 Set_Size_Known_At_Compile_Time 975 (Standard_Unsigned); 976 977 R_Node := New_Node (N_Range, Stloc); 978 Set_Low_Bound (R_Node, Make_Integer (Uint_0)); 979 Set_High_Bound (R_Node, Make_Integer (Modulus (Standard_Unsigned) - 1)); 980 Set_Etype (Low_Bound (R_Node), Standard_Unsigned); 981 Set_Etype (High_Bound (R_Node), Standard_Unsigned); 982 Set_Scalar_Range (Standard_Unsigned, R_Node); 983 984 -- Note: universal integer and universal real are constructed as fully 985 -- formed signed numeric types, with parameters corresponding to the 986 -- longest runtime types (Long_Long_Integer and Long_Long_Float). This 987 -- allows Gigi to properly process references to universal types that 988 -- are not folded at compile time. 989 990 Universal_Integer := New_Standard_Entity; 991 Decl := New_Node (N_Full_Type_Declaration, Stloc); 992 Set_Defining_Identifier (Decl, Universal_Integer); 993 Make_Name (Universal_Integer, "universal_integer"); 994 Set_Scope (Universal_Integer, Standard_Standard); 995 Build_Signed_Integer_Type 996 (Universal_Integer, Standard_Long_Long_Integer_Size); 997 998 Universal_Real := New_Standard_Entity; 999 Decl := New_Node (N_Full_Type_Declaration, Stloc); 1000 Set_Defining_Identifier (Decl, Universal_Real); 1001 Make_Name (Universal_Real, "universal_real"); 1002 Set_Scope (Universal_Real, Standard_Standard); 1003 Build_Float_Type 1004 (Universal_Real, 1005 Standard_Long_Long_Float_Size, 1006 Standard_Long_Long_Float_Digits); 1007 1008 -- Note: universal fixed, unlike universal integer and universal real, 1009 -- is never used at runtime, so it does not need to have bounds set. 1010 1011 Universal_Fixed := New_Standard_Entity; 1012 Decl := New_Node (N_Full_Type_Declaration, Stloc); 1013 Set_Defining_Identifier (Decl, Universal_Fixed); 1014 Make_Name (Universal_Fixed, "universal_fixed"); 1015 Set_Ekind (Universal_Fixed, E_Ordinary_Fixed_Point_Type); 1016 Set_Etype (Universal_Fixed, Universal_Fixed); 1017 Set_Scope (Universal_Fixed, Standard_Standard); 1018 Init_Size (Universal_Fixed, Standard_Long_Long_Integer_Size); 1019 Set_Prim_Alignment (Universal_Fixed); 1020 Set_Size_Known_At_Compile_Time 1021 (Universal_Fixed); 1022 1023 -- Create type declaration for Duration, using a 64-bit size. The 1024 -- delta and size values depend on the mode set in system.ads. 1025 1026 Build_Duration : declare 1027 Dlo : Uint; 1028 Dhi : Uint; 1029 Delta_Val : Ureal; 1030 1031 begin 1032 -- In 32 bit mode, the size is 32 bits, and the delta and 1033 -- small values are set to 20 milliseconds (20.0**(10.0**(-3)). 1034 1035 if Duration_32_Bits_On_Target then 1036 Dlo := Intval (Type_Low_Bound (Standard_Integer_32)); 1037 Dhi := Intval (Type_High_Bound (Standard_Integer_32)); 1038 Delta_Val := UR_From_Components (UI_From_Int (20), Uint_3, 10); 1039 1040 -- In standard 64-bit mode, the size is 64-bits and the delta and 1041 -- amll values are set to nanoseconds (1.0**(10.0**(-9)) 1042 1043 else 1044 Dlo := Intval (Type_Low_Bound (Standard_Integer_64)); 1045 Dhi := Intval (Type_High_Bound (Standard_Integer_64)); 1046 Delta_Val := UR_From_Components (Uint_1, Uint_9, 10); 1047 end if; 1048 1049 Tdef_Node := Make_Ordinary_Fixed_Point_Definition (Stloc, 1050 Delta_Expression => Make_Real_Literal (Stloc, Delta_Val), 1051 Real_Range_Specification => 1052 Make_Real_Range_Specification (Stloc, 1053 Low_Bound => Make_Real_Literal (Stloc, 1054 Realval => Dlo * Delta_Val), 1055 High_Bound => Make_Real_Literal (Stloc, 1056 Realval => Dhi * Delta_Val))); 1057 1058 Set_Type_Definition (Parent (Standard_Duration), Tdef_Node); 1059 1060 Set_Ekind (Standard_Duration, E_Ordinary_Fixed_Point_Type); 1061 Set_Etype (Standard_Duration, Standard_Duration); 1062 1063 if Duration_32_Bits_On_Target then 1064 Init_Size (Standard_Duration, 32); 1065 else 1066 Init_Size (Standard_Duration, 64); 1067 end if; 1068 1069 Set_Prim_Alignment (Standard_Duration); 1070 Set_Delta_Value (Standard_Duration, Delta_Val); 1071 Set_Small_Value (Standard_Duration, Delta_Val); 1072 Set_Scalar_Range (Standard_Duration, 1073 Real_Range_Specification 1074 (Type_Definition (Parent (Standard_Duration)))); 1075 1076 -- Normally it does not matter that nodes in package Standard are 1077 -- not marked as analyzed. The Scalar_Range of the fixed-point 1078 -- type Standard_Duration is an exception, because of the special 1079 -- test made in Freeze.Freeze_Fixed_Point_Type. 1080 1081 Set_Analyzed (Scalar_Range (Standard_Duration)); 1082 1083 Set_Etype (Type_High_Bound (Standard_Duration), Standard_Duration); 1084 Set_Etype (Type_Low_Bound (Standard_Duration), Standard_Duration); 1085 1086 Set_Is_Static_Expression (Type_High_Bound (Standard_Duration)); 1087 Set_Is_Static_Expression (Type_Low_Bound (Standard_Duration)); 1088 1089 Set_Corresponding_Integer_Value 1090 (Type_High_Bound (Standard_Duration), Dhi); 1091 1092 Set_Corresponding_Integer_Value 1093 (Type_Low_Bound (Standard_Duration), Dlo); 1094 1095 Set_Size_Known_At_Compile_Time (Standard_Duration); 1096 end Build_Duration; 1097 1098 -- Build standard exception type. Note that the type name here is 1099 -- actually used in the generated code, so it must be set correctly 1100 1101 Standard_Exception_Type := New_Standard_Entity; 1102 Set_Ekind (Standard_Exception_Type, E_Record_Type); 1103 Set_Etype (Standard_Exception_Type, Standard_Exception_Type); 1104 Set_Scope (Standard_Exception_Type, Standard_Standard); 1105 Set_Stored_Constraint 1106 (Standard_Exception_Type, No_Elist); 1107 Init_Size_Align (Standard_Exception_Type); 1108 Set_Size_Known_At_Compile_Time 1109 (Standard_Exception_Type, True); 1110 Make_Name (Standard_Exception_Type, "exception"); 1111 1112 Make_Component (Standard_Exception_Type, Standard_Boolean, 1113 "Not_Handled_By_Others"); 1114 Make_Component (Standard_Exception_Type, Standard_Character, "Lang"); 1115 Make_Component (Standard_Exception_Type, Standard_Natural, 1116 "Name_Length"); 1117 Make_Component (Standard_Exception_Type, Standard_A_Char, 1118 "Full_Name"); 1119 Make_Component (Standard_Exception_Type, Standard_A_Char, 1120 "HTable_Ptr"); 1121 Make_Component (Standard_Exception_Type, Standard_Integer, 1122 "Import_Code"); 1123 Make_Component (Standard_Exception_Type, Standard_A_Char, 1124 "Raise_Hook"); 1125 -- Build tree for record declaration, for use by the back-end. 1126 1127 declare 1128 Comp_List : List_Id; 1129 Comp : Entity_Id; 1130 1131 begin 1132 Comp := First_Entity (Standard_Exception_Type); 1133 Comp_List := New_List; 1134 1135 while Present (Comp) loop 1136 Append ( 1137 Make_Component_Declaration (Stloc, 1138 Defining_Identifier => Comp, 1139 Component_Definition => 1140 Make_Component_Definition (Stloc, 1141 Aliased_Present => False, 1142 Subtype_Indication => New_Occurrence_Of (Etype (Comp), 1143 Stloc))), 1144 Comp_List); 1145 1146 Next_Entity (Comp); 1147 end loop; 1148 1149 Decl := Make_Full_Type_Declaration (Stloc, 1150 Defining_Identifier => Standard_Exception_Type, 1151 Type_Definition => 1152 Make_Record_Definition (Stloc, 1153 End_Label => Empty, 1154 Component_List => 1155 Make_Component_List (Stloc, 1156 Component_Items => Comp_List))); 1157 end; 1158 1159 Append (Decl, Decl_S); 1160 1161 Layout_Type (Standard_Exception_Type); 1162 1163 -- Create declarations of standard exceptions 1164 1165 Build_Exception (S_Constraint_Error); 1166 Build_Exception (S_Program_Error); 1167 Build_Exception (S_Storage_Error); 1168 Build_Exception (S_Tasking_Error); 1169 1170 -- Numeric_Error is a normal exception in Ada 83, but in Ada 95 1171 -- it is a renaming of Constraint_Error 1172 1173 if Ada_83 then 1174 Build_Exception (S_Numeric_Error); 1175 1176 else 1177 Decl := New_Node (N_Exception_Renaming_Declaration, Stloc); 1178 E_Id := Standard_Entity (S_Numeric_Error); 1179 1180 Set_Ekind (E_Id, E_Exception); 1181 Set_Exception_Code (E_Id, Uint_0); 1182 Set_Etype (E_Id, Standard_Exception_Type); 1183 Set_Is_Public (E_Id); 1184 Set_Renamed_Entity (E_Id, Standard_Entity (S_Constraint_Error)); 1185 1186 Set_Defining_Identifier (Decl, E_Id); 1187 Append (Decl, Decl_S); 1188 1189 Ident_Node := New_Node (N_Identifier, Stloc); 1190 Set_Chars (Ident_Node, Chars (Standard_Entity (S_Constraint_Error))); 1191 Set_Entity (Ident_Node, Standard_Entity (S_Constraint_Error)); 1192 Set_Name (Decl, Ident_Node); 1193 end if; 1194 1195 -- Abort_Signal is an entity that does not get made visible 1196 1197 Abort_Signal := New_Standard_Entity; 1198 Set_Chars (Abort_Signal, Name_uAbort_Signal); 1199 Set_Ekind (Abort_Signal, E_Exception); 1200 Set_Exception_Code (Abort_Signal, Uint_0); 1201 Set_Etype (Abort_Signal, Standard_Exception_Type); 1202 Set_Scope (Abort_Signal, Standard_Standard); 1203 Set_Is_Public (Abort_Signal, True); 1204 Decl := 1205 Make_Exception_Declaration (Stloc, 1206 Defining_Identifier => Abort_Signal); 1207 1208 -- Create defining identifiers for shift operator entities. Note 1209 -- that these entities are used only for marking shift operators 1210 -- generated internally, and hence need no structure, just a name 1211 -- and a unique identity. 1212 1213 Standard_Op_Rotate_Left := New_Standard_Entity; 1214 Set_Chars (Standard_Op_Rotate_Left, Name_Rotate_Left); 1215 Set_Ekind (Standard_Op_Rotate_Left, E_Operator); 1216 1217 Standard_Op_Rotate_Right := New_Standard_Entity; 1218 Set_Chars (Standard_Op_Rotate_Right, Name_Rotate_Right); 1219 Set_Ekind (Standard_Op_Rotate_Right, E_Operator); 1220 1221 Standard_Op_Shift_Left := New_Standard_Entity; 1222 Set_Chars (Standard_Op_Shift_Left, Name_Shift_Left); 1223 Set_Ekind (Standard_Op_Shift_Left, E_Operator); 1224 1225 Standard_Op_Shift_Right := New_Standard_Entity; 1226 Set_Chars (Standard_Op_Shift_Right, Name_Shift_Right); 1227 Set_Ekind (Standard_Op_Shift_Right, E_Operator); 1228 1229 Standard_Op_Shift_Right_Arithmetic := New_Standard_Entity; 1230 Set_Chars (Standard_Op_Shift_Right_Arithmetic, 1231 Name_Shift_Right_Arithmetic); 1232 Set_Ekind (Standard_Op_Shift_Right_Arithmetic, 1233 E_Operator); 1234 1235 -- Create standard operator declarations 1236 1237 Create_Operators; 1238 1239 -- Initialize visibility table with entities in Standard 1240 1241 for E in Standard_Entity_Type loop 1242 if Ekind (Standard_Entity (E)) /= E_Operator then 1243 Set_Name_Entity_Id 1244 (Chars (Standard_Entity (E)), Standard_Entity (E)); 1245 Set_Homonym (Standard_Entity (E), Empty); 1246 end if; 1247 1248 if E not in S_ASCII_Names then 1249 Set_Scope (Standard_Entity (E), Standard_Standard); 1250 Set_Is_Immediately_Visible (Standard_Entity (E)); 1251 end if; 1252 end loop; 1253 1254 -- The predefined package Standard itself does not have a scope; 1255 -- it is the only entity in the system not to have one, and this 1256 -- is what identifies the package to Gigi. 1257 1258 Set_Scope (Standard_Standard, Empty); 1259 1260 -- Set global variables indicating last Id values and version 1261 1262 Last_Standard_Node_Id := Last_Node_Id; 1263 Last_Standard_List_Id := Last_List_Id; 1264 1265 -- The Error node has an Etype of Any_Type to help error recovery 1266 1267 Set_Etype (Error, Any_Type); 1268 1269 -- Print representation of standard if switch set 1270 1271 if Opt.Print_Standard then 1272 Print_Standard; 1273 end if; 1274 end Create_Standard; 1275 1276 ------------------------------------ 1277 -- Create_Unconstrained_Base_Type -- 1278 ------------------------------------ 1279 1280 procedure Create_Unconstrained_Base_Type 1281 (E : Entity_Id; 1282 K : Entity_Kind) 1283 is 1284 New_Ent : constant Entity_Id := New_Copy (E); 1285 1286 begin 1287 Set_Ekind (E, K); 1288 Set_Is_Constrained (E, True); 1289 Set_Is_First_Subtype (E, True); 1290 Set_Etype (E, New_Ent); 1291 1292 Append_Entity (New_Ent, Standard_Standard); 1293 Set_Is_Constrained (New_Ent, False); 1294 Set_Etype (New_Ent, New_Ent); 1295 Set_Is_Known_Valid (New_Ent, True); 1296 1297 if K = E_Signed_Integer_Subtype then 1298 Set_Etype (Low_Bound (Scalar_Range (E)), New_Ent); 1299 Set_Etype (High_Bound (Scalar_Range (E)), New_Ent); 1300 end if; 1301 1302 end Create_Unconstrained_Base_Type; 1303 1304 -------------------- 1305 -- Identifier_For -- 1306 -------------------- 1307 1308 function Identifier_For (S : Standard_Entity_Type) return Node_Id is 1309 Ident_Node : Node_Id; 1310 1311 begin 1312 Ident_Node := New_Node (N_Identifier, Stloc); 1313 Set_Chars (Ident_Node, Chars (Standard_Entity (S))); 1314 return Ident_Node; 1315 end Identifier_For; 1316 1317 -------------------- 1318 -- Make_Component -- 1319 -------------------- 1320 1321 procedure Make_Component 1322 (Rec : Entity_Id; 1323 Typ : Entity_Id; 1324 Nam : String) 1325 is 1326 Id : constant Entity_Id := New_Standard_Entity; 1327 1328 begin 1329 Set_Ekind (Id, E_Component); 1330 Set_Etype (Id, Typ); 1331 Set_Scope (Id, Rec); 1332 Init_Component_Location (Id); 1333 1334 Set_Original_Record_Component (Id, Id); 1335 Make_Name (Id, Nam); 1336 Append_Entity (Id, Rec); 1337 end Make_Component; 1338 1339 ----------------- 1340 -- Make_Formal -- 1341 ----------------- 1342 1343 function Make_Formal 1344 (Typ : Entity_Id; 1345 Formal_Name : String) return Entity_Id 1346 is 1347 Formal : Entity_Id; 1348 1349 begin 1350 Formal := New_Standard_Entity; 1351 1352 Set_Ekind (Formal, E_In_Parameter); 1353 Set_Mechanism (Formal, Default_Mechanism); 1354 Set_Scope (Formal, Standard_Standard); 1355 Set_Etype (Formal, Typ); 1356 Make_Name (Formal, Formal_Name); 1357 1358 return Formal; 1359 end Make_Formal; 1360 1361 ------------------ 1362 -- Make_Integer -- 1363 ------------------ 1364 1365 function Make_Integer (V : Uint) return Node_Id is 1366 N : constant Node_Id := Make_Integer_Literal (Stloc, V); 1367 begin 1368 Set_Is_Static_Expression (N); 1369 return N; 1370 end Make_Integer; 1371 1372 --------------- 1373 -- Make_Name -- 1374 --------------- 1375 1376 procedure Make_Name (Id : Entity_Id; Nam : String) is 1377 begin 1378 for J in 1 .. Nam'Length loop 1379 Name_Buffer (J) := Fold_Lower (Nam (Nam'First + (J - 1))); 1380 end loop; 1381 1382 Name_Len := Nam'Length; 1383 Set_Chars (Id, Name_Find); 1384 end Make_Name; 1385 1386 ------------------ 1387 -- New_Operator -- 1388 ------------------ 1389 1390 function New_Operator (Op : Name_Id; Typ : Entity_Id) return Entity_Id is 1391 Ident_Node : Entity_Id; 1392 1393 begin 1394 Ident_Node := Make_Defining_Identifier (Stloc, Op); 1395 1396 Set_Is_Pure (Ident_Node, True); 1397 Set_Ekind (Ident_Node, E_Operator); 1398 Set_Etype (Ident_Node, Typ); 1399 Set_Scope (Ident_Node, Standard_Standard); 1400 Set_Homonym (Ident_Node, Get_Name_Entity_Id (Op)); 1401 Set_Convention (Ident_Node, Convention_Intrinsic); 1402 1403 Set_Is_Immediately_Visible (Ident_Node, True); 1404 Set_Is_Intrinsic_Subprogram (Ident_Node, True); 1405 1406 Set_Name_Entity_Id (Op, Ident_Node); 1407 Append_Entity (Ident_Node, Standard_Standard); 1408 return Ident_Node; 1409 end New_Operator; 1410 1411 ------------------------- 1412 -- New_Standard_Entity -- 1413 ------------------------- 1414 1415 function New_Standard_Entity 1416 (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id 1417 is 1418 E : constant Entity_Id := New_Entity (New_Node_Kind, Stloc); 1419 1420 begin 1421 -- All standard entities are Pure and Public 1422 1423 Set_Is_Pure (E); 1424 Set_Is_Public (E); 1425 1426 -- All standard entity names are analyzed manually, and are thus 1427 -- frozen as soon as they are created. 1428 1429 Set_Is_Frozen (E); 1430 1431 -- Set debug information required for all standard types 1432 1433 Set_Needs_Debug_Info (E); 1434 1435 -- All standard entities are built with fully qualified names, so 1436 -- set the flag to prevent an abortive attempt at requalification! 1437 1438 Set_Has_Qualified_Name (E); 1439 1440 -- Return newly created entity to be completed by caller 1441 1442 return E; 1443 end New_Standard_Entity; 1444 1445 -------------------- 1446 -- Print_Standard -- 1447 -------------------- 1448 1449 procedure Print_Standard is 1450 1451 procedure P (Item : String) renames Output.Write_Line; 1452 -- Short-hand, since we do a lot of line writes here! 1453 1454 procedure P_Int_Range (Size : Pos); 1455 -- Prints the range of an integer based on its Size 1456 1457 procedure P_Float_Range (Id : Entity_Id); 1458 -- Prints the bounds range for the given float type entity 1459 1460 ------------------- 1461 -- P_Float_Range -- 1462 ------------------- 1463 1464 procedure P_Float_Range (Id : Entity_Id) is 1465 Digs : constant Nat := UI_To_Int (Digits_Value (Id)); 1466 1467 begin 1468 Write_Str (" range "); 1469 1470 if Vax_Float (Id) then 1471 if Digs = VAXFF_Digits then 1472 Write_Str (VAXFF_First'Universal_Literal_String); 1473 Write_Str (" .. "); 1474 Write_Str (VAXFF_Last'Universal_Literal_String); 1475 1476 elsif Digs = VAXDF_Digits then 1477 Write_Str (VAXDF_First'Universal_Literal_String); 1478 Write_Str (" .. "); 1479 Write_Str (VAXDF_Last'Universal_Literal_String); 1480 1481 else 1482 pragma Assert (Digs = VAXGF_Digits); 1483 1484 Write_Str (VAXGF_First'Universal_Literal_String); 1485 Write_Str (" .. "); 1486 Write_Str (VAXGF_Last'Universal_Literal_String); 1487 end if; 1488 1489 elsif Is_AAMP_Float (Id) then 1490 if Digs = AAMPS_Digits then 1491 Write_Str (AAMPS_First'Universal_Literal_String); 1492 Write_Str (" .. "); 1493 Write_Str (AAMPS_Last'Universal_Literal_String); 1494 1495 else 1496 pragma Assert (Digs = AAMPL_Digits); 1497 Write_Str (AAMPL_First'Universal_Literal_String); 1498 Write_Str (" .. "); 1499 Write_Str (AAMPL_Last'Universal_Literal_String); 1500 end if; 1501 1502 elsif Digs = IEEES_Digits then 1503 Write_Str (IEEES_First'Universal_Literal_String); 1504 Write_Str (" .. "); 1505 Write_Str (IEEES_Last'Universal_Literal_String); 1506 1507 1508 elsif Digs = IEEEL_Digits then 1509 Write_Str (IEEEL_First'Universal_Literal_String); 1510 Write_Str (" .. "); 1511 Write_Str (IEEEL_Last'Universal_Literal_String); 1512 1513 else 1514 pragma Assert (Digs = IEEEX_Digits); 1515 1516 Write_Str (IEEEX_First'Universal_Literal_String); 1517 Write_Str (" .. "); 1518 Write_Str (IEEEX_Last'Universal_Literal_String); 1519 end if; 1520 1521 Write_Str (";"); 1522 Write_Eol; 1523 end P_Float_Range; 1524 1525 ----------------- 1526 -- P_Int_Range -- 1527 ----------------- 1528 1529 procedure P_Int_Range (Size : Pos) is 1530 begin 1531 Write_Str (" is range -(2 **"); 1532 Write_Int (Size - 1); 1533 Write_Str (")"); 1534 Write_Str (" .. +(2 **"); 1535 Write_Int (Size - 1); 1536 Write_Str (" - 1);"); 1537 Write_Eol; 1538 end P_Int_Range; 1539 1540 -- Start of processing for Print_Standard 1541 1542 begin 1543 P ("-- Representation of package Standard"); 1544 Write_Eol; 1545 P ("-- This is not accurate Ada, since new base types cannot be "); 1546 P ("-- created, but the listing shows the target dependent"); 1547 P ("-- characteristics of the Standard types for this compiler"); 1548 Write_Eol; 1549 1550 P ("package Standard is"); 1551 P ("pragma Pure(Standard);"); 1552 Write_Eol; 1553 1554 P (" type Boolean is (False, True);"); 1555 P (" for Boolean'Size use 1;"); 1556 P (" for Boolean use (False => 0, True => 1);"); 1557 Write_Eol; 1558 1559 -- Integer types 1560 1561 Write_Str (" type Integer"); 1562 P_Int_Range (Standard_Integer_Size); 1563 Write_Str (" for Integer'Size use "); 1564 Write_Int (Standard_Integer_Size); 1565 P (";"); 1566 Write_Eol; 1567 1568 P (" subtype Natural is Integer range 0 .. Integer'Last;"); 1569 P (" subtype Positive is Integer range 1 .. Integer'Last;"); 1570 Write_Eol; 1571 1572 Write_Str (" type Short_Short_Integer"); 1573 P_Int_Range (Standard_Short_Short_Integer_Size); 1574 Write_Str (" for Short_Short_Integer'Size use "); 1575 Write_Int (Standard_Short_Short_Integer_Size); 1576 P (";"); 1577 Write_Eol; 1578 1579 Write_Str (" type Short_Integer"); 1580 P_Int_Range (Standard_Short_Integer_Size); 1581 Write_Str (" for Short_Integer'Size use "); 1582 Write_Int (Standard_Short_Integer_Size); 1583 P (";"); 1584 Write_Eol; 1585 1586 Write_Str (" type Long_Integer"); 1587 P_Int_Range (Standard_Long_Integer_Size); 1588 Write_Str (" for Long_Integer'Size use "); 1589 Write_Int (Standard_Long_Integer_Size); 1590 P (";"); 1591 Write_Eol; 1592 1593 Write_Str (" type Long_Long_Integer"); 1594 P_Int_Range (Standard_Long_Long_Integer_Size); 1595 Write_Str (" for Long_Long_Integer'Size use "); 1596 Write_Int (Standard_Long_Long_Integer_Size); 1597 P (";"); 1598 Write_Eol; 1599 1600 -- Floating point types 1601 1602 Write_Str (" type Short_Float is digits "); 1603 Write_Int (Standard_Short_Float_Digits); 1604 Write_Eol; 1605 P_Float_Range (Standard_Short_Float); 1606 Write_Str (" for Short_Float'Size use "); 1607 Write_Int (Standard_Short_Float_Size); 1608 P (";"); 1609 Write_Eol; 1610 1611 Write_Str (" type Float is digits "); 1612 Write_Int (Standard_Float_Digits); 1613 Write_Eol; 1614 P_Float_Range (Standard_Float); 1615 Write_Str (" for Float'Size use "); 1616 Write_Int (Standard_Float_Size); 1617 P (";"); 1618 Write_Eol; 1619 1620 Write_Str (" type Long_Float is digits "); 1621 Write_Int (Standard_Long_Float_Digits); 1622 Write_Eol; 1623 P_Float_Range (Standard_Long_Float); 1624 Write_Str (" for Long_Float'Size use "); 1625 Write_Int (Standard_Long_Float_Size); 1626 P (";"); 1627 Write_Eol; 1628 1629 Write_Str (" type Long_Long_Float is digits "); 1630 Write_Int (Standard_Long_Long_Float_Digits); 1631 Write_Eol; 1632 P_Float_Range (Standard_Long_Long_Float); 1633 Write_Str (" for Long_Long_Float'Size use "); 1634 Write_Int (Standard_Long_Long_Float_Size); 1635 P (";"); 1636 Write_Eol; 1637 1638 P (" type Character is (...)"); 1639 Write_Str (" for Character'Size use "); 1640 Write_Int (Standard_Character_Size); 1641 P (";"); 1642 P (" -- See RM A.1(35) for details of this type"); 1643 Write_Eol; 1644 1645 P (" type Wide_Character is (...)"); 1646 Write_Str (" for Wide_Character'Size use "); 1647 Write_Int (Standard_Wide_Character_Size); 1648 P (";"); 1649 P (" -- See RM A.1(36) for details of this type"); 1650 Write_Eol; 1651 1652 P (" type String is array (Positive range <>) of Character;"); 1653 P (" pragma Pack (String);"); 1654 Write_Eol; 1655 1656 P (" type Wide_String is array (Positive range <>)" & 1657 " of Wide_Character;"); 1658 P (" pragma Pack (Wide_String);"); 1659 Write_Eol; 1660 1661 -- Here it's OK to use the Duration type of the host compiler since 1662 -- the implementation of Duration in GNAT is target independent. 1663 1664 if Duration_32_Bits_On_Target then 1665 P (" type Duration is delta 0.020"); 1666 P (" range -((2 ** 31 - 1) * 0.020) .."); 1667 P (" +((2 ** 31 - 1) * 0.020);"); 1668 P (" for Duration'Small use 0.020;"); 1669 else 1670 P (" type Duration is delta 0.000000001"); 1671 P (" range -((2 ** 63 - 1) * 0.000000001) .."); 1672 P (" +((2 ** 63 - 1) * 0.000000001);"); 1673 P (" for Duration'Small use 0.000000001;"); 1674 end if; 1675 1676 Write_Eol; 1677 1678 P (" Constraint_Error : exception;"); 1679 P (" Program_Error : exception;"); 1680 P (" Storage_Error : exception;"); 1681 P (" Tasking_Error : exception;"); 1682 P (" Numeric_Error : exception renames Constraint_Error;"); 1683 Write_Eol; 1684 1685 P ("end Standard;"); 1686 end Print_Standard; 1687 1688 ---------------------- 1689 -- Set_Float_Bounds -- 1690 ---------------------- 1691 1692 procedure Set_Float_Bounds (Id : Entity_Id) is 1693 L : Node_Id; 1694 -- Low bound of literal value 1695 1696 H : Node_Id; 1697 -- High bound of literal value 1698 1699 R : Node_Id; 1700 -- Range specification 1701 1702 Digs : constant Nat := UI_To_Int (Digits_Value (Id)); 1703 -- Digits value, used to select bounds 1704 1705 begin 1706 -- Note: for the call from Cstand to initially create the types in 1707 -- Standard, Vax_Float will always be False. Circuitry in Sem_Vfpt 1708 -- will adjust these types appropriately in the Vax_Float case if 1709 -- a pragma Float_Representation (VAX_Float) is used. 1710 1711 if Vax_Float (Id) then 1712 if Digs = VAXFF_Digits then 1713 L := Real_Convert 1714 (VAXFF_First'Universal_Literal_String); 1715 H := Real_Convert 1716 (VAXFF_Last'Universal_Literal_String); 1717 1718 elsif Digs = VAXDF_Digits then 1719 L := Real_Convert 1720 (VAXDF_First'Universal_Literal_String); 1721 H := Real_Convert 1722 (VAXDF_Last'Universal_Literal_String); 1723 1724 else 1725 pragma Assert (Digs = VAXGF_Digits); 1726 1727 L := Real_Convert 1728 (VAXGF_First'Universal_Literal_String); 1729 H := Real_Convert 1730 (VAXGF_Last'Universal_Literal_String); 1731 end if; 1732 1733 elsif Is_AAMP_Float (Id) then 1734 if Digs = AAMPS_Digits then 1735 L := Real_Convert 1736 (AAMPS_First'Universal_Literal_String); 1737 H := Real_Convert 1738 (AAMPS_Last'Universal_Literal_String); 1739 1740 else 1741 pragma Assert (Digs = AAMPL_Digits); 1742 L := Real_Convert 1743 (AAMPL_First'Universal_Literal_String); 1744 H := Real_Convert 1745 (AAMPL_Last'Universal_Literal_String); 1746 end if; 1747 1748 elsif Digs = IEEES_Digits then 1749 L := Real_Convert 1750 (IEEES_First'Universal_Literal_String); 1751 H := Real_Convert 1752 (IEEES_Last'Universal_Literal_String); 1753 1754 elsif Digs = IEEEL_Digits then 1755 L := Real_Convert 1756 (IEEEL_First'Universal_Literal_String); 1757 H := Real_Convert 1758 (IEEEL_Last'Universal_Literal_String); 1759 1760 else 1761 pragma Assert (Digs = IEEEX_Digits); 1762 1763 L := Real_Convert 1764 (IEEEX_First'Universal_Literal_String); 1765 H := Real_Convert 1766 (IEEEX_Last'Universal_Literal_String); 1767 end if; 1768 1769 Set_Etype (L, Id); 1770 Set_Is_Static_Expression (L); 1771 1772 Set_Etype (H, Id); 1773 Set_Is_Static_Expression (H); 1774 1775 R := New_Node (N_Range, Stloc); 1776 Set_Low_Bound (R, L); 1777 Set_High_Bound (R, H); 1778 Set_Includes_Infinities (R, True); 1779 Set_Scalar_Range (Id, R); 1780 Set_Etype (R, Id); 1781 Set_Parent (R, Id); 1782 end Set_Float_Bounds; 1783 1784 ------------------------ 1785 -- Set_Integer_Bounds -- 1786 ------------------------ 1787 1788 procedure Set_Integer_Bounds 1789 (Id : Entity_Id; 1790 Typ : Entity_Id; 1791 Lb : Uint; 1792 Hb : Uint) 1793 is 1794 L : Node_Id; -- Low bound of literal value 1795 H : Node_Id; -- High bound of literal value 1796 R : Node_Id; -- Range specification 1797 1798 begin 1799 L := Make_Integer (Lb); 1800 H := Make_Integer (Hb); 1801 1802 Set_Etype (L, Typ); 1803 Set_Etype (H, Typ); 1804 1805 R := New_Node (N_Range, Stloc); 1806 Set_Low_Bound (R, L); 1807 Set_High_Bound (R, H); 1808 Set_Scalar_Range (Id, R); 1809 Set_Etype (R, Typ); 1810 Set_Parent (R, Id); 1811 Set_Is_Unsigned_Type (Id, Lb >= 0); 1812 end Set_Integer_Bounds; 1813 1814end CStand; 1815