eĿlipsis
a language independent preprocessor
 
Loading...
Searching...
No Matches
ellipsis-defer.h
Go to the documentation of this file.
1# pragma once
2
3# include_directives ⟨ellipsis-unique.dirs⟩ __prefix__(bind UNIQUE_NAME DEFER)
4# include_directives ⟨ellipsis-loc.h⟩ __prefix__(bind LOC_NAME DEFER_END)
5# include_directives ⟨ellipsis-loc.h⟩ __prefix__(bind LOC_NAME DEFER_LOC)
6# include_directives ⟨ellipsis-blockstate.h⟩
7# include_directives ⟨ellipsis-trigger.h⟩ __prefix__(bind NAME DEFER_TRIGGER)
8# include_directives ⟨ellipsis-forcebrace.h⟩
9
10# ifndef DOXYGEN_SPECIAL
11
12# xdefine DEFER_MODIFIABLE DEFER_LOC_NEW
13# xdefine DEFER_ONE DEFER_LOC_NEW
14
15/* Each {} level has a flag that is 0 if no defer has yet been seen in
16 the current {} and that is 1, once such a defer has been seen. Each
17 flag has function test-and-set (at each defer) and clear (at the
18 terminating })*/
19# define DEFER_CLEAR __BLOCKSTATE_SET0(DEFER_FLAG_, DEFER_END_LEVEL)
20
21# define DEFER_TAS() DEFER_TAS_(__BLOCKSTATE_TST(DEFER_FLAG_, DEFER_END_LEVEL))
22# define DEFER_TAS_(V) __MULTI__(DEFER_TAS, V)()V
23# define DEFER_TAS_0() __BLOCKSTATE_SET1(DEFER_FLAG_, DEFER_END_LEVEL)
24# define DEFER_TAS_1()
25
26
27/* At the very end of a {} block, after having handled all defer of
28 the block we have to test if have to unwind further or not. For all
29 higher levels we have to test if we are returning, only on level 0
30 we now that we are at the end and we should just fall off. */
31# define DEFER_RET DEFER_RET_(DEFER_LEVEL)
32# define DEFER_RET_(L) DEFER_RET__(DEFER_RET_ ⨝ L, /*^*/⸤if (defer_return_flag) goto⸥ DEFER(0, 1)⸤;⸥)
33# define DEFER_RET__(...) DEFER_RET___(__VA_ARGS__)
34# define DEFER_RET___(X, Y, ...) Y
35# define DEFER_RET_1 ,
36
37# define DEFER_RETURN(LABEL) __MULTI__(DEFER_RETURN, DEFER_MODE)(LABEL)
38# define DEFER_RETURN_0(LABEL)
39# define DEFER_RETURN_1(LABEL) ⸤goto⸥ LABEL
40# define DEFER_RETURN_2(LABEL) ⸤return⸥ DEFER_MODIFIABLE
41
42# define DEFER_OPENBR() DEFER_OPENBR_(__MULTI__(DEFER_OPENBR, __BLOCKSTATE_TST(DEFER_NUMBER))())__BLOCKSTATE_INC(DEFER_NUMBER)
43# define DEFER_OPENBR_(...) DEFER_OPENBR__(__VA_ARGS__,,)
44# define DEFER_OPENBR__(X, Y, ...) Y
45# define DEFER_OPENBR_0() , ⸤{⸥ /*^ ⸤start inner defer anchor at level⸥ __INSTANT__(DEFER_LEVEL) ^*/
46
47/* Now instrument the closing brace. Basically do nothing, if there
48 has not been a defer. Otherwise, launch the chain. */
49# bind DEFER_GO __MULTI__(DEFER_GO, DEFER_TAS())()DEFER_FINALIZE(DEFER_LEVEL)
50# define DEFER_GO_0() DEFER_CLEAR
51
52<|
53# define DEFER_GO_1()
54 /*^*/defer_skip⸤;⸥
55 /*^*/⸤}⸥ /*^ ⸤end inner defer anchor, level⸥ __INSTANT__(DEFER_LEVEL) ^*/
56 /*^*//*>*/⸤[[__maybe_unused__]]⸥ DEFER_END()⸤:;⸥
57 DEFER_SWITCH_END()DEFER_LOOP_END()DEFER_CLEAR DEFER_DOWN __BLOCKSTATE_SET0(DEFER_NUMBER)
58|>
59
60/* Prepend our code to whatever might already be plugged into } */
61# gather DEFER_GO }
62# gather } DEFER_GO
63
64# define DEFER_FINALIZE_RETURN() DEFER_FINALIZE_RETURN_(__MULTI__(DEFER_FINALIZE_RETURN, DEFER_MODE)())
65# define DEFER_FINALIZE_RETURN_(...) DEFER_FINALIZE_RETURN__(__VA_ARGS__)
66# define DEFER_FINALIZE_RETURN__(...) __VA_ARGS__
67# define DEFER_FINALIZE_RETURN_0()
68# define DEFER_FINALIZE_RETURN_1()
69# define DEFER_FINALIZE_RETURN_2() /*^*/⸤return⸥ DEFER_MODIFIABLE⸤;⸥
70
71/* clear the mode counter only on the top most level */
72# define DEFER_FINALIZE(L) DEFER_FINALIZE_(__MULTI__(DEFER_FINALIZE, L)(),,)
73# define DEFER_FINALIZE_(...) DEFER_FINALIZE__(__VA_ARGS__)
74# define DEFER_FINALIZE__(X, Y, ...) Y
75# define DEFER_FINALIZE_0() , DEFER_FINALIZE_RETURN()__SET0__(DEFER_MODE)
76
77# define DEFER_DO() __MULTI__(DEFER_DO, DEFER_TAS())
78# define DEFER_DO_0 DEFER_UP __SET1__(DEFER_IS_FIRST)DEFER_END_NEW
79# define DEFER_DO_1 DEFER()
80
81# define DEFER_DONE() DEFER_DONE_(__INSTANT__(DEFER_IS_FIRST))
82# define DEFER_DONE_(L) __MULTI__(DEFER_DONE, L)()
83# define DEFER_DONE_1() __SET0__(DEFER_IS_FIRST)DEFER_END()
84# define DEFER_DONE_0() DEFER(1)
85
86/* If there is no defer return context, yet, the top most {} level
87 with a defer is forced to be a defer return context with a void
88 return type. */
89# define DEFER_DEF() __MULTI__(DEFER_DEF, DEFER_MODE)()DEFER_LOOP_START()DEFER_SWITCH_START()
90# define DEFER_DEF_0() DEFER_DEF_FORCE(DEFER_LEVEL)
91# define DEFER_DEF_1()
92# define DEFER_DEF_2()
93
94# define DEFER_DEF_FORCE(L) DEFER_DEF_FORCE_(DEFER_DEF_FORCE_ ⨝ L)
95
96
97<|
98# define DEFER_DEF_FORCE_0
99 ,
100 /*>*/⸤[[__maybe_unused__]] register unsigned⸥ DEFER_ONE ⸤= 1U;⸥
101 /*^*/⸤[[__maybe_unused__]] register bool defer_return_flag = false;⸥__SET1__(DEFER_MODE) /*^*/
102|>
103
104# define DEFER_DEF_FORCE_(...) DEFER_DEF_FORCE__(__VA_ARGS__)
105# define DEFER_DEF_FORCE__(X, ...) __VA_ARGS__
106
107# define defer_return(M) __MULTI__(defer_return, M)()
108
109# define defer_return_0() ⸤return⸥
110
111<|
112# define defer_return_1()
113/*^*/⸤do {⸥
114/*>*/
115/*^*/ ⸤defer_return_flag = true;⸥
116/*^*/ defer_skip⸤;⸥
117/*^*/⸤} while(false)⸥
118|>
119
120# define defer_return_2() DEFER_RETURN_TO()
121
122# define DEFER_TOP DEFER_TOP_(DEFER_DO(), DEFER_NEW)
123# define DEFER_TOP_(...) DEFER_TOP__(__VA_ARGS__)
124
125<|
126# define DEFER_TOP__(TARGET, LOCATION) ⸤if (false) {⸥
127/*^*/LOCATION:
128 /*^*/ ⸤goto⸥ DEFER_END_NEW⸤;⸥
129/*^*/⸤} else⸥ DEFER_OPENBR()
130/*^*/⸤(void)0⸥ /*^ ⸤DEFER_TYPE needs a semicolon⸥ ^*/__SET0__(DEFER_IS_FIRST)
131|>
132
133/*
134 There is a per level state variable that knows if a compound
135 statement is inside a loop, and if so if it is the outermost (values
136 1 and 2) or an inner compound statement (value 3). That difference
137 is necessary to distinguish different terminating strategies for the
138 compound statement. If it is the outermost, execution may just fall
139 through, or perform a break or a continue for the loop. If it is an
140 inner one, it must continue unwinding to outer levels if a `break`
141 or `continue` has been requested.
142
143 To know if a `break` or `continue` has been requested there are two
144 local flags that hold the information. */
145# define DEFER_CONSTRUCTING_LOOP 0
146# define DEFER_LOOP_MARK_0 0
147# define DEFER_LOOP_TST() __BLOCKSTATE_TST(DEFER_LOOP_MARK_, DEFER_LOC_LEVEL)
148# define DEFER_LOOP_INH() __BLOCKSTATE_TST(DEFER_LOOP_MARK_, __EXPAND_DEC__(DEFER_LOC_LEVEL-1))
149# define DEFER_LOOP_SET0() __BLOCKSTATE_SET0(DEFER_LOOP_MARK_, DEFER_LOC_LEVEL)
150# define DEFER_LOOP_SET1() __BLOCKSTATE_SET1(DEFER_LOOP_MARK_, DEFER_LOC_LEVEL)
151# define DEFER_LOOP_SET2() __BLOCKSTATE_SET2(DEFER_LOOP_MARK_, DEFER_LOC_LEVEL)
152# define DEFER_LOOP_SET3() __BLOCKSTATE_SET3(DEFER_LOOP_MARK_, DEFER_LOC_LEVEL)
153
154# define DEFER_CONSTRUCT_LOOP __SET1__(DEFER_CONSTRUCTING_LOOP)
155# define DEFER_CONSTRUCT_LOOP_CANCEL() __SET0__(DEFER_CONSTRUCTING_LOOP)
156
157# define DEFER_CONSTRUCT_LOOP_SHOW() __MULTI__(DEFER_CONSTRUCT_LOOP_SHOW, DEFER_CONSTRUCTING_LOOP)()DEFER_CONSTRUCT_LOOP_CANCEL()
158# define DEFER_CONSTRUCT_LOOP_SHOW_1() DEFER_SWITCH_SET0()DEFER_LOOP_SET1()
159# define DEFER_CONSTRUCT_LOOP_SHOW_0() DEFER_LOOP_UPPER_(DEFER_LOOP_INH())
160
161# define DEFER_LOOP_UPPER_(M) __MULTI__(DEFER_LOOP_UPPER, M)()
162# define DEFER_LOOP_UPPER_0() DEFER_LOOP_SET0()
163# define DEFER_LOOP_UPPER_1() DEFER_LOOP_SET1()
164# define DEFER_LOOP_UPPER_2() DEFER_LOOP_SET3()
165# define DEFER_LOOP_UPPER_3() DEFER_LOOP_SET3()
166
167# define DEFER_LOOP_START() DEFER_LOOP_START_(DEFER_LOOP_TST(), DEFER_SWITCH_TST())
168# define DEFER_LOOP_START_(M, N) __MULTI__(DEFER_LOOP_START, M, N)()
169
170# define DEFER_LOOP_START_0_0()
171# define DEFER_LOOP_START_0_1()
172# define DEFER_LOOP_START_0_2()
173# define DEFER_LOOP_START_0_3()
174
175<|
176# define DEFER_LOOP_START_1_1()
177 DEFER_LOOP_SET2()
178 ⸤register bool defer_continue_flag = false;⸥/*^*/
179|>
180
181<|
182# define DEFER_LOOP_START_1_0()
183 DEFER_LOOP_START_1_1()
184⸤register bool defer_break_flag = false;⸥/*^*/__BLOCKSTATE_SET1(DEFER_BREAK_STATE)
185|>
186
187# define DEFER_LOOP_START_1_2() DEFER_LOOP_START_1_0()
188# define DEFER_LOOP_START_1_3() DEFER_LOOP_START_1_0()
189
190# define DEFER_LOOP_START_2_0()
191# define DEFER_LOOP_START_2_1()
192# define DEFER_LOOP_START_2_2()
193# define DEFER_LOOP_START_2_3()
194
195# define DEFER_LOOP_START_3_0()
196# define DEFER_LOOP_START_3_1()
197# define DEFER_LOOP_START_3_2()
198# define DEFER_LOOP_START_3_3()
199
200# define DEFER_LOOP_END() __MULTI__(DEFER_LOOP_END, DEFER_LOOP_TST(), DEFER_MODE)()
201
202# define DEFER_LOOP_END_0_0()
203# define DEFER_LOOP_END_0_1()
204# define DEFER_LOOP_END_0_2()
205
206# define DEFER_LOOP_END_1_0() DEFER_LOOP_SET0()
207# define DEFER_LOOP_END_1_1() DEFER_LOOP_SET0()
208# define DEFER_LOOP_END_1_2() DEFER_LOOP_SET0()
209# define DEFER_LOOP_END_2_0() DEFER_LOOP_SET0()
210# define DEFER_LOOP_END_2_1() DEFER_LOOP_SET0()
211# define DEFER_LOOP_END_2_2() DEFER_LOOP_SET0()
212
213# define DEFER_LOOP_END_3_0() DEFER_LOOP_SET0()
214# define DEFER_LOOP_END_3_1() DEFER_LOOP_SET0()
215# define DEFER_LOOP_END_3_2() DEFER_LOOP_SET0()
216
217# define DEFER_SWITCH_BREAK() __MULTI__(DEFER_SWITCH_BREAK, DEFER_SWITCH_TST(), DEFER_MODE, __BLOCKSTATE_TST(DEFER_BREAK_STATE))()
218
219# define DEFER_SWITCH_BREAK_0_0_0()
220# define DEFER_SWITCH_BREAK_0_1_0()
221# define DEFER_SWITCH_BREAK_0_2_0()
222
223# define DEFER_SWITCH_BREAK_1_0_0()
224# define DEFER_SWITCH_BREAK_1_1_0()
225# define DEFER_SWITCH_BREAK_1_2_0()
226
227# define DEFER_SWITCH_BREAK_2_0_0()
228# define DEFER_SWITCH_BREAK_2_1_0()
229# define DEFER_SWITCH_BREAK_2_2_0()
230
231# define DEFER_SWITCH_BREAK_3_0_0()
232# define DEFER_SWITCH_BREAK_3_1_0() /*^*/⸤if (defer_break_flag) goto⸥ DEFER(0, 1)⸤;⸥__SET1__(DEFER_SWITCH_BREAK_SET)
233# define DEFER_SWITCH_BREAK_3_2_0() DEFER_SWITCH_BREAK_3_1_0()
234
235# define DEFER_SWITCH_BREAK_0_0_1()
236# define DEFER_SWITCH_BREAK_0_1_1()
237# define DEFER_SWITCH_BREAK_0_2_1()
238
239# define DEFER_SWITCH_BREAK_1_0_1()
240# define DEFER_SWITCH_BREAK_1_1_1()
241# define DEFER_SWITCH_BREAK_1_2_1()
242
243# define DEFER_SWITCH_BREAK_2_0_1()
244# define DEFER_SWITCH_BREAK_2_1_1() /*^*/⸤if (defer_break_flag) break;⸥__SET1__(DEFER_SWITCH_BREAK_SET)
245# define DEFER_SWITCH_BREAK_2_2_1() DEFER_SWITCH_BREAK_2_1_1()
246
247# define DEFER_SWITCH_BREAK_3_0_1()
248# define DEFER_SWITCH_BREAK_3_1_1()
249# define DEFER_SWITCH_BREAK_3_2_1()
250
251# define DEFER_LOOP_BREAK() __MULTI__(⸤DEFER_LOOP_BREAK⸥, __INSTANT__(DEFER_SWITCH_BREAK_SET), DEFER_LOOP_TST(), DEFER_MODE)()__SET0__(DEFER_SWITCH_BREAK_SET)
252
253# define DEFER_LOOP_BREAK_0_0_0()
254# define DEFER_LOOP_BREAK_0_0_1()
255# define DEFER_LOOP_BREAK_0_0_2()
256
257# define DEFER_LOOP_BREAK_0_1_0()
258# define DEFER_LOOP_BREAK_0_1_1()
259# define DEFER_LOOP_BREAK_0_1_2()
260
261# define DEFER_LOOP_BREAK_0_2_0()
262# define DEFER_LOOP_BREAK_0_2_1() /*^*/⸤if (defer_break_flag) break;⸥
263# define DEFER_LOOP_BREAK_0_2_2() DEFER_LOOP_BREAK_0_2_1()
264
265# define DEFER_LOOP_BREAK_0_3_0()
266# define DEFER_LOOP_BREAK_0_3_1() /*^*/⸤if (defer_break_flag) goto⸥ DEFER(0, 1)⸤;⸥
267# define DEFER_LOOP_BREAK_0_3_2() DEFER_LOOP_BREAK_0_3_1()
268
269# define DEFER_LOOP_BREAK_1_0_0()
270# define DEFER_LOOP_BREAK_1_0_1()
271# define DEFER_LOOP_BREAK_1_0_2()
272
273# define DEFER_LOOP_BREAK_1_1_0()
274# define DEFER_LOOP_BREAK_1_1_1()
275# define DEFER_LOOP_BREAK_1_1_2()
276
277# define DEFER_LOOP_BREAK_1_2_0()
278# define DEFER_LOOP_BREAK_1_2_1()
279# define DEFER_LOOP_BREAK_1_2_2()
280
281# define DEFER_LOOP_BREAK_1_3_0()
282# define DEFER_LOOP_BREAK_1_3_1()
283# define DEFER_LOOP_BREAK_1_3_2()
284
285# define DEFER_LOOP_CONTINUE() __MULTI__(⸤DEFER_LOOP_CONTINUE⸥, DEFER_LOOP_TST(), DEFER_MODE)()
286
287# define DEFER_LOOP_CONTINUE_0_0()
288# define DEFER_LOOP_CONTINUE_0_1()
289# define DEFER_LOOP_CONTINUE_0_2()
290
291# define DEFER_LOOP_CONTINUE_1_0()
292# define DEFER_LOOP_CONTINUE_1_1()
293# define DEFER_LOOP_CONTINUE_1_2()
294
295# define DEFER_LOOP_CONTINUE_2_0()
296# define DEFER_LOOP_CONTINUE_2_1() /*^*/⸤if (defer_continue_flag) continue;⸥
297# define DEFER_LOOP_CONTINUE_2_2() DEFER_LOOP_CONTINUE_2_1()
298
299# define DEFER_LOOP_CONTINUE_3_0()
300# define DEFER_LOOP_CONTINUE_3_1() /*^*/⸤if (defer_continue_flag) goto⸥ DEFER(0, 1)⸤;⸥
301# define DEFER_LOOP_CONTINUE_3_2() DEFER_LOOP_CONTINUE_3_1()
302
303# define DEFER_LOOP_LEVEL 0
304# define DEFER_LOOP_LEVEL_UP DEFER_LOOP_LEVEL_UP_(DEFER_LOOP_LEVEL)
305# define DEFER_LOOP_LEVEL_UP_(L) DEFER_LOOP_LEVEL_UP__(DEFER_LOOP_LEVEL_UP_ ⨝ L,,)
306# define DEFER_LOOP_LEVEL_UP__(…) DEFER_LOOP_LEVEL_UP___(__VA_ARGS__)
307# define DEFER_LOOP_LEVEL_UP___(X, Y, …) Y
308
309# define DEFER_CONSTRUCTING_SWITCH 0
310# define DEFER_SWITCH_MARK_0 0
311# define DEFER_SWITCH_TST() __BLOCKSTATE_TST(DEFER_SWITCH_MARK_, DEFER_LOC_LEVEL)
312# define DEFER_SWITCH_INH() __BLOCKSTATE_TST(DEFER_SWITCH_MARK_, __EXPAND_DEC__(DEFER_LOC_LEVEL-1))
313# define DEFER_SWITCH_SET0() __BLOCKSTATE_SET0(DEFER_SWITCH_MARK_, DEFER_LOC_LEVEL)
314# define DEFER_SWITCH_SET1() __BLOCKSTATE_SET1(DEFER_SWITCH_MARK_, DEFER_LOC_LEVEL)
315# define DEFER_SWITCH_SET2() __BLOCKSTATE_SET2(DEFER_SWITCH_MARK_, DEFER_LOC_LEVEL)
316# define DEFER_SWITCH_SET3() __BLOCKSTATE_SET3(DEFER_SWITCH_MARK_, DEFER_LOC_LEVEL)
317
318# define DEFER_CONSTRUCT_SWITCH __SET1__(DEFER_CONSTRUCTING_SWITCH)
319# define DEFER_CONSTRUCT_SWITCH_CANCEL() __SET0__(DEFER_CONSTRUCTING_SWITCH)
320
321# define DEFER_CONSTRUCT_SWITCH_SHOW() __MULTI__(DEFER_CONSTRUCT_SWITCH_SHOW, DEFER_CONSTRUCTING_SWITCH)()DEFER_CONSTRUCT_SWITCH_CANCEL()
322# define DEFER_CONSTRUCT_SWITCH_SHOW_1() DEFER_SWITCH_SET1()
323# define DEFER_CONSTRUCT_SWITCH_SHOW_0() DEFER_SWITCH_UPPER(DEFER_SWITCH_INH())
324
325# define DEFER_SWITCH_UPPER(M) __MULTI__(DEFER_SWITCH_UPPER, M)()
326# define DEFER_SWITCH_UPPER_0() DEFER_SWITCH_SET0()
327# define DEFER_SWITCH_UPPER_1() DEFER_SWITCH_SET1()
328# define DEFER_SWITCH_UPPER_2() DEFER_SWITCH_SET3()
329# define DEFER_SWITCH_UPPER_3() DEFER_SWITCH_SET3()
330
331# define DEFER_SWITCH_START() __MULTI__(DEFER_SWITCH_START, DEFER_SWITCH_TST())()
332# define DEFER_SWITCH_START_0()
333# define DEFER_SWITCH_START_1() DEFER_SWITCH_SET2()⸤register bool defer_break_flag = false;⸥/*^*/__BLOCKSTATE_SET1(DEFER_BREAK_STATE)
334# define DEFER_SWITCH_START_2()
335# define DEFER_SWITCH_START_3()
336
337# define DEFER_SWITCH_END() __MULTI__(DEFER_SWITCH_END, DEFER_SWITCH_TST(), DEFER_MODE)()
338
339# define DEFER_SWITCH_END_0_0()
340# define DEFER_SWITCH_END_0_1()
341# define DEFER_SWITCH_END_0_2()
342
343# define DEFER_SWITCH_END_1_0() DEFER_SWITCH_SET0()
344# define DEFER_SWITCH_END_1_1() DEFER_SWITCH_SET0()
345# define DEFER_SWITCH_END_1_2() DEFER_SWITCH_SET0()
346# define DEFER_SWITCH_END_2_0() DEFER_SWITCH_SET0()
347# define DEFER_SWITCH_END_2_1() DEFER_SWITCH_SET0()
348# define DEFER_SWITCH_END_2_2() DEFER_SWITCH_SET0()
349
350# define DEFER_SWITCH_END_3_0() DEFER_SWITCH_SET0()
351# define DEFER_SWITCH_END_3_1() DEFER_SWITCH_SET0()
352# define DEFER_SWITCH_END_3_2() DEFER_SWITCH_SET0()
353
354# ifndef do
355# define do do
356# endif
357# ifndef while
358# define while while
359# endif
360# ifndef switch
361# define switch switch
362# endif
363# ifndef for
364# define for for
365# endif
366# ifndef if
367# define if if
368# endif
369# ifndef else
370# define else else
371# endif
372
373define _DEFER_REPLAY_FOR(...) DEFER_CONSTRUCT_SWITCH_CANCEL()DEFER_CONSTRUCT_LOOP ELLIPSIS_FORCEBRACE(__VA_ARGS__)
374define _DEFER_REPLAY_WHILE(...) DEFER_CONSTRUCT_SWITCH_CANCEL()DEFER_CONSTRUCT_LOOP ELLIPSIS_FORCEBRACE_WHILE(__VA_ARGS__)
375define _DEFER_REPLAY_SWITCH(...) DEFER_CONSTRUCT_LOOP_CANCEL()DEFER_CONSTRUCT_SWITCH ELLIPSIS_FORCEBRACE(__VA_ARGS__)
376
377# bind _DEFER_FOR _DEFER_REPLAY_FOR
378# bind _DEFER_WHILE _DEFER_REPLAY_WHILE
379# bind _DEFER_SWITCH _DEFER_REPLAY_SWITCH
380bind _DEFER_DO DEFER_CONSTRUCT_SWITCH_CANCEL()DEFER_CONSTRUCT_LOOP ELLIPSIS_FORCEBRACE_DO
381
382# gather for _DEFER_FOR
383# gather while _DEFER_WHILE
384# gather switch _DEFER_SWITCH
385# gather do _DEFER_DO
386
387
388# define DEFER_TMP DEFER_CONSTRUCT_SWITCH_CANCEL()DEFER_CONSTRUCT_LOOP_CANCEL()
389# gather ; DEFER_TMP
390# undef DEFER_TMP
391
392# define DEFER_TMP DEFER_RETURN_DONE()
393# gather DEFER_TMP ;
394# gather ; DEFER_TMP
395# undef DEFER_TMP
396
397# define DEFER_TMP DEFER_CONSTRUCT_SWITCH_SHOW() DEFER_CONSTRUCT_LOOP_SHOW()
398# gather { DEFER_TMP
399# undef DEFER_TMP
400
401# define DEFER_TMP DEFER_CONSTRUCT_SWITCH_CANCEL()DEFER_CONSTRUCT_LOOP_CANCEL()
402# gather DEFER_TMP if
403# gather if DEFER_TMP
404# undef DEFER_TMP
405
406# define DEFER_TMP DEFER_CONSTRUCT_SWITCH_CANCEL()DEFER_CONSTRUCT_LOOP_CANCEL()
407# gather DEFER_TMP else
408# gather else DEFER_TMP
409# undef DEFER_TMP
410
411<|
412#define DEFER_RETURN_TO() ELLIPSIS_MARK_LINE⸤do {⸥
414/*^*/ELLIPSIS_MARK_LINE⸤defer_return_flag = true;⸥
415/*^*/ELLIPSIS_MARK_LINE DEFER_MODIFIABLE =
416__BLOCKSTATE_SET1(DEFER_RETURN_STATE)ELLIPSIS_MARK_LINE
417|>
418
419#define DEFER_RETURN_DONE() DEFER_RETURN_DONE_(__BLOCKSTATE_TST(DEFER_RETURN_STATE))
420#define DEFER_RETURN_DONE_(S) __MULTI__(DEFER_RETURN_DONE, S)()
421
422<|
423#define DEFER_RETURN_DONE_1() ⸤;⸥
424/*^*/ELLIPSIS_MARK_LINE defer_skip⸤;⸥
425/*^*/ELLIPSIS_MARK_LINE⸤} while(false)⸥__BLOCKSTATE_SET0(DEFER_RETURN_STATE)
426|>
427
428#define DEFER_RETURN_DONE_0()
429
430#define DEFER_TRIGGER_START(TARGET, LOCATION) DEFER_TRIGGER_START_(TARGET, LOCATION)
431
432<|
433#define DEFER_TRIGGER_START_(TARGET, LOCATION)
434 ⸤[[__maybe_unused__, __deprecated__("dummy variable for better diagnostics")]]⸥
435 /*^*/⸤unsigned⸥ (*DEFER_LOC_NEW)⸤[⸥DEFER_ONE⸤]⸥ ⸤= {};⸥
436 /*^*/⸤if (false) {⸥
437 /*^*/ELLIPSIS_MARK_LINE/*>*/LOCATION⸤: {⸥
438 /*^*/ELLIPSIS_MARK_LINE/*>*/⸤[[__maybe_unused__, __deprecated__("invalid termination of a deferred block")]]⸥
439 /*^*/ELLIPSIS_MARK_LINE/*>*/⸤register bool const defer_return_flag = false, defer_break_flag = false, defer_continue_flag = false;⸥
441|>
442
443<|
444# define DEFER_TRIGGER_CLOSE()
445 /*^*/ELLIPSIS_MARK_LINE/*>*/⸤}⸥
446 DEFER_SWITCH_BREAK()DEFER_LOOP_BREAK()DEFER_LOOP_CONTINUE()DEFER_RET⸤⸥__BLOCKSTATE_SET0(DEFER_BREAK_STATE)
447 /*^*/ELLIPSIS_MARK_LINE⸤goto⸥ DEFER_DONE()⸤;⸥
448 /*^*/⸤} else⸥ DEFER_OPENBR()
449 /*^*/⸤(void)0⸥ /*^ ⸤defer needs braces and a semicolon⸥ ^*/
450|>
451
452# define defer_break_down() ⸤break⸥
453
454<|
455# define defer_break_up()
456/*^*/⸤do {⸥
457/*^*/ ⸤defer_break_flag = true;⸥
458/*^*/ defer_skip⸤;⸥
459/*^*/⸤} while(false)⸥
460|>
461
462# define defer_break_(ML, MS) __MULTI__(defer_break, ML, MS)()
463# define defer_break_0_0() defer_break_down()
464# define defer_break_0_1() defer_break_down()
465# define defer_break_1_0() defer_break_down()
466# define defer_break_1_1() defer_break_down()
467# define defer_break_2_1() defer_break_down()
468# define defer_break_3_1() defer_break_down()
469
470# define defer_break_0_2() defer_break_up()
471# define defer_break_0_3() defer_break_up()
472# define defer_break_1_2() defer_break_up()
473# define defer_break_1_3() defer_break_up()
474# define defer_break_2_0() defer_break_up()
475# define defer_break_2_2() defer_break_up()
476# define defer_break_2_3() defer_break_up()
477# define defer_break_3_0() defer_break_up()
478# define defer_break_3_2() defer_break_up()
479# define defer_break_3_3() defer_break_up()
480
481# define defer_continue(X) __MULTI__(defer_continue, X)()
482# define defer_continue_0() ⸤continue⸥
483# define defer_continue_1() ⸤continue⸥
484
485<|
486# define defer_continue_2()
487/*^*/⸤do {⸥
488/*^*/ ⸤defer_continue_flag = true;⸥
489/*^*/ defer_skip⸤;⸥
490/*^*/⸤} while(false)⸥
491|>
492
493# define defer_continue_3() defer_continue_2()
494
495
496# endif
497
498# define DEFER_MODE 0
499
500<|
501# define DEFER_TYPE(...)
505 /*>*/⸤typeof(__VA_ARGS__)⸥ DEFER_MODIFIABLE⸤;⸥
506 /*^*/⸤if (__func__[0] ≡ 'm' ∧ __func__[1] ≡ 'a' ∧ __func__[2] ≡ 'i' ∧ __func__[3] ≡ 'n' ∧ ¬__func__[4]) {⸥
507 /*^*/ DEFER_MODIFIABLE ⸤= (typeof(__VA_ARGS__)){};⸥
508 /*^*/ ⸤}⸥
509 )
510 /*^*/⸤[[__maybe_unused__]] register unsigned⸥ DEFER_ONE ⸤= 1U;⸥
511 /*^*/⸤[[__maybe_unused__]] register bool defer_return_flag = false;⸥
512 /*^*/DEFER_DEF()DEFER_TOP
513|>
514
515# define defer_return_value ((typeof(DEFER_MODIFIABLE))DEFER_MODIFIABLE)
516
517# define defer_skip goto DEFER()
518
519# define return defer_return(DEFER_MODE)
520
521# define break defer_break_(DEFER_LOOP_TST(), DEFER_SWITCH_TST())
522# define continue defer_continue(DEFER_LOOP_TST())
523
524# define defer /*>*//*^*//*>*/DEFER_DEF()DEFER_TRIGGER(DEFER_DO(), DEFER_NEW)
__directive__ define
The define directive as specified by the C standard.
Definition directives.c:33
__directive__ bind
A local equivalent to #define.
Definition directives.c:162
#define __BLOCKSTATE_SET1(NAME,...)
Set the brace-level-specific variable with name NAME to 1.
Definition ellipsis-blockstate.h:8
#define __BLOCKSTATE_SET0(NAME,...)
Set the brace-level-specific variable with name NAME to 0.
Definition ellipsis-blockstate.h:7
#define __SET1__(...)
Set the value of a macro holding an integer to 1.
Definition ellipsis-builtins.dirs:68
#define __SET2__(...)
Set the value of a macro holding an integer to 2.
Definition ellipsis-builtins.dirs:69
#define false
The constant false made accessible to the preprocessor.
Definition ellipsis-builtins.dirs:33
#define __SET0__(...)
Set the value of a macro holding an integer to 0.
Definition ellipsis-builtins.dirs:67
#define DEFER_MODE
The mode of the defer feature for the current function.
Definition ellipsis-defer.h:498
#define ELLIPSIS_MARK_LINE
A hook to add code that puts line number information into the output stream.
Definition ellipsis-environment.dirs:64
#define ELLIPSIS_FORCEBRACE
Definition ellipsis-forcebrace.h:5
#define __VA_OPT__
A pseudo macro that cannot be redefined.
Definition ellipsis-predefined.dirs:89