1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2009-2021, Free Software Foundation, Inc. --
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. --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 ------------------------------------------------------------------------------
26 with Einfo
; use Einfo
;
27 with Einfo
.Entities
; use Einfo
.Entities
;
28 with Einfo
.Utils
; use Einfo
.Utils
;
29 with Nlists
; use Nlists
;
30 with Rtsfind
; use Rtsfind
;
31 with Sem_Aux
; use Sem_Aux
;
32 with Sinfo
; use Sinfo
;
33 with Sinfo
.Nodes
; use Sinfo
.Nodes
;
34 with Stand
; use Stand
;
35 with SCIL_LL
; use SCIL_LL
;
37 package body Sem_SCIL
is
43 function Check_SCIL_Node
(N
: Node_Id
) return Traverse_Result
is
44 SCIL_Node
: constant Node_Id
:= Get_SCIL_Node
(N
);
49 -- For nodes that do not have SCIL node continue traversing the tree
51 if No
(SCIL_Node
) then
55 case Nkind
(SCIL_Node
) is
56 when N_SCIL_Dispatch_Table_Tag_Init
=>
57 pragma Assert
(Nkind
(N
) = N_Object_Declaration
);
60 when N_SCIL_Dispatching_Call
=>
61 Ctrl_Tag
:= SCIL_Controlling_Tag
(SCIL_Node
);
63 -- Parent of SCIL dispatching call nodes MUST be a subprogram call
65 if Nkind
(N
) not in N_Subprogram_Call
then
68 -- In simple cases the controlling tag is the tag of the
69 -- controlling argument (i.e. Obj.Tag).
71 elsif Nkind
(Ctrl_Tag
) = N_Selected_Component
then
72 Ctrl_Typ
:= Etype
(Ctrl_Tag
);
74 -- Interface types are unsupported
76 if Is_Interface
(Ctrl_Typ
)
77 or else Is_RTE
(Ctrl_Typ
, RE_Interface_Tag
)
82 pragma Assert
(Is_RTE
(Ctrl_Typ
, RE_Tag
));
86 -- When the controlling tag of a dispatching call is an identifier
87 -- the SCIL_Controlling_Tag attribute references the corresponding
88 -- object or parameter declaration. Interface types are still
91 elsif Nkind
(Ctrl_Tag
) in
92 N_Object_Declaration | N_Parameter_Specification
94 Ctrl_Typ
:= Etype
(Defining_Identifier
(Ctrl_Tag
));
96 -- Interface types are unsupported.
98 if Is_Interface
(Ctrl_Typ
)
99 or else Is_RTE
(Ctrl_Typ
, RE_Interface_Tag
)
100 or else (Is_Access_Type
(Ctrl_Typ
)
104 (Base_Type
(Designated_Type
(Ctrl_Typ
)))))
110 (Is_RTE
(Ctrl_Typ
, RE_Tag
)
112 (Is_Access_Type
(Ctrl_Typ
)
116 (Base_Type
(Designated_Type
(Ctrl_Typ
))),
121 -- Interface types are unsupported
123 elsif Is_Interface
(Etype
(Ctrl_Tag
)) then
127 pragma Assert
(False);
133 when N_SCIL_Membership_Test
=>
135 -- Check contents of the boolean expression associated with the
140 N_Identifier | N_And_Then | N_Or_Else |
141 N_Expression_With_Actions | N_Function_Call
142 and then Etype
(N
) = Standard_Boolean
);
144 -- Check the entity identifier of the associated tagged type (that
145 -- is, in testing for membership in T'Class, the entity id of the
148 -- Note: When the SCIL node is generated the private and full-view
149 -- of the tagged types may have been swapped and hence the node
150 -- referenced by attribute SCIL_Entity may be the private view.
151 -- Therefore, in order to uniformly locate the full-view we use
152 -- attribute Underlying_Type.
155 (Is_Tagged_Type
(Underlying_Type
(SCIL_Entity
(SCIL_Node
))));
157 -- Interface types are unsupported
160 (not Is_Interface
(Underlying_Type
(SCIL_Entity
(SCIL_Node
))));
162 -- Check the decoration of the expression that denotes the tag
163 -- value being tested
165 Ctrl_Tag
:= SCIL_Tag_Value
(SCIL_Node
);
167 case Nkind
(Ctrl_Tag
) is
169 -- For class-wide membership tests the SCIL tag value is the
170 -- tag of the tested object (i.e. Obj.Tag).
172 when N_Selected_Component
=>
173 pragma Assert
(Is_RTE
(Etype
(Ctrl_Tag
), RE_Tag
));
177 pragma Assert
(False);
184 pragma Assert
(False);
191 -------------------------
192 -- First_Non_SCIL_Node --
193 -------------------------
195 function First_Non_SCIL_Node
(L
: List_Id
) return Node_Id
is
200 while Nkind
(N
) in N_SCIL_Node
loop
205 end First_Non_SCIL_Node
;
207 ------------------------
208 -- Next_Non_SCIL_Node --
209 ------------------------
211 function Next_Non_SCIL_Node
(N
: Node_Id
) return Node_Id
is
216 while Nkind
(Aux_N
) in N_SCIL_Node
loop
221 end Next_Non_SCIL_Node
;