OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [sem_scil.adb] - Blame information for rev 848

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                             S E M _ S C I L                              --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 2009-2010, 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
with Einfo;   use Einfo;
27
with Nlists;  use Nlists;
28
with Rtsfind; use Rtsfind;
29
with Sem_Aux; use Sem_Aux;
30
with Sinfo;   use Sinfo;
31
with Stand;   use Stand;
32
with SCIL_LL; use SCIL_LL;
33
 
34
package body Sem_SCIL is
35
 
36
   ---------------------
37
   -- Check_SCIL_Node --
38
   ---------------------
39
 
40
   function Check_SCIL_Node (N : Node_Id) return Traverse_Result is
41
      SCIL_Node : constant Node_Id := Get_SCIL_Node (N);
42
      Ctrl_Tag  : Node_Id;
43
      Ctrl_Typ  : Entity_Id;
44
 
45
   begin
46
      --  For nodes that do not have SCIL node continue traversing the tree
47
 
48
      if No (SCIL_Node) then
49
         return OK;
50
      end if;
51
 
52
      case Nkind (SCIL_Node) is
53
         when N_SCIL_Dispatch_Table_Tag_Init =>
54
            pragma Assert (Nkind (N) = N_Object_Declaration);
55
            null;
56
 
57
         when N_SCIL_Dispatching_Call =>
58
            Ctrl_Tag := SCIL_Controlling_Tag (SCIL_Node);
59
 
60
            --  Parent of SCIL dispatching call nodes MUST be a subprogram call
61
 
62
            if not Nkind_In (N, N_Function_Call,
63
                                N_Procedure_Call_Statement)
64
            then
65
               pragma Assert (False);
66
               raise Program_Error;
67
 
68
            --  In simple cases the controlling tag is the tag of the
69
            --  controlling argument (i.e. Obj.Tag).
70
 
71
            elsif Nkind (Ctrl_Tag) = N_Selected_Component then
72
               Ctrl_Typ := Etype (Ctrl_Tag);
73
 
74
               --  Interface types are unsupported
75
 
76
               if Is_Interface (Ctrl_Typ)
77
                 or else (RTE_Available (RE_Interface_Tag)
78
                            and then Ctrl_Typ = RTE (RE_Interface_Tag))
79
               then
80
                  null;
81
 
82
               else
83
                  pragma Assert (Ctrl_Typ = RTE (RE_Tag));
84
                  null;
85
               end if;
86
 
87
            --  When the controlling tag of a dispatching call is an identifier
88
            --  the SCIL_Controlling_Tag attribute references the corresponding
89
            --  object or parameter declaration. Interface types are still
90
            --  unsupported.
91
 
92
            elsif Nkind_In (Ctrl_Tag, N_Object_Declaration,
93
                                      N_Parameter_Specification)
94
            then
95
               Ctrl_Typ := Etype (Defining_Identifier (Ctrl_Tag));
96
 
97
               --  Interface types are unsupported.
98
 
99
               if Is_Interface (Ctrl_Typ)
100
                 or else (RTE_Available (RE_Interface_Tag)
101
                           and then Ctrl_Typ = RTE (RE_Interface_Tag))
102
                 or else (Is_Access_Type (Ctrl_Typ)
103
                           and then
104
                             Is_Interface
105
                               (Available_View
106
                                 (Base_Type (Designated_Type (Ctrl_Typ)))))
107
               then
108
                  null;
109
 
110
               else
111
                  pragma Assert
112
                    (Ctrl_Typ = RTE (RE_Tag)
113
                       or else
114
                         (Is_Access_Type (Ctrl_Typ)
115
                           and then Available_View
116
                                      (Base_Type (Designated_Type (Ctrl_Typ)))
117
                                        = RTE (RE_Tag)));
118
                  null;
119
               end if;
120
 
121
            --  Interface types are unsupported
122
 
123
            elsif Is_Interface (Etype (Ctrl_Tag)) then
124
               null;
125
 
126
            else
127
               pragma Assert (False);
128
               raise Program_Error;
129
            end if;
130
 
131
            return Skip;
132
 
133
         when N_SCIL_Membership_Test =>
134
 
135
            --  Check contents of the boolean expression associated with the
136
            --  membership test.
137
 
138
            pragma Assert (Nkind_In (N, N_Identifier,
139
                                        N_And_Then,
140
                                        N_Or_Else,
141
                                        N_Expression_With_Actions)
142
              and then Etype (N) = Standard_Boolean);
143
 
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
146
            --  specific type T).
147
 
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.
153
 
154
            pragma Assert
155
              (Is_Tagged_Type (Underlying_Type (SCIL_Entity (SCIL_Node))));
156
 
157
            --  Interface types are unsupported
158
 
159
            pragma Assert
160
              (not Is_Interface (Underlying_Type (SCIL_Entity (SCIL_Node))));
161
 
162
            --  Check the decoration of the expression that denotes the tag
163
            --  value being tested
164
 
165
            Ctrl_Tag := SCIL_Tag_Value (SCIL_Node);
166
 
167
            case Nkind (Ctrl_Tag) is
168
 
169
               --  For class-wide membership tests the SCIL tag value is the
170
               --  tag of the tested object (i.e. Obj.Tag).
171
 
172
               when N_Selected_Component =>
173
                  pragma Assert (Etype (Ctrl_Tag) = RTE (RE_Tag));
174
                  null;
175
 
176
               when others =>
177
                  pragma Assert (False);
178
                  null;
179
            end case;
180
 
181
            return Skip;
182
 
183
         when others =>
184
            pragma Assert (False);
185
            raise Program_Error;
186
      end case;
187
 
188
      return Skip;
189
   end Check_SCIL_Node;
190
 
191
   -------------------------
192
   -- First_Non_SCIL_Node --
193
   -------------------------
194
 
195
   function First_Non_SCIL_Node (L : List_Id) return Node_Id is
196
      N : Node_Id;
197
 
198
   begin
199
      N := First (L);
200
      while Nkind (N) in N_SCIL_Node loop
201
         Next (N);
202
      end loop;
203
 
204
      return N;
205
   end First_Non_SCIL_Node;
206
 
207
   ------------------------
208
   -- Next_Non_SCIL_Node --
209
   ------------------------
210
 
211
   function Next_Non_SCIL_Node (N : Node_Id) return Node_Id is
212
      Aux_N : Node_Id;
213
 
214
   begin
215
      Aux_N := Next (N);
216
      while Nkind (Aux_N) in N_SCIL_Node loop
217
         Next (Aux_N);
218
      end loop;
219
 
220
      return Aux_N;
221
   end Next_Non_SCIL_Node;
222
 
223
end Sem_SCIL;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.