[colobot] 75/377: Moving CBotLeftExprVar 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 a878b0d2527ebc74abdf6c6910c3108039985d27
Author: Grunaka <dev at romainbreton.fr>
Date: Wed Nov 11 18:07:11 2015 +0100
Moving CBotLeftExprVar class in its own header and source files.
---
src/CBot/CBot.cpp | 63 +-------------------------
src/CBot/CBot.h | 18 --------
src/CBot/CBotClass.cpp | 2 +-
src/CBot/CBotInstr/CBotLeftExprVar.cpp | 83 ++++++++++++++++++++++++++++++++++
src/CBot/CBotInstr/CBotLeftExprVar.h | 75 ++++++++++++++++++++++++++++++
src/CBot/CMakeLists.txt | 1 +
6 files changed, 161 insertions(+), 81 deletions(-)
diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index df2db44..eff3549 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -49,6 +49,7 @@
#include "CBotInstr/CBotExprNan.h"
#include "CBotInstr/CBotExprNull.h"
#include "CBotInstr/CBotExprBool.h"
+#include "CBotInstr/CBotLeftExprVar.h"
// Local include
@@ -499,68 +500,6 @@ void CBotListInstr::RestoreState(CBotStack* &pj, bool bMain)
}
//////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////////////////////////////////////////
-// compilation of an element to the left of an assignment
-
-CBotLeftExprVar::CBotLeftExprVar()
-{
- name = "CBotLeftExprVar";
- m_typevar = -1;
- m_nIdent = 0;
-}
-
-CBotLeftExprVar::~CBotLeftExprVar()
-{
-}
-
-CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack)
-{
- // verifies that the token is a variable name
- if (p->GetType() != TokenTypVar)
- {
- pStack->SetError( TX_NOVAR, p->GetStart());
- return nullptr;
- }
-
- CBotLeftExprVar* inst = new CBotLeftExprVar();
- inst->SetToken(p);
- p = p->GetNext();
-
- return inst;
-}
-
-// creates a variable and assigns the result to the stack
-bool CBotLeftExprVar::Execute(CBotStack* &pj)
-{
- CBotVar* var1;
- CBotVar* var2;
-
- var1 = CBotVar::Create(m_token.GetString(), m_typevar);
- var1->SetUniqNum(m_nIdent); // with the unique identifier
- pj->AddVar(var1); // place it on the stack
-
- var2 = pj->GetVar(); // result on the stack
- if (var2) var1->SetVal(var2); // do the assignment
-
- return true;
-}
-
-void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain)
-{
- CBotVar* var1;
-
- var1 = pj->FindVar(m_token.GetString());
- if (var1 == nullptr) assert(0);
-
- var1->SetUniqNum(m_nIdent); // with the unique identifier
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////////////////////////////////////////
// defining an array of any type
// int a[12];
// point x[];
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index eebdb95..00e766e 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -930,24 +930,6 @@ public:
void RestoreState(CBotStack* &pj, bool bMain) override;
};
-
-class CBotLeftExprVar : public CBotInstr
-{
-private:
-public:
- CBotTypResult
- m_typevar; // type of variable declared
- long m_nIdent; // unique identifier for that variable
-
-public:
- CBotLeftExprVar();
- ~CBotLeftExprVar();
- 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/CBotClass.cpp b/src/CBot/CBotClass.cpp
index 7903058..b7aeb93 100644
--- a/src/CBot/CBotClass.cpp
+++ b/src/CBot/CBotClass.cpp
@@ -23,7 +23,7 @@
#include "CBot.h"
#include "CBotInstr/CBotNew.h"
-
+#include "CBotInstr/CBotLeftExprVar.h"
CBotClass* CBotClass::m_ExClass = nullptr;
diff --git a/src/CBot/CBotInstr/CBotLeftExprVar.cpp b/src/CBot/CBotInstr/CBotLeftExprVar.cpp
new file mode 100644
index 0000000..43ed496
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotLeftExprVar.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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 "CBotLeftExprVar.h"
+
+// Local include
+
+// Global include
+#include <assert.h>
+
+////////////////////////////////////////////////////////////////////////////////
+CBotLeftExprVar::CBotLeftExprVar()
+{
+ name = "CBotLeftExprVar";
+ m_typevar = -1;
+ m_nIdent = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotLeftExprVar::~CBotLeftExprVar()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotLeftExprVar::Compile(CBotToken* &p, CBotCStack* pStack)
+{
+ // verifies that the token is a variable name
+ if (p->GetType() != TokenTypVar)
+ {
+ pStack->SetError( TX_NOVAR, p->GetStart());
+ return nullptr;
+ }
+
+ CBotLeftExprVar* inst = new CBotLeftExprVar();
+ inst->SetToken(p);
+ p = p->GetNext();
+
+ return inst;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotLeftExprVar::Execute(CBotStack* &pj)
+{
+ CBotVar* var1;
+ CBotVar* var2;
+
+ var1 = CBotVar::Create(m_token.GetString(), m_typevar);
+ var1->SetUniqNum(m_nIdent); // with the unique identifier
+ pj->AddVar(var1); // place it on the stack
+
+ var2 = pj->GetVar(); // result on the stack
+ if (var2) var1->SetVal(var2); // do the assignment
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotLeftExprVar::RestoreState(CBotStack* &pj, bool bMain)
+{
+ CBotVar* var1;
+
+ var1 = pj->FindVar(m_token.GetString());
+ if (var1 == nullptr) assert(0);
+
+ var1->SetUniqNum(m_nIdent); // with the unique identifier
+}
diff --git a/src/CBot/CBotInstr/CBotLeftExprVar.h b/src/CBot/CBotInstr/CBotLeftExprVar.h
new file mode 100644
index 0000000..a264dba
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotLeftExprVar.h
@@ -0,0 +1,75 @@
+/*
+ * 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 CBotLeftExprVar class Compilation of an element to the left of an assignment.
+ */
+class CBotLeftExprVar : public CBotInstr
+{
+public:
+
+ /*!
+ * \brief CBotLeftExprVar
+ */
+ CBotLeftExprVar();
+
+ /*!
+ * \brief ~CBotLeftExprVar
+ */
+ ~CBotLeftExprVar();
+
+ /*!
+ * \brief Compile
+ * \param p
+ * \param pStack
+ * \return
+ */
+ static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
+
+ /*!
+ * \brief Execute Creates a variable and assigns the result to the stack.
+ * \param pj
+ * \return
+ */
+ bool Execute(CBotStack* &pj) override;
+
+ /*!
+ * \brief RestoreState
+ * \param pj
+ * \param bMain
+ */
+ void RestoreState(CBotStack* &pj, bool bMain) override;
+
+public:
+
+ //! Type of variable declared.
+ CBotTypResult m_typevar;
+ //! Unique identifier for that variable.
+ long m_nIdent;
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 104e2b1..5f2a020 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -25,6 +25,7 @@ set(SOURCES
CBotInstr/CBotExprNan.cpp
CBotInstr/CBotExprNull.cpp
CBotInstr/CBotExprBool.cpp
+ CBotInstr/CBotLeftExprVar.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