[colobot] 14/100: Make CBotFunction implement CBotLinkedList

Didier Raboud odyx at moszumanska.debian.org
Thu Jun 1 18:10:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 266b34d578cbbb8ed55c4e8ecdf9c9b195cd7756
Author: krzys-h <krzys_h at interia.pl>
Date:   Fri Nov 11 18:16:12 2016 +0100

    Make CBotFunction implement CBotLinkedList
---
 src/CBot/CBotCStack.cpp             |  2 +-
 src/CBot/CBotClass.cpp              |  4 ++--
 src/CBot/CBotDebug.cpp              |  4 ++--
 src/CBot/CBotInstr/CBotFunction.cpp | 21 ++-------------------
 src/CBot/CBotInstr/CBotFunction.h   | 16 +++-------------
 src/CBot/CBotProgram.cpp            |  6 +++---
 6 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/src/CBot/CBotCStack.cpp b/src/CBot/CBotCStack.cpp
index 044a473..ef3c409 100644
--- a/src/CBot/CBotCStack.cpp
+++ b/src/CBot/CBotCStack.cpp
@@ -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)
diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp
index 0eb86db..bd95605 100644
--- a/src/CBot/CBotClass.cpp
+++ b/src/CBot/CBotClass.cpp
@@ -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());
diff --git a/src/CBot/CBotDebug.cpp b/src/CBot/CBotDebug.cpp
index 652bd70..d71eac3 100644
--- a/src/CBot/CBotDebug.cpp
+++ b/src/CBot/CBotDebug.cpp
@@ -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;
diff --git a/src/CBot/CBotInstr/CBotFunction.cpp b/src/CBot/CBotInstr/CBotFunction.cpp
index 2885f1a..2d92910 100644
--- a/src/CBot/CBotInstr/CBotFunction.cpp
+++ b/src/CBot/CBotInstr/CBotFunction.cpp
@@ -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)
@@ -412,15 +410,6 @@ void CBotFunction::RestoreState(CBotVar** ppVars, CBotStack* &pj, CBotVar* pInst
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-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)
 {
     CBotTypResult type;
@@ -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 )
             {
@@ -907,12 +896,6 @@ std::string CBotFunction::GetParams()
 }
 
 ////////////////////////////////////////////////////////////////////////////////
-CBotFunction* CBotFunction::Next()
-{
-    return  m_next;
-}
-
-////////////////////////////////////////////////////////////////////////////////
 void CBotFunction::AddPublic(CBotFunction* func)
 {
     m_publicFunctions.insert(func);
diff --git a/src/CBot/CBotInstr/CBotFunction.h b/src/CBot/CBotInstr/CBotFunction.h
index d2f766c..6a0180f 100644
--- a/src/CBot/CBotInstr/CBotFunction.h
+++ b/src/CBot/CBotInstr/CBotFunction.h
@@ -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
@@ -225,12 +222,6 @@ public:
     bool IsExtern();
 
     /*!
-     * \brief Next
-     * \return
-     */
-    CBotFunction* Next();
-
-    /*!
      * \brief GetPosition
      * \param start
      * \param stop
@@ -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.
diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp
index 17c5ec0..6e8b6a6 100644
--- a/src/CBot/CBotProgram.cpp
+++ b/src/CBot/CBotProgram.cpp
@@ -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;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list