Fixed crash from previous commit (oops again)

dev-time-step
krzys-h 2015-12-23 17:50:10 +01:00
parent 8fa5b208c2
commit 30fea5893b
32 changed files with 79 additions and 75 deletions

View File

@ -683,7 +683,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
// make "this" known // make "this" known
CBotToken TokenThis(std::string("this"), std::string()); CBotToken TokenThis(std::string("this"), std::string());
CBotVar* pThis = CBotVar::Create(&TokenThis, CBotTypResult( CBotTypClass, this ) ); CBotVar* pThis = CBotVar::Create(TokenThis, CBotTypResult( CBotTypClass, this ) );
pThis->SetUniqNum(-2); pThis->SetUniqNum(-2);
pile->AddVar(pThis); pile->AddVar(pThis);
@ -691,7 +691,7 @@ bool CBotClass::CompileDefItem(CBotToken* &p, CBotCStack* pStack, bool bSecond)
{ {
// makes "super" known // makes "super" known
CBotToken TokenSuper(std::string("super"), std::string()); CBotToken TokenSuper(std::string("super"), std::string());
CBotVar* pThis = CBotVar::Create(&TokenSuper, CBotTypResult( CBotTypClass, m_pParent ) ); CBotVar* pThis = CBotVar::Create(TokenSuper, CBotTypResult( CBotTypClass, m_pParent ) );
pThis->SetUniqNum(-3); pThis->SetUniqNum(-3);
pile->AddVar(pThis); pile->AddVar(pThis);
} }

View File

@ -107,7 +107,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
} }
} }
var = CBotVar::Create(vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment) var = CBotVar::Create(*vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment)
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
var->SetUniqNum( var->SetUniqNum(
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); (static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());

View File

@ -105,7 +105,7 @@ bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
if ( val > 0 || pile->GetType() != CBotTypBoolean ) if ( val > 0 || pile->GetType() != CBotTypBoolean )
{ {
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean); CBotVar* var = CBotVar::Create("", CBotTypBoolean);
var->SetValInt( pile->GetVal() == val ); var->SetValInt( pile->GetVal() == val );
pile->SetVar(var); // calls on the stack pile->SetVar(var); // calls on the stack
} }

View File

@ -50,7 +50,7 @@ CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack)
inst->SetToken(p); inst->SetToken(p);
p = p->GetNext(); p = p->GetNext();
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypString); CBotVar* var = CBotVar::Create("", CBotTypString);
pStk->SetVar(var); pStk->SetVar(var);
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
@ -63,7 +63,7 @@ bool CBotExprAlpha::Execute(CBotStack* &pj)
if (pile->IfStep()) return false; if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypString); CBotVar* var = CBotVar::Create("", CBotTypString);
std::string chaine = m_token.GetString(); std::string chaine = m_token.GetString();
chaine = chaine.substr(1, chaine.length()-2); // removes the quotes chaine = chaine.substr(1, chaine.length()-2); // removes the quotes

View File

@ -54,7 +54,7 @@ CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack)
inst->SetToken(p); // stores the operation false or true inst->SetToken(p); // stores the operation false or true
p = p->GetNext(); p = p->GetNext();
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean); CBotVar* var = CBotVar::Create("", CBotTypBoolean);
pStk->SetVar(var); pStk->SetVar(var);
} }
@ -68,7 +68,7 @@ bool CBotExprBool::Execute(CBotStack* &pj)
if (pile->IfStep()) return false; if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean); CBotVar* var = CBotVar::Create("", CBotTypBoolean);
if (GetTokenType() == ID_TRUE) var->SetValInt(1); if (GetTokenType() == ID_TRUE) var->SetValInt(1);
else var->SetValInt(0); else var->SetValInt(0);

View File

@ -45,7 +45,7 @@ bool CBotExprNan::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this); CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false; if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypInt); CBotVar* var = CBotVar::Create("", CBotTypInt);
var->SetInit(CBotVar::InitType::IS_NAN); // nan var->SetInit(CBotVar::InitType::IS_NAN); // nan
pile->SetVar(var); // put on the stack pile->SetVar(var); // put on the stack

View File

@ -46,7 +46,7 @@ bool CBotExprNull::Execute(CBotStack* &pj)
CBotStack* pile = pj->AddStack(this); CBotStack* pile = pj->AddStack(this);
if (pile->IfStep()) return false; if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypNullPointer); CBotVar* var = CBotVar::Create("", CBotTypNullPointer);
var->SetInit(CBotVar::InitType::DEF); // null pointer valid var->SetInit(CBotVar::InitType::DEF); // null pointer valid
pile->SetVar(var); // place on the stack pile->SetVar(var); // place on the stack

View File

@ -72,7 +72,7 @@ CBotInstr* CBotExprNum::Compile(CBotToken* &p, CBotCStack* pStack)
if (pStk->NextToken(p)) if (pStk->NextToken(p))
{ {
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), inst->m_numtype); CBotVar* var = CBotVar::Create("", inst->m_numtype);
pStk->SetVar(var); pStk->SetVar(var);
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
@ -88,7 +88,7 @@ bool CBotExprNum::Execute(CBotStack* &pj)
if (pile->IfStep()) return false; if (pile->IfStep()) return false;
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(nullptr), m_numtype); CBotVar* var = CBotVar::Create("", m_numtype);
std::string nombre ; std::string nombre ;
if (m_token.GetType() == TokenTypDef) if (m_token.GetType() == TokenTypDef)

View File

@ -105,7 +105,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool
} }
} }
var = CBotVar::Create(vartoken, CBotTypFloat); var = CBotVar::Create(*vartoken, CBotTypFloat);
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
var->SetUniqNum( var->SetUniqNum(
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); (static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());

View File

@ -236,7 +236,7 @@ CBotFunction* CBotFunction::Compile(CBotToken* &p, CBotCStack* pStack, CBotFunct
// and compiles the following instruction block // and compiles the following instruction block
func->m_openblk = *p; func->m_openblk = *p;
func->m_Block = CBotBlock::Compile(p, pStk, false); func->m_Block = CBotBlock::Compile(p, pStk, false);
func->m_closeblk = *(p->GetPrev()); func->m_closeblk = p->GetPrev() != nullptr ? *(p->GetPrev()) : CBotToken();
if ( pStk->IsOk() ) if ( pStk->IsOk() )
{ {
if ( func->m_bPublic ) // public function, return known for all if ( func->m_bPublic ) // public function, return known for all

View File

@ -89,7 +89,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
}*/ }*/
} }
CBotVar* var = CBotVar::Create(vartoken, CBotTypString); CBotVar* var = CBotVar::Create(*vartoken, CBotTypString);
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF);
var->SetUniqNum( var->SetUniqNum(
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); (static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());

View File

@ -89,7 +89,7 @@ CBotInstr* CBotInstArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
} }
} }
CBotVar* var = CBotVar::Create(vartoken, type); // create an instance CBotVar* var = CBotVar::Create(*vartoken, type); // create an instance
inst->m_typevar = type; inst->m_typevar = type;
var->SetUniqNum( var->SetUniqNum(
@ -157,7 +157,7 @@ bool CBotInstArray::Execute(CBotStack* &pj)
m_typevar.SetArray(max); // store the limitations m_typevar.SetArray(max); // store the limitations
// create simply a nullptr pointer // create simply a nullptr pointer
CBotVar* var = CBotVar::Create(m_var->GetToken(), m_typevar); CBotVar* var = CBotVar::Create(*(m_var->GetToken()), m_typevar);
var->SetPointer(nullptr); var->SetPointer(nullptr);
var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
pj->AddVar(var); pj->AddVar(var);

View File

@ -119,7 +119,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n
} }
{ {
CBotVar* var = CBotVar::Create(vartoken, CBotTypInt);// create the variable (evaluated after the assignment) CBotVar* var = CBotVar::Create(*vartoken, CBotTypInt);// create the variable (evaluated after the assignment)
var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); // if initialized with assignment var->SetInit(inst->m_expr != nullptr ? CBotVar::InitType::DEF : CBotVar::InitType::UNDEF); // if initialized with assignment
var->SetUniqNum( //set it with a unique number var->SetUniqNum( //set it with a unique number
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum()); (static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());

View File

@ -260,7 +260,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
CBotTypResult t(type1); CBotTypResult t(type1);
t.SetType(TypeRes); t.SetType(TypeRes);
// is a variable on the stack for the type of result // is a variable on the stack for the type of result
pStk->SetVar(CBotVar::Create(static_cast<CBotToken*>(nullptr), t)); pStk->SetVar(CBotVar::Create("", t));
// and returns the requested object // and returns the requested object
return pStack->Return(inst, pStk); return pStack->Return(inst, pStk);
@ -313,14 +313,14 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
// for OR and AND logic does not evaluate the second expression if not necessary // for OR and AND logic does not evaluate the second expression if not necessary
if ( (GetTokenType() == ID_LOG_AND || GetTokenType() == ID_TXT_AND ) && pStk1->GetVal() == false ) if ( (GetTokenType() == ID_LOG_AND || GetTokenType() == ID_TXT_AND ) && pStk1->GetVal() == false )
{ {
CBotVar* res = CBotVar::Create( static_cast<CBotToken*>(nullptr), CBotTypBoolean); CBotVar* res = CBotVar::Create("", CBotTypBoolean);
res->SetValInt(false); res->SetValInt(false);
pStk1->SetVar(res); pStk1->SetVar(res);
return pStack->Return(pStk1); // transmits the result return pStack->Return(pStk1); // transmits the result
} }
if ( (GetTokenType() == ID_LOG_OR||GetTokenType() == ID_TXT_OR) && pStk1->GetVal() == true ) if ( (GetTokenType() == ID_LOG_OR||GetTokenType() == ID_TXT_OR) && pStk1->GetVal() == true )
{ {
CBotVar* res = CBotVar::Create( static_cast<CBotToken*>(nullptr), CBotTypBoolean); CBotVar* res = CBotVar::Create("", CBotTypBoolean);
res->SetValInt(true); res->SetValInt(true);
pStk1->SetVar(res); pStk1->SetVar(res);
return pStack->Return(pStk1); // transmits the result return pStack->Return(pStk1); // transmits the result
@ -378,7 +378,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
} }
// creates a variable for the result // creates a variable for the result
CBotVar* result = CBotVar::Create( static_cast<CBotToken*>(nullptr), TypeRes); CBotVar* result = CBotVar::Create("", TypeRes);
// creates a variable to perform the calculation in the appropriate type // creates a variable to perform the calculation in the appropriate type
TypeRes = MAX(type1.GetType(), type2.GetType()); TypeRes = MAX(type1.GetType(), type2.GetType());
@ -391,8 +391,8 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
CBotVar* temp; CBotVar* temp;
if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer; if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer;
if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( static_cast<CBotToken*>(nullptr), CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) ); if ( TypeRes == CBotTypClass ) temp = CBotVar::Create("", CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) );
else temp = CBotVar::Create( static_cast<CBotToken*>(nullptr), TypeRes ); else temp = CBotVar::Create("", TypeRes );
CBotError err = CBotNoErr; CBotError err = CBotNoErr;
// is a operation according to request // is a operation according to request

View File

@ -1021,17 +1021,17 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
{ {
case CBotTypInt: case CBotTypInt:
case CBotTypBoolean: case CBotTypBoolean:
pNew = CBotVar::Create(&token, w); // creates a variable pNew = CBotVar::Create(token, w); // creates a variable
if (!ReadWord(pf, w)) return false; if (!ReadWord(pf, w)) return false;
pNew->SetValInt(static_cast<short>(w), defnum); pNew->SetValInt(static_cast<short>(w), defnum);
break; break;
case CBotTypFloat: case CBotTypFloat:
pNew = CBotVar::Create(&token, w); // creates a variable pNew = CBotVar::Create(token, w); // creates a variable
if (!ReadFloat(pf, ww)) return false; if (!ReadFloat(pf, ww)) return false;
pNew->SetValFloat(ww); pNew->SetValFloat(ww);
break; break;
case CBotTypString: case CBotTypString:
pNew = CBotVar::Create(&token, w); // creates a variable pNew = CBotVar::Create(token, w); // creates a variable
if (!ReadString(pf, s)) return false; if (!ReadString(pf, s)) return false;
pNew->SetValString(s); pNew->SetValString(s);
break; break;
@ -1050,7 +1050,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
CBotVar* p = nullptr; CBotVar* p = nullptr;
if ( id ) p = CBotVarClass::Find(id) ; if ( id ) p = CBotVarClass::Find(id) ;
pNew = new CBotVarClass(&token, r); // directly creates an instance pNew = new CBotVarClass(token, r); // directly creates an instance
// attention cptuse = 0 // attention cptuse = 0
if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false; if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
pNew->SetIdent(id); pNew->SetIdent(id);
@ -1068,7 +1068,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
case CBotTypNullPointer: case CBotTypNullPointer:
if (!ReadString(pf, s)) return false; if (!ReadString(pf, s)) return false;
{ {
pNew = CBotVar::Create(&token, CBotTypResult(w, s));// creates a variable pNew = CBotVar::Create(token, CBotTypResult(w, s));// creates a variable
// CBotVarClass* p = nullptr; // CBotVarClass* p = nullptr;
long id; long id;
ReadLong(pf, id); ReadLong(pf, id);
@ -1089,7 +1089,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
CBotTypResult r; CBotTypResult r;
if (!ReadType(pf, r)) return false; if (!ReadType(pf, r)) return false;
pNew = CBotVar::Create(&token, r); // creates a variable pNew = CBotVar::Create(token, r); // creates a variable
// returns a copy of the original instance // returns a copy of the original instance
CBotVar* pInstance = nullptr; CBotVar* pInstance = nullptr;

View File

@ -186,12 +186,16 @@ void CBotToken::ClearDefineNum()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
const CBotToken& CBotToken::operator=(const CBotToken& src) const CBotToken& CBotToken::operator=(const CBotToken& src)
{ {
delete m_next; assert(m_prev == nullptr);
m_next = nullptr; if (m_next != nullptr)
m_prev = nullptr; {
m_next->m_prev = nullptr;
delete m_next;
m_next = nullptr;
}
m_text = src.m_text; m_text = src.m_text;
m_sep = src.m_sep; m_sep = src.m_sep;
m_type = src.m_type; m_type = src.m_type;
m_keywordId = src.m_keywordId; m_keywordId = src.m_keywordId;

View File

@ -137,14 +137,14 @@ void CBotVar::Maj(void* pUser, bool bContinu)
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVar* CBotVar::Create(const CBotToken* name, CBotType type ) CBotVar* CBotVar::Create(const CBotToken& name, CBotType type)
{ {
CBotTypResult t(type); CBotTypResult t(type);
return Create(name, t); return Create(name, t);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type) CBotVar* CBotVar::Create(const CBotToken& name, CBotTypResult type)
{ {
switch (type.GetType()) switch (type.GetType())
{ {
@ -213,23 +213,23 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type)
{ {
case CBotTypShort: case CBotTypShort:
case CBotTypInt: case CBotTypInt:
return new CBotVarInt(&name); return new CBotVarInt(name);
case CBotTypFloat: case CBotTypFloat:
return new CBotVarFloat(&name); return new CBotVarFloat(name);
case CBotTypBoolean: case CBotTypBoolean:
return new CBotVarBoolean(&name); return new CBotVarBoolean(name);
case CBotTypString: case CBotTypString:
return new CBotVarString(&name); return new CBotVarString(name);
case CBotTypPointer: case CBotTypPointer:
case CBotTypNullPointer: case CBotTypNullPointer:
{ {
CBotVarPointer* p = new CBotVarPointer(&name, type); CBotVarPointer* p = new CBotVarPointer(name, type);
// p->SetClass(type.GetClass()); // p->SetClass(type.GetClass());
return p; return p;
} }
case CBotTypIntrinsic: case CBotTypIntrinsic:
{ {
CBotVarClass* p = new CBotVarClass(&name, type); CBotVarClass* p = new CBotVarClass(name, type);
// p->SetClass(type.GetClass()); // p->SetClass(type.GetClass());
return p; return p;
} }
@ -238,20 +238,20 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type)
// creates a new instance of a class // creates a new instance of a class
// and returns the POINTER on this instance // and returns the POINTER on this instance
{ {
CBotVarClass* instance = new CBotVarClass(&name, type); CBotVarClass* instance = new CBotVarClass(name, type);
CBotVarPointer* pointer = new CBotVarPointer(&name, type); CBotVarPointer* pointer = new CBotVarPointer(name, type);
pointer->SetPointer( instance ); pointer->SetPointer( instance );
// pointer->SetClass( type.GetClass() ); // pointer->SetClass( type.GetClass() );
return pointer; return pointer;
} }
case CBotTypArrayPointer: case CBotTypArrayPointer:
return new CBotVarArray(&name, type); return new CBotVarArray(name, type);
case CBotTypArrayBody: case CBotTypArrayBody:
{ {
CBotVarClass* instance = new CBotVarClass(&name, type); CBotVarClass* instance = new CBotVarClass(name, type);
CBotVarArray* array = new CBotVarArray(&name, type); CBotVarArray* array = new CBotVarArray(name, type);
array->SetPointer( instance ); array->SetPointer( instance );
CBotVar* pv = array; CBotVar* pv = array;
@ -273,7 +273,7 @@ CBotVar* CBotVar::Create(const std::string& n, CBotTypResult type)
CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pClass) CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pClass)
{ {
CBotToken token( name, "" ); CBotToken token( name, "" );
CBotVar* pVar = Create( &token, type ); CBotVar* pVar = Create( token, type );
if ( type == CBotTypPointer && pClass == nullptr ) // pointer "null" ? if ( type == CBotTypPointer && pClass == nullptr ) // pointer "null" ?
return pVar; return pVar;
@ -295,7 +295,7 @@ CBotVar* CBotVar::Create(const std::string& name, CBotType type, CBotClass* pCla
CBotVar* CBotVar::Create(const std::string& name, CBotClass* pClass) CBotVar* CBotVar::Create(const std::string& name, CBotClass* pClass)
{ {
CBotToken token( name, "" ); CBotToken token( name, "" );
CBotVar* pVar = Create( &token, CBotTypResult( CBotTypClass, pClass ) ); CBotVar* pVar = Create( token, CBotTypResult( CBotTypClass, pClass ) );
// pVar->SetClass( pClass ); // pVar->SetClass( pClass );
return pVar; return pVar;
} }
@ -354,7 +354,7 @@ void CBotVar::SetInit(CBotVar::InitType initType)
CBotVarClass* instance = GetPointer(); CBotVarClass* instance = GetPointer();
if ( instance == nullptr ) if ( instance == nullptr )
{ {
instance = new CBotVarClass(nullptr, m_type); instance = new CBotVarClass(CBotToken(), m_type);
// instance->SetClass((static_cast<CBotVarPointer*>(this))->m_classes); // instance->SetClass((static_cast<CBotVarPointer*>(this))->m_classes);
SetPointer(instance); SetPointer(instance);
} }

View File

@ -82,14 +82,14 @@ public:
* \param name Variable name token * \param name Variable name token
* \param type Variable type * \param type Variable type
*/ */
static CBotVar* Create(const CBotToken* name, CBotType type); static CBotVar* Create(const CBotToken& name, CBotType type);
/** /**
* \brief Create a new variable of a given type described by CBotTypResult * \brief Create a new variable of a given type described by CBotTypResult
* \param name Variable name token * \param name Variable name token
* \param type Variable type * \param type Variable type
*/ */
static CBotVar* Create(const CBotToken* name, CBotTypResult type); static CBotVar* Create(const CBotToken& name, CBotTypResult type);
/** /**
* \brief Create a new variable of a given type of given class instance * \brief Create a new variable of a given type of given class instance

View File

@ -31,12 +31,12 @@
#include <cassert> #include <cassert>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarArray::CBotVarArray(const CBotToken* name, CBotTypResult& type ) CBotVarArray::CBotVarArray(const CBotToken& name, CBotTypResult& type)
{ {
if ( !type.Eq(CBotTypArrayPointer) && if ( !type.Eq(CBotTypArrayPointer) &&
!type.Eq(CBotTypArrayBody)) assert(0); !type.Eq(CBotTypArrayBody)) assert(0);
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = nullptr; m_pUserPtr = nullptr;
@ -117,7 +117,7 @@ CBotVar* CBotVarArray::GetItem(int n, bool bExtend)
if ( !bExtend ) return nullptr; if ( !bExtend ) return nullptr;
// creates an instance of the table // creates an instance of the table
CBotVarClass* instance = new CBotVarClass(nullptr, m_type); CBotVarClass* instance = new CBotVarClass(CBotToken(), m_type);
SetPointer( instance ); SetPointer( instance );
} }
return m_pInstance->GetItem(n, bExtend); return m_pInstance->GetItem(n, bExtend);

View File

@ -32,7 +32,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarArray(const CBotToken* name, CBotTypResult& type); CBotVarArray(const CBotToken& name, CBotTypResult& type);
/** /**
* \brief Destructor. Do not call directly, use CBotVar::Destroy() * \brief Destructor. Do not call directly, use CBotVar::Destroy()
*/ */

View File

@ -26,9 +26,9 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarBoolean::CBotVarBoolean( const CBotToken* name ) CBotVarBoolean::CBotVarBoolean(const CBotToken& name)
{ {
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = nullptr; m_pUserPtr = nullptr;

View File

@ -30,7 +30,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarBoolean(const CBotToken* name); CBotVarBoolean(const CBotToken& name);
void SetValInt(int val, const std::string& s = nullptr) override; void SetValInt(int val, const std::string& s = nullptr) override;
void SetValFloat(float val) override; void SetValFloat(float val) override;

View File

@ -37,7 +37,7 @@
CBotVarClass* CBotVarClass::m_ExClass = nullptr; CBotVarClass* CBotVarClass::m_ExClass = nullptr;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type) CBotVarClass::CBotVarClass(const CBotToken& name, const CBotTypResult& type)
{ {
if ( !type.Eq(CBotTypClass) && if ( !type.Eq(CBotTypClass) &&
!type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types !type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types
@ -45,7 +45,7 @@ CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type)
!type.Eq(CBotTypArrayPointer) && !type.Eq(CBotTypArrayPointer) &&
!type.Eq(CBotTypArrayBody)) assert(0); !type.Eq(CBotTypArrayBody)) assert(0);
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = OBJECTCREATED;//nullptr; m_pUserPtr = OBJECTCREATED;//nullptr;

View File

@ -32,7 +32,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarClass(const CBotToken* name, const CBotTypResult& type); CBotVarClass(const CBotToken& name, const CBotTypResult& type);
/** /**
* \brief Destructor. Do not call directly, use CBotVar::Destroy() * \brief Destructor. Do not call directly, use CBotVar::Destroy()
*/ */

View File

@ -31,9 +31,9 @@
#include <cmath> #include <cmath>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarFloat::CBotVarFloat( const CBotToken* name ) CBotVarFloat::CBotVarFloat(const CBotToken& name)
{ {
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = nullptr; m_pUserPtr = nullptr;

View File

@ -30,7 +30,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarFloat(const CBotToken* name); CBotVarFloat(const CBotToken& name);
void SetValInt(int val, const std::string& s = nullptr) override; void SetValInt(int val, const std::string& s = nullptr) override;
void SetValFloat(float val) override; void SetValFloat(float val) override;

View File

@ -30,9 +30,9 @@
#include <cmath> #include <cmath>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarInt::CBotVarInt( const CBotToken* name ) CBotVarInt::CBotVarInt(const CBotToken& name)
{ {
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = nullptr; m_pUserPtr = nullptr;

View File

@ -30,7 +30,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarInt(const CBotToken* name); CBotVarInt(const CBotToken& name);
void SetValInt(int val, const std::string& s = "") override; void SetValInt(int val, const std::string& s = "") override;
void SetValFloat(float val) override; void SetValFloat(float val) override;

View File

@ -33,14 +33,14 @@
#include <cassert> #include <cassert>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarPointer::CBotVarPointer(const CBotToken* name, CBotTypResult& type ) CBotVarPointer::CBotVarPointer(const CBotToken& name, CBotTypResult& type)
{ {
if ( !type.Eq(CBotTypPointer) && if ( !type.Eq(CBotTypPointer) &&
!type.Eq(CBotTypNullPointer) && !type.Eq(CBotTypNullPointer) &&
!type.Eq(CBotTypClass) && // for convenience accepts Class and Intrinsic !type.Eq(CBotTypClass) && // for convenience accepts Class and Intrinsic
!type.Eq(CBotTypIntrinsic) ) assert(0); !type.Eq(CBotTypIntrinsic) ) assert(0);
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = nullptr; m_pUserPtr = nullptr;

View File

@ -30,7 +30,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarPointer(const CBotToken* name, CBotTypResult& type); CBotVarPointer(const CBotToken& name, CBotTypResult& type);
/** /**
* \brief Destructor. Do not call directly, use CBotVar::Destroy() * \brief Destructor. Do not call directly, use CBotVar::Destroy()
*/ */

View File

@ -29,9 +29,9 @@
// Global include // Global include
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
CBotVarString::CBotVarString( const CBotToken* name ) CBotVarString::CBotVarString(const CBotToken& name)
{ {
m_token = new CBotToken(*name); m_token = new CBotToken(name);
m_next = nullptr; m_next = nullptr;
m_pMyThis = nullptr; m_pMyThis = nullptr;
m_pUserPtr = nullptr; m_pUserPtr = nullptr;

View File

@ -30,7 +30,7 @@ public:
/** /**
* \brief Constructor. Do not call directly, use CBotVar::Create() * \brief Constructor. Do not call directly, use CBotVar::Create()
*/ */
CBotVarString(const CBotToken* name); CBotVarString(const CBotToken& name);
void SetValString(const std::string& val) override; void SetValString(const std::string& val) override;
std::string GetValString() override; std::string GetValString() override;