Refactor public function list
parent
921c266311
commit
5443006979
|
@ -385,8 +385,7 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
pp = pp->Next();
|
pp = pp->Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
pp = CBotFunction::m_listPublic;
|
for (CBotFunction* pp : CBotFunction::m_publicFunctions)
|
||||||
while ( pp != nullptr )
|
|
||||||
{
|
{
|
||||||
if ( pToken->GetString() == pp->GetName() )
|
if ( pToken->GetString() == pp->GetName() )
|
||||||
{
|
{
|
||||||
|
@ -394,7 +393,6 @@ bool CBotCStack::CheckCall(CBotToken* &pToken, CBotDefParam* pParam)
|
||||||
if ( pp->CheckParam( pParam ) )
|
if ( pp->CheckParam( pParam ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pp = pp->m_nextpublic;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -51,8 +51,6 @@ CBotFunction::CBotFunction()
|
||||||
m_next = nullptr; // functions can be chained
|
m_next = nullptr; // functions can be chained
|
||||||
m_bPublic = false; // function not public
|
m_bPublic = false; // function not public
|
||||||
m_bExtern = false; // function not extern
|
m_bExtern = false; // function not extern
|
||||||
m_nextpublic = nullptr;
|
|
||||||
m_prevpublic = nullptr;
|
|
||||||
m_pProg = nullptr;
|
m_pProg = nullptr;
|
||||||
// m_nThisIdent = 0;
|
// m_nThisIdent = 0;
|
||||||
m_nFuncIdent = 0;
|
m_nFuncIdent = 0;
|
||||||
|
@ -60,7 +58,7 @@ CBotFunction::CBotFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotFunction* CBotFunction::m_listPublic = nullptr;
|
std::set<CBotFunction*> CBotFunction::m_publicFunctions{};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotFunction::~CBotFunction()
|
CBotFunction::~CBotFunction()
|
||||||
|
@ -72,19 +70,7 @@ CBotFunction::~CBotFunction()
|
||||||
// remove public list if there is
|
// remove public list if there is
|
||||||
if (m_bPublic)
|
if (m_bPublic)
|
||||||
{
|
{
|
||||||
if ( m_nextpublic != nullptr )
|
m_publicFunctions.erase(this);
|
||||||
{
|
|
||||||
m_nextpublic->m_prevpublic = m_prevpublic;
|
|
||||||
}
|
|
||||||
if ( m_prevpublic != nullptr)
|
|
||||||
{
|
|
||||||
m_prevpublic->m_nextpublic = m_nextpublic;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// if prev = next = null may not be in the list!
|
|
||||||
if ( m_listPublic == this ) m_listPublic = m_nextpublic;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,8 +449,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const std::string& n
|
||||||
}
|
}
|
||||||
|
|
||||||
// search the list of public functions
|
// search the list of public functions
|
||||||
|
for (CBotFunction* pt : m_publicFunctions)
|
||||||
for ( pt = m_listPublic ; pt != nullptr ; pt = pt->m_nextpublic )
|
|
||||||
{
|
{
|
||||||
if (pt->m_nFuncIdent == nIdent)
|
if (pt->m_nFuncIdent == nIdent)
|
||||||
{
|
{
|
||||||
|
@ -536,7 +521,7 @@ CBotFunction* CBotFunction::FindLocalOrPublic(long& nIdent, const std::string& n
|
||||||
|
|
||||||
if ( bPublic )
|
if ( bPublic )
|
||||||
{
|
{
|
||||||
for ( pt = m_listPublic ; pt != nullptr ; pt = pt->m_nextpublic )
|
for (CBotFunction* pt : m_publicFunctions)
|
||||||
{
|
{
|
||||||
if ( pt->m_token.GetString() == name )
|
if ( pt->m_token.GetString() == name )
|
||||||
{
|
{
|
||||||
|
@ -887,10 +872,5 @@ CBotFunction* CBotFunction::Next()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotFunction::AddPublic(CBotFunction* func)
|
void CBotFunction::AddPublic(CBotFunction* func)
|
||||||
{
|
{
|
||||||
if ( m_listPublic != nullptr )
|
m_publicFunctions.insert(func);
|
||||||
{
|
|
||||||
func->m_nextpublic = m_listPublic;
|
|
||||||
m_listPublic->m_prevpublic = func;
|
|
||||||
}
|
|
||||||
m_listPublic = func;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
// Local include
|
// Local include
|
||||||
|
|
||||||
// Global include
|
// Global include
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -243,8 +244,6 @@ public:
|
||||||
CBotGet modestop);
|
CBotGet modestop);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CBotFunction* m_nextpublic;
|
|
||||||
CBotFunction* m_prevpublic;
|
|
||||||
long m_nFuncIdent;
|
long m_nFuncIdent;
|
||||||
//! Synchronized method.
|
//! Synchronized method.
|
||||||
bool m_bSynchro;
|
bool m_bSynchro;
|
||||||
|
@ -272,8 +271,8 @@ private:
|
||||||
CBotToken m_openblk;
|
CBotToken m_openblk;
|
||||||
CBotToken m_closeblk;
|
CBotToken m_closeblk;
|
||||||
|
|
||||||
//! Management of list of (static) public functions.
|
//! List of public functions
|
||||||
static CBotFunction* m_listPublic;
|
static std::set<CBotFunction*> m_publicFunctions;
|
||||||
|
|
||||||
friend class CBotProgram;
|
friend class CBotProgram;
|
||||||
friend class CBotClass;
|
friend class CBotClass;
|
||||||
|
|
|
@ -179,13 +179,23 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief GetType Returns the base type of the variable (::CBotType)
|
* \brief GetType Returns the base type of the variable (::CBotType)
|
||||||
* \param mode TODO: document this param
|
* \param mode
|
||||||
|
* \parblock
|
||||||
|
* * mode = 0 Return type normally
|
||||||
|
* * mode = 1 Treat classes as pointers
|
||||||
|
* * mode = 2 Treat classes as intrinsic
|
||||||
|
* \endparblock
|
||||||
*/
|
*/
|
||||||
CBotType GetType(int mode = 0);
|
CBotType GetType(int mode = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns the complete type of the variable (CBotTypResult)
|
* \brief Returns the complete type of the variable (CBotTypResult)
|
||||||
* \param mode TODO: document this param
|
* \param mode
|
||||||
|
* \parblock
|
||||||
|
* * mode = 0 Return type normally
|
||||||
|
* * mode = 1 Treat classes as pointers
|
||||||
|
* * mode = 2 Treat classes as intrinsic
|
||||||
|
* \endparblock
|
||||||
*/
|
*/
|
||||||
CBotTypResult GetTypResult(int mode = 0);
|
CBotTypResult GetTypResult(int mode = 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue