]>
Commit | Line | Data |
---|---|---|
38cbfe40 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
5 | -- I T Y P E S -- | |
6 | -- -- | |
7 | -- B o d y -- | |
8 | -- -- | |
8d0d46f4 | 9 | -- Copyright (C) 1992-2021, Free Software Foundation, Inc. -- |
38cbfe40 RK |
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- -- | |
b5c84c3c | 13 | -- ware Foundation; either version 3, or (at your option) any later ver- -- |
38cbfe40 RK |
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 -- | |
b5c84c3c RD |
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. -- | |
38cbfe40 RK |
20 | -- -- |
21 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 22 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
38cbfe40 RK |
23 | -- -- |
24 | ------------------------------------------------------------------------------ | |
25 | ||
76f9c7f4 | 26 | with Einfo.Utils; use Einfo.Utils; |
4b790886 | 27 | with Sem; use Sem; |
76f9c7f4 BD |
28 | with Sinfo; use Sinfo; |
29 | with Sinfo.Nodes; use Sinfo.Nodes; | |
4b790886 BD |
30 | with Stand; use Stand; |
31 | with Targparm; use Targparm; | |
99cf6c77 | 32 | with Uintp; use Uintp; |
38cbfe40 RK |
33 | |
34 | package body Itypes is | |
35 | ||
36 | ------------------ | |
37 | -- Create_Itype -- | |
38 | ------------------ | |
39 | ||
40 | function Create_Itype | |
41 | (Ekind : Entity_Kind; | |
42 | Related_Nod : Node_Id; | |
43 | Related_Id : Entity_Id := Empty; | |
44 | Suffix : Character := ' '; | |
2e5df295 | 45 | Suffix_Index : Int := 0; |
d26dc4b5 | 46 | Scope_Id : Entity_Id := Current_Scope) return Entity_Id |
38cbfe40 RK |
47 | is |
48 | Typ : Entity_Id; | |
49 | ||
50 | begin | |
99cf6c77 RD |
51 | -- Should comment setting of Public_Status here ??? |
52 | ||
38cbfe40 RK |
53 | if Related_Id = Empty then |
54 | Typ := New_Internal_Entity (Ekind, Scope_Id, Sloc (Related_Nod), 'T'); | |
55 | Set_Public_Status (Typ); | |
56 | ||
57 | else | |
99cf6c77 RD |
58 | Typ := |
59 | New_External_Entity | |
60 | (Ekind, Scope_Id, Sloc (Related_Nod), Related_Id, Suffix, | |
61 | Suffix_Index, 'T'); | |
38cbfe40 RK |
62 | end if; |
63 | ||
99cf6c77 RD |
64 | -- Make sure Esize (Typ) was properly initialized, it should be since |
65 | -- New_Internal_Entity/New_External_Entity call Init_Size_Align. | |
66 | ||
67 | pragma Assert (Esize (Typ) = Uint_0); | |
68 | ||
38cbfe40 RK |
69 | Set_Etype (Typ, Any_Type); |
70 | Set_Is_Itype (Typ); | |
71 | Set_Associated_Node_For_Itype (Typ, Related_Nod); | |
fbf5a39b | 72 | |
65f1ca2e | 73 | if In_Deleted_Code then |
fbf5a39b AC |
74 | Set_Is_Frozen (Typ); |
75 | end if; | |
76 | ||
0503c53a | 77 | if Ekind in Access_Subprogram_Kind then |
4b790886 BD |
78 | Set_Can_Use_Internal_Rep (Typ, not Always_Compatible_Rep_On_Target); |
79 | end if; | |
80 | ||
38cbfe40 RK |
81 | return Typ; |
82 | end Create_Itype; | |
83 | ||
ec53a6da JM |
84 | --------------------------------- |
85 | -- Create_Null_Excluding_Itype -- | |
86 | --------------------------------- | |
87 | ||
88 | function Create_Null_Excluding_Itype | |
89 | (T : Entity_Id; | |
90 | Related_Nod : Node_Id; | |
91 | Scope_Id : Entity_Id := Current_Scope) return Entity_Id | |
92 | is | |
93 | I_Typ : Entity_Id; | |
94 | ||
95 | begin | |
96 | pragma Assert (Is_Access_Type (T)); | |
97 | ||
98 | I_Typ := Create_Itype (Ekind => E_Access_Subtype, | |
99 | Related_Nod => Related_Nod, | |
100 | Scope_Id => Scope_Id); | |
101 | ||
d26dc4b5 | 102 | Set_Directly_Designated_Type (I_Typ, Directly_Designated_Type (T)); |
b66c3ff4 | 103 | Set_Etype (I_Typ, Base_Type (T)); |
d26dc4b5 | 104 | Set_Depends_On_Private (I_Typ, Depends_On_Private (T)); |
bfc8aa81 | 105 | Set_Is_Public (I_Typ, Is_Public (T)); |
7b56a91b | 106 | Set_From_Limited_With (I_Typ, From_Limited_With (T)); |
d26dc4b5 | 107 | Set_Is_Access_Constant (I_Typ, Is_Access_Constant (T)); |
bfc8aa81 RD |
108 | Set_Is_Generic_Type (I_Typ, Is_Generic_Type (T)); |
109 | Set_Is_Volatile (I_Typ, Is_Volatile (T)); | |
110 | Set_Treat_As_Volatile (I_Typ, Treat_As_Volatile (T)); | |
111 | Set_Is_Atomic (I_Typ, Is_Atomic (T)); | |
112 | Set_Is_Ada_2005_Only (I_Typ, Is_Ada_2005_Only (T)); | |
599a7411 | 113 | Set_Is_Ada_2012_Only (I_Typ, Is_Ada_2012_Only (T)); |
d26dc4b5 | 114 | Set_Can_Never_Be_Null (I_Typ); |
ec53a6da JM |
115 | |
116 | return I_Typ; | |
117 | end Create_Null_Excluding_Itype; | |
118 | ||
38cbfe40 | 119 | end Itypes; |