@@ -34,6 +34,7 @@ struct ConditionalCodeWrapper
3434 immutable (Formula)* currentCondition;
3535 StringType currentStringType;
3636 bool forceExpression;
37+ bool active;
3738
3839 enum StringType
3940 {
@@ -51,6 +52,7 @@ struct ConditionalCodeWrapper
5152 }
5253
5354 void add (string prefix, string suffix, immutable (Formula)* condition)
55+ in (! active)
5456 {
5557 {
5658 string [] newData;
@@ -152,6 +154,7 @@ struct ConditionalCodeWrapper
152154 }
153155
154156 void checkTree (Tree tree, bool allowNonArrayPPIf)
157+ in (! active)
155158 {
156159 if (allowNonArrayPPIfSet)
157160 assert (this .allowNonArrayPPIf == allowNonArrayPPIf);
@@ -176,13 +179,15 @@ struct ConditionalCodeWrapper
176179 }
177180
178181 void checkTree (Tree[] trees, bool allowNonArrayPPIf)
182+ in (! active)
179183 {
180184 foreach (c; trees)
181185 checkTree(c, allowNonArrayPPIf);
182186 }
183187
184188 void changeCurrentCondition (ref CodeWriter code,
185189 immutable (Formula)* condition, StringType stringType)
190+ in (active)
186191 {
187192 if (condition ! is currentCondition || stringType != currentStringType)
188193 {
@@ -221,7 +226,10 @@ struct ConditionalCodeWrapper
221226 }
222227
223228 void begin (ref CodeWriter code, immutable (Formula)* condition)
229+ in (! active)
224230 {
231+ active = true ;
232+
225233 size_t outI;
226234 foreach (i, e; conditionMapPrefix.entries)
227235 {
@@ -302,6 +310,7 @@ struct ConditionalCodeWrapper
302310 }
303311
304312 void end (ref CodeWriter code, immutable (Formula)* condition)
313+ in (active)
305314 {
306315 if (! alwaysUseMixin && conditionMapPrefix.entries.length == 1
307316 && conditionMapSuffix.entries.length == 1 )
@@ -349,10 +358,12 @@ struct ConditionalCodeWrapper
349358 if (forceExpression)
350359 code.write(" )" );
351360 }
361+ active = false ;
352362 }
353363
354364 void writeTree (ref CodeWriter code, scope void delegate (Tree,
355365 immutable (Formula)* ) F, Tree tree, immutable (Formula)* condition)
366+ in (active)
356367 {
357368 if (! tree.isValid)
358369 return ;
@@ -393,18 +404,21 @@ struct ConditionalCodeWrapper
393404 }
394405
395406 void writeTree (ref CodeWriter code, scope void delegate (Tree, immutable (Formula)* ) F, Tree tree)
407+ in (active)
396408 {
397409 writeTree(code, F, tree, firstCondition);
398410 }
399411
400412 void writeTree (ref CodeWriter code, scope void delegate (Tree,
401413 immutable (Formula)* ) F, Tree[] trees)
414+ in (active)
402415 {
403416 foreach (c; trees)
404417 writeTree(code, F, c);
405418 }
406419
407420 void writeString (ref CodeWriter code, string s)
421+ in (active)
408422 {
409423 changeCurrentCondition(code, firstCondition, StringType.string );
410424 code.write(s);
0 commit comments