annotate gcc/ada/ghost.ads @ 118:fd00160c1b76

ifdef TARGET_64BIT
author mir3636
date Tue, 27 Feb 2018 15:01:35 +0900
parents 04ced10e8804
children 84e7813d76e9
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 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 2014-2017, Free Software Foundation, Inc. --
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 Add_Ignored_Ghost_Unit (Unit : Node_Id);
kono
parents:
diff changeset
35 -- Add a single ignored Ghost compilation unit to the internal table for
kono
parents:
diff changeset
36 -- post processing.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 procedure Check_Ghost_Completion
kono
parents:
diff changeset
39 (Prev_Id : Entity_Id;
kono
parents:
diff changeset
40 Compl_Id : Entity_Id);
kono
parents:
diff changeset
41 -- Verify that the Ghost policy of initial entity Prev_Id is compatible
kono
parents:
diff changeset
42 -- with the Ghost policy of completing entity Compl_Id. Emit an error if
kono
parents:
diff changeset
43 -- this is not the case.
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 procedure Check_Ghost_Context
kono
parents:
diff changeset
46 (Ghost_Id : Entity_Id;
kono
parents:
diff changeset
47 Ghost_Ref : Node_Id);
kono
parents:
diff changeset
48 -- Determine whether node Ghost_Ref appears within a Ghost-friendly context
kono
parents:
diff changeset
49 -- where Ghost entity Ghost_Id can safely reside.
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 procedure Check_Ghost_Overriding
kono
parents:
diff changeset
52 (Subp : Entity_Id;
kono
parents:
diff changeset
53 Overridden_Subp : Entity_Id);
kono
parents:
diff changeset
54 -- Verify that the Ghost policy of parent subprogram Overridden_Subp is
kono
parents:
diff changeset
55 -- compatible with the Ghost policy of overriding subprogram Subp. Emit
kono
parents:
diff changeset
56 -- an error if this is not the case.
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 procedure Check_Ghost_Primitive (Prim : Entity_Id; Typ : Entity_Id);
kono
parents:
diff changeset
59 -- Verify that the Ghost policy of primitive operation Prim is the same as
kono
parents:
diff changeset
60 -- the Ghost policy of tagged type Typ. Emit an error if this is not the
kono
parents:
diff changeset
61 -- case.
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 procedure Check_Ghost_Refinement
kono
parents:
diff changeset
64 (State : Node_Id;
kono
parents:
diff changeset
65 State_Id : Entity_Id;
kono
parents:
diff changeset
66 Constit : Node_Id;
kono
parents:
diff changeset
67 Constit_Id : Entity_Id);
kono
parents:
diff changeset
68 -- Verify that the Ghost policy of constituent Constit_Id is compatible
kono
parents:
diff changeset
69 -- with the Ghost policy of abstract state State_I.
kono
parents:
diff changeset
70
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
kono
parents:
diff changeset
77 procedure Install_Ghost_Mode (Mode : Ghost_Mode_Type);
kono
parents:
diff changeset
78 -- Set the value of global variable Ghost_Mode depending on the Ghost
kono
parents:
diff changeset
79 -- policy denoted by Mode.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 function Is_Ghost_Assignment (N : Node_Id) return Boolean;
kono
parents:
diff changeset
82 -- Determine whether arbitrary node N denotes an assignment statement whose
kono
parents:
diff changeset
83 -- target is a Ghost entity.
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 function Is_Ghost_Declaration (N : Node_Id) return Boolean;
kono
parents:
diff changeset
86 -- Determine whether arbitrary node N denotes a declaration which defines
kono
parents:
diff changeset
87 -- a Ghost entity.
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 function Is_Ghost_Pragma (N : Node_Id) return Boolean;
kono
parents:
diff changeset
90 -- Determine whether arbitrary node N denotes a pragma which encloses a
kono
parents:
diff changeset
91 -- Ghost entity or is associated with a Ghost entity.
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 function Is_Ghost_Procedure_Call (N : Node_Id) return Boolean;
kono
parents:
diff changeset
94 -- Determine whether arbitrary node N denotes a procedure call invoking a
kono
parents:
diff changeset
95 -- Ghost procedure.
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 function Is_Ignored_Ghost_Unit (N : Node_Id) return Boolean;
kono
parents:
diff changeset
98 -- Determine whether compilation unit N is subject to pragma Ghost with
kono
parents:
diff changeset
99 -- policy Ignore.
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 procedure Lock;
kono
parents:
diff changeset
102 -- Lock internal tables before calling backend
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Mark_And_Set_Ghost_Assignment (N : Node_Id);
kono
parents:
diff changeset
105 -- Mark assignment statement N as Ghost when:
kono
parents:
diff changeset
106 --
kono
parents:
diff changeset
107 -- * The left hand side denotes a Ghost entity
kono
parents:
diff changeset
108 --
kono
parents:
diff changeset
109 -- Install the Ghost mode of the assignment statement. This routine starts
kono
parents:
diff changeset
110 -- a Ghost region and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 procedure Mark_And_Set_Ghost_Body
kono
parents:
diff changeset
113 (N : Node_Id;
kono
parents:
diff changeset
114 Spec_Id : Entity_Id);
kono
parents:
diff changeset
115 -- Mark package or subprogram body N as Ghost when:
kono
parents:
diff changeset
116 --
kono
parents:
diff changeset
117 -- * The body is subject to pragma Ghost
kono
parents:
diff changeset
118 --
kono
parents:
diff changeset
119 -- * The body completes a previous declaration whose spec denoted by
kono
parents:
diff changeset
120 -- Spec_Id is a Ghost entity.
kono
parents:
diff changeset
121 --
kono
parents:
diff changeset
122 -- * The body appears within a Ghost region
kono
parents:
diff changeset
123 --
kono
parents:
diff changeset
124 -- Install the Ghost mode of the body. This routine starts a Ghost region
kono
parents:
diff changeset
125 -- and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 procedure Mark_And_Set_Ghost_Completion
kono
parents:
diff changeset
128 (N : Node_Id;
kono
parents:
diff changeset
129 Prev_Id : Entity_Id);
kono
parents:
diff changeset
130 -- Mark completion N of a deferred constant or private type [extension]
kono
parents:
diff changeset
131 -- Ghost when:
kono
parents:
diff changeset
132 --
kono
parents:
diff changeset
133 -- * The entity of the previous declaration denoted by Prev_Id is Ghost
kono
parents:
diff changeset
134 --
kono
parents:
diff changeset
135 -- * The completion appears within a Ghost region
kono
parents:
diff changeset
136 --
kono
parents:
diff changeset
137 -- Install the Ghost mode of the completion. This routine starts a Ghost
kono
parents:
diff changeset
138 -- region and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
139
kono
parents:
diff changeset
140 procedure Mark_And_Set_Ghost_Declaration (N : Node_Id);
kono
parents:
diff changeset
141 -- Mark declaration N as Ghost when:
kono
parents:
diff changeset
142 --
kono
parents:
diff changeset
143 -- * The declaration is subject to pragma Ghost
kono
parents:
diff changeset
144 --
kono
parents:
diff changeset
145 -- * The declaration denotes a child package or subprogram and the parent
kono
parents:
diff changeset
146 -- is a Ghost unit.
kono
parents:
diff changeset
147 --
kono
parents:
diff changeset
148 -- * The declaration appears within a Ghost region
kono
parents:
diff changeset
149 --
kono
parents:
diff changeset
150 -- Install the Ghost mode of the declaration. This routine starts a Ghost
kono
parents:
diff changeset
151 -- region and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 procedure Mark_And_Set_Ghost_Instantiation
kono
parents:
diff changeset
154 (N : Node_Id;
kono
parents:
diff changeset
155 Gen_Id : Entity_Id);
kono
parents:
diff changeset
156 -- Mark instantiation N as Ghost when:
kono
parents:
diff changeset
157 --
kono
parents:
diff changeset
158 -- * The instantiation is subject to pragma Ghost
kono
parents:
diff changeset
159 --
kono
parents:
diff changeset
160 -- * The generic template denoted by Gen_Id is Ghost
kono
parents:
diff changeset
161 --
kono
parents:
diff changeset
162 -- * The instantiation appears within a Ghost region
kono
parents:
diff changeset
163 --
kono
parents:
diff changeset
164 -- Install the Ghost mode of the instantiation. This routine starts a Ghost
kono
parents:
diff changeset
165 -- region and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 procedure Mark_And_Set_Ghost_Procedure_Call (N : Node_Id);
kono
parents:
diff changeset
168 -- Mark procedure call N as Ghost when:
kono
parents:
diff changeset
169 --
kono
parents:
diff changeset
170 -- * The procedure being invoked is a Ghost entity
kono
parents:
diff changeset
171 --
kono
parents:
diff changeset
172 -- Install the Ghost mode of the procedure call. This routine starts a
kono
parents:
diff changeset
173 -- Ghost region and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 procedure Mark_Ghost_Clause (N : Node_Id);
kono
parents:
diff changeset
176 -- Mark use package, use type, or with clause N as Ghost when:
kono
parents:
diff changeset
177 --
kono
parents:
diff changeset
178 -- * The clause mentions a Ghost entity
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 procedure Mark_Ghost_Pragma
kono
parents:
diff changeset
181 (N : Node_Id;
kono
parents:
diff changeset
182 Id : Entity_Id);
kono
parents:
diff changeset
183 -- Mark pragma N as Ghost when:
kono
parents:
diff changeset
184 --
kono
parents:
diff changeset
185 -- * The pragma encloses Ghost entity Id
kono
parents:
diff changeset
186 --
kono
parents:
diff changeset
187 -- * The pragma is associated with Ghost entity Id
kono
parents:
diff changeset
188
kono
parents:
diff changeset
189 procedure Mark_Ghost_Renaming
kono
parents:
diff changeset
190 (N : Node_Id;
kono
parents:
diff changeset
191 Id : Entity_Id);
kono
parents:
diff changeset
192 -- Mark renaming declaration N as Ghost when:
kono
parents:
diff changeset
193 --
kono
parents:
diff changeset
194 -- * Renamed entity Id denotes a Ghost entity
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 procedure Remove_Ignored_Ghost_Code;
kono
parents:
diff changeset
197 -- Remove all code marked as ignored Ghost from the trees of all qualifying
kono
parents:
diff changeset
198 -- units (SPARK RM 6.9(4)).
kono
parents:
diff changeset
199 --
kono
parents:
diff changeset
200 -- WARNING: this is a separate front end pass, care should be taken to keep
kono
parents:
diff changeset
201 -- it optimized.
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 procedure Restore_Ghost_Mode (Mode : Ghost_Mode_Type);
kono
parents:
diff changeset
204 -- Terminate a Ghost region by restoring the Ghost mode prior to the
kono
parents:
diff changeset
205 -- region denoted by Mode. This routine must be used in conjunction
kono
parents:
diff changeset
206 -- with Mark_And_Set_xxx routines as well as Set_Ghost_Mode.
kono
parents:
diff changeset
207
kono
parents:
diff changeset
208 procedure Set_Ghost_Mode (N : Node_Or_Entity_Id);
kono
parents:
diff changeset
209 -- Install the Ghost mode of arbitrary node N. This routine starts a Ghost
kono
parents:
diff changeset
210 -- region and must be used in conjunction with Restore_Ghost_Mode.
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 procedure Set_Is_Ghost_Entity (Id : Entity_Id);
kono
parents:
diff changeset
213 -- Set the relevant Ghost attributes of entity Id depending on the current
kono
parents:
diff changeset
214 -- Ghost assertion policy in effect.
kono
parents:
diff changeset
215
kono
parents:
diff changeset
216 end Ghost;