Fixed object:: with other types (#207)
parent
5b7638d9f4
commit
0807b75d4b
|
@ -178,6 +178,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
|
||||||
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
|
if ( IsOfType( p, ID_DBLDOTS ) ) // method for a class
|
||||||
{
|
{
|
||||||
func->m_MasterClass = pp->GetString();
|
func->m_MasterClass = pp->GetString();
|
||||||
|
func->m_classToken = *pp;
|
||||||
CBotClass* pClass = CBotClass::Find(pp);
|
CBotClass* pClass = CBotClass::Find(pp);
|
||||||
if ( pClass == nullptr ) goto bad;
|
if ( pClass == nullptr ) goto bad;
|
||||||
|
|
||||||
|
@ -355,10 +356,16 @@ bool CBotFunction::Execute(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInstance)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (m_MasterClass != pInstance->GetClass()->GetName())
|
||||||
|
{
|
||||||
|
pile->SetError(CBotErrBadType2, &m_classToken);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
pThis = CBotVar::Create("this", CBotTypResult( CBotTypPointer, m_MasterClass ));
|
pThis = CBotVar::Create("this", CBotTypResult( CBotTypPointer, m_MasterClass ));
|
||||||
pThis->SetPointer(pInstance);
|
pThis->SetPointer(pInstance);
|
||||||
}
|
}
|
||||||
assert(pThis);
|
assert(pThis != nullptr);
|
||||||
pThis->SetInit(CBotVar::InitType::IS_POINTER);
|
pThis->SetInit(CBotVar::InitType::IS_POINTER);
|
||||||
|
|
||||||
// pThis->SetUniqNum(m_nThisIdent);
|
// pThis->SetUniqNum(m_nThisIdent);
|
||||||
|
@ -617,10 +624,16 @@ int CBotFunction::DoCall(long& nIdent, const std::string& name, CBotVar** ppVars
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (pt->m_MasterClass != pInstance->GetClass()->GetName())
|
||||||
|
{
|
||||||
|
pStack->SetError(CBotErrBadType2, &pt->m_classToken);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
pThis = CBotVar::Create("this", CBotTypResult( CBotTypPointer, pt->m_MasterClass ));
|
pThis = CBotVar::Create("this", CBotTypResult( CBotTypPointer, pt->m_MasterClass ));
|
||||||
pThis->SetPointer(pInstance);
|
pThis->SetPointer(pInstance);
|
||||||
}
|
}
|
||||||
assert(pThis);
|
assert(pThis != nullptr);
|
||||||
pThis->SetInit(CBotVar::InitType::IS_POINTER);
|
pThis->SetInit(CBotVar::InitType::IS_POINTER);
|
||||||
|
|
||||||
pThis->SetUniqNum(-2);
|
pThis->SetUniqNum(-2);
|
||||||
|
|
|
@ -261,8 +261,10 @@ private:
|
||||||
bool m_bPublic;
|
bool m_bPublic;
|
||||||
//! Extern function.
|
//! Extern function.
|
||||||
bool m_bExtern;
|
bool m_bExtern;
|
||||||
//! Name of the class we derive.
|
//! Name of the class we are part of
|
||||||
std::string m_MasterClass;
|
std::string m_MasterClass;
|
||||||
|
//! Token of the class we are part of
|
||||||
|
CBotToken m_classToken;
|
||||||
CBotProgram* m_pProg;
|
CBotProgram* m_pProg;
|
||||||
//! For the position of the word "extern".
|
//! For the position of the word "extern".
|
||||||
CBotToken m_extern;
|
CBotToken m_extern;
|
||||||
|
|
Loading…
Reference in New Issue