Fix RestoreMethode when calling inherited methods
parent
397e312424
commit
d0a8a32a57
|
@ -368,7 +368,14 @@ void CBotClass::RestoreMethode(long& nIdent,
|
||||||
CBotVar** ppParams,
|
CBotVar** ppParams,
|
||||||
CBotStack*& pStack)
|
CBotStack*& pStack)
|
||||||
{
|
{
|
||||||
m_pMethod->RestoreCall(nIdent, name, pThis, ppParams, pStack, this);
|
CBotClass* pClass = this;
|
||||||
|
while (pClass != nullptr)
|
||||||
|
{
|
||||||
|
bool ok = pClass->m_pMethod->RestoreCall(nIdent, name, pThis, ppParams, pStack, pClass);
|
||||||
|
if (ok) return;
|
||||||
|
pClass = pClass->m_parent;
|
||||||
|
}
|
||||||
|
assert(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -801,7 +801,7 @@ int CBotFunction::DoCall(long& nIdent, const std::string& name, CBotVar* pThis,
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotFunction::RestoreCall(long& nIdent, const std::string& name, CBotVar* pThis, CBotVar** ppVars,
|
bool CBotFunction::RestoreCall(long& nIdent, const std::string& name, CBotVar* pThis, CBotVar** ppVars,
|
||||||
CBotStack* pStack, CBotClass* pClass)
|
CBotStack* pStack, CBotClass* pClass)
|
||||||
{
|
{
|
||||||
CBotTypResult type;
|
CBotTypResult type;
|
||||||
|
@ -810,14 +810,20 @@ void CBotFunction::RestoreCall(long& nIdent, const std::string& name, CBotVar* p
|
||||||
if ( pt != nullptr )
|
if ( pt != nullptr )
|
||||||
{
|
{
|
||||||
CBotStack* pStk = pStack->RestoreStack(pt);
|
CBotStack* pStk = pStack->RestoreStack(pt);
|
||||||
if ( pStk == nullptr ) return;
|
if ( pStk == nullptr ) return true;
|
||||||
pStk->SetProgram(pt->m_pProg); // it may have changed module
|
pStk->SetProgram(pt->m_pProg); // it may have changed module
|
||||||
|
|
||||||
CBotVar* pthis = pStk->FindVar("this");
|
CBotVar* pthis = pStk->FindVar("this");
|
||||||
pthis->SetUniqNum(-2);
|
pthis->SetUniqNum(-2);
|
||||||
|
|
||||||
|
if (pClass->GetParent() != nullptr)
|
||||||
|
{
|
||||||
|
CBotVar* psuper = pStk->FindVar("super");
|
||||||
|
if (psuper != nullptr) psuper->SetUniqNum(-3);
|
||||||
|
}
|
||||||
|
|
||||||
CBotStack* pStk3 = pStk->RestoreStack(nullptr); // to set parameters passed
|
CBotStack* pStk3 = pStk->RestoreStack(nullptr); // to set parameters passed
|
||||||
if ( pStk3 == nullptr ) return;
|
if ( pStk3 == nullptr ) return true;
|
||||||
|
|
||||||
pt->m_param->RestoreState(pStk3, true); // parameters
|
pt->m_param->RestoreState(pStk3, true); // parameters
|
||||||
|
|
||||||
|
@ -831,7 +837,9 @@ void CBotFunction::RestoreCall(long& nIdent, const std::string& name, CBotVar* p
|
||||||
// finally calls the found function
|
// finally calls the found function
|
||||||
|
|
||||||
pt->m_block->RestoreState(pStk3, true); // interrupt !
|
pt->m_block->RestoreState(pStk3, true); // interrupt !
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -179,8 +179,9 @@ public:
|
||||||
* \param ppVars
|
* \param ppVars
|
||||||
* \param pStack
|
* \param pStack
|
||||||
* \param pClass
|
* \param pClass
|
||||||
|
* \return Returns true if the method call was restored.
|
||||||
*/
|
*/
|
||||||
void RestoreCall(long& nIdent,
|
bool RestoreCall(long& nIdent,
|
||||||
const std::string& name,
|
const std::string& name,
|
||||||
CBotVar* pThis,
|
CBotVar* pThis,
|
||||||
CBotVar** ppVars,
|
CBotVar** ppVars,
|
||||||
|
|
Loading…
Reference in New Issue