1-------------------------------------------------------------------------------
2--
3--  This unit is part of the @Asis2@ ASIS secondary library.
4--
5--  <STRONG>Copyright (c) 2003 by Thomas Wolf.</STRONG>
6--  <BLOCKQUOTE>
7--    AdaBrowse is free software; you can redistribute it and/or modify it
8--    under the terms of the  GNU General Public License as published by the
9--    Free Software  Foundation; either version 2, or (at your option) any
10--    later version. AdaBrowse is distributed in the hope that it will be
11--    useful, but <EM>without any warranty</EM>; without even the implied
12--    warranty of <EM>merchantability or fitness for a particular purpose.</EM>
13--    See the GNU General Public License for  more details. You should have
14--    received a copy of the GNU General Public License with this distribution,
15--    see file "<A HREF="GPL.txt">GPL.txt</A>". If not, write to the Free
16--    Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17--    USA.
18--  </BLOCKQUOTE>
19--  <BLOCKQUOTE>
20--    As a special exception from the GPL, if other files instantiate generics
21--    from this unit, or you link this unit with other files to produce an
22--    executable, this unit does not by itself cause the resulting executable
23--    to be covered by the GPL. This exception does not however invalidate any
24--    other reasons why the executable file might be covered by the GPL.
25--  </BLOCKQUOTE>
26--
27--  <AUTHOR>
28--     Thomas Wolf  (TW) <E_MAIL>
29--  </AUTHOR>
30--
31--  <PURPOSE>
32--    Useful predicates on @Asis.Element@. All predicates return @False@ if
33--    called with inappropriate element kinds.
34--
35--    Whereever the following descriptions specify "a declaration of", this
36--    also allows "a defining name in a declaration of".
37--
38--    Wherever the following descriptions specify "a declaration of a type" or
39--    " a type declaration", this also allows "a type definition" of such a
40--    type.
41--
42--    Mentions of "type" include generic formal types, "variable" includes
43--    generic formal "in out" objects, and so on.
44--
45--    If @Element@ is an @Expression@, the predicates on types are also
46--    applicable, they refer to the type of the expression. If the @Expression@
47--    is a name (identifier, operator, enumeration literal, or selected
48--    component), they refer to the referenced defining name.
49--  </PURPOSE>
50--
51--  <HISTORY>
52--   05-JUN-2003   TW  Initial version.
53--   08-JUL-2003   TW  Added 'Is_Package'; changed 'Unique_Name' to really
54--                     return the fully qualified name.
55--   18-JUL-2003   TW  Removed the string operations, put into the @Asis2@
56--                     library, changed the license.
57--  </HISTORY>
58-------------------------------------------------------------------------------
59
60pragma License (Modified_GPL);
61
62with Asis;
63
64package Asis2.Predicates is
65
66   pragma Elaborate_Body;
67
68   ----------------------------------------------------------------------------
69   --  Units
70
71   function Is_Private
72     (Element : in Asis.Element)
73     return Boolean;
74   --  Returns @True@ if @Element@ is a declaration occurring in the private
75   --  part of a (generic) package declaration, task or protected type
76   --  declaration, or a single task or protected object declaration. Also
77   --  returns @True@ if <CODE>Is_Unit (Element)</CODE> and it is a private
78   --  library unit.
79
80   function Is_Separate
81     (Element : in Asis.Element)
82     return Boolean;
83   --  Returns @True@ for separate body declarations and stubs.
84
85   function Is_Unit
86     (Element : in Asis.Element)
87     return Boolean;
88   --  Returns @True@ if @Element@ is the declaration of a compilation unit
89   --  (spec or body).
90
91   function Is_Child
92     (Element : in Asis.Element)
93     return Boolean;
94   --  Returns @True@ if <CODE>Is_Unit (Element)</CODE> and it is not a
95   --  root library unit.
96
97   ----------------------------------------------------------------------------
98   --  Items
99
100   function Is_Package
101     (Element : in Asis.Element)
102     return Boolean;
103   --  Returns @True@ for all kinds of package declarations.
104
105   function Is_Constant
106     (Element : in Asis.Element)
107     return Boolean;
108   --  Returns @True@ for constant and named number declarations.
109
110   function Is_Variable
111     (Element : in Asis.Element)
112     return Boolean;
113   --  Returns @True@ for variable declarations and single task or protected
114   --  object declarations.
115
116   function Is_Type
117     (Element : in Asis.Element)
118     return Boolean;
119   --  Returns @True@ if @Element@ is a type declaration.
120
121   function Is_Subtype
122     (Element : in Asis.Element)
123     return Boolean;
124   --  Returns @True@ if @Element@ is a subtype declaration.
125
126   function Is_Procedure
127     (Element : in Asis.Element)
128     return Boolean;
129
130   function Is_Function
131     (Element : in Asis.Element)
132     return Boolean;
133
134   function Is_Subprogram
135     (Element : in Asis.Element)
136     return Boolean;
137   --  <CODE>Is_Procedure (Element) <STRONG>or</STRONG>
138   --  Is_Function (Element)</CODE>.
139
140   function Is_Entry
141     (Element : in Asis.Element)
142     return Boolean;
143
144   function Is_Pragma
145     (Element : in Asis.Element)
146     return Boolean;
147
148   function Is_Clause
149     (Element : in Asis.Element)
150     return Boolean;
151
152   ----------------------------------------------------------------------------
153   --  Types, Variables, and Constants. See RM 3.2
154
155   function Is_Elementary
156     (Element : in Asis.Element)
157     return Boolean;
158
159   function Is_Scalar
160     (Element : in Asis.Element)
161     return Boolean;
162
163   function Is_Discrete
164     (Element : in Asis.Element)
165     return Boolean;
166
167   function Is_Enumeration
168     (Element : in Asis.Element)
169     return Boolean;
170   --  Returns @True@ if @Element@ is either the declaration of an enumeration
171   --  type or a variable declaration whose type is an enumeration type.
172   --  Includes subtypes and derived types, also includes character and boolean
173   --  types.
174
175   function Is_Integral
176     (Element : in Asis.Element)
177     return Boolean;
178   --  Returns @True@ if @Element@ is either the declaration of an integer
179   --  type or a variable declaration whose type is an integer type.
180   --  Includes subtypes and derived types.
181
182   function Is_Signed
183     (Element : in Asis.Element)
184     return Boolean;
185
186   function Is_Modular
187     (Element : in Asis.Element)
188     return Boolean;
189   --  Returns @True@ if @Element@ is either the declaration of a modular
190   --  type or a variable declaration whose type is a modular type.
191   --  Includes subtypes and derived types.
192
193   function Is_Real
194     (Element : in Asis.Element)
195     return Boolean;
196
197   function Is_Float
198     (Element : in Asis.Element)
199     return Boolean;
200   --  Returns @True@ if @Element@ is either the declaration of a modular
201   --  type or a variable declaration whose type is a modular type.
202   --  Includes subtypes and derived types.
203
204   function Is_Fixed
205     (Element : in Asis.Element)
206     return Boolean;
207   --  Returns @True@ if @Element@ is either the declaration of a modular
208   --  type or a variable declaration whose type is a modular type.
209   --  Includes subtypes and derived types.
210
211   function Is_Ordinary_Fixed
212     (Element : in Asis.Element)
213     return Boolean;
214
215   function Is_Decimal_Fixed
216     (Element : in Asis.Element)
217     return Boolean;
218
219   function Is_Numeric
220     (Element : in Asis.Element)
221     return Boolean;
222
223   function Is_Access
224     (Element : in Asis.Element)
225     return Boolean;
226   --  <CODE>Is_Access_To_Object <STRONG>or</STRONG>
227   --  Is_Access_To_Subprogram</CODE>.
228
229   function Is_Access_To_Object
230     (Element : in Asis.Element)
231     return Boolean;
232   --  Returns @True@ if @Element@ is either the declaration of an access
233   --  type or a variable declaration whose type is an access type. Includes
234   --  subtypes and derived types.
235
236   function Is_Access_To_Subprogram
237     (Element : in Asis.Element)
238     return Boolean;
239   --  Returns @True@ if @Element@ is either the declaration of an access
240   --  type or a variable declaration whose type is an access type. Includes
241   --  subtypes and derived types.
242
243   function Is_Composite
244     (Element : in Asis.Element)
245     return Boolean;
246
247   function Is_Array
248     (Element : in Asis.Element)
249     return Boolean;
250   --  Returns @True@ if @Element@ is either the declaration of an array
251   --  type or a variable declaration whose type is an array type. Includes
252   --  subtypes and derived types.
253
254   function Is_Record
255     (Element : in Asis.Element)
256     return Boolean;
257   --  Returns @True@ if @Element@ is either the declaration of a record
258   --  type or a variable declaration whose type is a record type. Includes
259   --  subtypes and derived types.
260
261   function Is_Tagged
262     (Element : in Asis.Element)
263     return Boolean;
264   --  Returns @True@ if @Element@ is either the declaration of a tagged type
265   --  or a variable declaration whose type is tagged.
266   --
267   --  This includes types derived from tagged types, but not subtypes of
268   --  tagged types!
269
270   function Is_Task
271     (Element : in Asis.Element)
272     return Boolean;
273   --  Returns @True@ if @Element@ is either a task type declaration, a single
274   --  task declaration, or a defining name in a variable declaration whose
275   --  type is a task type. Includes subtypes and derived types.
276
277   function Is_Protected
278     (Element : in Asis.Element)
279     return Boolean;
280   --  Returns @True@ if @Element@ is either a protected type declaration, a
281   --  protected object declaration, or a defining name in a variable
282   --  declaration whose type is a protected type. Includes subtypes and
283   --  derived types.
284
285   function Is_Limited
286     (Element : in Asis.Element)
287     return Boolean;
288   --  Returns @True@ if @Element@ is either the declaration of a limited type
289   --  or a variable declaration whose type is limited. Includes subtypes and
290   --  derived types.
291
292   function Is_Class_Wide
293     (Element : in Asis.Element)
294     return Boolean;
295   --  Returns @True@ if @Element@ is either the declaration of a class-wide
296   --  type or a variable declaration whose type is class-wide. Includes
297   --  subtypes.
298
299   function Is_Controlled
300     (Element : in Asis.Element)
301     return Boolean;
302   --  Definition: a <EM>controlled type</EM> is a type derived from one of
303   --  the two types declared in @Ada.Finalization@.
304   --
305   --  Returns @True@ if @Element@ is either the declaration of a controlled
306   --  type or a variable declaration whose type is controlled. Includes
307   --  subtypes.
308
309   function Is_Private_Type
310     (Element : in Asis.Element)
311     return Boolean;
312   --  Returns @True@ if @Element@ is either the declaration of a private
313   --  type or a variable declaration whose type is private.
314
315   function Is_Incomplete
316     (Element : in Asis.Element)
317     return Boolean;
318   --  Returns @True@ if @Element@ is the declaration of an incomplete type
319   --  or a deferred constant.
320
321   function Is_Aliased
322     (Element : in Asis.Element)
323     return Boolean;
324
325   ----------------------------------------------------------------------------
326   --  Generics, renamings, and other stuff.
327
328   function Is_Exception
329     (Element : in Asis.Element)
330     return Boolean;
331
332   function Is_Renaming
333     (Element : in Asis.Element)
334     return Boolean;
335
336   function Is_Generic
337     (Element : in Asis.Element)
338     return Boolean;
339   --  Returns @True@ for generic subprogram and package declarations, their
340   --  bodies, and generic formal types and objects.
341
342   function Is_Generic_Formal
343     (Element : in Asis.Element)
344     return Boolean;
345   --  Returns @True@ for all generic formals.
346
347   function Is_Instance
348     (Element : in Asis.Element)
349     return Boolean;
350   --  Returns @True@ for all instantiations of generic subprograms or
351   --  packages.
352
353   function Is_Abstract
354     (Element : in Asis.Element)
355     return Boolean;
356   --  Returns @True@ for all abstract types and subprograms.
357
358end Asis2.Predicates;
359