本文整理汇总了C++中CBotStack::GetVal方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotStack::GetVal方法的具体用法?C++ CBotStack::GetVal怎么用?C++ CBotStack::GetVal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotStack
的用法示例。
在下文中一共展示了CBotStack::GetVal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RestoreState
void CBotIf :: RestoreState(CBotStack* &pj, bool bMain)
{
if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this); // adds an item to the stack
if ( pile == nullptr ) return;
// according to recovery, it may be in one of two states
if( pile->GetState() == 0 )
{
// evaluates the condition
m_condition->RestoreState(pile, bMain); // interrupted here!
return;
}
// second state, evaluates the associated instructions
// the result of the condition is on the stack
if ( pile->GetVal() == true ) // condition was true?
{
if (m_block != nullptr ) // block may be absent
m_block->RestoreState(pile, bMain); // interrupted here!
}
else
{
if (m_blockElse != nullptr ) // if there is an alternate block
m_blockElse->RestoreState(pile, bMain); // interrupted here!
}
}
示例2: 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;
}
}
示例3: Execute
bool CBotThrow :: Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this);
// if ( pile == EOX ) return true;
if ( pile->GetState() == 0 )
{
if ( !m_Value->Execute(pile) ) return false;
pile->IncState();
}
if ( pile->IfStep() ) return false;
int val = pile->GetVal();
if ( val < 0 ) val = TX_BADTHROW;
pile->SetError( val, &m_token );
return pj->Return( pile );
}
示例4: Execute
bool CBotIf :: Execute(CBotStack* &pj)
{
CBotStack* pile = pj->AddStack(this); // adds an item to the stack
// or found in case of recovery
// if ( pile == EOX ) return true;
if ( pile->IfStep() ) return false;
// according to recovery, it may be in one of two states
if( pile->GetState() == 0 )
{
// evaluates the condition
if ( !m_condition->Execute(pile) ) return false; // interrupted here?
// terminates if there is an error
if ( !pile->IsOk() )
{
return pj->Return(pile); // returns the results and releases the stack
}
// passes into the second state
if (!pile->SetState(1)) return false; // ready for further
}
// second state, evaluates the associated instructions
// the result of the condition is on the stack
if ( pile->GetVal() == true ) // condition was true?
{
if (m_block != nullptr && // block may be absent
!m_block->Execute(pile) ) return false; // interrupted here?
}
else
{
if (m_blockElse != nullptr && // if there is an alternate block
!m_blockElse->Execute(pile) ) return false; // interrupted here
}
// sends the results and releases the stack
return pj->Return(pile);
}