[colobot] 76/377: Moving CBotPreIncExpr class in its own header and source files.
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:00 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 605b1b244aeaedbc219ac0bd313de865a0555013
Author: Grunaka <dev at romainbreton.fr>
Date: Wed Nov 11 18:16:49 2015 +0100
Moving CBotPreIncExpr class in its own header and source files.
---
src/CBot/CBot.cpp | 66 +------------------------
src/CBot/CBot.h | 15 ------
src/CBot/CBotInstr/CBotPreIncExpr.cpp | 92 +++++++++++++++++++++++++++++++++++
src/CBot/CBotInstr/CBotPreIncExpr.h | 65 +++++++++++++++++++++++++
src/CBot/CMakeLists.txt | 1 +
5 files changed, 159 insertions(+), 80 deletions(-)
diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index eff3549..f6c11ca 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -50,6 +50,7 @@
#include "CBotInstr/CBotExprNull.h"
#include "CBotInstr/CBotExprBool.h"
#include "CBotInstr/CBotLeftExprVar.h"
+#include "CBotInstr/CBotPreIncExpr.h"
// Local include
@@ -2001,17 +2002,6 @@ CBotPostIncExpr::~CBotPostIncExpr()
delete m_Instr;
}
-CBotPreIncExpr::CBotPreIncExpr()
-{
- m_Instr = nullptr;
- name = "CBotPreIncExpr";
-}
-
-CBotPreIncExpr::~CBotPreIncExpr()
-{
- delete m_Instr;
-}
-
bool CBotPostIncExpr::Execute(CBotStack* &pj)
{
CBotStack* pile1 = pj->AddStack(this);
@@ -2056,60 +2046,6 @@ void CBotPostIncExpr::RestoreState(CBotStack* &pj, bool bMain)
if (pile1 != nullptr) pile1->RestoreStack(this);
}
-bool CBotPreIncExpr::Execute(CBotStack* &pj)
-{
- CBotStack* pile = pj->AddStack(this);
-
- if (pile->IfStep()) return false;
-
- CBotVar* var1;
-
- if (pile->GetState() == 0)
- {
- CBotStack* pile2 = pile;
- // retrieves the variable fields and indexes according
- // pile2 is modified on return
- if (!(static_cast<CBotExprVar*>(m_Instr))->ExecuteVar(var1, pile2, nullptr, true)) return false;
-
- if (var1->IsNAN())
- {
- pile->SetError(TX_OPNAN, &m_token);
- return pj->Return(pile); // operation performed
- }
-
- if (!var1->IsDefined())
- {
- pile->SetError(TX_NOTINIT, &m_token);
- return pj->Return(pile); // operation performed
- }
-
- if (GetTokenType() == ID_INC) var1->Inc();
- else var1->Dec(); // ((CBotVarInt*)var1)->m_val
-
- pile->IncState();
- }
-
- if (!m_Instr->Execute(pile)) return false;
- return pj->Return(pile); // operation performed
-}
-
-
-void CBotPreIncExpr::RestoreState(CBotStack* &pj, bool bMain)
-{
- if (!bMain) return;
-
- CBotStack* pile = pj->RestoreStack(this);
- if (pile == nullptr) return;
-
- if (pile->GetState() == 0)
- {
- return;
- }
-
- m_Instr->RestoreState(pile, bMain);
-}
-
-
//////////////////////////////////////////////////////////////////////////////////////
// compile an unary expression
// +
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 00e766e..814183b 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -915,21 +915,6 @@ public:
void RestoreState(CBotStack* &pj, bool bMain) override;
};
-class CBotPreIncExpr : public CBotInstr
-{
-private:
- CBotInstr* m_Instr;
- friend class CBotParExpr;
-
-public:
- CBotPreIncExpr();
- ~CBotPreIncExpr();
-// static
-// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
- bool Execute(CBotStack* &pj) override;
- void RestoreState(CBotStack* &pj, bool bMain) override;
-};
-
#define MAX(a,b) ((a>b) ? a : b)
diff --git a/src/CBot/CBotInstr/CBotPreIncExpr.cpp b/src/CBot/CBotInstr/CBotPreIncExpr.cpp
new file mode 100644
index 0000000..700bbff
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotPreIncExpr.cpp
@@ -0,0 +1,92 @@
+/*
+ * 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
+ */
+
+// Modules inlcude
+#include "CBotPreIncExpr.h"
+
+// Local include
+
+// Global include
+
+////////////////////////////////////////////////////////////////////////////////
+CBotPreIncExpr::CBotPreIncExpr()
+{
+ m_Instr = nullptr;
+ name = "CBotPreIncExpr";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotPreIncExpr::~CBotPreIncExpr()
+{
+ delete m_Instr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotPreIncExpr::Execute(CBotStack* &pj)
+{
+ CBotStack* pile = pj->AddStack(this);
+
+ if (pile->IfStep()) return false;
+
+ CBotVar* var1;
+
+ if (pile->GetState() == 0)
+ {
+ CBotStack* pile2 = pile;
+ // retrieves the variable fields and indexes according
+ // pile2 is modified on return
+ if (!(static_cast<CBotExprVar*>(m_Instr))->ExecuteVar(var1, pile2, nullptr, true)) return false;
+
+ if (var1->IsNAN())
+ {
+ pile->SetError(TX_OPNAN, &m_token);
+ return pj->Return(pile); // operation performed
+ }
+
+ if (!var1->IsDefined())
+ {
+ pile->SetError(TX_NOTINIT, &m_token);
+ return pj->Return(pile); // operation performed
+ }
+
+ if (GetTokenType() == ID_INC) var1->Inc();
+ else var1->Dec(); // ((CBotVarInt*)var1)->m_val
+
+ pile->IncState();
+ }
+
+ if (!m_Instr->Execute(pile)) return false;
+ return pj->Return(pile); // operation performed
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotPreIncExpr::RestoreState(CBotStack* &pj, bool bMain)
+{
+ if (!bMain) return;
+
+ CBotStack* pile = pj->RestoreStack(this);
+ if (pile == nullptr) return;
+
+ if (pile->GetState() == 0)
+ {
+ return;
+ }
+
+ m_Instr->RestoreState(pile, bMain);
+}
diff --git a/src/CBot/CBotInstr/CBotPreIncExpr.h b/src/CBot/CBotInstr/CBotPreIncExpr.h
new file mode 100644
index 0000000..ede694d
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotPreIncExpr.h
@@ -0,0 +1,65 @@
+/*
+ * 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 CBotPreIncExpr class Management of pre increment. There is no
+ * routine Compiles, the object is created directly. Compiles in CBotParExpr
+ */
+class CBotPreIncExpr : public CBotInstr
+{
+public:
+
+ /*!
+ * \brief CBotPreIncExpr
+ */
+ CBotPreIncExpr();
+
+ /*!
+ * \brief ~CBotPreIncExpr
+ */
+ ~CBotPreIncExpr();
+
+ /*!
+ * \brief Execute
+ * \param pj
+ * \return
+ */
+ bool Execute(CBotStack* &pj) override;
+
+ /*!
+ * \brief RestoreState
+ * \param pj
+ * \param bMain
+ */
+ void RestoreState(CBotStack* &pj, bool bMain) override;
+
+private:
+ CBotInstr* m_Instr;
+ friend class CBotParExpr;
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 5f2a020..b7c6349 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -26,6 +26,7 @@ set(SOURCES
CBotInstr/CBotExprNull.cpp
CBotInstr/CBotExprBool.cpp
CBotInstr/CBotLeftExprVar.cpp
+ CBotInstr/CBotPreIncExpr.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