FSF GCC merge 02/23/03
[official-gcc.git] / gcc / ada / itypes.ads
blob2dc7cacc8baf4be5ee001ec98c262b1e0c591781
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- I T Y P E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1992,1993,1994,1995,1996 Free Software Foundation, Inc. --
11 -- --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 -- --
26 ------------------------------------------------------------------------------
28 -- This package contains declarations for handling of implicit types
30 with Einfo; use Einfo;
31 with Sem_Util; use Sem_Util;
32 with Types; use Types;
34 package Itypes is
36 --------------------
37 -- Implicit Types --
38 --------------------
40 -- Implicit types are types and subtypes created by the semantic phase
41 -- or the expander to reflect the underlying semantics. These could be
42 -- generated by building trees for corresponding declarations and then
43 -- analyzing these trees, but there are three reasons for not doing this:
45 -- 1. The declarations would require more tree nodes
47 -- 2. In some cases, the elaboration of these types is associated
48 -- with internal nodes in the tree.
50 -- 3. For some types, notably class wide types, there is no Ada
51 -- declaration that would correspond to the desired entity.
53 -- So instead, implicit types are constructed by simply creating an
54 -- appropriate entity with the help of routines in this package. These
55 -- entities are fully decorated, as described in Einfo (just as though
56 -- they had been created by the normal analysis procedure).
58 -- The type declaration declaring an Itype must be analyzed with checks
59 -- off because this declaration has not been inserted in the tree (if it
60 -- has been then it is not an itype), and hence checks that would be
61 -- generated during the analysis cannot be inserted in the tree. At any
62 -- rate, itype analysis should always be done with checks off, otherwise
63 -- duplicate checks will most likely be emitted.
65 -- Unlike types declared explicitly, implicit types are defined on first
66 -- use, which means that Gigi detects the use of such types, and defines
67 -- them at the point of the first use automatically.
69 -- Although Itypes are not explicitly declared, they are associated with
70 -- a specific node in the tree (roughly the node that caused them to be
71 -- created), via the Associated_Node_For_Itype field. This association is
72 -- used particularly by New_Copy_Tree, which uses it to determine whether
73 -- or not to copy a referenced Itype. If the associated node is part of
74 -- the tree to be copied by New_Copy_Tree, then (since the idea of the
75 -- call to New_Copy_Tree is to create a complete duplicate of a tree,
76 -- as though it had appeared separately int he source), the Itype in
77 -- question is duplicated as part of the New_Copy_Tree processing.
79 -----------------
80 -- Subprograms --
81 -----------------
83 function Create_Itype
84 (Ekind : Entity_Kind;
85 Related_Nod : Node_Id;
86 Related_Id : Entity_Id := Empty;
87 Suffix : Character := ' ';
88 Suffix_Index : Nat := 0;
89 Scope_Id : Entity_Id := Current_Scope)
90 return Entity_Id;
91 -- Used to create a new Itype.
93 -- Related_Nod is the node for which this Itype was created. It is
94 -- set as the Associated_Node_For_Itype of the new itype. The Sloc of
95 -- the new Itype is that of this node.
97 -- Related_Id is present only if the implicit type name may be referenced
98 -- as a public symbol, and thus needs a unique external name. The name
99 -- is created by a call to:
101 -- New_External_Name (Chars (Related_Id), Suffix, Suffix_Index, 'T')
103 -- If the implicit type does not need an external name, then the
104 -- Related_Id parameter is omitted (and hence Empty). In this case
105 -- Suffix and Suffix_Index are ignored and the implicit type name is
106 -- created by a call to New_Internal_Name ('T').
108 -- Note that in all cases, the name starts with "T". This is used
109 -- to identify implicit types in the error message handling circuits.
111 -- The Scope_Id parameter specifies the scope of the created type, and
112 -- is normally the Current_Scope as shown, but can be set otherwise.
114 end Itypes;