Reduced amount of warnings in CBot library
Changed most of C-style casting to C++ casting Commented unused variablesdev-ui
parent
a9186d1960
commit
e154e654f1
|
@ -602,7 +602,7 @@ CBotInstr* CBotInstArray::Compile(CBotToken* &p, CBotCStack* pStack, CBotTypResu
|
|||
inst->m_typevar = type;
|
||||
|
||||
var->SetUniqNum(
|
||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||
pStack->AddVar(var); // place it on the stack
|
||||
|
||||
if (IsOfType(p, ID_ASS)) // with an assignment
|
||||
|
@ -670,7 +670,7 @@ bool CBotInstArray::Execute(CBotStack* &pj)
|
|||
// create simply a NULL pointer
|
||||
CBotVar* var = CBotVar::Create(m_var->GetToken(), m_typevar);
|
||||
var->SetPointer(NULL);
|
||||
var->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent);
|
||||
var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
|
||||
pj->AddVar(var);
|
||||
|
||||
#if STACKMEM
|
||||
|
@ -685,7 +685,7 @@ bool CBotInstArray::Execute(CBotStack* &pj)
|
|||
{
|
||||
if (m_listass != NULL) // there is the assignment for this table
|
||||
{
|
||||
CBotVar* pVar = pj->FindVar(((CBotLeftExprVar*)m_var)->m_nIdent);
|
||||
CBotVar* pVar = pj->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
|
||||
|
||||
if (!m_listass->Execute(pile1, pVar)) return false;
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ void CBotInstArray::RestoreState(CBotStack* &pj, bool bMain)
|
|||
CBotStack* pile1 = pj;
|
||||
|
||||
CBotVar* var = pj->FindVar(m_var->GetToken()->GetString());
|
||||
if (var != NULL) var->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent);
|
||||
if (var != NULL) var->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
|
||||
|
||||
if (bMain)
|
||||
{
|
||||
|
@ -970,7 +970,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n
|
|||
|
||||
if (!cont && !IsOfType(p, ID_INT)) return NULL;
|
||||
|
||||
CBotInt* inst = (CBotInt*)CompileArray(p, pStack, CBotTypInt);
|
||||
CBotInt* inst = static_cast<CBotInt*>(CompileArray(p, pStack, CBotTypInt));
|
||||
if (inst != NULL || !pStack->IsOk()) return inst;
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||
|
@ -985,7 +985,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n
|
|||
// determines the expression is valid for the item on the left side
|
||||
if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||
{
|
||||
((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypInt;
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypInt;
|
||||
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||
{
|
||||
pStk->SetError(TX_REDEFVAR, vartoken);
|
||||
|
@ -1014,7 +1014,7 @@ CBotInstr* CBotInt::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool n
|
|||
return pStack->Return(inst2, pStk);
|
||||
}
|
||||
}
|
||||
inst = (CBotInt*)inst2;
|
||||
inst = static_cast<CBotInt*>(inst2);
|
||||
goto suite; // no assignment, variable already created
|
||||
}
|
||||
|
||||
|
@ -1035,7 +1035,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)
|
||||
var->SetInit(inst->m_expr != NULL); // if initialized with assignment
|
||||
var->SetUniqNum( //set it with a unique number
|
||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||
pStack->AddVar(var); // place it on the stack
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
|
||||
if (!cont && !IsOfType(p, ID_BOOLEAN, ID_BOOL)) return NULL;
|
||||
|
||||
CBotBoolean* inst = (CBotBoolean*)CompileArray(p, pStack, CBotTypBoolean);
|
||||
CBotBoolean* inst = static_cast<CBotBoolean*>(CompileArray(p, pStack, CBotTypBoolean));
|
||||
if (inst != NULL || !pStack->IsOk()) return inst;
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||
|
@ -1143,7 +1143,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
|
||||
if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||
{
|
||||
((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypBoolean;
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypBoolean;
|
||||
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||
{
|
||||
pStk->SetError(TX_REDEFVAR, vartoken);
|
||||
|
@ -1157,7 +1157,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
|
||||
// compiles an array declaration
|
||||
|
||||
inst = (CBotBoolean*)CBotInstArray::Compile(p, pStk, CBotTypBoolean);
|
||||
inst = static_cast<CBotBoolean*>(CBotInstArray::Compile(p, pStk, CBotTypBoolean));
|
||||
|
||||
if (!pStk->IsOk() )
|
||||
{
|
||||
|
@ -1183,7 +1183,7 @@ CBotInstr* CBotBoolean::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
var = CBotVar::Create(vartoken, CBotTypBoolean);// create the variable (evaluated after the assignment)
|
||||
var->SetInit(inst->m_expr != NULL);
|
||||
var->SetUniqNum(
|
||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||
pStack->AddVar(var);
|
||||
suite:
|
||||
if (IsOfType(p, ID_COMMA))
|
||||
|
@ -1276,7 +1276,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool
|
|||
|
||||
if (!cont && !IsOfType(p, ID_FLOAT)) return NULL;
|
||||
|
||||
CBotFloat* inst = (CBotFloat*)CompileArray(p, pStack, CBotTypFloat);
|
||||
CBotFloat* inst = static_cast<CBotFloat*>(CompileArray(p, pStack, CBotTypFloat));
|
||||
if (inst != NULL || !pStack->IsOk()) return inst;
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||
|
@ -1291,7 +1291,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool
|
|||
|
||||
if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||
{
|
||||
((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypFloat;
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypFloat;
|
||||
if (pStk->CheckVarLocal(vartoken)) // redefinition of a variable
|
||||
{
|
||||
pStk->SetStartError(vartoken->GetStart());
|
||||
|
@ -1303,7 +1303,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool
|
|||
{
|
||||
delete inst;
|
||||
p = vartoken;
|
||||
inst = (CBotFloat*)CBotInstArray::Compile(p, pStk, CBotTypFloat);
|
||||
inst = static_cast<CBotFloat*>(CBotInstArray::Compile(p, pStk, CBotTypFloat));
|
||||
|
||||
if (!pStk->IsOk() )
|
||||
{
|
||||
|
@ -1329,7 +1329,7 @@ CBotInstr* CBotFloat::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bool
|
|||
var = CBotVar::Create(vartoken, CBotTypFloat);
|
||||
var->SetInit(inst->m_expr != NULL);
|
||||
var->SetUniqNum(
|
||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||
pStack->AddVar(var);
|
||||
suite:
|
||||
if (IsOfType(p, ID_COMMA))
|
||||
|
@ -1422,7 +1422,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
|
||||
if (!cont && !IsOfType(p, ID_STRING)) return NULL;
|
||||
|
||||
CBotIString* inst = (CBotIString*)CompileArray(p, pStack, CBotTypString);
|
||||
CBotIString* inst = static_cast<CBotIString*>(CompileArray(p, pStack, CBotTypString));
|
||||
if (inst != NULL || !pStack->IsOk()) return inst;
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack(pp);
|
||||
|
@ -1436,7 +1436,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
|
||||
if (NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )))
|
||||
{
|
||||
((CBotLeftExprVar*)inst->m_var)->m_typevar = CBotTypString;
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = CBotTypString;
|
||||
if (pStk->CheckVarLocal(vartoken))
|
||||
{
|
||||
pStk->SetStartError(vartoken->GetStart());
|
||||
|
@ -1460,7 +1460,7 @@ CBotInstr* CBotIString::Compile(CBotToken* &p, CBotCStack* pStack, bool cont, bo
|
|||
CBotVar* var = CBotVar::Create(vartoken, CBotTypString);
|
||||
var->SetInit(inst->m_expr != NULL);
|
||||
var->SetUniqNum(
|
||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||
pStack->AddVar(var);
|
||||
|
||||
if (IsOfType(p, ID_COMMA))
|
||||
|
@ -1657,7 +1657,8 @@ bool CBotExpression::Execute(CBotStack* &pj)
|
|||
{
|
||||
CBotStack* pile = pj->AddStack(this);
|
||||
|
||||
CBotToken* pToken = m_leftop->GetToken();
|
||||
// CBotToken* pToken = m_leftop->GetToken();
|
||||
|
||||
CBotVar* pVar = NULL;
|
||||
|
||||
CBotStack* pile1 = pile;
|
||||
|
@ -1768,8 +1769,8 @@ void CBotExpression::RestoreState(CBotStack* &pj, bool bMain)
|
|||
{
|
||||
if (bMain)
|
||||
{
|
||||
CBotToken* pToken = m_leftop->GetToken();
|
||||
CBotVar* pVar = NULL;
|
||||
// CBotToken* pToken = m_leftop->GetToken();
|
||||
// CBotVar* pVar = NULL;
|
||||
|
||||
CBotStack* pile = pj->RestoreStack(this);
|
||||
if (pile == NULL) return;
|
||||
|
@ -2063,7 +2064,7 @@ bool CBotPostIncExpr::Execute(CBotStack* &pj)
|
|||
CBotVar* var1 = NULL;
|
||||
|
||||
// retrieves the variable fields and indexes according
|
||||
if (!((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true)) return false;
|
||||
if (!(static_cast<CBotExprVar*>(m_Instr))->ExecuteVar(var1, pile2, NULL, true)) return false;
|
||||
|
||||
pile1->SetState(1);
|
||||
pile1->SetCopyVar(var1); // places the result (before incrementation);
|
||||
|
@ -2094,7 +2095,7 @@ void CBotPostIncExpr::RestoreState(CBotStack* &pj, bool bMain)
|
|||
CBotStack* pile1 = pj->RestoreStack(this);
|
||||
if (pile1 == NULL) return;
|
||||
|
||||
((CBotExprVar*)m_Instr)->RestoreStateVar(pile1, bMain);
|
||||
(static_cast<CBotExprVar*>(m_Instr))->RestoreStateVar(pile1, bMain);
|
||||
|
||||
if (pile1 != NULL) pile1->RestoreStack(this);
|
||||
}
|
||||
|
@ -2112,7 +2113,7 @@ bool CBotPreIncExpr::Execute(CBotStack* &pj)
|
|||
CBotStack* pile2 = pile;
|
||||
// retrieves the variable fields and indexes according
|
||||
// pile2 is modified on return
|
||||
if (!((CBotExprVar*)m_Instr)->ExecuteVar(var1, pile2, NULL, true)) return false;
|
||||
if (!(static_cast<CBotExprVar*>(m_Instr))->ExecuteVar(var1, pile2, NULL, true)) return false;
|
||||
|
||||
if (var1->GetInit() == IS_NAN)
|
||||
{
|
||||
|
@ -2274,7 +2275,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotCStack* &pile)
|
|||
if (pVar->GetType(1) != CBotTypArrayPointer)
|
||||
ASM_TRAP();
|
||||
|
||||
pVar = ((CBotVarArray*)pVar)->GetItem(0, false); // at compile time makes the element [0]
|
||||
pVar = (static_cast<CBotVarArray*>(pVar))->GetItem(0, false); // at compile time makes the element [0]
|
||||
if (pVar == NULL)
|
||||
{
|
||||
pile->SetError(TX_OUTARRAY, m_token.GetEnd());
|
||||
|
@ -2314,7 +2315,7 @@ bool CBotIndexExpr::ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prev
|
|||
|
||||
int n = p->GetValInt(); // position in the table
|
||||
|
||||
pVar = ((CBotVarArray*)pVar)->GetItem(n, bExtend);
|
||||
pVar = (static_cast<CBotVarArray*>(pVar))->GetItem(n, bExtend);
|
||||
if (pVar == NULL)
|
||||
{
|
||||
pile->SetError(TX_OUTARRAY, prevToken);
|
||||
|
@ -2524,7 +2525,7 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
i->m_expr = CBotExpression::Compile(p, pStk);
|
||||
inst->AddNext3(i); // add to the chain
|
||||
|
||||
var = ((CBotVarArray*)var)->GetItem(0,true); // gets the component [0]
|
||||
var = (static_cast<CBotVarArray*>(var))->GetItem(0,true); // gets the component [0]
|
||||
|
||||
if (i->m_expr == NULL)
|
||||
{
|
||||
|
@ -2577,15 +2578,15 @@ CBotLeftExpr* CBotLeftExpr::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
}
|
||||
|
||||
|
||||
if (pStk->IsOk()) return (CBotLeftExpr*) pStack->Return(inst, pStk);
|
||||
if (pStk->IsOk()) return static_cast<CBotLeftExpr*> (pStack->Return(inst, pStk));
|
||||
}
|
||||
pStk->SetError(TX_UNDEFVAR, p);
|
||||
err:
|
||||
delete inst;
|
||||
return (CBotLeftExpr*) pStack->Return(NULL, pStk);
|
||||
return static_cast<CBotLeftExpr*> ( pStack->Return(NULL, pStk));
|
||||
}
|
||||
|
||||
return (CBotLeftExpr*) pStack->Return(NULL, pStk);
|
||||
return static_cast<CBotLeftExpr*> ( pStack->Return(NULL, pStk));
|
||||
}
|
||||
|
||||
// runs, is a variable and assigns the result to the stack
|
||||
|
@ -2768,7 +2769,7 @@ extern float GetNumFloat(const char* p)
|
|||
}
|
||||
|
||||
if (bNeg) num = -num;
|
||||
return (float)num;
|
||||
return static_cast<float>(num);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2814,7 +2815,7 @@ CBotInstr* CBotExprNum::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
|
||||
if (pStk->NextToken(p))
|
||||
{
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, inst->m_numtype);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), inst->m_numtype);
|
||||
pStk->SetVar(var);
|
||||
|
||||
return pStack->Return(inst, pStk);
|
||||
|
@ -2831,7 +2832,7 @@ bool CBotExprNum::Execute(CBotStack* &pj)
|
|||
|
||||
if (pile->IfStep()) return false;
|
||||
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, m_numtype);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), m_numtype);
|
||||
|
||||
CBotString nombre ;
|
||||
if (m_token.GetType() == TokenTypDef)
|
||||
|
@ -2883,7 +2884,7 @@ CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
inst->SetToken(p);
|
||||
p = p->GetNext();
|
||||
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypString);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypString);
|
||||
pStk->SetVar(var);
|
||||
|
||||
return pStack->Return(inst, pStk);
|
||||
|
@ -2897,7 +2898,7 @@ bool CBotExprAlpha::Execute(CBotStack* &pj)
|
|||
|
||||
if (pile->IfStep()) return false;
|
||||
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypString);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypString);
|
||||
|
||||
CBotString chaine = m_token.GetString();
|
||||
chaine = chaine.Mid(1, chaine.GetLength()-2); // removes the quotes
|
||||
|
@ -2941,7 +2942,7 @@ CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
inst->SetToken(p); // stores the operation false or true
|
||||
p = p->GetNext();
|
||||
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypBoolean);
|
||||
pStk->SetVar(var);
|
||||
}
|
||||
|
||||
|
@ -2956,7 +2957,7 @@ bool CBotExprBool::Execute(CBotStack* &pj)
|
|||
|
||||
if (pile->IfStep()) return false;
|
||||
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypBoolean);
|
||||
|
||||
if (GetTokenType() == ID_TRUE) var->SetValInt(1);
|
||||
else var->SetValInt(0);
|
||||
|
@ -2990,7 +2991,7 @@ bool CBotExprNull::Execute(CBotStack* &pj)
|
|||
CBotStack* pile = pj->AddStack(this);
|
||||
|
||||
if (pile->IfStep()) return false;
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypNullPointer);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypNullPointer);
|
||||
|
||||
var->SetInit(true); // null pointer valid
|
||||
pile->SetVar(var); // place on the stack
|
||||
|
@ -3022,7 +3023,7 @@ bool CBotExprNan::Execute(CBotStack* &pj)
|
|||
CBotStack* pile = pj->AddStack(this);
|
||||
|
||||
if (pile->IfStep()) return false;
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypInt);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypInt);
|
||||
|
||||
var->SetInit(IS_NAN); // nan
|
||||
pile->SetVar(var); // put on the stack
|
||||
|
@ -3051,7 +3052,7 @@ CBotExprVar::~CBotExprVar()
|
|||
|
||||
CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat)
|
||||
{
|
||||
CBotToken* pDebut = p;
|
||||
// CBotToken* pDebut = p;
|
||||
CBotCStack* pStk = pStack->TokenStack();
|
||||
|
||||
pStk->SetStartError(p->GetStart());
|
||||
|
@ -3068,7 +3069,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat)
|
|||
if (NULL != (var = pStk->FindVar(p))) // seek if known variable
|
||||
{
|
||||
int ident = var->GetUniqNum();
|
||||
((CBotExprVar*)inst)->m_nIdent = ident; // identifies variable by its number
|
||||
(static_cast<CBotExprVar*>(inst))->m_nIdent = ident; // identifies variable by its number
|
||||
|
||||
if (ident > 0 && ident < 9000)
|
||||
{
|
||||
|
@ -3085,7 +3086,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat)
|
|||
///tests
|
||||
CBotToken token("this");
|
||||
inst->SetToken(&token);
|
||||
((CBotExprVar*)inst)->m_nIdent = -2; // identificator for this
|
||||
(static_cast<CBotExprVar*>(inst))->m_nIdent = -2; // identificator for this
|
||||
|
||||
CBotFieldExpr* i = new CBotFieldExpr(); // new element
|
||||
i->SetToken(p); // keeps the name of the token
|
||||
|
@ -3105,7 +3106,7 @@ CBotInstr* CBotExprVar::Compile(CBotToken* &p, CBotCStack* pStack, int privat)
|
|||
i->m_expr = CBotExpression::Compile(p, pStk); // compile the formula
|
||||
inst->AddNext3(i); // add to the chain
|
||||
|
||||
var = ((CBotVarArray*)var)->GetItem(0,true); // gets the component [0]
|
||||
var = (static_cast<CBotVarArray*>(var))->GetItem(0,true); // gets the component [0]
|
||||
|
||||
if (i->m_expr == NULL)
|
||||
{
|
||||
|
@ -3202,7 +3203,7 @@ CBotInstr* CBotExprVar::CompileMethode(CBotToken* &p, CBotCStack* pStack)
|
|||
// adds the equivalent of this. before
|
||||
|
||||
inst->SetToken(&pthis);
|
||||
((CBotExprVar*)inst)->m_nIdent = -2; // ident for this
|
||||
(static_cast<CBotExprVar*>(inst))->m_nIdent = -2; // ident for this
|
||||
|
||||
CBotToken* pp = p;
|
||||
|
||||
|
@ -3555,9 +3556,9 @@ void CBotInstrMethode::RestoreStateVar(CBotStack* &pile, bool bMain)
|
|||
ppVars[i] = NULL;
|
||||
|
||||
CBotClass* pClass = CBotClass::Find(m_ClassName);
|
||||
CBotVar* pResult = NULL;
|
||||
// CBotVar* pResult = NULL;
|
||||
|
||||
CBotVar* pRes = pResult;
|
||||
// CBotVar* pRes = pResult;
|
||||
|
||||
pClass->RestoreMethode(m_MethodeIdent, m_NomMethod,
|
||||
pThis, ppVars, pile2);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#define STACKMEM true /// \def preserve memory for the execution stack
|
||||
#define MAXSTACK 990 /// \def stack size reserved
|
||||
|
||||
#define EOX (CBotStack*)-1 /// \def tag special condition
|
||||
#define EOX (reinterpret_cast<CBotStack*>(-1)) /// \def tag special condition
|
||||
|
||||
|
||||
// fix for MSVC instruction __asm int 3 (setting a trap)
|
||||
|
|
|
@ -488,7 +488,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
|
||||
bool bIntrinsic = pClass->IsIntrinsic();
|
||||
CBotTypResult type = CBotTypResult( bIntrinsic ? CBotTypIntrinsic : CBotTypPointer, pClass );
|
||||
CBotClassInst* inst = (CBotClassInst*)CompileArray(p, pStack, type);
|
||||
CBotClassInst* inst = static_cast<CBotClassInst*>(CompileArray(p, pStack, type));
|
||||
if ( inst != NULL || !pStack->IsOk() ) return inst;
|
||||
|
||||
CBotCStack* pStk = pStack->TokenStack();
|
||||
|
@ -501,7 +501,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
|
||||
if ( NULL != (inst->m_var = CBotLeftExprVar::Compile( p, pStk )) )
|
||||
{
|
||||
((CBotLeftExprVar*)inst->m_var)->m_typevar = type;
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_typevar = type;
|
||||
if (pStk->CheckVarLocal(vartoken)) // redefinition of the variable
|
||||
{
|
||||
pStk->SetStartError(vartoken->GetStart());
|
||||
|
@ -516,7 +516,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
|
||||
// compiles declaration an array
|
||||
|
||||
inst = (CBotClassInst*)CBotInstArray::Compile( p, pStk, type );
|
||||
inst = static_cast<CBotClassInst*>(CBotInstArray::Compile( p, pStk, type ));
|
||||
|
||||
if (!pStk->IsOk() )
|
||||
{
|
||||
|
@ -531,7 +531,7 @@ CBotInstr* CBotClassInst::Compile(CBotToken* &p, CBotCStack* pStack, CBotClass*
|
|||
var = CBotVar::Create(vartoken->GetString(), type); // creates the instance
|
||||
// var->SetClass(pClass);
|
||||
var->SetUniqNum(
|
||||
((CBotLeftExprVar*)inst->m_var)->m_nIdent = CBotVar::NextUniqNum());
|
||||
(static_cast<CBotLeftExprVar*>(inst->m_var))->m_nIdent = CBotVar::NextUniqNum());
|
||||
// its attribute a unique number
|
||||
pStack->AddVar(var); // placed on the stack
|
||||
|
||||
|
@ -667,12 +667,12 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
|||
pThis = CBotVar::Create(name, CBotTypResult( CBotTypPointer, pClass ));
|
||||
}
|
||||
|
||||
pThis->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); // its attribute as unique number
|
||||
pThis->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); // its attribute as unique number
|
||||
pile->AddVar(pThis); // place on the stack
|
||||
pile->IncState();
|
||||
}
|
||||
|
||||
if ( pThis == NULL ) pThis = pile->FindVar(((CBotLeftExprVar*)m_var)->m_nIdent);
|
||||
if ( pThis == NULL ) pThis = pile->FindVar((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent);
|
||||
|
||||
if ( pile->GetState()<3)
|
||||
{
|
||||
|
@ -698,7 +698,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
|||
else
|
||||
{
|
||||
CBotVarClass* pInstance;
|
||||
pInstance = ((CBotVarPointer*)pile->GetVar())->GetPointer(); // value for the assignment
|
||||
pInstance = (static_cast<CBotVarPointer*>(pile->GetVar()))->GetPointer(); // value for the assignment
|
||||
pThis->SetPointer(pInstance);
|
||||
}
|
||||
pThis->SetInit(true);
|
||||
|
@ -716,7 +716,7 @@ bool CBotClassInst::Execute(CBotStack* &pj)
|
|||
// creates an instance of the requested class
|
||||
|
||||
CBotVarClass* pInstance;
|
||||
pInstance = (CBotVarClass*)CBotVar::Create("", pClass);
|
||||
pInstance = static_cast<CBotVarClass*>(CBotVar::Create("", pClass));
|
||||
pThis->SetPointer(pInstance);
|
||||
delete pInstance;
|
||||
|
||||
|
@ -789,7 +789,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
|||
{
|
||||
CBotString name = m_var->m_token.GetString();
|
||||
pThis = pile->FindVar(name);
|
||||
pThis->SetUniqNum(((CBotLeftExprVar*)m_var)->m_nIdent); // its attribute a unique number
|
||||
pThis->SetUniqNum((static_cast<CBotLeftExprVar*>(m_var))->m_nIdent); // its attribute a unique number
|
||||
}
|
||||
|
||||
CBotToken* pt = &m_token;
|
||||
|
@ -845,7 +845,7 @@ void CBotClassInst::RestoreState(CBotStack* &pj, bool bMain)
|
|||
ppVars[i] = NULL;
|
||||
|
||||
// creates a variable for the result
|
||||
CBotVar* pResult = NULL; // constructor still void
|
||||
// CBotVar* pResult = NULL; // constructor still void
|
||||
|
||||
pClass->RestoreMethode(m_nMethodeIdent, pClass->GetName(), pThis, ppVars, pile2);
|
||||
return;
|
||||
|
|
|
@ -77,9 +77,10 @@ enum CBotType
|
|||
//n = not implemented yet
|
||||
|
||||
// for SetUserPtr when deleting an object
|
||||
#define OBJECTDELETED ((void*)-1)
|
||||
// \TODO define own types to distinct between different states of objects
|
||||
#define OBJECTDELETED (reinterpret_cast<void*>(-1))
|
||||
// value set before initialization
|
||||
#define OBJECTCREATED ((void*)-2)
|
||||
#define OBJECTCREATED (reinterpret_cast<void*>(-2))
|
||||
|
||||
|
||||
/** \brief CBotTypResult class to define the complete type of a result*/
|
||||
|
@ -314,7 +315,7 @@ private:
|
|||
int m_lg;
|
||||
|
||||
/** \brief Keeps the string corresponding to keyword ID */
|
||||
static const std::map<EID, char *> s_keywordString;
|
||||
static const std::map<EID,const char *> s_keywordString;
|
||||
|
||||
/**
|
||||
* \brief MapIdToString maps given ID to its string equivalent
|
||||
|
|
|
@ -462,7 +462,8 @@ CBotTypResult CBotFunction::CompileCall(const char* name, CBotVar** ppVars, long
|
|||
nIdent = 0;
|
||||
CBotTypResult type;
|
||||
|
||||
CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type);
|
||||
// CBotFunction* pt = FindLocalOrPublic(nIdent, name, ppVars, type);
|
||||
FindLocalOrPublic(nIdent, name, ppVars, type);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -731,7 +732,7 @@ void CBotFunction::RestoreCall(long& nIdent, const char* name, CBotVar** ppVars,
|
|||
{
|
||||
if ( !pt->m_MasterClass.IsEmpty() )
|
||||
{
|
||||
CBotVar* pInstance = m_pProg->m_pInstance;
|
||||
// CBotVar* pInstance = m_pProg->m_pInstance;
|
||||
// make "this" known
|
||||
CBotVar* pThis = pStk1->FindVar("this");
|
||||
pThis->SetInit(2);
|
||||
|
@ -957,7 +958,7 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
|||
if (list == NULL) list = param;
|
||||
else list->AddNext(param); // added to the list
|
||||
|
||||
CBotClass* pClass = NULL;//= CBotClass::Find(p);
|
||||
// CBotClass* pClass = NULL;//= CBotClass::Find(p);
|
||||
param->m_typename = p->GetString();
|
||||
CBotTypResult type = param->m_type = TypeParam(p, pStack);
|
||||
// if ( type == CBotTypPointer ) type = CBotTypClass; // we must create a new object
|
||||
|
@ -1036,7 +1037,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
|||
newvar->SetValInt(ppVars[i]->GetValInt());
|
||||
break;
|
||||
case CBotTypIntrinsic:
|
||||
((CBotVarClass*)newvar)->Copy(ppVars[i], false);
|
||||
(static_cast<CBotVarClass*>(newvar))->Copy(ppVars[i], false);
|
||||
break;
|
||||
case CBotTypPointer:
|
||||
case CBotTypArrayPointer:
|
||||
|
@ -1059,7 +1060,7 @@ bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
|||
|
||||
void CBotDefParam::RestoreState(CBotStack* &pj, bool bMain)
|
||||
{
|
||||
int i = 0;
|
||||
// int i = 0;
|
||||
CBotDefParam* p = this;
|
||||
|
||||
while ( p != NULL )
|
||||
|
@ -1287,7 +1288,7 @@ bool CBotInstrCall::Execute(CBotStack* &pj)
|
|||
CBotStack* pile = pj->AddStack(this);
|
||||
if ( pile->StackOver() ) return pj->Return( pile );
|
||||
|
||||
CBotStack* pile1 = pile;
|
||||
// CBotStack* pile1 = pile;
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
@ -1324,7 +1325,7 @@ void CBotInstrCall::RestoreState(CBotStack* &pj, bool bMain)
|
|||
CBotStack* pile = pj->RestoreStack(this);
|
||||
if ( pile == NULL ) return;
|
||||
|
||||
CBotStack* pile1 = pile;
|
||||
// CBotStack* pile1 = pile;
|
||||
|
||||
int i = 0;
|
||||
CBotVar* ppVars[1000];
|
||||
|
|
|
@ -487,7 +487,7 @@ bool ReadType(FILE* pf, CBotTypResult& type)
|
|||
if ( !ReadWord(pf, ww) ) return false;
|
||||
if ( !ReadType(pf, r) ) return false;
|
||||
type = CBotTypResult( w, r );
|
||||
type.SetLimite((short)ww);
|
||||
type.SetLimite(static_cast<short>(ww));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal=false)
|
|||
|
||||
while( true )
|
||||
{
|
||||
ppVars[i];
|
||||
// ppVars[i];
|
||||
if ( ppVars[i] == NULL ) break;
|
||||
|
||||
CBotVar* pp = CBotVar::Create(ppVars[i]);
|
||||
|
@ -781,7 +781,7 @@ fund:
|
|||
// lists the parameters depending on the contents of the stack (pStackVar)
|
||||
|
||||
CBotVar* pVar = MakeListVars(ppVar, true);
|
||||
CBotVar* pVarToDelete = pVar;
|
||||
// CBotVar* pVarToDelete = pVar;
|
||||
|
||||
// creates a variable to the result
|
||||
CBotVar* pResult = rettype.Eq(0) ? NULL : CBotVar::Create("", rettype);
|
||||
|
@ -815,7 +815,8 @@ bool CBotCall::RestoreCall(long& nIdent, CBotToken* token, CBotVar** ppVar, CBot
|
|||
CBotStack* pile = pStack->RestoreStackEOX(pt);
|
||||
if ( pile == NULL ) return true;
|
||||
|
||||
CBotStack* pile2 = pile->RestoreStack();
|
||||
// CBotStack* pile2 = pile->RestoreStack();
|
||||
pile->RestoreStack();
|
||||
return true;
|
||||
}
|
||||
pt = pt->m_next;
|
||||
|
|
|
@ -47,7 +47,7 @@ CBotStack* CBotStack::FirstStack()
|
|||
size *= (MAXSTACK+10);
|
||||
|
||||
// request a slice of memory for the stack
|
||||
p = (CBotStack*)malloc(size);
|
||||
p = static_cast<CBotStack*>(malloc(size));
|
||||
|
||||
// completely empty
|
||||
memset(p, 0, size);
|
||||
|
@ -905,7 +905,7 @@ bool CBotStack::RestoreState(FILE* pf, CBotStack* &pStack)
|
|||
pStack->m_bBlock = w;
|
||||
|
||||
if (!ReadWord(pf, w)) return false; // in what state ?
|
||||
pStack->SetState((short)w); // in a good state
|
||||
pStack->SetState(static_cast<short>(w)); // in a good state
|
||||
|
||||
if (!ReadWord(pf, w)) return false; // dont delete?
|
||||
// uses more
|
||||
|
@ -1016,7 +1016,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
|||
case CBotTypBoolean:
|
||||
pNew = CBotVar::Create(&token, w); // creates a variable
|
||||
if (!ReadWord(pf, w)) return false;
|
||||
pNew->SetValInt((short)w, defnum);
|
||||
pNew->SetValInt(static_cast<short>(w), defnum);
|
||||
break;
|
||||
case CBotTypFloat:
|
||||
pNew = CBotVar::Create(&token, w); // creates a variable
|
||||
|
@ -1045,7 +1045,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
|||
|
||||
pNew = new CBotVarClass(&token, r); // directly creates an instance
|
||||
// attention cptuse = 0
|
||||
if ( !RestoreState(pf, ((CBotVarClass*)pNew)->m_pVar)) return false;
|
||||
if ( !RestoreState(pf, (static_cast<CBotVarClass*>(pNew))->m_pVar)) return false;
|
||||
pNew->SetIdent(id);
|
||||
|
||||
if ( p != NULL )
|
||||
|
@ -1062,7 +1062,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
|||
if (!ReadString(pf, s)) return false;
|
||||
{
|
||||
pNew = CBotVar::Create(&token, CBotTypResult(w, s));// creates a variable
|
||||
CBotVarClass* p = NULL;
|
||||
// CBotVarClass* p = NULL;
|
||||
long id;
|
||||
ReadLong(pf, id);
|
||||
// if ( id ) p = CBotVarClass::Find(id); // found the instance (made by RestoreInstance)
|
||||
|
@ -1070,9 +1070,9 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
|||
// returns a copy of the original instance
|
||||
CBotVar* pInstance = NULL;
|
||||
if ( !CBotVar::RestoreState( pf, pInstance ) ) return false;
|
||||
((CBotVarPointer*)pNew)->SetPointer( pInstance ); // and point over
|
||||
(static_cast<CBotVarPointer*>(pNew))->SetPointer( pInstance ); // and point over
|
||||
|
||||
// if ( p != NULL ) ((CBotVarPointer*)pNew)->SetPointer( p ); // rather this one
|
||||
// if ( p != NULL ) (static_cast<CBotVarPointer*>(pNew))->SetPointer( p ); // rather this one
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -1087,7 +1087,7 @@ bool CBotVar::RestoreState(FILE* pf, CBotVar* &pVar)
|
|||
// returns a copy of the original instance
|
||||
CBotVar* pInstance = NULL;
|
||||
if ( !CBotVar::RestoreState( pf, pInstance ) ) return false;
|
||||
((CBotVarPointer*)pNew)->SetPointer( pInstance ); // and point over
|
||||
(static_cast<CBotVarPointer*>(pNew))->SetPointer( pInstance ); // and point over
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <algorithm>
|
||||
|
||||
//Map is filled with id-string pars that are needed for CBot language parsing
|
||||
const std::map<EID, char *> CBotString::s_keywordString =
|
||||
const std::map<EID,const char *> CBotString::s_keywordString =
|
||||
{
|
||||
{ID_IF, "if"},
|
||||
{ID_ELSE, "else"},
|
||||
|
@ -170,7 +170,7 @@ CBotString CBotString::Left(int nCount) const
|
|||
{
|
||||
char chain[2000];
|
||||
|
||||
size_t i;
|
||||
int i;
|
||||
for (i = 0; i < m_lg && i < nCount && i < 1999; ++i)
|
||||
{
|
||||
chain[i] = m_ptr[i];
|
||||
|
@ -187,8 +187,8 @@ CBotString CBotString::Right(int nCount) const
|
|||
int i = m_lg - nCount;
|
||||
if ( i < 0 ) i = 0;
|
||||
|
||||
size_t j;
|
||||
for (size_t j = 0 ; i < m_lg && i < 1999; ++i)
|
||||
int j;
|
||||
for (int j = 0 ; i < m_lg && i < 1999; ++i)
|
||||
{
|
||||
chain[j++] = m_ptr[i];
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ CBotString CBotString::Mid(int nFirst, int nCount) const
|
|||
{
|
||||
char chain[2000];
|
||||
|
||||
size_t i;
|
||||
int i;
|
||||
for (i = nFirst; i < m_lg && i < 1999 && i <= nFirst + nCount; ++i)
|
||||
{
|
||||
chain[i] = m_ptr[i];
|
||||
|
@ -215,7 +215,7 @@ CBotString CBotString::Mid(int nFirst) const
|
|||
{
|
||||
char chain[2000];
|
||||
|
||||
size_t i;
|
||||
int i;
|
||||
for (i = nFirst; i < m_lg && i < 1999 ; ++i)
|
||||
{
|
||||
chain[i] = m_ptr[i];
|
||||
|
@ -228,7 +228,7 @@ CBotString CBotString::Mid(int nFirst) const
|
|||
|
||||
int CBotString::Find(const char c)
|
||||
{
|
||||
for (size_t i = 0; i < m_lg; ++i)
|
||||
for (int i = 0; i < m_lg; ++i)
|
||||
{
|
||||
if (m_ptr[i] == c) return i;
|
||||
}
|
||||
|
@ -239,9 +239,9 @@ int CBotString::Find(const char * lpsz)
|
|||
{
|
||||
int l = strlen(lpsz);
|
||||
|
||||
for (size_t i = 0; i <= m_lg-l; ++i)
|
||||
for (size_t i = 0; static_cast<int>(i) <= m_lg-l; ++i)
|
||||
{
|
||||
for (size_t j = 0; j < l; ++j)
|
||||
for (size_t j = 0; static_cast<int>(j) < l; ++j)
|
||||
{
|
||||
if (m_ptr[i+j] != lpsz[j]) goto bad;
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ CBotString CBotString::Mid(int start, int lg)
|
|||
|
||||
void CBotString::MakeUpper()
|
||||
{
|
||||
for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
|
||||
for (size_t i = 0; static_cast<int>(i) < m_lg && static_cast<int>(i) < 1999 ; ++i)
|
||||
{
|
||||
char c = m_ptr[i];
|
||||
if ( c >= 'a' && c <= 'z' ) m_ptr[i] = c - 'a' + 'A';
|
||||
|
@ -305,7 +305,7 @@ void CBotString::MakeUpper()
|
|||
|
||||
void CBotString::MakeLower()
|
||||
{
|
||||
for (size_t i = 0; i < m_lg && i < 1999 ; ++i)
|
||||
for (size_t i = 0; static_cast<int>(i) < m_lg && static_cast<int>(i) < 1999 ; ++i)
|
||||
{
|
||||
char c = m_ptr[i];
|
||||
if ( c >= 'A' && c <= 'Z' ) m_ptr[i] = c - 'A' + 'a';
|
||||
|
@ -315,7 +315,7 @@ void CBotString::MakeLower()
|
|||
bool CBotString::LoadString(unsigned int id)
|
||||
{
|
||||
const char * str = NULL;
|
||||
str = MapIdToString((EID)id);
|
||||
str = MapIdToString(static_cast<EID>(id));
|
||||
if (m_ptr != NULL) free(m_ptr);
|
||||
|
||||
m_lg = strlen(str);
|
||||
|
@ -374,7 +374,7 @@ const CBotString& CBotString::operator=(const char ch)
|
|||
|
||||
m_lg = 1;
|
||||
|
||||
m_ptr = (char*)malloc(2);
|
||||
m_ptr = static_cast<char*>(malloc(2));
|
||||
m_ptr[0] = ch;
|
||||
m_ptr[1] = 0;
|
||||
|
||||
|
@ -403,7 +403,7 @@ const CBotString& CBotString::operator=(const char* pString)
|
|||
|
||||
const CBotString& CBotString::operator+=(const char ch)
|
||||
{
|
||||
char* p = (char*)malloc(m_lg+2);
|
||||
char* p = static_cast<char*>(malloc(m_lg+2));
|
||||
|
||||
if (m_ptr!=NULL) strcpy(p, m_ptr);
|
||||
p[m_lg++] = ch;
|
||||
|
@ -418,7 +418,7 @@ const CBotString& CBotString::operator+=(const char ch)
|
|||
|
||||
const CBotString& CBotString::operator+=(const CBotString& str)
|
||||
{
|
||||
char* p = (char*)malloc(m_lg+str.m_lg+1);
|
||||
char* p = static_cast<char*>(malloc(m_lg+str.m_lg+1));
|
||||
|
||||
strcpy(p, m_ptr);
|
||||
char* pp = p + m_lg;
|
||||
|
@ -618,6 +618,7 @@ void CBotStringArray::SetSize(int nNewSize)
|
|||
// shrink to nothing
|
||||
|
||||
DestructElements(m_pData, m_nSize);
|
||||
// delete[] static_cast<unsigned char *>(m_pData);
|
||||
delete[] (unsigned char *)m_pData;
|
||||
m_pData = NULL;
|
||||
m_nSize = m_nMaxSize = 0;
|
||||
|
|
|
@ -217,12 +217,12 @@ bool Char2InList(const char c, const char cc, const char* list)
|
|||
}
|
||||
}
|
||||
|
||||
static char* sep1 = " \r\n\t,:()[]{}-+*/=;><!~^|&%.";
|
||||
static char* sep2 = " \r\n\t"; // only separators
|
||||
static char* sep3 = ",:()[]{}-+*/=;<>!~^|&%."; // operational separators
|
||||
static char* num = "0123456789"; // point (single) is tested separately
|
||||
static char* hexnum = "0123456789ABCDEFabcdef";
|
||||
static char* nch = "\"\r\n\t"; // forbidden in chains
|
||||
static char sep1[] = " \r\n\t,:()[]{}-+*/=;><!~^|&%.";
|
||||
static char sep2[] = " \r\n\t"; // only separators
|
||||
static char sep3[] = ",:()[]{}-+*/=;<>!~^|&%."; // operational separators
|
||||
static char num[] = "0123456789"; // point (single) is tested separately
|
||||
static char hexnum[] = "0123456789ABCDEFabcdef";
|
||||
static char nch[] = "\"\r\n\t"; // forbidden in chains
|
||||
|
||||
//static char* duo = "+=-=*=/===!=<=>=++--///**/||&&"; // double operators
|
||||
|
||||
|
@ -382,7 +382,7 @@ bis:
|
|||
CBotToken* CBotToken::CompileTokens(const char* program, int& error)
|
||||
{
|
||||
CBotToken *nxt, *prv, *tokenbase;
|
||||
char* p = (char*) program;
|
||||
char* p = const_cast<char*> ( program);
|
||||
int pos = 0;
|
||||
|
||||
error = 0;
|
||||
|
|
|
@ -259,7 +259,7 @@ CBotInstr* CBotTwoOpExpr::Compile(CBotToken* &p, CBotCStack* pStack, int* pOpera
|
|||
CBotTypResult t(type1);
|
||||
t.SetType(TypeRes);
|
||||
// is a variable on the stack for the type of result
|
||||
pStk->SetVar(CBotVar::Create((CBotToken*)NULL, t));
|
||||
pStk->SetVar(CBotVar::Create(static_cast<CBotToken*>(NULL), t));
|
||||
|
||||
// and returns the requested object
|
||||
return pStack->Return(inst, pStk);
|
||||
|
@ -309,14 +309,14 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
// 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 )
|
||||
{
|
||||
CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
|
||||
CBotVar* res = CBotVar::Create( static_cast<CBotToken*>(NULL), CBotTypBoolean);
|
||||
res->SetValInt(false);
|
||||
pStk1->SetVar(res);
|
||||
return pStack->Return(pStk1); // transmits the result
|
||||
}
|
||||
if ( (GetTokenType() == ID_LOG_OR||GetTokenType() == ID_TXT_OR) && pStk1->GetVal() == true )
|
||||
{
|
||||
CBotVar* res = CBotVar::Create( (CBotToken*)NULL, CBotTypBoolean);
|
||||
CBotVar* res = CBotVar::Create( static_cast<CBotToken*>(NULL), CBotTypBoolean);
|
||||
res->SetValInt(true);
|
||||
pStk1->SetVar(res);
|
||||
return pStack->Return(pStk1); // transmits the result
|
||||
|
@ -374,7 +374,7 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
}
|
||||
|
||||
// creates a variable for the result
|
||||
CBotVar* result = CBotVar::Create( (CBotToken*)NULL, TypeRes);
|
||||
CBotVar* result = CBotVar::Create( static_cast<CBotToken*>(NULL), TypeRes);
|
||||
|
||||
// creates a variable to perform the calculation in the appropriate type
|
||||
TypeRes = MAX(type1.GetType(), type2.GetType());
|
||||
|
@ -387,8 +387,8 @@ bool CBotTwoOpExpr::Execute(CBotStack* &pStack)
|
|||
CBotVar* temp;
|
||||
|
||||
if ( TypeRes == CBotTypPointer ) TypeRes = CBotTypNullPointer;
|
||||
if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( (CBotToken*)NULL, CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) );
|
||||
else temp = CBotVar::Create( (CBotToken*)NULL, TypeRes );
|
||||
if ( TypeRes == CBotTypClass ) temp = CBotVar::Create( static_cast<CBotToken*>(NULL), CBotTypResult(CBotTypIntrinsic, type1.GetClass() ) );
|
||||
else temp = CBotVar::Create( static_cast<CBotToken*>(NULL), TypeRes );
|
||||
|
||||
int err = 0;
|
||||
// is a operation according to request
|
||||
|
@ -558,7 +558,7 @@ void t()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 01
|
||||
#if 0
|
||||
void t(bool t)
|
||||
{
|
||||
int x;
|
||||
|
|
|
@ -203,13 +203,13 @@ CBotVar::~CBotVar( )
|
|||
|
||||
void CBotVar::debug()
|
||||
{
|
||||
const char* p = (const char*) m_token->GetString();
|
||||
CBotString s = (const char*) GetValString();
|
||||
const char* v = (const char*) s;
|
||||
// const char* p = static_cast<const char*>( m_token->GetString());
|
||||
CBotString s = static_cast<const char*>( GetValString());
|
||||
// const char* v = static_cast<const char*> (s);
|
||||
|
||||
if ( m_type.Eq(CBotTypClass) )
|
||||
{
|
||||
CBotVar* pv = ((CBotVarClass*)this)->m_pVar;
|
||||
CBotVar* pv = (static_cast<CBotVarClass*>(this))->m_pVar;
|
||||
while (pv != NULL)
|
||||
{
|
||||
pv->debug();
|
||||
|
@ -227,15 +227,15 @@ void CBotVar::SetUserPtr(void* pUser)
|
|||
{
|
||||
m_pUserPtr = pUser;
|
||||
if (m_type.Eq(CBotTypPointer) &&
|
||||
((CBotVarPointer*)this)->m_pVarClass != NULL )
|
||||
((CBotVarPointer*)this)->m_pVarClass->SetUserPtr(pUser);
|
||||
(static_cast<CBotVarPointer*>(this))->m_pVarClass != NULL )
|
||||
(static_cast<CBotVarPointer*>(this))->m_pVarClass->SetUserPtr(pUser);
|
||||
}
|
||||
|
||||
void CBotVar::SetIdent(long n)
|
||||
{
|
||||
if (m_type.Eq(CBotTypPointer) &&
|
||||
((CBotVarPointer*)this)->m_pVarClass != NULL )
|
||||
((CBotVarPointer*)this)->m_pVarClass->SetIdent(n);
|
||||
(static_cast<CBotVarPointer*>(this))->m_pVarClass != NULL )
|
||||
(static_cast<CBotVarPointer*>(this))->m_pVarClass->SetIdent(n);
|
||||
}
|
||||
|
||||
void CBotVar::SetUniqNum(long n)
|
||||
|
@ -328,7 +328,7 @@ CBotVar* CBotVar::Create(const CBotToken* name, CBotTypResult type)
|
|||
while (type.Eq(CBotTypArrayBody))
|
||||
{
|
||||
type = type.GetTypElem();
|
||||
pv = ((CBotVarArray*)pv)->GetItem(0, true); // creates at least the element [0]
|
||||
pv = (static_cast<CBotVarArray*>(pv))->GetItem(0, true); // creates at least the element [0]
|
||||
}
|
||||
|
||||
return array;
|
||||
|
@ -399,7 +399,7 @@ CBotVar* CBotVar::Create( const char* n, CBotTypResult type)
|
|||
while (type.Eq(CBotTypArrayBody))
|
||||
{
|
||||
type = type.GetTypElem();
|
||||
pv = ((CBotVarArray*)pv)->GetItem(0, true); // creates at least the element [0]
|
||||
pv = (static_cast<CBotVarArray*>(pv))->GetItem(0, true); // creates at least the element [0]
|
||||
}
|
||||
|
||||
return array;
|
||||
|
@ -484,7 +484,7 @@ void CBotVar::SetInit(int bInit)
|
|||
if ( instance == NULL )
|
||||
{
|
||||
instance = new CBotVarClass(NULL, m_type);
|
||||
// instance->SetClass(((CBotVarPointer*)this)->m_pClass);
|
||||
// instance->SetClass((static_cast<CBotVarPointer*>(this))->m_pClass);
|
||||
SetPointer(instance);
|
||||
}
|
||||
instance->SetInit(1);
|
||||
|
@ -492,11 +492,11 @@ void CBotVar::SetInit(int bInit)
|
|||
|
||||
if ( m_type.Eq(CBotTypClass) || m_type.Eq(CBotTypIntrinsic) )
|
||||
{
|
||||
CBotVar* p = ((CBotVarClass*)this)->m_pVar;
|
||||
CBotVar* p = (static_cast<CBotVarClass*>(this))->m_pVar;
|
||||
while( p != NULL )
|
||||
{
|
||||
p->SetInit( bInit );
|
||||
p->m_pMyThis = (CBotVarClass*)this;
|
||||
p->m_pMyThis = static_cast<CBotVarClass*>(this);
|
||||
p = p->GetNext();
|
||||
}
|
||||
}
|
||||
|
@ -548,11 +548,11 @@ bool CBotVar::IsElemOfClass(const char* name)
|
|||
|
||||
if ( m_type.Eq(CBotTypPointer) )
|
||||
{
|
||||
pc = ((CBotVarPointer*)this)->m_pClass;
|
||||
pc = (static_cast<CBotVarPointer*>(this))->m_pClass;
|
||||
}
|
||||
if ( m_type.Eq(CBotTypClass) )
|
||||
{
|
||||
pc = ((CBotVarClass*)this)->m_pClass;
|
||||
pc = (static_cast<CBotVarClass*>(this))->m_pClass;
|
||||
}
|
||||
|
||||
while ( pc != NULL )
|
||||
|
@ -596,7 +596,7 @@ void CBotVar::SetVal(CBotVar* var)
|
|||
SetValInt(var->GetValInt());
|
||||
break;
|
||||
case CBotTypInt:
|
||||
SetValInt(var->GetValInt(), ((CBotVarInt*)var)->m_defnum);
|
||||
SetValInt(var->GetValInt(), (static_cast<CBotVarInt*>(var))->m_defnum);
|
||||
break;
|
||||
case CBotTypFloat:
|
||||
SetValFloat(var->GetValFloat());
|
||||
|
@ -611,8 +611,8 @@ void CBotVar::SetVal(CBotVar* var)
|
|||
break;
|
||||
case CBotTypClass:
|
||||
{
|
||||
delete ((CBotVarClass*)this)->m_pVar;
|
||||
((CBotVarClass*)this)->m_pVar = NULL;
|
||||
delete (static_cast<CBotVarClass*>(this))->m_pVar;
|
||||
(static_cast<CBotVarClass*>(this))->m_pVar = NULL;
|
||||
Copy(var, false);
|
||||
}
|
||||
break;
|
||||
|
@ -841,7 +841,7 @@ void CBotVar::SetIndirection(CBotVar* pVar)
|
|||
// copy a variable in to another
|
||||
void CBotVarInt::Copy(CBotVar* pSrc, bool bName)
|
||||
{
|
||||
CBotVarInt* p = (CBotVarInt*)pSrc;
|
||||
CBotVarInt* p = static_cast<CBotVarInt*>(pSrc);
|
||||
|
||||
if ( bName) *m_token = *p->m_token;
|
||||
m_type = p->m_type;
|
||||
|
@ -870,7 +870,7 @@ void CBotVarInt::SetValInt(int val, const char* defnum)
|
|||
|
||||
void CBotVarInt::SetValFloat(float val)
|
||||
{
|
||||
m_val = (int)val;
|
||||
m_val = static_cast<int>(val);
|
||||
m_binit = true;
|
||||
}
|
||||
|
||||
|
@ -881,7 +881,7 @@ int CBotVarInt::GetValInt()
|
|||
|
||||
float CBotVarInt::GetValFloat()
|
||||
{
|
||||
return (float)m_val;
|
||||
return static_cast<float>(m_val);
|
||||
}
|
||||
|
||||
CBotString CBotVarInt::GetValString()
|
||||
|
@ -917,7 +917,7 @@ void CBotVarInt::Mul(CBotVar* left, CBotVar* right)
|
|||
|
||||
void CBotVarInt::Power(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
m_val = (int) pow( (double) left->GetValInt() , (double) right->GetValInt() );
|
||||
m_val = static_cast<int>( pow( static_cast<double>( left->GetValInt()) , static_cast<double>( left->GetValInt()) ));
|
||||
m_binit = true;
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ bool CBotVarInt::Ne(CBotVar* left, CBotVar* right)
|
|||
// copy a variable into another
|
||||
void CBotVarFloat::Copy(CBotVar* pSrc, bool bName)
|
||||
{
|
||||
CBotVarFloat* p = (CBotVarFloat*)pSrc;
|
||||
CBotVarFloat* p = static_cast<CBotVarFloat*>(pSrc);
|
||||
|
||||
if (bName) *m_token = *p->m_token;
|
||||
m_type = p->m_type;
|
||||
|
@ -1072,7 +1072,7 @@ void CBotVarFloat::Copy(CBotVar* pSrc, bool bName)
|
|||
|
||||
void CBotVarFloat::SetValInt(int val, const char* s)
|
||||
{
|
||||
m_val = (float)val;
|
||||
m_val = static_cast<float>(val);
|
||||
m_binit = true;
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ void CBotVarFloat::SetValFloat(float val)
|
|||
|
||||
int CBotVarFloat::GetValInt()
|
||||
{
|
||||
return (int)m_val;
|
||||
return static_cast<int>(m_val);
|
||||
}
|
||||
|
||||
float CBotVarFloat::GetValFloat()
|
||||
|
@ -1123,7 +1123,7 @@ void CBotVarFloat::Mul(CBotVar* left, CBotVar* right)
|
|||
|
||||
void CBotVarFloat::Power(CBotVar* left, CBotVar* right)
|
||||
{
|
||||
m_val = (float)pow( left->GetValFloat() , right->GetValFloat() );
|
||||
m_val = static_cast<float>(pow( left->GetValFloat() , right->GetValFloat() ));
|
||||
m_binit = true;
|
||||
}
|
||||
|
||||
|
@ -1143,7 +1143,7 @@ int CBotVarFloat::Modulo(CBotVar* left, CBotVar* right)
|
|||
float r = right->GetValFloat();
|
||||
if ( r != 0 )
|
||||
{
|
||||
m_val = (float)fmod( left->GetValFloat() , r );
|
||||
m_val = static_cast<float>(fmod( left->GetValFloat() , r ));
|
||||
m_binit = true;
|
||||
}
|
||||
return ( r == 0 ? TX_DIVZERO : 0 );
|
||||
|
@ -1213,7 +1213,7 @@ bool CBotVarFloat::Ne(CBotVar* left, CBotVar* right)
|
|||
// copy a variable into another
|
||||
void CBotVarBoolean::Copy(CBotVar* pSrc, bool bName)
|
||||
{
|
||||
CBotVarBoolean* p = (CBotVarBoolean*)pSrc;
|
||||
CBotVarBoolean* p = static_cast<CBotVarBoolean*>(pSrc);
|
||||
|
||||
if (bName) *m_token = *p->m_token;
|
||||
m_type = p->m_type;
|
||||
|
@ -1233,13 +1233,13 @@ void CBotVarBoolean::Copy(CBotVar* pSrc, bool bName)
|
|||
|
||||
void CBotVarBoolean::SetValInt(int val, const char* s)
|
||||
{
|
||||
m_val = (bool)val;
|
||||
m_val = static_cast<bool>(val);
|
||||
m_binit = true;
|
||||
}
|
||||
|
||||
void CBotVarBoolean::SetValFloat(float val)
|
||||
{
|
||||
m_val = (bool)val;
|
||||
m_val = static_cast<bool>(val);
|
||||
m_binit = true;
|
||||
}
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ int CBotVarBoolean::GetValInt()
|
|||
|
||||
float CBotVarBoolean::GetValFloat()
|
||||
{
|
||||
return (float)m_val;
|
||||
return static_cast<float>(m_val);
|
||||
}
|
||||
|
||||
CBotString CBotVarBoolean::GetValString()
|
||||
|
@ -1311,7 +1311,7 @@ bool CBotVarBoolean::Ne(CBotVar* left, CBotVar* right)
|
|||
// copy a variable into another
|
||||
void CBotVarString::Copy(CBotVar* pSrc, bool bName)
|
||||
{
|
||||
CBotVarString* p = (CBotVarString*)pSrc;
|
||||
CBotVarString* p = static_cast<CBotVarString*>(pSrc);
|
||||
|
||||
if (bName) *m_token = *p->m_token;
|
||||
m_type = p->m_type;
|
||||
|
@ -1400,7 +1400,7 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName)
|
|||
if ( pSrc->GetType() != CBotTypClass )
|
||||
ASM_TRAP();
|
||||
|
||||
CBotVarClass* p = (CBotVarClass*)pSrc;
|
||||
CBotVarClass* p = static_cast<CBotVarClass*>(pSrc);
|
||||
|
||||
if (bName) *m_token = *p->m_token;
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ void CBotVarClass::Copy(CBotVar* pSrc, bool bName)
|
|||
m_pClass = p->m_pClass;
|
||||
if ( p->m_pParent )
|
||||
{
|
||||
ASM_TRAP(); "que faire du pParent";
|
||||
ASM_TRAP(); // "que faire du pParent";
|
||||
}
|
||||
|
||||
// m_next = NULL;
|
||||
|
@ -1793,7 +1793,7 @@ void CBotVarArray::Copy(CBotVar* pSrc, bool bName)
|
|||
if ( pSrc->GetType() != CBotTypArrayPointer )
|
||||
ASM_TRAP();
|
||||
|
||||
CBotVarArray* p = (CBotVarArray*)pSrc;
|
||||
CBotVarArray* p = static_cast<CBotVarArray*>(pSrc);
|
||||
|
||||
if ( bName) *m_token = *p->m_token;
|
||||
m_type = p->m_type;
|
||||
|
@ -1827,11 +1827,11 @@ void CBotVarArray::SetPointer(CBotVar* pVarClass)
|
|||
!pVarClass->m_type.Eq(CBotTypArrayBody))
|
||||
ASM_TRAP();
|
||||
|
||||
((CBotVarClass*)pVarClass)->IncrementUse(); // incement the reference
|
||||
(static_cast<CBotVarClass*>(pVarClass))->IncrementUse(); // incement the reference
|
||||
}
|
||||
|
||||
if ( m_pInstance != NULL ) m_pInstance->DecrementUse();
|
||||
m_pInstance = (CBotVarClass*)pVarClass;
|
||||
m_pInstance = static_cast<CBotVarClass*>(pVarClass);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1967,14 +1967,14 @@ void CBotVarPointer::SetPointer(CBotVar* pVarClass)
|
|||
if ( !pVarClass->m_type.Eq(CBotTypClass) )
|
||||
ASM_TRAP();
|
||||
|
||||
((CBotVarClass*)pVarClass)->IncrementUse(); // increment the reference
|
||||
m_pClass = ((CBotVarClass*)pVarClass)->m_pClass;
|
||||
(static_cast<CBotVarClass*>(pVarClass))->IncrementUse(); // increment the reference
|
||||
m_pClass = (static_cast<CBotVarClass*>(pVarClass))->m_pClass;
|
||||
m_pUserPtr = pVarClass->m_pUserPtr; // not really necessary
|
||||
m_type = CBotTypResult(CBotTypPointer, m_pClass); // what kind of a pointer
|
||||
}
|
||||
|
||||
if ( m_pVarClass != NULL ) m_pVarClass->DecrementUse();
|
||||
m_pVarClass = (CBotVarClass*)pVarClass;
|
||||
m_pVarClass = static_cast<CBotVarClass*>(pVarClass);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2036,7 +2036,7 @@ void CBotVarPointer::Copy(CBotVar* pSrc, bool bName)
|
|||
pSrc->GetType() != CBotTypNullPointer)
|
||||
ASM_TRAP();
|
||||
|
||||
CBotVarPointer* p = (CBotVarPointer*)pSrc;
|
||||
CBotVarPointer* p = static_cast<CBotVarPointer*>(pSrc);
|
||||
|
||||
if ( bName) *m_token = *p->m_token;
|
||||
m_type = p->m_type;
|
||||
|
|
|
@ -1132,7 +1132,7 @@ bool CBotTry :: Execute(CBotStack* &pj)
|
|||
// see what it returns
|
||||
|
||||
CBotCatch* pc = m_ListCatch;
|
||||
int state = (short)pile1->GetState(); // where were we?
|
||||
int state = static_cast<short>(pile1->GetState()); // where were we?
|
||||
val = pile2->GetState(); // what error?
|
||||
pile0->SetState(1); // marking the GetRunPos
|
||||
|
||||
|
@ -1315,7 +1315,7 @@ bool CBotCatch :: TestCatch(CBotStack* &pile, int val)
|
|||
|
||||
if ( val > 0 || pile->GetType() != CBotTypBoolean )
|
||||
{
|
||||
CBotVar* var = CBotVar::Create((CBotToken*)NULL, CBotTypBoolean);
|
||||
CBotVar* var = CBotVar::Create(static_cast<CBotToken*>(NULL), CBotTypBoolean);
|
||||
var->SetValInt( pile->GetVal() == val );
|
||||
pile->SetVar(var); // calls on the stack
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue