本文整理汇总了C++中CBotStack::IfContinue方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotStack::IfContinue方法的具体用法?C++ CBotStack::IfContinue怎么用?C++ CBotStack::IfContinue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotStack
的用法示例。
在下文中一共展示了CBotStack::IfContinue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
bool CBotWhile::Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this); // adds an item to the stack
// or find in case of recovery
// if ( pile == EOX ) return true;
if ( pile->IfStep() ) return false;
while( true ) switch( pile->GetState() ) // executes the loop
{ // there are two possible states (depending on recovery)
case 0:
// evaluates the condition
if ( !m_condition->Execute(pile) ) return false; // interrupted here?
// the result of the condition is on the stack
// terminates if an error or if the condition is false
if ( !pile->IsOk() || pile->GetVal() != true )
{
return pj->Return(pile); // sends the results and releases the stack
}
// the condition is true, pass in the second mode
if (!pile->SetState(1)) return false; // ready for further
case 1:
// evaluates the associated statement block
if (m_block != nullptr &&
!m_block->Execute(pile) )
{
if (pile->IfContinue(0, m_label)) continue; // if continued, will return to test
return pj->BreakReturn(pile, m_label); // sends the results and releases the stack
}
// terminates if there is an error
if ( !pile->IsOk() )
{
return pj->Return(pile); // sends the results and releases the stack
}
// returns to the test again
if (!pile->SetState(0, 0)) return false;
continue;
}
}
示例2: Execute
bool CBotFor :: Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this, true); // adds an item to the stack (variables locales)
// or find in case of recovery
// if ( pile == EOX ) return true;
if ( pile->IfStep() ) return false;
while( true ) switch( pile->GetState() ) // executes the loop
{ // there are four possible states (depending on recovery)
case 0:
// initialize
if ( m_Init != nullptr &&
!m_Init->Execute(pile) ) return false; // interrupted here ?
if (!pile->SetState(1)) return false; // ready for further
case 1:
// evaluates the condition
if ( m_Test != nullptr ) // no strings attached? -> True!
{
if (!m_Test->Execute(pile) ) return false; // interrupted here ?
// the result of the condition is on the stack
// terminates if an error or if the condition is false
if ( !pile->IsOk() || pile->GetVal() != true )
{
return pj->Return(pile); // sends the results and releases the stack
}
}
// la condition est vrai, passe à la suite
if (!pile->SetState(2)) return false; // ready for further
case 2:
// evaluates the associated statement block
if ( m_Block != nullptr &&
!m_Block->Execute(pile) )
{
if (pile->IfContinue(3, m_label)) continue; // if continued, going on to incrementation
return pj->BreakReturn(pile, m_label); // sends the results and releases the stack
}
// terminates if there is an error
if ( !pile->IsOk() )
{
return pj->Return(pile); // sends the results and releases the stack
}
if (!pile->SetState(3)) return false; // ready for further
case 3:
// evalutate the incrementation
if ( m_Incr != nullptr &&
!m_Incr->Execute(pile) ) return false; // interrupted here ?
// returns to the test again
if (!pile->SetState(1, 0)) return false; // returns to the test
continue;
}
}