Make CBotFunction implement CBotLinkedList

dev-buzzingcars
krzys-h 2016-11-11 18:16:12 +01:00
parent 8764d28e9e
commit 266b34d578
6 changed files with 13 additions and 40 deletions

View File

@ -378,7 +378,7 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
if ( pp->CheckParam( pParam ) )
return true;
}
pp = pp->Next();
pp = pp->GetNext();
}
for (CBotFunction* pp : CBotFunction::m_publicFunctions)

View File

@ -464,7 +464,7 @@ bool CBotClass::CheckCall(CBotProgram* program, CBotDefParam* pParam, CBotToken*
if ( pp->CheckParam( pParam ) )
return true;
}
pp = pp->Next();
pp = pp->GetNext();
}
return false;
@ -647,7 +647,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
while ( pf != nullptr ) // search by name and parameters
{
if (pf->GetName() == pp && pf->CheckParam( params )) break;
pf = pf->Next();
pf = pf->GetNext();
}
bool bConstructor = (pp == GetName());

View File

@ -41,7 +41,7 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
while (func != nullptr)
{
funcIdMap[func->m_nFuncIdent] = func;
func = func->Next();
func = func->GetNext();
}
std::set<CBotInstr*> finished;
@ -123,7 +123,7 @@ void CBotDebug::DumpCompiledProgram(CBotProgram* program)
prev = GetPointerAsString(func);
}
func = func->Next();
func = func->GetNext();
}
ss << "}" << std::endl;

View File

@ -46,7 +46,6 @@ CBotFunction::CBotFunction()
{
m_param = nullptr; // empty parameter list
m_block = nullptr; // the instruction block
m_next = nullptr; // functions can be chained
m_bPublic = false; // function not public
m_bExtern = false; // function not extern
m_pProg = nullptr;
@ -63,7 +62,6 @@ CBotFunction::~CBotFunction()
{
delete m_param; // empty parameter list
delete m_block; // the instruction block
delete m_next;
// remove public list if there is
if (m_bPublic)
@ -411,15 +409,6 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
m_block->RestoreState(pile2, true);
}
////////////////////////////////////////////////////////////////////////////////
void CBotFunction::AddNext(CBotFunction* p)
{
CBotFunction* pp = this;
while (pp->m_next != nullptr) pp = pp->m_next;
pp->m_next = p;
}
////////////////////////////////////////////////////////////////////////////////
CBotTypResult CBotFunction::CompileCall(CBotFunction* localFunctionList, const std::string &name, CBotVar** ppVars, long &nIdent)
{
@ -441,7 +430,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(CBotFunction* localFunctionList, l
if ( nIdent )
{
if ( localFunctionList != nullptr ) for ( pt = localFunctionList ; pt != nullptr ; pt = pt->m_next )
if ( localFunctionList != nullptr ) for ( pt = localFunctionList ; pt != nullptr ; pt = pt->GetNext() )
{
if ( pt->m_nFuncIdent == nIdent )
{
@ -467,7 +456,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(CBotFunction* localFunctionList, l
if ( localFunctionList != nullptr )
{
for ( pt = localFunctionList ; pt != nullptr ; pt = pt->m_next )
for ( pt = localFunctionList ; pt != nullptr ; pt = pt->GetNext() )
{
if ( pt->m_token.GetString() == name )
{
@ -906,12 +895,6 @@ std::string CBotFunction::GetParams()
return params;
}
////////////////////////////////////////////////////////////////////////////////
CBotFunction* CBotFunction::Next()
{
return m_next;
}
////////////////////////////////////////////////////////////////////////////////
void CBotFunction::AddPublic(CBotFunction* func)
{

View File

@ -39,7 +39,7 @@ namespace CBot
* void classname::test() { ... }
* \endcode
*/
class CBotFunction : public CBotInstr
class CBotFunction : public CBotInstr, public CBotLinkedList<CBotFunction>
{
public:
CBotFunction();
@ -91,11 +91,8 @@ public:
CBotStack* &pj,
CBotVar* pInstance = nullptr);
/*!
* \brief AddNext
* \param p
*/
void AddNext(CBotFunction* p);
using CBotLinkedList<CBotFunction>::GetNext;
using CBotLinkedList<CBotFunction>::AddNext;
/*!
* \brief Compile a function call
@ -224,12 +221,6 @@ public:
*/
bool IsExtern();
/*!
* \brief Next
* \return
*/
CBotFunction* Next();
/*!
* \brief GetPosition
* \param start
@ -257,7 +248,6 @@ private:
CBotDefParam* m_param;
//! The instruction block.
CBotInstr* m_block;
CBotFunction* m_next;
//! If returns CBotTypClass.
CBotToken m_retToken;
//! Complete type of the result.

View File

@ -132,7 +132,7 @@ bool CBotProgram::Compile(const std::string& program, std::vector<std::string>&
if (next->IsExtern()) functions.push_back(next->GetName()/* + next->GetParams()*/);
if (next->IsPublic()) CBotFunction::AddPublic(next);
next->m_pProg = this; // keeps pointers to the module
next = next->Next();
next = next->GetNext();
}
}
@ -157,7 +157,7 @@ bool CBotProgram::Start(const std::string& name)
while (m_entryPoint != nullptr)
{
if (m_entryPoint->GetName() == name ) break;
m_entryPoint = m_entryPoint->m_next;
m_entryPoint = m_entryPoint->GetNext();
}
if (m_entryPoint == nullptr)
@ -178,7 +178,7 @@ bool CBotProgram::GetPosition(const std::string& name, int& start, int& stop, CB
while (p != nullptr)
{
if ( p->GetName() == name ) break;
p = p->m_next;
p = p->GetNext();
}
if ( p == nullptr ) return false;