本文整理汇总了C++中CBotStack::SetError方法的典型用法代码示例。如果您正苦于以下问题:C++ CBotStack::SetError方法的具体用法?C++ CBotStack::SetError怎么用?C++ CBotStack::SetError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBotStack
的用法示例。
在下文中一共展示了CBotStack::SetError方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
{
CBotStack* pile = pj->AddStack(this, 2); // one end of stack local to this function
// if ( pile == EOX ) return true;
pile->SetBotCall(m_pProg); // bases for routines
if ( pile->GetState() == 0 )
{
if ( !m_Param->Execute(ppVars, pile) ) return false; // define parameters
pile->IncState();
}
if ( pile->GetState() == 1 && !m_MasterClass.IsEmpty() )
{
// makes "this" known
CBotVar* pThis ;
if ( pInstance == NULL )
{
pThis = CBotVar::Create("this", CBotTypResult( CBotTypClass, m_MasterClass ));
pThis->SetInit(2);
}
else
{
pThis = CBotVar::Create("this", CBotTypResult( CBotTypPointer, m_MasterClass ));
pThis->SetPointer(pInstance);
pThis->SetInit(2);
}
// pThis->SetUniqNum(m_nThisIdent);
pThis->SetUniqNum(-2);
pile->AddVar(pThis);
pile->IncState();
}
if ( pile->IfStep() ) return false;
if ( !m_Block->Execute(pile) )
{
if ( pile->GetError() < 0 )
pile->SetError( 0 );
else
return false;
}
return pj->Return(pile);
}
示例2: 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 );
}
示例3: Execute
bool CBotLeftExpr::Execute(CBotStack* &pj, CBotStack* array)
{
CBotStack* pile = pj->AddStack();
CBotVar* var1 = nullptr;
CBotVar* var2 = nullptr;
// fetch a variable (not copy)
if (!ExecuteVar(var1, array, nullptr, false)) return false;
if (pile->IfStep()) return false;
if (var1)
{
var2 = pj->GetVar(); // result on the input stack
if (var2)
{
CBotTypResult t1 = var1->GetTypResult();
CBotTypResult t2 = var2->GetTypResult();
if (t2.Eq(CBotTypPointer))
{
CBotClass* c1 = t1.GetClass();
CBotClass* c2 = var2->GetClass();
if ( !c2->IsChildOf(c1))
{
CBotToken* pt = &m_token;
pile->SetError(CBotErrBadType1, pt);
return pj->Return(pile); // operation performed
}
var1->SetVal(var2); // set pointer
var1->SetType(t1); // keep pointer type
}
else
var1->SetVal(var2); // do assignment
}
pile->SetCopyVar(var1); // replace the stack with the copy of the variable
// (for name)
}
return pj->Return(pile); // operation performed
}
示例4: Execute
bool CBotClassInst::Execute(CBotStack* &pj)
{
CBotVar* pThis = NULL;
CBotStack* pile = pj->AddStack(this);//essential for SetState()
// if ( pile == EOX ) return true;
CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt);
bool bIntrincic = pClass->IsIntrinsic();
// creates the variable of type pointer to the object
if ( pile->GetState()==0)
{
CBotString name = m_var->m_token.GetString();
if ( bIntrincic )
{
pThis = CBotVar::Create(name, CBotTypResult( CBotTypIntrinsic, pClass ));
}
else
{
pThis = CBotVar::Create(name, CBotTypResult( CBotTypPointer, pClass ));
}
pThis->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); // its attribute as unique number
pile->AddVar(pThis); // place on the stack
pile->IncState();
}
if ( pThis == NULL ) pThis = pile->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
if ( pile->GetState()<3)
{
// ss there an assignment or parameters (contructor)
// CBotVarClass* pInstance = NULL;
if ( m_expr != NULL )
{
// evaluates the expression for the assignment
if (!m_expr->Execute(pile)) return false;
if ( bIntrincic )
{
CBotVar* pv = pile->GetVar();
if ( pv == NULL || pv->GetPointer() == NULL )
{
pile->SetError(TX_NULLPT, &m_token);
return pj->Return(pile);
}
pThis->Copy(pile->GetVar(), false);
}
else
{
CBotVarClass* pInstance;
pInstance = (static_cast<CBotVarPointer*>(pile->GetVar()))->GetPointer(); // value for the assignment
pThis->SetPointer(pInstance);
}
pThis->SetInit(true);
}
else if ( m_hasParams )
{
// evaluates the constructor of an instance
if ( !bIntrincic && pile->GetState() == 1)
{
CBotToken* pt = &m_token;
CBotClass* pClass = CBotClass::Find(pt);
// creates an instance of the requested class
CBotVarClass* pInstance;
pInstance = static_cast<CBotVarClass*>(CBotVar::Create("", pClass));
pThis->SetPointer(pInstance);
delete pInstance;
pile->IncState();
}
CBotVar* ppVars[1000];
CBotStack* pile2 = pile;
int i = 0;
CBotInstr* p = m_Parameters;
// evaluates the parameters
// and places the values on the stack
// to (can) be interrupted (broken) at any time
if ( p != NULL) while ( true )
{
pile2 = pile2->AddStack(); // place on the stack for the results
if ( pile2->GetState() == 0 )
{
if (!p->Execute(pile2)) return false; // interrupted here?
pile2->SetState(1);
}
//.........这里部分代码省略.........
示例5: Execute
bool CBotDefArray::Execute(CBotStack* &pj)
{
CBotStack* pile1 = pj->AddStack(this);
CBotStack* pile = pile1;
if (pile1->GetState() == 0)
{
// seek the maximum dimension of the table
CBotInstr* p = GetNext3b(); // the different formulas
int nb = 0;
while (p != nullptr)
{
pile = pile->AddStack(); // little room to work
nb++;
if (pile->GetState() == 0)
{
if (!p->Execute(pile)) return false; // size calculation //interrupted?
pile->IncState();
}
p = p->GetNext3b();
}
p = GetNext3b();
pile = pile1; // returns to the stack
int n = 0;
int max[100];
while (p != nullptr)
{
pile = pile->AddStack();
CBotVar* v = pile->GetVar(); // result
max[n] = v->GetValInt(); // value
if (max[n]>MAXARRAYSIZE)
{
pile->SetError(CBotErrOutArray, &m_token);
return pj->Return (pile);
}
n++;
p = p->GetNext3b();
}
while (n<100) max[n++] = 0;
m_typevar.SetArray(max); // store the limitations
// create simply a nullptr pointer
CBotVar* var = CBotVar::Create(*(m_var->GetToken()), m_typevar);
var->SetPointer(nullptr);
var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
pj->AddVar(var);
#if STACKMEM
pile1->AddStack()->Delete();
#else
delete pile1->AddStack(); // need more indices
#endif
pile1->IncState();
}
if (pile1->GetState() == 1)
{
if (m_listass != nullptr) // there is the assignment for this table
{
CBotVar* pVar = pj->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent, false);
if (!m_listass->Execute(pile1, pVar)) return false;
}
pile1->IncState();
}
if (pile1->IfStep()) return false;
if ( m_next2b &&
!m_next2b->Execute(pile1 )) return false;
return pj->Return(pile1);
}