[colobot] 87/377: Moving CBotTwoOpExpr class in its own header and source files.
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:01 UTC 2016
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch debian/master
in repository colobot.
commit d44df45d26e1ae02206ba2d32a4e2fc078ce44b0
Author: Grunaka <dev at romainbreton.fr>
Date: Wed Nov 11 21:27:56 2015 +0100
Moving CBotTwoOpExpr class in its own header and source files.
---
src/CBot/CBot.cpp | 1 +
src/CBot/CBot.h | 17 -------
src/CBot/CBotClass.cpp | 1 +
src/CBot/CBotFunction.cpp | 1 +
src/CBot/CBotInstr/CBotBoolExpr.cpp | 1 +
src/CBot/{ => CBotInstr}/CBotTwoOpExpr.cpp | 55 ++++++---------------
src/CBot/CBotInstr/CBotTwoOpExpr.h | 78 ++++++++++++++++++++++++++++++
src/CBot/CMakeLists.txt | 2 +-
8 files changed, 99 insertions(+), 57 deletions(-)
diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 93eec5f..78bf8ca 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -57,6 +57,7 @@
#include "CBotInstr/CBotListInstr.h"
#include "CBotInstr/CBotExprUnaire.h"
#include "CBotInstr/CBotBoolExpr.h"
+#include "CBotInstr/CBotTwoOpExpr.h"
// Local include
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 976789c..31edd2a 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -727,23 +727,6 @@ public:
void RestoreState(CBotStack* &pj, bool bMain) override;
};
-
-// all operations with two operands
-
-class CBotTwoOpExpr : public CBotInstr
-{
-private:
- CBotInstr* m_leftop; // left element
- CBotInstr* m_rightop; // right element
-public:
- CBotTwoOpExpr();
- ~CBotTwoOpExpr();
- static
- CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations = nullptr);
- bool Execute(CBotStack* &pStack) override;
- void RestoreState(CBotStack* &pj, bool bMain) override;
-};
-
#define MAX(a,b) ((a>b) ? a : b)
diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp
index b7aeb93..11f93a1 100644
--- a/src/CBot/CBotClass.cpp
+++ b/src/CBot/CBotClass.cpp
@@ -24,6 +24,7 @@
#include "CBot.h"
#include "CBotInstr/CBotNew.h"
#include "CBotInstr/CBotLeftExprVar.h"
+#include "CBotInstr/CBotTwoOpExpr.h"
CBotClass* CBotClass::m_ExClass = nullptr;
diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp
index 6ebad17..838c8de 100644
--- a/src/CBot/CBotFunction.cpp
+++ b/src/CBot/CBotFunction.cpp
@@ -24,6 +24,7 @@
#include "CBot.h"
#include "CBotInstr/CBotBlock.h"
+#include "CBotInstr/CBotTwoOpExpr.h"
#include <cassert>
diff --git a/src/CBot/CBotInstr/CBotBoolExpr.cpp b/src/CBot/CBotInstr/CBotBoolExpr.cpp
index 4fd4d7b..2815c8e 100644
--- a/src/CBot/CBotInstr/CBotBoolExpr.cpp
+++ b/src/CBot/CBotInstr/CBotBoolExpr.cpp
@@ -19,6 +19,7 @@
// Modules inlcude
#include "CBotBoolExpr.h"
+#include "CBotTwoOpExpr.h"
// Local include
diff --git a/src/CBot/CBotTwoOpExpr.cpp b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp
similarity index 96%
rename from src/CBot/CBotTwoOpExpr.cpp
rename to src/CBot/CBotInstr/CBotTwoOpExpr.cpp
index d9173d6..b381ca4 100644
--- a/src/CBot/CBotTwoOpExpr.cpp
+++ b/src/CBot/CBotInstr/CBotTwoOpExpr.cpp
@@ -17,27 +17,18 @@
* along with this program. If not, see http://gnu.org/licenses
*/
-///////////////////////////////////////////////////
-// expression of type Opérande1 + Opérande2
-// Opérande1 > Opérande2
-
+// Modules inlcude
+#include "CBotTwoOpExpr.h"
+#include "CBotParExpr.h"
+#include "CBotLogicExpr.h"
#include "CBot.h"
-#include "CBotInstr/CBotParExpr.h"
-#include "CBotInstr/CBotLogicExpr.h"
+// Local include
+// Global include
#include <cassert>
-namespace
-{
-bool VarIsNAN(const CBotVar* var)
-{
- return var->GetInit() > CBotVar::InitType::DEF;
-}
-}
-
-// various constructors
-
+////////////////////////////////////////////////////////////////////////////////
CBotTwoOpExpr::CBotTwoOpExpr()
{
m_leftop =
@@ -45,6 +36,7 @@ CBotTwoOpExpr::CBotTwoOpExpr()
name = "CBotTwoOpExpr"; // debug
}
+////////////////////////////////////////////////////////////////////////////////
CBotTwoOpExpr::~CBotTwoOpExpr()
{
delete m_leftop;
@@ -116,8 +108,7 @@ bool TypeOk( int type, int test )
}
}
-// compiles a instruction of type A op B
-
+////////////////////////////////////////////////////////////////////////////////
CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations)
{
int typemasque;
@@ -281,6 +272,11 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
}
+bool VarIsNAN(const CBotVar* var)
+{
+ return var->GetInit() > CBotVar::InitType::DEF;
+}
+
bool IsNan(CBotVar* left, CBotVar* right, int* err = nullptr)
{
if ( VarIsNAN(left) || VarIsNAN(right) )
@@ -291,9 +287,7 @@ bool IsNan(CBotVar* left, CBotVar* right, int* err = nullptr)
return false;
}
-
-// performes the operation on two operands
-
+////////////////////////////////////////////////////////////////////////////////
bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
{
CBotStack* pStk1 = pStack->AddStack(this); // adds an item to the stack
@@ -477,6 +471,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
return pStack->Return(pStk2); // transmits the result
}
+////////////////////////////////////////////////////////////////////////////////
void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
{
if ( !bMain ) return;
@@ -501,21 +496,3 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
return;
}
}
-
-#if 0
-void t()
-{
- int x,y;
- 1>0 ? x = 0 : y = 0;
-}
-#endif
-
-#if 0
-void t(bool t)
-{
- int x;
- x = 1 + t ? 1 : 3 + 4 * 2 ;
- t ? 0 : "test";
-}
-#endif
-
diff --git a/src/CBot/CBotInstr/CBotTwoOpExpr.h b/src/CBot/CBotInstr/CBotTwoOpExpr.h
new file mode 100644
index 0000000..1bcc2f8
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotTwoOpExpr.h
@@ -0,0 +1,78 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+#pragma once
+
+// Modules inlcude
+#include "CBot.h"
+
+// Local include
+
+// Global include
+
+
+/*!
+ * \brief The CBotTwoOpExpr class All operations with two operands.
+ * eg :
+ * - Opérande1 + Opérande2
+ * - Opérande1 > Opérande2
+ */
+class CBotTwoOpExpr : public CBotInstr
+{
+public:
+
+ /*!
+ * \brief CBotTwoOpExpr
+ */
+ CBotTwoOpExpr();
+
+ /*!
+ * \brief ~CBotTwoOpExpr
+ */
+ ~CBotTwoOpExpr();
+
+ /*!
+ * \brief Compile Compiles a instruction of type A op B.
+ * \param p
+ * \param pStack
+ * \param pOperations
+ * \return
+ */
+ static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, int* pOperations = nullptr);
+
+ /*!
+ * \brief Execute Performes the operation on two operands.
+ * \param pStack
+ * \return
+ */
+ bool Execute(CBotStack* &pStack) override;
+
+ /*!
+ * \brief RestoreState
+ * \param pj
+ * \param bMain
+ */
+ void RestoreState(CBotStack* &pj, bool bMain) override;
+
+private:
+ //! Left element
+ CBotInstr* m_leftop;
+ //! Right element
+ CBotInstr* m_rightop;
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 150724a..ba8f1a2 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -7,7 +7,6 @@ set(SOURCES
CBotStack.cpp
CBotString.cpp
CBotToken.cpp
- CBotTwoOpExpr.cpp
CBotVar.cpp
CBotInstr/CBotWhile.cpp
CBotInstr/CBotDo.cpp
@@ -37,6 +36,7 @@ set(SOURCES
CBotInstr/CBotParExpr.cpp
CBotInstr/CBotBoolExpr.cpp
CBotInstr/CBotLogicExpr.cpp
+ CBotInstr/CBotTwoOpExpr.cpp
)
# Includes
--
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