annotate gcc/ada/uname.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- U N A M E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with Namet; use Namet;
kono
parents:
diff changeset
33 with Types; use Types;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 package Uname is
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 ---------------------------
kono
parents:
diff changeset
38 -- Unit Name Conventions --
kono
parents:
diff changeset
39 ---------------------------
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 -- Units are associated with a unique ASCII name as follows. First we have
kono
parents:
diff changeset
42 -- the fully expanded name of the unit, with lower case letters (except
kono
parents:
diff changeset
43 -- for the use of upper case letters for encoding upper half and wide
kono
parents:
diff changeset
44 -- characters, as described in Namet), and periods. Following this is one
kono
parents:
diff changeset
45 -- of the following suffixes:
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 -- %s for package/subprogram/generic declarations (specs)
kono
parents:
diff changeset
48 -- %b for package/subprogram/generic bodies and subunits
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 -- Unit names are stored in the names table, and referred to by the
kono
parents:
diff changeset
51 -- corresponding Name_Id values. The type Unit_Name_Type, derived from
kono
parents:
diff changeset
52 -- Name_Id, is used to indicate that a Name_Id value that holds a unit name
kono
parents:
diff changeset
53 -- (as defined above) is expected.
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -- Note: as far as possible the conventions for unit names are encapsulated
kono
parents:
diff changeset
56 -- in this package. The one exception is that package Fname, which provides
kono
parents:
diff changeset
57 -- conversion routines from unit names to file names must be aware of the
kono
parents:
diff changeset
58 -- precise conventions that are used.
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -------------------
kono
parents:
diff changeset
61 -- Display Names --
kono
parents:
diff changeset
62 -------------------
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- For display purposes, unit names are printed out with the suffix
kono
parents:
diff changeset
65 -- " (body)" for a body and " (spec)" for a spec. These formats are
kono
parents:
diff changeset
66 -- used for the Write_Unit_Name and Get_Unit_Name_String subprograms.
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 -----------------
kono
parents:
diff changeset
69 -- Subprograms --
kono
parents:
diff changeset
70 -----------------
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 function Get_Body_Name (N : Unit_Name_Type) return Unit_Name_Type;
kono
parents:
diff changeset
73 -- Given the name of a spec, this function returns the name of the
kono
parents:
diff changeset
74 -- corresponding body, i.e. characters %s replaced by %b
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Get_Parent_Body_Name (N : Unit_Name_Type) return Unit_Name_Type;
kono
parents:
diff changeset
77 -- Given the name of a subunit, returns the name of the parent body
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 function Get_Parent_Spec_Name (N : Unit_Name_Type) return Unit_Name_Type;
kono
parents:
diff changeset
80 -- Given the name of a child unit spec or body, returns the unit name
kono
parents:
diff changeset
81 -- of the parent spec. Returns No_Name if the given name is not the name
kono
parents:
diff changeset
82 -- of a child unit.
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 procedure Get_External_Unit_Name_String (N : Unit_Name_Type);
kono
parents:
diff changeset
85 -- Given the name of a body or spec unit, this procedure places in
kono
parents:
diff changeset
86 -- Name_Buffer the name of the unit with periods replaced by double
kono
parents:
diff changeset
87 -- underscores. The spec/body indication is eliminated. The length
kono
parents:
diff changeset
88 -- of the stored name is placed in Name_Len. All letters are lower
kono
parents:
diff changeset
89 -- case, corresponding to the string used in external names.
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 function Get_Spec_Name (N : Unit_Name_Type) return Unit_Name_Type;
kono
parents:
diff changeset
92 -- Given the name of a body, this function returns the name of the
kono
parents:
diff changeset
93 -- corresponding spec, i.e. characters %b replaced by %s
kono
parents:
diff changeset
94
kono
parents:
diff changeset
95 function Get_Unit_Name (N : Node_Id) return Unit_Name_Type;
kono
parents:
diff changeset
96 -- This procedure returns the unit name that corresponds to the given node,
kono
parents:
diff changeset
97 -- which is one of the following:
kono
parents:
diff changeset
98 --
kono
parents:
diff changeset
99 -- N_Subprogram_Declaration (spec) cases
kono
parents:
diff changeset
100 -- N_Package_Declaration
kono
parents:
diff changeset
101 -- N_Generic_Declaration
kono
parents:
diff changeset
102 -- N_With_Clause
kono
parents:
diff changeset
103 -- N_Function_Instantiation
kono
parents:
diff changeset
104 -- N_Package_Instantiation
kono
parents:
diff changeset
105 -- N_Procedure_Instantiation
kono
parents:
diff changeset
106 -- N_Pragma (Elaborate case)
kono
parents:
diff changeset
107 --
kono
parents:
diff changeset
108 -- N_Package_Body (body) cases
kono
parents:
diff changeset
109 -- N_Subprogram_Body
kono
parents:
diff changeset
110 -- N_Identifier
kono
parents:
diff changeset
111 -- N_Selected_Component
kono
parents:
diff changeset
112 --
kono
parents:
diff changeset
113 -- N_Subprogram_Body_Stub (subunit) cases
kono
parents:
diff changeset
114 -- N_Package_Body_Stub
kono
parents:
diff changeset
115 -- N_Task_Body_Stub
kono
parents:
diff changeset
116 -- N_Protected_Body_Stub
kono
parents:
diff changeset
117 -- N_Subunit
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 procedure Get_Unit_Name_String
kono
parents:
diff changeset
120 (N : Unit_Name_Type;
kono
parents:
diff changeset
121 Suffix : Boolean := True);
kono
parents:
diff changeset
122 -- Places the display name of the unit in Name_Buffer and sets Name_Len to
kono
parents:
diff changeset
123 -- the length of the stored name, i.e. it uses the same interface as the
kono
parents:
diff changeset
124 -- Get_Name_String routine in the Namet package. The name is decoded and
kono
parents:
diff changeset
125 -- contains an indication of spec or body if Boolean parameter Suffix is
kono
parents:
diff changeset
126 -- True.
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 function Is_Body_Name (N : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
129 -- Returns True iff the given name is the unit name of a body (i.e. if
kono
parents:
diff changeset
130 -- it ends with the characters %b).
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 function Is_Child_Name (N : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
133 -- Returns True iff the given name is a child unit name (of either a
kono
parents:
diff changeset
134 -- body or a spec).
kono
parents:
diff changeset
135
kono
parents:
diff changeset
136 function Is_Internal_Unit_Name
kono
parents:
diff changeset
137 (Name : String;
kono
parents:
diff changeset
138 Renamings_Included : Boolean := True) return Boolean;
kono
parents:
diff changeset
139 -- Same as Fname.Is_Internal_File_Name, except it works with the name of
kono
parents:
diff changeset
140 -- the unit, rather than the file name.
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 function Is_Predefined_Unit_Name
kono
parents:
diff changeset
143 (Name : String;
kono
parents:
diff changeset
144 Renamings_Included : Boolean := True) return Boolean;
kono
parents:
diff changeset
145 -- Same as Fname.Is_Predefined_File_Name, except it works with the name of
kono
parents:
diff changeset
146 -- the unit, rather than the file name.
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 function Is_Spec_Name (N : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
149 -- Returns True iff the given name is the unit name of a specification
kono
parents:
diff changeset
150 -- (i.e. if it ends with the characters %s).
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 function Name_To_Unit_Name (N : Name_Id) return Unit_Name_Type;
kono
parents:
diff changeset
153 -- Given the Id of the Ada name of a unit, this function returns the
kono
parents:
diff changeset
154 -- corresponding unit name of the spec (by appending %s to the name).
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156 function New_Child
kono
parents:
diff changeset
157 (Old : Unit_Name_Type;
kono
parents:
diff changeset
158 Newp : Unit_Name_Type) return Unit_Name_Type;
kono
parents:
diff changeset
159 -- Old is a child unit name (for either a body or spec). Newp is the unit
kono
parents:
diff changeset
160 -- name of the actual parent (this may be different from the parent in
kono
parents:
diff changeset
161 -- old). The returned unit name is formed by taking the parent name from
kono
parents:
diff changeset
162 -- Newp and the child unit name from Old, with the result being a body or
kono
parents:
diff changeset
163 -- spec depending on Old. For example:
kono
parents:
diff changeset
164 --
kono
parents:
diff changeset
165 -- Old = A.B.C (body)
kono
parents:
diff changeset
166 -- Newp = A.R (spec)
kono
parents:
diff changeset
167 -- result = A.R.C (body)
kono
parents:
diff changeset
168 --
kono
parents:
diff changeset
169 -- See spec of Load_Unit for extensive discussion of why this routine
kono
parents:
diff changeset
170 -- needs to be used (the call in the body of Load_Unit is the only one).
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 function Uname_Ge (Left, Right : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
173 function Uname_Gt (Left, Right : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
174 function Uname_Le (Left, Right : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
175 function Uname_Lt (Left, Right : Unit_Name_Type) return Boolean;
kono
parents:
diff changeset
176 -- These functions perform lexicographic ordering of unit names. The
kono
parents:
diff changeset
177 -- ordering is suitable for printing, and is not quite a straightforward
kono
parents:
diff changeset
178 -- comparison of the names, since the convention is that specs appear
kono
parents:
diff changeset
179 -- before bodies. Note that the standard = and /= operators work fine
kono
parents:
diff changeset
180 -- because all unit names are hashed into the name table, so if two names
kono
parents:
diff changeset
181 -- are the same, they always have the same Name_Id value.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183 procedure Write_Unit_Name (N : Unit_Name_Type);
kono
parents:
diff changeset
184 -- Given a unit name, this procedure writes the display name to the
kono
parents:
diff changeset
185 -- standard output file. Name_Buffer and Name_Len are set as described
kono
parents:
diff changeset
186 -- above for the Get_Unit_Name_String call on return.
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 end Uname;