Moving CBotVar class in its own header and source files.
parent
2eeab6d4d0
commit
660f17454a
|
@ -75,6 +75,7 @@
|
|||
#include "CBotStack.h"
|
||||
#include "CBotClass.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "CBotUtils.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "CBotUtils.h"
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "CBotUtils.h"
|
||||
#include "CBotCallMethode.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "CBotProgram.h"
|
||||
|
||||
#include "CBotDefines.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -26,3 +26,10 @@
|
|||
// Global include
|
||||
|
||||
#define MAXARRAYSIZE 9999
|
||||
|
||||
|
||||
// variable type SetPrivate / IsPrivate
|
||||
#define PR_PUBLIC 0 // public variable
|
||||
#define PR_READ 1 // read only
|
||||
#define PR_PROTECT 2 // protected (inheritance)
|
||||
#define PR_PRIVATE 3 // strictly private
|
||||
|
|
|
@ -494,231 +494,6 @@ bool rMean(CBotVar* pVar, CBotVar* pResult, int& Exception)
|
|||
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Class for managing variables
|
||||
|
||||
// may be useful to the outside of the module
|
||||
// ( it is currently not expected to be able to create these objects in outer )
|
||||
|
||||
// variable type SetPrivate / IsPrivate
|
||||
#define PR_PUBLIC 0 // public variable
|
||||
#define PR_READ 1 // read only
|
||||
#define PR_PROTECT 2 // protected (inheritance)
|
||||
#define PR_PRIVATE 3 // strictly private
|
||||
|
||||
class CBotVar
|
||||
{
|
||||
public:
|
||||
// results of GetInit()
|
||||
enum class InitType : int { UNDEF = 0, DEF = 1, IS_POINTER = 2, IS_NAN = 999 };
|
||||
|
||||
protected:
|
||||
CBotToken* m_token; // the corresponding token
|
||||
|
||||
CBotVar* m_next; // list of variables
|
||||
friend class CBotStack;
|
||||
friend class CBotCStack;
|
||||
friend class CBotInstrCall;
|
||||
friend class CBotProgram;
|
||||
|
||||
CBotTypResult m_type; // type of value
|
||||
|
||||
InitType m_binit; // not initialized?
|
||||
CBotVarClass* m_pMyThis; // ^ corresponding this element
|
||||
void* m_pUserPtr; // ^user data if necessary
|
||||
bool m_bStatic; // static element (in class)
|
||||
int m_mPrivate; // element public, protected or private?
|
||||
|
||||
CBotInstr* m_InitExpr; // expression for the original content
|
||||
CBotInstr* m_LimExpr; // list of limits for a table
|
||||
friend class CBotClass;
|
||||
friend class CBotVarClass;
|
||||
friend class CBotVarPointer;
|
||||
friend class CBotVarArray;
|
||||
|
||||
long m_ident; // unique identifier
|
||||
static long m_identcpt; // counter
|
||||
|
||||
public:
|
||||
CBotVar();
|
||||
virtual ~CBotVar( ); // destructor
|
||||
|
||||
static
|
||||
CBotVar* Create( const char* name, CBotTypResult type);
|
||||
// creates from a complete type
|
||||
|
||||
static
|
||||
CBotVar* Create( const char* name, CBotClass* pClass);
|
||||
// creates from one instance of a known class
|
||||
|
||||
static
|
||||
CBotVar* Create( const CBotToken* name, int type );
|
||||
static
|
||||
CBotVar* Create( const CBotToken* name, CBotTypResult type );
|
||||
|
||||
static
|
||||
CBotVar* Create( const char* name, int type, CBotClass* pClass);
|
||||
|
||||
static
|
||||
CBotVar* Create( CBotVar* pVar );
|
||||
|
||||
static void Destroy(CBotVar* var);
|
||||
|
||||
|
||||
void SetUserPtr(void* pUser);
|
||||
// associate a user pointer to an instance
|
||||
|
||||
virtual void SetIdent(long UniqId);
|
||||
// associates a unique identifier to an instance
|
||||
// ( it is used to ensure that the id is unique)
|
||||
|
||||
void* GetUserPtr();
|
||||
// makes the pointer associated with the variable
|
||||
|
||||
CBotString GetName(); // the name of the variable, if known
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
void SetName(const char* name); // changes the name of the variable
|
||||
|
||||
int GetType(int mode = 0); // returns the base type (int) of the variable
|
||||
// TODO check it
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CBotTypResult GetTypResult(int mode = 0); // returns the complete type of the variable
|
||||
|
||||
|
||||
CBotToken* GetToken();
|
||||
void SetType(CBotTypResult& type);
|
||||
|
||||
void SetInit(InitType initType); // is the variable in the state UNDEF, DEF, NAN
|
||||
InitType GetInit() const; // gives the state of the variable
|
||||
bool IsUndefined() const { return GetInit() == InitType::UNDEF; }
|
||||
bool IsDefined() const { return GetInit() == InitType::DEF; }
|
||||
bool IsNAN() const { return GetInit() == InitType::IS_NAN; }
|
||||
|
||||
void SetStatic(bool bStatic);
|
||||
bool IsStatic();
|
||||
|
||||
void SetPrivate(int mPrivate);
|
||||
bool IsPrivate(int mode = PR_PROTECT);
|
||||
int GetPrivate();
|
||||
|
||||
virtual
|
||||
void ConstructorSet();
|
||||
|
||||
void SetVal(CBotVar* var); // remprend une valeur
|
||||
// TODO remprend value
|
||||
virtual
|
||||
CBotVar* GetItem(const char* name); // returns an element of a class according to its name (*)
|
||||
virtual
|
||||
CBotVar* GetItemRef(int nIdent); // idem à partir du n° ref
|
||||
// TODO ditto from ref no.
|
||||
virtual
|
||||
CBotVar* GetItem(int row, bool bGrow = false);
|
||||
|
||||
virtual
|
||||
CBotVar* GetItemList(); // lists the elements
|
||||
|
||||
CBotVar* GetStaticVar(); // makes the pointer to the variable if it is static
|
||||
|
||||
bool IsElemOfClass(const char* name);
|
||||
// said if the element belongs to the class "name"
|
||||
// makes true if the object is a subclass
|
||||
|
||||
CBotVar* GetNext(); // next variable in the list (parameters)
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void AddNext(CBotVar* pVar); // added to a list
|
||||
|
||||
virtual
|
||||
void Copy(CBotVar* pSrc, bool bName = true); // makes a copy of the variable
|
||||
|
||||
virtual void SetValInt(int val, const char* name = nullptr);
|
||||
// initialized with an integer value (#)
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void SetValFloat(float val); // initialized with a real value (#)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void SetValString(const char* p);// initialized with a string value (#)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual int GetValInt(); // request the full value (#)
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual float GetValFloat(); // gets real value (#)
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual
|
||||
CBotString GetValString(); // request the string value (#)
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void SetClass(CBotClass* pClass);
|
||||
virtual
|
||||
CBotClass* GetClass();
|
||||
|
||||
virtual void SetPointer(CBotVar* p);
|
||||
virtual
|
||||
CBotVarClass* GetPointer();
|
||||
// virtual void SetIndirection(CBotVar* pVar);
|
||||
|
||||
virtual void Add(CBotVar* left, CBotVar* right); // addition
|
||||
virtual void Sub(CBotVar* left, CBotVar* right); // subtraction
|
||||
virtual void Mul(CBotVar* left, CBotVar* right); // multiplication
|
||||
virtual int Div(CBotVar* left, CBotVar* right); // division
|
||||
virtual int Modulo(CBotVar* left, CBotVar* right); // remainder of division
|
||||
virtual void Power(CBotVar* left, CBotVar* right); // power
|
||||
|
||||
virtual bool Lo(CBotVar* left, CBotVar* right);
|
||||
virtual bool Hi(CBotVar* left, CBotVar* right);
|
||||
virtual bool Ls(CBotVar* left, CBotVar* right);
|
||||
virtual bool Hs(CBotVar* left, CBotVar* right);
|
||||
virtual bool Eq(CBotVar* left, CBotVar* right);
|
||||
virtual bool Ne(CBotVar* left, CBotVar* right);
|
||||
|
||||
virtual void And(CBotVar* left, CBotVar* right);
|
||||
virtual void Or(CBotVar* left, CBotVar* right);
|
||||
virtual void XOr(CBotVar* left, CBotVar* right);
|
||||
virtual void ASR(CBotVar* left, CBotVar* right);
|
||||
virtual void SR(CBotVar* left, CBotVar* right);
|
||||
virtual void SL(CBotVar* left, CBotVar* right);
|
||||
|
||||
virtual void Neg();
|
||||
virtual void Not();
|
||||
virtual void Inc();
|
||||
virtual void Dec();
|
||||
|
||||
|
||||
virtual bool Save0State(FILE* pf);
|
||||
virtual bool Save1State(FILE* pf);
|
||||
static bool RestoreState(FILE* pf, CBotVar* &pVar);
|
||||
|
||||
void debug();
|
||||
|
||||
// virtual
|
||||
// CBotVar* GetMyThis();
|
||||
|
||||
virtual
|
||||
void Maj(void* pUser = nullptr, bool bContinue = true);
|
||||
|
||||
void SetUniqNum(long n);
|
||||
long GetUniqNum();
|
||||
static long NextUniqNum();
|
||||
};
|
||||
|
||||
/* NOTE (#)
|
||||
methods SetValInt() SetValFloat() et SetValString()
|
||||
can be called with objects which are respectively integer, real or string
|
||||
Always be sure of the type of the variable before calling these methods
|
||||
|
||||
if ( pVar->GetType() == CBotInt() ) pVar->SetValFloat( 3.3 ); // plante !!
|
||||
|
||||
methods GetValInt(), GetValFloat() et GetValString()
|
||||
use value conversions,
|
||||
GetValString() works on numbers (makes the corresponding string)
|
||||
but do not make GetValInt () with a string variable!
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Examples of use
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// Modules inlcude
|
||||
#include "CBot.h"
|
||||
|
||||
#include "CBotDefines.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
#include "CBotDefParam.h"
|
||||
#include "CBotUtils.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
|
||||
#include "CBotDefines.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "CBotStack.h"
|
||||
#include "CBotClass.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "CBotStack.h"
|
||||
#include "CBotClass.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "CBotExprNan.h"
|
||||
#include "CBotExpression.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "CBotClass.h"
|
||||
#include "CBotStack.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -17,13 +17,9 @@
|
|||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Definition for the class CBotVar
|
||||
// variables management of the language CBoT
|
||||
|
||||
// it never creates an instance of the class mother CBotVar
|
||||
|
||||
#include "CBot.h"
|
||||
// Modules inlcude
|
||||
#include "CBotVar.h"
|
||||
|
||||
#include "CBotStack.h"
|
||||
|
||||
|
@ -37,12 +33,17 @@
|
|||
|
||||
#include "CBotClass.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long CBotVar::m_identcpt = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar::CBotVar( )
|
||||
{
|
||||
m_next = nullptr;
|
||||
|
@ -57,12 +58,14 @@ CBotVar::CBotVar( )
|
|||
m_mPrivate = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar::~CBotVar( )
|
||||
{
|
||||
delete m_token;
|
||||
delete m_next;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::debug()
|
||||
{
|
||||
// const char* p = static_cast<const char*>( m_token->GetString());
|
||||
|
@ -80,11 +83,13 @@ void CBotVar::debug()
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::ConstructorSet()
|
||||
{
|
||||
// nop
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetUserPtr(void* pUser)
|
||||
{
|
||||
m_pUserPtr = pUser;
|
||||
|
@ -93,6 +98,7 @@ void CBotVar::SetUserPtr(void* pUser)
|
|||
(static_cast<CBotVarPointer*>(this))->m_pVarClass->SetUserPtr(pUser);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetIdent(long n)
|
||||
{
|
||||
if (m_type.Eq(CBotTypPointer) &&
|
||||
|
@ -100,6 +106,7 @@ void CBotVar::SetIdent(long n)
|
|||
(static_cast<CBotVarPointer*>(this))->m_pVarClass->SetIdent(n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetUniqNum(long n)
|
||||
{
|
||||
m_ident = n;
|
||||
|
@ -107,23 +114,26 @@ void CBotVar::SetUniqNum(long n)
|
|||
if ( n == 0 ) assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long CBotVar::NextUniqNum()
|
||||
{
|
||||
if (++m_identcpt < 10000) m_identcpt = 10000;
|
||||
return m_identcpt;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
long CBotVar::GetUniqNum()
|
||||
{
|
||||
return m_ident;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void* CBotVar::GetUserPtr()
|
||||
{
|
||||
return m_pUserPtr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Save1State(FILE* pf)
|
||||
{
|
||||
// this routine "virtual" must never be called,
|
||||
|
@ -133,21 +143,21 @@ bool CBotVar::Save1State(FILE* pf)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Maj(void* pUser, bool bContinu)
|
||||
{
|
||||
/* if (!bContinu && m_pMyThis != nullptr)
|
||||
m_pMyThis->Maj(pUser, true);*/
|
||||
}
|
||||
|
||||
|
||||
// creates a variable depending on its type
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::Create(const CBotToken* name, int type )
|
||||
{
|
||||
CBotTypResult t(type);
|
||||
return Create(name, t);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type)
|
||||
{
|
||||
switch (type.GetType())
|
||||
|
@ -201,13 +211,14 @@ CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::Create( CBotVar* pVar )
|
||||
{
|
||||
CBotVar* p = Create(pVar->m_token->GetString(), pVar->GetTypResult(2));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::Create( const char* n, CBotTypResult type)
|
||||
{
|
||||
CBotToken name(n);
|
||||
|
@ -272,6 +283,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::Create( const char* name, int type, CBotClass* pClass)
|
||||
{
|
||||
CBotToken token( name, "" );
|
||||
|
@ -293,6 +305,7 @@ CBotVar* CBotVar::Create( const char* name, int type, CBotClass* pClass)
|
|||
return pVar;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::Create( const char* name, CBotClass* pClass)
|
||||
{
|
||||
CBotToken token( name, "" );
|
||||
|
@ -301,11 +314,13 @@ CBotVar* CBotVar::Create( const char* name, CBotClass* pClass)
|
|||
return pVar;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Destroy(CBotVar* var)
|
||||
{
|
||||
delete var;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult CBotVar::GetTypResult(int mode)
|
||||
{
|
||||
CBotTypResult r = m_type;
|
||||
|
@ -318,6 +333,7 @@ CBotTypResult CBotVar::GetTypResult(int mode)
|
|||
return r;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotVar::GetType(int mode)
|
||||
{
|
||||
if ( mode == 1 && m_type.Eq(CBotTypClass) )
|
||||
|
@ -327,11 +343,13 @@ int CBotVar::GetType(int mode)
|
|||
return m_type.GetType();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetType(CBotTypResult& type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar::InitType CBotVar::GetInit() const
|
||||
{
|
||||
if ( m_type.Eq(CBotTypClass) ) return InitType::DEF; // always set!
|
||||
|
@ -339,6 +357,7 @@ CBotVar::InitType CBotVar::GetInit() const
|
|||
return m_binit;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetInit(CBotVar::InitType bInit)
|
||||
{
|
||||
m_binit = bInit;
|
||||
|
@ -368,46 +387,53 @@ void CBotVar::SetInit(CBotVar::InitType bInit)
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotString CBotVar::GetName()
|
||||
{
|
||||
return m_token->GetString();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetName(const char* name)
|
||||
{
|
||||
m_token->SetString(name);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotToken* CBotVar::GetToken()
|
||||
{
|
||||
return m_token;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::GetItem(const char* name)
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::GetItemRef(int nIdent)
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::GetItemList()
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::GetItem(int row, bool bGrow)
|
||||
{
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// check if a variable belongs to a given class
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::IsElemOfClass(const char* name)
|
||||
{
|
||||
CBotClass* pc = nullptr;
|
||||
|
@ -430,7 +456,7 @@ bool CBotVar::IsElemOfClass(const char* name)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::GetStaticVar()
|
||||
{
|
||||
// makes the pointer to the variable if it is static
|
||||
|
@ -440,12 +466,13 @@ CBotVar* CBotVar::GetStaticVar()
|
|||
return pClass->GetItem( m_token->GetString() );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVar* CBotVar::GetNext()
|
||||
{
|
||||
return m_next;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::AddNext(CBotVar* pVar)
|
||||
{
|
||||
CBotVar* p = this;
|
||||
|
@ -454,6 +481,7 @@ void CBotVar::AddNext(CBotVar* pVar)
|
|||
p->m_next = pVar;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetVal(CBotVar* var)
|
||||
{
|
||||
switch (var->GetType())
|
||||
|
@ -489,37 +517,43 @@ void CBotVar::SetVal(CBotVar* var)
|
|||
m_binit = var->m_binit; // copie l'état nan s'il y a
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetStatic(bool bStatic)
|
||||
{
|
||||
m_bStatic = bStatic;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetPrivate(int mPrivate)
|
||||
{
|
||||
m_mPrivate = mPrivate;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::IsStatic()
|
||||
{
|
||||
return m_bStatic;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::IsPrivate(int mode)
|
||||
{
|
||||
return m_mPrivate >= mode;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotVar::GetPrivate()
|
||||
{
|
||||
return m_mPrivate;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetPointer(CBotVar* pVarClass)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotVarClass* CBotVar::GetPointer()
|
||||
{
|
||||
assert(0);
|
||||
|
@ -528,167 +562,198 @@ CBotVarClass* CBotVar::GetPointer()
|
|||
|
||||
// All these functions must be defined in the subclasses
|
||||
// derived from class CBotVar
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotVar::GetValInt()
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float CBotVar::GetValFloat()
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetValInt(int c, const char* s)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetValFloat(float c)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Mul(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Power(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotVar::Div(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotVar::Modulo(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Add(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Sub(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Lo(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Hi(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Ls(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Hs(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Eq(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotVar::Ne(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::And(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Or(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::XOr(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::ASR(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SR(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SL(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Neg()
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Not()
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Inc()
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Dec()
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::Copy(CBotVar* pSrc, bool bName)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetValString(const char* p)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotString CBotVar::GetValString()
|
||||
{
|
||||
assert(0);
|
||||
return CBotString();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotVar::SetClass(CBotClass* pClass)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotClass* CBotVar::GetClass()
|
||||
{
|
||||
assert(0);
|
||||
|
@ -698,7 +763,7 @@ CBotClass* CBotVar::GetClass()
|
|||
///////////////////////////////////////////////////////
|
||||
// management of results types
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::CBotTypResult(int type)
|
||||
{
|
||||
m_type = type;
|
||||
|
@ -707,6 +772,7 @@ CBotTypResult::CBotTypResult(int type)
|
|||
m_limite = -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::CBotTypResult(int type, const char* name)
|
||||
{
|
||||
m_type = type;
|
||||
|
@ -723,6 +789,7 @@ CBotTypResult::CBotTypResult(int type, const char* name)
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::CBotTypResult(int type, CBotClass* pClass)
|
||||
{
|
||||
m_type = type;
|
||||
|
@ -733,6 +800,7 @@ CBotTypResult::CBotTypResult(int type, CBotClass* pClass)
|
|||
if ( m_pClass && m_pClass->IsIntrinsic() ) m_type = CBotTypIntrinsic;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::CBotTypResult(int type, CBotTypResult elem)
|
||||
{
|
||||
m_type = type;
|
||||
|
@ -745,6 +813,7 @@ CBotTypResult::CBotTypResult(int type, CBotTypResult elem)
|
|||
m_pNext = new CBotTypResult( elem );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::CBotTypResult(const CBotTypResult& typ)
|
||||
{
|
||||
m_type = typ.m_type;
|
||||
|
@ -756,6 +825,7 @@ CBotTypResult::CBotTypResult(const CBotTypResult& typ)
|
|||
m_pNext = new CBotTypResult( *typ.m_pNext );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::CBotTypResult()
|
||||
{
|
||||
m_type = 0;
|
||||
|
@ -764,11 +834,13 @@ CBotTypResult::CBotTypResult()
|
|||
m_pClass = nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult::~CBotTypResult()
|
||||
{
|
||||
delete m_pNext;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotTypResult::GetType(int mode) const
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
@ -786,31 +858,37 @@ int CBotTypResult::GetType(int mode) const
|
|||
return m_type;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotTypResult::SetType(int n)
|
||||
{
|
||||
m_type = n;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotClass* CBotTypResult::GetClass() const
|
||||
{
|
||||
return m_pClass;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult& CBotTypResult::GetTypElem() const
|
||||
{
|
||||
return *m_pNext;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CBotTypResult::GetLimite() const
|
||||
{
|
||||
return m_limite;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotTypResult::SetLimite(int n)
|
||||
{
|
||||
m_limite = n;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CBotTypResult::SetArray( int* max )
|
||||
{
|
||||
m_limite = *max;
|
||||
|
@ -822,8 +900,7 @@ void CBotTypResult::SetArray( int* max )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotTypResult::Compare(const CBotTypResult& typ) const
|
||||
{
|
||||
if ( m_type != typ.m_type ) return false;
|
||||
|
@ -840,13 +917,14 @@ bool CBotTypResult::Compare(const CBotTypResult& typ) const
|
|||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CBotTypResult::Eq(int type) const
|
||||
{
|
||||
return m_type == type;
|
||||
}
|
||||
|
||||
CBotTypResult&
|
||||
CBotTypResult::operator=(const CBotTypResult& src)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CBotTypResult& CBotTypResult::operator=(const CBotTypResult& src)
|
||||
{
|
||||
m_type = src.m_type;
|
||||
m_limite = src.m_limite;
|
|
@ -0,0 +1,624 @@
|
|||
/*
|
||||
* 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 "../CBotDll.h"
|
||||
|
||||
#include "../CBotDefines.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
||||
|
||||
/*!
|
||||
* \brief The CBotVar class Class for managing variables. May be useful to the
|
||||
* outside of the module ( it is currently not expected to be able to create
|
||||
* these objects in outer ). It never creates an instance of the class mother
|
||||
* CBotVar.
|
||||
*/
|
||||
class CBotVar
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief The InitType enum Results of GetInit().
|
||||
*/
|
||||
enum class InitType : int
|
||||
{
|
||||
UNDEF = 0,
|
||||
DEF = 1,
|
||||
IS_POINTER = 2,
|
||||
IS_NAN = 999
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief CBotVar
|
||||
*/
|
||||
CBotVar();
|
||||
|
||||
/*!
|
||||
* \brief ~CBotVar Destructor.
|
||||
*/
|
||||
virtual ~CBotVar( );
|
||||
|
||||
/*!
|
||||
* \brief Create Creates from a complete type.
|
||||
* \param name
|
||||
* \param type
|
||||
* \return
|
||||
*/
|
||||
static CBotVar* Create( const char* name, CBotTypResult type);
|
||||
|
||||
/*!
|
||||
* \brief Create Creates from one instance of a known class.
|
||||
* \param name
|
||||
* \param pClass
|
||||
* \return
|
||||
*/
|
||||
static CBotVar* Create( const char* name, CBotClass* pClass);
|
||||
|
||||
/*!
|
||||
* \brief Create Creates a variable depending on its type.
|
||||
* \param name
|
||||
* \param type
|
||||
* \return
|
||||
*/
|
||||
static CBotVar* Create( const CBotToken* name, int type );
|
||||
|
||||
/*!
|
||||
* \brief Create
|
||||
* \param name
|
||||
* \param type
|
||||
* \return
|
||||
*/
|
||||
static CBotVar* Create( const CBotToken* name, CBotTypResult type );
|
||||
|
||||
/*!
|
||||
* \brief Create
|
||||
* \param name
|
||||
* \param type
|
||||
* \param pClass
|
||||
* \return
|
||||
*/
|
||||
static CBotVar* Create( const char* name, int type, CBotClass* pClass);
|
||||
|
||||
/*!
|
||||
* \brief Create
|
||||
* \param pVar
|
||||
* \return
|
||||
*/
|
||||
static CBotVar* Create( CBotVar* pVar );
|
||||
|
||||
/*!
|
||||
* \brief Destroy
|
||||
* \param var
|
||||
*/
|
||||
static void Destroy(CBotVar* var);
|
||||
|
||||
/*!
|
||||
* \brief SetUserPtr Associate a user pointer to an instance.
|
||||
* \param pUser
|
||||
*/
|
||||
void SetUserPtr(void* pUser);
|
||||
|
||||
/*!
|
||||
* \brief SetIdent Associates a unique identifier to an instance
|
||||
* ( it is used to ensure that the id is unique)
|
||||
* \param UniqId
|
||||
*/
|
||||
virtual void SetIdent(long UniqId);
|
||||
|
||||
/*!
|
||||
* \brief GetUserPtr Makes the pointer associated with the variable.
|
||||
* \return
|
||||
*/
|
||||
void* GetUserPtr();
|
||||
|
||||
/*!
|
||||
* \brief GetName The name of the variable, if known.
|
||||
* \return
|
||||
*/
|
||||
CBotString GetName();
|
||||
|
||||
/*!
|
||||
* \brief SetName Changes the name of the variable
|
||||
* \param name
|
||||
*/
|
||||
void SetName(const char* name);
|
||||
|
||||
/*!
|
||||
* \brief GetType Returns the base type (int) of the variable
|
||||
* \param mode
|
||||
* \return
|
||||
* \todo Check it?
|
||||
*/
|
||||
int GetType(int mode = 0);
|
||||
|
||||
/*!
|
||||
* \brief GetTypResult Returns the complete type of the variable.
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
CBotTypResult GetTypResult(int mode = 0);
|
||||
|
||||
/*!
|
||||
* \brief GetToken
|
||||
* \return
|
||||
*/
|
||||
CBotToken* GetToken();
|
||||
|
||||
/*!
|
||||
* \brief SetType
|
||||
* \param type
|
||||
*/
|
||||
void SetType(CBotTypResult& type);
|
||||
|
||||
/*!
|
||||
* \brief SetInit Is the variable in the state UNDEF, DEF, NAN.
|
||||
* \param initType
|
||||
*/
|
||||
void SetInit(InitType initType);
|
||||
|
||||
/*!
|
||||
* \brief GetInit Gives the state of the variable.
|
||||
* \return
|
||||
*/
|
||||
InitType GetInit() const;
|
||||
|
||||
/*!
|
||||
* \brief IsUndefined
|
||||
* \return
|
||||
*/
|
||||
bool IsUndefined() const { return GetInit() == InitType::UNDEF; }
|
||||
|
||||
/*!
|
||||
* \brief IsDefined
|
||||
* \return
|
||||
*/
|
||||
bool IsDefined() const { return GetInit() == InitType::DEF; }
|
||||
|
||||
/*!
|
||||
* \brief IsNAN
|
||||
* \return
|
||||
*/
|
||||
bool IsNAN() const { return GetInit() == InitType::IS_NAN; }
|
||||
|
||||
/*!
|
||||
* \brief SetStatic
|
||||
* \param bStatic
|
||||
*/
|
||||
void SetStatic(bool bStatic);
|
||||
|
||||
/*!
|
||||
* \brief IsStatic
|
||||
* \return
|
||||
*/
|
||||
bool IsStatic();
|
||||
|
||||
/*!
|
||||
* \brief SetPrivate
|
||||
* \param mPrivate
|
||||
*/
|
||||
void SetPrivate(int mPrivate);
|
||||
|
||||
/*!
|
||||
* \brief IsPrivate
|
||||
* \param mode
|
||||
* \return
|
||||
*/
|
||||
bool IsPrivate(int mode = PR_PROTECT);
|
||||
|
||||
/*!
|
||||
* \brief GetPrivate
|
||||
* \return
|
||||
*/
|
||||
int GetPrivate();
|
||||
|
||||
/*!
|
||||
* \brief ConstructorSet
|
||||
*/
|
||||
virtual void ConstructorSet();
|
||||
|
||||
/*!
|
||||
* \brief SetVal Set the value.
|
||||
* \param var
|
||||
*/
|
||||
void SetVal(CBotVar* var);
|
||||
|
||||
/*!
|
||||
* \brief GetItem Returns an element of a class according to its name (*).
|
||||
* \param name
|
||||
* \return
|
||||
*/
|
||||
virtual CBotVar* GetItem(const char* name);
|
||||
|
||||
/*!
|
||||
* \brief GetItemRef
|
||||
* \param nIdent
|
||||
* \return
|
||||
*/
|
||||
virtual CBotVar* GetItemRef(int nIdent);
|
||||
|
||||
/*!
|
||||
* \brief GetItem
|
||||
* \param row
|
||||
* \param bGrow
|
||||
* \return
|
||||
*/
|
||||
virtual CBotVar* GetItem(int row, bool bGrow = false);
|
||||
|
||||
/*!
|
||||
* \brief GetItemList Lists the elements.
|
||||
* \return
|
||||
*/
|
||||
virtual CBotVar* GetItemList();
|
||||
|
||||
/*!
|
||||
* \brief GetStaticVar Makes the pointer to the variable if it is static.
|
||||
* \return
|
||||
*/
|
||||
CBotVar* GetStaticVar();
|
||||
|
||||
/*!
|
||||
* \brief IsElemOfClass Check if a variable belongs to a given class said if
|
||||
* the element belongs to the class "name" makes true if the object is a
|
||||
* subclass.
|
||||
* \param name
|
||||
* \return
|
||||
*/
|
||||
bool IsElemOfClass(const char* name);
|
||||
|
||||
/*!
|
||||
* \brief GetNext Next variable in the list (parameters).
|
||||
* \return
|
||||
*/
|
||||
CBotVar* GetNext();
|
||||
|
||||
/*!
|
||||
* \brief AddNext Added to a list.
|
||||
* \param pVar
|
||||
*/
|
||||
void AddNext(CBotVar* pVar);
|
||||
|
||||
/*!
|
||||
* \brief Copy Makes a copy of the variable.
|
||||
* \param pSrc
|
||||
* \param bName
|
||||
*/
|
||||
virtual void Copy(CBotVar* pSrc, bool bName = true);
|
||||
|
||||
/*!
|
||||
* \brief SetValInt Initialized with an integer value (#)
|
||||
* \param val
|
||||
* \param name
|
||||
*/
|
||||
virtual void SetValInt(int val, const char* name = nullptr);
|
||||
|
||||
/*!
|
||||
* \brief SetValFloat Initialized with a real value (#).
|
||||
* \param val
|
||||
*/
|
||||
virtual void SetValFloat(float val);
|
||||
|
||||
/*!
|
||||
* \brief SetValString Initialized with a string value (#).
|
||||
* \param p
|
||||
*/
|
||||
virtual void SetValString(const char* p);
|
||||
|
||||
/*!
|
||||
* \brief GetValInt Request the full value (#).
|
||||
* \return
|
||||
*/
|
||||
virtual int GetValInt();
|
||||
|
||||
/*!
|
||||
* \brief GetValFloat Gets real value (#).
|
||||
* \return
|
||||
*/
|
||||
virtual float GetValFloat();
|
||||
|
||||
/*!
|
||||
* \brief GetValString Request the string value (#).
|
||||
* \return
|
||||
*/
|
||||
virtual CBotString GetValString();
|
||||
|
||||
/*!
|
||||
* \brief SetClass
|
||||
* \param pClass
|
||||
*/
|
||||
virtual void SetClass(CBotClass* pClass);
|
||||
|
||||
/*!
|
||||
* \brief GetClass
|
||||
* \return
|
||||
*/
|
||||
virtual CBotClass* GetClass();
|
||||
|
||||
/*!
|
||||
* \brief SetPointer
|
||||
* \param p
|
||||
*/
|
||||
virtual void SetPointer(CBotVar* p);
|
||||
|
||||
/*!
|
||||
* \brief GetPointer
|
||||
* \return
|
||||
*/
|
||||
virtual CBotVarClass* GetPointer();
|
||||
|
||||
/*!
|
||||
* \brief Add Addition
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void Add(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Sub Subtraction
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void Sub(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Mul Multiplication
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void Mul(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Div Division
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual int Div(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Modulo Remainder of division
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual int Modulo(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Power
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void Power(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Lo
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual bool Lo(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Hi
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual bool Hi(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Ls
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual bool Ls(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Hs
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual bool Hs(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Eq
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual bool Eq(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Ne
|
||||
* \param left
|
||||
* \param right
|
||||
* \return
|
||||
*/
|
||||
virtual bool Ne(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief And
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void And(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Or
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void Or(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief XOr
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void XOr(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief ASR
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void ASR(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief SR
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void SR(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief SL
|
||||
* \param left
|
||||
* \param right
|
||||
*/
|
||||
virtual void SL(CBotVar* left, CBotVar* right);
|
||||
|
||||
/*!
|
||||
* \brief Neg
|
||||
*/
|
||||
virtual void Neg();
|
||||
|
||||
/*!
|
||||
* \brief Not
|
||||
*/
|
||||
virtual void Not();
|
||||
|
||||
/*!
|
||||
* \brief Inc
|
||||
*/
|
||||
virtual void Inc();
|
||||
|
||||
/*!
|
||||
* \brief Dec
|
||||
*/
|
||||
virtual void Dec();
|
||||
|
||||
/*!
|
||||
* \brief Save0State
|
||||
* \param pf
|
||||
* \return
|
||||
*/
|
||||
virtual bool Save0State(FILE* pf);
|
||||
|
||||
/*!
|
||||
* \brief Save1State
|
||||
* \param pf
|
||||
* \return
|
||||
*/
|
||||
virtual bool Save1State(FILE* pf);
|
||||
|
||||
/*!
|
||||
* \brief RestoreState
|
||||
* \param pf
|
||||
* \param pVar
|
||||
* \return
|
||||
*/
|
||||
static bool RestoreState(FILE* pf, CBotVar* &pVar);
|
||||
|
||||
/*!
|
||||
* \brief debug
|
||||
*/
|
||||
void debug();
|
||||
|
||||
/*!
|
||||
* \brief Maj
|
||||
* \param pUser
|
||||
* \param bContinue
|
||||
*/
|
||||
virtual void Maj(void* pUser = nullptr, bool bContinue = true);
|
||||
|
||||
/*!
|
||||
* \brief SetUniqNum
|
||||
* \param n
|
||||
*/
|
||||
void SetUniqNum(long n);
|
||||
|
||||
/*!
|
||||
* \brief GetUniqNum
|
||||
* \return
|
||||
*/
|
||||
long GetUniqNum();
|
||||
|
||||
/*!
|
||||
* \brief NextUniqNum
|
||||
* \return
|
||||
*/
|
||||
static long NextUniqNum();
|
||||
|
||||
protected:
|
||||
|
||||
//! The corresponding token.
|
||||
CBotToken* m_token;
|
||||
//! List of variables.
|
||||
CBotVar* m_next;
|
||||
//! Type of value.
|
||||
CBotTypResult m_type;
|
||||
//! Not initialized.
|
||||
InitType m_binit;
|
||||
//! Corresponding this element.
|
||||
CBotVarClass* m_pMyThis;
|
||||
//! User data if necessary.
|
||||
void* m_pUserPtr;
|
||||
//! Static element (in class).
|
||||
bool m_bStatic;
|
||||
//! Element public, protected or private.
|
||||
int m_mPrivate;
|
||||
//! Expression for the original content.
|
||||
CBotInstr* m_InitExpr;
|
||||
//! List of limits for a table.
|
||||
CBotInstr* m_LimExpr;
|
||||
//! Unique identifier.
|
||||
long m_ident;
|
||||
|
||||
//! Counter
|
||||
static long m_identcpt;
|
||||
|
||||
friend class CBotStack;
|
||||
friend class CBotCStack;
|
||||
friend class CBotInstrCall;
|
||||
friend class CBotProgram;
|
||||
friend class CBotClass;
|
||||
friend class CBotVarClass;
|
||||
friend class CBotVarPointer;
|
||||
friend class CBotVarArray;
|
||||
};
|
||||
|
||||
/* NOTE (#)
|
||||
methods SetValInt() SetValFloat() et SetValString()
|
||||
can be called with objects which are respectively integer, real or string
|
||||
Always be sure of the type of the variable before calling these methods
|
||||
|
||||
if ( pVar->GetType() == CBotInt() ) pVar->SetValFloat( 3.3 ); // plante !!
|
||||
|
||||
methods GetValInt(), GetValFloat() et GetValString()
|
||||
use value conversions,
|
||||
GetValString() works on numbers (makes the corresponding string)
|
||||
but do not make GetValInt () with a string variable!
|
||||
*/
|
|
@ -23,6 +23,8 @@
|
|||
#include "CBot.h"
|
||||
#include "CBotDefines.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// Modules inlcude
|
||||
#include "CBotToken.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// Modules inlcude
|
||||
#include "CBot.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// Modules inlcude
|
||||
#include "CBotDll.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// Modules inlcude
|
||||
#include "CBotDll.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#pragma once
|
||||
|
||||
// Modules inlcude
|
||||
#include "CBotDll.h"
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// Modules inlcude
|
||||
#include "CBotDll.h"
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// Local include
|
||||
|
||||
// Global include
|
||||
|
|
|
@ -5,7 +5,6 @@ set(SOURCES
|
|||
CBotStack.cpp
|
||||
CBotString.cpp
|
||||
CBotToken.cpp
|
||||
CBotVar.cpp
|
||||
CBotCall.cpp
|
||||
CBotUtils.cpp
|
||||
CBotDefParam.cpp
|
||||
|
@ -62,6 +61,7 @@ set(SOURCES
|
|||
CBotVar/CBotVarString.cpp
|
||||
CBotVar/CBotVarFloat.cpp
|
||||
CBotVar/CBotVarInt.cpp
|
||||
CBotVar/CBotVar.cpp
|
||||
)
|
||||
|
||||
# Includes
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
* along with this program. If not, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#include "CBotVar/CBotVar.h"
|
||||
|
||||
// definition of string functions
|
||||
|
||||
|
||||
// gives the length of a chain
|
||||
// execution
|
||||
|
||||
|
||||
bool rStrLen( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||
{
|
||||
// it takes a parameter
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "ui/controls/list.h"
|
||||
|
||||
#include "CBot/CBotToken.h"
|
||||
#include "CBot/CBotVar/CBotVar.h"
|
||||
|
||||
|
||||
const int CBOT_IPF = 100; // CBOT: default number of instructions / frame
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
// TODO must be replaced by CBot.h
|
||||
#include "CBot/CBotClass.h"
|
||||
#include "CBot/CBotVar/CBotVar.h"
|
||||
|
||||
#include "app/app.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue