annotate gcc/ada/ghost.ads @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
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 -- G H O S T --
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) 2014-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. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package contains routines that deal with the static and runtime
kono
parents:
diff changeset
27 -- semantics of Ghost entities.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 with Opt; use Opt;
kono
parents:
diff changeset
30 with Types; use Types;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package Ghost is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 procedure Check_Ghost_Completion
kono
parents:
diff changeset
35 (Prev_Id : Entity_Id;
kono
parents:
diff changeset
36 Compl_Id : Entity_Id);
kono
parents:
diff changeset
37 -- Verify that the Ghost policy of initial entity Prev_Id is compatible
kono
parents:
diff changeset
38 -- with the Ghost policy of completing entity Compl_Id. Emit an error if
kono
parents:
diff changeset
39 -- this is not the case.
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 procedure Check_Ghost_Context
kono
parents:
diff changeset
42 (Ghost_Id : Entity_Id;
kono
parents:
diff changeset
43 Ghost_Ref : Node_Id);
kono
parents:
diff changeset
44 -- Determine whether node Ghost_Ref appears within a Ghost-friendly context
kono
parents:
diff changeset
45 -- where Ghost entity Ghost_Id can safely reside.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 procedure Check_Ghost_Overriding
kono
parents:
diff changeset
48 (Subp : Entity_Id;
kono
parents:
diff changeset
49 Overridden_Subp : Entity_Id);
kono
parents:
diff changeset
50 -- Verify that the Ghost policy of parent subprogram Overridden_Subp is
kono
parents:
diff changeset
51 -- compatible with the Ghost policy of overriding subprogram Subp. Emit
kono
parents:
diff changeset
52 -- an error if this is not the case.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 procedure Check_Ghost_Primitive (Prim : Entity_Id; Typ : Entity_Id);
kono
parents:
diff changeset
55 -- Verify that the Ghost policy of primitive operation Prim is the same as
kono
parents:
diff changeset
56 -- the Ghost policy of tagged type Typ. Emit an error if this is not the
kono
parents:
diff changeset
57 -- case.
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 procedure Check_Ghost_Refinement
kono
parents:
diff changeset
60 (State : Node_Id;
kono
parents:
diff changeset
61 State_Id : Entity_Id;
kono
parents:
diff changeset
62 Constit : Node_Id;
kono
parents:
diff changeset
63 Constit_Id : Entity_Id);
kono
parents:
diff changeset
64 -- Verify that the Ghost policy of constituent Constit_Id is compatible
kono
parents:
diff changeset
65 -- with the Ghost policy of abstract state State_I.
kono
parents:
diff changeset
66
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
67 procedure Check_Ghost_Type (Typ : Entity_Id);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 -- Verify that Ghost type Typ is neither concurrent, nor effectively
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
69 -- volatile.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
70
111
kono
parents:
diff changeset
71 function Implements_Ghost_Interface (Typ : Entity_Id) return Boolean;
kono
parents:
diff changeset
72 -- Determine whether type Typ implements at least one Ghost interface
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 procedure Initialize;
kono
parents:
diff changeset
75 -- Initialize internal tables
kono
parents:
diff changeset
76
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
77 procedure Install_Ghost_Region (Mode : Ghost_Mode_Type; N : Node_Id);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
78 pragma Inline (Install_Ghost_Region);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 -- Install a Ghost region described by mode Mode and ignored region start
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
80 -- node N.
111
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function Is_Ghost_Assignment (N : Node_Id) return Boolean;
kono
parents:
diff changeset
83 -- Determine whether arbitrary node N denotes an assignment statement whose
kono
parents:
diff changeset
84 -- target is a Ghost entity.
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function Is_Ghost_Declaration (N : Node_Id) return Boolean;
kono
parents:
diff changeset
87 -- Determine whether arbitrary node N denotes a declaration which defines
kono
parents:
diff changeset
88 -- a Ghost entity.
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function Is_Ghost_Pragma (N : Node_Id) return Boolean;
kono
parents:
diff changeset
91 -- Determine whether arbitrary node N denotes a pragma which encloses a
kono
parents:
diff changeset
92 -- Ghost entity or is associated with a Ghost entity.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 function Is_Ghost_Procedure_Call (N : Node_Id) return Boolean;
kono
parents:
diff changeset
95 -- Determine whether arbitrary node N denotes a procedure call invoking a
kono
parents:
diff changeset
96 -- Ghost procedure.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 function Is_Ignored_Ghost_Unit (N : Node_Id) return Boolean;
kono
parents:
diff changeset
99 -- Determine whether compilation unit N is subject to pragma Ghost with
kono
parents:
diff changeset
100 -- policy Ignore.
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 procedure Lock;
kono
parents:
diff changeset
103 -- Lock internal tables before calling backend
kono
parents:
diff changeset
104
kono
parents:
diff changeset
105 procedure Mark_And_Set_Ghost_Assignment (N : Node_Id);
kono
parents:
diff changeset
106 -- Mark assignment statement N as Ghost when:
kono
parents:
diff changeset
107 --
kono
parents:
diff changeset
108 -- * The left hand side denotes a Ghost entity
kono
parents:
diff changeset
109 --
kono
parents:
diff changeset
110 -- Install the Ghost mode of the assignment statement. This routine starts
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 -- a Ghost region and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Mark_And_Set_Ghost_Body
kono
parents:
diff changeset
114 (N : Node_Id;
kono
parents:
diff changeset
115 Spec_Id : Entity_Id);
kono
parents:
diff changeset
116 -- Mark package or subprogram body N as Ghost when:
kono
parents:
diff changeset
117 --
kono
parents:
diff changeset
118 -- * The body is subject to pragma Ghost
kono
parents:
diff changeset
119 --
kono
parents:
diff changeset
120 -- * The body completes a previous declaration whose spec denoted by
kono
parents:
diff changeset
121 -- Spec_Id is a Ghost entity.
kono
parents:
diff changeset
122 --
kono
parents:
diff changeset
123 -- * The body appears within a Ghost region
kono
parents:
diff changeset
124 --
kono
parents:
diff changeset
125 -- Install the Ghost mode of the body. This routine starts a Ghost region
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126 -- and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 procedure Mark_And_Set_Ghost_Completion
kono
parents:
diff changeset
129 (N : Node_Id;
kono
parents:
diff changeset
130 Prev_Id : Entity_Id);
kono
parents:
diff changeset
131 -- Mark completion N of a deferred constant or private type [extension]
kono
parents:
diff changeset
132 -- Ghost when:
kono
parents:
diff changeset
133 --
kono
parents:
diff changeset
134 -- * The entity of the previous declaration denoted by Prev_Id is Ghost
kono
parents:
diff changeset
135 --
kono
parents:
diff changeset
136 -- * The completion appears within a Ghost region
kono
parents:
diff changeset
137 --
kono
parents:
diff changeset
138 -- Install the Ghost mode of the completion. This routine starts a Ghost
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 -- region and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 procedure Mark_And_Set_Ghost_Declaration (N : Node_Id);
kono
parents:
diff changeset
142 -- Mark declaration N as Ghost when:
kono
parents:
diff changeset
143 --
kono
parents:
diff changeset
144 -- * The declaration is subject to pragma Ghost
kono
parents:
diff changeset
145 --
kono
parents:
diff changeset
146 -- * The declaration denotes a child package or subprogram and the parent
kono
parents:
diff changeset
147 -- is a Ghost unit.
kono
parents:
diff changeset
148 --
kono
parents:
diff changeset
149 -- * The declaration appears within a Ghost region
kono
parents:
diff changeset
150 --
kono
parents:
diff changeset
151 -- Install the Ghost mode of the declaration. This routine starts a Ghost
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
152 -- region and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
153
kono
parents:
diff changeset
154 procedure Mark_And_Set_Ghost_Instantiation
kono
parents:
diff changeset
155 (N : Node_Id;
kono
parents:
diff changeset
156 Gen_Id : Entity_Id);
kono
parents:
diff changeset
157 -- Mark instantiation N as Ghost when:
kono
parents:
diff changeset
158 --
kono
parents:
diff changeset
159 -- * The instantiation is subject to pragma Ghost
kono
parents:
diff changeset
160 --
kono
parents:
diff changeset
161 -- * The generic template denoted by Gen_Id is Ghost
kono
parents:
diff changeset
162 --
kono
parents:
diff changeset
163 -- * The instantiation appears within a Ghost region
kono
parents:
diff changeset
164 --
kono
parents:
diff changeset
165 -- Install the Ghost mode of the instantiation. This routine starts a Ghost
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
166 -- region and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 procedure Mark_And_Set_Ghost_Procedure_Call (N : Node_Id);
kono
parents:
diff changeset
169 -- Mark procedure call N as Ghost when:
kono
parents:
diff changeset
170 --
kono
parents:
diff changeset
171 -- * The procedure being invoked is a Ghost entity
kono
parents:
diff changeset
172 --
kono
parents:
diff changeset
173 -- Install the Ghost mode of the procedure call. This routine starts a
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174 -- Ghost region and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 procedure Mark_Ghost_Clause (N : Node_Id);
kono
parents:
diff changeset
177 -- Mark use package, use type, or with clause N as Ghost when:
kono
parents:
diff changeset
178 --
kono
parents:
diff changeset
179 -- * The clause mentions a Ghost entity
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 procedure Mark_Ghost_Pragma
kono
parents:
diff changeset
182 (N : Node_Id;
kono
parents:
diff changeset
183 Id : Entity_Id);
kono
parents:
diff changeset
184 -- Mark pragma N as Ghost when:
kono
parents:
diff changeset
185 --
kono
parents:
diff changeset
186 -- * The pragma encloses Ghost entity Id
kono
parents:
diff changeset
187 --
kono
parents:
diff changeset
188 -- * The pragma is associated with Ghost entity Id
kono
parents:
diff changeset
189
kono
parents:
diff changeset
190 procedure Mark_Ghost_Renaming
kono
parents:
diff changeset
191 (N : Node_Id;
kono
parents:
diff changeset
192 Id : Entity_Id);
kono
parents:
diff changeset
193 -- Mark renaming declaration N as Ghost when:
kono
parents:
diff changeset
194 --
kono
parents:
diff changeset
195 -- * Renamed entity Id denotes a Ghost entity
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 procedure Remove_Ignored_Ghost_Code;
kono
parents:
diff changeset
198 -- Remove all code marked as ignored Ghost from the trees of all qualifying
kono
parents:
diff changeset
199 -- units (SPARK RM 6.9(4)).
kono
parents:
diff changeset
200 --
kono
parents:
diff changeset
201 -- WARNING: this is a separate front end pass, care should be taken to keep
kono
parents:
diff changeset
202 -- it optimized.
kono
parents:
diff changeset
203
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
204 procedure Restore_Ghost_Region (Mode : Ghost_Mode_Type; N : Node_Id);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
205 pragma Inline (Restore_Ghost_Region);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
206 -- Restore a Ghost region to a previous state described by mode Mode and
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
207 -- ignored region start node N. This routine must be used in conjunction
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
208 -- with the following routines:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
209 --
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
210 -- Install_Ghost_Region
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
211 -- Mark_And_Set_xxx
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
212 -- Set_Ghost_Mode
111
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 procedure Set_Ghost_Mode (N : Node_Or_Entity_Id);
kono
parents:
diff changeset
215 -- Install the Ghost mode of arbitrary node N. This routine starts a Ghost
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
216 -- region and must be used with routine Restore_Ghost_Region.
111
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 procedure Set_Is_Ghost_Entity (Id : Entity_Id);
kono
parents:
diff changeset
219 -- Set the relevant Ghost attributes of entity Id depending on the current
kono
parents:
diff changeset
220 -- Ghost assertion policy in effect.
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 end Ghost;