Branch data Line data Source code
1 : : /* do not edit automatically generated by mc from M2Pass. */
2 : : /* M2Pass.mod provides setting and testing of the current pass.
3 : :
4 : : Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 : : Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 : :
7 : : This file is part of GNU Modula-2.
8 : :
9 : : GNU Modula-2 is free software; you can redistribute it and/or modify
10 : : it under the terms of the GNU General Public License as published by
11 : : the Free Software Foundation; either version 3, or (at your option)
12 : : any later version.
13 : :
14 : : GNU Modula-2 is distributed in the hope that it will be useful, but
15 : : WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 : : General Public License for more details.
18 : :
19 : : You should have received a copy of the GNU General Public License
20 : : along with GNU Modula-2; see the file COPYING3. If not see
21 : : <http://www.gnu.org/licenses/>. */
22 : :
23 : : #include "config.h"
24 : : #include "system.h"
25 : : #include <stdbool.h>
26 : : # if !defined (PROC_D)
27 : : # define PROC_D
28 : : typedef void (*PROC_t) (void);
29 : : typedef struct { PROC_t proc; } PROC;
30 : : # endif
31 : :
32 : : #define _M2Pass_H
33 : : #define _M2Pass_C
34 : :
35 : : # include "GM2Error.h"
36 : :
37 : : typedef enum {M2Pass_NoPass, M2Pass_Pass0, M2Pass_Pass1, M2Pass_Pass2, M2Pass_PassC, M2Pass_Pass3, M2Pass_CodeGeneration, M2Pass_ErrorPass, M2Pass_HiddenPass} M2Pass_Pass;
38 : :
39 : : static M2Pass_Pass CurrentPass;
40 : :
41 : : /*
42 : : SetPassToNoPass - sets the pass state to no Pass.
43 : : */
44 : :
45 : : extern "C" void M2Pass_SetPassToNoPass (void);
46 : :
47 : : /*
48 : : SetPassToPass0 - sets the pass state to Pass 0.
49 : : */
50 : :
51 : : extern "C" void M2Pass_SetPassToPass0 (void);
52 : :
53 : : /*
54 : : SetPassToPass1 - sets the pass state to Pass 1.
55 : : */
56 : :
57 : : extern "C" void M2Pass_SetPassToPass1 (void);
58 : :
59 : : /*
60 : : SetPassToPass2 - sets the pass state to Pass 2.
61 : : */
62 : :
63 : : extern "C" void M2Pass_SetPassToPass2 (void);
64 : :
65 : : /*
66 : : SetPassToPassC - sets the pass state to Pass C.
67 : : */
68 : :
69 : : extern "C" void M2Pass_SetPassToPassC (void);
70 : :
71 : : /*
72 : : SetPassToPass3 - sets the pass state to Pass 3.
73 : : */
74 : :
75 : : extern "C" void M2Pass_SetPassToPass3 (void);
76 : :
77 : : /*
78 : : SetPassToPassHidden - sets the pass state to the hidden type pass.
79 : : */
80 : :
81 : : extern "C" void M2Pass_SetPassToPassHidden (void);
82 : :
83 : : /*
84 : : SetPassToCodeGeneration - sets the pass state to CodeGeneration.
85 : : */
86 : :
87 : : extern "C" void M2Pass_SetPassToCodeGeneration (void);
88 : :
89 : : /*
90 : : SetPassToErrorPass - sets the pass state to no Error Pass.
91 : : */
92 : :
93 : : extern "C" void M2Pass_SetPassToErrorPass (void);
94 : :
95 : : /*
96 : : IsNoPass - returns true if currently in no Pass.
97 : : */
98 : :
99 : : extern "C" bool M2Pass_IsNoPass (void);
100 : :
101 : : /*
102 : : IsPass0 - returns true if currently in Pass 0.
103 : : */
104 : :
105 : : extern "C" bool M2Pass_IsPass0 (void);
106 : :
107 : : /*
108 : : IsPass1 - returns true if currently in Pass 1.
109 : : */
110 : :
111 : : extern "C" bool M2Pass_IsPass1 (void);
112 : :
113 : : /*
114 : : IsPass2 - returns true if currently in Pass 2.
115 : : */
116 : :
117 : : extern "C" bool M2Pass_IsPass2 (void);
118 : :
119 : : /*
120 : : IsPassC - returns true if currently in Pass C.
121 : : */
122 : :
123 : : extern "C" bool M2Pass_IsPassC (void);
124 : :
125 : : /*
126 : : IsPass3 - returns true if currently in Pass 3.
127 : : */
128 : :
129 : : extern "C" bool M2Pass_IsPass3 (void);
130 : :
131 : : /*
132 : : IsPassHidden - returns TRUE if currently parsing for hidden types.
133 : : */
134 : :
135 : : extern "C" bool M2Pass_IsPassHidden (void);
136 : :
137 : : /*
138 : : IsPassCodeGeneration - returns true if currently in the CodeGeneration Pass.
139 : : */
140 : :
141 : : extern "C" bool M2Pass_IsPassCodeGeneration (void);
142 : :
143 : : /*
144 : : IsErrorPass - returns true if currently in the Error Pass.
145 : : */
146 : :
147 : : extern "C" bool M2Pass_IsErrorPass (void);
148 : :
149 : :
150 : : /*
151 : : SetPassToNoPass - sets the pass state to no Pass.
152 : : */
153 : :
154 : 181727 : extern "C" void M2Pass_SetPassToNoPass (void)
155 : : {
156 : 181727 : CurrentPass = M2Pass_NoPass;
157 : 181727 : }
158 : :
159 : :
160 : : /*
161 : : SetPassToPass0 - sets the pass state to Pass 0.
162 : : */
163 : :
164 : 12963 : extern "C" void M2Pass_SetPassToPass0 (void)
165 : : {
166 : 12963 : if (CurrentPass == M2Pass_NoPass)
167 : : {
168 : 12963 : CurrentPass = M2Pass_Pass0;
169 : : }
170 : : else
171 : : {
172 : 0 : M2Error_InternalError ((const char *) "attempting to set CurrentPass to Pass1", 38);
173 : : }
174 : 12963 : }
175 : :
176 : :
177 : : /*
178 : : SetPassToPass1 - sets the pass state to Pass 1.
179 : : */
180 : :
181 : 12916 : extern "C" void M2Pass_SetPassToPass1 (void)
182 : : {
183 : 12916 : if (CurrentPass == M2Pass_NoPass)
184 : : {
185 : 12916 : CurrentPass = M2Pass_Pass1;
186 : : }
187 : : else
188 : : {
189 : 0 : M2Error_InternalError ((const char *) "attempting to set CurrentPass to Pass1", 38);
190 : : }
191 : 12916 : }
192 : :
193 : :
194 : : /*
195 : : SetPassToPass2 - sets the pass state to Pass 2.
196 : : */
197 : :
198 : 12904 : extern "C" void M2Pass_SetPassToPass2 (void)
199 : : {
200 : 12904 : if (CurrentPass == M2Pass_NoPass)
201 : : {
202 : 12904 : CurrentPass = M2Pass_Pass2;
203 : : }
204 : : else
205 : : {
206 : 0 : M2Error_InternalError ((const char *) "attempting to set CurrentPass to Pass2", 38);
207 : : }
208 : 12904 : }
209 : :
210 : :
211 : : /*
212 : : SetPassToPassC - sets the pass state to Pass C.
213 : : */
214 : :
215 : 12868 : extern "C" void M2Pass_SetPassToPassC (void)
216 : : {
217 : 12868 : if (CurrentPass == M2Pass_NoPass)
218 : : {
219 : 12868 : CurrentPass = M2Pass_PassC;
220 : : }
221 : : else
222 : : {
223 : 0 : M2Error_InternalError ((const char *) "attempting to set CurrentPass to PassC", 38);
224 : : }
225 : 12868 : }
226 : :
227 : :
228 : : /*
229 : : SetPassToPass3 - sets the pass state to Pass 3.
230 : : */
231 : :
232 : 58814 : extern "C" void M2Pass_SetPassToPass3 (void)
233 : : {
234 : 58814 : if (CurrentPass == M2Pass_NoPass)
235 : : {
236 : 58814 : CurrentPass = M2Pass_Pass3;
237 : : }
238 : : else
239 : : {
240 : 0 : M2Error_InternalError ((const char *) "attempting to set CurrentPass to Pass3", 38);
241 : : }
242 : 58814 : }
243 : :
244 : :
245 : : /*
246 : : SetPassToPassHidden - sets the pass state to the hidden type pass.
247 : : */
248 : :
249 : 46018 : extern "C" void M2Pass_SetPassToPassHidden (void)
250 : : {
251 : 46018 : CurrentPass = M2Pass_HiddenPass;
252 : 46018 : }
253 : :
254 : :
255 : : /*
256 : : SetPassToCodeGeneration - sets the pass state to CodeGeneration.
257 : : */
258 : :
259 : 12454 : extern "C" void M2Pass_SetPassToCodeGeneration (void)
260 : : {
261 : 12454 : if (CurrentPass == M2Pass_NoPass)
262 : : {
263 : 12454 : CurrentPass = M2Pass_CodeGeneration;
264 : : }
265 : : else
266 : : {
267 : 0 : M2Error_InternalError ((const char *) "attempting to set CurrentPass to CodeGeneration", 47);
268 : : }
269 : 12454 : }
270 : :
271 : :
272 : : /*
273 : : SetPassToErrorPass - sets the pass state to no Error Pass.
274 : : */
275 : :
276 : 0 : extern "C" void M2Pass_SetPassToErrorPass (void)
277 : : {
278 : 0 : CurrentPass = M2Pass_ErrorPass;
279 : 0 : }
280 : :
281 : :
282 : : /*
283 : : IsNoPass - returns true if currently in no Pass.
284 : : */
285 : :
286 : 0 : extern "C" bool M2Pass_IsNoPass (void)
287 : : {
288 : 0 : return CurrentPass == M2Pass_NoPass;
289 : : /* static analysis guarentees a RETURN statement will be used before here. */
290 : : __builtin_unreachable ();
291 : : }
292 : :
293 : :
294 : : /*
295 : : IsPass0 - returns true if currently in Pass 0.
296 : : */
297 : :
298 : 13957799 : extern "C" bool M2Pass_IsPass0 (void)
299 : : {
300 : 13957799 : return CurrentPass == M2Pass_Pass0;
301 : : /* static analysis guarentees a RETURN statement will be used before here. */
302 : : __builtin_unreachable ();
303 : : }
304 : :
305 : :
306 : : /*
307 : : IsPass1 - returns true if currently in Pass 1.
308 : : */
309 : :
310 : 130008 : extern "C" bool M2Pass_IsPass1 (void)
311 : : {
312 : 130008 : return CurrentPass == M2Pass_Pass1;
313 : : /* static analysis guarentees a RETURN statement will be used before here. */
314 : : __builtin_unreachable ();
315 : : }
316 : :
317 : :
318 : : /*
319 : : IsPass2 - returns true if currently in Pass 2.
320 : : */
321 : :
322 : 130008 : extern "C" bool M2Pass_IsPass2 (void)
323 : : {
324 : 130008 : return CurrentPass == M2Pass_Pass2;
325 : : /* static analysis guarentees a RETURN statement will be used before here. */
326 : : __builtin_unreachable ();
327 : : }
328 : :
329 : :
330 : : /*
331 : : IsPassC - returns true if currently in Pass C.
332 : : */
333 : :
334 : 130008 : extern "C" bool M2Pass_IsPassC (void)
335 : : {
336 : 130008 : return CurrentPass == M2Pass_PassC;
337 : : /* static analysis guarentees a RETURN statement will be used before here. */
338 : : __builtin_unreachable ();
339 : : }
340 : :
341 : :
342 : : /*
343 : : IsPass3 - returns true if currently in Pass 3.
344 : : */
345 : :
346 : 130008 : extern "C" bool M2Pass_IsPass3 (void)
347 : : {
348 : 130008 : return CurrentPass == M2Pass_Pass3;
349 : : /* static analysis guarentees a RETURN statement will be used before here. */
350 : : __builtin_unreachable ();
351 : : }
352 : :
353 : :
354 : : /*
355 : : IsPassHidden - returns TRUE if currently parsing for hidden types.
356 : : */
357 : :
358 : 0 : extern "C" bool M2Pass_IsPassHidden (void)
359 : : {
360 : 0 : return CurrentPass == M2Pass_HiddenPass;
361 : : /* static analysis guarentees a RETURN statement will be used before here. */
362 : : __builtin_unreachable ();
363 : : }
364 : :
365 : :
366 : : /*
367 : : IsPassCodeGeneration - returns true if currently in the CodeGeneration Pass.
368 : : */
369 : :
370 : 424197 : extern "C" bool M2Pass_IsPassCodeGeneration (void)
371 : : {
372 : 424197 : return CurrentPass == M2Pass_CodeGeneration;
373 : : /* static analysis guarentees a RETURN statement will be used before here. */
374 : : __builtin_unreachable ();
375 : : }
376 : :
377 : :
378 : : /*
379 : : IsErrorPass - returns true if currently in the Error Pass.
380 : : */
381 : :
382 : 0 : extern "C" bool M2Pass_IsErrorPass (void)
383 : : {
384 : 0 : return CurrentPass == M2Pass_ErrorPass;
385 : : /* static analysis guarentees a RETURN statement will be used before here. */
386 : : __builtin_unreachable ();
387 : : }
388 : :
389 : 12963 : extern "C" void _M2_M2Pass_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
390 : : {
391 : 12963 : M2Pass_SetPassToNoPass ();
392 : 12963 : }
393 : :
394 : 0 : extern "C" void _M2_M2Pass_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[])
395 : : {
396 : 0 : }
|