Пример #1
0
void Parser::IncludedFile::WalkThrough::enter_conditional_chain(CondChain *cc)
{
	CListEntry *i, *j;
#if SANITY_CHECK
	unsigned sum = 0;
	unsigned has_else = 0;
#endif

	if(method == MED_BF && on_conditional_chain_callback)
		on_conditional_chain_callback(context, cc);
	for(i = cc->chain.next; i != &cc->chain; i = j) {
		j = i->next;
		Cond *c = container_of(i, Cond, link);
#if SANITY_CHECK
		sum += c->value;
		has_else += (c->type == Cond::CT_ELSE);
#endif
		c->sanity_check();
		enter_conditional(c);
	}
#if SANITY_CHECK
	char emsg[256] = {0x1} ;
	if(sum > 1)
		snprintf(emsg, sizeof(emsg), "Has %u true conditionals", sum);
	if(has_else && sum != 1)
		snprintf(emsg, sizeof(emsg), "A chain with else has %u true conditionals", sum);
	if(emsg[0] != '\x1')
		dump_and_exit(cc, emsg);
#endif
	if(method == MED_DF && on_conditional_chain_callback)
		on_conditional_chain_callback(context, cc);
}