本文整理汇总了C++中CBotStack::AddStack2方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotStack::AddStack2方法的具体用法?C++ CBotStack::AddStack2怎么用?C++ CBotStack::AddStack2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotStack
的用法示例。
在下文中一共展示了CBotStack::AddStack2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
bool CBotInstrCall::Execute(CBotStack* &pj)
{
CBotVar* ppVars[1000];
CBotStack* pile = pj->AddStack(this);
if ( pile->StackOver() ) return pj->Return( pile );
CBotStack* pile3 = nullptr;
if (m_exprRetVar != nullptr) // func().member
{
pile3 = pile->AddStack2();
if (pile3->GetState() == 1) // function call is done?
{
if (!m_exprRetVar->Execute(pile3)) return false;
return pj->Return(pile3);
}
}
// CBotStack* pile1 = pile;
int i = 0;
CBotInstr* p = m_parameters;
// evaluates parameters
// and places the values on the stack
// for allow of interruption at any time
if ( p != nullptr) while ( true )
{
pile = pile->AddStack(); // place on the stack for the results
if ( pile->GetState() == 0 )
{
if (!p->Execute(pile)) return false; // interrupted here?
pile->SetState(1); // set state to remember that parameters were executed
}
ppVars[i++] = pile->GetVar();
p = p->GetNext();
if ( p == nullptr) break;
}
ppVars[i] = nullptr;
CBotStack* pile2 = pile->AddStack();
if ( pile2->IfStep() ) return false;
if ( !pile2->ExecuteCall(m_nFuncIdent, GetToken(), ppVars, m_typRes)) return false; // interrupt
if (m_exprRetVar != nullptr) // func().member
{
pile3->SetCopyVar( pile2->GetVar() ); // copy the result
pile2->SetVar(nullptr);
pile3->SetState(1); // set call is done
return false; // go back to the top ^^^
}
return pj->Return(pile2); // release the entire stack
}
示例2: RestoreState
void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
{
if ( !bMain ) return;
CBotStack* pile = pj->RestoreStack(this);
if ( pile == nullptr ) return;
if (m_exprRetVar != nullptr) // func().member
{
CBotStack* pile3 = pile->AddStack2();
if (pile3->GetState() == 1) // function call is done?
{
m_exprRetVar->RestoreState(pile3, bMain);
return;
}
}
// CBotStack* pile1 = pile;
int i = 0;
CBotVar* ppVars[1000];
CBotInstr* p = m_parameters;
// evaluate parameters
// and place the values on the stack
// for allow of interruption at any time
if ( p != nullptr) while ( true )
{
pile = pile->RestoreStack(); // place on the stack for the results
if ( pile == nullptr ) return;
if ( pile->GetState() == 0 )
{
p->RestoreState(pile, bMain); // interrupt here!
return;
}
ppVars[i++] = pile->GetVar(); // constructs the list of parameters
p = p->GetNext();
if ( p == nullptr) break;
}
ppVars[i] = nullptr;
CBotStack* pile2 = pile->RestoreStack();
if ( pile2 == nullptr ) return;
pile2->RestoreCall(m_nFuncIdent, GetToken(), ppVars);
}